From 548ebbc2332556b8224a359c836cac7b07fb5c0b Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Mon, 20 Sep 2021 20:11:33 +0200 Subject: [PATCH] LibWeb: Resolve 'inherit' property-value somewhat This doesn't capture the whole picture as shorthands are not considered in a careful way. A very dirty hack is included to not try to resolve 'font' as the amount of debug spam it generated ("No inital value found for...") was unhelpful. --- Userland/Libraries/LibWeb/CSS/StyleResolver.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp index f3fa43e3cf..be94138111 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -534,8 +534,8 @@ Optional StyleResolver::resolve_custom_property(DOM::Element& ele NonnullRefPtr StyleResolver::resolve_style(DOM::Element& element) const { auto style = StyleProperties::create(); - - if (auto* parent_style = element.parent_element() ? element.parent_element()->specified_css_values() : nullptr) { + auto* parent_style = element.parent_element() ? element.parent_element()->specified_css_values() : nullptr; + if (parent_style) { parent_style->for_each_property([&](auto property_id, auto& value) { if (is_inherited_property(property_id)) set_property_expanding_shorthands(style, property_id, value, m_document); @@ -558,6 +558,17 @@ NonnullRefPtr StyleResolver::resolve_style(DOM::Element& elemen property_value = resolved.value().value; } } + // FIXME: This also captures shorthands of which we ideally want to resolve the long names separately. + if (property_value->is_inherit()) { + // HACK: Trying to resolve the font property here lead to copious amounts of debug-spam + if (property.property_id == CSS::PropertyID::Font) + continue; + if (parent_style) { + auto maybe_parent_property_value = parent_style->property(property.property_id); + if (maybe_parent_property_value.has_value()) + property_value = maybe_parent_property_value.release_value(); + } + } set_property_expanding_shorthands(style, property.property_id, property_value, m_document); } }