mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
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:
parent
8f3f5ac8ce
commit
7a3f59ae3f
Notes:
sideshowbarker
2024-07-19 13:28:46 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7a3f59ae3fc
3 changed files with 48 additions and 0 deletions
10
LibHTML/CSS/StyledNode.cpp
Normal file
10
LibHTML/CSS/StyledNode.cpp
Normal 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
37
LibHTML/CSS/StyledNode.h
Normal 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;
|
||||||
|
};
|
|
@ -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 \
|
||||||
|
|
Loading…
Reference in a new issue