mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 16:25:08 +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
|
@ -1,5 +1,7 @@
|
|||
#include <LibHTML/CSS/StyleResolver.h>
|
||||
#include <LibHTML/CSS/StyleSheet.h>
|
||||
#include <LibHTML/CSS/StyledNode.h>
|
||||
#include <LibHTML/DOM/Document.h>
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Dump.h>
|
||||
#include <stdio.h>
|
||||
|
@ -51,15 +53,19 @@ NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Eleme
|
|||
return matching_rules;
|
||||
}
|
||||
|
||||
OwnPtr<LayoutStyle> StyleResolver::resolve_document_style(const Document& document)
|
||||
NonnullRefPtr<StyledNode> StyleResolver::create_styled_node(const Document& document)
|
||||
{
|
||||
UNUSED_PARAM(document);
|
||||
return make<LayoutStyle>();
|
||||
return StyledNode::create(document);
|
||||
}
|
||||
|
||||
OwnPtr<LayoutStyle> StyleResolver::resolve_element_style(const Element& element)
|
||||
NonnullRefPtr<StyledNode> StyleResolver::create_styled_node(const Element& element)
|
||||
{
|
||||
auto style = make<LayoutStyle>();
|
||||
auto style = StyledNode::create(element);
|
||||
auto matching_rules = collect_matching_rules(element);
|
||||
for (auto& rule : matching_rules) {
|
||||
for (auto& declaration : rule.declarations()) {
|
||||
style->set_property(declaration.property_name(), declaration.value());
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue