mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibWeb/CSS: Improve parsing of length percentage values for transforms
This commit is contained in:
parent
480cbd9126
commit
c994326d5a
Notes:
sideshowbarker
2024-07-16 20:51:53 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/c994326d5a Pull-request: https://github.com/SerenityOS/serenity/pull/22668 Issue: https://github.com/SerenityOS/serenity/issues/22666 Reviewed-by: https://github.com/AtkinsSJ
4 changed files with 33 additions and 2 deletions
|
@ -0,0 +1,15 @@
|
|||
<!doctype html><style>
|
||||
* { outline: 1px solid black; }
|
||||
html { background: white; }
|
||||
body {
|
||||
background: pink;
|
||||
padding: 32px;
|
||||
width: 200px;
|
||||
}
|
||||
div {
|
||||
background: orange;
|
||||
transform: translate(-26px, -25px);
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
</style><body><div>
|
16
Tests/LibWeb/Ref/transform-calc-length-percentage.html
Normal file
16
Tests/LibWeb/Ref/transform-calc-length-percentage.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<link rel="match" href="reference/transform-calc-length-percentage-ref.html" /><style>
|
||||
* { outline: 1px solid black; }
|
||||
html { background: white; }
|
||||
body {
|
||||
background: pink;
|
||||
padding: 32px;
|
||||
width: 200px;
|
||||
}
|
||||
div {
|
||||
background: orange;
|
||||
transform: translate(calc(-50% - 1px), -50%);
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
</style><body><div>
|
|
@ -5095,7 +5095,7 @@ RefPtr<StyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>& to
|
|||
break;
|
||||
}
|
||||
case TransformFunctionParameterType::LengthPercentage: {
|
||||
if (maybe_calc_value && maybe_calc_value->resolves_to_length()) {
|
||||
if (maybe_calc_value && maybe_calc_value->resolves_to_length_percentage()) {
|
||||
values.append(maybe_calc_value.release_nonnull());
|
||||
} else {
|
||||
auto dimension_value = parse_dimension_value(value);
|
||||
|
|
|
@ -426,7 +426,7 @@ Vector<CSS::Transformation> StyleProperties::transformations_for_style_value(Sty
|
|||
for (auto& transformation_value : transformation_style_value.values()) {
|
||||
if (transformation_value->is_calculated()) {
|
||||
auto& calculated = transformation_value->as_calculated();
|
||||
if (calculated.resolves_to_length()) {
|
||||
if (calculated.resolves_to_length_percentage()) {
|
||||
values.append(CSS::LengthPercentage { calculated });
|
||||
} else if (calculated.resolves_to_percentage()) {
|
||||
values.append({ calculated.resolve_percentage().value() });
|
||||
|
|
Loading…
Reference in a new issue