mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +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`.
|
/// only ever see these and must never see instances of `LayoutJS`.
|
||||||
|
|
||||||
pub trait LayoutNode<'ln> : Sized + Copy + Clone {
|
pub trait LayoutNode<'ln> : Sized + Copy + Clone {
|
||||||
type ConcreteLayoutElement: LayoutElement<'ln>;
|
type ConcreteLayoutElement: LayoutElement<'ln, ConcreteLayoutNode = Self,
|
||||||
type ConcreteLayoutDocument: LayoutDocument<'ln>;
|
ConcreteLayoutDocument = Self::ConcreteLayoutDocument>;
|
||||||
|
type ConcreteLayoutDocument: LayoutDocument<'ln, ConcreteLayoutNode = Self,
|
||||||
|
ConcreteLayoutElement = Self::ConcreteLayoutElement>;
|
||||||
|
|
||||||
/// Returns the type ID of this node.
|
/// Returns the type ID of this node.
|
||||||
fn type_id(&self) -> NodeTypeId;
|
fn type_id(&self) -> NodeTypeId;
|
||||||
|
@ -162,8 +164,10 @@ pub trait LayoutNode<'ln> : Sized + Copy + Clone {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait LayoutDocument<'ld> : Sized + Copy + Clone {
|
pub trait LayoutDocument<'ld> : Sized + Copy + Clone {
|
||||||
type ConcreteLayoutNode: LayoutNode<'ld>;
|
type ConcreteLayoutNode: LayoutNode<'ld, ConcreteLayoutElement = Self::ConcreteLayoutElement,
|
||||||
type ConcreteLayoutElement: LayoutElement<'ld>;
|
ConcreteLayoutDocument = Self>;
|
||||||
|
type ConcreteLayoutElement: LayoutElement<'ld, ConcreteLayoutNode = Self::ConcreteLayoutNode,
|
||||||
|
ConcreteLayoutDocument = Self>;
|
||||||
|
|
||||||
fn as_node(&self) -> Self::ConcreteLayoutNode;
|
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 {
|
pub trait LayoutElement<'le> : Sized + Copy + Clone + ::selectors::Element + TElementAttributes {
|
||||||
type ConcreteLayoutNode: LayoutNode<'le>;
|
type ConcreteLayoutNode: LayoutNode<'le, ConcreteLayoutElement = Self,
|
||||||
type ConcreteLayoutDocument: LayoutDocument<'le>;
|
ConcreteLayoutDocument = Self::ConcreteLayoutDocument>;
|
||||||
|
type ConcreteLayoutDocument: LayoutDocument<'le, ConcreteLayoutNode = Self::ConcreteLayoutNode,
|
||||||
|
ConcreteLayoutElement = Self>;
|
||||||
|
|
||||||
fn as_node(&self) -> Self::ConcreteLayoutNode;
|
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.
|
/// node does not allow any parents or siblings of nodes to be accessed, to avoid races.
|
||||||
|
|
||||||
pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized {
|
pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized {
|
||||||
type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'ln>;
|
type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'ln, ConcreteThreadSafeLayoutNode = Self>;
|
||||||
|
|
||||||
/// Converts self into an `OpaqueNode`.
|
/// Converts self into an `OpaqueNode`.
|
||||||
fn opaque(&self) -> OpaqueNode;
|
fn opaque(&self) -> OpaqueNode;
|
||||||
|
@ -947,8 +953,8 @@ trait DangerousThreadSafeLayoutNode<'ln> : ThreadSafeLayoutNode<'ln> {
|
||||||
unsafe fn dangerous_next_sibling(&self) -> Option<Self>;
|
unsafe fn dangerous_next_sibling(&self) -> Option<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ThreadSafeLayoutElement<'le> {
|
pub trait ThreadSafeLayoutElement<'le>: Clone + Copy + Sized {
|
||||||
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'le>;
|
type ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode<'le, ConcreteThreadSafeLayoutElement = Self>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_attr(&self, namespace: &Namespace, name: &Atom) -> Option<&'le str>;
|
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
|
/// A wrapper around elements that ensures layout can only ever access safe properties and cannot
|
||||||
/// race on elements.
|
/// race on elements.
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub struct ServoThreadSafeLayoutElement<'le> {
|
pub struct ServoThreadSafeLayoutElement<'le> {
|
||||||
element: &'le Element,
|
element: &'le Element,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue