mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Require layout update for less properties in getComputedStyle()
Some properties like `justify-items`, `grid`, or `display` do affect layout, but their used values can be obtained without performing a layout calculation. This change introduces a new helper, `property_needs_layout_for_getcomputedstyle()`, specifically for use by `CSSStyleProperties::property()`. It returns true only for properties such as `width`, `height`, `margin`, `padding`, `top`, and `left`, where an up-to-date layout is required to return the correct used value.
This commit is contained in:
committed by
Andreas Kling
parent
815e77c04d
commit
db5fd614ac
Notes:
github-actions[bot]
2025-09-12 09:07:24 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/db5fd614aca Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6158 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/Zaggy1024
@@ -291,6 +291,7 @@ size_t property_maximum_value_count(PropertyID);
|
||||
|
||||
bool property_affects_layout(PropertyID);
|
||||
bool property_affects_stacking_context(PropertyID);
|
||||
bool property_needs_layout_for_getcomputedstyle(PropertyID);
|
||||
|
||||
constexpr PropertyID first_property_id = PropertyID::@first_property_id@;
|
||||
constexpr PropertyID last_property_id = PropertyID::@last_property_id@;
|
||||
@@ -700,6 +701,32 @@ bool property_affects_stacking_context(PropertyID property_id)
|
||||
}
|
||||
}
|
||||
|
||||
bool property_needs_layout_for_getcomputedstyle(PropertyID property_id)
|
||||
{
|
||||
switch (property_id) {
|
||||
)~~~");
|
||||
|
||||
properties.for_each_member([&](auto& name, auto& value) {
|
||||
VERIFY(value.is_object());
|
||||
if (is_legacy_alias(value.as_object()))
|
||||
return;
|
||||
|
||||
if (value.as_object().get_bool("needs-layout-for-getcomputedstyle"sv).value_or(false)) {
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
case PropertyID::@name:titlecase@:
|
||||
)~~~");
|
||||
}
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> property_initial_value(PropertyID property_id)
|
||||
{
|
||||
static Array<RefPtr<StyleValue const>, to_underlying(last_property_id) + 1> initial_values;
|
||||
|
||||
Reference in New Issue
Block a user