diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 6b93514ad6e..b4e78319135 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -383,11 +383,9 @@ pub struct LayoutElement<'le> { impl<'le> LayoutElement<'le> { pub fn style_attribute(&self) -> &'le Option { - use script::dom::element::ElementHelpers; - let style: &Option = unsafe { - &*(*self.element.unsafe_get()).style_attribute().borrow_for_layout() - }; - style + unsafe { + &*self.element.style_attribute() + } } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index ff9864c88b8..85fe33aa5b5 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -511,6 +511,7 @@ pub trait LayoutElementHelpers { unsafe fn html_element_in_html_document_for_layout(&self) -> bool; #[allow(unsafe_code)] unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool; + fn style_attribute(&self) -> *const Option; } impl LayoutElementHelpers for LayoutJS { @@ -528,6 +529,13 @@ impl LayoutElementHelpers for LayoutJS { unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool { get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some() } + + #[allow(unsafe_code)] + fn style_attribute(&self) -> *const Option { + unsafe { + (*self.unsafe_get()).style_attribute.borrow_for_layout() + } + } } #[derive(PartialEq)]