style: Add a way to optimize the "attribute in no namespace exists" check

Go through the slow path by default. No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D180528
This commit is contained in:
Emilio Cobos Álvarez 2023-06-14 21:08:21 +00:00 committed by Martin Robinson
parent c36a22a97f
commit 54a783db17
2 changed files with 12 additions and 5 deletions

View file

@ -80,6 +80,17 @@ pub trait Element: Sized + Clone + Debug {
operation: &AttrSelectorOperation<&<Self::Impl as SelectorImpl>::AttrValue>,
) -> bool;
fn has_attr_in_no_namespace(
&self,
local_name: &<Self::Impl as SelectorImpl>::LocalName,
) -> bool {
self.attr_matches(
&NamespaceConstraint::Specific(&crate::parser::namespace_empty_string::<Self::Impl>()),
local_name,
&AttrSelectorOperation::Exists,
)
}
fn match_non_ts_pseudo_class(
&self,
pc: &<Self::Impl as SelectorImpl>::NonTSPseudoClass,