mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb/CSS: Correct matching of calc()
against <number-percentage>
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:
parent
797b0d0f43
commit
760943d584
Notes:
github-actions[bot]
2024-10-30 19:59:14 +00:00
Author: https://github.com/AtkinsSJ
Commit: 760943d584
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2061
Reviewed-by: https://github.com/LucasChollet
3 changed files with 18 additions and 3 deletions
|
@ -0,0 +1 @@
|
||||||
|
rgb(88, 101, 242)
|
|
@ -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>
|
|
@ -350,7 +350,7 @@ bool CSSNumericType::matches_percentage() const
|
||||||
auto base_type = static_cast<BaseType>(i);
|
auto base_type = static_cast<BaseType>(i);
|
||||||
auto type_exponent = exponent(base_type);
|
auto type_exponent = exponent(base_type);
|
||||||
if (base_type == BaseType::Percent) {
|
if (base_type == BaseType::Percent) {
|
||||||
if (!type_exponent.has_value() || type_exponent == 0)
|
if (type_exponent != 1)
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (type_exponent.has_value() && type_exponent != 0)
|
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 base_type = static_cast<BaseType>(i);
|
||||||
auto type_exponent = exponent(base_type);
|
auto type_exponent = exponent(base_type);
|
||||||
|
|
||||||
if (base_type == BaseType::Percent && type_exponent.has_value() && type_exponent != 0 && type_exponent != 1) {
|
if (base_type == BaseType::Percent) {
|
||||||
return false;
|
if (type_exponent.has_value() && type_exponent != 0 && type_exponent != 1)
|
||||||
|
return false;
|
||||||
} else if (type_exponent.has_value() && type_exponent != 0) {
|
} else if (type_exponent.has_value() && type_exponent != 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue