style: Avoid some allocations in selector serialization.

The allocations in display_to_css_identifier show up in the profiles of
bug 1675628.

Differential Revision: https://phabricator.services.mozilla.com/D97856
This commit is contained in:
Emilio Cobos Álvarez 2020-11-22 01:02:22 +00:00
parent 4ea378a6ae
commit 9f40b9ba38
19 changed files with 220 additions and 114 deletions

View file

@ -20,7 +20,8 @@ use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl};
use crate::shared_lock::{Locked, SharedRwLock};
use crate::stylist::CascadeData;
use crate::traversal_flags::TraversalFlags;
use crate::{Atom, LocalName, Namespace, WeakAtom};
use crate::values::AtomIdent;
use crate::{LocalName, Namespace, WeakAtom};
use atomic_refcell::{AtomicRef, AtomicRefMut};
use selectors::matching::{ElementSelectorFlags, QuirksMode, VisitedHandlingMode};
use selectors::sink::Push;
@ -121,7 +122,7 @@ pub trait TDocument: Sized + Copy + Clone {
/// return an empty slice.
fn elements_with_id<'a>(
&self,
_id: &Atom,
_id: &AtomIdent,
) -> Result<&'a [<Self::ConcreteNode as TNode>::ConcreteElement], ()>
where
Self: 'a,
@ -344,7 +345,7 @@ pub trait TShadowRoot: Sized + Copy + Clone + Debug + PartialEq {
/// return an empty slice.
fn elements_with_id<'a>(
&self,
_id: &Atom,
_id: &AtomIdent,
) -> Result<&'a [<Self::ConcreteNode as TNode>::ConcreteElement], ()>
where
Self: 'a,
@ -520,20 +521,20 @@ pub trait TElement:
/// Internal iterator for the classes of this element.
fn each_class<F>(&self, callback: F)
where
F: FnMut(&Atom);
F: FnMut(&AtomIdent);
/// Internal iterator for the part names of this element.
fn each_part<F>(&self, _callback: F)
where
F: FnMut(&Atom),
F: FnMut(&AtomIdent),
{
}
/// Internal iterator for the part names that this element exports for a
/// given part name.
fn each_exported_part<F>(&self, _name: &Atom, _callback: F)
fn each_exported_part<F>(&self, _name: &AtomIdent, _callback: F)
where
F: FnMut(&Atom),
F: FnMut(&AtomIdent),
{
}