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:
Tim Ledbetter
2025-06-14 00:47:59 +01:00
committed by Alexander Kalenik
parent a3f6e71e33
commit a8d5758777
Notes: github-actions[bot] 2025-06-15 14:02:58 +00:00
7 changed files with 131 additions and 17 deletions

View File

@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Transform Module Level 1: parsing transform-origin with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms/#transform-origin-property">
<meta name="assert" content="transform-origin supports only the grammar from spec.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("transform-origin", "1px 2px 3%");
test_invalid_value("transform-origin", "1px 2px left");
test_invalid_value("transform-origin", "1px 2px 3px 4px");
test_invalid_value("transform-origin", "1px left");
test_invalid_value("transform-origin", "top 1px"); // Blink fails.
test_invalid_value("transform-origin", "right left");
test_invalid_value("transform-origin", "top bottom");
test_invalid_value("transform-origin", "bottom 10% right 20%");
test_invalid_value("transform-origin", "right 30% top -60px");
test_invalid_value("transform-origin", "right 20px bottom 30px");
</script>
</body>
</html>

View File

@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Transform Module Level 1: parsing transform-origin with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms/#transform-origin-property">
<meta name="assert" content="transform-origin supports the full grammar from spec.">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../../css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("transform-origin", "left", ["left center 0px", "left 50% 0px", "left center"]);
test_valid_value("transform-origin", "center", ["center center 0px", "center 50% 0px", "center center"]);
test_valid_value("transform-origin", "right", ["right center 0px", "right 50% 0px", "right center"]);
test_valid_value("transform-origin", "top", ["center top 0px", "50% top 0px", "center top"]);
test_valid_value("transform-origin", "bottom", ["center bottom 0px", "50% bottom 0px", "center bottom"]);
test_valid_value("transform-origin", "-1px", ["-1px center 0px", "-1px 50% 0px", "-1px center"]);
test_valid_value("transform-origin", "calc(2em + 3ex)", ["calc(2em + 3ex) center 0px", "calc(2em + 3ex) 50% 0px", "calc(2em + 3ex) center"]);
test_valid_value("transform-origin", "-4%", ["-4% center 0px", "-4% 50% 0px", "-4% center"]);
test_valid_value("transform-origin", "left center", ["left center 0px", "left center"]);
test_valid_value("transform-origin", "center top", ["center top 0px", "center top"]);
test_valid_value("transform-origin", "right -4%", ["right -4% 0px", "right -4%"]);
test_valid_value("transform-origin", "-1px bottom 5px");
test_valid_value("transform-origin", "center left 6px", "left center 6px");
test_valid_value("transform-origin", "top center", ["center top 0px", "center top"]);
test_valid_value("transform-origin", "bottom right 7px", "right bottom 7px");
test_valid_value("transform-origin", "-1px -2px -3px");
</script>
</body>
</html>