aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/main/layout/wrapper.rs9
-rw-r--r--src/components/script/dom/element.rs12
2 files changed, 13 insertions, 8 deletions
diff --git a/src/components/main/layout/wrapper.rs b/src/components/main/layout/wrapper.rs
index b6a475af271..6a2cdac2331 100644
--- a/src/components/main/layout/wrapper.rs
+++ b/src/components/main/layout/wrapper.rs
@@ -50,7 +50,7 @@ use servo_msg::constellation_msg::{PipelineId, SubpageId};
use servo_util::namespace::Namespace;
use servo_util::namespace;
use servo_util::str::is_whitespace;
-use std::cell::{Ref, RefMut};
+use std::cell::{RefCell, Ref, RefMut};
use std::kinds::marker::ContravariantLifetime;
use std::mem;
use style::computed_values::{content, display, white_space};
@@ -355,7 +355,12 @@ pub struct LayoutElement<'le> {
impl<'le> LayoutElement<'le> {
pub fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
- &self.element.style_attribute
+ let style: &Option<PropertyDeclarationBlock> = unsafe {
+ let style: &RefCell<Option<PropertyDeclarationBlock>> = self.element.style_attribute.deref();
+ // cast to the direct reference to T placed on the head of RefCell<T>
+ mem::transmute(style)
+ };
+ style
}
}
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 3189360ccf5..742463b597e 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -10,6 +10,7 @@ use dom::bindings::codegen::Bindings::ElementBinding;
use dom::bindings::codegen::InheritTypes::{ElementDerived, NodeCast};
use dom::bindings::js::{JS, JSRef, Temporary, TemporaryPushable};
use dom::bindings::js::{OptionalSettable, OptionalRootable, Root};
+use dom::bindings::trace::Traceable;
use dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::error::{ErrorResult, Fallible, NamespaceError, InvalidCharacter};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
@@ -40,7 +41,7 @@ pub struct Element {
pub namespace: Namespace,
pub prefix: Option<DOMString>,
pub attrs: RefCell<Vec<JS<Attr>>>,
- pub style_attribute: Option<style::PropertyDeclarationBlock>,
+ pub style_attribute: Traceable<RefCell<Option<style::PropertyDeclarationBlock>>>,
pub attr_list: Cell<Option<JS<AttrList>>>
}
@@ -149,7 +150,7 @@ impl Element {
prefix: prefix,
attrs: RefCell::new(vec!()),
attr_list: Cell::new(None),
- style_attribute: None,
+ style_attribute: Traceable::new(RefCell::new(None)),
}
}
@@ -747,8 +748,8 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
"style" => {
let doc = document_from_node(self).root();
let base_url = doc.deref().url().clone();
- let mut self_alias = self.clone();
- self_alias.deref_mut().style_attribute = Some(style::parse_style_attribute(value.as_slice(), &base_url))
+ let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
+ *self.deref().style_attribute.deref().borrow_mut() = style;
}
"id" => {
let node: &JSRef<Node> = NodeCast::from_ref(self);
@@ -771,8 +772,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
match name.as_slice() {
"style" => {
- let mut self_alias = self.clone();
- self_alias.deref_mut().style_attribute = None
+ *self.deref().style_attribute.deref().borrow_mut() = None;
}
"id" => {
let node: &JSRef<Node> = NodeCast::from_ref(self);