Bug 1804802 [wpt PR 37414] - Fix a bug in CSSNumericValue parsing, a=testonly

Automatic update from web-platform-tests
Fix a bug in CSSNumericValue parsing

In CSSNumericValue parsing, there's a part of code that tries to merge
consecutive binary operations (e.g., `a + b + c`) into a variable
Typed OM operation node. The code was written before the introduction
of min/max/clamp, and incorrectly loops into such nodes, and then tries
to convert a min/max/clamp as a binary arithmetic operation.

This patch makes it aware that there are comparison nodes in the
expression tree and therefore fixes the bug.

Fixed: 1395232
Change-Id: Iff12c5f26785effa716b705630c21219935f9861
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4090552
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org>
Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1081264}

--

wpt-commits: f8579f36b038208e5a7feef1ff1658871643c508
wpt-pr: 37414
This commit is contained in:
Xiaocheng Hu 2022-12-11 21:38:36 +00:00 committed by moz-wptsync-bot
parent 70223718c1
commit 2013d69eb8

View File

@ -46,4 +46,13 @@ test(() => {
assert_style_value_equals(expected, CSSNumericValue.parse('clamp(10px, 10%, 20px)'));
}, 'Parsing clamp() is successful');
test(() => {
const expected = new CSSMathSum(...[1, 2, 3].map(x => new CSSMathMin(CSS.number(x))));
assert_style_value_equals(expected, CSSNumericValue.parse('min(1) + min(2) + min(3)'));
}, 'Parsing sum of multiple min() is successful');
test(() => {
const expected = new CSSMathProduct(...[1, 2, 3].map(x => new CSSMathMin(CSS.number(x))));
assert_style_value_equals(expected, CSSNumericValue.parse('min(1) * min(2) * min(3)'));
}, 'Parsing product of multiple min() is successful');
</script>