LibWeb/CSS: Correct matching of calc() against <number-percentage>
Some checks are pending
CI / Lagom (false, FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, macos-14, macOS, Clang) (push) Waiting to run
CI / Lagom (false, NO_FUZZ, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (true, NO_FUZZ, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Push notes / build (push) Waiting to run

This seems to have vanished from the spec, but in any case, we still
need it. Without this change we erroneously thought that calculations
that match <percentage> did not match <number-percentage>.
This commit is contained in:
Sam Atkins 2024-10-30 17:12:42 +00:00 committed by Alexander Kalenik
parent 797b0d0f43
commit 760943d584
Notes: github-actions[bot] 2024-10-30 19:59:14 +00:00
3 changed files with 18 additions and 3 deletions

View file

@ -0,0 +1 @@
rgb(88, 101, 242)

View file

@ -0,0 +1,13 @@
<!doctype html>
<script src="../include.js"></script>
<style>
#target {
background-color: hsl(235 calc(1 * 85.6%) 64.7% / 1);
}
</style>
<div id="target">Hello</div>
<script>
test(() => {
println(getComputedStyle(document.getElementById("target"))["background-color"]);
});
</script>

View file

@ -350,7 +350,7 @@ bool CSSNumericType::matches_percentage() const
auto base_type = static_cast<BaseType>(i);
auto type_exponent = exponent(base_type);
if (base_type == BaseType::Percent) {
if (!type_exponent.has_value() || type_exponent == 0)
if (type_exponent != 1)
return false;
} else {
if (type_exponent.has_value() && type_exponent != 0)
@ -409,8 +409,9 @@ bool CSSNumericType::matches_number_percentage() const
auto base_type = static_cast<BaseType>(i);
auto type_exponent = exponent(base_type);
if (base_type == BaseType::Percent && type_exponent.has_value() && type_exponent != 0 && type_exponent != 1) {
return false;
if (base_type == BaseType::Percent) {
if (type_exponent.has_value() && type_exponent != 0 && type_exponent != 1)
return false;
} else if (type_exponent.has_value() && type_exponent != 0) {
return false;
}