mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:05:09 +00:00
LibWeb: Use FlyString for Element tag names
This makes selector matching a lot more efficient, and also reduces the number of strings on the heap.
This commit is contained in:
parent
c4a6d6ae9f
commit
7309642ca8
48 changed files with 67 additions and 63 deletions
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/String.h>
|
#include <AK/FlyString.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibWeb/CSS/Specificity.h>
|
#include <LibWeb/CSS/Specificity.h>
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public:
|
||||||
};
|
};
|
||||||
PseudoClass pseudo_class { PseudoClass::None };
|
PseudoClass pseudo_class { PseudoClass::None };
|
||||||
|
|
||||||
String value;
|
FlyString value;
|
||||||
|
|
||||||
enum class AttributeMatchType {
|
enum class AttributeMatchType {
|
||||||
None,
|
None,
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
AttributeMatchType attribute_match_type { AttributeMatchType::None };
|
AttributeMatchType attribute_match_type { AttributeMatchType::None };
|
||||||
String attribute_name;
|
FlyString attribute_name;
|
||||||
String attribute_value;
|
String attribute_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/String.h>
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/DOM/CharacterData.h>
|
#include <LibWeb/DOM/CharacterData.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
explicit Comment(Document&, const String&);
|
explicit Comment(Document&, const String&);
|
||||||
virtual ~Comment() override;
|
virtual ~Comment() override;
|
||||||
|
|
||||||
virtual String tag_name() const override { return "#comment"; }
|
virtual FlyString tag_name() const override { return "#comment"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <AK/Function.h>
|
#include <AK/Function.h>
|
||||||
#include <AK/NonnullRefPtrVector.h>
|
#include <AK/NonnullRefPtrVector.h>
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
|
@ -69,7 +70,7 @@ public:
|
||||||
void add_sheet(const StyleSheet& sheet) { m_sheets.append(sheet); }
|
void add_sheet(const StyleSheet& sheet) { m_sheets.append(sheet); }
|
||||||
const NonnullRefPtrVector<StyleSheet>& stylesheets() const { return m_sheets; }
|
const NonnullRefPtrVector<StyleSheet>& stylesheets() const { return m_sheets; }
|
||||||
|
|
||||||
virtual String tag_name() const override { return "#document"; }
|
virtual FlyString tag_name() const override { return "#document"; }
|
||||||
|
|
||||||
void set_hovered_node(Node*);
|
void set_hovered_node(Node*);
|
||||||
Node* hovered_node() { return m_hovered_node; }
|
Node* hovered_node() { return m_hovered_node; }
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/DOM/ParentNode.h>
|
#include <LibWeb/DOM/ParentNode.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -37,7 +38,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual String tag_name() const override { return "#document-fragment"; }
|
virtual FlyString tag_name() const override { return "#document-fragment"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/DOM/Node.h>
|
#include <LibWeb/DOM/Node.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
@ -35,7 +36,7 @@ public:
|
||||||
explicit DocumentType(Document&);
|
explicit DocumentType(Document&);
|
||||||
virtual ~DocumentType() override;
|
virtual ~DocumentType() override;
|
||||||
|
|
||||||
virtual String tag_name() const override { return "#doctype"; }
|
virtual FlyString tag_name() const override { return "#doctype"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
Element::Element(Document& document, const String& tag_name)
|
Element::Element(Document& document, const FlyString& tag_name)
|
||||||
: ParentNode(document, NodeType::ELEMENT_NODE)
|
: ParentNode(document, NodeType::ELEMENT_NODE)
|
||||||
, m_tag_name(tag_name)
|
, m_tag_name(tag_name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,10 +55,10 @@ private:
|
||||||
|
|
||||||
class Element : public ParentNode {
|
class Element : public ParentNode {
|
||||||
public:
|
public:
|
||||||
Element(Document&, const String& tag_name);
|
Element(Document&, const FlyString& tag_name);
|
||||||
virtual ~Element() override;
|
virtual ~Element() override;
|
||||||
|
|
||||||
virtual String tag_name() const final { return m_tag_name; }
|
virtual FlyString tag_name() const final { return m_tag_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;
|
||||||
|
@ -94,7 +94,7 @@ private:
|
||||||
Attribute* find_attribute(const FlyString& name);
|
Attribute* find_attribute(const FlyString& name);
|
||||||
const Attribute* find_attribute(const FlyString& name) const;
|
const Attribute* find_attribute(const FlyString& name) const;
|
||||||
|
|
||||||
String m_tag_name;
|
FlyString m_tag_name;
|
||||||
Vector<Attribute> m_attributes;
|
Vector<Attribute> m_attributes;
|
||||||
|
|
||||||
RefPtr<StyleProperties> m_resolved_style;
|
RefPtr<StyleProperties> m_resolved_style;
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
NonnullRefPtr<Element> create_element(Document& document, const String& tag_name)
|
NonnullRefPtr<Element> create_element(Document& document, const FlyString& tag_name)
|
||||||
{
|
{
|
||||||
auto lowercase_tag_name = tag_name.to_lowercase();
|
auto lowercase_tag_name = tag_name.to_lowercase();
|
||||||
if (lowercase_tag_name == "a")
|
if (lowercase_tag_name == "a")
|
||||||
|
|
|
@ -30,6 +30,6 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
NonnullRefPtr<Element> create_element(Document&, const String& tag_name);
|
NonnullRefPtr<Element> create_element(Document&, const FlyString& tag_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLAnchorElement::HTMLAnchorElement(Document& document, const String& tag_name)
|
HTMLAnchorElement::HTMLAnchorElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLAnchorElement : public HTMLElement {
|
class HTMLAnchorElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLAnchorElement(Document&, const String& tag_name);
|
HTMLAnchorElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLAnchorElement() override;
|
virtual ~HTMLAnchorElement() override;
|
||||||
|
|
||||||
String href() const { return attribute("href"); }
|
String href() const { return attribute("href"); }
|
||||||
|
@ -41,7 +41,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().to_lowercase() == "a";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("a");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLBRElement::HTMLBRElement(Document& document, const String& tag_name)
|
HTMLBRElement::HTMLBRElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLBRElement final : public HTMLElement {
|
class HTMLBRElement final : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLBRElement(Document&, const String& tag_name);
|
HTMLBRElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLBRElement() override;
|
virtual ~HTMLBRElement() override;
|
||||||
|
|
||||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const 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().to_lowercase() == "br";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("br");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLBlinkElement::HTMLBlinkElement(Document& document, const String& tag_name)
|
HTMLBlinkElement::HTMLBlinkElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
, m_timer(Core::Timer::construct())
|
, m_timer(Core::Timer::construct())
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLBlinkElement : public HTMLElement {
|
class HTMLBlinkElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLBlinkElement(Document&, const String& tag_name);
|
HTMLBlinkElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLBlinkElement() override;
|
virtual ~HTMLBlinkElement() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLBodyElement::HTMLBodyElement(Document& document, const String& tag_name)
|
HTMLBodyElement::HTMLBodyElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLBodyElement : public HTMLElement {
|
class HTMLBodyElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLBodyElement(Document&, const String& tag_name);
|
HTMLBodyElement(Document&, const FlyString& tag_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().to_lowercase() == "body";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("body");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLCanvasElement::HTMLCanvasElement(Document& document, const String& tag_name)
|
HTMLCanvasElement::HTMLCanvasElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ class HTMLCanvasElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
using WrapperType = Bindings::HTMLCanvasElementWrapper;
|
using WrapperType = Bindings::HTMLCanvasElementWrapper;
|
||||||
|
|
||||||
HTMLCanvasElement(Document&, const String& tag_name);
|
HTMLCanvasElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLCanvasElement() override;
|
virtual ~HTMLCanvasElement() override;
|
||||||
|
|
||||||
int preferred_width() const;
|
int preferred_width() const;
|
||||||
|
@ -59,7 +59,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().to_lowercase() == "canvas";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("canvas");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLElement::HTMLElement(Document& document, const String& tag_name)
|
HTMLElement::HTMLElement(Document& document, const FlyString& tag_name)
|
||||||
: Element(document, tag_name)
|
: Element(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLElement : public Element {
|
class HTMLElement : public Element {
|
||||||
public:
|
public:
|
||||||
HTMLElement(Document&, const String& tag_name);
|
HTMLElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLElement() override;
|
virtual ~HTMLElement() override;
|
||||||
|
|
||||||
String title() const { return attribute("title"); }
|
String title() const { return attribute("title"); }
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLFontElement::HTMLFontElement(Document& document, const String& tag_name)
|
HTMLFontElement::HTMLFontElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLFontElement : public HTMLElement {
|
class HTMLFontElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLFontElement(Document&, const String& tag_name);
|
HTMLFontElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLFontElement() override;
|
virtual ~HTMLFontElement() override;
|
||||||
|
|
||||||
virtual void apply_presentational_hints(StyleProperties&) const override;
|
virtual void apply_presentational_hints(StyleProperties&) const override;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLFormElement::HTMLFormElement(Document& document, const String& tag_name)
|
HTMLFormElement::HTMLFormElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLFormElement : public HTMLElement {
|
class HTMLFormElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLFormElement(Document&, const String& tag_name);
|
HTMLFormElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLFormElement() override;
|
virtual ~HTMLFormElement() override;
|
||||||
|
|
||||||
String action() const { return attribute("action"); }
|
String action() const { return attribute("action"); }
|
||||||
|
@ -44,7 +44,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().to_lowercase() == "form";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("form");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLHRElement::HTMLHRElement(Document& document, const String& tag_name)
|
HTMLHRElement::HTMLHRElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLHRElement : public HTMLElement {
|
class HTMLHRElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLHRElement(Document&, const String& tag_name);
|
HTMLHRElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLHRElement() override;
|
virtual ~HTMLHRElement() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLHeadElement::HTMLHeadElement(Document& document, const String& tag_name)
|
HTMLHeadElement::HTMLHeadElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLHeadElement : public HTMLElement {
|
class HTMLHeadElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLHeadElement(Document&, const String& tag_name);
|
HTMLHeadElement(Document&, const FlyString& tag_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().to_lowercase() == "head";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("head");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLHeadingElement::HTMLHeadingElement(Document& document, const String& tag_name)
|
HTMLHeadingElement::HTMLHeadingElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLHeadingElement : public HTMLElement {
|
class HTMLHeadingElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLHeadingElement(Document&, const String& tag_name);
|
HTMLHeadingElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLHeadingElement() override;
|
virtual ~HTMLHeadingElement() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLHtmlElement::HTMLHtmlElement(Document& document, const String& tag_name)
|
HTMLHtmlElement::HTMLHtmlElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLHtmlElement : public HTMLElement {
|
class HTMLHtmlElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLHtmlElement(Document&, const String& tag_name);
|
HTMLHtmlElement(Document&, const FlyString& tag_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().to_lowercase() == "html";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("html");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLImageElement::HTMLImageElement(Document& document, const String& tag_name)
|
HTMLImageElement::HTMLImageElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class LayoutDocument;
|
||||||
|
|
||||||
class HTMLImageElement : public HTMLElement {
|
class HTMLImageElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLImageElement(Document&, const String& tag_name);
|
HTMLImageElement(Document&, const FlyString& tag_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;
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLInputElement::HTMLInputElement(Document& document, const String& tag_name)
|
HTMLInputElement::HTMLInputElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLInputElement : public HTMLElement {
|
class HTMLInputElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLInputElement(Document&, const String& tag_name);
|
HTMLInputElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLInputElement() override;
|
virtual ~HTMLInputElement() override;
|
||||||
|
|
||||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const 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().to_lowercase() == "input";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("input");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLLinkElement::HTMLLinkElement(Document& document, const String& tag_name)
|
HTMLLinkElement::HTMLLinkElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLLinkElement final : public HTMLElement {
|
class HTMLLinkElement final : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLLinkElement(Document&, const String& tag_name);
|
HTMLLinkElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLLinkElement() override;
|
virtual ~HTMLLinkElement() override;
|
||||||
|
|
||||||
virtual void inserted_into(Node&) override;
|
virtual void inserted_into(Node&) override;
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
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().to_lowercase() == "link";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("link");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLScriptElement::HTMLScriptElement(Document& document, const String& tag_name)
|
HTMLScriptElement::HTMLScriptElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLScriptElement : public HTMLElement {
|
class HTMLScriptElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLScriptElement(Document&, const String& tag_name);
|
HTMLScriptElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLScriptElement() override;
|
virtual ~HTMLScriptElement() override;
|
||||||
|
|
||||||
virtual void inserted_into(Node&) override;
|
virtual void inserted_into(Node&) override;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLStyleElement::HTMLStyleElement(Document& document, const String& tag_name)
|
HTMLStyleElement::HTMLStyleElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ class StyleSheet;
|
||||||
|
|
||||||
class HTMLStyleElement : public HTMLElement {
|
class HTMLStyleElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLStyleElement(Document&, const String& tag_name);
|
HTMLStyleElement(Document&, const FlyString& tag_name);
|
||||||
virtual ~HTMLStyleElement() override;
|
virtual ~HTMLStyleElement() override;
|
||||||
|
|
||||||
virtual void inserted_into(Node&) override;
|
virtual void inserted_into(Node&) override;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
HTMLTitleElement::HTMLTitleElement(Document& document, const String& tag_name)
|
HTMLTitleElement::HTMLTitleElement(Document& document, const FlyString& tag_name)
|
||||||
: HTMLElement(document, tag_name)
|
: HTMLElement(document, tag_name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,14 @@ namespace Web {
|
||||||
|
|
||||||
class HTMLTitleElement : public HTMLElement {
|
class HTMLTitleElement : public HTMLElement {
|
||||||
public:
|
public:
|
||||||
HTMLTitleElement(Document&, const String& tag_name);
|
HTMLTitleElement(Document&, const FlyString& tag_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().to_lowercase() == "title";
|
return is<Element>(node) && to<Element>(node).tag_name().equals_ignoring_case("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const;
|
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const;
|
||||||
|
|
||||||
virtual String tag_name() const = 0;
|
virtual FlyString tag_name() const = 0;
|
||||||
|
|
||||||
virtual String text_content() const;
|
virtual String text_content() const;
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibWeb/DOM/CharacterData.h>
|
#include <LibWeb/DOM/CharacterData.h>
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ public:
|
||||||
explicit Text(Document&, const String&);
|
explicit Text(Document&, const String&);
|
||||||
virtual ~Text() override;
|
virtual ~Text() override;
|
||||||
|
|
||||||
virtual String tag_name() const override { return "#text"; }
|
virtual FlyString tag_name() const override { return "#text"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
virtual RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
||||||
|
|
|
@ -75,7 +75,7 @@ void dump_tree(const LayoutNode& layout_node)
|
||||||
for (size_t i = 0; i < indent; ++i)
|
for (size_t i = 0; i < indent; ++i)
|
||||||
dbgprintf(" ");
|
dbgprintf(" ");
|
||||||
|
|
||||||
String tag_name;
|
FlyString tag_name;
|
||||||
if (layout_node.is_anonymous())
|
if (layout_node.is_anonymous())
|
||||||
tag_name = "(anonymous)";
|
tag_name = "(anonymous)";
|
||||||
else if (is<Text>(layout_node.node()))
|
else if (is<Text>(layout_node.node()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue