mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +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:
parent
9d4cd565e3
commit
3cb50a4714
34 changed files with 140 additions and 137 deletions
|
@ -334,11 +334,11 @@ Vector<const Element*> Document::get_elements_by_name(const String& name) const
|
|||
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;
|
||||
for_each_in_subtree_of_type<Element>([&](auto& element) {
|
||||
if (element.tag_name() == tag_name)
|
||||
if (element.local_name() == tag_name)
|
||||
elements.append(element);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
|
|
@ -124,7 +124,7 @@ public:
|
|||
void schedule_style_update();
|
||||
|
||||
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&);
|
||||
NonnullRefPtrVector<Element> query_selector_all(const StringView&);
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ RefPtr<LayoutNode> Element::create_layout_node(const StyleProperties* parent_sty
|
|||
if (display == CSS::Display::None)
|
||||
return nullptr;
|
||||
|
||||
if (tag_name() == "noscript" && document().is_scripting_enabled())
|
||||
if (local_name() == "noscript" && document().is_scripting_enabled())
|
||||
return nullptr;
|
||||
|
||||
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()) {
|
||||
if (child->is_element()) {
|
||||
builder.append('<');
|
||||
builder.append(to<Element>(*child).tag_name());
|
||||
builder.append(to<Element>(*child).local_name());
|
||||
builder.append('>');
|
||||
|
||||
recurse(*child);
|
||||
|
||||
builder.append("</");
|
||||
builder.append(to<Element>(*child).tag_name());
|
||||
builder.append(to<Element>(*child).local_name());
|
||||
builder.append('>');
|
||||
}
|
||||
if (child->is_text()) {
|
||||
|
|
|
@ -42,11 +42,14 @@ class Element : public ParentNode {
|
|||
public:
|
||||
using WrapperType = Bindings::ElementWrapper;
|
||||
|
||||
Element(Document&, const FlyString& tag_name);
|
||||
Element(Document&, const FlyString& local_name);
|
||||
virtual ~Element() override;
|
||||
|
||||
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(); }
|
||||
String attribute(const FlyString& name) const;
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLAnchorElement : public HTMLElement {
|
||||
public:
|
||||
HTMLAnchorElement(Document&, const FlyString& tag_name);
|
||||
HTMLAnchorElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLAnchorElement() override;
|
||||
|
||||
String href() const { return attribute(HTML::AttributeNames::href); }
|
||||
|
@ -42,7 +42,7 @@ public:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLBRElement final : public HTMLElement {
|
||||
public:
|
||||
HTMLBRElement(Document&, const FlyString& tag_name);
|
||||
HTMLBRElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLBRElement() override;
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Web {
|
|||
|
||||
class HTMLBlinkElement : public HTMLElement {
|
||||
public:
|
||||
HTMLBlinkElement(Document&, const FlyString& tag_name);
|
||||
HTMLBlinkElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLBlinkElement() override;
|
||||
|
||||
private:
|
||||
|
@ -45,7 +45,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLBodyElement : public HTMLElement {
|
||||
public:
|
||||
HTMLBodyElement(Document&, const FlyString& tag_name);
|
||||
HTMLBodyElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLBodyElement() override;
|
||||
|
||||
virtual void parse_attribute(const FlyString&, const String&) override;
|
||||
|
@ -45,7 +45,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement {
|
|||
public:
|
||||
using WrapperType = Bindings::HTMLCanvasElementWrapper;
|
||||
|
||||
HTMLCanvasElement(Document&, const FlyString& tag_name);
|
||||
HTMLCanvasElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLCanvasElement() override;
|
||||
|
||||
const Gfx::Bitmap* bitmap() const { return m_bitmap; }
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class HTMLElement : public Element {
|
|||
public:
|
||||
using WrapperType = Bindings::HTMLElementWrapper;
|
||||
|
||||
HTMLElement(Document&, const FlyString& tag_name);
|
||||
HTMLElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLElement() override;
|
||||
|
||||
String title() const { return attribute(HTML::AttributeNames::title); }
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLFontElement : public HTMLElement {
|
||||
public:
|
||||
HTMLFontElement(Document&, const FlyString& tag_name);
|
||||
HTMLFontElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLFontElement() override;
|
||||
|
||||
virtual void apply_presentational_hints(StyleProperties&) const override;
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Web {
|
|||
|
||||
class HTMLFormElement : public HTMLElement {
|
||||
public:
|
||||
HTMLFormElement(Document&, const FlyString& tag_name);
|
||||
HTMLFormElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLFormElement() override;
|
||||
|
||||
String action() const { return attribute(HTML::AttributeNames::action); }
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
|||
|
||||
class HTMLHRElement : public HTMLElement {
|
||||
public:
|
||||
HTMLHRElement(Document&, const FlyString& tag_name);
|
||||
HTMLHRElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLHRElement() override;
|
||||
};
|
||||
|
||||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
|||
|
||||
class HTMLHeadElement : public HTMLElement {
|
||||
public:
|
||||
HTMLHeadElement(Document&, const FlyString& tag_name);
|
||||
HTMLHeadElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLHeadElement() override;
|
||||
};
|
||||
|
||||
template<>
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLHeadingElement : public HTMLElement {
|
||||
public:
|
||||
HTMLHeadingElement(Document&, const FlyString& tag_name);
|
||||
HTMLHeadingElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLHeadingElement() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
|||
|
||||
class HTMLHtmlElement : public HTMLElement {
|
||||
public:
|
||||
HTMLHtmlElement(Document&, const FlyString& tag_name);
|
||||
HTMLHtmlElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLHtmlElement() override;
|
||||
};
|
||||
|
||||
template<>
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLIFrameElement final : public HTMLElement {
|
||||
public:
|
||||
HTMLIFrameElement(Document&, const FlyString& tag_name);
|
||||
HTMLIFrameElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLIFrameElement() override;
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
|
||||
|
@ -54,7 +54,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class HTMLImageElement final : public HTMLElement {
|
|||
public:
|
||||
using WrapperType = Bindings::HTMLImageElementWrapper;
|
||||
|
||||
HTMLImageElement(Document&, const FlyString& tag_name);
|
||||
HTMLImageElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLImageElement() override;
|
||||
|
||||
virtual void parse_attribute(const FlyString& name, const String& value) override;
|
||||
|
@ -63,7 +63,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLInputElement : public HTMLElement {
|
||||
public:
|
||||
HTMLInputElement(Document&, const FlyString& tag_name);
|
||||
HTMLInputElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLInputElement() override;
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) override;
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class HTMLLinkElement final
|
|||
: public HTMLElement
|
||||
, public ResourceClient {
|
||||
public:
|
||||
HTMLLinkElement(Document&, const FlyString& tag_name);
|
||||
HTMLLinkElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLLinkElement() override;
|
||||
|
||||
virtual void inserted_into(Node&) override;
|
||||
|
@ -67,7 +67,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class LayoutDocument;
|
|||
|
||||
class HTMLObjectElement final : public HTMLElement {
|
||||
public:
|
||||
HTMLObjectElement(Document&, const FlyString& tag_name);
|
||||
HTMLObjectElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLObjectElement() override;
|
||||
|
||||
virtual void parse_attribute(const FlyString& name, const String& value) override;
|
||||
|
@ -55,7 +55,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace Web {
|
|||
|
||||
class HTMLScriptElement : public HTMLElement {
|
||||
public:
|
||||
HTMLScriptElement(Document&, const FlyString& tag_name);
|
||||
HTMLScriptElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLScriptElement() override;
|
||||
|
||||
bool is_non_blocking() const { return m_non_blocking; }
|
||||
|
@ -68,7 +68,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class StyleSheet;
|
|||
|
||||
class HTMLStyleElement : public HTMLElement {
|
||||
public:
|
||||
HTMLStyleElement(Document&, const FlyString& tag_name);
|
||||
HTMLStyleElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLStyleElement() override;
|
||||
|
||||
virtual void children_changed() override;
|
||||
|
@ -47,7 +47,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLTableCellElement final : public HTMLElement {
|
||||
public:
|
||||
HTMLTableCellElement(Document&, const FlyString& tag_name);
|
||||
HTMLTableCellElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLTableCellElement() override;
|
||||
|
||||
private:
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
template<>
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
|||
|
||||
class HTMLTableElement final : public HTMLElement {
|
||||
public:
|
||||
HTMLTableElement(Document&, const FlyString& tag_name);
|
||||
HTMLTableElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLTableElement() override;
|
||||
|
||||
private:
|
||||
|
@ -42,7 +42,7 @@ private:
|
|||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
|||
|
||||
class HTMLTableRowElement : public HTMLElement {
|
||||
public:
|
||||
HTMLTableRowElement(Document&, const FlyString& tag_name);
|
||||
HTMLTableRowElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLTableRowElement() override;
|
||||
};
|
||||
|
||||
template<>
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
|||
|
||||
class HTMLTitleElement : public HTMLElement {
|
||||
public:
|
||||
HTMLTitleElement(Document&, const FlyString& tag_name);
|
||||
HTMLTitleElement(Document&, const FlyString& local_name);
|
||||
virtual ~HTMLTitleElement() override;
|
||||
};
|
||||
|
||||
template<>
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue