Browse Source

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

Removing some more use of DeprecatedFlyString
Shannon Booth 1 year ago
parent
commit
326b34c7c7

+ 3 - 3
Userland/Libraries/LibWeb/CSS/SelectorEngine.cpp

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

+ 0 - 2
Userland/Libraries/LibWeb/DOM/Element.h

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

+ 1 - 1
Userland/Libraries/LibWeb/DOM/Node.cpp

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

+ 1 - 1
Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp

@@ -3915,7 +3915,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node)
             //    Otherwise, let tagname be current node's qualified name.
             //    Otherwise, let tagname be current node's qualified name.
             FlyString tag_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();
                 tag_name = element.local_name();
             else
             else
                 tag_name = element.qualified_name();
                 tag_name = element.qualified_name();