LibWeb: Avoid FlyString copy when matching tag selector namespace URI

This commit is contained in:
Andreas Kling 2024-03-18 15:54:40 +01:00
parent e3e6af39bc
commit 22465e80fe
Notes: sideshowbarker 2024-07-17 08:55:54 +09:00

View File

@ -569,10 +569,10 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, Optio
switch (qualified_name.namespace_type) {
case CSS::Selector::SimpleSelector::QualifiedName::NamespaceType::Default:
// "if no default namespace has been declared for selectors, this is equivalent to *|E."
if (!style_sheet_for_rule.has_value() || !style_sheet_for_rule->default_namespace().has_value())
if (!style_sheet_for_rule.has_value() || !style_sheet_for_rule->default_namespace_rule())
return true;
// "Otherwise it is equivalent to ns|E where ns is the default namespace."
return element.namespace_uri() == style_sheet_for_rule->default_namespace();
return element.namespace_uri() == style_sheet_for_rule->default_namespace_rule()->namespace_uri();
case CSS::Selector::SimpleSelector::QualifiedName::NamespaceType::None:
// "elements with name E without a namespace"
return !element.namespace_uri().has_value();