mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Optimize QuerySelector in shadow trees.
Pretty much the same setup we have for document. We have the awkwardness of having to check containing shadow manually for ShadowRoot because it's not available in TNode (and making it available added a bit more complexity that wasn't worth it IMO). Bug: 1464428 Reviewed-by: xidorn MozReview-Commit-ID: CqOh0sLHf6o
This commit is contained in:
parent
82e97b8ec5
commit
38cbada278
3 changed files with 103 additions and 42 deletions
|
@ -135,14 +135,17 @@ pub trait TDocument: Sized + Copy + Clone {
|
|||
fn quirks_mode(&self) -> QuirksMode;
|
||||
|
||||
/// Get a list of elements with a given ID in this document, sorted by
|
||||
/// document position.
|
||||
/// tree position.
|
||||
///
|
||||
/// Can return an error to signal that this list is not available, or also
|
||||
/// return an empty slice.
|
||||
fn elements_with_id(
|
||||
fn elements_with_id<'a>(
|
||||
&self,
|
||||
_id: &Atom,
|
||||
) -> Result<&[<Self::ConcreteNode as TNode>::ConcreteElement], ()> {
|
||||
) -> Result<&'a [<Self::ConcreteNode as TNode>::ConcreteElement], ()>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
@ -342,6 +345,21 @@ pub trait TShadowRoot: Sized + Copy + Clone + PartialEq {
|
|||
fn style_data<'a>(&self) -> &'a CascadeData
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
/// Get a list of elements with a given ID in this shadow root, sorted by
|
||||
/// tree position.
|
||||
///
|
||||
/// Can return an error to signal that this list is not available, or also
|
||||
/// return an empty slice.
|
||||
fn elements_with_id<'a>(
|
||||
&self,
|
||||
_id: &Atom,
|
||||
) -> Result<&'a [<Self::ConcreteNode as TNode>::ConcreteElement], ()>
|
||||
where
|
||||
Self: 'a,
|
||||
{
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
/// The element trait, the main abstraction the style crate acts over.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue