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

@ -730,11 +730,7 @@ where
Component::AttributeInNoNamespaceExists {
ref local_name,
ref local_name_lower,
} => element.attr_matches(
&NamespaceConstraint::Specific(&crate::parser::namespace_empty_string::<E::Impl>()),
select_name(element, local_name, local_name_lower),
&AttrSelectorOperation::Exists,
),
} => element.has_attr_in_no_namespace(select_name(element, local_name, local_name_lower)),
Component::AttributeInNoNamespace {
ref local_name,
ref value,

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,