mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb/CSS: Improve parsing of length percentage values for transforms
This commit is contained in:
parent
480cbd9126
commit
c994326d5a
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;
|
break;
|
||||||
}
|
}
|
||||||
case TransformFunctionParameterType::LengthPercentage: {
|
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());
|
values.append(maybe_calc_value.release_nonnull());
|
||||||
} else {
|
} else {
|
||||||
auto dimension_value = parse_dimension_value(value);
|
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()) {
|
for (auto& transformation_value : transformation_style_value.values()) {
|
||||||
if (transformation_value->is_calculated()) {
|
if (transformation_value->is_calculated()) {
|
||||||
auto& calculated = transformation_value->as_calculated();
|
auto& calculated = transformation_value->as_calculated();
|
||||||
if (calculated.resolves_to_length()) {
|
if (calculated.resolves_to_length_percentage()) {
|
||||||
values.append(CSS::LengthPercentage { calculated });
|
values.append(CSS::LengthPercentage { calculated });
|
||||||
} else if (calculated.resolves_to_percentage()) {
|
} else if (calculated.resolves_to_percentage()) {
|
||||||
values.append({ calculated.resolve_percentage().value() });
|
values.append({ calculated.resolve_percentage().value() });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue