Truly independent web browser
LibWeb: Resolve math functions in computed `border-image-slice` values
Tim Ledbetterfc112988ac3f
diff --git a/Libraries/LibWeb/Rust/src/css/absolutize.rs b/Libraries/LibWeb/Rust/src/css/absolutize.rsindex 0741d77bc5f..93cfbaa5dca 100644--- a/Libraries/LibWeb/Rust/src/css/absolutize.rs+++ b/Libraries/LibWeb/Rust/src/css/absolutize.rs@@ -1678,6 +1678,29 @@ pub(crate) fn absolutize(value: &StyleValueData, context: &AbsolutizationContext})}+ StyleValueData::BorderImageSlice {+ top,+ right,+ bottom,+ left,+ fill,+ } => {+ let mut changed = false;+ let top = absolutize_child(top, context, &mut changed)?;+ let right = absolutize_child(right, context, &mut changed)?;+ let bottom = absolutize_child(bottom, context, &mut changed)?;+ let left = absolutize_child(left, context, &mut changed)?;+ rebuild!(+ changed,+ StyleValueData::BorderImageSlice {+ top,+ right,+ bottom,+ left,+ fill: *fill,+ }+ )+ }StyleValueData::BorderRadius {is_elliptical,horizontal_radius,diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.txtnew file mode 100644index 00000000000..a6a53e6d399--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.txt@@ -0,0 +1,12 @@+Harness status: OK++Found 7 tests++7 Pass+Pass Property border-image-slice value '1'+Pass Property border-image-slice value '1 2%'+Pass Property border-image-slice value '1 2% 3'+Pass Property border-image-slice value '1 2% 3 4%'+Pass Property border-image-slice value '1% 2 3% 4 fill'+Pass Property border-image-slice value 'calc(10 + (sign(2cqw - 10px) * 5))'+Pass Property border-image-slice value 'calc(10 + (sign(2cqw - 10px) * 5)) calc(20% + (sign(2cqw - 10px) * 5%))'\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.txtnew file mode 100644index 00000000000..bbec7a4b1be--- /dev/null+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.txt@@ -0,0 +1,77 @@+Harness status: OK++Found 72 tests++72 Pass+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (-1) should be [20]+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0) should be [100]+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.125) should be [110]+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.875) should be [170]+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (1) should be [180]+Pass CSS Transitions: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (2) should be [260]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (-1) should be [20]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0) should be [100]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.125) should be [110]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.875) should be [170]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (1) should be [180]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (2) should be [260]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (-1) should be [20]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0) should be [100]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.125) should be [110]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.875) should be [170]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (1) should be [180]+Pass CSS Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (2) should be [260]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (-1) should be [20]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0) should be [100]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.125) should be [110]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (0.875) should be [170]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (1) should be [180]+Pass Web Animations: property <border-image-slice> from [100] to [calc(sign(20rem - 20px) * 180)] at (2) should be [260]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (-1) should be [20%]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0) should be [100%]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.125) should be [110%]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.875) should be [170%]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (1) should be [180%]+Pass CSS Transitions: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (2) should be [260%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (-1) should be [20%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0) should be [100%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.125) should be [110%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.875) should be [170%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (1) should be [180%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (2) should be [260%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (-1) should be [20%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0) should be [100%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.125) should be [110%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.875) should be [170%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (1) should be [180%]+Pass CSS Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (2) should be [260%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (-1) should be [20%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0) should be [100%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.125) should be [110%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (0.875) should be [170%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (1) should be [180%]+Pass Web Animations: property <border-image-slice> from [100%] to [calc(sign(20rem - 20px) * 180%)] at (2) should be [260%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (-1) should be [20%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0) should be [100%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.125) should be [110%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.875) should be [170%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (1) should be [180%]+Pass CSS Transitions: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (2) should be [260%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (-1) should be [20%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0) should be [100%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.125) should be [110%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.875) should be [170%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (1) should be [180%]+Pass CSS Transitions with transition: all: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (2) should be [260%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (-1) should be [20%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0) should be [100%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.125) should be [110%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.875) should be [170%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (1) should be [180%]+Pass CSS Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (2) should be [260%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (-1) should be [20%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0) should be [100%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.125) should be [110%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (0.875) should be [170%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (1) should be [180%]+Pass Web Animations: property <border-image-slice> from [calc(sign(20rem - 20px) * 100%)] to [calc(progress(10rem, 20px, 100px) * 180%)] at (2) should be [260%]\ No newline at end of filediff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.htmlnew file mode 100644index 00000000000..2153b7efbbb--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-backgrounds/parsing/border-image-slice-computed.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<html>+<head>+<meta charset="utf-8">+<title>CSS Backgrounds and Borders: getComputedStyle().borderImageSlice</title>+<link rel="help" href="https://drafts.csswg.org/css-backgrounds/#border-image-slice">+<meta name="assert" content="border-image-slice computed value is four values, each either a number or percentage; plus a fill keyword if specified.">+<script src="../../../resources/testharness.js"></script>+<script src="../../../resources/testharnessreport.js"></script>+<script src="../../../css/support/computed-testcommon.js"></script>+<style>+ #container {+ container-type: inline-size;+ width: 100px;+ }+</style>+</head>+<body>+<div id="container">+ <div id="target"></div>+</div>+<script>++test_computed_value("border-image-slice", "1");+test_computed_value("border-image-slice", "1 2%");+test_computed_value("border-image-slice", "1 2% 3");+test_computed_value("border-image-slice", "1 2% 3 4%");++test_computed_value("border-image-slice", "1% 2 3% 4 fill");++test_computed_value("border-image-slice", 'calc(10 + (sign(2cqw - 10px) * 5))', '5');+test_computed_value("border-image-slice", 'calc(10 + (sign(2cqw - 10px) * 5)) calc(20% + (sign(2cqw - 10px) * 5%))', '5 15%');+</script>+</body>+</html>diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.html b/Tests/LibWeb/Text/input/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.htmlnew file mode 100644index 00000000000..7882fa6c7ef--- /dev/null+++ b/Tests/LibWeb/Text/input/wpt-import/css/css-images/animation/image-slice-interpolation-math-functions-tentative.html@@ -0,0 +1,59 @@+<!DOCTYPE html>+<html>+ <head>+ <meta charset="utf-8">+ <title>border-image-slice interpolation with css math functions</title>+ <link rel="author" title="Daniil Sakhapov" href="mailto:[email protected]">+ <link rel="help" href="https://drafts.csswg.org/css-backgrounds/#the-border-image-slice">+ <script src="../../../resources/testharness.js"></script>+ <script src="../../../resources/testharnessreport.js"></script>+ <script src="../../../css/support/interpolation-testcommon.js"></script>+ </head>+ <style>+ :root {+ font-size: 10px;+ }+ </style>+ <body>+ <script>+ test_interpolation({+ property: 'border-image-slice',+ from: '100',+ to: 'calc(sign(20rem - 20px) * 180)',+ }, [+ {at: -1, expect: '20'},+ {at: 0, expect: '100'},+ {at: 0.125, expect: '110'},+ {at: 0.875, expect: '170'},+ {at: 1, expect: '180'},+ {at: 2, expect: '260'}+ ]);++ test_interpolation({+ property: 'border-image-slice',+ from: '100%',+ to: 'calc(sign(20rem - 20px) * 180%)',+ }, [+ {at: -1, expect: '20%'},+ {at: 0, expect: '100%'},+ {at: 0.125, expect: '110%'},+ {at: 0.875, expect: '170%'},+ {at: 1, expect: '180%'},+ {at: 2, expect: '260%'}+ ]);++ test_interpolation({+ property: 'border-image-slice',+ from: 'calc(sign(20rem - 20px) * 100%)',+ to: 'calc(progress(10rem, 20px, 100px) * 180%)',+ }, [+ {at: -1, expect: '20%'},+ {at: 0, expect: '100%'},+ {at: 0.125, expect: '110%'},+ {at: 0.875, expect: '170%'},+ {at: 1, expect: '180%'},+ {at: 2, expect: '260%'}+ ]);+ </script>+ </body>+</html>