web-platform-tests / wpt

Test suites for Web platform specs — including WHATWG, W3C, and others
https://web-platform-tests.org/
Other
5.02k stars 3.12k forks source link

Make ConsumeNumberOrPercent() not crash on unresolvable calc(). #49311

Closed chromium-wpt-export-bot closed 1 day ago

chromium-wpt-export-bot commented 1 day ago

Instead of calling GetDoubleValue() on percentage calc expressions, we just return them directly, and then add a new rule saying that ComputeNumber() on them returns the percentage value divided by 100. This avoids crashes when we try to force them during parsing.

This also takes us halfway towards fixing the opacity-valid.html test; we no longer convert it into just a double (without surrounding calc()), but since we don't properly simplify comparison expressions containing percentages, we don't simplify as much as we should either, so the test is still broken. (And even after that, we'd probably need to convert percentages to decimals inside calc for such properties.)

Change-Id: I8e0e25c35d3df82da75cfb1cf551d7f25d825696 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6037437 Reviewed-by: Anders Hartvoll Ruud \andruud@chromium.org Commit-Queue: Steinar H Gunderson \sesse@chromium.org Cr-Commit-Position: refs/heads/main@{#1386209}