mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Handle style attributes in element setter instead of html parser
This commit is contained in:
parent
eadda9411b
commit
2ad350531a
4 changed files with 16 additions and 13 deletions
|
@ -47,6 +47,7 @@ use js::jsapi::{JSContext, JSObject};
|
|||
use std::cell::Cell;
|
||||
use std::comm;
|
||||
use std::str::eq_slice;
|
||||
use extra::net::url;
|
||||
|
||||
pub struct Element {
|
||||
parent: Node<ScriptView>,
|
||||
|
@ -262,8 +263,7 @@ impl<'self> Element {
|
|||
|
||||
pub fn set_attr(&mut self, name: &DOMString, value: &DOMString) {
|
||||
let name = name.to_str();
|
||||
let value = value.to_str();
|
||||
let value_cell = Cell::new(value);
|
||||
let value_cell = Cell::new(value.to_str());
|
||||
let mut found = false;
|
||||
for self.attrs.mut_iter().advance |attr| {
|
||||
if eq_slice(attr.name, name) {
|
||||
|
@ -276,6 +276,13 @@ impl<'self> Element {
|
|||
self.attrs.push(Attr::new(name.to_str(), value_cell.take().clone()));
|
||||
}
|
||||
|
||||
if "style" == name {
|
||||
self.style_attribute = Some(
|
||||
Stylesheet::from_attribute(
|
||||
url::from_str("http://www.example.com/").unwrap(),
|
||||
value.get_ref()));
|
||||
}
|
||||
|
||||
match self.parent.owner_doc {
|
||||
Some(owner) => do owner.with_base |owner| { owner.content_changed() },
|
||||
None => {}
|
||||
|
@ -312,7 +319,7 @@ impl Element {
|
|||
null_string
|
||||
}
|
||||
|
||||
pub fn SetAttribute(&self, _name: &DOMString, _value: &DOMString, _rv: &mut ErrorResult) {
|
||||
pub fn SetAttribute(&mut self, _name: &DOMString, _value: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn SetAttributeNS(&self, _namespace: &DOMString, _localname: &DOMString, _value: &DOMString, _rv: &mut ErrorResult) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue