LibHTML: Add a StyledNode class.

I'd like to try doing DOM -> style tree -> layout tree. I'm not exactly sure
how it's gonna work, but we'll figure it out as we go.
This commit is contained in:
Andreas Kling 2019-06-27 08:37:47 +02:00
parent 8f3f5ac8ce
commit 7a3f59ae3f
Notes: sideshowbarker 2024-07-19 13:28:46 +09:00
3 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,10 @@
#include <LibHTML/CSS/StyledNode.h>
StyledNode::StyledNode(const Node* node)
: m_node(node)
{
}
StyledNode::~StyledNode()
{
}

37
LibHTML/CSS/StyledNode.h Normal file
View file

@ -0,0 +1,37 @@
#pragma once
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <AK/AKString.h>
#include <LibHTML/TreeNode.h>
#include <LibHTML/CSS/StyleValue.h>
class Node;
class StyledNode : public TreeNode<StyledNode> {
public:
~StyledNode();
const Node* node() const { return m_node; }
template<typename Callback>
inline void for_each_child(Callback callback) const
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}
template<typename Callback>
inline void for_each_child(Callback callback)
{
for (auto* node = first_child(); node; node = node->next_sibling())
callback(*node);
}
protected:
explicit StyledNode(const Node*);
private:
const Node* m_node { nullptr };
HashMap<String, NonnullRefPtr<StyleValue>> m_property_values;
};

View file

@ -9,6 +9,7 @@ LIBHTML_OBJS = \
CSS/StyleRule.o \ CSS/StyleRule.o \
CSS/StyleDeclaration.o \ CSS/StyleDeclaration.o \
CSS/StyleValue.o \ CSS/StyleValue.o \
CSS/StyledNode.o \
CSS/DefaultStyleSheetSource.o \ CSS/DefaultStyleSheetSource.o \
Parser/HTMLParser.o \ Parser/HTMLParser.o \
Parser/CSSParser.o \ Parser/CSSParser.o \