mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-24 03:52:58 +00:00
LibWeb: Make transform: scale(calc(..))
work
The `transform` property supports transform functions that sometimes need their `calc(percentage)` values to be converted to a number instead of a length. Currently this only applies to the `scale*` family of functions, which are marked as such in `TransformFunctions.json`. We were not consistently applying the `NumberPercentage` type to these functions though, and in addition, any `NumberPercentage` value would not consider calculated values.
This commit is contained in:
parent
202cbe7df6
commit
545d151948
Notes:
github-actions[bot]
2025-03-25 19:54:42 +00:00
Author: https://github.com/gmta
Commit: 545d151948
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4088
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 26 additions and 10 deletions
|
@ -46,7 +46,15 @@ ErrorOr<Gfx::FloatMatrix4x4> Transformation::to_matrix(Optional<Painting::Painta
|
|||
[&](CSS::NumberPercentage const& value) -> ErrorOr<float> {
|
||||
if (value.is_percentage())
|
||||
return value.percentage().as_fraction();
|
||||
return value.number().value();
|
||||
if (value.is_number())
|
||||
return value.number().value();
|
||||
if (value.is_calculated()) {
|
||||
if (value.calculated()->resolves_to_number())
|
||||
return value.calculated()->resolve_number(context).value();
|
||||
if (value.calculated()->resolves_to_percentage())
|
||||
return value.calculated()->resolve_percentage(context)->as_fraction();
|
||||
}
|
||||
return Error::from_string_literal("Transform contains non absolute units");
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue