mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 14:07:42 +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
3 changed files with 48 additions and 0 deletions
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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue