LibWeb/CSS: Don't serialize longhands which match their initial values

Shorthand subproperties that match their initial values are now
excluded from serialization, by default.

Properties where this behavior is not desired, like `gap`, are
special-cased.
This commit is contained in:
Tim Ledbetter 2025-04-06 23:34:39 +01:00 committed by Sam Atkins
commit 3186adeaa1
Notes: github-actions[bot] 2025-04-07 10:40:16 +00:00
6 changed files with 144 additions and 27 deletions

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Backgrounds and Borders Module Level 3: parsing border with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-backgrounds/#border-shorthands">
<meta name="assert" content="border supports the full grammar '<line-width> || <line-style> || <color>'.">
<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("border", "1px dotted red");
test_valid_value("border", "green double thin", "thin double green");
test_valid_value("border-top", "thin", ["thin", "thin none"]);
test_valid_value("border-right", "double", ["double", "medium double"]);
test_valid_value("border-bottom", "green", ["green", "medium none green"]);
test_valid_value("border-left", "1px dotted red");
</script>
</body>
</html>

View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS UI Level 3: parsing outline with valid values</title>
<link rel="author" title="Eric Willigers" href="mailto:ericwilligers@chromium.org">
<link rel="help" href="https://drafts.csswg.org/css-ui-3/#outline">
<link rel="help" href="https://drafts.csswg.org/cssom/#serializing-css-values">
<meta name="assert" content="outline supports the full grammar '<outline-color> || <outline> || <outline>'.">
<meta name="assert" content="outline serializes in canonical order, with shortest possible serialization.">
<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("outline", "rgba(10, 20, 30, 0.4)");
test_valid_value("outline", "auto");
test_valid_value("outline", "none", ["currentcolor", "none", "medium"]);
test_valid_value("outline", "dotted");
test_valid_value("outline", "dashed");
test_valid_value("outline", "solid");
test_valid_value("outline", "double");
test_valid_value("outline", "groove");
test_valid_value("outline", "ridge");
test_valid_value("outline", "inset");
test_valid_value("outline", "outset");
test_valid_value("outline", "0", "0px");
test_valid_value("outline", "1px");
test_valid_value("outline", "calc(2em + 3ex)");
test_valid_value("outline", "thin");
test_valid_value("outline", "medium", ["currentcolor", "none", "medium"]);
test_valid_value("outline", "thick");
test_valid_value("outline", "dashed thin");
test_valid_value("outline", "medium rgba(10, 20, 30, 0.4)", ["rgba(10, 20, 30, 0.4) medium", "rgba(10, 20, 30, 0.4)"]);
test_valid_value("outline", "3px ridge rgba(10, 20, 30, 0.4)", "rgba(10, 20, 30, 0.4) ridge 3px");
</script>
</body>
</html>