mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Only resolve transform-origin
keywords for the computed value
Previously, we were resolving these keywords at parse time, which gave an incorrect serialization of the specified value.
This commit is contained in:
parent
a3f6e71e33
commit
a8d5758777
Notes:
github-actions[bot]
2025-06-15 14:02:58 +00:00
Author: https://github.com/tcl3
Commit: a8d5758777
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5085
7 changed files with 131 additions and 17 deletions
|
@ -640,15 +640,30 @@ TransformBox ComputedProperties::transform_box() const
|
|||
|
||||
TransformOrigin ComputedProperties::transform_origin() const
|
||||
{
|
||||
auto length_percentage_with_keywords_resolved = [](CSSStyleValue const& value) -> Optional<LengthPercentage> {
|
||||
if (value.is_keyword()) {
|
||||
auto keyword = value.to_keyword();
|
||||
if (keyword == Keyword::Left || keyword == Keyword::Top)
|
||||
return Percentage(0);
|
||||
if (keyword == Keyword::Center)
|
||||
return Percentage(50);
|
||||
if (keyword == Keyword::Right || keyword == Keyword::Bottom)
|
||||
return Percentage(100);
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return length_percentage_for_style_value(value);
|
||||
};
|
||||
|
||||
auto const& value = property(PropertyID::TransformOrigin);
|
||||
if (!value.is_value_list() || value.as_value_list().size() != 2)
|
||||
return {};
|
||||
auto const& list = value.as_value_list();
|
||||
auto x_value = length_percentage_for_style_value(list.values()[0]);
|
||||
auto y_value = length_percentage_for_style_value(list.values()[1]);
|
||||
if (!x_value.has_value() || !y_value.has_value()) {
|
||||
|
||||
auto x_value = length_percentage_with_keywords_resolved(list.values()[0]);
|
||||
auto y_value = length_percentage_with_keywords_resolved(list.values()[1]);
|
||||
if (!x_value.has_value() || !y_value.has_value())
|
||||
return {};
|
||||
}
|
||||
return { x_value.value(), y_value.value() };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue