diff options
-rw-r--r-- | components/layout/construct.rs | 2 | ||||
-rw-r--r-- | components/layout/css/node_style.rs | 18 | ||||
-rw-r--r-- | components/layout/lib.rs | 1 |
3 files changed, 10 insertions, 11 deletions
diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 746ecef1e6b..aad12f4e770 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -667,7 +667,7 @@ impl<'a> FlowConstructor<'a> { self.create_fragments_for_node_text_content(&mut initial_fragments, node, - node.style()); + &*node.style()); } self.build_flow_for_block_starting_with_fragments(flow, node, initial_fragments) diff --git a/components/layout/css/node_style.rs b/components/layout/css/node_style.rs index 5f513a19399..1a5c1a74933 100644 --- a/components/layout/css/node_style.rs +++ b/components/layout/css/node_style.rs @@ -7,16 +7,17 @@ use data::LayoutDataWrapper; use wrapper::{PseudoElementType, ThreadSafeLayoutNode}; -use std::mem; use style::properties::ComputedValues; + +use std::cell::Ref; use std::sync::Arc; /// Node mixin providing `style` method that returns a `NodeStyle` pub trait StyledNode { - fn get_style<'a>(&'a self, layout_data_ref: &'a LayoutDataWrapper) -> &'a Arc<ComputedValues>; + fn get_style<'a>(&self, layout_data_ref: &'a LayoutDataWrapper) -> &'a Arc<ComputedValues>; /// Returns the style results for the given node. If CSS selector matching has not yet been /// performed, fails. - fn style<'a>(&'a self) -> &'a Arc<ComputedValues>; + fn style<'a>(&'a self) -> Ref<'a, Arc<ComputedValues>>; /// Does this node have a computed style yet? fn has_style(&self) -> bool; /// Removes the style from this node. @@ -34,14 +35,11 @@ impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> { } #[inline] - #[allow(unsafe_code)] - fn style<'a>(&'a self) -> &'a Arc<ComputedValues> { - unsafe { - let layout_data_ref = self.borrow_layout_data(); + fn style<'a>(&'a self) -> Ref<'a, Arc<ComputedValues>> { + Ref::map(self.borrow_layout_data(), |layout_data_ref| { let layout_data = layout_data_ref.as_ref().expect("no layout data"); - mem::transmute::<&Arc<ComputedValues>, - &'a Arc<ComputedValues>>(self.get_style(&layout_data)) - } + self.get_style(layout_data) + }) } fn has_style(&self) -> bool { diff --git a/components/layout/lib.rs b/components/layout/lib.rs index f16272f0d22..9bb10cdd93c 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -5,6 +5,7 @@ #![feature(append)] #![feature(arc_unique)] #![feature(box_syntax)] +#![feature(cell_extras)] #![feature(custom_derive)] #![feature(filling_drop)] #![feature(hashmap_hasher)] |