mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
LibHTML: Add virtual Node::tag_name()
This is analogous to the DOM's Node.tagName and makes it easy to ask "hey, what kinda thing is this Node?"
This commit is contained in:
parent
a768724270
commit
fb4702dd49
4 changed files with 8 additions and 1 deletions
|
@ -23,6 +23,8 @@ 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"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnPtr<StyleResolver> m_style_resolver;
|
OwnPtr<StyleResolver> m_style_resolver;
|
||||||
NonnullRefPtrVector<StyleSheet> m_sheets;
|
NonnullRefPtrVector<StyleSheet> m_sheets;
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
explicit Element(const String& tag_name);
|
explicit Element(const String& tag_name);
|
||||||
virtual ~Element() override;
|
virtual ~Element() override;
|
||||||
|
|
||||||
const String& tag_name() const { return m_tag_name; }
|
virtual String tag_name() const override { return m_tag_name; }
|
||||||
|
|
||||||
String attribute(const String& name) const;
|
String attribute(const String& name) const;
|
||||||
void set_attribute(const String& name, const String& value);
|
void set_attribute(const String& name, const String& value);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Badge.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
|
#include <AK/String.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibHTML/TreeNode.h>
|
#include <LibHTML/TreeNode.h>
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ public:
|
||||||
RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const;
|
RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const;
|
||||||
RefPtr<LayoutNode> create_layout_tree(const StyleResolver&, const StyleProperties* parent_properties) const;
|
RefPtr<LayoutNode> create_layout_tree(const StyleResolver&, const StyleProperties* parent_properties) const;
|
||||||
|
|
||||||
|
virtual String tag_name() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit Node(NodeType);
|
explicit Node(NodeType);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ public:
|
||||||
|
|
||||||
const String& data() const { return m_data; }
|
const String& data() const { return m_data; }
|
||||||
|
|
||||||
|
virtual String tag_name() const override { return "#text"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_data;
|
String m_data;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue