1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:07:36 +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

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