Ver código fonte

LibWeb: Move DOM classes into the Web::DOM namespace

LibWeb keeps growing and the Web namespace is filling up fast.
Let's put DOM stuff into Web::DOM, just like we already started doing
with SVG stuff in Web::SVG.
Andreas Kling 5 anos atrás
pai
commit
11ff9d0f17
100 arquivos alterados com 299 adições e 301 exclusões
  1. 5 5
      Applications/Browser/ConsoleWidget.cpp
  2. 1 1
      Applications/Browser/ConsoleWidget.h
  3. 4 4
      Applications/Browser/InspectorWidget.cpp
  4. 3 3
      Applications/Browser/InspectorWidget.h
  5. 5 5
      Applications/IRCClient/IRCLogBuffer.cpp
  6. 4 4
      Applications/IRCClient/IRCLogBuffer.h
  7. 1 1
      Applications/IRCClient/IRCWindow.cpp
  8. 1 1
      Libraries/LibWeb/Bindings/EventListenerWrapper.cpp
  9. 4 4
      Libraries/LibWeb/Bindings/EventListenerWrapper.h
  10. 2 2
      Libraries/LibWeb/Bindings/EventWrapperFactory.cpp
  11. 2 4
      Libraries/LibWeb/Bindings/EventWrapperFactory.h
  12. 7 7
      Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp
  13. 1 1
      Libraries/LibWeb/Bindings/NodeWrapperFactory.h
  14. 2 2
      Libraries/LibWeb/Bindings/WindowObject.cpp
  15. 4 4
      Libraries/LibWeb/Bindings/WindowObject.h
  16. 9 9
      Libraries/LibWeb/CSS/SelectorEngine.cpp
  17. 3 8
      Libraries/LibWeb/CSS/SelectorEngine.h
  18. 1 1
      Libraries/LibWeb/CSS/StyleProperties.cpp
  19. 1 1
      Libraries/LibWeb/CSS/StyleProperties.h
  20. 4 4
      Libraries/LibWeb/CSS/StyleResolver.cpp
  21. 7 12
      Libraries/LibWeb/CSS/StyleResolver.h
  22. 1 1
      Libraries/LibWeb/CSS/StyleSheetList.cpp
  23. 3 3
      Libraries/LibWeb/CSS/StyleSheetList.h
  24. 2 2
      Libraries/LibWeb/CSS/StyleValue.cpp
  25. 6 6
      Libraries/LibWeb/CSS/StyleValue.h
  26. 36 17
      Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp
  27. 1 1
      Libraries/LibWeb/DOM/CharacterData.cpp
  28. 3 3
      Libraries/LibWeb/DOM/CharacterData.h
  29. 1 1
      Libraries/LibWeb/DOM/Comment.cpp
  30. 3 3
      Libraries/LibWeb/DOM/Comment.h
  31. 2 2
      Libraries/LibWeb/DOM/Document.cpp
  32. 3 4
      Libraries/LibWeb/DOM/Document.h
  33. 3 3
      Libraries/LibWeb/DOM/DocumentFragment.h
  34. 1 1
      Libraries/LibWeb/DOM/DocumentType.cpp
  35. 3 3
      Libraries/LibWeb/DOM/DocumentType.h
  36. 1 1
      Libraries/LibWeb/DOM/Element.cpp
  37. 3 5
      Libraries/LibWeb/DOM/Element.h
  38. 1 1
      Libraries/LibWeb/DOM/ElementFactory.cpp
  39. 1 1
      Libraries/LibWeb/DOM/ElementFactory.h
  40. 1 1
      Libraries/LibWeb/DOM/Event.h
  41. 1 1
      Libraries/LibWeb/DOM/EventListener.cpp
  42. 1 1
      Libraries/LibWeb/DOM/EventListener.h
  43. 1 1
      Libraries/LibWeb/DOM/EventTarget.cpp
  44. 1 1
      Libraries/LibWeb/DOM/EventTarget.h
  45. 2 2
      Libraries/LibWeb/DOM/MouseEvent.h
  46. 1 1
      Libraries/LibWeb/DOM/Node.cpp
  47. 1 10
      Libraries/LibWeb/DOM/Node.h
  48. 1 1
      Libraries/LibWeb/DOM/NonElementParentNode.h
  49. 1 1
      Libraries/LibWeb/DOM/ParentNode.cpp
  50. 3 3
      Libraries/LibWeb/DOM/ParentNode.h
  51. 1 1
      Libraries/LibWeb/DOM/Text.cpp
  52. 3 3
      Libraries/LibWeb/DOM/Text.h
  53. 1 1
      Libraries/LibWeb/DOM/Timer.cpp
  54. 1 1
      Libraries/LibWeb/DOM/Timer.h
  55. 1 1
      Libraries/LibWeb/DOM/Window.cpp
  56. 1 1
      Libraries/LibWeb/DOM/Window.h
  57. 5 5
      Libraries/LibWeb/DOM/XMLHttpRequest.cpp
  58. 5 5
      Libraries/LibWeb/DOM/XMLHttpRequest.h
  59. 7 7
      Libraries/LibWeb/DOMTreeModel.cpp
  60. 4 5
      Libraries/LibWeb/DOMTreeModel.h
  61. 19 19
      Libraries/LibWeb/Dump.cpp
  62. 1 1
      Libraries/LibWeb/Dump.h
  63. 17 13
      Libraries/LibWeb/Forward.h
  64. 6 6
      Libraries/LibWeb/Frame/EventHandler.cpp
  65. 2 2
      Libraries/LibWeb/Frame/Frame.cpp
  66. 9 9
      Libraries/LibWeb/Frame/Frame.h
  67. 1 1
      Libraries/LibWeb/HTML/HTMLAnchorElement.cpp
  68. 2 2
      Libraries/LibWeb/HTML/HTMLAnchorElement.h
  69. 1 1
      Libraries/LibWeb/HTML/HTMLBRElement.cpp
  70. 2 2
      Libraries/LibWeb/HTML/HTMLBRElement.h
  71. 1 1
      Libraries/LibWeb/HTML/HTMLBlinkElement.cpp
  72. 2 2
      Libraries/LibWeb/HTML/HTMLBlinkElement.h
  73. 2 2
      Libraries/LibWeb/HTML/HTMLBodyElement.cpp
  74. 2 2
      Libraries/LibWeb/HTML/HTMLBodyElement.h
  75. 1 1
      Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
  76. 2 2
      Libraries/LibWeb/HTML/HTMLCanvasElement.h
  77. 1 1
      Libraries/LibWeb/HTML/HTMLElement.cpp
  78. 3 3
      Libraries/LibWeb/HTML/HTMLElement.h
  79. 1 1
      Libraries/LibWeb/HTML/HTMLFontElement.cpp
  80. 2 2
      Libraries/LibWeb/HTML/HTMLFontElement.h
  81. 1 1
      Libraries/LibWeb/HTML/HTMLFormElement.cpp
  82. 2 2
      Libraries/LibWeb/HTML/HTMLFormElement.h
  83. 1 1
      Libraries/LibWeb/HTML/HTMLHRElement.cpp
  84. 2 2
      Libraries/LibWeb/HTML/HTMLHRElement.h
  85. 1 1
      Libraries/LibWeb/HTML/HTMLHeadElement.cpp
  86. 2 2
      Libraries/LibWeb/HTML/HTMLHeadElement.h
  87. 1 1
      Libraries/LibWeb/HTML/HTMLHeadingElement.cpp
  88. 1 1
      Libraries/LibWeb/HTML/HTMLHeadingElement.h
  89. 1 1
      Libraries/LibWeb/HTML/HTMLHtmlElement.cpp
  90. 2 2
      Libraries/LibWeb/HTML/HTMLHtmlElement.h
  91. 2 2
      Libraries/LibWeb/HTML/HTMLIFrameElement.cpp
  92. 3 3
      Libraries/LibWeb/HTML/HTMLIFrameElement.h
  93. 3 3
      Libraries/LibWeb/HTML/HTMLImageElement.cpp
  94. 2 2
      Libraries/LibWeb/HTML/HTMLImageElement.h
  95. 2 2
      Libraries/LibWeb/HTML/HTMLInputElement.cpp
  96. 2 2
      Libraries/LibWeb/HTML/HTMLInputElement.h
  97. 1 1
      Libraries/LibWeb/HTML/HTMLLinkElement.cpp
  98. 2 2
      Libraries/LibWeb/HTML/HTMLLinkElement.h
  99. 1 1
      Libraries/LibWeb/HTML/HTMLObjectElement.cpp
  100. 2 2
      Libraries/LibWeb/HTML/HTMLObjectElement.h

+ 5 - 5
Applications/Browser/ConsoleWidget.cpp

@@ -47,13 +47,13 @@ ConsoleWidget::ConsoleWidget()
     set_layout<GUI::VerticalBoxLayout>();
     set_fill_with_background_color(true);
 
-    auto base_document = adopt(*new Web::Document);
-    base_document->append_child(adopt(*new Web::DocumentType(base_document)));
-    auto html_element = create_element(base_document, "html");
+    auto base_document = adopt(*new Web::DOM::Document);
+    base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document)));
+    auto html_element = Web::DOM::create_element(base_document, "html");
     base_document->append_child(html_element);
-    auto head_element = create_element(base_document, "head");
+    auto head_element = Web::DOM::create_element(base_document, "head");
     html_element->append_child(head_element);
-    auto body_element = create_element(base_document, "body");
+    auto body_element = Web::DOM::create_element(base_document, "body");
     html_element->append_child(body_element);
     m_output_container = body_element;
 

+ 1 - 1
Applications/Browser/ConsoleWidget.h

@@ -52,7 +52,7 @@ private:
 
     RefPtr<GUI::TextBox> m_input;
     RefPtr<Web::PageView> m_output_view;
-    RefPtr<Web::Element> m_output_container;
+    RefPtr<Web::DOM::Element> m_output_container;
     WeakPtr<JS::Interpreter> m_interpreter;
     OwnPtr<BrowserConsoleClient> m_console_client;
 };

+ 4 - 4
Applications/Browser/InspectorWidget.cpp

@@ -38,11 +38,11 @@
 
 namespace Browser {
 
-void InspectorWidget::set_inspected_node(Web::Node* node)
+void InspectorWidget::set_inspected_node(Web::DOM::Node* node)
 {
     m_document->set_inspected_node(node);
     if (node && node->is_element()) {
-        auto& element = downcast<Web::Element>(*node);
+        auto& element = downcast<Web::DOM::Element>(*node);
         if (element.resolved_style()) {
             m_style_table_view->set_model(Web::StylePropertiesModel::create(*element.resolved_style()));
             m_computed_style_table_view->set_model(Web::StylePropertiesModel::create(*element.computed_style()));
@@ -62,7 +62,7 @@ InspectorWidget::InspectorWidget()
 
     m_dom_tree_view = top_tab_widget.add_tab<GUI::TreeView>("DOM");
     m_dom_tree_view->on_selection = [this](auto& index) {
-        auto* node = static_cast<Web::Node*>(index.internal_data());
+        auto* node = static_cast<Web::DOM::Node*>(index.internal_data());
         set_inspected_node(node);
     };
 
@@ -82,7 +82,7 @@ InspectorWidget::~InspectorWidget()
 {
 }
 
-void InspectorWidget::set_document(Web::Document* document)
+void InspectorWidget::set_document(Web::DOM::Document* document)
 {
     if (m_document == document)
         return;

+ 3 - 3
Applications/Browser/InspectorWidget.h

@@ -36,18 +36,18 @@ class InspectorWidget final : public GUI::Widget {
 public:
     virtual ~InspectorWidget();
 
-    void set_document(Web::Document*);
+    void set_document(Web::DOM::Document*);
 
 private:
     InspectorWidget();
 
-    void set_inspected_node(Web::Node*);
+    void set_inspected_node(Web::DOM::Node*);
 
     RefPtr<GUI::TreeView> m_dom_tree_view;
     RefPtr<GUI::TreeView> m_layout_tree_view;
     RefPtr<GUI::TableView> m_style_table_view;
     RefPtr<GUI::TableView> m_computed_style_table_view;
-    RefPtr<Web::Document> m_document;
+    RefPtr<Web::DOM::Document> m_document;
 };
 
 }

+ 5 - 5
Applications/IRCClient/IRCLogBuffer.cpp

@@ -40,14 +40,14 @@ NonnullRefPtr<IRCLogBuffer> IRCLogBuffer::create()
 
 IRCLogBuffer::IRCLogBuffer()
 {
-    m_document = adopt(*new Web::Document);
-    m_document->append_child(adopt(*new Web::DocumentType(document())));
+    m_document = adopt(*new Web::DOM::Document);
+    m_document->append_child(adopt(*new Web::DOM::DocumentType(document())));
     auto html_element = create_element(document(), "html");
     m_document->append_child(html_element);
     auto head_element = create_element(document(), "head");
     html_element->append_child(head_element);
     auto style_element = create_element(document(), "style");
-    style_element->append_child(adopt(*new Web::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
+    style_element->append_child(adopt(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
     head_element->append_child(style_element);
     auto body_element = create_element(document(), "body");
     html_element->append_child(body_element);
@@ -76,7 +76,7 @@ void IRCLogBuffer::add_message(char prefix, const String& name, const String& te
         escape_html_entities(nick_string).characters(),
         escape_html_entities(text).characters());
 
-    auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div);
+    auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
     wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
     wrapper->set_inner_html(html);
     m_container_element->append_child(wrapper);
@@ -90,7 +90,7 @@ void IRCLogBuffer::add_message(const String& text, Color color)
         "<span>%s</span>",
         timestamp_string().characters(),
         escape_html_entities(text).characters());
-    auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div);
+    auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
     wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
     wrapper->set_inner_html(html);
     m_container_element->append_child(wrapper);

+ 4 - 4
Applications/IRCClient/IRCLogBuffer.h

@@ -49,11 +49,11 @@ public:
     void add_message(const String& text, Color = Color::Black);
     void dump() const;
 
-    const Web::Document& document() const { return *m_document; }
-    Web::Document& document() { return *m_document; }
+    const Web::DOM::Document& document() const { return *m_document; }
+    Web::DOM::Document& document() { return *m_document; }
 
 private:
     IRCLogBuffer();
-    RefPtr<Web::Document> m_document;
-    RefPtr<Web::Element> m_container_element;
+    RefPtr<Web::DOM::Document> m_document;
+    RefPtr<Web::DOM::Element> m_container_element;
 };

+ 1 - 1
Applications/IRCClient/IRCWindow.cpp

@@ -214,7 +214,7 @@ IRCWindow::~IRCWindow()
 void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer)
 {
     m_log_buffer = &log_buffer;
-    m_page_view->set_document(const_cast<Web::Document*>(&log_buffer.document()));
+    m_page_view->set_document(const_cast<Web::DOM::Document*>(&log_buffer.document()));
 }
 
 bool IRCWindow::is_active() const

+ 1 - 1
Libraries/LibWeb/Bindings/EventListenerWrapper.cpp

@@ -33,7 +33,7 @@
 namespace Web {
 namespace Bindings {
 
-EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, EventListener& impl)
+EventListenerWrapper::EventListenerWrapper(JS::GlobalObject& global_object, DOM::EventListener& impl)
     : Wrapper(*global_object.object_prototype())
     , m_impl(impl)
 {

+ 4 - 4
Libraries/LibWeb/Bindings/EventListenerWrapper.h

@@ -35,14 +35,14 @@ class EventListenerWrapper final : public Wrapper {
     JS_OBJECT(EventListenerWrapper, Wrapper);
 
 public:
-    EventListenerWrapper(JS::GlobalObject&, EventListener&);
+    EventListenerWrapper(JS::GlobalObject&, DOM::EventListener&);
     virtual ~EventListenerWrapper() override;
 
-    EventListener& impl() { return *m_impl; }
-    const EventListener& impl() const { return *m_impl; }
+    DOM::EventListener& impl() { return *m_impl; }
+    const DOM::EventListener& impl() const { return *m_impl; }
 
 private:
-    NonnullRefPtr<EventListener> m_impl;
+    NonnullRefPtr<DOM::EventListener> m_impl;
 };
 
 }

+ 2 - 2
Libraries/LibWeb/Bindings/EventWrapperFactory.cpp

@@ -30,10 +30,10 @@
 namespace Web {
 namespace Bindings {
 
-EventWrapper* wrap(JS::GlobalObject& global_object, Event& event)
+EventWrapper* wrap(JS::GlobalObject& global_object, DOM::Event& event)
 {
     if (event.is_mouse_event())
-        return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<MouseEvent&>(event)));
+        return static_cast<MouseEventWrapper*>(wrap_impl(global_object, static_cast<DOM::MouseEvent&>(event)));
     return static_cast<EventWrapper*>(wrap_impl(global_object, event));
 }
 

+ 2 - 4
Libraries/LibWeb/Bindings/EventWrapperFactory.h

@@ -29,10 +29,8 @@
 #include <LibJS/Forward.h>
 #include <LibWeb/Forward.h>
 
-namespace Web {
-namespace Bindings {
+namespace Web::Bindings {
 
-EventWrapper* wrap(JS::GlobalObject&, Event&);
+EventWrapper* wrap(JS::GlobalObject&, DOM::Event&);
 
 }
-}

+ 7 - 7
Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp

@@ -38,20 +38,20 @@
 namespace Web {
 namespace Bindings {
 
-NodeWrapper* wrap(JS::GlobalObject& global_object, Node& node)
+NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node)
 {
-    if (is<Document>(node))
-        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<Document>(node)));
-    if (is<DocumentType>(node))
-        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DocumentType>(node)));
+    if (is<DOM::Document>(node))
+        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Document>(node)));
+    if (is<DOM::DocumentType>(node))
+        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::DocumentType>(node)));
     if (is<HTMLCanvasElement>(node))
         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLCanvasElement>(node)));
     if (is<HTMLImageElement>(node))
         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLImageElement>(node)));
     if (is<HTMLElement>(node))
         return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLElement>(node)));
-    if (is<Element>(node))
-        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<Element>(node)));
+    if (is<DOM::Element>(node))
+        return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<DOM::Element>(node)));
     return static_cast<NodeWrapper*>(wrap_impl(global_object, node));
 }
 

+ 1 - 1
Libraries/LibWeb/Bindings/NodeWrapperFactory.h

@@ -32,7 +32,7 @@
 namespace Web {
 namespace Bindings {
 
-NodeWrapper* wrap(JS::GlobalObject&, Node&);
+NodeWrapper* wrap(JS::GlobalObject&, DOM::Node&);
 
 }
 }

+ 2 - 2
Libraries/LibWeb/Bindings/WindowObject.cpp

@@ -48,7 +48,7 @@
 namespace Web {
 namespace Bindings {
 
-WindowObject::WindowObject(Window& impl)
+WindowObject::WindowObject(DOM::Window& impl)
     : m_impl(impl)
 {
     impl.set_wrapper({}, *this);
@@ -91,7 +91,7 @@ void WindowObject::visit_children(Visitor& visitor)
     visitor.visit(m_xhr_prototype);
 }
 
-static Window* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
+static DOM::Window* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)
 {
     auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);
     if (!this_object) {

+ 4 - 4
Libraries/LibWeb/Bindings/WindowObject.h

@@ -37,12 +37,12 @@ class WindowObject final
     : public JS::GlobalObject
     , public Weakable<WindowObject> {
 public:
-    explicit WindowObject(Window&);
+    explicit WindowObject(DOM::Window&);
     virtual void initialize() override;
     virtual ~WindowObject() override;
 
-    Window& impl() { return *m_impl; }
-    const Window& impl() const { return *m_impl; }
+    DOM::Window& impl() { return *m_impl; }
+    const DOM::Window& impl() const { return *m_impl; }
 
     XMLHttpRequestPrototype* xhr_prototype() { return m_xhr_prototype; }
     XMLHttpRequestConstructor* xhr_constructor() { return m_xhr_constructor; }
@@ -65,7 +65,7 @@ private:
     JS_DECLARE_NATIVE_FUNCTION(atob);
     JS_DECLARE_NATIVE_FUNCTION(btoa);
 
-    NonnullRefPtr<Window> m_impl;
+    NonnullRefPtr<DOM::Window> m_impl;
 
     XMLHttpRequestConstructor* m_xhr_constructor { nullptr };
     XMLHttpRequestPrototype* m_xhr_prototype { nullptr };

+ 9 - 9
Libraries/LibWeb/CSS/SelectorEngine.cpp

@@ -34,7 +34,7 @@ namespace Web {
 
 namespace SelectorEngine {
 
-static bool matches_hover_pseudo_class(const Element& element)
+static bool matches_hover_pseudo_class(const DOM::Element& element)
 {
     auto* hovered_node = element.document().hovered_node();
     if (!hovered_node)
@@ -44,7 +44,7 @@ static bool matches_hover_pseudo_class(const Element& element)
     return element.is_ancestor_of(*hovered_node);
 }
 
-bool matches(const Selector::SimpleSelector& component, const Element& element)
+bool matches(const Selector::SimpleSelector& component, const DOM::Element& element)
 {
     switch (component.pseudo_class) {
     case Selector::SimpleSelector::PseudoClass::None:
@@ -76,7 +76,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element)
             return false;
         break;
     case Selector::SimpleSelector::PseudoClass::Empty:
-        if (element.first_child_of_type<Element>() || element.first_child_of_type<Text>())
+        if (element.first_child_of_type<DOM::Element>() || element.first_child_of_type<DOM::Text>())
             return false;
         break;
     case Selector::SimpleSelector::PseudoClass::Root:
@@ -116,7 +116,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element)
     }
 }
 
-bool matches(const Selector& selector, int component_list_index, const Element& element)
+bool matches(const Selector& selector, int component_list_index, const DOM::Element& element)
 {
     auto& component_list = selector.complex_selectors()[component_list_index];
     for (auto& component : component_list.compound_selector) {
@@ -129,17 +129,17 @@ bool matches(const Selector& selector, int component_list_index, const Element&
     case Selector::ComplexSelector::Relation::Descendant:
         ASSERT(component_list_index != 0);
         for (auto* ancestor = element.parent(); ancestor; ancestor = ancestor->parent()) {
-            if (!is<Element>(*ancestor))
+            if (!is<DOM::Element>(*ancestor))
                 continue;
-            if (matches(selector, component_list_index - 1, downcast<Element>(*ancestor)))
+            if (matches(selector, component_list_index - 1, downcast<DOM::Element>(*ancestor)))
                 return true;
         }
         return false;
     case Selector::ComplexSelector::Relation::ImmediateChild:
         ASSERT(component_list_index != 0);
-        if (!element.parent() || !is<Element>(*element.parent()))
+        if (!element.parent() || !is<DOM::Element>(*element.parent()))
             return false;
-        return matches(selector, component_list_index - 1, downcast<Element>(*element.parent()));
+        return matches(selector, component_list_index - 1, downcast<DOM::Element>(*element.parent()));
     case Selector::ComplexSelector::Relation::AdjacentSibling:
         ASSERT(component_list_index != 0);
         if (auto* sibling = element.previous_element_sibling())
@@ -156,7 +156,7 @@ bool matches(const Selector& selector, int component_list_index, const Element&
     ASSERT_NOT_REACHED();
 }
 
-bool matches(const Selector& selector, const Element& element)
+bool matches(const Selector& selector, const DOM::Element& element)
 {
     ASSERT(!selector.complex_selectors().is_empty());
     return matches(selector, selector.complex_selectors().size() - 1, element);

+ 3 - 8
Libraries/LibWeb/CSS/SelectorEngine.h

@@ -27,15 +27,10 @@
 #pragma once
 
 #include <LibWeb/CSS/Selector.h>
+#include <LibWeb/DOM/Element.h>
 
-namespace Web {
+namespace Web::SelectorEngine {
 
-class Element;
-
-namespace SelectorEngine {
-
-bool matches(const Selector&, const Element&);
-
-}
+bool matches(const Selector&, const DOM::Element&);
 
 }

+ 1 - 1
Libraries/LibWeb/CSS/StyleProperties.cpp

@@ -94,7 +94,7 @@ String StyleProperties::string_or_fallback(CSS::PropertyID id, const StringView&
     return value.value()->to_string();
 }
 
-Color StyleProperties::color_or_fallback(CSS::PropertyID id, const Document& document, Color fallback) const
+Color StyleProperties::color_or_fallback(CSS::PropertyID id, const DOM::Document& document, Color fallback) const
 {
     auto value = property(id);
     if (!value.has_value())

+ 1 - 1
Libraries/LibWeb/CSS/StyleProperties.h

@@ -59,7 +59,7 @@ public:
     Length length_or_fallback(CSS::PropertyID, const Length& fallback) const;
     LengthBox length_box(CSS::PropertyID left_id, CSS::PropertyID top_id, CSS::PropertyID right_id, CSS::PropertyID bottom_id) const;
     String string_or_fallback(CSS::PropertyID, const StringView& fallback) const;
-    Color color_or_fallback(CSS::PropertyID, const Document&, Color fallback) const;
+    Color color_or_fallback(CSS::PropertyID, const DOM::Document&, Color fallback) const;
     CSS::TextAlign text_align() const;
     CSS::Display display() const;
     Optional<CSS::Float> float_() const;

+ 4 - 4
Libraries/LibWeb/CSS/StyleResolver.cpp

@@ -37,7 +37,7 @@
 
 namespace Web {
 
-StyleResolver::StyleResolver(Document& document)
+StyleResolver::StyleResolver(DOM::Document& document)
     : m_document(document)
 {
 }
@@ -66,7 +66,7 @@ void StyleResolver::for_each_stylesheet(Callback callback) const
     }
 }
 
-Vector<MatchingRule> StyleResolver::collect_matching_rules(const Element& element) const
+Vector<MatchingRule> StyleResolver::collect_matching_rules(const DOM::Element& element) const
 {
     Vector<MatchingRule> matching_rules;
 
@@ -203,7 +203,7 @@ static inline void set_property_border_style(StyleProperties& style, const Style
         style.set_property(CSS::PropertyID::BorderLeftStyle, value);
 }
 
-static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, Document& document)
+static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, DOM::Document& document)
 {
     CSS::ParsingContext context(document);
 
@@ -519,7 +519,7 @@ static void set_property_expanding_shorthands(StyleProperties& style, CSS::Prope
     style.set_property(property_id, value);
 }
 
-NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_style) const
+NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const DOM::Element& element, const StyleProperties* parent_style) const
 {
     auto style = StyleProperties::create();
 

+ 7 - 12
Libraries/LibWeb/CSS/StyleResolver.h

@@ -29,15 +29,10 @@
 #include <AK/NonnullRefPtrVector.h>
 #include <AK/OwnPtr.h>
 #include <LibWeb/CSS/StyleProperties.h>
+#include <LibWeb/Forward.h>
 
 namespace Web {
 
-class Document;
-class Element;
-class ParentNode;
-class StyleRule;
-class StyleSheet;
-
 struct MatchingRule {
     RefPtr<StyleRule> rule;
     size_t style_sheet_index { 0 };
@@ -47,15 +42,15 @@ struct MatchingRule {
 
 class StyleResolver {
 public:
-    explicit StyleResolver(Document&);
+    explicit StyleResolver(DOM::Document&);
     ~StyleResolver();
 
-    Document& document() { return m_document; }
-    const Document& document() const { return m_document; }
+    DOM::Document& document() { return m_document; }
+    const DOM::Document& document() const { return m_document; }
 
-    NonnullRefPtr<StyleProperties> resolve_style(const Element&, const StyleProperties* parent_style) const;
+    NonnullRefPtr<StyleProperties> resolve_style(const DOM::Element&, const StyleProperties* parent_style) const;
 
-    Vector<MatchingRule> collect_matching_rules(const Element&) const;
+    Vector<MatchingRule> collect_matching_rules(const DOM::Element&) const;
 
     static bool is_inherited_property(CSS::PropertyID);
 
@@ -63,7 +58,7 @@ private:
     template<typename Callback>
     void for_each_stylesheet(Callback) const;
 
-    Document& m_document;
+    DOM::Document& m_document;
 };
 
 }

+ 1 - 1
Libraries/LibWeb/CSS/StyleSheetList.cpp

@@ -33,7 +33,7 @@ void StyleSheetList::add_sheet(NonnullRefPtr<StyleSheet> sheet)
     m_sheets.append(move(sheet));
 }
 
-StyleSheetList::StyleSheetList(Document& document)
+StyleSheetList::StyleSheetList(DOM::Document& document)
     : m_document(document)
 {
 }

+ 3 - 3
Libraries/LibWeb/CSS/StyleSheetList.h

@@ -33,7 +33,7 @@ namespace Web::CSS {
 
 class StyleSheetList : public RefCounted<StyleSheetList> {
 public:
-    static NonnullRefPtr<StyleSheetList> create(Document& document)
+    static NonnullRefPtr<StyleSheetList> create(DOM::Document& document)
     {
         return adopt(*new StyleSheetList(document));
     }
@@ -43,9 +43,9 @@ public:
     const NonnullRefPtrVector<StyleSheet>& sheets() const { return m_sheets; }
 
 private:
-    explicit StyleSheetList(Document&);
+    explicit StyleSheetList(DOM::Document&);
 
-    Document& m_document;
+    DOM::Document& m_document;
     NonnullRefPtrVector<StyleSheet> m_sheets;
 };
 

+ 2 - 2
Libraries/LibWeb/CSS/StyleValue.cpp

@@ -167,7 +167,7 @@ String IdentifierStyleValue::to_string() const
     }
 }
 
-Color IdentifierStyleValue::to_color(const Document& document) const
+Color IdentifierStyleValue::to_color(const DOM::Document& document) const
 {
     if (id() == CSS::ValueID::VendorSpecificLink)
         return document.link_color();
@@ -287,7 +287,7 @@ Color IdentifierStyleValue::to_color(const Document& document) const
     }
 }
 
-ImageStyleValue::ImageStyleValue(const URL& url, Document& document)
+ImageStyleValue::ImageStyleValue(const URL& url, DOM::Document& document)
     : StyleValue(Type::Image)
     , m_url(url)
     , m_document(document.make_weak_ptr())

+ 6 - 6
Libraries/LibWeb/CSS/StyleValue.h

@@ -182,7 +182,7 @@ public:
 
     virtual String to_string() const = 0;
     virtual Length to_length() const { return Length::make_auto(); }
-    virtual Color to_color(const Document&) const { return {}; }
+    virtual Color to_color(const DOM::Document&) const { return {}; }
 
     virtual bool is_auto() const { return false; }
 
@@ -276,7 +276,7 @@ public:
 
     Color color() const { return m_color; }
     String to_string() const override { return m_color.to_string(); }
-    Color to_color(const Document&) const override { return m_color; }
+    Color to_color(const DOM::Document&) const override { return m_color; }
 
 private:
     explicit ColorStyleValue(Color color)
@@ -299,7 +299,7 @@ public:
     CSS::ValueID id() const { return m_id; }
 
     virtual String to_string() const override;
-    virtual Color to_color(const Document&) const override;
+    virtual Color to_color(const DOM::Document&) const override;
 
 private:
     explicit IdentifierStyleValue(CSS::ValueID id)
@@ -315,7 +315,7 @@ class ImageStyleValue final
     : public StyleValue
     , public ImageResourceClient {
 public:
-    static NonnullRefPtr<ImageStyleValue> create(const URL& url, Document& document) { return adopt(*new ImageStyleValue(url, document)); }
+    static NonnullRefPtr<ImageStyleValue> create(const URL& url, DOM::Document& document) { return adopt(*new ImageStyleValue(url, document)); }
     virtual ~ImageStyleValue() override { }
 
     String to_string() const override { return String::format("Image{%s}", m_url.to_string().characters()); }
@@ -323,13 +323,13 @@ public:
     const Gfx::Bitmap* bitmap() const { return m_bitmap; }
 
 private:
-    ImageStyleValue(const URL&, Document&);
+    ImageStyleValue(const URL&, DOM::Document&);
 
     // ^ResourceClient
     virtual void resource_did_load() override;
 
     URL m_url;
-    WeakPtr<Document> m_document;
+    WeakPtr<DOM::Document> m_document;
     RefPtr<Gfx::Bitmap> m_bitmap;
 };
 

+ 36 - 17
Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp

@@ -26,6 +26,7 @@
 
 #include <AK/ByteBuffer.h>
 #include <AK/HashMap.h>
+#include <AK/LexicalPath.h>
 #include <AK/StringBuilder.h>
 #include <LibCore/ArgsParser.h>
 #include <LibCore/File.h>
@@ -108,6 +109,7 @@ struct Interface {
     // Added for convenience after parsing
     String wrapper_class;
     String wrapper_base_class;
+    String fully_qualified_name;
 };
 
 OwnPtr<Interface> parse_interface(const StringView& input)
@@ -312,6 +314,9 @@ int main(int argc, char** argv)
         return 1;
     }
 
+    LexicalPath lexical_path(path);
+    auto namespace_ = lexical_path.parts().at(lexical_path.parts().size() - 2);
+
     auto data = file_or_error.value()->read_all();
     auto interface = IDL::parse_interface(data);
 
@@ -320,6 +325,17 @@ int main(int argc, char** argv)
         return 1;
     }
 
+    if (namespace_ == "DOM") {
+        StringBuilder builder;
+        builder.append(namespace_);
+        builder.append("::");
+        builder.append(interface->name);
+        interface->fully_qualified_name = builder.to_string();
+    } else {
+        interface->fully_qualified_name = interface->name;
+    }
+
+
 #if 0
     dbg() << "Attributes:";
     for (auto& attribute : interface->attributes) {
@@ -402,22 +418,21 @@ static void generate_header(const IDL::Interface& interface)
     if (wrapper_base_class != "Wrapper")
         out() << "#include <LibWeb/Bindings/" << wrapper_base_class << ".h>";
 
-    out() << "namespace Web {";
-    out() << "namespace Bindings {";
+    out() << "namespace Web::Bindings {";
 
     out() << "class " << wrapper_class << " : public " << wrapper_base_class << " {";
     out() << "    JS_OBJECT(" << wrapper_class << ", " << wrapper_base_class << ");";
     out() << "public:";
-    out() << "    " << wrapper_class << "(JS::GlobalObject&, " << interface.name << "&);";
+    out() << "    " << wrapper_class << "(JS::GlobalObject&, " << interface.fully_qualified_name << "&);";
     out() << "    virtual void initialize(JS::GlobalObject&) override;";
     out() << "    virtual ~" << wrapper_class << "() override;";
 
     if (wrapper_base_class == "Wrapper") {
-        out() << "    " << interface.name << "& impl() { return *m_impl; }";
-        out() << "    const " << interface.name << "& impl() const { return *m_impl; }";
+        out() << "    " << interface.fully_qualified_name << "& impl() { return *m_impl; }";
+        out() << "    const " << interface.fully_qualified_name << "& impl() const { return *m_impl; }";
     } else {
-        out() << "    " << interface.name << "& impl() { return static_cast<" << interface.name << "&>(" << wrapper_base_class << "::impl()); }";
-        out() << "    const " << interface.name << "& impl() const { return static_cast<const " << interface.name << "&>(" << wrapper_base_class << "::impl()); }";
+        out() << "    " << interface.fully_qualified_name << "& impl() { return static_cast<" << interface.fully_qualified_name << "&>(" << wrapper_base_class << "::impl()); }";
+        out() << "    const " << interface.fully_qualified_name << "& impl() const { return static_cast<const " << interface.fully_qualified_name << "&>(" << wrapper_base_class << "::impl()); }";
     }
 
     auto is_foo_wrapper_name = snake_name(String::format("Is%s", wrapper_class.characters()));
@@ -436,17 +451,16 @@ static void generate_header(const IDL::Interface& interface)
     }
 
     if (wrapper_base_class == "Wrapper") {
-        out() << "    NonnullRefPtr<" << interface.name << "> m_impl;";
+        out() << "    NonnullRefPtr<" << interface.fully_qualified_name << "> m_impl;";
     }
 
     out() << "};";
 
     if (should_emit_wrapper_factory(interface)) {
-        out() << wrapper_class << "* wrap(JS::GlobalObject&, " << interface.name << "&);";
+        out() << wrapper_class << "* wrap(JS::GlobalObject&, " << interface.fully_qualified_name << "&);";
     }
 
     out() << "}";
-    out() << "}";
 }
 
 void generate_implementation(const IDL::Interface& interface)
@@ -473,11 +487,17 @@ void generate_implementation(const IDL::Interface& interface)
     out() << "#include <LibWeb/Bindings/ImageDataWrapper.h>";
     out() << "#include <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>";
 
-    out() << "namespace Web {";
-    out() << "namespace Bindings {";
+    // FIXME: This is a total hack until we can figure out the namespace for a given type somehow.
+    out() << "using Web::DOM::Node;";
+    out() << "using Web::DOM::Document;";
+    out() << "using Web::DOM::DocumentType;";
+    out() << "using Web::DOM::Element;";
+    out() << "using Web::DOM::EventListener;";
+
+    out() << "namespace Web::Bindings {";
 
     // Implementation: Wrapper constructor
-    out() << wrapper_class << "::" << wrapper_class << "(JS::GlobalObject& global_object, " << interface.name << "& impl)";
+    out() << wrapper_class << "::" << wrapper_class << "(JS::GlobalObject& global_object, " << interface.fully_qualified_name << "& impl)";
     if (wrapper_base_class == "Wrapper") {
         out() << "    : Wrapper(*global_object.object_prototype())";
         out() << "    , m_impl(impl)";
@@ -510,13 +530,13 @@ void generate_implementation(const IDL::Interface& interface)
 
     // Implementation: impl_from()
     if (!interface.attributes.is_empty() || !interface.functions.is_empty()) {
-        out() << "static " << interface.name << "* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)";
+        out() << "static " << interface.fully_qualified_name << "* impl_from(JS::Interpreter& interpreter, JS::GlobalObject& global_object)";
         out() << "{";
         out() << "    auto* this_object = interpreter.this_value(global_object).to_object(interpreter, global_object);";
         out() << "    if (!this_object)";
         out() << "        return {};";
         out() << "    if (!this_object->inherits(\"" << wrapper_class << "\")) {";
-        out() << "        interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.name << "\");";
+        out() << "        interpreter.throw_exception<JS::TypeError>(JS::ErrorType::NotA, \"" << interface.fully_qualified_name << "\");";
         out() << "        return nullptr;";
         out() << "    }";
         out() << "    return &static_cast<" << wrapper_class << "*>(this_object)->impl();";
@@ -676,12 +696,11 @@ void generate_implementation(const IDL::Interface& interface)
 
     // Implementation: Wrapper factory
     if (should_emit_wrapper_factory(interface)) {
-        out() << wrapper_class << "* wrap(JS::GlobalObject& global_object, " << interface.name << "& impl)";
+        out() << wrapper_class << "* wrap(JS::GlobalObject& global_object, " << interface.fully_qualified_name << "& impl)";
         out() << "{";
         out() << "    return static_cast<" << wrapper_class << "*>(wrap_impl(global_object, impl));";
         out() << "}";
     }
 
     out() << "}";
-    out() << "}";
 }

+ 1 - 1
Libraries/LibWeb/DOM/CharacterData.cpp

@@ -26,7 +26,7 @@
 
 #include <LibWeb/DOM/CharacterData.h>
 
-namespace Web {
+namespace Web::DOM {
 
 CharacterData::CharacterData(Document& document, NodeType type, const String& data)
     : Node(document, type)

+ 3 - 3
Libraries/LibWeb/DOM/CharacterData.h

@@ -29,7 +29,7 @@
 #include <AK/String.h>
 #include <LibWeb/DOM/Node.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class CharacterData : public Node {
 public:
@@ -49,6 +49,6 @@ private:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::CharacterData)
-static bool is_type(const Web::Node& node) { return node.is_character_data(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::CharacterData)
+static bool is_type(const Web::DOM::Node& node) { return node.is_character_data(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/Comment.cpp

@@ -27,7 +27,7 @@
 #include <LibWeb/DOM/Comment.h>
 #include <LibWeb/Layout/LayoutText.h>
 
-namespace Web {
+namespace Web::DOM {
 
 Comment::Comment(Document& document, const String& data)
     : CharacterData(document, NodeType::COMMENT_NODE, data)

+ 3 - 3
Libraries/LibWeb/DOM/Comment.h

@@ -29,7 +29,7 @@
 #include <AK/FlyString.h>
 #include <LibWeb/DOM/CharacterData.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class Comment final : public CharacterData {
 public:
@@ -41,6 +41,6 @@ public:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::Comment)
-static bool is_type(const Web::Node& node) { return node.is_comment(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::Comment)
+static bool is_type(const Web::DOM::Node& node) { return node.is_comment(); }
 AK_END_TYPE_TRAITS()

+ 2 - 2
Libraries/LibWeb/DOM/Document.cpp

@@ -59,7 +59,7 @@
 #include <LibWeb/SVG/TagNames.h>
 #include <stdio.h>
 
-namespace Web {
+namespace Web::DOM {
 
 Document::Document(const URL& url)
     : ParentNode(*this, NodeType::DOCUMENT_NODE)
@@ -433,7 +433,7 @@ JS::Value Document::run_javascript(const StringView& source)
 
 NonnullRefPtr<Element> Document::create_element(const String& tag_name)
 {
-    return Web::create_element(*this, tag_name);
+    return DOM::create_element(*this, tag_name);
 }
 
 NonnullRefPtr<Text> Document::create_text_node(const String& data)

+ 3 - 4
Libraries/LibWeb/DOM/Document.h

@@ -41,7 +41,7 @@
 #include <LibWeb/DOM/NonElementParentNode.h>
 #include <LibWeb/DOM/ParentNode.h>
 
-namespace Web {
+namespace Web::DOM {
 
 enum class QuirksMode {
     No,
@@ -190,7 +190,6 @@ private:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::Document)
-static bool is_type(const Web::Node& node) { return node.is_document(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::Document)
+static bool is_type(const Web::DOM::Node& node) { return node.is_document(); }
 AK_END_TYPE_TRAITS()
-

+ 3 - 3
Libraries/LibWeb/DOM/DocumentFragment.h

@@ -30,7 +30,7 @@
 #include <LibWeb/DOM/NonElementParentNode.h>
 #include <LibWeb/DOM/ParentNode.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class DocumentFragment
     : public ParentNode
@@ -46,6 +46,6 @@ public:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::DocumentFragment)
-static bool is_type(const Web::Node& node) { return node.is_document_fragment(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentFragment)
+static bool is_type(const Web::DOM::Node& node) { return node.is_document_fragment(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/DocumentType.cpp

@@ -26,7 +26,7 @@
 
 #include <LibWeb/DOM/DocumentType.h>
 
-namespace Web {
+namespace Web::DOM {
 
 DocumentType::DocumentType(Document& document)
     : Node(document, NodeType::DOCUMENT_TYPE_NODE)

+ 3 - 3
Libraries/LibWeb/DOM/DocumentType.h

@@ -29,7 +29,7 @@
 #include <AK/FlyString.h>
 #include <LibWeb/DOM/Node.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class DocumentType final : public Node {
 public:
@@ -57,6 +57,6 @@ private:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::DocumentType)
-static bool is_type(const Web::Node& node) { return node.type() == Web::NodeType::DOCUMENT_TYPE_NODE; }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::DocumentType)
+static bool is_type(const Web::DOM::Node& node) { return node.type() == Web::DOM::NodeType::DOCUMENT_TYPE_NODE; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/Element.cpp

@@ -43,7 +43,7 @@
 #include <LibWeb/Layout/LayoutTreeBuilder.h>
 #include <LibWeb/Parser/HTMLDocumentParser.h>
 
-namespace Web {
+namespace Web::DOM {
 
 Element::Element(Document& document, const FlyString& tag_name)
     : ParentNode(document, NodeType::ELEMENT_NODE)

+ 3 - 5
Libraries/LibWeb/DOM/Element.h

@@ -34,9 +34,7 @@
 #include <LibWeb/DOM/TagNames.h>
 #include <LibWeb/Layout/LayoutNode.h>
 
-namespace Web {
-
-class LayoutNodeWithStyle;
+namespace Web::DOM {
 
 class Element : public ParentNode {
 public:
@@ -101,6 +99,6 @@ private:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::Element)
-static bool is_type(const Web::Node& node) { return node.is_element(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::Element)
+static bool is_type(const Web::DOM::Node& node) { return node.is_element(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/ElementFactory.cpp

@@ -51,7 +51,7 @@
 #include <LibWeb/SVG/SVGSVGElement.h>
 #include <LibWeb/SVG/TagNames.h>
 
-namespace Web {
+namespace Web::DOM {
 
 NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_name)
 {

+ 1 - 1
Libraries/LibWeb/DOM/ElementFactory.h

@@ -28,7 +28,7 @@
 
 #include <LibWeb/DOM/Element.h>
 
-namespace Web {
+namespace Web::DOM {
 
 NonnullRefPtr<Element> create_element(Document&, const FlyString& tag_name);
 

+ 1 - 1
Libraries/LibWeb/DOM/Event.h

@@ -29,7 +29,7 @@
 #include <AK/FlyString.h>
 #include <LibWeb/Bindings/Wrappable.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class Event
     : public RefCounted<Event>

+ 1 - 1
Libraries/LibWeb/DOM/EventListener.cpp

@@ -27,7 +27,7 @@
 #include <LibJS/Runtime/Function.h>
 #include <LibWeb/DOM/EventListener.h>
 
-namespace Web {
+namespace Web::DOM {
 
 JS::Function& EventListener::function()
 {

+ 1 - 1
Libraries/LibWeb/DOM/EventListener.h

@@ -30,7 +30,7 @@
 #include <LibJS/Heap/Handle.h>
 #include <LibWeb/Bindings/Wrappable.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class EventListener
     : public RefCounted<EventListener>

+ 1 - 1
Libraries/LibWeb/DOM/EventTarget.cpp

@@ -27,7 +27,7 @@
 #include <LibWeb/DOM/EventListener.h>
 #include <LibWeb/DOM/EventTarget.h>
 
-namespace Web {
+namespace Web::DOM {
 
 EventTarget::EventTarget()
 {

+ 1 - 1
Libraries/LibWeb/DOM/EventTarget.h

@@ -31,7 +31,7 @@
 #include <AK/Vector.h>
 #include <LibWeb/Forward.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class EventTarget {
     AK_MAKE_NONCOPYABLE(EventTarget);

+ 2 - 2
Libraries/LibWeb/DOM/MouseEvent.h

@@ -28,9 +28,9 @@
 
 #include <LibWeb/DOM/Event.h>
 
-namespace Web {
+namespace Web::DOM {
 
-class MouseEvent final : public Event {
+class MouseEvent final : public DOM::Event {
 public:
     using WrapperType = Bindings::MouseEventWrapper;
 

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

@@ -48,7 +48,7 @@
 
 //#define EVENT_DEBUG
 
-namespace Web {
+namespace Web::DOM {
 
 Node::Node(Document& document, NodeType type)
     : m_document(&document)

+ 1 - 10
Libraries/LibWeb/DOM/Node.h

@@ -35,7 +35,7 @@
 #include <LibWeb/DOM/EventTarget.h>
 #include <LibWeb/TreeNode.h>
 
-namespace Web {
+namespace Web::DOM {
 
 enum class NodeType : unsigned {
     INVALID = 0,
@@ -47,15 +47,6 @@ enum class NodeType : unsigned {
     DOCUMENT_FRAGMENT_NODE = 11,
 };
 
-class Document;
-class Element;
-class HTMLElement;
-class HTMLAnchorElement;
-class ParentNode;
-class LayoutNode;
-class StyleResolver;
-class StyleProperties;
-
 class Node
     : public TreeNode<Node>
     , public EventTarget

+ 1 - 1
Libraries/LibWeb/DOM/NonElementParentNode.h

@@ -31,7 +31,7 @@
 #include <LibWeb/Forward.h>
 #include <LibWeb/TreeNode.h>
 
-namespace Web {
+namespace Web::DOM {
 
 template<typename NodeType>
 class NonElementParentNode {

+ 1 - 1
Libraries/LibWeb/DOM/ParentNode.cpp

@@ -26,7 +26,7 @@
 
 #include <LibWeb/DOM/ParentNode.h>
 
-namespace Web {
+namespace Web::DOM {
 
 void ParentNode::remove_all_children()
 {

+ 3 - 3
Libraries/LibWeb/DOM/ParentNode.h

@@ -28,7 +28,7 @@
 
 #include <LibWeb/DOM/Node.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class ParentNode : public Node {
 public:
@@ -60,6 +60,6 @@ inline void ParentNode::for_each_child(Callback callback)
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::ParentNode)
-static bool is_type(const Web::Node& node) { return node.is_parent_node(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::ParentNode)
+static bool is_type(const Web::DOM::Node& node) { return node.is_parent_node(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/Text.cpp

@@ -27,7 +27,7 @@
 #include <LibWeb/DOM/Text.h>
 #include <LibWeb/Layout/LayoutText.h>
 
-namespace Web {
+namespace Web::DOM {
 
 Text::Text(Document& document, const String& data)
     : CharacterData(document, NodeType::TEXT_NODE, data)

+ 3 - 3
Libraries/LibWeb/DOM/Text.h

@@ -30,7 +30,7 @@
 #include <AK/String.h>
 #include <LibWeb/DOM/CharacterData.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class Text final : public CharacterData {
 public:
@@ -45,6 +45,6 @@ private:
 
 }
 
-AK_BEGIN_TYPE_TRAITS(Web::Text)
-static bool is_type(const Web::Node& node) { return node.is_text(); }
+AK_BEGIN_TYPE_TRAITS(Web::DOM::Text)
+static bool is_type(const Web::DOM::Node& node) { return node.is_text(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/DOM/Timer.cpp

@@ -30,7 +30,7 @@
 #include <LibWeb/DOM/Timer.h>
 #include <LibWeb/DOM/Window.h>
 
-namespace Web {
+namespace Web::DOM {
 
 NonnullRefPtr<Timer> Timer::create_interval(Window& window, int milliseconds, JS::Function& callback)
 {

+ 1 - 1
Libraries/LibWeb/DOM/Timer.h

@@ -31,7 +31,7 @@
 #include <LibJS/Heap/Handle.h>
 #include <LibWeb/Forward.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class Timer final : public RefCounted<Timer> {
 public:

+ 1 - 1
Libraries/LibWeb/DOM/Window.cpp

@@ -35,7 +35,7 @@
 #include <LibWeb/Frame/Frame.h>
 #include <LibWeb/PageView.h>
 
-namespace Web {
+namespace Web::DOM {
 
 NonnullRefPtr<Window> Window::create_with_document(Document& document)
 {

+ 1 - 1
Libraries/LibWeb/DOM/Window.h

@@ -33,7 +33,7 @@
 #include <LibWeb/Bindings/WindowObject.h>
 #include <LibWeb/Bindings/Wrappable.h>
 
-namespace Web {
+namespace Web::DOM {
 
 class Window : public RefCounted<Window> {
 public:

+ 5 - 5
Libraries/LibWeb/DOM/XMLHttpRequest.cpp

@@ -38,7 +38,7 @@
 
 namespace Web {
 
-XMLHttpRequest::XMLHttpRequest(Window& window)
+XMLHttpRequest::XMLHttpRequest(DOM::Window& window)
     : m_window(window)
 {
 }
@@ -78,22 +78,22 @@ void XMLHttpRequest::send()
                 return;
             const_cast<XMLHttpRequest&>(*weak_this).m_response = data;
             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done);
-            const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(Event::create("load"));
+            const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("load"));
         },
         [weak_this = make_weak_ptr()](auto& error) {
             if (!weak_this)
                 return;
             dbg() << "XHR failed to load: " << error;
             const_cast<XMLHttpRequest&>(*weak_this).set_ready_state(ReadyState::Done);
-            const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(Event::create("error"));
+            const_cast<XMLHttpRequest&>(*weak_this).dispatch_event(DOM::Event::create("error"));
         });
 }
 
-void XMLHttpRequest::dispatch_event(NonnullRefPtr<Event> event)
+void XMLHttpRequest::dispatch_event(NonnullRefPtr<DOM::Event> event)
 {
     for (auto& listener : listeners()) {
         if (listener.event_name == event->type()) {
-            auto& function = const_cast<EventListener&>(*listener.listener).function();
+            auto& function = const_cast<DOM::EventListener&>(*listener.listener).function();
             auto& global_object = function.global_object();
             auto* this_value = wrap(global_object, *this);
             JS::MarkedValueList arguments(global_object.heap());

+ 5 - 5
Libraries/LibWeb/DOM/XMLHttpRequest.h

@@ -37,7 +37,7 @@ namespace Web {
 class XMLHttpRequest final
     : public RefCounted<XMLHttpRequest>
     , public Weakable<XMLHttpRequest>
-    , public EventTarget
+    , public DOM::EventTarget
     , public Bindings::Wrappable {
 public:
     enum class ReadyState {
@@ -50,7 +50,7 @@ public:
 
     using WrapperType = Bindings::XMLHttpRequestWrapper;
 
-    static NonnullRefPtr<XMLHttpRequest> create(Window& window) { return adopt(*new XMLHttpRequest(window)); }
+    static NonnullRefPtr<XMLHttpRequest> create(DOM::Window& window) { return adopt(*new XMLHttpRequest(window)); }
 
     virtual ~XMLHttpRequest() override;
 
@@ -65,13 +65,13 @@ public:
 private:
     virtual void ref_event_target() override { ref(); }
     virtual void unref_event_target() override { unref(); }
-    virtual void dispatch_event(NonnullRefPtr<Event>) override;
+    virtual void dispatch_event(NonnullRefPtr<DOM::Event>) override;
 
     void set_ready_state(ReadyState);
 
-    explicit XMLHttpRequest(Window&);
+    explicit XMLHttpRequest(DOM::Window&);
 
-    NonnullRefPtr<Window> m_window;
+    NonnullRefPtr<DOM::Window> m_window;
 
     ReadyState m_ready_state { ReadyState::Unsent };
 

+ 7 - 7
Libraries/LibWeb/DOMTreeModel.cpp

@@ -34,7 +34,7 @@
 
 namespace Web {
 
-DOMTreeModel::DOMTreeModel(Document& document)
+DOMTreeModel::DOMTreeModel(DOM::Document& document)
     : m_document(document)
 {
     m_document_icon.set_bitmap_for_size(16, Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png"));
@@ -51,7 +51,7 @@ GUI::ModelIndex DOMTreeModel::index(int row, int column, const GUI::ModelIndex&
     if (!parent.is_valid()) {
         return create_index(row, column, m_document.ptr());
     }
-    auto& parent_node = *static_cast<Node*>(parent.internal_data());
+    auto& parent_node = *static_cast<DOM::Node*>(parent.internal_data());
     return create_index(row, column, parent_node.child_at_index(row));
 }
 
@@ -59,7 +59,7 @@ GUI::ModelIndex DOMTreeModel::parent_index(const GUI::ModelIndex& index) const
 {
     if (!index.is_valid())
         return {};
-    auto& node = *static_cast<Node*>(index.internal_data());
+    auto& node = *static_cast<DOM::Node*>(index.internal_data());
     if (!node.parent())
         return {};
 
@@ -85,7 +85,7 @@ int DOMTreeModel::row_count(const GUI::ModelIndex& index) const
 {
     if (!index.is_valid())
         return 1;
-    auto& node = *static_cast<Node*>(index.internal_data());
+    auto& node = *static_cast<DOM::Node*>(index.internal_data());
     return node.child_count();
 }
 
@@ -117,7 +117,7 @@ static String with_whitespace_collapsed(const StringView& string)
 
 GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const
 {
-    auto& node = *static_cast<Node*>(index.internal_data());
+    auto& node = *static_cast<DOM::Node*>(index.internal_data());
     if (role == Role::Icon) {
         if (node.is_document())
             return m_document_icon;
@@ -128,10 +128,10 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const
     }
     if (role == Role::Display) {
         if (node.is_text())
-            return String::format("%s", with_whitespace_collapsed(downcast<Text>(node).data()).characters());
+            return String::format("%s", with_whitespace_collapsed(downcast<DOM::Text>(node).data()).characters());
         if (!node.is_element())
             return node.node_name();
-        auto& element = downcast<Element>(node);
+        auto& element = downcast<DOM::Element>(node);
         StringBuilder builder;
         builder.append('<');
         builder.append(element.local_name());

+ 4 - 5
Libraries/LibWeb/DOMTreeModel.h

@@ -27,14 +27,13 @@
 #pragma once
 
 #include <LibGUI/Model.h>
+#include <LibWeb/Forward.h>
 
 namespace Web {
 
-class Document;
-
 class DOMTreeModel final : public GUI::Model {
 public:
-    static NonnullRefPtr<DOMTreeModel> create(Document& document)
+    static NonnullRefPtr<DOMTreeModel> create(DOM::Document& document)
     {
         return adopt(*new DOMTreeModel(document));
     }
@@ -49,9 +48,9 @@ public:
     virtual void update() override;
 
 private:
-    explicit DOMTreeModel(Document&);
+    explicit DOMTreeModel(DOM::Document&);
 
-    NonnullRefPtr<Document> m_document;
+    NonnullRefPtr<DOM::Document> m_document;
 
     GUI::Icon m_document_icon;
     GUI::Icon m_element_icon;

+ 19 - 19
Libraries/LibWeb/Dump.cpp

@@ -43,31 +43,31 @@
 
 namespace Web {
 
-void dump_tree(const Node& node)
+void dump_tree(const DOM::Node& node)
 {
     static int indent = 0;
     for (int i = 0; i < indent; ++i)
         dbgprintf("  ");
-    if (is<Document>(node)) {
+    if (is<DOM::Document>(node)) {
         dbgprintf("*Document*\n");
-    } else if (is<Element>(node)) {
-        dbgprintf("<%s", downcast<Element>(node).local_name().characters());
-        downcast<Element>(node).for_each_attribute([](auto& name, auto& value) {
+    } else if (is<DOM::Element>(node)) {
+        dbgprintf("<%s", downcast<DOM::Element>(node).local_name().characters());
+        downcast<DOM::Element>(node).for_each_attribute([](auto& name, auto& value) {
             dbgprintf(" %s=%s", name.characters(), value.characters());
         });
         dbgprintf(">\n");
-    } else if (is<Text>(node)) {
-        dbgprintf("\"%s\"\n", static_cast<const Text&>(node).data().characters());
-    } else if (is<DocumentType>(node)) {
+    } else if (is<DOM::Text>(node)) {
+        dbgprintf("\"%s\"\n", downcast<DOM::Text>(node).data().characters());
+    } else if (is<DOM::DocumentType>(node)) {
         dbgprintf("<!DOCTYPE html>\n");
-    } else if (is<Comment>(node)) {
-        dbgprintf("<!--%s-->\n", downcast<Comment>(node).data().characters());
-    } else if (is<DocumentFragment>(node)) {
+    } else if (is<DOM::Comment>(node)) {
+        dbgprintf("<!--%s-->\n", downcast<DOM::Comment>(node).data().characters());
+    } else if (is<DOM::DocumentFragment>(node)) {
         dbgprintf("#document-fragment\n");
     }
     ++indent;
-    if (is<ParentNode>(node)) {
-        static_cast<const ParentNode&>(node).for_each_child([](auto& child) {
+    if (is<DOM::ParentNode>(node)) {
+        static_cast<const DOM::ParentNode&>(node).for_each_child([](auto& child) {
             dump_tree(child);
         });
     }
@@ -83,18 +83,18 @@ void dump_tree(const LayoutNode& layout_node)
     FlyString tag_name;
     if (layout_node.is_anonymous())
         tag_name = "(anonymous)";
-    else if (is<Text>(layout_node.node()))
+    else if (is<DOM::Text>(layout_node.node()))
         tag_name = "#text";
-    else if (is<Document>(layout_node.node()))
+    else if (is<DOM::Document>(layout_node.node()))
         tag_name = "#document";
-    else if (is<Element>(layout_node.node()))
-        tag_name = downcast<Element>(*layout_node.node()).local_name();
+    else if (is<DOM::Element>(layout_node.node()))
+        tag_name = downcast<DOM::Element>(*layout_node.node()).local_name();
     else
         tag_name = "???";
 
     String identifier = "";
-    if (layout_node.node() && is<Element>(*layout_node.node())) {
-        auto& element = downcast<Element>(*layout_node.node());
+    if (layout_node.node() && is<DOM::Element>(*layout_node.node())) {
+        auto& element = downcast<DOM::Element>(*layout_node.node());
         StringBuilder builder;
         auto id = element.attribute(HTML::AttributeNames::id);
         if (!id.is_empty()) {

+ 1 - 1
Libraries/LibWeb/Dump.h

@@ -30,7 +30,7 @@
 
 namespace Web {
 
-void dump_tree(const Node&);
+void dump_tree(const DOM::Node&);
 void dump_tree(const LayoutNode&);
 void dump_sheet(const StyleSheet&);
 void dump_rule(const StyleRule&);

+ 17 - 13
Libraries/LibWeb/Forward.h

@@ -26,9 +26,7 @@
 
 #pragma once
 
-namespace Web {
-
-class CanvasRenderingContext2D;
+namespace Web::DOM {
 class Document;
 class DocumentType;
 class Element;
@@ -36,7 +34,19 @@ class Event;
 class EventHandler;
 class EventListener;
 class EventTarget;
+class MouseEvent;
+class Node;
+class ParentNode;
+class Text;
+class Timer;
+class Window;
+enum class QuirksMode;
+}
+
+namespace Web {
+class CanvasRenderingContext2D;
 class Frame;
+class HTMLAnchorElement;
 class HTMLBodyElement;
 class HTMLCanvasElement;
 class HTMLDocumentParser;
@@ -46,35 +56,29 @@ class HTMLHeadElement;
 class HTMLHtmlElement;
 class HTMLImageElement;
 class HTMLScriptElement;
-class PageView;
 class ImageData;
-class LineBox;
-class LineBoxFragment;
 class LayoutBlock;
 class LayoutDocument;
 class LayoutNode;
 class LayoutNodeWithStyle;
 class LayoutReplaced;
+class LineBox;
+class LineBoxFragment;
 class LoadRequest;
-class MouseEvent;
-class Node;
 class Origin;
 class Page;
 class PageClient;
+class PageView;
 class PaintContext;
 class Resource;
 class ResourceLoader;
 class Selector;
 class StackingContext;
+class StyleProperties;
 class StyleResolver;
 class StyleRule;
 class StyleSheet;
-class Text;
-class Timer;
-class Window;
 class XMLHttpRequest;
-enum class QuirksMode;
-
 }
 
 namespace Web::Bindings {

+ 6 - 6
Libraries/LibWeb/Frame/EventHandler.cpp

@@ -78,14 +78,14 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button
 
     auto result = layout_root()->hit_test(position);
     if (result.layout_node && result.layout_node->node()) {
-        RefPtr<Node> node = result.layout_node->node();
+        RefPtr<DOM::Node> node = result.layout_node->node();
         if (is<HTMLIFrameElement>(*node)) {
             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
                 return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers);
             return false;
         }
         auto offset = compute_mouse_event_offset(position, *result.layout_node);
-        node->dispatch_event(MouseEvent::create("mouseup", offset.x(), offset.y()));
+        node->dispatch_event(DOM::MouseEvent::create("mouseup", offset.x(), offset.y()));
         handled_event = true;
     }
 
@@ -107,7 +107,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
     if (!result.layout_node)
         return false;
 
-    RefPtr<Node> node = result.layout_node->node();
+    RefPtr<DOM::Node> node = result.layout_node->node();
     document->set_hovered_node(node);
     if (!node)
         return false;
@@ -119,7 +119,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
     }
 
     auto offset = compute_mouse_event_offset(position, *result.layout_node);
-    node->dispatch_event(MouseEvent::create("mousedown", offset.x(), offset.y()));
+    node->dispatch_event(DOM::MouseEvent::create("mousedown", offset.x(), offset.y()));
     if (!layout_root())
         return true;
 
@@ -173,7 +173,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
     auto result = layout_root()->hit_test(position);
     const HTMLAnchorElement* hovered_link_element = nullptr;
     if (result.layout_node) {
-        RefPtr<Node> node = result.layout_node->node();
+        RefPtr<DOM::Node> node = result.layout_node->node();
 
         if (node && is<HTMLIFrameElement>(*node)) {
             if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
@@ -192,7 +192,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
                 is_hovering_link = true;
             }
             auto offset = compute_mouse_event_offset(position, *result.layout_node);
-            node->dispatch_event(MouseEvent::create("mousemove", offset.x(), offset.y()));
+            node->dispatch_event(DOM::MouseEvent::create("mousemove", offset.x(), offset.y()));
             if (!layout_root())
                 return true;
         }

+ 2 - 2
Libraries/LibWeb/Frame/Frame.cpp

@@ -33,7 +33,7 @@
 
 namespace Web {
 
-Frame::Frame(Element& host_element, Frame& main_frame)
+Frame::Frame(DOM::Element& host_element, Frame& main_frame)
     : m_page(main_frame.page())
     , m_main_frame(main_frame)
     , m_loader(*this)
@@ -54,7 +54,7 @@ Frame::~Frame()
 {
 }
 
-void Frame::set_document(Document* document)
+void Frame::set_document(DOM::Document* document)
 {
     if (m_document == document)
         return;

+ 9 - 9
Libraries/LibWeb/Frame/Frame.h

@@ -41,16 +41,16 @@ namespace Web {
 
 class Frame : public TreeNode<Frame> {
 public:
-    static NonnullRefPtr<Frame> create_subframe(Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); }
+    static NonnullRefPtr<Frame> create_subframe(DOM::Element& host_element, Frame& main_frame) { return adopt(*new Frame(host_element, main_frame)); }
     static NonnullRefPtr<Frame> create(Page& page) { return adopt(*new Frame(page)); }
     ~Frame();
 
     bool is_main_frame() const { return this == &m_main_frame; }
 
-    const Document* document() const { return m_document; }
-    Document* document() { return m_document; }
+    const DOM::Document* document() const { return m_document; }
+    DOM::Document* document() { return m_document; }
 
-    void set_document(Document*);
+    void set_document(DOM::Document*);
 
     Page& page() { return m_page; }
     const Page& page() const { return m_page; }
@@ -77,15 +77,15 @@ public:
     Frame& main_frame() { return m_main_frame; }
     const Frame& main_frame() const { return m_main_frame; }
 
-    Element* host_element() { return m_host_element; }
-    const Element* host_element() const { return m_host_element; }
+    DOM::Element* host_element() { return m_host_element; }
+    const DOM::Element* host_element() const { return m_host_element; }
 
     Gfx::IntPoint to_main_frame_position(const Gfx::IntPoint&);
     Gfx::IntRect to_main_frame_rect(const Gfx::IntRect&);
 
 
 private:
-    explicit Frame(Element& host_element, Frame& main_frame);
+    explicit Frame(DOM::Element& host_element, Frame& main_frame);
     explicit Frame(Page&);
 
     Page& m_page;
@@ -94,8 +94,8 @@ private:
     FrameLoader m_loader;
     EventHandler m_event_handler;
 
-    WeakPtr<Element> m_host_element;
-    RefPtr<Document> m_document;
+    WeakPtr<DOM::Element> m_host_element;
+    RefPtr<DOM::Document> m_document;
     Gfx::IntSize m_size;
     Gfx::IntRect m_viewport_rect;
 };

+ 1 - 1
Libraries/LibWeb/HTML/HTMLAnchorElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLAnchorElement::HTMLAnchorElement(Document& document, const FlyString& tag_name)
+HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLAnchorElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLAnchorElement : public HTMLElement {
 public:
-    HTMLAnchorElement(Document&, const FlyString& local_name);
+    HTMLAnchorElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLAnchorElement() override;
 
     String href() const { return attribute(HTML::AttributeNames::href); }
@@ -42,5 +42,5 @@ public:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLAnchorElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::a; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::a; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLBRElement.cpp

@@ -29,7 +29,7 @@
 
 namespace Web {
 
-HTMLBRElement::HTMLBRElement(Document& document, const FlyString& tag_name)
+HTMLBRElement::HTMLBRElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLBRElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLBRElement final : public HTMLElement {
 public:
-    HTMLBRElement(Document&, const FlyString& local_name);
+    HTMLBRElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLBRElement() override;
 
     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@@ -41,5 +41,5 @@ public:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLBRElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::br; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::br; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLBlinkElement.cpp

@@ -32,7 +32,7 @@
 
 namespace Web {
 
-HTMLBlinkElement::HTMLBlinkElement(Document& document, const FlyString& tag_name)
+HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
     , m_timer(Core::Timer::construct())
 {

+ 2 - 2
Libraries/LibWeb/HTML/HTMLBlinkElement.h

@@ -33,7 +33,7 @@ namespace Web {
 
 class HTMLBlinkElement : public HTMLElement {
 public:
-    HTMLBlinkElement(Document&, const FlyString& local_name);
+    HTMLBlinkElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLBlinkElement() override;
 
 private:
@@ -45,5 +45,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLBlinkElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::blink; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::blink; }
 AK_END_TYPE_TRAITS()

+ 2 - 2
Libraries/LibWeb/HTML/HTMLBodyElement.cpp

@@ -31,7 +31,7 @@
 
 namespace Web {
 
-HTMLBodyElement::HTMLBodyElement(Document& document, const FlyString& tag_name)
+HTMLBodyElement::HTMLBodyElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }
@@ -74,7 +74,7 @@ void HTMLBodyElement::parse_attribute(const FlyString& name, const String& value
         if (color.has_value())
             document().set_visited_link_color(color.value());
     } else if (name.equals_ignoring_case("background")) {
-        m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast<Document&>(document()));
+        m_background_style_value = ImageStyleValue::create(document().complete_url(value), const_cast<DOM::Document&>(document()));
     }
 }
 

+ 2 - 2
Libraries/LibWeb/HTML/HTMLBodyElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLBodyElement : public HTMLElement {
 public:
-    HTMLBodyElement(Document&, const FlyString& local_name);
+    HTMLBodyElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLBodyElement() override;
 
     virtual void parse_attribute(const FlyString&, const String&) override;
@@ -45,5 +45,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLBodyElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::body; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::body; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLCanvasElement.cpp

@@ -36,7 +36,7 @@ namespace Web {
 
 static constexpr auto max_canvas_area = 16384 * 16384;
 
-HTMLCanvasElement::HTMLCanvasElement(Document& document, const FlyString& tag_name)
+HTMLCanvasElement::HTMLCanvasElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLCanvasElement.h

@@ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement {
 public:
     using WrapperType = Bindings::HTMLCanvasElementWrapper;
 
-    HTMLCanvasElement(Document&, const FlyString& local_name);
+    HTMLCanvasElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLCanvasElement() override;
 
     const Gfx::Bitmap* bitmap() const { return m_bitmap; }
@@ -60,5 +60,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLCanvasElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::canvas; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::canvas; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLElement::HTMLElement(Document& document, const FlyString& tag_name)
+HTMLElement::HTMLElement(DOM::Document& document, const FlyString& tag_name)
     : Element(document, tag_name)
 {
 }

+ 3 - 3
Libraries/LibWeb/HTML/HTMLElement.h

@@ -30,11 +30,11 @@
 
 namespace Web {
 
-class HTMLElement : public Element {
+class HTMLElement : public DOM::Element {
 public:
     using WrapperType = Bindings::HTMLElementWrapper;
 
-    HTMLElement(Document&, const FlyString& local_name);
+    HTMLElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLElement() override;
 
     String title() const { return attribute(HTML::AttributeNames::title); }
@@ -46,5 +46,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element(); }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element(); }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLFontElement.cpp

@@ -30,7 +30,7 @@
 
 namespace Web {
 
-HTMLFontElement::HTMLFontElement(Document& document, const FlyString& tag_name)
+HTMLFontElement::HTMLFontElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLFontElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLFontElement : public HTMLElement {
 public:
-    HTMLFontElement(Document&, const FlyString& local_name);
+    HTMLFontElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLFontElement() override;
 
     virtual void apply_presentational_hints(StyleProperties&) const override;
@@ -41,5 +41,5 @@ public:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLFontElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::font; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::font; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLFormElement.cpp

@@ -33,7 +33,7 @@
 
 namespace Web {
 
-HTMLFormElement::HTMLFormElement(Document& document, const FlyString& tag_name)
+HTMLFormElement::HTMLFormElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLFormElement.h

@@ -33,7 +33,7 @@ namespace Web {
 
 class HTMLFormElement : public HTMLElement {
 public:
-    HTMLFormElement(Document&, const FlyString& local_name);
+    HTMLFormElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLFormElement() override;
 
     String action() const { return attribute(HTML::AttributeNames::action); }
@@ -45,5 +45,5 @@ public:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLFormElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::form; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::form; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLHRElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLHRElement::HTMLHRElement(Document& document, const FlyString& tag_name)
+HTMLHRElement::HTMLHRElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLHRElement.h

@@ -32,12 +32,12 @@ namespace Web {
 
 class HTMLHRElement : public HTMLElement {
 public:
-    HTMLHRElement(Document&, const FlyString& local_name);
+    HTMLHRElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLHRElement() override;
 };
 
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLHRElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::hr; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::hr; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLHeadElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLHeadElement::HTMLHeadElement(Document& document, const FlyString& tag_name)
+HTMLHeadElement::HTMLHeadElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLHeadElement.h

@@ -32,12 +32,12 @@ namespace Web {
 
 class HTMLHeadElement : public HTMLElement {
 public:
-    HTMLHeadElement(Document&, const FlyString& local_name);
+    HTMLHeadElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLHeadElement() override;
 };
 
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::head; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::head; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLHeadingElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLHeadingElement::HTMLHeadingElement(Document& document, const FlyString& tag_name)
+HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 1 - 1
Libraries/LibWeb/HTML/HTMLHeadingElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLHeadingElement : public HTMLElement {
 public:
-    HTMLHeadingElement(Document&, const FlyString& local_name);
+    HTMLHeadingElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLHeadingElement() override;
 };
 

+ 1 - 1
Libraries/LibWeb/HTML/HTMLHtmlElement.cpp

@@ -28,7 +28,7 @@
 
 namespace Web {
 
-HTMLHtmlElement::HTMLHtmlElement(Document& document, const FlyString& tag_name)
+HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLHtmlElement.h

@@ -32,12 +32,12 @@ namespace Web {
 
 class HTMLHtmlElement : public HTMLElement {
 public:
-    HTMLHtmlElement(Document&, const FlyString& local_name);
+    HTMLHtmlElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLHtmlElement() override;
 };
 
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLHtmlElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::html; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::html; }
 AK_END_TYPE_TRAITS()

+ 2 - 2
Libraries/LibWeb/HTML/HTMLIFrameElement.cpp

@@ -41,7 +41,7 @@
 
 namespace Web {
 
-HTMLIFrameElement::HTMLIFrameElement(Document& document, const FlyString& tag_name)
+HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }
@@ -82,7 +82,7 @@ void HTMLIFrameElement::load_src(const String& value)
     m_hosted_frame->loader().load(url, FrameLoader::Type::IFrame);
 }
 
-const Document* HTMLIFrameElement::hosted_document() const
+const DOM::Document* HTMLIFrameElement::hosted_document() const
 {
     return m_hosted_frame ? m_hosted_frame->document() : nullptr;
 }

+ 3 - 3
Libraries/LibWeb/HTML/HTMLIFrameElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLIFrameElement final : public HTMLElement {
 public:
-    HTMLIFrameElement(Document&, const FlyString& local_name);
+    HTMLIFrameElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLIFrameElement() override;
 
     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@@ -40,7 +40,7 @@ public:
     Frame* hosted_frame() { return m_hosted_frame; }
     const Frame* hosted_frame() const { return m_hosted_frame; }
 
-    const Document* hosted_document() const;
+    const DOM::Document* hosted_document() const;
 
 private:
     virtual void document_did_attach_to_frame(Frame&) override;
@@ -54,5 +54,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLIFrameElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::iframe; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::iframe; }
 AK_END_TYPE_TRAITS()

+ 3 - 3
Libraries/LibWeb/HTML/HTMLImageElement.cpp

@@ -37,18 +37,18 @@
 
 namespace Web {
 
-HTMLImageElement::HTMLImageElement(Document& document, const FlyString& tag_name)
+HTMLImageElement::HTMLImageElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
     m_image_loader.on_load = [this] {
         this->document().update_layout();
-        dispatch_event(Event::create("load"));
+        dispatch_event(DOM::Event::create("load"));
     };
 
     m_image_loader.on_fail = [this] {
         dbg() << "HTMLImageElement: Resource did fail: " << this->src();
         this->document().update_layout();
-        dispatch_event(Event::create("error"));
+        dispatch_event(DOM::Event::create("error"));
     };
 
     m_image_loader.on_animate = [this] {

+ 2 - 2
Libraries/LibWeb/HTML/HTMLImageElement.h

@@ -40,7 +40,7 @@ class HTMLImageElement final : public HTMLElement {
 public:
     using WrapperType = Bindings::HTMLImageElementWrapper;
 
-    HTMLImageElement(Document&, const FlyString& local_name);
+    HTMLImageElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLImageElement() override;
 
     virtual void parse_attribute(const FlyString& name, const String& value) override;
@@ -63,5 +63,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLImageElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::img; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::img; }
 AK_END_TYPE_TRAITS()

+ 2 - 2
Libraries/LibWeb/HTML/HTMLInputElement.cpp

@@ -37,7 +37,7 @@
 
 namespace Web {
 
-HTMLInputElement::HTMLInputElement(Document& document, const FlyString& tag_name)
+HTMLInputElement::HTMLInputElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }
@@ -76,7 +76,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties* p
         int text_width = Gfx::Font::default_font().width(value());
         button.set_relative_rect(0, 0, text_width + 20, 20);
         button.on_click = [this](auto) {
-            const_cast<HTMLInputElement*>(this)->dispatch_event(Event::create("click"));
+            const_cast<HTMLInputElement*>(this)->dispatch_event(DOM::Event::create("click"));
         };
         widget = button;
     } else {

+ 2 - 2
Libraries/LibWeb/HTML/HTMLInputElement.h

@@ -32,7 +32,7 @@ namespace Web {
 
 class HTMLInputElement : public HTMLElement {
 public:
-    HTMLInputElement(Document&, const FlyString& local_name);
+    HTMLInputElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLInputElement() override;
 
     virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@@ -45,5 +45,5 @@ public:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLInputElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::input; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::input; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLLinkElement.cpp

@@ -34,7 +34,7 @@
 
 namespace Web {
 
-HTMLLinkElement::HTMLLinkElement(Document& document, const FlyString& tag_name)
+HTMLLinkElement::HTMLLinkElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
 }

+ 2 - 2
Libraries/LibWeb/HTML/HTMLLinkElement.h

@@ -35,7 +35,7 @@ class HTMLLinkElement final
     : public HTMLElement
     , public ResourceClient {
 public:
-    HTMLLinkElement(Document&, const FlyString& local_name);
+    HTMLLinkElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLLinkElement() override;
 
     virtual void inserted_into(Node&) override;
@@ -67,5 +67,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLLinkElement)
-static bool is_type(const Web::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::link; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast<Web::HTMLElement>(node).local_name() == Web::HTML::TagNames::link; }
 AK_END_TYPE_TRAITS()

+ 1 - 1
Libraries/LibWeb/HTML/HTMLObjectElement.cpp

@@ -35,7 +35,7 @@
 
 namespace Web {
 
-HTMLObjectElement::HTMLObjectElement(Document& document, const FlyString& tag_name)
+HTMLObjectElement::HTMLObjectElement(DOM::Document& document, const FlyString& tag_name)
     : HTMLElement(document, tag_name)
 {
     m_image_loader.on_load = [this] {

+ 2 - 2
Libraries/LibWeb/HTML/HTMLObjectElement.h

@@ -37,7 +37,7 @@ class LayoutDocument;
 
 class HTMLObjectElement final : public HTMLElement {
 public:
-    HTMLObjectElement(Document&, const FlyString& local_name);
+    HTMLObjectElement(DOM::Document&, const FlyString& local_name);
     virtual ~HTMLObjectElement() override;
 
     virtual void parse_attribute(const FlyString& name, const String& value) override;
@@ -55,5 +55,5 @@ private:
 }
 
 AK_BEGIN_TYPE_TRAITS(Web::HTMLObjectElement)
-static bool is_type(const Web::Node& node) { return node.is_element() && downcast<Web::Element>(node).local_name() == Web::HTML::TagNames::object; }
+static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::object; }
 AK_END_TYPE_TRAITS()

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff