mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
LibHTML: Implement basic style inheritance
This commit is contained in:
parent
3be897a3d5
commit
841ae44392
2 changed files with 11 additions and 2 deletions
|
@ -52,9 +52,18 @@ NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Eleme
|
||||||
return matching_rules;
|
return matching_rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleProperties StyleResolver::resolve_style(const Element& element)
|
StyleProperties StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_properties) const
|
||||||
{
|
{
|
||||||
StyleProperties style_properties;
|
StyleProperties style_properties;
|
||||||
|
|
||||||
|
if (parent_properties) {
|
||||||
|
parent_properties->for_each_property([&](const StringView& name, auto& value) {
|
||||||
|
// TODO: proper inheritance
|
||||||
|
if (name.starts_with("font") || name == "white-space")
|
||||||
|
style_properties.set_property(name, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
auto matching_rules = collect_matching_rules(element);
|
auto matching_rules = collect_matching_rules(element);
|
||||||
for (auto& rule : matching_rules) {
|
for (auto& rule : matching_rules) {
|
||||||
for (auto& declaration : rule.declarations()) {
|
for (auto& declaration : rule.declarations()) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
Document& document() { return m_document; }
|
Document& document() { return m_document; }
|
||||||
const Document& document() const { return m_document; }
|
const Document& document() const { return m_document; }
|
||||||
|
|
||||||
StyleProperties resolve_style(const Element&);
|
StyleProperties resolve_style(const Element&, const StyleProperties* parent_properties) const;
|
||||||
|
|
||||||
NonnullRefPtrVector<StyleRule> collect_matching_rules(const Element&) const;
|
NonnullRefPtrVector<StyleRule> collect_matching_rules(const Element&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue