Przeglądaj źródła

LibWeb: Don't include DOM/Attr.h from DOM/Element.h

This required moving Element::for_each_attribute() out of line, but that
seems harmless enough.
Andreas Kling 2 lat temu
rodzic
commit
5b5fbecb38

+ 1 - 0
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -18,6 +18,7 @@
 #include <LibWeb/CSS/MediaQueryListEvent.h>
 #include <LibWeb/CSS/StyleComputer.h>
 #include <LibWeb/Cookie/ParsedCookie.h>
+#include <LibWeb/DOM/Attr.h>
 #include <LibWeb/DOM/Comment.h>
 #include <LibWeb/DOM/CustomEvent.h>
 #include <LibWeb/DOM/DOMImplementation.h>

+ 9 - 0
Userland/Libraries/LibWeb/DOM/Element.cpp

@@ -15,6 +15,7 @@
 #include <LibWeb/CSS/ResolvedCSSStyleDeclaration.h>
 #include <LibWeb/CSS/SelectorEngine.h>
 #include <LibWeb/CSS/StyleComputer.h>
+#include <LibWeb/DOM/Attr.h>
 #include <LibWeb/DOM/DOMTokenList.h>
 #include <LibWeb/DOM/Document.h>
 #include <LibWeb/DOM/Element.h>
@@ -1673,4 +1674,12 @@ void Element::set_prefix(DeprecatedFlyString const& value)
     m_qualified_name.set_prefix(value);
 }
 
+void Element::for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)> callback) const
+{
+    for (size_t i = 0; i < m_attributes->length(); ++i) {
+        auto const* attribute = m_attributes->item(i);
+        callback(attribute->name(), attribute->value());
+    }
+}
+
 }

+ 1 - 9
Userland/Libraries/LibWeb/DOM/Element.h

@@ -13,7 +13,6 @@
 #include <LibWeb/Bindings/ShadowRootPrototype.h>
 #include <LibWeb/Bindings/WindowGlobalMixin.h>
 #include <LibWeb/CSS/CSSStyleDeclaration.h>
-#include <LibWeb/DOM/Attr.h>
 #include <LibWeb/DOM/ChildNode.h>
 #include <LibWeb/DOM/NamedNodeMap.h>
 #include <LibWeb/DOM/NonDocumentTypeChildNode.h>
@@ -118,14 +117,7 @@ public:
     int client_width() const;
     int client_height() const;
 
-    template<typename Callback>
-    void for_each_attribute(Callback callback) const
-    {
-        for (size_t i = 0; i < m_attributes->length(); ++i) {
-            auto const* attribute = m_attributes->item(i);
-            callback(attribute->name(), attribute->value());
-        }
-    }
+    void for_each_attribute(Function<void(DeprecatedFlyString const&, DeprecatedString const&)>) const;
 
     bool has_class(FlyString const&, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
     Vector<FlyString> const& class_names() const { return m_classes; }

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

@@ -14,6 +14,7 @@
 #include <LibRegex/Regex.h>
 #include <LibWeb/Bindings/MainThreadVM.h>
 #include <LibWeb/Bindings/NodePrototype.h>
+#include <LibWeb/DOM/Attr.h>
 #include <LibWeb/DOM/Comment.h>
 #include <LibWeb/DOM/DocumentType.h>
 #include <LibWeb/DOM/Element.h>

+ 1 - 0
Userland/Libraries/LibWeb/DOMParsing/XMLSerializer.cpp

@@ -4,6 +4,7 @@
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
+#include <LibWeb/DOM/Attr.h>
 #include <LibWeb/DOM/CDATASection.h>
 #include <LibWeb/DOM/Comment.h>
 #include <LibWeb/DOM/Document.h>