mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb: Handle calc() in CSS z-index
We also make getComputedStyle() reflect the actually used z-index value, since otherwise this change is hard to observe. +26 new WPT subtest passes.
This commit is contained in:
parent
821d54de7f
commit
c1e79d0b13
Notes:
github-actions[bot]
2025-05-20 11:29:48 +00:00
Author: https://github.com/awesomekling
Commit: c1e79d0b13
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4823
3 changed files with 48 additions and 34 deletions
|
@ -1005,6 +1005,10 @@ RefPtr<CSSStyleValue const> CSSStyleProperties::style_value_for_computed_propert
|
|||
return used_values_for_grid_template_rows;
|
||||
}
|
||||
}
|
||||
} else if (property_id == PropertyID::ZIndex) {
|
||||
if (auto z_index = layout_node.computed_values().z_index(); z_index.has_value()) {
|
||||
return NumberStyleValue::create(z_index.value());
|
||||
}
|
||||
}
|
||||
|
||||
if (!property_is_shorthand(property_id))
|
||||
|
|
|
@ -332,14 +332,24 @@ Optional<int> ComputedProperties::z_index() const
|
|||
auto const& value = property(PropertyID::ZIndex);
|
||||
if (value.has_auto())
|
||||
return {};
|
||||
if (value.is_integer()) {
|
||||
// Clamp z-index to the range of a signed 32-bit integer for consistency with other engines.
|
||||
auto integer = value.as_integer().integer();
|
||||
if (integer >= NumericLimits<int>::max())
|
||||
|
||||
// Clamp z-index to the range of a signed 32-bit integer for consistency with other engines.
|
||||
auto clamp = [](auto number) -> int {
|
||||
if (number >= NumericLimits<int>::max())
|
||||
return NumericLimits<int>::max();
|
||||
if (integer <= NumericLimits<int>::min())
|
||||
if (number <= NumericLimits<int>::min())
|
||||
return NumericLimits<int>::min();
|
||||
return static_cast<int>(integer);
|
||||
return static_cast<int>(number);
|
||||
};
|
||||
|
||||
if (value.is_integer()) {
|
||||
return clamp(value.as_integer().integer());
|
||||
}
|
||||
if (value.is_calculated()) {
|
||||
auto maybe_double = value.as_calculated().resolve_number({});
|
||||
if (maybe_double.has_value()) {
|
||||
return clamp(maybe_double.value());
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue