From c46439f24063a5531f1f7562cf6d733cdbabdb51 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 28 Jul 2020 18:20:36 +0200 Subject: [PATCH] LibWeb: Move HTML classes into the Web::HTML namespace --- DevTools/HackStudio/Editor.cpp | 2 +- .../LibWeb/Bindings/NodeWrapperFactory.cpp | 84 +++++++++---------- .../CodeGenerators/WrapperGenerator.cpp | 9 +- Libraries/LibWeb/DOM/Document.cpp | 28 +++---- Libraries/LibWeb/DOM/Document.h | 26 +++--- Libraries/LibWeb/DOM/Element.cpp | 2 +- Libraries/LibWeb/DOM/ElementFactory.cpp | 44 +++++----- Libraries/LibWeb/DOM/Node.cpp | 10 +-- Libraries/LibWeb/DOM/Node.h | 4 +- Libraries/LibWeb/Forward.h | 7 +- Libraries/LibWeb/Frame/EventHandler.cpp | 18 ++-- Libraries/LibWeb/Frame/Frame.cpp | 4 +- .../LibWeb/HTML/CanvasRenderingContext2D.cpp | 2 +- .../LibWeb/HTML/CanvasRenderingContext2D.h | 2 +- Libraries/LibWeb/HTML/HTMLAnchorElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLAnchorElement.h | 4 +- Libraries/LibWeb/HTML/HTMLBRElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLBRElement.h | 4 +- Libraries/LibWeb/HTML/HTMLBlinkElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLBlinkElement.h | 4 +- Libraries/LibWeb/HTML/HTMLBodyElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLBodyElement.h | 4 +- Libraries/LibWeb/HTML/HTMLCanvasElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLCanvasElement.h | 4 +- Libraries/LibWeb/HTML/HTMLElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLElement.h | 4 +- Libraries/LibWeb/HTML/HTMLFontElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLFontElement.h | 4 +- Libraries/LibWeb/HTML/HTMLFormElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLFormElement.h | 6 +- Libraries/LibWeb/HTML/HTMLHRElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLHRElement.h | 6 +- Libraries/LibWeb/HTML/HTMLHeadElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLHeadElement.h | 4 +- Libraries/LibWeb/HTML/HTMLHeadingElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLHeadingElement.h | 6 +- Libraries/LibWeb/HTML/HTMLHtmlElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLHtmlElement.h | 6 +- Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLIFrameElement.h | 6 +- Libraries/LibWeb/HTML/HTMLImageElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLImageElement.h | 6 +- Libraries/LibWeb/HTML/HTMLInputElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLInputElement.h | 6 +- Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLLinkElement.h | 6 +- Libraries/LibWeb/HTML/HTMLObjectElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLObjectElement.h | 6 +- Libraries/LibWeb/HTML/HTMLScriptElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLScriptElement.h | 6 +- Libraries/LibWeb/HTML/HTMLStyleElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLStyleElement.h | 6 +- .../LibWeb/HTML/HTMLTableCellElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTableCellElement.h | 6 +- Libraries/LibWeb/HTML/HTMLTableElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTableElement.h | 6 +- Libraries/LibWeb/HTML/HTMLTableRowElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTableRowElement.h | 6 +- Libraries/LibWeb/HTML/HTMLTitleElement.cpp | 2 +- Libraries/LibWeb/HTML/HTMLTitleElement.h | 6 +- Libraries/LibWeb/HTML/ImageData.cpp | 2 +- Libraries/LibWeb/HTML/ImageData.h | 2 +- Libraries/LibWeb/Layout/LayoutBreak.cpp | 2 +- Libraries/LibWeb/Layout/LayoutBreak.h | 4 +- Libraries/LibWeb/Layout/LayoutCanvas.cpp | 2 +- Libraries/LibWeb/Layout/LayoutCanvas.h | 7 +- Libraries/LibWeb/Layout/LayoutFrame.h | 4 +- Libraries/LibWeb/Layout/LayoutImage.cpp | 6 +- Libraries/LibWeb/Layout/LayoutImage.h | 2 - Libraries/LibWeb/Loader/FrameLoader.cpp | 8 +- Libraries/LibWeb/PageView.cpp | 2 +- .../LibWeb/Parser/HTMLDocumentParser.cpp | 6 +- Libraries/LibWeb/Parser/HTMLDocumentParser.h | 4 +- Libraries/LibWeb/Parser/HTMLToken.cpp | 2 +- Libraries/LibWeb/Parser/HTMLToken.h | 2 +- Libraries/LibWeb/Parser/HTMLTokenizer.cpp | 4 +- Libraries/LibWeb/Parser/HTMLTokenizer.h | 4 +- .../Parser/ListOfActiveFormattingElements.cpp | 2 +- .../Parser/ListOfActiveFormattingElements.h | 2 +- .../LibWeb/Parser/StackOfOpenElements.cpp | 2 +- Libraries/LibWeb/Parser/StackOfOpenElements.h | 2 +- Userland/test-web.cpp | 4 +- 82 files changed, 238 insertions(+), 247 deletions(-) diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 18638564cb..c6b07ca749 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -175,7 +175,7 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token m_documentation_page_view->load_html(html_text, {}); if (auto* document = m_documentation_page_view->document()) { - const_cast(document->body())->set_attribute(Web::HTML::AttributeNames::style, "background-color: #dac7b5;"); + const_cast(document->body())->set_attribute(Web::HTML::AttributeNames::style, "background-color: #dac7b5;"); } m_documentation_tooltip_window->move_to(screen_location.translated(4, 4)); diff --git a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp index f7c9cc8dbb..d87eb2b73f 100644 --- a/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp +++ b/Libraries/LibWeb/Bindings/NodeWrapperFactory.cpp @@ -80,48 +80,48 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& node) return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); - if (is(node)) - return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); + if (is(node)) + return static_cast(wrap_impl(global_object, downcast(node))); if (is(node)) return static_cast(wrap_impl(global_object, downcast(node))); return static_cast(wrap_impl(global_object, node)); diff --git a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp index 9595f282b2..f9a50dccec 100644 --- a/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp +++ b/Libraries/LibWeb/CodeGenerators/WrapperGenerator.cpp @@ -325,7 +325,7 @@ int main(int argc, char** argv) return 1; } - if (namespace_ == "DOM" || namespace_ == "UIEvents") { + if (namespace_.is_one_of("DOM", "HTML", "UIEvents")) { StringBuilder builder; builder.append(namespace_); builder.append("::"); @@ -491,11 +491,8 @@ void generate_implementation(const IDL::Interface& interface) out() << "#include "; // 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() << "using namespace Web::DOM;"; + out() << "using namespace Web::HTML;"; out() << "namespace Web::Bindings {"; diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index 35954044b8..1a69da0ee3 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -117,7 +117,7 @@ void Document::fixup() if (!first_child() || !is(*first_child())) prepend_child(adopt(*new DocumentType(*this))); - if (is(first_child()->next_sibling())) + if (is(first_child()->next_sibling())) return; auto body = create_element("body"); @@ -127,25 +127,25 @@ void Document::fixup() this->append_child(html); } -const HTMLHtmlElement* Document::document_element() const +const HTML::HTMLHtmlElement* Document::document_element() const { - return first_child_of_type(); + return first_child_of_type(); } -const HTMLHeadElement* Document::head() const +const HTML::HTMLHeadElement* Document::head() const { auto* html = document_element(); if (!html) return nullptr; - return html->first_child_of_type(); + return html->first_child_of_type(); } -const HTMLElement* Document::body() const +const HTML::HTMLElement* Document::body() const { auto* html = document_element(); if (!html) return nullptr; - return html->first_child_of_type(); + return html->first_child_of_type(); } String Document::title() const @@ -154,7 +154,7 @@ String Document::title() const if (!head_element) return {}; - auto* title_element = head_element->first_child_of_type(); + auto* title_element = head_element->first_child_of_type(); if (!title_element) return {}; @@ -441,32 +441,32 @@ NonnullRefPtr Document::create_text_node(const String& data) return adopt(*new Text(*this, data)); } -void Document::set_pending_parsing_blocking_script(Badge, HTMLScriptElement* script) +void Document::set_pending_parsing_blocking_script(Badge, HTML::HTMLScriptElement* script) { m_pending_parsing_blocking_script = script; } -NonnullRefPtr Document::take_pending_parsing_blocking_script(Badge) +NonnullRefPtr Document::take_pending_parsing_blocking_script(Badge) { return m_pending_parsing_blocking_script.release_nonnull(); } -void Document::add_script_to_execute_when_parsing_has_finished(Badge, HTMLScriptElement& script) +void Document::add_script_to_execute_when_parsing_has_finished(Badge, HTML::HTMLScriptElement& script) { m_scripts_to_execute_when_parsing_has_finished.append(script); } -NonnullRefPtrVector Document::take_scripts_to_execute_when_parsing_has_finished(Badge) +NonnullRefPtrVector Document::take_scripts_to_execute_when_parsing_has_finished(Badge) { return move(m_scripts_to_execute_when_parsing_has_finished); } -void Document::add_script_to_execute_as_soon_as_possible(Badge, HTMLScriptElement& script) +void Document::add_script_to_execute_as_soon_as_possible(Badge, HTML::HTMLScriptElement& script) { m_scripts_to_execute_as_soon_as_possible.append(script); } -NonnullRefPtrVector Document::take_scripts_to_execute_as_soon_as_possible(Badge) +NonnullRefPtrVector Document::take_scripts_to_execute_as_soon_as_possible(Badge) { return move(m_scripts_to_execute_as_soon_as_possible); } diff --git a/Libraries/LibWeb/DOM/Document.h b/Libraries/LibWeb/DOM/Document.h index 788c628c6c..3f8bfe7cf1 100644 --- a/Libraries/LibWeb/DOM/Document.h +++ b/Libraries/LibWeb/DOM/Document.h @@ -85,9 +85,9 @@ public: Node* inspected_node() { return m_inspected_node; } const Node* inspected_node() const { return m_inspected_node; } - const HTMLHtmlElement* document_element() const; - const HTMLHeadElement* head() const; - const HTMLElement* body() const; + const HTML::HTMLHtmlElement* document_element() const; + const HTML::HTMLHeadElement* head() const; + const HTML::HTMLElement* body() const; String title() const; @@ -138,15 +138,15 @@ public: NonnullRefPtr create_element(const String& tag_name); NonnullRefPtr create_text_node(const String& data); - void set_pending_parsing_blocking_script(Badge, HTMLScriptElement*); - HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; } - NonnullRefPtr take_pending_parsing_blocking_script(Badge); + void set_pending_parsing_blocking_script(Badge, HTML::HTMLScriptElement*); + HTML::HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; } + NonnullRefPtr take_pending_parsing_blocking_script(Badge); - void add_script_to_execute_when_parsing_has_finished(Badge, HTMLScriptElement&); - NonnullRefPtrVector take_scripts_to_execute_when_parsing_has_finished(Badge); + void add_script_to_execute_when_parsing_has_finished(Badge, HTML::HTMLScriptElement&); + NonnullRefPtrVector take_scripts_to_execute_when_parsing_has_finished(Badge); - void add_script_to_execute_as_soon_as_possible(Badge, HTMLScriptElement&); - NonnullRefPtrVector take_scripts_to_execute_as_soon_as_possible(Badge); + void add_script_to_execute_as_soon_as_possible(Badge, HTML::HTMLScriptElement&); + NonnullRefPtrVector take_scripts_to_execute_as_soon_as_possible(Badge); QuirksMode mode() const { return m_quirks_mode; } bool in_quirks_mode() const { return m_quirks_mode == QuirksMode::Yes; } @@ -181,9 +181,9 @@ private: OwnPtr m_interpreter; - RefPtr m_pending_parsing_blocking_script; - NonnullRefPtrVector m_scripts_to_execute_when_parsing_has_finished; - NonnullRefPtrVector m_scripts_to_execute_as_soon_as_possible; + RefPtr m_pending_parsing_blocking_script; + NonnullRefPtrVector m_scripts_to_execute_when_parsing_has_finished; + NonnullRefPtrVector m_scripts_to_execute_as_soon_as_possible; QuirksMode m_quirks_mode { QuirksMode::No }; }; diff --git a/Libraries/LibWeb/DOM/Element.cpp b/Libraries/LibWeb/DOM/Element.cpp index c938805478..abfd3ccef1 100644 --- a/Libraries/LibWeb/DOM/Element.cpp +++ b/Libraries/LibWeb/DOM/Element.cpp @@ -252,7 +252,7 @@ NonnullRefPtr Element::computed_style() void Element::set_inner_html(StringView markup) { - auto new_children = HTMLDocumentParser::parse_html_fragment(*this, markup); + auto new_children = HTML::HTMLDocumentParser::parse_html_fragment(*this, markup); remove_all_children(); while (!new_children.is_empty()) { append_child(new_children.take_first()); diff --git a/Libraries/LibWeb/DOM/ElementFactory.cpp b/Libraries/LibWeb/DOM/ElementFactory.cpp index 37c6705d42..d75fb01715 100644 --- a/Libraries/LibWeb/DOM/ElementFactory.cpp +++ b/Libraries/LibWeb/DOM/ElementFactory.cpp @@ -57,49 +57,49 @@ NonnullRefPtr create_element(Document& document, const FlyString& tag_n { auto lowercase_tag_name = tag_name.to_lowercase(); if (lowercase_tag_name == HTML::TagNames::a) - return adopt(*new HTMLAnchorElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLAnchorElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::html) - return adopt(*new HTMLHtmlElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLHtmlElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::head) - return adopt(*new HTMLHeadElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLHeadElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::body) - return adopt(*new HTMLBodyElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLBodyElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::font) - return adopt(*new HTMLFontElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLFontElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::hr) - return adopt(*new HTMLHRElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLHRElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::style) - return adopt(*new HTMLStyleElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLStyleElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::title) - return adopt(*new HTMLTitleElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLTitleElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::link) - return adopt(*new HTMLLinkElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLLinkElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::img) - return adopt(*new HTMLImageElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLImageElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::blink) - return adopt(*new HTMLBlinkElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLBlinkElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::form) - return adopt(*new HTMLFormElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLFormElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::input) - return adopt(*new HTMLInputElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLInputElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::br) - return adopt(*new HTMLBRElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLBRElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::iframe) - return adopt(*new HTMLIFrameElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLIFrameElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::table) - return adopt(*new HTMLTableElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLTableElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::tr) - return adopt(*new HTMLTableRowElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLTableRowElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::td || lowercase_tag_name == HTML::TagNames::th) - return adopt(*new HTMLTableCellElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLTableCellElement(document, lowercase_tag_name)); if (lowercase_tag_name.is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) - return adopt(*new HTMLHeadingElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLHeadingElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::script) - return adopt(*new HTMLScriptElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLScriptElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::canvas) - return adopt(*new HTMLCanvasElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLCanvasElement(document, lowercase_tag_name)); if (lowercase_tag_name == HTML::TagNames::object) - return adopt(*new HTMLObjectElement(document, lowercase_tag_name)); + return adopt(*new HTML::HTMLObjectElement(document, lowercase_tag_name)); if (lowercase_tag_name == SVG::TagNames::svg) return adopt(*new SVG::SVGSVGElement(document, lowercase_tag_name)); if (lowercase_tag_name == SVG::TagNames::path) diff --git a/Libraries/LibWeb/DOM/Node.cpp b/Libraries/LibWeb/DOM/Node.cpp index fc5d0e5d0c..744c0f27d2 100644 --- a/Libraries/LibWeb/DOM/Node.cpp +++ b/Libraries/LibWeb/DOM/Node.cpp @@ -62,18 +62,18 @@ Node::~Node() layout_node()->parent()->remove_child(*layout_node()); } -const HTMLAnchorElement* Node::enclosing_link_element() const +const HTML::HTMLAnchorElement* Node::enclosing_link_element() const { for (auto* node = this; node; node = node->parent()) { - if (is(*node) && downcast(*node).has_attribute(HTML::AttributeNames::href)) - return downcast(node); + if (is(*node) && downcast(*node).has_attribute(HTML::AttributeNames::href)) + return downcast(node); } return nullptr; } -const HTMLElement* Node::enclosing_html_element() const +const HTML::HTMLElement* Node::enclosing_html_element() const { - return first_ancestor_of_type(); + return first_ancestor_of_type(); } String Node::text_content() const diff --git a/Libraries/LibWeb/DOM/Node.h b/Libraries/LibWeb/DOM/Node.h index d81428f373..cc73a7ac67 100644 --- a/Libraries/LibWeb/DOM/Node.h +++ b/Libraries/LibWeb/DOM/Node.h @@ -87,8 +87,8 @@ public: Document& document() { return *m_document; } const Document& document() const { return *m_document; } - const HTMLAnchorElement* enclosing_link_element() const; - const HTMLElement* enclosing_html_element() const; + const HTML::HTMLAnchorElement* enclosing_link_element() const; + const HTML::HTMLElement* enclosing_html_element() const; String child_text_content() const; diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index c3de704746..81c19bd5c0 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -51,9 +51,8 @@ class Window; enum class QuirksMode; } -namespace Web { +namespace Web::HTML { class CanvasRenderingContext2D; -class Frame; class HTMLAnchorElement; class HTMLBodyElement; class HTMLCanvasElement; @@ -65,6 +64,10 @@ class HTMLHtmlElement; class HTMLImageElement; class HTMLScriptElement; class ImageData; +} + +namespace Web { +class Frame; class LayoutBlock; class LayoutDocument; class LayoutNode; diff --git a/Libraries/LibWeb/Frame/EventHandler.cpp b/Libraries/LibWeb/Frame/EventHandler.cpp index a7a607d539..7bbd5181c2 100644 --- a/Libraries/LibWeb/Frame/EventHandler.cpp +++ b/Libraries/LibWeb/Frame/EventHandler.cpp @@ -79,8 +79,8 @@ 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 = result.layout_node->node(); - if (is(*node)) { - if (auto* subframe = downcast(*node).hosted_frame()) + if (is(*node)) { + if (auto* subframe = downcast(*node).hosted_frame()) return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return false; } @@ -112,8 +112,8 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (!node) return false; - if (is(*node)) { - if (auto* subframe = downcast(*node).hosted_frame()) + if (is(*node)) { + if (auto* subframe = downcast(*node).hosted_frame()) return subframe->event_handler().handle_mousedown(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); return false; } @@ -123,7 +123,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (!layout_root()) return true; - if (RefPtr link = node->enclosing_link_element()) { + if (RefPtr link = node->enclosing_link_element()) { auto href = link->href(); auto url = document->complete_url(href); dbg() << "Web::EventHandler: Clicking on a link to " << url; @@ -170,12 +170,12 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt bool hovered_node_changed = false; bool is_hovering_link = false; auto result = layout_root()->hit_test(position); - const HTMLAnchorElement* hovered_link_element = nullptr; + const HTML::HTMLAnchorElement* hovered_link_element = nullptr; if (result.layout_node) { RefPtr node = result.layout_node->node(); - if (node && is(*node)) { - if (auto* subframe = downcast(*node).hosted_frame()) + if (node && is(*node)) { + if (auto* subframe = downcast(*node).hosted_frame()) return subframe->event_handler().handle_mousemove(position.translated(compute_mouse_event_offset({}, *result.layout_node)), buttons, modifiers); return false; } @@ -203,7 +203,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt } page_client.page_did_request_cursor_change(is_hovering_link ? GUI::StandardCursor::Hand : GUI::StandardCursor::None); if (hovered_node_changed) { - RefPtr hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element() : nullptr; + RefPtr hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element() : nullptr; if (hovered_html_element && !hovered_html_element->title().is_null()) { page_client.page_did_enter_tooltip_area(m_frame.to_main_frame_position(position), hovered_html_element->title()); } else { diff --git a/Libraries/LibWeb/Frame/Frame.cpp b/Libraries/LibWeb/Frame/Frame.cpp index d4af97a0da..b2dafa1533 100644 --- a/Libraries/LibWeb/Frame/Frame.cpp +++ b/Libraries/LibWeb/Frame/Frame.cpp @@ -124,8 +124,8 @@ void Frame::scroll_to_anchor(const String& fragment) if (!element) { auto candidates = document()->get_elements_by_name(fragment); for (auto* candidate : candidates) { - if (is(*candidate)) { - element = downcast(candidate); + if (is(*candidate)) { + element = downcast(candidate); break; } } diff --git a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 5b8a7c1605..ae2579e3bc 100644 --- a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -32,7 +32,7 @@ #include #include -namespace Web { +namespace Web::HTML { CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& element) : m_element(element.make_weak_ptr()) diff --git a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h index eee5804897..58cccfc6e6 100644 --- a/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h +++ b/Libraries/LibWeb/HTML/CanvasRenderingContext2D.h @@ -34,7 +34,7 @@ #include #include -namespace Web { +namespace Web::HTML { class CanvasRenderingContext2D : public RefCounted diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp index 8657759625..2377cb5b0c 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLAnchorElement.h b/Libraries/LibWeb/HTML/HTMLAnchorElement.h index 8e4da8a7c8..ced8d9b2b2 100644 --- a/Libraries/LibWeb/HTML/HTMLAnchorElement.h +++ b/Libraries/LibWeb/HTML/HTMLAnchorElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLAnchorElement : public HTMLElement { public: @@ -43,6 +43,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLAnchorElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLAnchorElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::a; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.cpp b/Libraries/LibWeb/HTML/HTMLBRElement.cpp index 2772f20ddd..672263e987 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBRElement.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLBRElement::HTMLBRElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLBRElement.h b/Libraries/LibWeb/HTML/HTMLBRElement.h index eaded297d3..c7147dc33d 100644 --- a/Libraries/LibWeb/HTML/HTMLBRElement.h +++ b/Libraries/LibWeb/HTML/HTMLBRElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLBRElement final : public HTMLElement { public: @@ -42,6 +42,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLBRElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLBRElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::br; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp b/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp index 6c1648e83e..1f8e7cb7d8 100644 --- a/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBlinkElement.cpp @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLBlinkElement.h b/Libraries/LibWeb/HTML/HTMLBlinkElement.h index 4b8f731ed3..65f50b7fe4 100644 --- a/Libraries/LibWeb/HTML/HTMLBlinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLBlinkElement.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::HTML { class HTMLBlinkElement : public HTMLElement { public: @@ -44,6 +44,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLBlinkElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLBlinkElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::blink; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp index 95bc5a56d6..df52de6514 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.cpp @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLBodyElement::HTMLBodyElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLBodyElement.h b/Libraries/LibWeb/HTML/HTMLBodyElement.h index 5e75d45535..9df7ef8309 100644 --- a/Libraries/LibWeb/HTML/HTMLBodyElement.h +++ b/Libraries/LibWeb/HTML/HTMLBodyElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLBodyElement : public HTMLElement { public: @@ -46,6 +46,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLBodyElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLBodyElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::body; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index a933182051..0e74dbf637 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -32,7 +32,7 @@ #include #include -namespace Web { +namespace Web::HTML { static constexpr auto max_canvas_area = 16384 * 16384; diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.h b/Libraries/LibWeb/HTML/HTMLCanvasElement.h index d426a5c6f4..73b05447f4 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.h +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { class LayoutDocument; @@ -59,6 +59,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLCanvasElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLCanvasElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::canvas; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLElement.cpp b/Libraries/LibWeb/HTML/HTMLElement.cpp index e976aae3c9..757574eb90 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLElement::HTMLElement(DOM::Document& document, const FlyString& tag_name) : Element(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLElement.h b/Libraries/LibWeb/HTML/HTMLElement.h index 1bf814fb40..b148fde16a 100644 --- a/Libraries/LibWeb/HTML/HTMLElement.h +++ b/Libraries/LibWeb/HTML/HTMLElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLElement : public DOM::Element { public: @@ -45,6 +45,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLElement) static bool is_type(const Web::DOM::Node& node) { return node.is_html_element(); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLFontElement.cpp b/Libraries/LibWeb/HTML/HTMLFontElement.cpp index 7a7a9f2cb1..da41454609 100644 --- a/Libraries/LibWeb/HTML/HTMLFontElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFontElement.cpp @@ -28,7 +28,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLFontElement::HTMLFontElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLFontElement.h b/Libraries/LibWeb/HTML/HTMLFontElement.h index 1993ea2425..80f6b0e685 100644 --- a/Libraries/LibWeb/HTML/HTMLFontElement.h +++ b/Libraries/LibWeb/HTML/HTMLFontElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLFontElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLFontElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLFontElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::font; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index 3d4e216a96..1ba31f0504 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -31,7 +31,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLFormElement::HTMLFormElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.h b/Libraries/LibWeb/HTML/HTMLFormElement.h index 286b37d8de..97e3722ab7 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.h +++ b/Libraries/LibWeb/HTML/HTMLFormElement.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::HTML { class HTMLFormElement : public HTMLElement { public: @@ -46,6 +46,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLFormElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::form; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLFormElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::form; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Libraries/LibWeb/HTML/HTMLHRElement.cpp index 2d403392ff..6dd0b0d69b 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLHRElement::HTMLHRElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.h b/Libraries/LibWeb/HTML/HTMLHRElement.h index 94340e3742..c9e9873f7c 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.h +++ b/Libraries/LibWeb/HTML/HTMLHRElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLHRElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLHRElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::hr; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLHRElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::hr; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.cpp b/Libraries/LibWeb/HTML/HTMLHeadElement.cpp index aade728d5b..86ffef1448 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLHeadElement::HTMLHeadElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLHeadElement.h b/Libraries/LibWeb/HTML/HTMLHeadElement.h index a074b97616..e97ba5a5a2 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLHeadElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLHeadElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::head; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index 48c22e7b90..82fbb68712 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Libraries/LibWeb/HTML/HTMLHeadingElement.h index f042af1662..577465572a 100644 --- a/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLHeadingElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLHeadingElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name().is_one_of(Web::HTML::TagNames::h1, Web::HTML::TagNames::h2, Web::HTML::TagNames::h3, Web::HTML::TagNames::h4, Web::HTML::TagNames::h5, Web::HTML::TagNames::h6); } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLHeadingElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name().is_one_of(Web::HTML::TagNames::h1, Web::HTML::TagNames::h2, Web::HTML::TagNames::h3, Web::HTML::TagNames::h4, Web::HTML::TagNames::h5, Web::HTML::TagNames::h6); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp b/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp index 1c91ded368..e671d28d15 100644 --- a/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLHtmlElement.h b/Libraries/LibWeb/HTML/HTMLHtmlElement.h index c06ce9957e..59aa5fc101 100644 --- a/Libraries/LibWeb/HTML/HTMLHtmlElement.h +++ b/Libraries/LibWeb/HTML/HTMLHtmlElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLHtmlElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLHtmlElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::html; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLHtmlElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::html; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 3922ebd9ff..d365210a70 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -39,7 +39,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLIFrameElement.h b/Libraries/LibWeb/HTML/HTMLIFrameElement.h index 015e65b314..caf639ae63 100644 --- a/Libraries/LibWeb/HTML/HTMLIFrameElement.h +++ b/Libraries/LibWeb/HTML/HTMLIFrameElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLIFrameElement final : public HTMLElement { public: @@ -55,6 +55,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLIFrameElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::iframe; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLIFrameElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::iframe; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 79d2bada92..c584801f3c 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -35,7 +35,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLImageElement::HTMLImageElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.h b/Libraries/LibWeb/HTML/HTMLImageElement.h index edffe13042..920bd6d2c2 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.h +++ b/Libraries/LibWeb/HTML/HTMLImageElement.h @@ -32,9 +32,7 @@ #include #include -namespace Web { - -class LayoutDocument; +namespace Web::HTML { class HTMLImageElement final : public HTMLElement { public: @@ -62,6 +60,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLImageElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLImageElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::img; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Libraries/LibWeb/HTML/HTMLInputElement.cpp index a248eae12e..faf10c6a31 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -35,7 +35,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLInputElement::HTMLInputElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLInputElement.h b/Libraries/LibWeb/HTML/HTMLInputElement.h index ebb399f29d..d02db5fd7a 100644 --- a/Libraries/LibWeb/HTML/HTMLInputElement.h +++ b/Libraries/LibWeb/HTML/HTMLInputElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLInputElement : public HTMLElement { public: @@ -46,6 +46,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLInputElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::input; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLInputElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::input; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 743b0ca1b5..dc12be1cef 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -32,7 +32,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLLinkElement::HTMLLinkElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index eec0f9c347..1a50f2ffde 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::HTML { class HTMLLinkElement final : public HTMLElement @@ -68,6 +68,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLLinkElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::link; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLLinkElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::link; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp index b793819bda..45807816fd 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.cpp @@ -33,7 +33,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLObjectElement::HTMLObjectElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLObjectElement.h b/Libraries/LibWeb/HTML/HTMLObjectElement.h index c21111e51c..3ee410b198 100644 --- a/Libraries/LibWeb/HTML/HTMLObjectElement.h +++ b/Libraries/LibWeb/HTML/HTMLObjectElement.h @@ -31,9 +31,7 @@ #include #include -namespace Web { - -class LayoutDocument; +namespace Web::HTML { class HTMLObjectElement final : public HTMLElement { public: @@ -56,6 +54,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLObjectElement) +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLObjectElement) static bool is_type(const Web::DOM::Node& node) { return node.is_element() && downcast(node).local_name() == Web::HTML::TagNames::object; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index a30825ab05..4dc71914dc 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -32,7 +32,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLScriptElement::HTMLScriptElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.h b/Libraries/LibWeb/HTML/HTMLScriptElement.h index f9d3ab885a..85858e931c 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.h +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.h @@ -29,7 +29,7 @@ #include #include -namespace Web { +namespace Web::HTML { class HTMLScriptElement : public HTMLElement { public: @@ -69,6 +69,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLScriptElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::script; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLScriptElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::script; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.cpp b/Libraries/LibWeb/HTML/HTMLStyleElement.cpp index 95a27f3f98..40e239b547 100644 --- a/Libraries/LibWeb/HTML/HTMLStyleElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.cpp @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLStyleElement::HTMLStyleElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLStyleElement.h b/Libraries/LibWeb/HTML/HTMLStyleElement.h index cb8b64eba5..20897dc219 100644 --- a/Libraries/LibWeb/HTML/HTMLStyleElement.h +++ b/Libraries/LibWeb/HTML/HTMLStyleElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLStyleElement : public HTMLElement { public: @@ -46,6 +46,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLStyleElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::style; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLStyleElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::style; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index bb1798372f..c1edb20176 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.h b/Libraries/LibWeb/HTML/HTMLTableCellElement.h index 648e982f98..cb01c684ee 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLTableCellElement final : public HTMLElement { public: @@ -43,6 +43,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLTableCellElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name().is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th); } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLTableCellElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name().is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th); } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.cpp b/Libraries/LibWeb/HTML/HTMLTableElement.cpp index ddd7459537..2374c6b751 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableElement.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::HTML { HTMLTableElement::HTMLTableElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLTableElement.h b/Libraries/LibWeb/HTML/HTMLTableElement.h index c87c5f9726..fb34149384 100644 --- a/Libraries/LibWeb/HTML/HTMLTableElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLTableElement final : public HTMLElement { public: @@ -43,6 +43,6 @@ private: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLTableElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::table; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLTableElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::table; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp index 9e8a8d8deb..d8155af01e 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLTableRowElement.h b/Libraries/LibWeb/HTML/HTMLTableRowElement.h index e211555727..5a562f0b84 100644 --- a/Libraries/LibWeb/HTML/HTMLTableRowElement.h +++ b/Libraries/LibWeb/HTML/HTMLTableRowElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLTableRowElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLTableRowElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::tr; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLTableRowElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::tr; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.cpp b/Libraries/LibWeb/HTML/HTMLTitleElement.cpp index cfcde00345..36f2835191 100644 --- a/Libraries/LibWeb/HTML/HTMLTitleElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { HTMLTitleElement::HTMLTitleElement(DOM::Document& document, const FlyString& tag_name) : HTMLElement(document, tag_name) diff --git a/Libraries/LibWeb/HTML/HTMLTitleElement.h b/Libraries/LibWeb/HTML/HTMLTitleElement.h index b0bd70b4ec..a4ffd9c93a 100644 --- a/Libraries/LibWeb/HTML/HTMLTitleElement.h +++ b/Libraries/LibWeb/HTML/HTMLTitleElement.h @@ -28,7 +28,7 @@ #include -namespace Web { +namespace Web::HTML { class HTMLTitleElement : public HTMLElement { public: @@ -40,6 +40,6 @@ public: } -AK_BEGIN_TYPE_TRAITS(Web::HTMLTitleElement) -static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::title; } +AK_BEGIN_TYPE_TRAITS(Web::HTML::HTMLTitleElement) +static bool is_type(const Web::DOM::Node& node) { return node.is_html_element() && downcast(node).local_name() == Web::HTML::TagNames::title; } AK_END_TYPE_TRAITS() diff --git a/Libraries/LibWeb/HTML/ImageData.cpp b/Libraries/LibWeb/HTML/ImageData.cpp index 064ffc5ae0..4dcee14f47 100644 --- a/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Libraries/LibWeb/HTML/ImageData.cpp @@ -28,7 +28,7 @@ #include #include -namespace Web { +namespace Web::HTML { RefPtr ImageData::create_with_size(JS::GlobalObject& global_object, int width, int height) { diff --git a/Libraries/LibWeb/HTML/ImageData.h b/Libraries/LibWeb/HTML/ImageData.h index 493e0517a8..810400d187 100644 --- a/Libraries/LibWeb/HTML/ImageData.h +++ b/Libraries/LibWeb/HTML/ImageData.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { class ImageData : public RefCounted diff --git a/Libraries/LibWeb/Layout/LayoutBreak.cpp b/Libraries/LibWeb/Layout/LayoutBreak.cpp index 7149c189af..6f4a57d2c9 100644 --- a/Libraries/LibWeb/Layout/LayoutBreak.cpp +++ b/Libraries/LibWeb/Layout/LayoutBreak.cpp @@ -29,7 +29,7 @@ namespace Web { -LayoutBreak::LayoutBreak(DOM::Document& document, const HTMLBRElement& element) +LayoutBreak::LayoutBreak(DOM::Document& document, const HTML::HTMLBRElement& element) : LayoutNodeWithStyleAndBoxModelMetrics(document, &element, CSS::StyleProperties::create()) { set_inline(true); diff --git a/Libraries/LibWeb/Layout/LayoutBreak.h b/Libraries/LibWeb/Layout/LayoutBreak.h index 61a5a7ec9c..e54115cd8b 100644 --- a/Libraries/LibWeb/Layout/LayoutBreak.h +++ b/Libraries/LibWeb/Layout/LayoutBreak.h @@ -33,10 +33,10 @@ namespace Web { class LayoutBreak final : public LayoutNodeWithStyleAndBoxModelMetrics { public: - LayoutBreak(DOM::Document&, const HTMLBRElement&); + LayoutBreak(DOM::Document&, const HTML::HTMLBRElement&); virtual ~LayoutBreak() override; - const HTMLBRElement& node() const { return downcast(*LayoutNode::node()); } + const HTML::HTMLBRElement& node() const { return downcast(*LayoutNode::node()); } private: virtual bool is_break() const override { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.cpp b/Libraries/LibWeb/Layout/LayoutCanvas.cpp index a778af20c0..3f864be0cd 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.cpp +++ b/Libraries/LibWeb/Layout/LayoutCanvas.cpp @@ -31,7 +31,7 @@ namespace Web { -LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTMLCanvasElement& element, NonnullRefPtr style) +LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTML::HTMLCanvasElement& element, NonnullRefPtr style) : LayoutReplaced(document, element, move(style)) { } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.h b/Libraries/LibWeb/Layout/LayoutCanvas.h index 4e248eb993..db25e1cc27 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.h +++ b/Libraries/LibWeb/Layout/LayoutCanvas.h @@ -31,24 +31,21 @@ namespace Web { -class HTMLCanvasElement; - class LayoutCanvas : public LayoutReplaced { public: - LayoutCanvas(DOM::Document&, const HTMLCanvasElement&, NonnullRefPtr); + LayoutCanvas(DOM::Document&, const HTML::HTMLCanvasElement&, NonnullRefPtr); virtual ~LayoutCanvas() override; virtual void layout(LayoutMode = LayoutMode::Default) override; virtual void paint(PaintContext&, PaintPhase) override; - const HTMLCanvasElement& node() const { return static_cast(LayoutReplaced::node()); } + const HTML::HTMLCanvasElement& node() const { return static_cast(LayoutReplaced::node()); } private: virtual const char* class_name() const override { return "LayoutCanvas"; } virtual bool is_canvas() const override { return true; } }; - } AK_BEGIN_TYPE_TRAITS(Web::LayoutCanvas) diff --git a/Libraries/LibWeb/Layout/LayoutFrame.h b/Libraries/LibWeb/Layout/LayoutFrame.h index cd7694d6e1..3679c026c6 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.h +++ b/Libraries/LibWeb/Layout/LayoutFrame.h @@ -39,8 +39,8 @@ public: virtual void paint(PaintContext&, PaintPhase) override; virtual void layout(LayoutMode) override; - const HTMLIFrameElement& node() const { return static_cast(LayoutReplaced::node()); } - HTMLIFrameElement& node() { return static_cast(LayoutReplaced::node()); } + const HTML::HTMLIFrameElement& node() const { return downcast(LayoutReplaced::node()); } + HTML::HTMLIFrameElement& node() { return downcast(LayoutReplaced::node()); } private: virtual bool is_frame() const final { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutImage.cpp b/Libraries/LibWeb/Layout/LayoutImage.cpp index 92a37a5a00..d4d658d9cf 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.cpp +++ b/Libraries/LibWeb/Layout/LayoutImage.cpp @@ -71,7 +71,7 @@ void LayoutImage::layout(LayoutMode layout_mode) } if (renders_as_alt_text()) { - auto& image_element = downcast(node()); + auto& image_element = downcast(node()); auto& font = Gfx::Font::default_font(); auto alt = image_element.alt(); if (alt.is_empty()) @@ -101,7 +101,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase) if (phase == PaintPhase::Foreground) { if (renders_as_alt_text()) { - auto& image_element = downcast(node()); + auto& image_element = downcast(node()); context.painter().set_font(Gfx::Font::default_font()); Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); auto alt = image_element.alt(); @@ -116,7 +116,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase) bool LayoutImage::renders_as_alt_text() const { - if (is(node())) + if (is(node())) return !m_image_loader.has_image(); return false; } diff --git a/Libraries/LibWeb/Layout/LayoutImage.h b/Libraries/LibWeb/Layout/LayoutImage.h index b2001a26b1..d953f257c8 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.h +++ b/Libraries/LibWeb/Layout/LayoutImage.h @@ -31,8 +31,6 @@ namespace Web { -class HTMLImageElement; - class LayoutImage : public LayoutReplaced { public: LayoutImage(DOM::Document&, const DOM::Element&, NonnullRefPtr, const ImageLoader&); diff --git a/Libraries/LibWeb/Loader/FrameLoader.cpp b/Libraries/LibWeb/Loader/FrameLoader.cpp index cfc6b78bf5..811da754b8 100644 --- a/Libraries/LibWeb/Loader/FrameLoader.cpp +++ b/Libraries/LibWeb/Loader/FrameLoader.cpp @@ -54,7 +54,7 @@ static RefPtr create_markdown_document(const ByteBuffer& data, co if (!markdown_document) return nullptr; - return parse_html_document(markdown_document->render_to_html(), url, "utf-8"); + return HTML::parse_html_document(markdown_document->render_to_html(), url, "utf-8"); } static RefPtr create_text_document(const ByteBuffer& data, const URL& url) @@ -116,7 +116,7 @@ static RefPtr create_gemini_document(const ByteBuffer& data, cons { auto markdown_document = Gemini::Document::parse({ (const char*)data.data(), data.size() }, url); - return parse_html_document(markdown_document->render_to_html(), url, "utf-8"); + return HTML::parse_html_document(markdown_document->render_to_html(), url, "utf-8"); } RefPtr FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding) @@ -130,7 +130,7 @@ RefPtr FrameLoader::create_document_from_mime_type(const ByteBuff if (mime_type == "text/gemini") return create_gemini_document(data, url); if (mime_type == "text/html") { - HTMLDocumentParser parser(data, encoding); + HTML::HTMLDocumentParser parser(data, encoding); parser.run(url); return parser.document(); } @@ -189,7 +189,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error) String::copy(data).characters(), escape_html_entities(failed_url.to_string()).characters(), escape_html_entities(error).characters()); - auto document = parse_html_document(html, failed_url, "utf-8"); + auto document = HTML::parse_html_document(html, failed_url, "utf-8"); ASSERT(document); frame().set_document(document); frame().page().client().page_did_change_title(document->title()); diff --git a/Libraries/LibWeb/PageView.cpp b/Libraries/LibWeb/PageView.cpp index 4a08bdef45..69ecd7ea98 100644 --- a/Libraries/LibWeb/PageView.cpp +++ b/Libraries/LibWeb/PageView.cpp @@ -383,7 +383,7 @@ void PageView::reload() void PageView::load_html(const StringView& html, const URL& url) { - HTMLDocumentParser parser(html, "utf-8"); + HTML::HTMLDocumentParser parser(html, "utf-8"); parser.run(url); set_document(&parser.document()); } diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 9b5e0058eb..96da68d5cf 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -32,20 +32,20 @@ #include #include #include +#include #include #include #include -#include #include #include +namespace Web::HTML { + #define PARSE_ERROR() \ do { \ dbg() << "Parse error! " << __PRETTY_FUNCTION__ << " @ " << __LINE__; \ } while (0) -namespace Web { - static Vector s_quirks_public_ids = { "+//Silmaril//dtd html Pro v0r11 19970101//", "-//AS//DTD HTML 3.0 asWedit + extensions//", diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.h b/Libraries/LibWeb/Parser/HTMLDocumentParser.h index 390f913890..ebcfd9ec46 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.h +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.h @@ -32,6 +32,8 @@ #include #include +namespace Web::HTML { + #define ENUMERATE_INSERTION_MODES \ __ENUMERATE_INSERTION_MODE(Initial) \ __ENUMERATE_INSERTION_MODE(BeforeHTML) \ @@ -57,8 +59,6 @@ __ENUMERATE_INSERTION_MODE(AfterAfterBody) \ __ENUMERATE_INSERTION_MODE(AfterAfterFrameset) -namespace Web { - RefPtr parse_html_document(const StringView&, const URL&, const String& encoding); class HTMLDocumentParser { diff --git a/Libraries/LibWeb/Parser/HTMLToken.cpp b/Libraries/LibWeb/Parser/HTMLToken.cpp index ada76e415a..2a82660297 100644 --- a/Libraries/LibWeb/Parser/HTMLToken.cpp +++ b/Libraries/LibWeb/Parser/HTMLToken.cpp @@ -26,7 +26,7 @@ #include -namespace Web { +namespace Web::HTML { String HTMLToken::to_string() const { diff --git a/Libraries/LibWeb/Parser/HTMLToken.h b/Libraries/LibWeb/Parser/HTMLToken.h index 879296f7c4..13e12e9a83 100644 --- a/Libraries/LibWeb/Parser/HTMLToken.h +++ b/Libraries/LibWeb/Parser/HTMLToken.h @@ -33,7 +33,7 @@ #include #include -namespace Web { +namespace Web::HTML { class HTMLToken { friend class HTMLDocumentParser; diff --git a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp index 4ac64210f5..7a03e77aa5 100644 --- a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp +++ b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp @@ -30,6 +30,8 @@ #include #include +namespace Web::HTML { + #pragma GCC diagnostic ignored "-Wunused-label" //#define TOKENIZER_TRACE @@ -211,8 +213,6 @@ static inline bool is_control(u32 codepoint) return is_c0_control(codepoint) || (codepoint >= 0x7f && codepoint <= 0x9f); } -namespace Web { - Optional HTMLTokenizer::next_codepoint() { if (m_utf8_iterator == m_utf8_view.end()) diff --git a/Libraries/LibWeb/Parser/HTMLTokenizer.h b/Libraries/LibWeb/Parser/HTMLTokenizer.h index af714dbde6..1f8b8e6648 100644 --- a/Libraries/LibWeb/Parser/HTMLTokenizer.h +++ b/Libraries/LibWeb/Parser/HTMLTokenizer.h @@ -33,6 +33,8 @@ #include #include +namespace Web::HTML { + #define ENUMERATE_TOKENIZER_STATES \ __ENUMERATE_TOKENIZER_STATE(Data) \ __ENUMERATE_TOKENIZER_STATE(RCDATA) \ @@ -115,8 +117,6 @@ __ENUMERATE_TOKENIZER_STATE(DecimalCharacterReference) \ __ENUMERATE_TOKENIZER_STATE(NumericCharacterReferenceEnd) -namespace Web { - class HTMLTokenizer { public: explicit HTMLTokenizer(const StringView& input, const String& encoding); diff --git a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp index d3f19e9778..9594fd0024 100644 --- a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp +++ b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.cpp @@ -27,7 +27,7 @@ #include #include -namespace Web { +namespace Web::HTML { ListOfActiveFormattingElements::~ListOfActiveFormattingElements() { diff --git a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h index 40a9d091f0..65064be7e5 100644 --- a/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h +++ b/Libraries/LibWeb/Parser/ListOfActiveFormattingElements.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { class ListOfActiveFormattingElements { public: diff --git a/Libraries/LibWeb/Parser/StackOfOpenElements.cpp b/Libraries/LibWeb/Parser/StackOfOpenElements.cpp index 61632753f3..9624c483b8 100644 --- a/Libraries/LibWeb/Parser/StackOfOpenElements.cpp +++ b/Libraries/LibWeb/Parser/StackOfOpenElements.cpp @@ -28,7 +28,7 @@ #include #include -namespace Web { +namespace Web::HTML { static Vector s_base_list { "applet", "caption", "html", "table", "td", "th", "marquee", "object", "template" }; diff --git a/Libraries/LibWeb/Parser/StackOfOpenElements.h b/Libraries/LibWeb/Parser/StackOfOpenElements.h index 09a299c48c..54a709d943 100644 --- a/Libraries/LibWeb/Parser/StackOfOpenElements.h +++ b/Libraries/LibWeb/Parser/StackOfOpenElements.h @@ -30,7 +30,7 @@ #include #include -namespace Web { +namespace Web::HTML { class StackOfOpenElements { public: diff --git a/Userland/test-web.cpp b/Userland/test-web.cpp index cf763a08d1..3a5aba070c 100644 --- a/Userland/test-web.cpp +++ b/Userland/test-web.cpp @@ -222,7 +222,7 @@ void TestRunner::run() { Web::ResourceLoader::the().load_sync( page_to_load, [&](auto data, auto&) { - Web::HTMLDocumentParser parser(data, "utf-8", *m_page_view->document()); + Web::HTML::HTMLDocumentParser parser(data, "utf-8", *m_page_view->document()); parser.run(page_to_load); }, [page_to_load](auto error) { @@ -326,7 +326,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path) page_to_load, [&](auto data, auto&) { // Create a new parser and immediately get its document to replace the old interpreter. - Web::HTMLDocumentParser parser(data, "utf-8"); + Web::HTML::HTMLDocumentParser parser(data, "utf-8"); auto& new_interpreter = parser.document().interpreter(); // Setup the test environment and call "__BeforeInitialPageLoad__"