From 50801260951066eaf4f81c927ece87d4c5174686 Mon Sep 17 00:00:00 2001 From: Vetrox <39677514+Vetrox@users.noreply.github.com> Date: Sat, 31 Dec 2022 11:11:41 +0100 Subject: [PATCH] LibWeb: CSS don't set resolve-failures (var/attr) Previously when resolving an attr or var-defined property with a 'not-set' value like this `property: var(--ValueNotSet)`, we left the property unchanged (as an unresolved) and added it to the computed-style of the element. We still don't change the property but rather we now also don't set unresolved properties in the computed-style. This is an intended behavior. The specification suggests that, on resolving an attr or var property (custom properties) we have an invalid property when neither the variable inside the var, nor the backup value could be resolved. An invalid property must be inherited or defaulted depending on it's type. We already do this with every 'untouched' (as in m_property_values contains no entry for it) value. So not setting the property results in an inherited (or initial) value by a later-called function. This also fixes another problem, where `text-decoration: var(--NotSet)` wouldn't be inherited because the computed-style of the parent element hasn't set `text-decoration` but rather all it's long-versions like `text-decoration-line` and so on. --- Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp index 4869b7a638..109fa2da14 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -787,7 +787,8 @@ void StyleComputer::cascade_declarations(StyleProperties& style, DOM::Element& e if (auto resolved = resolve_unresolved_style_value(element, property.property_id, property.value->as_unresolved())) property_value = resolved.release_nonnull(); } - set_property_expanding_shorthands(style, property.property_id, property_value, m_document); + if (!property_value->is_unresolved()) + set_property_expanding_shorthands(style, property.property_id, property_value, m_document); } } @@ -801,7 +802,8 @@ void StyleComputer::cascade_declarations(StyleProperties& style, DOM::Element& e if (auto resolved = resolve_unresolved_style_value(element, property.property_id, property.value->as_unresolved())) property_value = resolved.release_nonnull(); } - set_property_expanding_shorthands(style, property.property_id, property_value, m_document); + if (!property_value->is_unresolved()) + set_property_expanding_shorthands(style, property.property_id, property_value, m_document); } } }