diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 88c001ca4d6..5c81c5c1fb5 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -79,6 +79,8 @@ pub trait LayoutNode: TNode { /// Returns the type ID of this node. fn type_id(&self) -> NodeTypeId; + fn get_style_data(&self) -> Option<&RefCell>; + /// Similar to borrow_data*, but returns the full PrivateLayoutData rather /// than only the PrivateStyleData. unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData>; @@ -292,6 +294,14 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> { } } + fn get_style_data(&self) -> Option<&RefCell> { + unsafe { + self.get_jsmanaged().get_style_and_layout_data().map(|d| { + &**d.ptr + }) + } + } + unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData> { self.get_jsmanaged().get_style_and_layout_data().map(|opaque| { let container = *opaque.ptr as NonOpaqueStyleAndLayoutData; @@ -932,6 +942,8 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Sized + PartialEq { fn layer_id_for_overflow_scroll(&self) -> LayerId { LayerId::new_of_type(LayerType::OverflowScroll, self.opaque().id() as usize) } + + fn get_style_data(&self) -> Option<&RefCell>; } // This trait is only public so that it can be implemented by the gecko wrapper. @@ -1159,6 +1171,10 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> { self.get_jsmanaged().downcast::().unwrap().get_colspan() } } + + fn get_style_data(&self) -> Option<&RefCell> { + self.node.get_style_data() + } } pub struct ThreadSafeLayoutNodeChildrenIterator {