diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2023-06-14 21:08:21 +0000 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-11-24 08:57:14 +0100 |
commit | 54a783db1746efe4e5c8775cc7cfb69e765c2fb5 (patch) | |
tree | 5968d4ca580eecf32439343ef931faeb2e688404 | |
parent | c36a22a97fa0d28ef5ed787f03e2da9cb93f0bba (diff) | |
download | servo-54a783db1746efe4e5c8775cc7cfb69e765c2fb5.tar.gz servo-54a783db1746efe4e5c8775cc7cfb69e765c2fb5.zip |
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
-rw-r--r-- | components/selectors/matching.rs | 6 | ||||
-rw-r--r-- | components/selectors/tree.rs | 11 |
2 files changed, 12 insertions, 5 deletions
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index f347dc4078e..6a603f10abd 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -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, diff --git a/components/selectors/tree.rs b/components/selectors/tree.rs index fa150def0d6..560b1e61d81 100644 --- a/components/selectors/tree.rs +++ b/components/selectors/tree.rs @@ -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, |