LibWeb: Handle flood-opacity in line with other opacity properties

We now do the proper thing in terms of:
 - Allowing percentages
 - Returning the computed value in getComputedStyle
 - Handling values out of the [0,1] range

Gains us 13 WPT passes in the imported tests.
This commit is contained in:
Callum Law
2025-07-18 22:37:12 +12:00
committed by Alexander Kalenik
parent 6f39c30704
commit 4ee8110449
Notes: github-actions[bot] 2025-07-18 15:06:07 +00:00
7 changed files with 84 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
width="800px" height="800px">
<title>Filter Effects Module Level 1: getComputedStyle().floodOpacity</title>
<metadata>
<h:link rel="help" href="https://drafts.fxtf.org/filter-effects/#propdef-flood-opacity"/>
<h:meta name="assert" content="flood-opacity computed value is clamped to the range [0,1]."/>
</metadata>
<g id="target"></g>
<h:script src="../../../resources/testharness.js"/>
<h:script src="../../../resources/testharnessreport.js"/>
<h:script src="../../../css/support/computed-testcommon.js"/>
<script><![CDATA[
test_computed_value("flood-opacity", "-1", "0");
test_computed_value("flood-opacity", "0.5");
test_computed_value("flood-opacity", "3", "1");
test_computed_value("flood-opacity", "-100%", "0");
test_computed_value("flood-opacity", "50%", "0.5");
test_computed_value("flood-opacity", "300%", "1");
test_computed_value("flood-opacity", "calc(0.5 * sign(10em - 1px))", "0.5");
test_computed_value("flood-opacity", "calc(50% * sign(10em - 1px))", "0.5");
]]></script>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:h="http://www.w3.org/1999/xhtml"
width="800px" height="800px">
<title>Filter Effects Module Level 1: parsing flood-opacity with valid values</title>
<metadata>
<h:link rel="help" href="https://drafts.fxtf.org/filter-effects/#propdef-flood-opacity"/>
<h:meta name="assert" content="flood-opacity supports the full grammar 'alpha-value'."/>
</metadata>
<g id="target"></g>
<h:script src="../../../resources/testharness.js"/>
<h:script src="../../../resources/testharnessreport.js"/>
<h:script src="../../../css/support/parsing-testcommon.js"/>
<script><![CDATA[
test_valid_value("flood-opacity", "-1");
test_valid_value("flood-opacity", "0.5");
test_valid_value("flood-opacity", "3");
test_valid_value("flood-opacity", "-100%", "-1");
test_valid_value("flood-opacity", "50%", "0.5");
test_valid_value("flood-opacity", "300%", "3");
test_valid_value("flood-opacity", "calc(0.5 * sign(10em - 1px))");
]]></script>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB