1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

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.
This commit is contained in:
Tobias Christiansen 2021-09-20 20:11:33 +02:00 committed by Andreas Kling
parent a50f4d2fc9
commit 548ebbc233

View file

@ -534,8 +534,8 @@ Optional<StyleProperty> StyleResolver::resolve_custom_property(DOM::Element& ele
NonnullRefPtr<StyleProperties> 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<StyleProperties> 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);
}
}