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

LibWeb: Rename Element::tag_name() => local_name()

To prepare for fully qualified tag names, let's call this local_name.
Note that we still keep an Element::tag_name() around since that's what
the JS bindings end up calling into for the Element.tagName property.
This commit is contained in:
Andreas Kling 2020-07-23 18:18:13 +02:00
parent 9d4cd565e3
commit 3cb50a4714
34 changed files with 140 additions and 137 deletions

View file

@ -110,7 +110,7 @@ bool matches(const Selector::SimpleSelector& component, const Element& element)
case Selector::SimpleSelector::Type::Class: case Selector::SimpleSelector::Type::Class:
return element.has_class(component.value); return element.has_class(component.value);
case Selector::SimpleSelector::Type::TagName: case Selector::SimpleSelector::Type::TagName:
return component.value == element.tag_name(); return component.value == element.local_name();
default: default:
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }

View file

@ -334,11 +334,11 @@ Vector<const Element*> Document::get_elements_by_name(const String& name) const
return elements; return elements;
} }
NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const String& tag_name) const NonnullRefPtrVector<Element> Document::get_elements_by_tag_name(const FlyString& tag_name) const
{ {
NonnullRefPtrVector<Element> elements; NonnullRefPtrVector<Element> elements;
for_each_in_subtree_of_type<Element>([&](auto& element) { for_each_in_subtree_of_type<Element>([&](auto& element) {
if (element.tag_name() == tag_name) if (element.local_name() == tag_name)
elements.append(element); elements.append(element);
return IterationDecision::Continue; return IterationDecision::Continue;
}); });

View file

@ -124,7 +124,7 @@ public:
void schedule_style_update(); void schedule_style_update();
Vector<const Element*> get_elements_by_name(const String&) const; Vector<const Element*> get_elements_by_name(const String&) const;
NonnullRefPtrVector<Element> get_elements_by_tag_name(const String&) const; NonnullRefPtrVector<Element> get_elements_by_tag_name(const FlyString&) const;
RefPtr<Element> query_selector(const StringView&); RefPtr<Element> query_selector(const StringView&);
NonnullRefPtrVector<Element> query_selector_all(const StringView&); NonnullRefPtrVector<Element> query_selector_all(const StringView&);

View file

@ -116,7 +116,7 @@ RefPtr<LayoutNode> Element::create_layout_node(const StyleProperties* parent_sty
if (display == CSS::Display::None) if (display == CSS::Display::None)
return nullptr; return nullptr;
if (tag_name() == "noscript" && document().is_scripting_enabled()) if (local_name() == "noscript" && document().is_scripting_enabled())
return nullptr; return nullptr;
if (display == CSS::Display::Block) if (display == CSS::Display::Block)
@ -271,13 +271,13 @@ String Element::inner_html() const
for (auto* child = node.first_child(); child; child = child->next_sibling()) { for (auto* child = node.first_child(); child; child = child->next_sibling()) {
if (child->is_element()) { if (child->is_element()) {
builder.append('<'); builder.append('<');
builder.append(to<Element>(*child).tag_name()); builder.append(to<Element>(*child).local_name());
builder.append('>'); builder.append('>');
recurse(*child); recurse(*child);
builder.append("</"); builder.append("</");
builder.append(to<Element>(*child).tag_name()); builder.append(to<Element>(*child).local_name());
builder.append('>'); builder.append('>');
} }
if (child->is_text()) { if (child->is_text()) {

View file

@ -42,11 +42,14 @@ class Element : public ParentNode {
public: public:
using WrapperType = Bindings::ElementWrapper; using WrapperType = Bindings::ElementWrapper;
Element(Document&, const FlyString& tag_name); Element(Document&, const FlyString& local_name);
virtual ~Element() override; virtual ~Element() override;
virtual FlyString node_name() const final { return m_tag_name; } virtual FlyString node_name() const final { return m_tag_name; }
const FlyString& tag_name() const { return m_tag_name; } const FlyString& local_name() const { return m_tag_name; }
// NOTE: This is for the JS bindings
const FlyString& tag_name() const { return local_name(); }
bool has_attribute(const FlyString& name) const { return !attribute(name).is_null(); } bool has_attribute(const FlyString& name) const { return !attribute(name).is_null(); }
String attribute(const FlyString& name) const; String attribute(const FlyString& name) const;

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLAnchorElement : public HTMLElement { class HTMLAnchorElement : public HTMLElement {
public: public:
HTMLAnchorElement(Document&, const FlyString& tag_name); HTMLAnchorElement(Document&, const FlyString& local_name);
virtual ~HTMLAnchorElement() override; virtual ~HTMLAnchorElement() override;
String href() const { return attribute(HTML::AttributeNames::href); } String href() const { return attribute(HTML::AttributeNames::href); }
@ -42,7 +42,7 @@ public:
template<> template<>
inline bool is<HTMLAnchorElement>(const Node& node) inline bool is<HTMLAnchorElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::a; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::a;
} }
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLBRElement final : public HTMLElement { class HTMLBRElement final : public HTMLElement {
public: public:
HTMLBRElement(Document&, const FlyString& tag_name); HTMLBRElement(Document&, const FlyString& local_name);
virtual ~HTMLBRElement() override; virtual ~HTMLBRElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@ -41,7 +41,7 @@ public:
template<> template<>
inline bool is<HTMLBRElement>(const Node& node) inline bool is<HTMLBRElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::br; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::br;
} }
} }

View file

@ -33,7 +33,7 @@ namespace Web {
class HTMLBlinkElement : public HTMLElement { class HTMLBlinkElement : public HTMLElement {
public: public:
HTMLBlinkElement(Document&, const FlyString& tag_name); HTMLBlinkElement(Document&, const FlyString& local_name);
virtual ~HTMLBlinkElement() override; virtual ~HTMLBlinkElement() override;
private: private:
@ -45,7 +45,7 @@ private:
template<> template<>
inline bool is<HTMLBlinkElement>(const Node& node) inline bool is<HTMLBlinkElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::blink; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::blink;
} }
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLBodyElement : public HTMLElement { class HTMLBodyElement : public HTMLElement {
public: public:
HTMLBodyElement(Document&, const FlyString& tag_name); HTMLBodyElement(Document&, const FlyString& local_name);
virtual ~HTMLBodyElement() override; virtual ~HTMLBodyElement() override;
virtual void parse_attribute(const FlyString&, const String&) override; virtual void parse_attribute(const FlyString&, const String&) override;
@ -45,7 +45,7 @@ private:
template<> template<>
inline bool is<HTMLBodyElement>(const Node& node) inline bool is<HTMLBodyElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::body; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::body;
} }
} }

View file

@ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement {
public: public:
using WrapperType = Bindings::HTMLCanvasElementWrapper; using WrapperType = Bindings::HTMLCanvasElementWrapper;
HTMLCanvasElement(Document&, const FlyString& tag_name); HTMLCanvasElement(Document&, const FlyString& local_name);
virtual ~HTMLCanvasElement() override; virtual ~HTMLCanvasElement() override;
const Gfx::Bitmap* bitmap() const { return m_bitmap; } const Gfx::Bitmap* bitmap() const { return m_bitmap; }
@ -60,7 +60,7 @@ private:
template<> template<>
inline bool is<HTMLCanvasElement>(const Node& node) inline bool is<HTMLCanvasElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::canvas; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::canvas;
} }
} }

View file

@ -34,7 +34,7 @@ class HTMLElement : public Element {
public: public:
using WrapperType = Bindings::HTMLElementWrapper; using WrapperType = Bindings::HTMLElementWrapper;
HTMLElement(Document&, const FlyString& tag_name); HTMLElement(Document&, const FlyString& local_name);
virtual ~HTMLElement() override; virtual ~HTMLElement() override;
String title() const { return attribute(HTML::AttributeNames::title); } String title() const { return attribute(HTML::AttributeNames::title); }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLFontElement : public HTMLElement { class HTMLFontElement : public HTMLElement {
public: public:
HTMLFontElement(Document&, const FlyString& tag_name); HTMLFontElement(Document&, const FlyString& local_name);
virtual ~HTMLFontElement() override; virtual ~HTMLFontElement() override;
virtual void apply_presentational_hints(StyleProperties&) const override; virtual void apply_presentational_hints(StyleProperties&) const override;
@ -41,7 +41,7 @@ public:
template<> template<>
inline bool is<HTMLFontElement>(const Node& node) inline bool is<HTMLFontElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::font; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::font;
} }
} }

View file

@ -33,7 +33,7 @@ namespace Web {
class HTMLFormElement : public HTMLElement { class HTMLFormElement : public HTMLElement {
public: public:
HTMLFormElement(Document&, const FlyString& tag_name); HTMLFormElement(Document&, const FlyString& local_name);
virtual ~HTMLFormElement() override; virtual ~HTMLFormElement() override;
String action() const { return attribute(HTML::AttributeNames::action); } String action() const { return attribute(HTML::AttributeNames::action); }
@ -45,7 +45,7 @@ public:
template<> template<>
inline bool is<HTMLFormElement>(const Node& node) inline bool is<HTMLFormElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::form; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::form;
} }
} }

View file

@ -32,14 +32,14 @@ namespace Web {
class HTMLHRElement : public HTMLElement { class HTMLHRElement : public HTMLElement {
public: public:
HTMLHRElement(Document&, const FlyString& tag_name); HTMLHRElement(Document&, const FlyString& local_name);
virtual ~HTMLHRElement() override; virtual ~HTMLHRElement() override;
}; };
template<> template<>
inline bool is<HTMLHRElement>(const Node& node) inline bool is<HTMLHRElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::hr; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::hr;
} }
} }

View file

@ -32,14 +32,14 @@ namespace Web {
class HTMLHeadElement : public HTMLElement { class HTMLHeadElement : public HTMLElement {
public: public:
HTMLHeadElement(Document&, const FlyString& tag_name); HTMLHeadElement(Document&, const FlyString& local_name);
virtual ~HTMLHeadElement() override; virtual ~HTMLHeadElement() override;
}; };
template<> template<>
inline bool is<HTMLHeadElement>(const Node& node) inline bool is<HTMLHeadElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("head"); return is<Element>(node) && to<Element>(node).local_name().equals_ignoring_case("head");
} }
} }

View file

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

View file

@ -32,14 +32,14 @@ namespace Web {
class HTMLHtmlElement : public HTMLElement { class HTMLHtmlElement : public HTMLElement {
public: public:
HTMLHtmlElement(Document&, const FlyString& tag_name); HTMLHtmlElement(Document&, const FlyString& local_name);
virtual ~HTMLHtmlElement() override; virtual ~HTMLHtmlElement() override;
}; };
template<> template<>
inline bool is<HTMLHtmlElement>(const Node& node) inline bool is<HTMLHtmlElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("html"); return is<Element>(node) && to<Element>(node).local_name().equals_ignoring_case("html");
} }
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLIFrameElement final : public HTMLElement { class HTMLIFrameElement final : public HTMLElement {
public: public:
HTMLIFrameElement(Document&, const FlyString& tag_name); HTMLIFrameElement(Document&, const FlyString& local_name);
virtual ~HTMLIFrameElement() override; virtual ~HTMLIFrameElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@ -54,7 +54,7 @@ private:
template<> template<>
inline bool is<HTMLIFrameElement>(const Node& node) inline bool is<HTMLIFrameElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::iframe; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::iframe;
} }
} }

View file

@ -40,7 +40,7 @@ class HTMLImageElement final : public HTMLElement {
public: public:
using WrapperType = Bindings::HTMLImageElementWrapper; using WrapperType = Bindings::HTMLImageElementWrapper;
HTMLImageElement(Document&, const FlyString& tag_name); HTMLImageElement(Document&, const FlyString& local_name);
virtual ~HTMLImageElement() override; virtual ~HTMLImageElement() override;
virtual void parse_attribute(const FlyString& name, const String& value) override; virtual void parse_attribute(const FlyString& name, const String& value) override;
@ -63,7 +63,7 @@ private:
template<> template<>
inline bool is<HTMLImageElement>(const Node& node) inline bool is<HTMLImageElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::img; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::img;
} }
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLInputElement : public HTMLElement { class HTMLInputElement : public HTMLElement {
public: public:
HTMLInputElement(Document&, const FlyString& tag_name); HTMLInputElement(Document&, const FlyString& local_name);
virtual ~HTMLInputElement() override; virtual ~HTMLInputElement() override;
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override; virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
@ -45,7 +45,7 @@ public:
template<> template<>
inline bool is<HTMLInputElement>(const Node& node) inline bool is<HTMLInputElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::input; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::input;
} }
} }

View file

@ -35,7 +35,7 @@ class HTMLLinkElement final
: public HTMLElement : public HTMLElement
, public ResourceClient { , public ResourceClient {
public: public:
HTMLLinkElement(Document&, const FlyString& tag_name); HTMLLinkElement(Document&, const FlyString& local_name);
virtual ~HTMLLinkElement() override; virtual ~HTMLLinkElement() override;
virtual void inserted_into(Node&) override; virtual void inserted_into(Node&) override;
@ -67,7 +67,7 @@ private:
template<> template<>
inline bool is<HTMLLinkElement>(const Node& node) inline bool is<HTMLLinkElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::link; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::link;
} }
} }

View file

@ -37,7 +37,7 @@ class LayoutDocument;
class HTMLObjectElement final : public HTMLElement { class HTMLObjectElement final : public HTMLElement {
public: public:
HTMLObjectElement(Document&, const FlyString& tag_name); HTMLObjectElement(Document&, const FlyString& local_name);
virtual ~HTMLObjectElement() override; virtual ~HTMLObjectElement() override;
virtual void parse_attribute(const FlyString& name, const String& value) override; virtual void parse_attribute(const FlyString& name, const String& value) override;
@ -55,7 +55,7 @@ private:
template<> template<>
inline bool is<HTMLObjectElement>(const Node& node) inline bool is<HTMLObjectElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::object; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::object;
} }
} }

View file

@ -33,7 +33,7 @@ namespace Web {
class HTMLScriptElement : public HTMLElement { class HTMLScriptElement : public HTMLElement {
public: public:
HTMLScriptElement(Document&, const FlyString& tag_name); HTMLScriptElement(Document&, const FlyString& local_name);
virtual ~HTMLScriptElement() override; virtual ~HTMLScriptElement() override;
bool is_non_blocking() const { return m_non_blocking; } bool is_non_blocking() const { return m_non_blocking; }
@ -68,7 +68,7 @@ private:
template<> template<>
inline bool is<HTMLScriptElement>(const Node& node) inline bool is<HTMLScriptElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::script; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::script;
} }
} }

View file

@ -34,7 +34,7 @@ class StyleSheet;
class HTMLStyleElement : public HTMLElement { class HTMLStyleElement : public HTMLElement {
public: public:
HTMLStyleElement(Document&, const FlyString& tag_name); HTMLStyleElement(Document&, const FlyString& local_name);
virtual ~HTMLStyleElement() override; virtual ~HTMLStyleElement() override;
virtual void children_changed() override; virtual void children_changed() override;
@ -47,7 +47,7 @@ private:
template<> template<>
inline bool is<HTMLStyleElement>(const Node& node) inline bool is<HTMLStyleElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::style; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::style;
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLTableCellElement final : public HTMLElement { class HTMLTableCellElement final : public HTMLElement {
public: public:
HTMLTableCellElement(Document&, const FlyString& tag_name); HTMLTableCellElement(Document&, const FlyString& local_name);
virtual ~HTMLTableCellElement() override; virtual ~HTMLTableCellElement() override;
private: private:
@ -42,7 +42,7 @@ private:
template<> template<>
inline bool is<HTMLTableCellElement>(const Node& node) inline bool is<HTMLTableCellElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th); return is<Element>(node) && to<Element>(node).local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th);
} }
} }

View file

@ -32,7 +32,7 @@ namespace Web {
class HTMLTableElement final : public HTMLElement { class HTMLTableElement final : public HTMLElement {
public: public:
HTMLTableElement(Document&, const FlyString& tag_name); HTMLTableElement(Document&, const FlyString& local_name);
virtual ~HTMLTableElement() override; virtual ~HTMLTableElement() override;
private: private:
@ -42,7 +42,7 @@ private:
template<> template<>
inline bool is<HTMLTableElement>(const Node& node) inline bool is<HTMLTableElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::table; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::table;
} }
} }

View file

@ -32,14 +32,14 @@ namespace Web {
class HTMLTableRowElement : public HTMLElement { class HTMLTableRowElement : public HTMLElement {
public: public:
HTMLTableRowElement(Document&, const FlyString& tag_name); HTMLTableRowElement(Document&, const FlyString& local_name);
virtual ~HTMLTableRowElement() override; virtual ~HTMLTableRowElement() override;
}; };
template<> template<>
inline bool is<HTMLTableRowElement>(const Node& node) inline bool is<HTMLTableRowElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name() == HTML::TagNames::tr; return is<Element>(node) && to<Element>(node).local_name() == HTML::TagNames::tr;
} }
} }

View file

@ -32,14 +32,14 @@ namespace Web {
class HTMLTitleElement : public HTMLElement { class HTMLTitleElement : public HTMLElement {
public: public:
HTMLTitleElement(Document&, const FlyString& tag_name); HTMLTitleElement(Document&, const FlyString& local_name);
virtual ~HTMLTitleElement() override; virtual ~HTMLTitleElement() override;
}; };
template<> template<>
inline bool is<HTMLTitleElement>(const Node& node) inline bool is<HTMLTitleElement>(const Node& node)
{ {
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("title"); return is<Element>(node) && to<Element>(node).local_name().equals_ignoring_case("title");
} }
} }

View file

@ -134,7 +134,7 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, Role role) const
auto& element = to<Element>(node); auto& element = to<Element>(node);
StringBuilder builder; StringBuilder builder;
builder.append('<'); builder.append('<');
builder.append(element.tag_name()); builder.append(element.local_name());
element.for_each_attribute([&](auto& name, auto& value) { element.for_each_attribute([&](auto& name, auto& value) {
builder.append(' '); builder.append(' ');
builder.append(name); builder.append(name);

View file

@ -51,7 +51,7 @@ void dump_tree(const Node& node)
if (is<Document>(node)) { if (is<Document>(node)) {
dbgprintf("*Document*\n"); dbgprintf("*Document*\n");
} else if (is<Element>(node)) { } else if (is<Element>(node)) {
dbgprintf("<%s", to<Element>(node).tag_name().characters()); dbgprintf("<%s", to<Element>(node).local_name().characters());
to<Element>(node).for_each_attribute([](auto& name, auto& value) { to<Element>(node).for_each_attribute([](auto& name, auto& value) {
dbgprintf(" %s=%s", name.characters(), value.characters()); dbgprintf(" %s=%s", name.characters(), value.characters());
}); });
@ -88,7 +88,7 @@ void dump_tree(const LayoutNode& layout_node)
else if (is<Document>(layout_node.node())) else if (is<Document>(layout_node.node()))
tag_name = "#document"; tag_name = "#document";
else if (is<Element>(layout_node.node())) else if (is<Element>(layout_node.node()))
tag_name = to<Element>(*layout_node.node()).tag_name(); tag_name = to<Element>(*layout_node.node()).local_name();
else else
tag_name = "???"; tag_name = "???";

View file

@ -138,7 +138,7 @@ GUI::Variant LayoutTreeModel::data(const GUI::ModelIndex& index, Role role) cons
} else { } else {
auto& element = to<Element>(*node.node()); auto& element = to<Element>(*node.node());
builder.append('<'); builder.append('<');
builder.append(element.tag_name()); builder.append(element.local_name());
element.for_each_attribute([&](auto& name, auto& value) { element.for_each_attribute([&](auto& name, auto& value) {
builder.append(' '); builder.append(' ');
builder.append(name); builder.append(name);

View file

@ -379,7 +379,7 @@ Element& HTMLDocumentParser::node_before_current_node()
HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropriate_place_for_inserting_node() HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropriate_place_for_inserting_node()
{ {
auto& target = current_node(); auto& target = current_node();
if (m_foster_parenting && target.tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) { if (m_foster_parenting && target.local_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) {
// FIXME: There's a bunch of steps for <template> elements here. // FIXME: There's a bunch of steps for <template> elements here.
auto last_table = m_stack_of_open_elements.last_element_with_tag_name(HTML::TagNames::table); auto last_table = m_stack_of_open_elements.last_element_with_tag_name(HTML::TagNames::table);
if (!last_table) { if (!last_table) {
@ -558,7 +558,7 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_) { if (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_) {
// FIXME: Support this properly // FIXME: Support this properly
ASSERT(current_node().tag_name() == HTML::TagNames::template_); ASSERT(current_node().local_name() == HTML::TagNames::template_);
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
return; return;
} }
@ -729,14 +729,14 @@ AnythingElse:
void HTMLDocumentParser::generate_implied_end_tags(const FlyString& exception) void HTMLDocumentParser::generate_implied_end_tags(const FlyString& exception)
{ {
while (current_node().tag_name() != exception && current_node().tag_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc)) while (current_node().local_name() != exception && current_node().local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc))
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} }
void HTMLDocumentParser::close_a_p_element() void HTMLDocumentParser::close_a_p_element()
{ {
generate_implied_end_tags(HTML::TagNames::p); generate_implied_end_tags(HTML::TagNames::p);
if (current_node().tag_name() != HTML::TagNames::p) { if (current_node().local_name() != HTML::TagNames::p) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::p); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::p);
@ -844,7 +844,7 @@ Advance:
Create: Create:
// FIXME: Hold on to the real token! // FIXME: Hold on to the real token!
auto new_element = insert_html_element(HTMLToken::make_start_tag(entry->tag_name())); auto new_element = insert_html_element(HTMLToken::make_start_tag(entry->local_name()));
m_list_of_active_formatting_elements.entries().at(index).element = *new_element; m_list_of_active_formatting_elements.entries().at(index).element = *new_element;
@ -859,7 +859,7 @@ HTMLDocumentParser::AdoptionAgencyAlgorithmOutcome HTMLDocumentParser::run_the_a
// If the current node is an HTML element whose tag name is subject, // If the current node is an HTML element whose tag name is subject,
// and the current node is not in the list of active formatting elements, // and the current node is not in the list of active formatting elements,
// then pop the current node off the stack of open elements, and return. // then pop the current node off the stack of open elements, and return.
if (current_node().tag_name() == subject && !m_list_of_active_formatting_elements.contains(current_node())) { if (current_node().local_name() == subject && !m_list_of_active_formatting_elements.contains(current_node())) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
return AdoptionAgencyAlgorithmOutcome::DoNothing; return AdoptionAgencyAlgorithmOutcome::DoNothing;
} }
@ -1047,7 +1047,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::body) { if (token.is_start_tag() && token.tag_name() == HTML::TagNames::body) {
PARSE_ERROR(); PARSE_ERROR();
if (m_stack_of_open_elements.elements().size() == 1 if (m_stack_of_open_elements.elements().size() == 1
|| m_stack_of_open_elements.elements().at(1).tag_name() != HTML::TagNames::body || m_stack_of_open_elements.elements().at(1).local_name() != HTML::TagNames::body
|| m_stack_of_open_elements.contains(HTML::TagNames::template_)) { || m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
return; return;
@ -1066,7 +1066,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
PARSE_ERROR(); PARSE_ERROR();
if (m_stack_of_open_elements.elements().size() == 1 if (m_stack_of_open_elements.elements().size() == 1
|| m_stack_of_open_elements.elements().at(1).tag_name() != HTML::TagNames::body) { || m_stack_of_open_elements.elements().at(1).local_name() != HTML::TagNames::body) {
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
return; return;
} }
@ -1098,7 +1098,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
} }
for (auto& node : m_stack_of_open_elements.elements()) { for (auto& node : m_stack_of_open_elements.elements()) {
if (!node.tag_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) { if (!node.local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) {
PARSE_ERROR(); PARSE_ERROR();
break; break;
} }
@ -1115,7 +1115,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
} }
for (auto& node : m_stack_of_open_elements.elements()) { for (auto& node : m_stack_of_open_elements.elements()) {
if (!node.tag_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) { if (!node.local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) {
PARSE_ERROR(); PARSE_ERROR();
break; break;
} }
@ -1136,7 +1136,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) { if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) {
if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p)) if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p))
close_a_p_element(); close_a_p_element();
if (current_node().tag_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) { if (current_node().local_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) {
PARSE_ERROR(); PARSE_ERROR();
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} }
@ -1183,16 +1183,16 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
RefPtr<Element> node = m_stack_of_open_elements.elements()[i]; RefPtr<Element> node = m_stack_of_open_elements.elements()[i];
if (node->tag_name() == HTML::TagNames::li) { if (node->local_name() == HTML::TagNames::li) {
generate_implied_end_tags(HTML::TagNames::li); generate_implied_end_tags(HTML::TagNames::li);
if (current_node().tag_name() != HTML::TagNames::li) { if (current_node().local_name() != HTML::TagNames::li) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li);
break; break;
} }
if (is_special_tag(node->tag_name()) && !node->tag_name().is_one_of(HTML::TagNames::address, HTML::TagNames::div, HTML::TagNames::p)) if (is_special_tag(node->local_name()) && !node->local_name().is_one_of(HTML::TagNames::address, HTML::TagNames::div, HTML::TagNames::p))
break; break;
} }
@ -1207,23 +1207,23 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
m_frameset_ok = false; m_frameset_ok = false;
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
RefPtr<Element> node = m_stack_of_open_elements.elements()[i]; RefPtr<Element> node = m_stack_of_open_elements.elements()[i];
if (node->tag_name() == HTML::TagNames::dd) { if (node->local_name() == HTML::TagNames::dd) {
generate_implied_end_tags(HTML::TagNames::dd); generate_implied_end_tags(HTML::TagNames::dd);
if (current_node().tag_name() != HTML::TagNames::dd) { if (current_node().local_name() != HTML::TagNames::dd) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dd); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dd);
break; break;
} }
if (node->tag_name() == HTML::TagNames::dt) { if (node->local_name() == HTML::TagNames::dt) {
generate_implied_end_tags(HTML::TagNames::dt); generate_implied_end_tags(HTML::TagNames::dt);
if (current_node().tag_name() != HTML::TagNames::dt) { if (current_node().local_name() != HTML::TagNames::dt) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dt); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dt);
break; break;
} }
if (is_special_tag(node->tag_name()) && !node->tag_name().is_one_of(HTML::TagNames::address, HTML::TagNames::div, HTML::TagNames::p)) if (is_special_tag(node->local_name()) && !node->local_name().is_one_of(HTML::TagNames::address, HTML::TagNames::div, HTML::TagNames::p))
break; break;
} }
if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p)) if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p))
@ -1260,7 +1260,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != token.tag_name()) { if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR(); PARSE_ERROR();
} }
@ -1287,7 +1287,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
return; return;
} }
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != HTML::TagNames::form) { if (current_node().local_name() != HTML::TagNames::form) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::form); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::form);
@ -1310,9 +1310,9 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
return; return;
} }
generate_implied_end_tags(HTML::TagNames::li); generate_implied_end_tags(HTML::TagNames::li);
if (current_node().tag_name() != HTML::TagNames::li) { if (current_node().local_name() != HTML::TagNames::li) {
PARSE_ERROR(); PARSE_ERROR();
dbg() << "Expected <li> current node, but had <" << current_node().tag_name() << ">"; dbg() << "Expected <li> current node, but had <" << current_node().local_name() << ">";
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li);
return; return;
@ -1324,7 +1324,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
return; return;
} }
generate_implied_end_tags(token.tag_name()); generate_implied_end_tags(token.tag_name());
if (current_node().tag_name() != token.tag_name()) { if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name()); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
@ -1343,13 +1343,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
} }
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != token.tag_name()) { if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR(); PARSE_ERROR();
} }
for (;;) { for (;;) {
auto popped_element = m_stack_of_open_elements.pop(); auto popped_element = m_stack_of_open_elements.pop();
if (popped_element->tag_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) if (popped_element->local_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6))
break; break;
} }
return; return;
@ -1411,7 +1411,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
} }
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != token.tag_name()) { if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR(); PARSE_ERROR();
} }
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name()); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
@ -1546,7 +1546,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
} }
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::optgroup, HTML::TagNames::option)) { if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::optgroup, HTML::TagNames::option)) {
if (current_node().tag_name() == HTML::TagNames::option) if (current_node().local_name() == HTML::TagNames::option)
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
reconstruct_the_active_formatting_elements(); reconstruct_the_active_formatting_elements();
insert_html_element(token); insert_html_element(token);
@ -1557,7 +1557,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (m_stack_of_open_elements.has_in_scope(HTML::TagNames::ruby)) if (m_stack_of_open_elements.has_in_scope(HTML::TagNames::ruby))
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != HTML::TagNames::ruby) if (current_node().local_name() != HTML::TagNames::ruby)
PARSE_ERROR(); PARSE_ERROR();
insert_html_element(token); insert_html_element(token);
@ -1568,7 +1568,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (m_stack_of_open_elements.has_in_scope(HTML::TagNames::ruby)) if (m_stack_of_open_elements.has_in_scope(HTML::TagNames::ruby))
generate_implied_end_tags(HTML::TagNames::rtc); generate_implied_end_tags(HTML::TagNames::rtc);
if (current_node().tag_name() != HTML::TagNames::rtc || current_node().tag_name() != HTML::TagNames::ruby) if (current_node().local_name() != HTML::TagNames::rtc || current_node().local_name() != HTML::TagNames::ruby)
PARSE_ERROR(); PARSE_ERROR();
insert_html_element(token); insert_html_element(token);
@ -1624,7 +1624,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
RefPtr<Element> node; RefPtr<Element> node;
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
node = m_stack_of_open_elements.elements()[i]; node = m_stack_of_open_elements.elements()[i];
if (node->tag_name() == token.tag_name()) { if (node->local_name() == token.tag_name()) {
generate_implied_end_tags(token.tag_name()); generate_implied_end_tags(token.tag_name());
if (node != current_node()) { if (node != current_node()) {
PARSE_ERROR(); PARSE_ERROR();
@ -1635,7 +1635,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
break; break;
} }
if (is_special_tag(node->tag_name())) { if (is_special_tag(node->local_name())) {
PARSE_ERROR(); PARSE_ERROR();
return; return;
} }
@ -1749,7 +1749,7 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
} }
if (token.is_end_of_file()) { if (token.is_end_of_file()) {
PARSE_ERROR(); PARSE_ERROR();
if (current_node().tag_name() == HTML::TagNames::script) if (current_node().local_name() == HTML::TagNames::script)
to<HTMLScriptElement>(current_node()).set_already_started({}, true); to<HTMLScriptElement>(current_node()).set_already_started({}, true);
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
m_insertion_mode = m_original_insertion_mode; m_insertion_mode = m_original_insertion_mode;
@ -1825,28 +1825,28 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
void HTMLDocumentParser::clear_the_stack_back_to_a_table_context() void HTMLDocumentParser::clear_the_stack_back_to_a_table_context()
{ {
while (!current_node().tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::template_, HTML::TagNames::html)) while (!current_node().local_name().is_one_of(HTML::TagNames::table, HTML::TagNames::template_, HTML::TagNames::html))
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
if (current_node().tag_name() == HTML::TagNames::html) if (current_node().local_name() == HTML::TagNames::html)
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
} }
void HTMLDocumentParser::clear_the_stack_back_to_a_table_row_context() void HTMLDocumentParser::clear_the_stack_back_to_a_table_row_context()
{ {
while (!current_node().tag_name().is_one_of(HTML::TagNames::tr, HTML::TagNames::template_, HTML::TagNames::html)) while (!current_node().local_name().is_one_of(HTML::TagNames::tr, HTML::TagNames::template_, HTML::TagNames::html))
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
if (current_node().tag_name() == HTML::TagNames::html) if (current_node().local_name() == HTML::TagNames::html)
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
} }
void HTMLDocumentParser::clear_the_stack_back_to_a_table_body_context() void HTMLDocumentParser::clear_the_stack_back_to_a_table_body_context()
{ {
while (!current_node().tag_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::template_, HTML::TagNames::html)) while (!current_node().local_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::template_, HTML::TagNames::html))
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
if (current_node().tag_name() == HTML::TagNames::html) if (current_node().local_name() == HTML::TagNames::html)
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
} }
@ -1910,10 +1910,10 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token)
void HTMLDocumentParser::close_the_cell() void HTMLDocumentParser::close_the_cell()
{ {
generate_implied_end_tags(); generate_implied_end_tags();
if (!current_node().tag_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) { if (!current_node().local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) {
PARSE_ERROR(); PARSE_ERROR();
} }
while (!current_node().tag_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) while (!current_node().local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th))
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
m_list_of_active_formatting_elements.clear_up_to_the_last_marker(); m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
@ -1929,7 +1929,7 @@ void HTMLDocumentParser::handle_in_cell(HTMLToken& token)
} }
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != token.tag_name()) { if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR(); PARSE_ERROR();
} }
@ -2057,7 +2057,7 @@ void HTMLDocumentParser::handle_in_table_body(HTMLToken& token)
void HTMLDocumentParser::handle_in_table(HTMLToken& token) void HTMLDocumentParser::handle_in_table(HTMLToken& token)
{ {
if (token.is_character() && current_node().tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) { if (token.is_character() && current_node().local_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) {
m_pending_table_character_tokens.clear(); m_pending_table_character_tokens.clear();
m_original_insertion_mode = m_insertion_mode; m_original_insertion_mode = m_insertion_mode;
m_insertion_mode = InsertionMode::InTableText; m_insertion_mode = InsertionMode::InTableText;
@ -2228,7 +2228,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
} }
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::option) { if (token.is_start_tag() && token.tag_name() == HTML::TagNames::option) {
if (current_node().tag_name() == HTML::TagNames::option) { if (current_node().local_name() == HTML::TagNames::option) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} }
insert_html_element(token); insert_html_element(token);
@ -2236,10 +2236,10 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
} }
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::optgroup) { if (token.is_start_tag() && token.tag_name() == HTML::TagNames::optgroup) {
if (current_node().tag_name() == HTML::TagNames::option) { if (current_node().local_name() == HTML::TagNames::option) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} }
if (current_node().tag_name() == HTML::TagNames::optgroup) { if (current_node().local_name() == HTML::TagNames::optgroup) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} }
insert_html_element(token); insert_html_element(token);
@ -2247,10 +2247,10 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
} }
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::optgroup) { if (token.is_end_tag() && token.tag_name() == HTML::TagNames::optgroup) {
if (current_node().tag_name() == HTML::TagNames::option && node_before_current_node().tag_name() == HTML::TagNames::optgroup) if (current_node().local_name() == HTML::TagNames::option && node_before_current_node().local_name() == HTML::TagNames::optgroup)
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
if (current_node().tag_name() == HTML::TagNames::optgroup) { if (current_node().local_name() == HTML::TagNames::optgroup) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} else { } else {
PARSE_ERROR(); PARSE_ERROR();
@ -2260,7 +2260,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
} }
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::option) { if (token.is_end_tag() && token.tag_name() == HTML::TagNames::option) {
if (current_node().tag_name() == HTML::TagNames::option) { if (current_node().local_name() == HTML::TagNames::option) {
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
} else { } else {
PARSE_ERROR(); PARSE_ERROR();
@ -2336,7 +2336,7 @@ void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != HTML::TagNames::caption) if (current_node().local_name() != HTML::TagNames::caption)
PARSE_ERROR(); PARSE_ERROR();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption);
@ -2356,7 +2356,7 @@ void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
generate_implied_end_tags(); generate_implied_end_tags();
if (current_node().tag_name() != HTML::TagNames::caption) if (current_node().local_name() != HTML::TagNames::caption)
PARSE_ERROR(); PARSE_ERROR();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption); m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption);
@ -2405,7 +2405,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
} }
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::colgroup) { if (token.is_end_tag() && token.tag_name() == HTML::TagNames::colgroup) {
if (current_node().tag_name() != HTML::TagNames::colgroup) { if (current_node().local_name() != HTML::TagNames::colgroup) {
PARSE_ERROR(); PARSE_ERROR();
return; return;
} }
@ -2430,7 +2430,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
return; return;
} }
if (current_node().tag_name() != HTML::TagNames::colgroup) { if (current_node().local_name() != HTML::TagNames::colgroup) {
PARSE_ERROR(); PARSE_ERROR();
return; return;
} }
@ -2550,7 +2550,7 @@ void HTMLDocumentParser::handle_in_frameset(HTMLToken& token)
m_stack_of_open_elements.pop(); m_stack_of_open_elements.pop();
if (!m_parsing_fragment && current_node().tag_name() != HTML::TagNames::frameset) { if (!m_parsing_fragment && current_node().local_name() != HTML::TagNames::frameset) {
m_insertion_mode = InsertionMode::AfterFrameset; m_insertion_mode = InsertionMode::AfterFrameset;
} }
return; return;
@ -2656,61 +2656,61 @@ void HTMLDocumentParser::reset_the_insertion_mode_appropriately()
node = m_stack_of_open_elements.elements().at(i); node = m_stack_of_open_elements.elements().at(i);
} }
if (node->tag_name() == HTML::TagNames::select) { if (node->local_name() == HTML::TagNames::select) {
TODO(); TODO();
} }
if (!last && node->tag_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) { if (!last && node->local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) {
m_insertion_mode = InsertionMode::InCell; m_insertion_mode = InsertionMode::InCell;
return; return;
} }
if (node->tag_name() == HTML::TagNames::tr) { if (node->local_name() == HTML::TagNames::tr) {
m_insertion_mode = InsertionMode::InRow; m_insertion_mode = InsertionMode::InRow;
return; return;
} }
if (node->tag_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) { if (node->local_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::thead, HTML::TagNames::tfoot)) {
m_insertion_mode = InsertionMode::InTableBody; m_insertion_mode = InsertionMode::InTableBody;
return; return;
} }
if (node->tag_name() == HTML::TagNames::caption) { if (node->local_name() == HTML::TagNames::caption) {
m_insertion_mode = InsertionMode::InCaption; m_insertion_mode = InsertionMode::InCaption;
return; return;
} }
if (node->tag_name() == HTML::TagNames::colgroup) { if (node->local_name() == HTML::TagNames::colgroup) {
m_insertion_mode = InsertionMode::InColumnGroup; m_insertion_mode = InsertionMode::InColumnGroup;
return; return;
} }
if (node->tag_name() == HTML::TagNames::table) { if (node->local_name() == HTML::TagNames::table) {
m_insertion_mode = InsertionMode::InTable; m_insertion_mode = InsertionMode::InTable;
return; return;
} }
if (node->tag_name() == HTML::TagNames::template_) { if (node->local_name() == HTML::TagNames::template_) {
TODO(); TODO();
} }
if (!last && node->tag_name() == HTML::TagNames::head) { if (!last && node->local_name() == HTML::TagNames::head) {
m_insertion_mode = InsertionMode::InHead; m_insertion_mode = InsertionMode::InHead;
return; return;
} }
if (node->tag_name() == HTML::TagNames::body) { if (node->local_name() == HTML::TagNames::body) {
m_insertion_mode = InsertionMode::InBody; m_insertion_mode = InsertionMode::InBody;
return; return;
} }
if (node->tag_name() == HTML::TagNames::frameset) { if (node->local_name() == HTML::TagNames::frameset) {
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
m_insertion_mode = InsertionMode::InFrameset; m_insertion_mode = InsertionMode::InFrameset;
return; return;
} }
if (node->tag_name() == HTML::TagNames::html) { if (node->local_name() == HTML::TagNames::html) {
if (!m_head_element) { if (!m_head_element) {
ASSERT(m_parsing_fragment); ASSERT(m_parsing_fragment);
m_insertion_mode = InsertionMode::BeforeHead; m_insertion_mode = InsertionMode::BeforeHead;
@ -2750,16 +2750,16 @@ NonnullRefPtrVector<Node> HTMLDocumentParser::parse_html_fragment(Element& conte
parser.m_parsing_fragment = true; parser.m_parsing_fragment = true;
parser.document().set_quirks_mode(context_element.document().mode()); parser.document().set_quirks_mode(context_element.document().mode());
if (context_element.tag_name().is_one_of(HTML::TagNames::title, HTML::TagNames::textarea)) { if (context_element.local_name().is_one_of(HTML::TagNames::title, HTML::TagNames::textarea)) {
parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA); parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA);
} else if (context_element.tag_name().is_one_of(HTML::TagNames::style, HTML::TagNames::xmp, HTML::TagNames::iframe, HTML::TagNames::noembed, HTML::TagNames::noframes)) { } else if (context_element.local_name().is_one_of(HTML::TagNames::style, HTML::TagNames::xmp, HTML::TagNames::iframe, HTML::TagNames::noembed, HTML::TagNames::noframes)) {
parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RAWTEXT); parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RAWTEXT);
} else if (context_element.tag_name().is_one_of(HTML::TagNames::script)) { } else if (context_element.local_name().is_one_of(HTML::TagNames::script)) {
parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::ScriptData); parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::ScriptData);
} else if (context_element.tag_name().is_one_of(HTML::TagNames::noscript)) { } else if (context_element.local_name().is_one_of(HTML::TagNames::noscript)) {
if (context_element.document().is_scripting_enabled()) if (context_element.document().is_scripting_enabled())
parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RAWTEXT); parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::RAWTEXT);
} else if (context_element.tag_name().is_one_of(HTML::TagNames::plaintext)) { } else if (context_element.local_name().is_one_of(HTML::TagNames::plaintext)) {
parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::PLAINTEXT); parser.m_tokenizer.switch_to({}, HTMLTokenizer::State::PLAINTEXT);
} }
@ -2767,7 +2767,7 @@ NonnullRefPtrVector<Node> HTMLDocumentParser::parse_html_fragment(Element& conte
parser.document().append_child(root); parser.document().append_child(root);
parser.m_stack_of_open_elements.push(root); parser.m_stack_of_open_elements.push(root);
if (context_element.tag_name() == HTML::TagNames::template_) { if (context_element.local_name() == HTML::TagNames::template_) {
TODO(); TODO();
} }

View file

@ -58,7 +58,7 @@ Element* ListOfActiveFormattingElements::last_element_with_tag_name_before_marke
auto& entry = m_entries[i]; auto& entry = m_entries[i];
if (entry.is_marker()) if (entry.is_marker())
return nullptr; return nullptr;
if (entry.element->tag_name() == tag_name) if (entry.element->local_name() == tag_name)
return entry.element; return entry.element;
} }
return nullptr; return nullptr;

View file

@ -40,9 +40,9 @@ bool StackOfOpenElements::has_in_scope_impl(const FlyString& tag_name, const Vec
{ {
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& node = m_elements.at(i); auto& node = m_elements.at(i);
if (node.tag_name() == tag_name) if (node.local_name() == tag_name)
return true; return true;
if (list.contains_slow(node.tag_name())) if (list.contains_slow(node.local_name()))
return false; return false;
} }
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
@ -59,7 +59,7 @@ bool StackOfOpenElements::has_in_scope_impl(const Element& target_node, const Ve
auto& node = m_elements.at(i); auto& node = m_elements.at(i);
if (&node == &target_node) if (&node == &target_node)
return true; return true;
if (list.contains_slow(node.tag_name())) if (list.contains_slow(node.local_name()))
return false; return false;
} }
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
@ -107,7 +107,7 @@ bool StackOfOpenElements::contains(const Element& element) const
bool StackOfOpenElements::contains(const FlyString& tag_name) const bool StackOfOpenElements::contains(const FlyString& tag_name) const
{ {
for (auto& element_on_stack : m_elements) { for (auto& element_on_stack : m_elements) {
if (element_on_stack.tag_name() == tag_name) if (element_on_stack.local_name() == tag_name)
return true; return true;
} }
return false; return false;
@ -115,7 +115,7 @@ bool StackOfOpenElements::contains(const FlyString& tag_name) const
void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(const FlyString& tag_name) void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(const FlyString& tag_name)
{ {
while (m_elements.last().tag_name() != tag_name) while (m_elements.last().local_name() != tag_name)
pop(); pop();
pop(); pop();
} }
@ -127,7 +127,7 @@ Element* StackOfOpenElements::topmost_special_node_below(const Element& formatti
auto& element = m_elements[i]; auto& element = m_elements[i];
if (&element == &formatting_element) if (&element == &formatting_element)
break; break;
if (HTMLDocumentParser::is_special_tag(element.tag_name())) if (HTMLDocumentParser::is_special_tag(element.local_name()))
found_element = &element; found_element = &element;
} }
return found_element; return found_element;
@ -137,7 +137,7 @@ Element* StackOfOpenElements::last_element_with_tag_name(const FlyString& tag_na
{ {
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) { for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
auto& element = m_elements[i]; auto& element = m_elements[i];
if (element.tag_name() == tag_name) if (element.local_name() == tag_name)
return &element; return &element;
} }
return nullptr; return nullptr;