mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Constrain the ConcreteLayoutFoo associated types to provide full tri-ality among the types.
Otherwise we end up with this problem: http://is.gd/ACBLAU
This commit is contained in:
parent
2dab0e1584
commit
2cfe4de09b
1 changed files with 16 additions and 9 deletions
|
@ -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<T> PseudoElementType<T> {
|
|||
/// 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<Self>;
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue