Truly independent web browser
LibWeb: Normalize computed shape coordinates to scalar offsets
Andreas Kling566ddda0b054
diff --git a/Libraries/LibWeb/Rust/src/css/absolutize.rs b/Libraries/LibWeb/Rust/src/css/absolutize.rsindex 75a4269dc82..edd8e4d33d6 100644--- a/Libraries/LibWeb/Rust/src/css/absolutize.rs+++ b/Libraries/LibWeb/Rust/src/css/absolutize.rs@@ -1212,10 +1212,26 @@ fn absolutize_basic_shape(*changed = true;retain_new(StyleValueData::Percentage { value: percentage })};+ // NB: Drop resolved position wrappers so positions and explicit coordinate pairs have+ // identical computed representations, including implicit and explicit "from origin".+ let mut resolve_coordinate = |value: &RetainedStyleValueData, changed: &mut bool| {+ let value = resolve(&keyword_as_percentage(value, changed), changed)?;+ if let Some(StyleValueData::Edge {+ has_edge: false,+ offset,+ ..+ }) = value.optional_data()+ {+ *changed = true;+ Some(offset.clone_retained())+ } else {+ Some(value)+ }+ };for point in points.as_slice() {let [x, y] = point.values();- let x = resolve(&keyword_as_percentage(x, &mut changed), &mut changed)?;- let y = resolve(&keyword_as_percentage(y, &mut changed), &mut changed)?;+ let x = resolve_coordinate(x, &mut changed)?;+ let y = resolve_coordinate(y, &mut changed)?;absolutized_points.push(crate::css::style_value::RetainedShapePoint::from_retained_values(x, y));}if !changed {diff --git a/Libraries/LibWeb/Rust/src/svg/path_parser.rs b/Libraries/LibWeb/Rust/src/svg/path_parser.rsindex 6c3d564e842..95485699d51 100644--- a/Libraries/LibWeb/Rust/src/svg/path_parser.rs+++ b/Libraries/LibWeb/Rust/src/svg/path_parser.rs@@ -751,8 +751,9 @@ impl ParsedPath {/// https://drafts.csswg.org/css-shapes-1/#interpolating-shape/// The commands and points of the shape() equivalent to this path, for interpolating it with a shape(). The first- /// command of the path becomes the initial <coordinate-pair> of the shape(). Absolute coordinates become positions- /// and relative ones coordinate pairs, the way shape() holds them after parsing.+ /// command of the path becomes the initial <coordinate-pair> of the shape().+ /// NB: Commands retain their absolute/relative interpretation, while all coordinates use scalar lengths,+ /// matching computed shape() points.pub(crate) fn to_shape_commands(&self,) -> Option<(@@ -768,19 +769,8 @@ impl ParsedPath {unit: crate::css::style_compute::px_length_unit(),};let value = |value: StyleValueData| RetainedStyleValueData::from_owned(value);- let edge = |offset: f32| {- value(StyleValueData::Edge {- has_edge: false,- edge: 0,- offset: value(length(offset)),- })- };- let point = |absolute: bool, point: [f32; 2]| {- if absolute {- RetainedShapePoint::from_retained_values(edge(point[0]), edge(point[1]))- } else {- RetainedShapePoint::from_retained_values(value(length(point[0])), value(length(point[1])))- }+ let point = |point: [f32; 2]| {+ RetainedShapePoint::from_retained_values(value(length(point[0])), value(length(point[1])))};let zero = || value(StyleValueData::Percentage { value: 0.0 });let mut commands = Vec::with_capacity(self.instructions.len());@@ -793,11 +783,11 @@ impl ParsedPath {} => {if index == 0 {// NB: The current point starts at the origin, so a relative first move is absolute too.- points.push(point(true, end_point));+ points.push(point(end_point));commands.push(ShapeCommand::new(ShapeCommandKind::From, false));continue;}- points.push(point(absolute, end_point));+ points.push(point(end_point));(ShapeCommandKind::Move, absolute)}_ if index == 0 => return None,@@ -806,7 +796,7 @@ impl ParsedPath {absolute,point: end_point,} => {- points.push(point(absolute, end_point));+ points.push(point(end_point));(ShapeCommandKind::Line, absolute)}PathInstruction::HorizontalLineTo { absolute, x } => {@@ -849,7 +839,7 @@ impl ParsedPath {_ => unreachable!(),};let mut command = ShapeCommand::new(kind, !absolute);- points.push(point(absolute, end_point));+ points.push(point(end_point));for (control_index, control_point) in control_points.into_iter().enumerate() {// Absolute control points are positions in the reference box, and relative ones are relative to// the start of the segment.@@ -859,7 +849,7 @@ impl ParsedPath {ShapeControlPointAnchor::Start};command.control_point_count += 1;- points.push(point(absolute, control_point));+ points.push(point(control_point));}commands.push(command);continue;@@ -876,7 +866,7 @@ impl ParsedPath {command.arc_clockwise = sweep;command.arc_large = large_arc;command.arc_has_rotation = x_axis_rotation != 0.0;- points.push(point(absolute, end_point));+ points.push(point(end_point));points.push(RetainedShapePoint::from_retained_values(value(length(radius[0])),value(length(radius[1])),diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-masking/animations/clip-path-interpolation-shape-control-points.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-masking/animations/clip-path-interpolation-shape-control-points.txtindex b901eec2322..06c45342f6d 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-masking/animations/clip-path-interpolation-shape-control-points.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-masking/animations/clip-path-interpolation-shape-control-points.txt@@ -2,31 +2,30 @@ Harness status: OKFound 306 tests-288 Pass-18 Fail-Fail CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]-Fail CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]+306 Pass+Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]+Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px)]Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]-Fail CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]+Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 50px)]-Fail Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]+Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 100px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from origin / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px / 40px 150px)]-Fail CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]-Fail CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]+Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]+Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px)]Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]-Fail CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]+Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]Pass CSS Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)]-Fail Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]+Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (0.5) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 100px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px from origin)] at (1) should be [shape(from top left, curve to 100% 50% with 20px 30px from start / 40px 150px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, curve by 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve by 100% 50% with 20px 30px / 40px 150px)] at (0) should be [shape(from top left, curve by 100% 50% with 20px 30px / 40px 50px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, curve by 100% 50% with 20px 30px from start / 40px 50px)] to [shape(from top left, curve by 100% 50% with 20px 30px / 40px 150px)] at (0.5) should be [shape(from top left, curve by 100% 50% with 20px 30px / 40px 100px)]@@ -76,17 +75,17 @@ Pass CSS Animations: property <clip-path> from [shape(from top left, curve by 10Pass Web Animations: property <clip-path> from [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 50px)] to [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 150px)] at (0) should be [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 50px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 50px)] to [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 150px)] at (0.5) should be [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 100px)]Pass Web Animations: property <clip-path> from [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 50px)] to [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 150px)] at (1) should be [shape(from top left, curve by 100% 50% with 20px 30px from end / 40px 150px)]-Fail CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]-Fail CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]+Pass CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]+Pass CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (1) should be [shape(from top left, smooth to 100% 50% with 20px 150px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]-Fail CSS Transitions with transition: all: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]+Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]Pass CSS Transitions with transition: all: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (1) should be [shape(from top left, smooth to 100% 50% with 20px 150px)]Pass CSS Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]-Fail CSS Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]+Pass CSS Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]Pass CSS Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (1) should be [shape(from top left, smooth to 100% 50% with 20px 150px)]Pass Web Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px)]-Fail Web Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]+Pass Web Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px)]Pass Web Animations: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px)] to [shape(from top left, smooth to 100% 50% with 20px 150px from origin)] at (1) should be [shape(from top left, smooth to 100% 50% with 20px 150px)]Pass CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px from start)] to [shape(from top left, smooth to 100% 50% with 20px 150px from start)] at (0) should be [shape(from top left, smooth to 100% 50% with 20px 50px from start)]Pass CSS Transitions: property <clip-path> from [shape(from top left, smooth to 100% 50% with 20px 50px from start)] to [shape(from top left, smooth to 100% 50% with 20px 150px from start)] at (0.5) should be [shape(from top left, smooth to 100% 50% with 20px 100px from start)]