LibWeb: Port all callers of Element::namespace to Element::namespace_uri

Removing some more use of DeprecatedFlyString
This commit is contained in:
Shannon Booth 2023-11-05 13:12:53 +13:00 committed by Andreas Kling
parent f2e77f7778
commit 326b34c7c7
4 changed files with 5 additions and 7 deletions

View file

@ -562,10 +562,10 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, Optio
if (!style_sheet_for_rule.has_value() || !style_sheet_for_rule->default_namespace().has_value())
return true;
// "Otherwise it is equivalent to ns|E where ns is the default namespace."
return element.namespace_() == style_sheet_for_rule->default_namespace();
return element.namespace_uri() == style_sheet_for_rule->default_namespace();
case CSS::Selector::SimpleSelector::QualifiedName::NamespaceType::None:
// "elements with name E without a namespace"
return element.namespace_().is_empty();
return !element.namespace_uri().has_value();
case CSS::Selector::SimpleSelector::QualifiedName::NamespaceType::Any:
// "elements with name E in any namespace, including those without a namespace"
return true;
@ -578,7 +578,7 @@ static inline bool matches(CSS::Selector::SimpleSelector const& component, Optio
return false;
auto selector_namespace = style_sheet_for_rule->namespace_uri(qualified_name.namespace_);
return selector_namespace.has_value() && selector_namespace.value() == element.namespace_();
return selector_namespace.has_value() && selector_namespace.value() == element.namespace_uri();
}
VERIFY_NOT_REACHED();
}

View file

@ -90,8 +90,6 @@ public:
void set_prefix(Optional<FlyString> value);
DeprecatedFlyString namespace_() const { return m_qualified_name.deprecated_namespace_(); }
// NOTE: This is for the JS bindings
Optional<FlyString> const& namespace_uri() const { return m_qualified_name.namespace_(); }

View file

@ -1379,7 +1379,7 @@ bool Node::is_equal_node(Node const* other_node) const
// Its namespace, namespace prefix, local name, and its attribute lists size.
auto& this_element = verify_cast<Element>(*this);
auto& other_element = verify_cast<Element>(*other_node);
if (this_element.namespace_() != other_element.namespace_()
if (this_element.namespace_uri() != other_element.namespace_uri()
|| this_element.prefix() != other_element.prefix()
|| this_element.local_name() != other_element.local_name()
|| this_element.attribute_list_size() != other_element.attribute_list_size())

View file

@ -3915,7 +3915,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
// Otherwise, let tagname be current node's qualified name.
FlyString tag_name;
if (element.namespace_().is_one_of(Namespace::HTML, Namespace::MathML, Namespace::SVG))
if (element.namespace_uri().has_value() && element.namespace_uri()->is_one_of(Namespace::HTML, Namespace::MathML, Namespace::SVG))
tag_name = element.local_name();
else
tag_name = element.qualified_name();