diff options
author | Vetrox <39677514+Vetrox@users.noreply.github.com> | 2022-12-31 11:11:41 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-03 18:07:28 +0100 |
commit | 50801260951066eaf4f81c927ece87d4c5174686 (patch) | |
tree | be32ec743e19294551bb04f349e22bd2f6eed52a /Userland/Libraries/LibWeb | |
parent | b36d09bab0d33c8d9c04efe6ece1173b24475d29 (diff) | |
download | serenity-50801260951066eaf4f81c927ece87d4c5174686.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/StyleComputer.cpp | 6 |
1 files 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); } } } |