1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

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

This commit is contained in:
Andreas Kling 2020-07-28 18:20:36 +02:00
parent ebd2e7d9f5
commit c46439f240
82 changed files with 238 additions and 247 deletions

View file

@ -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<Web::HTMLElement*>(document->body())->set_attribute(Web::HTML::AttributeNames::style, "background-color: #dac7b5;");
const_cast<Web::HTML::HTMLElement*>(document->body())->set_attribute(Web::HTML::AttributeNames::style, "background-color: #dac7b5;");
}
m_documentation_tooltip_window->move_to(screen_location.translated(4, 4));

View file

@ -80,48 +80,48 @@ NodeWrapper* wrap(JS::GlobalObject& global_object, DOM::Node& 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<HTMLAnchorElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLAnchorElement>(node)));
if (is<HTMLBodyElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLBodyElement>(node)));
if (is<HTMLBRElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLBRElement>(node)));
if (is<HTMLCanvasElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLCanvasElement>(node)));
if (is<HTMLFormElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLFormElement>(node)));
if (is<HTMLHeadElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHeadElement>(node)));
if (is<HTMLHeadingElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHeadingElement>(node)));
if (is<HTMLHRElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHRElement>(node)));
if (is<HTMLHtmlElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLHtmlElement>(node)));
if (is<HTMLIFrameElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLIFrameElement>(node)));
if (is<HTMLImageElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLImageElement>(node)));
if (is<HTMLInputElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLInputElement>(node)));
if (is<HTMLLinkElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLLinkElement>(node)));
if (is<HTMLObjectElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLObjectElement>(node)));
if (is<HTMLScriptElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLScriptElement>(node)));
if (is<HTMLStyleElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLStyleElement>(node)));
if (is<HTMLTableCellElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableCellElement>(node)));
if (is<HTMLTableElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableElement>(node)));
if (is<HTMLTableRowElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTableRowElement>(node)));
if (is<HTMLTitleElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLTitleElement>(node)));
if (is<HTMLElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTMLElement>(node)));
if (is<HTML::HTMLAnchorElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLAnchorElement>(node)));
if (is<HTML::HTMLBodyElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLBodyElement>(node)));
if (is<HTML::HTMLBRElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLBRElement>(node)));
if (is<HTML::HTMLCanvasElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLCanvasElement>(node)));
if (is<HTML::HTMLFormElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLFormElement>(node)));
if (is<HTML::HTMLHeadElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLHeadElement>(node)));
if (is<HTML::HTMLHeadingElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLHeadingElement>(node)));
if (is<HTML::HTMLHRElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLHRElement>(node)));
if (is<HTML::HTMLHtmlElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLHtmlElement>(node)));
if (is<HTML::HTMLIFrameElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLIFrameElement>(node)));
if (is<HTML::HTMLImageElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLImageElement>(node)));
if (is<HTML::HTMLInputElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLInputElement>(node)));
if (is<HTML::HTMLLinkElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLLinkElement>(node)));
if (is<HTML::HTMLObjectElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLObjectElement>(node)));
if (is<HTML::HTMLScriptElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLScriptElement>(node)));
if (is<HTML::HTMLStyleElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLStyleElement>(node)));
if (is<HTML::HTMLTableCellElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableCellElement>(node)));
if (is<HTML::HTMLTableElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableElement>(node)));
if (is<HTML::HTMLTableRowElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTableRowElement>(node)));
if (is<HTML::HTMLTitleElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLTitleElement>(node)));
if (is<HTML::HTMLElement>(node))
return static_cast<NodeWrapper*>(wrap_impl(global_object, downcast<HTML::HTMLElement>(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));

View file

@ -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 <LibWeb/Bindings/CanvasRenderingContext2DWrapper.h>";
// 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 {";

View file

@ -117,7 +117,7 @@ void Document::fixup()
if (!first_child() || !is<DocumentType>(*first_child()))
prepend_child(adopt(*new DocumentType(*this)));
if (is<HTMLHtmlElement>(first_child()->next_sibling()))
if (is<HTML::HTMLHtmlElement>(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<HTMLHtmlElement>();
return first_child_of_type<HTML::HTMLHtmlElement>();
}
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<HTMLHeadElement>();
return html->first_child_of_type<HTML::HTMLHeadElement>();
}
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<HTMLBodyElement>();
return html->first_child_of_type<HTML::HTMLBodyElement>();
}
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<HTMLTitleElement>();
auto* title_element = head_element->first_child_of_type<HTML::HTMLTitleElement>();
if (!title_element)
return {};
@ -441,32 +441,32 @@ NonnullRefPtr<Text> Document::create_text_node(const String& data)
return adopt(*new Text(*this, data));
}
void Document::set_pending_parsing_blocking_script(Badge<HTMLScriptElement>, HTMLScriptElement* script)
void Document::set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement* script)
{
m_pending_parsing_blocking_script = script;
}
NonnullRefPtr<HTMLScriptElement> Document::take_pending_parsing_blocking_script(Badge<HTMLDocumentParser>)
NonnullRefPtr<HTML::HTMLScriptElement> Document::take_pending_parsing_blocking_script(Badge<HTML::HTMLDocumentParser>)
{
return m_pending_parsing_blocking_script.release_nonnull();
}
void Document::add_script_to_execute_when_parsing_has_finished(Badge<HTMLScriptElement>, HTMLScriptElement& script)
void Document::add_script_to_execute_when_parsing_has_finished(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement& script)
{
m_scripts_to_execute_when_parsing_has_finished.append(script);
}
NonnullRefPtrVector<HTMLScriptElement> Document::take_scripts_to_execute_when_parsing_has_finished(Badge<HTMLDocumentParser>)
NonnullRefPtrVector<HTML::HTMLScriptElement> Document::take_scripts_to_execute_when_parsing_has_finished(Badge<HTML::HTMLDocumentParser>)
{
return move(m_scripts_to_execute_when_parsing_has_finished);
}
void Document::add_script_to_execute_as_soon_as_possible(Badge<HTMLScriptElement>, HTMLScriptElement& script)
void Document::add_script_to_execute_as_soon_as_possible(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement& script)
{
m_scripts_to_execute_as_soon_as_possible.append(script);
}
NonnullRefPtrVector<HTMLScriptElement> Document::take_scripts_to_execute_as_soon_as_possible(Badge<HTMLDocumentParser>)
NonnullRefPtrVector<HTML::HTMLScriptElement> Document::take_scripts_to_execute_as_soon_as_possible(Badge<HTML::HTMLDocumentParser>)
{
return move(m_scripts_to_execute_as_soon_as_possible);
}

View file

@ -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<Element> create_element(const String& tag_name);
NonnullRefPtr<Text> create_text_node(const String& data);
void set_pending_parsing_blocking_script(Badge<HTMLScriptElement>, HTMLScriptElement*);
HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; }
NonnullRefPtr<HTMLScriptElement> take_pending_parsing_blocking_script(Badge<HTMLDocumentParser>);
void set_pending_parsing_blocking_script(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement*);
HTML::HTMLScriptElement* pending_parsing_blocking_script() { return m_pending_parsing_blocking_script; }
NonnullRefPtr<HTML::HTMLScriptElement> take_pending_parsing_blocking_script(Badge<HTML::HTMLDocumentParser>);
void add_script_to_execute_when_parsing_has_finished(Badge<HTMLScriptElement>, HTMLScriptElement&);
NonnullRefPtrVector<HTMLScriptElement> take_scripts_to_execute_when_parsing_has_finished(Badge<HTMLDocumentParser>);
void add_script_to_execute_when_parsing_has_finished(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement&);
NonnullRefPtrVector<HTML::HTMLScriptElement> take_scripts_to_execute_when_parsing_has_finished(Badge<HTML::HTMLDocumentParser>);
void add_script_to_execute_as_soon_as_possible(Badge<HTMLScriptElement>, HTMLScriptElement&);
NonnullRefPtrVector<HTMLScriptElement> take_scripts_to_execute_as_soon_as_possible(Badge<HTMLDocumentParser>);
void add_script_to_execute_as_soon_as_possible(Badge<HTML::HTMLScriptElement>, HTML::HTMLScriptElement&);
NonnullRefPtrVector<HTML::HTMLScriptElement> take_scripts_to_execute_as_soon_as_possible(Badge<HTML::HTMLDocumentParser>);
QuirksMode mode() const { return m_quirks_mode; }
bool in_quirks_mode() const { return m_quirks_mode == QuirksMode::Yes; }
@ -181,9 +181,9 @@ private:
OwnPtr<JS::Interpreter> m_interpreter;
RefPtr<HTMLScriptElement> m_pending_parsing_blocking_script;
NonnullRefPtrVector<HTMLScriptElement> m_scripts_to_execute_when_parsing_has_finished;
NonnullRefPtrVector<HTMLScriptElement> m_scripts_to_execute_as_soon_as_possible;
RefPtr<HTML::HTMLScriptElement> m_pending_parsing_blocking_script;
NonnullRefPtrVector<HTML::HTMLScriptElement> m_scripts_to_execute_when_parsing_has_finished;
NonnullRefPtrVector<HTML::HTMLScriptElement> m_scripts_to_execute_as_soon_as_possible;
QuirksMode m_quirks_mode { QuirksMode::No };
};

View file

@ -252,7 +252,7 @@ NonnullRefPtr<CSS::StyleProperties> 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());

View file

@ -57,49 +57,49 @@ NonnullRefPtr<Element> 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)

View file

@ -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<HTMLAnchorElement>(*node) && downcast<HTMLAnchorElement>(*node).has_attribute(HTML::AttributeNames::href))
return downcast<HTMLAnchorElement>(node);
if (is<HTML::HTMLAnchorElement>(*node) && downcast<HTML::HTMLAnchorElement>(*node).has_attribute(HTML::AttributeNames::href))
return downcast<HTML::HTMLAnchorElement>(node);
}
return nullptr;
}
const HTMLElement* Node::enclosing_html_element() const
const HTML::HTMLElement* Node::enclosing_html_element() const
{
return first_ancestor_of_type<HTMLElement>();
return first_ancestor_of_type<HTML::HTMLElement>();
}
String Node::text_content() const

View file

@ -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;

View file

@ -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;

View file

@ -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<DOM::Node> node = result.layout_node->node();
if (is<HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
if (is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*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<HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
if (is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*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<HTMLAnchorElement> link = node->enclosing_link_element()) {
if (RefPtr<HTML::HTMLAnchorElement> 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<DOM::Node> node = result.layout_node->node();
if (node && is<HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTMLIFrameElement>(*node).hosted_frame())
if (node && is<HTML::HTMLIFrameElement>(*node)) {
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*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<HTMLElement> hovered_html_element = document.hovered_node() ? document.hovered_node()->enclosing_html_element() : nullptr;
RefPtr<HTML::HTMLElement> 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 {

View file

@ -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<HTMLAnchorElement>(*candidate)) {
element = downcast<HTMLAnchorElement>(candidate);
if (is<HTML::HTMLAnchorElement>(*candidate)) {
element = downcast<HTML::HTMLAnchorElement>(candidate);
break;
}
}

View file

@ -32,7 +32,7 @@
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/HTML/ImageData.h>
namespace Web {
namespace Web::HTML {
CanvasRenderingContext2D::CanvasRenderingContext2D(HTMLCanvasElement& element)
: m_element(element.make_weak_ptr())

View file

@ -34,7 +34,7 @@
#include <LibGfx/Path.h>
#include <LibWeb/Bindings/Wrappable.h>
namespace Web {
namespace Web::HTML {
class CanvasRenderingContext2D
: public RefCounted<CanvasRenderingContext2D>

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLAnchorElement.h>
namespace Web {
namespace Web::HTML {
HTMLAnchorElement::HTMLAnchorElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::a; }
AK_END_TYPE_TRAITS()

View file

@ -27,7 +27,7 @@
#include <LibWeb/HTML/HTMLBRElement.h>
#include <LibWeb/Layout/LayoutBreak.h>
namespace Web {
namespace Web::HTML {
HTMLBRElement::HTMLBRElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::br; }
AK_END_TYPE_TRAITS()

View file

@ -30,7 +30,7 @@
#include <LibWeb/HTML/HTMLBlinkElement.h>
#include <LibWeb/Layout/LayoutNode.h>
namespace Web {
namespace Web::HTML {
HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -29,7 +29,7 @@
#include <LibCore/Forward.h>
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::blink; }
AK_END_TYPE_TRAITS()

View file

@ -29,7 +29,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLBodyElement.h>
namespace Web {
namespace Web::HTML {
HTMLBodyElement::HTMLBodyElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::body; }
AK_END_TYPE_TRAITS()

View file

@ -32,7 +32,7 @@
#include <LibWeb/HTML/HTMLCanvasElement.h>
#include <LibWeb/Layout/LayoutCanvas.h>
namespace Web {
namespace Web::HTML {
static constexpr auto max_canvas_area = 16384 * 16384;

View file

@ -30,7 +30,7 @@
#include <LibGfx/Forward.h>
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::canvas; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLElement.h>
namespace Web {
namespace Web::HTML {
HTMLElement::HTMLElement(DOM::Document& document, const FlyString& tag_name)
: Element(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/DOM/Element.h>
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()

View file

@ -28,7 +28,7 @@
#include <LibWeb/CSS/StyleValue.h>
#include <LibWeb/HTML/HTMLFontElement.h>
namespace Web {
namespace Web::HTML {
HTMLFontElement::HTMLFontElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::font; }
AK_END_TYPE_TRAITS()

View file

@ -31,7 +31,7 @@
#include <LibWeb/PageView.h>
#include <LibWeb/URLEncoder.h>
namespace Web {
namespace Web::HTML {
HTMLFormElement::HTMLFormElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -29,7 +29,7 @@
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::form; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLHRElement.h>
namespace Web {
namespace Web::HTML {
HTMLHRElement::HTMLHRElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::hr; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLHeadElement.h>
namespace Web {
namespace Web::HTML {
HTMLHeadElement::HTMLHeadElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::head; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLHeadingElement.h>
namespace Web {
namespace Web::HTML {
HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(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()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLHtmlElement.h>
namespace Web {
namespace Web::HTML {
HTMLHtmlElement::HTMLHtmlElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::html; }
AK_END_TYPE_TRAITS()

View file

@ -39,7 +39,7 @@
#include <LibWeb/PageView.h>
#include <LibWeb/Parser/HTMLDocumentParser.h>
namespace Web {
namespace Web::HTML {
HTMLIFrameElement::HTMLIFrameElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::iframe; }
AK_END_TYPE_TRAITS()

View file

@ -35,7 +35,7 @@
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Parser/CSSParser.h>
namespace Web {
namespace Web::HTML {
HTMLImageElement::HTMLImageElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -32,9 +32,7 @@
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/Loader/ImageLoader.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::img; }
AK_END_TYPE_TRAITS()

View file

@ -35,7 +35,7 @@
#include <LibWeb/Layout/LayoutWidget.h>
#include <LibWeb/PageView.h>
namespace Web {
namespace Web::HTML {
HTMLInputElement::HTMLInputElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::input; }
AK_END_TYPE_TRAITS()

View file

@ -32,7 +32,7 @@
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Parser/CSSParser.h>
namespace Web {
namespace Web::HTML {
HTMLLinkElement::HTMLLinkElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -29,7 +29,7 @@
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/Loader/Resource.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::link; }
AK_END_TYPE_TRAITS()

View file

@ -33,7 +33,7 @@
#include <LibWeb/Layout/LayoutImage.h>
#include <LibWeb/Loader/ResourceLoader.h>
namespace Web {
namespace Web::HTML {
HTMLObjectElement::HTMLObjectElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -31,9 +31,7 @@
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/Loader/ImageLoader.h>
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<Web::DOM::Element>(node).local_name() == Web::HTML::TagNames::object; }
AK_END_TYPE_TRAITS()

View file

@ -32,7 +32,7 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Loader/ResourceLoader.h>
namespace Web {
namespace Web::HTML {
HTMLScriptElement::HTMLScriptElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -29,7 +29,7 @@
#include <AK/Function.h>
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::script; }
AK_END_TYPE_TRAITS()

View file

@ -30,7 +30,7 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Parser/CSSParser.h>
namespace Web {
namespace Web::HTML {
HTMLStyleElement::HTMLStyleElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::style; }
AK_END_TYPE_TRAITS()

View file

@ -27,7 +27,7 @@
#include <LibWeb/HTML/HTMLTableCellElement.h>
#include <LibWeb/Parser/CSSParser.h>
namespace Web {
namespace Web::HTML {
HTMLTableCellElement::HTMLTableCellElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name().is_one_of(Web::HTML::TagNames::td, Web::HTML::TagNames::th); }
AK_END_TYPE_TRAITS()

View file

@ -27,7 +27,7 @@
#include <LibWeb/HTML/HTMLTableElement.h>
#include <LibWeb/Parser/CSSParser.h>
namespace Web {
namespace Web::HTML {
HTMLTableElement::HTMLTableElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::table; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLTableRowElement.h>
namespace Web {
namespace Web::HTML {
HTMLTableRowElement::HTMLTableRowElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::tr; }
AK_END_TYPE_TRAITS()

View file

@ -26,7 +26,7 @@
#include <LibWeb/HTML/HTMLTitleElement.h>
namespace Web {
namespace Web::HTML {
HTMLTitleElement::HTMLTitleElement(DOM::Document& document, const FlyString& tag_name)
: HTMLElement(document, tag_name)

View file

@ -28,7 +28,7 @@
#include <LibWeb/HTML/HTMLElement.h>
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<Web::HTMLElement>(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<Web::HTML::HTMLElement>(node).local_name() == Web::HTML::TagNames::title; }
AK_END_TYPE_TRAITS()

View file

@ -28,7 +28,7 @@
#include <LibJS/Runtime/Uint8ClampedArray.h>
#include <LibWeb/HTML/ImageData.h>
namespace Web {
namespace Web::HTML {
RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, int width, int height)
{

View file

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

View file

@ -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);

View file

@ -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<HTMLBRElement>(*LayoutNode::node()); }
const HTML::HTMLBRElement& node() const { return downcast<HTML::HTMLBRElement>(*LayoutNode::node()); }
private:
virtual bool is_break() const override { return true; }

View file

@ -31,7 +31,7 @@
namespace Web {
LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTMLCanvasElement& element, NonnullRefPtr<CSS::StyleProperties> style)
LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTML::HTMLCanvasElement& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutReplaced(document, element, move(style))
{
}

View file

@ -31,24 +31,21 @@
namespace Web {
class HTMLCanvasElement;
class LayoutCanvas : public LayoutReplaced {
public:
LayoutCanvas(DOM::Document&, const HTMLCanvasElement&, NonnullRefPtr<CSS::StyleProperties>);
LayoutCanvas(DOM::Document&, const HTML::HTMLCanvasElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutCanvas() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;
virtual void paint(PaintContext&, PaintPhase) override;
const HTMLCanvasElement& node() const { return static_cast<const HTMLCanvasElement&>(LayoutReplaced::node()); }
const HTML::HTMLCanvasElement& node() const { return static_cast<const HTML::HTMLCanvasElement&>(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)

View file

@ -39,8 +39,8 @@ public:
virtual void paint(PaintContext&, PaintPhase) override;
virtual void layout(LayoutMode) override;
const HTMLIFrameElement& node() const { return static_cast<const HTMLIFrameElement&>(LayoutReplaced::node()); }
HTMLIFrameElement& node() { return static_cast<HTMLIFrameElement&>(LayoutReplaced::node()); }
const HTML::HTMLIFrameElement& node() const { return downcast<HTML::HTMLIFrameElement>(LayoutReplaced::node()); }
HTML::HTMLIFrameElement& node() { return downcast<HTML::HTMLIFrameElement>(LayoutReplaced::node()); }
private:
virtual bool is_frame() const final { return true; }

View file

@ -71,7 +71,7 @@ void LayoutImage::layout(LayoutMode layout_mode)
}
if (renders_as_alt_text()) {
auto& image_element = downcast<HTMLImageElement>(node());
auto& image_element = downcast<HTML::HTMLImageElement>(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<HTMLImageElement>(node());
auto& image_element = downcast<HTML::HTMLImageElement>(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<HTMLImageElement>(node()))
if (is<HTML::HTMLImageElement>(node()))
return !m_image_loader.has_image();
return false;
}

View file

@ -31,8 +31,6 @@
namespace Web {
class HTMLImageElement;
class LayoutImage : public LayoutReplaced {
public:
LayoutImage(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);

View file

@ -54,7 +54,7 @@ static RefPtr<DOM::Document> 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<DOM::Document> create_text_document(const ByteBuffer& data, const URL& url)
@ -116,7 +116,7 @@ static RefPtr<DOM::Document> 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<DOM::Document> FrameLoader::create_document_from_mime_type(const ByteBuffer& data, const URL& url, const String& mime_type, const String& encoding)
@ -130,7 +130,7 @@ RefPtr<DOM::Document> 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());

View file

@ -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());
}

View file

@ -32,20 +32,20 @@
#include <LibWeb/DOM/DocumentType.h>
#include <LibWeb/DOM/ElementFactory.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Parser/HTMLDocumentParser.h>
#include <LibWeb/Parser/HTMLToken.h>
namespace Web::HTML {
#define PARSE_ERROR() \
do { \
dbg() << "Parse error! " << __PRETTY_FUNCTION__ << " @ " << __LINE__; \
} while (0)
namespace Web {
static Vector<FlyString> s_quirks_public_ids = {
"+//Silmaril//dtd html Pro v0r11 19970101//",
"-//AS//DTD HTML 3.0 asWedit + extensions//",

View file

@ -32,6 +32,8 @@
#include <LibWeb/Parser/ListOfActiveFormattingElements.h>
#include <LibWeb/Parser/StackOfOpenElements.h>
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<DOM::Document> parse_html_document(const StringView&, const URL&, const String& encoding);
class HTMLDocumentParser {

View file

@ -26,7 +26,7 @@
#include <LibWeb/Parser/HTMLToken.h>
namespace Web {
namespace Web::HTML {
String HTMLToken::to_string() const
{

View file

@ -33,7 +33,7 @@
#include <AK/Utf8View.h>
#include <AK/Vector.h>
namespace Web {
namespace Web::HTML {
class HTMLToken {
friend class HTMLDocumentParser;

View file

@ -30,6 +30,8 @@
#include <LibWeb/Parser/HTMLTokenizer.h>
#include <ctype.h>
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<u32> HTMLTokenizer::next_codepoint()
{
if (m_utf8_iterator == m_utf8_view.end())

View file

@ -33,6 +33,8 @@
#include <LibWeb/Forward.h>
#include <LibWeb/Parser/HTMLToken.h>
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);

View file

@ -27,7 +27,7 @@
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Parser/ListOfActiveFormattingElements.h>
namespace Web {
namespace Web::HTML {
ListOfActiveFormattingElements::~ListOfActiveFormattingElements()
{

View file

@ -30,7 +30,7 @@
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Forward.h>
namespace Web {
namespace Web::HTML {
class ListOfActiveFormattingElements {
public:

View file

@ -28,7 +28,7 @@
#include <LibWeb/Parser/HTMLDocumentParser.h>
#include <LibWeb/Parser/StackOfOpenElements.h>
namespace Web {
namespace Web::HTML {
static Vector<FlyString> s_base_list { "applet", "caption", "html", "table", "td", "th", "marquee", "object", "template" };

View file

@ -30,7 +30,7 @@
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Forward.h>
namespace Web {
namespace Web::HTML {
class StackOfOpenElements {
public:

View file

@ -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__"