diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 828d9bf778d..b26bd79d95d 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -75,8 +75,10 @@ use util::str::{is_whitespace, search_index}; /// only ever see these and must never see instances of `LayoutJS`. pub trait LayoutNode<'ln> : Sized + Copy + Clone { - type ConcreteLayoutElement: LayoutElement<'ln>; - type ConcreteLayoutDocument: LayoutDocument<'ln>; + type ConcreteLayoutElement: LayoutElement<'ln, ConcreteLayoutNode = Self, + ConcreteLayoutDocument = Self::ConcreteLayoutDocument>; + type ConcreteLayoutDocument: LayoutDocument<'ln, ConcreteLayoutNode = Self, + ConcreteLayoutElement = Self::ConcreteLayoutElement>; /// Returns the type ID of this node. fn type_id(&self) -> NodeTypeId; @@ -162,8 +164,10 @@ pub trait LayoutNode<'ln> : Sized + Copy + Clone { } pub trait LayoutDocument<'ld> : Sized + Copy + Clone { - type ConcreteLayoutNode: LayoutNode<'ld>; - type ConcreteLayoutElement: LayoutElement<'ld>; + type ConcreteLayoutNode: LayoutNode<'ld, ConcreteLayoutElement = Self::ConcreteLayoutElement, + ConcreteLayoutDocument = Self>; + type ConcreteLayoutElement: LayoutElement<'ld, ConcreteLayoutNode = Self::ConcreteLayoutNode, + ConcreteLayoutDocument = Self>; fn as_node(&self) -> Self::ConcreteLayoutNode; @@ -173,8 +177,10 @@ pub trait LayoutDocument<'ld> : Sized + Copy + Clone { } pub trait LayoutElement<'le> : Sized + Copy + Clone + ::selectors::Element + TElementAttributes { - type ConcreteLayoutNode: LayoutNode<'le>; - type ConcreteLayoutDocument: LayoutDocument<'le>; + type ConcreteLayoutNode: LayoutNode<'le, ConcreteLayoutElement = Self, + ConcreteLayoutDocument = Self::ConcreteLayoutDocument>; + type ConcreteLayoutDocument: LayoutDocument<'le, ConcreteLayoutNode = Self::ConcreteLayoutNode, + ConcreteLayoutElement = Self>; fn as_node(&self) -> Self::ConcreteLayoutNode; @@ -799,7 +805,7 @@ impl PseudoElementType { /// node does not allow any parents or siblings of nodes to be accessed, to avoid races. pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized { - type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'ln>; + type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'ln, ConcreteThreadSafeLayoutNode = Self>; /// Converts self into an `OpaqueNode`. fn opaque(&self) -> OpaqueNode; @@ -947,8 +953,8 @@ trait DangerousThreadSafeLayoutNode<'ln> : ThreadSafeLayoutNode<'ln> { unsafe fn dangerous_next_sibling(&self) -> Option; } -pub trait ThreadSafeLayoutElement<'le> { - type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'le>; +pub trait ThreadSafeLayoutElement<'le>: Clone + Copy + Sized { + type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'le, ConcreteThreadSafeLayoutElement = Self>; #[inline] fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&'le str>; @@ -1258,6 +1264,7 @@ impl<'ln, ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<'ln, C /// A wrapper around elements that ensures layout can only ever access safe properties and cannot /// race on elements. +#[derive(Copy, Clone)] pub struct ServoThreadSafeLayoutElement<'le> { element: &'le Element, }