Truly independent web browser
LibWeb: Implement the shape() basic shape
Andreas Klinga3a3aabedf9e
diff --git a/Libraries/LibWeb/Rust/src/css/absolutize.rs b/Libraries/LibWeb/Rust/src/css/absolutize.rsindex caa9d3578ce..d4efd284086 100644--- a/Libraries/LibWeb/Rust/src/css/absolutize.rs+++ b/Libraries/LibWeb/Rust/src/css/absolutize.rs@@ -925,6 +925,7 @@ fn absolutize_basic_shape(fill_rule,points,path,+ commands,} = value.basic_shape()?;// Absolutizes a freshly built 100%-minus calculation for the inset lowering.let flipped = |values: &[&StyleValueData],@@ -970,6 +971,7 @@ fn absolutize_basic_shape(fill_rule: *fill_rule,points: points.clone(),path: path.clone(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})))}@@ -1016,6 +1018,7 @@ fn absolutize_basic_shape(fill_rule: *fill_rule,points: points.clone(),path: path.clone(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})))}@@ -1037,16 +1040,33 @@ fn absolutize_basic_shape(fill_rule: *fill_rule,points: points.clone(),path: path.clone(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})))}- 5 => {+ // polygon() and shape() hold their coordinates as points.+ 5 | 7 => {let mut changed = false;let mut absolutized_points = Vec::with_capacity(points.as_slice().len());+ // https://drafts.csswg.org/css-shapes-1/#shape-function+ // A horizontal or vertical line to a side keyword draws to that position.+ let keyword_as_percentage = |value: &RetainedStyleValueData, changed: &mut bool| {+ let percentage = match value.optional_data() {+ Some(StyleValueData::Keyword { keyword }) => match *keyword {+ keyword::LEFT | keyword::TOP | keyword::X_START | keyword::Y_START => 0.0,+ keyword::CENTER => 50.0,+ keyword::RIGHT | keyword::BOTTOM | keyword::X_END | keyword::Y_END => 100.0,+ _ => return value.clone_retained(),+ },+ _ => return value.clone_retained(),+ };+ *changed = true;+ retain_new(StyleValueData::Percentage { value: percentage })+ };for point in points.as_slice() {let [x, y] = point.values();- let x = resolve(x, &mut changed)?;- let y = resolve(y, &mut changed)?;+ let x = resolve(&keyword_as_percentage(x, &mut changed), &mut changed)?;+ let y = resolve(&keyword_as_percentage(y, &mut changed), &mut changed)?;absolutized_points.push(crate::css::style_value::RetainedShapePoint::from_retained_values(x, y));}if !changed {@@ -1054,7 +1074,7 @@ fn absolutize_basic_shape(}Some(Absolutized::Changed(retain_new(StyleValueData::BasicShape {shape: OwnedBasicShapeData::new(BasicShapeData {- kind: 5,+ kind: *kind,v0: v0.clone_retained(),v1: v1.clone_retained(),v2: v2.clone_retained(),@@ -1063,6 +1083,7 @@ fn absolutize_basic_shape(fill_rule: *fill_rule,points: crate::css::style_value::RetainedShapePointList::from_retained_points(absolutized_points),path: path.clone(),+ commands: commands.clone(),}),})))}diff --git a/Libraries/LibWeb/Rust/src/css/animation.rs b/Libraries/LibWeb/Rust/src/css/animation.rsindex 602f39772ca..7b0b9a2b8c0 100644--- a/Libraries/LibWeb/Rust/src/css/animation.rs+++ b/Libraries/LibWeb/Rust/src/css/animation.rs@@ -2401,6 +2401,7 @@ fn interpolate_basic_shape(fill_rule: 0,points: empty_shape_points(),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}@@ -2440,6 +2441,7 @@ fn interpolate_basic_shape(fill_rule: 0,points: empty_shape_points(),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}@@ -2473,6 +2475,7 @@ fn interpolate_basic_shape(fill_rule: *from_fill_rule,points: RetainedShapePointList::from_retained_points(points),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}@@ -2590,6 +2593,7 @@ fn composite_basic_shape(fill_rule: 0,points: empty_shape_points(),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),}),BASIC_SHAPE_CIRCLE | BASIC_SHAPE_ELLIPSE => {@@ -2624,6 +2628,7 @@ fn composite_basic_shape(fill_rule: 0,points: empty_shape_points(),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}@@ -2657,6 +2662,7 @@ fn composite_basic_shape(fill_rule: *underlying_fill_rule,points: RetainedShapePointList::from_retained_points(points),path: crate::css::css_path::CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}diff --git a/Libraries/LibWeb/Rust/src/css/calc.rs b/Libraries/LibWeb/Rust/src/css/calc.rsindex 81c791db7c2..91b43e1f60e 100644--- a/Libraries/LibWeb/Rust/src/css/calc.rs+++ b/Libraries/LibWeb/Rust/src/css/calc.rs@@ -1799,7 +1799,7 @@ impl CalcNumericType {}/// The canonical unit code of each dimension: the index whose ratio is one.-fn canonical_unit_code(ratios: &[f64]) -> u8 {+pub(crate) fn canonical_unit_code(ratios: &[f64]) -> u8 {ratios.iter().position(|&ratio| ratio == 1.0)diff --git a/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rsindex d8de4766926..e951e2412f8 100644--- a/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/positions_shapes_parser.rs@@ -744,6 +744,7 @@ fn basic_shape(fill_rule,points: RetainedShapePointList::from_retained_points(points),path,+ commands: crate::css::style_value::ShapeCommands::default(),}),}}@@ -934,6 +935,7 @@ fn parse_circle_or_ellipse(fill_rule: 0,points: RetainedShapePointList::from_retained_points(vec![]),path: CssPath::none(),+ commands: crate::css::style_value::ShapeCommands::default(),}),})}@@ -1022,11 +1024,308 @@ fn parse_basic_shape(context: &ParseContext, property: u16, values: &[ComponentVparse_polygon(context, property, arguments)} else if equals_ascii_case_insensitive(name, b"path") {parse_path(context, arguments)+ } else if equals_ascii_case_insensitive(name, b"shape") {+ parse_shape(context, property, arguments)} else {None}}+/// The index in `values` of the first top-level identifier at or after `start` that matches one of `names`.+fn find_identifier(values: &[ComponentValue], start: usize, names: &[&str]) -> Option<usize> {+ values[start..]+ .iter()+ .position(|value| {+ value.ident().is_some_and(|ident| {+ names+ .iter()+ .any(|name| equals_ascii_case_insensitive(ident, name.as_bytes()))+ })+ })+ .map(|index| start + index)+}++fn shape_point(x: StyleValueData, y: StyleValueData) -> RetainedShapePoint {+ RetainedShapePoint::from_retained_values(retained(x), retained(y))+}++/// <coordinate-pair> = <length-percentage>{2}, filling all of `values`.+fn parse_coordinate_pair(+ context: &ParseContext,+ property: u16,+ values: &[ComponentValue],+) -> Option<RetainedShapePoint> {+ let mut tokens = TokenStream::new(values);+ let x = parse_length_percentage(context, property, &mut tokens)?;+ let y = parse_length_percentage(context, property, &mut tokens)?;+ tokens.discard_whitespace();+ (!tokens.has_next_token()).then(|| shape_point(x, y))+}++/// A <position>, filling all of `values`, as the point of its two edges.+fn parse_shape_position(+ context: &ParseContext,+ property: u16,+ values: &[ComponentValue],+) -> Option<RetainedShapePoint> {+ let StyleValueData::Position { edge_x, edge_y } = parse_position_value(context, property, values, false)? else {+ return None;+ };+ Some(RetainedShapePoint::from_retained_values(edge_x, edge_y))+}++/// <command-end-point> = [ to <position> | by <coordinate-pair> ], filling all of `values`, and whether it is+/// relative.+fn parse_command_end_point(+ context: &ParseContext,+ property: u16,+ values: &[ComponentValue],+) -> Option<(bool, RetainedShapePoint)> {+ let start = values.iter().position(|value| !value.is_whitespace())?;+ let keyword = values[start].ident()?;+ let rest = &values[start + 1..];+ if equals_ascii_case_insensitive(keyword, b"to") {+ Some((false, parse_shape_position(context, property, rest)?))+ } else if equals_ascii_case_insensitive(keyword, b"by") {+ Some((true, parse_coordinate_pair(context, property, rest)?))+ } else {+ None+ }+}++/// <control-point> = [ <position> | <relative-control-point> ] when `allows_position`, otherwise+/// <relative-control-point> = <coordinate-pair> [ from [ start | end | origin ] ]?+fn parse_control_point(+ context: &ParseContext,+ property: u16,+ values: &[ComponentValue],+ allows_position: bool,+) -> Option<(crate::css::style_value::ShapeControlPointAnchor, RetainedShapePoint)> {+ use crate::css::style_value::ShapeControlPointAnchor;+ if let Some(from) = find_identifier(values, 0, &["from"]) {+ let point = parse_coordinate_pair(context, property, &values[..from])?;+ let mut tokens = TokenStream::new(&values[from + 1..]);+ tokens.discard_whitespace();+ let anchor = tokens.consume_a_token().ident()?;+ let anchor = if equals_ascii_case_insensitive(anchor, b"start") {+ ShapeControlPointAnchor::Start+ } else if equals_ascii_case_insensitive(anchor, b"end") {+ ShapeControlPointAnchor::End+ } else if equals_ascii_case_insensitive(anchor, b"origin") {+ ShapeControlPointAnchor::Origin+ } else {+ return None;+ };+ tokens.discard_whitespace();+ return (!tokens.has_next_token()).then_some((anchor, point));+ }+ if allows_position && let Some(point) = parse_shape_position(context, property, values) {+ return Some((ShapeControlPointAnchor::Origin, point));+ }+ Some((+ ShapeControlPointAnchor::Start,+ parse_coordinate_pair(context, property, values)?,+ ))+}++// https://drafts.csswg.org/css-shapes-1/#shape-function+fn parse_shape(context: &ParseContext, property: u16, arguments: &[ComponentValue]) -> Option<StyleValueData> {+ use crate::css::style_value::{ShapeCommand, ShapeCommandKind, ShapeCommands};+ let segments = arguments.split(ComponentValue::is_comma).collect::<Vec<_>>();+ if segments.len() < 2 {+ return None;+ }++ let mut commands = Vec::new();+ let mut points = Vec::new();++ // <'fill-rule'>? from <position>+ let first = segments[0];+ let from = find_identifier(first, 0, &["from"])?;+ let fill_rule = if first[..from].iter().all(ComponentValue::is_whitespace) {+ 0+ } else {+ parse_fill_rule(&first[..from])?+ };+ points.push(parse_shape_position(context, property, &first[from + 1..])?);+ commands.push(ShapeCommand::new(ShapeCommandKind::From, false));++ for segment in &segments[1..] {+ let start = segment.iter().position(|value| !value.is_whitespace())?;+ let name = segment[start].ident()?;+ let rest = &segment[start + 1..];+ let named = |expected: &str| equals_ascii_case_insensitive(name, expected.as_bytes());+ if named("close") {+ if !rest.iter().all(ComponentValue::is_whitespace) {+ return None;+ }+ commands.push(ShapeCommand::new(ShapeCommandKind::Close, false));+ } else if named("move") || named("line") {+ let (relative, point) = parse_command_end_point(context, property, rest)?;+ let kind = if named("move") {+ ShapeCommandKind::Move+ } else {+ ShapeCommandKind::Line+ };+ commands.push(ShapeCommand::new(kind, relative));+ points.push(point);+ } else if named("hline") || named("vline") {+ let horizontal = named("hline");+ let mut tokens = TokenStream::new(rest);+ tokens.discard_whitespace();+ let keyword = tokens.consume_a_token().ident()?;+ let relative = if equals_ascii_case_insensitive(keyword, b"by") {+ true+ } else if equals_ascii_case_insensitive(keyword, b"to") {+ false+ } else {+ return None;+ };+ tokens.discard_whitespace();+ let keywords: &[&str] = if horizontal {+ &["left", "center", "right", "x-start", "x-end"]+ } else {+ &["top", "center", "bottom", "y-start", "y-end"]+ };+ let named_keyword = (!relative)+ .then(|| tokens.next_token().ident())+ .flatten()+ .filter(|ident| {+ keywords+ .iter()+ .any(|name| equals_ascii_case_insensitive(ident, name.as_bytes()))+ })+ .and_then(keyword_from_ascii_case_insensitive);+ let coordinate = match named_keyword {+ Some(parsed_keyword) => {+ tokens.discard_a_token();+ StyleValueData::Keyword {+ keyword: parsed_keyword,+ }+ }+ None => parse_length_percentage(context, property, &mut tokens)?,+ };+ tokens.discard_whitespace();+ if tokens.has_next_token() {+ return None;+ }+ let zero = || StyleValueData::Percentage { value: 0.0 };+ points.push(if horizontal {+ shape_point(coordinate, zero())+ } else {+ shape_point(zero(), coordinate)+ });+ let kind = if horizontal {+ ShapeCommandKind::HorizontalLine+ } else {+ ShapeCommandKind::VerticalLine+ };+ commands.push(ShapeCommand::new(kind, relative));+ } else if named("curve") || named("smooth") {+ let curve = named("curve");+ let with = find_identifier(rest, 0, &["with"]);+ let (relative, end_point) =+ parse_command_end_point(context, property, &rest[..with.unwrap_or(rest.len())])?;+ let mut command = ShapeCommand::new(+ if curve {+ ShapeCommandKind::Curve+ } else {+ ShapeCommandKind::Smooth+ },+ relative,+ );+ points.push(end_point);+ match with {+ Some(with) => {+ let control_points = rest[with + 1..].split(|value| value.is_delim(b'/')).collect::<Vec<_>>();+ if control_points.len() > if curve { 2 } else { 1 } {+ return None;+ }+ for (index, values) in control_points.into_iter().enumerate() {+ let (anchor, point) = parse_control_point(context, property, values, !relative)?;+ command.control_points[index] = anchor;+ command.control_point_count += 1;+ points.push(point);+ }+ }+ None if curve => return None,+ None => {}+ }+ commands.push(command);+ } else if named("arc") {+ let options = find_identifier(rest, 0, &["of", "cw", "ccw", "large", "small", "rotate"])?;+ let (relative, end_point) = parse_command_end_point(context, property, &rest[..options])?;+ let mut command = ShapeCommand::new(ShapeCommandKind::Arc, relative);+ let mut tokens = TokenStream::new(&rest[options..]);+ let mut radii = None;+ let (mut sweep, mut size, mut rotation) = (None, None, None);+ loop {+ tokens.discard_whitespace();+ if !tokens.has_next_token() {+ break;+ }+ let option = tokens.consume_a_token().ident()?;+ let is = |expected: &str| equals_ascii_case_insensitive(option, expected.as_bytes());+ if is("of") && radii.is_none() {+ let horizontal = parse_length_percentage(context, property, &mut tokens)?;+ let mut after_first = tokens.clone();+ let vertical = parse_length_percentage(context, property, &mut after_first);+ command.arc_has_one_radius = vertical.is_none();+ let vertical = match vertical {+ Some(vertical) => {+ tokens = after_first;+ vertical+ }+ None => horizontal.clone(),+ };+ radii = Some(shape_point(horizontal, vertical));+ } else if (is("cw") || is("ccw")) && sweep.is_none() {+ sweep = Some(is("cw"));+ } else if (is("large") || is("small")) && size.is_none() {+ size = Some(is("large"));+ } else if is("rotate") && rotation.is_none() {+ rotation = Some(super::value_parser::parse_angle_from_stream(+ context,+ property,+ &mut tokens,+ NumericRange::INFINITE,+ )?);+ } else {+ return None;+ }+ }+ command.arc_clockwise = sweep.unwrap_or(false);+ command.arc_large = size.unwrap_or(false);+ command.arc_has_rotation = rotation.is_some();+ let rotation = rotation.unwrap_or(StyleValueData::Angle {+ value: 0.0,+ unit: crate::css::calc::canonical_unit_code(&crate::css::calc::ANGLE_UNIT_CANONICAL_RATIOS),+ });+ points.push(end_point);+ points.push(radii?);+ points.push(shape_point(rotation.clone(), rotation));+ commands.push(command);+ } else {+ return None;+ }+ }++ Some(StyleValueData::BasicShape {+ shape: OwnedBasicShapeData::new(BasicShapeData {+ kind: 7,+ v0: RetainedStyleValueData::none(),+ v1: RetainedStyleValueData::none(),+ v2: RetainedStyleValueData::none(),+ v3: RetainedStyleValueData::none(),+ v4: RetainedStyleValueData::none(),+ fill_rule,+ points: RetainedShapePointList::from_retained_points(points),+ path: CssPath::none(),+ commands: ShapeCommands::new(commands),+ }),+ })+}+fn shape_box(value: &ComponentValue) -> Option<StyleValueData> {let parsed_keyword = keyword_from_ascii_case_insensitive(value.ident()?)?;["content-box", "padding-box", "border-box", "margin-box"]@@ -1753,6 +2052,7 @@ mod tests {("ellipse(10px 20% at center)", 4),("polygon(evenodd, 0 0, 100% 0, 50% 100%)", 5),("path(evenodd, \"M 0 0 L 10 10\")", 6),+ ("shape(from 0 0, line to right bottom, close)", 7),] {let ParseOutcome::Parsed(value) = parse_geometry(property_id::CLIP_PATH, source) else {panic!("basic shape should parse: {source}");@@ -1760,7 +2060,7 @@ mod tests {assert!(matches!(&*value, StyleValueData::BasicShape { shape } if shape.as_ref().kind == expected_kind));}assert!(matches!(- parse_geometry(property_id::CLIP_PATH, "shape(from 0 0, close)"),+ parse_geometry(property_id::CLIP_PATH, "shape(from 0 0)"),ParseOutcome::Invalid));}diff --git a/Libraries/LibWeb/Rust/src/css/serialize.rs b/Libraries/LibWeb/Rust/src/css/serialize.rsindex d0da7008521..43e47a968cc 100644--- a/Libraries/LibWeb/Rust/src/css/serialize.rs+++ b/Libraries/LibWeb/Rust/src/css/serialize.rs@@ -1659,8 +1659,9 @@ pub(crate) fn serialize_style_value(sink: &mut TextSink, value: &StyleValueData,fill_rule,points,path,+ commands,} = shape.as_ref();- // BasicShape kinds: inset 0, xywh 1, rect 2, circle 3, ellipse 4, polygon 5, path 6;+ // BasicShape kinds: inset 0, xywh 1, rect 2, circle 3, ellipse 4, polygon 5, path 6, shape 7;// fill rules follow Gfx::WindingRule (Nonzero 0, EvenOdd 1).let round_clause = |sink: &mut TextSink, radius: &crate::css::style_value::RetainedStyleValueData| {let mut radius_sink = TextSink::new();@@ -1730,6 +1731,7 @@ pub(crate) fn serialize_style_value(sink: &mut TextSink, value: &StyleValueData,}sink.push_ascii(")");}+ 7 => serialize_shape_function(sink, *fill_rule, points.as_slice(), commands.as_slice(), mode),_ => {sink.push_ascii("path(");if !(mode.is_resolved() && *fill_rule == 0) {@@ -3240,6 +3242,104 @@ pub unsafe extern "C" fn rust_style_value_serialize(value: *const c_void, mode:sink_into_raw(sink)}+// https://drafts.csswg.org/css-shapes-1/#shape-function+fn serialize_shape_function(+ sink: &mut TextSink,+ fill_rule: u8,+ points: &[crate::css::style_value::RetainedShapePoint],+ commands: &[crate::css::style_value::ShapeCommand],+ mode: SerializationMode,+) {+ use crate::css::style_value::{ShapeCommandKind, ShapeControlPointAnchor};+ let push_point = |sink: &mut TextSink, point: &crate::css::style_value::RetainedShapePoint| {+ let [x, y] = point.values();+ serialize_style_value(sink, x.data(), mode);+ sink.push_ascii(" ");+ serialize_style_value(sink, y.data(), mode);+ };+ sink.push_ascii("shape(");+ if fill_rule == 1 {+ sink.push_ascii("evenodd ");+ }+ let mut points = points.iter();+ for (index, command) in commands.iter().enumerate() {+ if index > 0 {+ sink.push_ascii(", ");+ }+ let to_or_by = if command.relative { "by " } else { "to " };+ match command.kind {+ ShapeCommandKind::From => {+ sink.push_ascii("from ");+ push_point(sink, points.next().unwrap());+ }+ ShapeCommandKind::Close => sink.push_ascii("close"),+ ShapeCommandKind::Move | ShapeCommandKind::Line => {+ sink.push_ascii(if command.kind == ShapeCommandKind::Move {+ "move "+ } else {+ "line "+ });+ sink.push_ascii(to_or_by);+ push_point(sink, points.next().unwrap());+ }+ ShapeCommandKind::HorizontalLine | ShapeCommandKind::VerticalLine => {+ let horizontal = command.kind == ShapeCommandKind::HorizontalLine;+ sink.push_ascii(if horizontal { "hline " } else { "vline " });+ sink.push_ascii(to_or_by);+ let [x, y] = points.next().unwrap().values();+ serialize_style_value(sink, if horizontal { x.data() } else { y.data() }, mode);+ }+ ShapeCommandKind::Curve | ShapeCommandKind::Smooth => {+ sink.push_ascii(if command.kind == ShapeCommandKind::Curve {+ "curve "+ } else {+ "smooth "+ });+ sink.push_ascii(to_or_by);+ push_point(sink, points.next().unwrap());+ for control_point in 0..usize::from(command.control_point_count) {+ sink.push_ascii(if control_point == 0 { " with " } else { " / " });+ push_point(sink, points.next().unwrap());+ // A control point is relative to the start of a relative command, and to the origin of an+ // absolute one, unless it says otherwise.+ match command.control_points[control_point] {+ ShapeControlPointAnchor::Start if !command.relative => sink.push_ascii(" from start"),+ ShapeControlPointAnchor::End => sink.push_ascii(" from end"),+ ShapeControlPointAnchor::Origin if command.relative => sink.push_ascii(" from origin"),+ ShapeControlPointAnchor::Start | ShapeControlPointAnchor::Origin => {}+ }+ }+ }+ ShapeCommandKind::Arc => {+ sink.push_ascii("arc ");+ sink.push_ascii(to_or_by);+ push_point(sink, points.next().unwrap());+ sink.push_ascii(" of ");+ let radii = points.next().unwrap();+ if command.arc_has_one_radius {+ serialize_style_value(sink, radii.values()[0].data(), mode);+ } else {+ push_point(sink, radii);+ }+ if command.arc_clockwise {+ sink.push_ascii(" cw");+ }+ if command.arc_large {+ sink.push_ascii(" large");+ }+ let rotation = points.next().unwrap();+ let rotation_is_zero =+ matches!(rotation.values()[0].data(), StyleValueData::Angle { value, .. } if *value == 0.0);+ if command.arc_has_rotation && !rotation_is_zero {+ sink.push_ascii(" rotate ");+ serialize_style_value(sink, rotation.values()[0].data(), mode);+ }+ }+ }+ }+ sink.push_ascii(")");+}+#[cfg(test)]mod tests {use super::*;diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rsindex 6833174d841..4ec5f039573 100644--- a/Libraries/LibWeb/Rust/src/css/style_value.rs+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs@@ -1587,6 +1587,99 @@ pub struct BasicShapeData {pub(crate) v4: RetainedStyleValueData,pub(crate) points: RetainedShapePointList,pub(crate) path: crate::css::css_path::CssPath,+ /// The commands of a shape(), whose coordinates are `points` in order.+ pub(crate) commands: ShapeCommands,+}++/// https://drafts.csswg.org/css-shapes-1/#shape-function+/// One command of a shape(). Its points, in order, are its end point, then its control points, or its arc's+/// radii and rotation. Each point holds two length-percentages, the two edges of a position, or a keyword.+#[repr(C)]+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct ShapeCommand {+ pub(crate) kind: ShapeCommandKind,+ /// Whether the end point is given with `by`, relative to the command's starting point.+ pub(crate) relative: bool,+ /// What each control point is relative to.+ pub(crate) control_points: [ShapeControlPointAnchor; 2],+ pub(crate) control_point_count: u8,+ /// Whether an arc's single radius applies to both axes.+ pub(crate) arc_has_one_radius: bool,+ pub(crate) arc_clockwise: bool,+ pub(crate) arc_large: bool,+ /// Whether an arc's rotation was given. Arcs hold their rotation angle as a third point either way.+ pub(crate) arc_has_rotation: bool,+}++#[repr(u8)]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum ShapeCommandKind {+ From,+ Move,+ Line,+ HorizontalLine,+ VerticalLine,+ Curve,+ Smooth,+ Arc,+ Close,+}++/// What a shape() control point is relative to: the command's start or end point, or the reference box.+#[repr(u8)]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum ShapeControlPointAnchor {+ Start,+ End,+ Origin,+}++impl ShapeCommand {+ pub(crate) fn new(kind: ShapeCommandKind, relative: bool) -> Self {+ Self {+ kind,+ relative,+ control_points: [ShapeControlPointAnchor::Start; 2],+ control_point_count: 0,+ arc_has_one_radius: false,+ arc_clockwise: false,+ arc_large: false,+ arc_has_rotation: false,+ }+ }+}++/// The commands of a shape().+#[repr(C)]+pub struct ShapeCommands {+ pointer: *mut ShapeCommand,+ length: usize,+}++retained_list!(ShapeCommands, ShapeCommand, native);+retained_list_as_slice!(ShapeCommands, ShapeCommand);+retained_list_from_vec!(ShapeCommands, ShapeCommand);+retained_list_send_sync!(ShapeCommands, ShapeCommand);++impl ShapeCommands {+ pub(crate) fn new(commands: Vec<ShapeCommand>) -> Self {+ Self::from_retained_elements(commands)+ }+}++impl Default for ShapeCommands {+ fn default() -> Self {+ Self {+ pointer: std::ptr::null_mut(),+ length: 0,+ }+ }+}++impl PartialEq for ShapeCommands {+ fn eq(&self, other: &Self) -> bool {+ self.as_slice() == other.as_slice()+ }}/// A Rust-owned shape allocation with an explicit pointer layout for C++ bindings.@@ -2312,8 +2405,10 @@ impl StyleValueData {fill_rule,points: _,path,+ commands,} = shape.as_ref();hasher.write_u8(*kind);+ hasher.write_usize(commands.as_slice().len());write_value(hasher, v0);write_value(hasher, v1);write_value(hasher, v2);diff --git a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rsindex b6da95e1845..32ab63c63e6 100644--- a/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs+++ b/Libraries/LibWeb/Rust/src/painting/visual_context/basic_shapes.rs@@ -22,6 +22,7 @@ mod basic_shape_kind {pub const ELLIPSE: u8 = 4;pub const POLYGON: u8 = 5;pub const PATH: u8 = 6;+ pub const SHAPE: u8 = 7;}mod radial_extent {@@ -412,6 +413,138 @@ fn polygon_to_path(points: &crate::css::style_value::RetainedShapePointList, refpath.build()}+/// One coordinate of a shape() point: a length-percentage, or a position edge holding one.+fn shape_coordinate(value: &RetainedStyleValueData, basis: CssPixels) -> f32 {+ let value = match value.data() {+ StyleValueData::Edge { offset, .. } => offset.data(),+ value => value,+ };+ LengthPercentageRef::over(value).to_px(basis).to_float()+}++// https://drafts.csswg.org/css-shapes-1/#shape-function+// The commands used by shape() are dynamically turned into path segments when it is used for rendering.+pub(crate) fn shape_to_path(+ points: &[crate::css::style_value::RetainedShapePoint],+ commands: &[crate::css::style_value::ShapeCommand],+ reference_box: CssPixelRect,+) -> OwnedPath {+ use crate::css::style_value::{ShapeCommandKind, ShapeControlPointAnchor};+ let (width, height) = (reference_box.width, reference_box.height);+ let resolve = |point: &crate::css::style_value::RetainedShapePoint| {+ let [x, y] = point.values();+ (shape_coordinate(x, width), shape_coordinate(y, height))+ };+ let mut path = PathBuilder::new();+ let mut points = points.iter();+ let mut current = (0.0f32, 0.0f32);+ let mut subpath_start = current;+ // The second control point of the previous command, if it was a curve, for smooth commands to reflect.+ let mut previous_control_point: Option<(f32, f32)> = None;+ for command in commands {+ let mut control_point = None;+ let start = current;+ let end_point = |offset: (f32, f32)| {+ if command.relative {+ (start.0 + offset.0, start.1 + offset.1)+ } else {+ offset+ }+ };+ match command.kind {+ ShapeCommandKind::From | ShapeCommandKind::Move => {+ current = end_point(resolve(points.next().unwrap()));+ subpath_start = current;+ path.move_to(current.0, current.1);+ }+ ShapeCommandKind::Line => {+ current = end_point(resolve(points.next().unwrap()));+ path.line_to(current.0, current.1);+ }+ ShapeCommandKind::HorizontalLine => {+ let (x, _) = resolve(points.next().unwrap());+ current = if command.relative {+ (start.0 + x, start.1)+ } else {+ (x, start.1)+ };+ path.line_to(current.0, current.1);+ }+ ShapeCommandKind::VerticalLine => {+ let (_, y) = resolve(points.next().unwrap());+ current = if command.relative {+ (start.0, start.1 + y)+ } else {+ (start.0, y)+ };+ path.line_to(current.0, current.1);+ }+ ShapeCommandKind::Curve | ShapeCommandKind::Smooth => {+ let end = end_point(resolve(points.next().unwrap()));+ let mut control_points = Vec::with_capacity(2);+ for anchor in &command.control_points[..usize::from(command.control_point_count)] {+ let offset = resolve(points.next().unwrap());+ control_points.push(match anchor {+ ShapeControlPointAnchor::Start => (start.0 + offset.0, start.1 + offset.1),+ ShapeControlPointAnchor::End => (end.0 + offset.0, end.1 + offset.1),+ ShapeControlPointAnchor::Origin => offset,+ });+ }+ if command.kind == ShapeCommandKind::Smooth {+ // A smooth command's first control point is the reflection of the previous curve's second+ // control point around the starting point, or the starting point itself.+ let reflected = previous_control_point.map_or(start, |previous| {+ (2.0 * start.0 - previous.0, 2.0 * start.1 - previous.1)+ });+ control_points.insert(0, reflected);+ }+ match control_points[..] {+ [only] => path.quadratic_bezier_curve_to(only.0, only.1, end.0, end.1),+ [first, second] => path.cubic_bezier_curve_to(first.0, first.1, second.0, second.1, end.0, end.1),+ _ => unreachable!("a curve has one or two control points"),+ }+ control_point = control_points.last().copied();+ current = end;+ }+ ShapeCommandKind::Arc => {+ let end = end_point(resolve(points.next().unwrap()));+ let radii = points.next().unwrap();+ let (radius_x, radius_y) = if command.arc_has_one_radius {+ // A single radius resolves percentages against the direction-agnostic size of the reference+ // box.+ let [radius, _] = radii.values();+ let agnostic_size = CssPixels::nearest_value_for(+ (width.to_double().powi(2) + height.to_double().powi(2)).sqrt() / std::f64::consts::SQRT_2,+ );+ let radius = shape_coordinate(radius, agnostic_size);+ (radius, radius)+ } else {+ resolve(radii)+ };+ let rotation_degrees =+ crate::css::table_group_builder::angle_degrees(points.next().unwrap().values()[0].data())+ .unwrap_or(0.0);+ path.elliptical_arc_to(+ end.0,+ end.1,+ radius_x.abs(),+ radius_y.abs(),+ rotation_degrees.to_radians() as f32,+ command.arc_large,+ command.arc_clockwise,+ );+ current = end;+ }+ ShapeCommandKind::Close => {+ path.close();+ current = subpath_start;+ }+ }+ previous_control_point = control_point;+ }+ path.build()+}+pub(crate) fn compute_basic_shape_clip_path_data(layout_arena: &impl PaintRead,slot: NodeSlotId,@@ -430,6 +563,7 @@ pub(crate) fn compute_basic_shape_clip_path_data(fill_rule,points,path,+ commands,} = clip_path.basic_shape()?;// FIXME: Support other geometry boxes. See: https://drafts.fxtf.org/css-masking/#typedef-geometry-box@@ -446,10 +580,13 @@ pub(crate) fn compute_basic_shape_clip_path_data(basic_shape_kind::ELLIPSE => ellipse_to_path(v0, v1, reference_box),basic_shape_kind::POLYGON => polygon_to_path(points, reference_box),basic_shape_kind::PATH => path.to_gfx_path(),+ basic_shape_kind::SHAPE => shape_to_path(points.as_slice(), commands.as_slice(), reference_box),_ => unreachable!("computed clip-path basic shape holds an unlowered kind"),};let resolved_fill_rule = match *kind {- basic_shape_kind::POLYGON | basic_shape_kind::PATH => WindingRule::from_raw(i32::from(*fill_rule)),+ basic_shape_kind::POLYGON | basic_shape_kind::PATH | basic_shape_kind::SHAPE => {+ WindingRule::from_raw(i32::from(*fill_rule))+ }_ => WindingRule::Nonzero,};diff --git a/Tests/LibWeb/Ref/expected/shape-arc-rotation-calc-ref.html b/Tests/LibWeb/Ref/expected/shape-arc-rotation-calc-ref.htmlnew file mode 100644index 00000000000..59ca6331e33--- /dev/null+++ b/Tests/LibWeb/Ref/expected/shape-arc-rotation-calc-ref.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<style>+div {+ width: 200px;+ height: 200px;+ background: green;+ clip-path: shape(from 20px 100px, arc to 180px 100px of 100px 30px rotate 45deg, close);+}+</style>+<div></div>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-003-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-003-ref.htmlnew file mode 100644index 00000000000..8d6173464c3--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-003-ref.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<html>+<head>+ <title>Reference of CSS Masking: Test clip-path property and shape function with nonzero fill</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+</head>+<style>+ #ref {+ width: 100px;+ height: 100px;+ background-color: green;+ clip-path: path(nonzero, "M 10 10 Q 40 0 60 20 T 90 0 c 10 40 20 20 -20 60 s -10 70 -40 -10");+ }+</style>+<body>+ <div id="ref"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-004-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-004-ref.htmlnew file mode 100644index 00000000000..b74e6abdd9e--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-004-ref.html@@ -0,0 +1,18 @@+<!DOCTYPE html>+<html>+<head>+ <title>Reference of CSS Masking: Test clip-path property and shape function with nonzero fill</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+</head>+<style>+ #ref {+ width: 100px;+ height: 100px;+ background-color: green;+ clip-path: path(nonzero, "M 20 20 A 25 12 0 0 1 80 20 a 33 33 120 1 1 -40 50 A 20 25 0 0 0 20 20");+ }+</style>+<body>+ <div id="ref"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-arc-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-arc-ref.htmlnew file mode 100644index 00000000000..9cbe55de210--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-arc-ref.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Masking: Test clip-path property and shape function with single-value arc radius</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+</head>+<style>+#shape {+ /* 500/sqrt(2) ~= 353 */+ width: 353px;+ height: 353px;+ background: green;+ clip-path: shape(+ from 0px 100px,+ arc to 20px 100px of 10% large cw,+ arc to 100px 20px of 5% small,+ arc to 0 100px of calc(10px + 15%)+ rotate 30deg);+}+</style>++<body>+ <div id="shape"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/green-100x100.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/green-100x100.htmlnew file mode 100644index 00000000000..f718ea6abfb--- /dev/null+++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-masking/clip-path/reference/green-100x100.html@@ -0,0 +1,2 @@+<!DOCTYPE html>+<div style="width: 100px; height: 100px; background-color: green"></div>diff --git a/Tests/LibWeb/Ref/input/shape-arc-rotation-calc.html b/Tests/LibWeb/Ref/input/shape-arc-rotation-calc.htmlnew file mode 100644index 00000000000..066b3435aa4--- /dev/null+++ b/Tests/LibWeb/Ref/input/shape-arc-rotation-calc.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<link rel="match" href="../expected/shape-arc-rotation-calc-ref.html">+<style>+div {+ width: 200px;+ height: 200px;+ background: green;+ clip-path: shape(from 20px 100px, arc to 180px 100px of 100px 30px rotate calc(30deg + 15deg), close);+}+</style>+<!-- An arc's rotation given as a calculation rotates the arc as the plain angle does. -->+<div></div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-003.htmlnew file mode 100644index 00000000000..3ed676202ff--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-003.html@@ -0,0 +1,25 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Masking: Test clip-path property and shape function with nonzero fill</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-003-ref.html">+ <meta name="assert" content="The clip-path property takes the basic shape+ 'shape()' for clipping. Test curves.">+</head>+<style>+ #rect {+ width: 100px;+ height: 100px;+ background-color: green;+ clip-path: shape(nonzero from 10px 10px,+ curve to 60px 20% with 40px 0,+ smooth to 90px 0,+ curve by -20px 60% with 10% 40px / 20% 20px,+ smooth by -40% -10px with -10px 70px);+ }+</style>+<body>+ <div id="rect"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-004.htmlnew file mode 100644index 00000000000..3ee98ee85f2--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-004.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Masking: Test clip-path property and shape function with nonzero fill</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-004-ref.html">+ <meta name="assert" content="The clip-path property takes the basic shape+ 'shape()' for clipping. Test arcs.">+</head>+<style>+ #rect {+ width: 100px;+ height: 100px;+ background-color: green;+ clip-path: shape(nonzero from 20px 20px,+ arc to 80px 20px of 25px 12px cw,+ arc by -40px 50px of 33px cw large rotate 120deg,+ arc to 20% 20% of 20px 25px ccw);+ }+</style>+<body>+ <div id="rect"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-011.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-011.htmlnew file mode 100644index 00000000000..5efe9078c5a--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-011.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Masking: Test clip-path property and shape function with single-value arc radius</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-masking/clip-path/reference/clip-path-shape-arc-ref.html">+ <meta name="assert" content="When providing one radius value with percentage, the percentage should be relative to the diagonal.">+ <meta name="fuzzy" content="maxDifference=0-127;totalPixels=0-128">+</head>+<style>+#shape {+ width: 400px;+ height: 300px;+ background: green;+ clip-path: shape(+ from 0px 100px,+ arc to 20px 100px of 10% large cw,+ arc to 100px 20px of 5% small,+ arc to 0 100px of calc(10px + 15%)+ rotate 30deg);+}+</style>++<body>+ <div id="shape"></div>+</body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.htmlnew file mode 100644index 00000000000..f34fe0da5f3--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-masking/clip-path/clip-path-shape-hline-vline-keywords.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<html>+<head>+ <title>CSS Masking: Test clip-path property and shape function hline/vline keywords</title>+ <link rel="help" href="https://drafts.csswg.org/css-shapes-2/#funcdef-shape">+ <link rel="match" href="../../../../../expected/wpt-import/css/css-masking/clip-path/reference/green-100x100.html">+ <meta name="assert" content="Test that center and edge keywords work in hline and vline">+</head>+<style>+ #shape {+ width: 200px;+ height: 200px;+ background-color: green;+ clip-path: shape(from top left,+ hline to center,+ vline to center,+ hline to left,+ close);+ }+</style>+<body>+ <div id="shape"></div>+</body>+</html>diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-computed.txtindex 0f24917d49a..c29e658e5e8 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-computed.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-computed.txt@@ -2,39 +2,39 @@ Harness status: OKFound 35 tests-35 Fail-Fail Property clip-path value 'shape(from 20px 40px, line to 20px 30px)'-Fail Property clip-path value 'shape(from 20px 40px, line to 20px 30px )'-Fail Property clip-path value 'shape(from 0 0, line to 100% 100%)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, line by 20px 30px)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to 100px)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline by 100%)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to 100px)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline by 100%)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to left, hline to center, hline to right)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to x-start, vline to y-start)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to top, vline to center, vline to bottom)'-Fail Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to y-start, vline to y-end)'-Fail Property clip-path value 'shape(from 20px 40px, curve by 20px 20px with 10px 30px)'-Fail Property clip-path value 'shape(from 20px 40px, curve by 20px 20px with 10px 30px / 12px 32px)'-Fail Property clip-path value 'shape(from center, curve to center bottom with top right / bottom right)'-Fail Property clip-path value 'shape(from center, curve by 20px 20px with 10px 30px from end / 12px 32px from start)'-Fail Property clip-path value 'shape(from center right, curve by 20px 20px with 10px 30px from origin / 12px 32px from origin)'-Fail Property clip-path value 'shape(from 20px 40px, curve to top right with 10px 30px from origin / 12px 32px from origin)'-Fail Property clip-path value 'shape(from 20px 40px, smooth by 20px 20px)'-Fail Property clip-path value 'shape(from 20px 40px, smooth by 20px 20px with 12px 32px)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10%)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 0)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 0)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% rotate 0deg)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20%)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of -10% -20% large)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% rotate 1deg)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 12deg)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 3.14159265rad)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large rotate 12deg)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw large)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large cw)'-Fail Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% rotate 12deg large)'\ No newline at end of file+35 Pass+Pass Property clip-path value 'shape(from 20px 40px, line to 20px 30px)'+Pass Property clip-path value 'shape(from 20px 40px, line to 20px 30px )'+Pass Property clip-path value 'shape(from 0 0, line to 100% 100%)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, line by 20px 30px)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to 100px)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline by 100%)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to 100px)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline by 100%)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to left, hline to center, hline to right)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, hline to x-start, vline to y-start)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to top, vline to center, vline to bottom)'+Pass Property clip-path value 'shape(from 20px 40px, move to 20px 30px, vline to y-start, vline to y-end)'+Pass Property clip-path value 'shape(from 20px 40px, curve by 20px 20px with 10px 30px)'+Pass Property clip-path value 'shape(from 20px 40px, curve by 20px 20px with 10px 30px / 12px 32px)'+Pass Property clip-path value 'shape(from center, curve to center bottom with top right / bottom right)'+Pass Property clip-path value 'shape(from center, curve by 20px 20px with 10px 30px from end / 12px 32px from start)'+Pass Property clip-path value 'shape(from center right, curve by 20px 20px with 10px 30px from origin / 12px 32px from origin)'+Pass Property clip-path value 'shape(from 20px 40px, curve to top right with 10px 30px from origin / 12px 32px from origin)'+Pass Property clip-path value 'shape(from 20px 40px, smooth by 20px 20px)'+Pass Property clip-path value 'shape(from 20px 40px, smooth by 20px 20px with 12px 32px)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10%)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 0)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 0)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% rotate 0deg)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20%)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of -10% -20% large)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% rotate 1deg)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 12deg)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 3.14159265rad)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large rotate 12deg)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% cw large)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% large cw)'+Pass Property clip-path value 'shape(from 20px 40px, arc by 20px 20px of 10% 20% rotate 12deg large)'\ No newline at end of filediff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-valid.txtindex 53e29cc649b..2304f36521f 100644--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-valid.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-shapes/shape-functions/shape-function-valid.txt@@ -2,55 +2,55 @@ Harness status: OKFound 51 tests-51 Fail-Fail e.style['clip-path'] = "shape(from 20px 40px, line to 20px 30px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, line to 20px 30px )" should set the property value-Fail e.style['clip-path'] = "shape(from 0 0, line to 100% 100%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, line by 20px 30px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to 100px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline by 100%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to 100px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline by 100%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to left, hline to center, hline to right)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to x-start, vline to y-start)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to top, vline to center, vline to bottom)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to y-start, vline to y-end)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to 20px 20px with 10px 30px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to 20em 20pt with 10vw 30vh)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to 10% 20% with 10px 30px / 12px 32px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to top left with 10px 30px / 12px 32px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20% 40%, curve to center with center right / bottom center)" should set the property value-Fail e.style['clip-path'] = "shape(from bottom right, curve to left with center right / bottom center)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to bottom left with 10px 30px from end)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from start / 12px 32px from end)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from start/12px 32px from end)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from end / 12px 32px from origin)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from origin / 12px 32px from start)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px from origin)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px / 12px 32px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve by 20% 20em with 10px 30px from start / 12px 32px from end)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, curve by 20% 20em with 10.3% 30px from origin / 12pt 5.4% from start)" should set the property value-Fail e.style['clip-path'] = "shape(from top left, smooth to top right)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, smooth to center 20%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, smooth by 20px 20px)" should set the property value-Fail e.style['clip-path'] = "shape(from right bottom, smooth by 20px 20px with 12px 32px)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, smooth by 20pt 20px with 12px 32px from start)" should set the property value-Fail e.style['clip-path'] = "shape(from center 40px, smooth by 20% 20% with 12px 32px from end)" should set the property value-Fail e.style['clip-path'] = "shape(from center, smooth by 20px 20px with 12px 32px from origin)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc to top right of 10%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 0)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 0)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20% 20pt of 10% rotate 0deg)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20%)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of -10% -20% large)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% rotate 1deg)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 12deg)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10px 20px cw rotate 0.52rad)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large rotate 12deg)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw large)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large cw)" should set the property value-Fail e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% rotate 12deg large)" should set the property value\ No newline at end of file+51 Pass+Pass e.style['clip-path'] = "shape(from 20px 40px, line to 20px 30px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, line to 20px 30px )" should set the property value+Pass e.style['clip-path'] = "shape(from 0 0, line to 100% 100%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, line by 20px 30px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to 100px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline by 100%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to 100px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline by 100%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to left, hline to center, hline to right)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, hline to x-start, vline to y-start)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to top, vline to center, vline to bottom)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, move to 20px 30px, vline to y-start, vline to y-end)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to 20px 20px with 10px 30px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to 20em 20pt with 10vw 30vh)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to 10% 20% with 10px 30px / 12px 32px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to top left with 10px 30px / 12px 32px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20% 40%, curve to center with center right / bottom center)" should set the property value+Pass e.style['clip-path'] = "shape(from bottom right, curve to left with center right / bottom center)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to bottom left with 10px 30px from end)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from start / 12px 32px from end)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from start/12px 32px from end)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from end / 12px 32px from origin)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve to right center with 10px 30px from origin / 12px 32px from start)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px from origin)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve by 20px 20px with 10px 30px / 12px 32px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve by 20% 20em with 10px 30px from start / 12px 32px from end)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, curve by 20% 20em with 10.3% 30px from origin / 12pt 5.4% from start)" should set the property value+Pass e.style['clip-path'] = "shape(from top left, smooth to top right)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, smooth to center 20%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, smooth by 20px 20px)" should set the property value+Pass e.style['clip-path'] = "shape(from right bottom, smooth by 20px 20px with 12px 32px)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, smooth by 20pt 20px with 12px 32px from start)" should set the property value+Pass e.style['clip-path'] = "shape(from center 40px, smooth by 20% 20% with 12px 32px from end)" should set the property value+Pass e.style['clip-path'] = "shape(from center, smooth by 20px 20px with 12px 32px from origin)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc to top right of 10%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 0)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 0)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20% 20pt of 10% rotate 0deg)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20%)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of -10% -20% large)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% rotate 1deg)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw rotate 12deg)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10px 20px cw rotate 0.52rad)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large rotate 12deg)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% cw large)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% large cw)" should set the property value+Pass e.style['clip-path'] = "shape(from 20px 40px, arc by 20px 20px of 10% 20% rotate 12deg large)" should set the property value\ No newline at end of file