mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:28:13 +00:00
LibHTML: Start building the style tree.
Walk the DOM and construct a parallel style tree that points back to the DOM and has the relevant CSS property values hanging off of them. The values are picked based on naive selector matching. There's no cascade or specificity taken into account yet.
This commit is contained in:
parent
3af59dfed1
commit
ffcbe8f0de
6 changed files with 86 additions and 16 deletions
|
@ -10,6 +10,10 @@ class Node;
|
|||
|
||||
class StyledNode : public TreeNode<StyledNode> {
|
||||
public:
|
||||
static NonnullRefPtr<StyledNode> create(const Node& node)
|
||||
{
|
||||
return adopt(*new StyledNode(&node));
|
||||
}
|
||||
~StyledNode();
|
||||
|
||||
const Node* node() const { return m_node; }
|
||||
|
@ -28,6 +32,18 @@ public:
|
|||
callback(*node);
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
inline void for_each_property(Callback callback) const
|
||||
{
|
||||
for (auto& it : m_property_values)
|
||||
callback(it.key, *it.value);
|
||||
}
|
||||
|
||||
void set_property(const String& name, NonnullRefPtr<StyleValue> value)
|
||||
{
|
||||
m_property_values.set(name, move(value));
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit StyledNode(const Node*);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue