mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Handle unset
immediately in compute_properties
Previously we would hand off to `compute_defaulted_properties` to resolve these values but there is no need as we can just resolve them immediately.
This commit is contained in:
parent
c9fbc2db0b
commit
ca9cb42ed4
Notes:
github-actions[bot]
2025-08-21 11:50:50 +00:00
Author: https://github.com/Calme1709
Commit: ca9cb42ed4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5927
Reviewed-by: https://github.com/gmta ✅
1 changed files with 12 additions and 9 deletions
|
@ -2674,23 +2674,26 @@ GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::Element& elem
|
|||
if (property_id == PropertyID::FontSize && !value && new_font_size)
|
||||
continue;
|
||||
|
||||
bool should_inherit = (!value && is_inherited_property(property_id));
|
||||
|
||||
// https://www.w3.org/TR/css-cascade-4/#inherit
|
||||
// If the cascaded value of a property is the inherit keyword, the property’s specified and computed values are the inherited value.
|
||||
should_inherit |= value && value->is_inherit();
|
||||
|
||||
// https://www.w3.org/TR/css-cascade-4/#inherit-initial
|
||||
// If the cascaded value of a property is the unset keyword, then if it is an inherited property, this is treated as inherit, and if it is not, this is treated as initial.
|
||||
should_inherit |= value && value->is_unset() && is_inherited_property(property_id);
|
||||
|
||||
// FIXME: Logical properties should inherit from their parent's equivalent unmapped logical property.
|
||||
if ((!value && is_inherited_property(property_id)) || (value && value->is_inherit())) {
|
||||
if (should_inherit) {
|
||||
value = get_inherit_value(property_id, &element, pseudo_element);
|
||||
animated_value = get_animated_inherit_value(property_id, &element, pseudo_element);
|
||||
inherited = ComputedProperties::Inherited::Yes;
|
||||
}
|
||||
|
||||
if (!value || value->is_initial())
|
||||
if (!value || value->is_initial() || value->is_unset())
|
||||
value = property_initial_value(property_id);
|
||||
|
||||
if (value->is_unset()) {
|
||||
if (is_inherited_property(property_id))
|
||||
value = KeywordStyleValue::create(Keyword::Inherit);
|
||||
else
|
||||
value = KeywordStyleValue::create(Keyword::Initial);
|
||||
}
|
||||
|
||||
computed_style->set_property(property_id, value.release_nonnull(), inherited);
|
||||
if (animated_value.has_value())
|
||||
computed_style->set_animated_property(property_id, animated_value.value(), inherited);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue