mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Introduce a TDocument trait.
This will be useful for querySelector optimizations.
This commit is contained in:
parent
6c796b50ec
commit
4d4fa69018
3 changed files with 58 additions and 9 deletions
|
@ -133,12 +133,24 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// The `TDocument` trait, to represent a document node.
|
||||
pub trait TDocument : Sized + Copy + Clone {
|
||||
/// The concrete `TNode` type.
|
||||
type ConcreteNode: TNode<ConcreteDocument = Self>;
|
||||
|
||||
/// Get this document as a `TNode`.
|
||||
fn as_node(&self) -> Self::ConcreteNode;
|
||||
}
|
||||
|
||||
/// The `TNode` trait. This is the main generic trait over which the style
|
||||
/// system can be implemented.
|
||||
pub trait TNode : Sized + Copy + Clone + Debug + NodeInfo + PartialEq {
|
||||
/// The concrete `TElement` type.
|
||||
type ConcreteElement: TElement<ConcreteNode = Self>;
|
||||
|
||||
/// The concrete `TDocument` type.
|
||||
type ConcreteDocument: TDocument<ConcreteNode = Self>;
|
||||
|
||||
/// Get this node's parent node.
|
||||
fn parent_node(&self) -> Option<Self>;
|
||||
|
||||
|
@ -211,6 +223,9 @@ pub trait TNode : Sized + Copy + Clone + Debug + NodeInfo + PartialEq {
|
|||
/// Get this node as an element, if it's one.
|
||||
fn as_element(&self) -> Option<Self::ConcreteElement>;
|
||||
|
||||
/// Get this node as a document, if it's one.
|
||||
fn as_document(&self) -> Option<Self::ConcreteDocument>;
|
||||
|
||||
/// Whether this node can be fragmented. This is used for multicol, and only
|
||||
/// for Servo.
|
||||
fn can_be_fragmented(&self) -> bool;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue