diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index 811c71a4c6c..4de39b32d75 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -1911,6 +1911,12 @@ ScrollbarWidth ComputedProperties::scrollbar_width() const return keyword_to_scrollbar_width(value.to_keyword()).release_value(); } +ShapeRendering ComputedProperties::shape_rendering() const +{ + auto const& value = property(PropertyID::ShapeRendering); + return keyword_to_shape_rendering(value.to_keyword()).release_value(); +} + WillChange ComputedProperties::will_change() const { auto const& value = property(PropertyID::WillChange); diff --git a/Libraries/LibWeb/CSS/ComputedProperties.h b/Libraries/LibWeb/CSS/ComputedProperties.h index 11fc8b57a3f..196143cfef9 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.h +++ b/Libraries/LibWeb/CSS/ComputedProperties.h @@ -195,6 +195,7 @@ public: FillRule fill_rule() const; ClipRule clip_rule() const; float flood_opacity() const; + CSS::ShapeRendering shape_rendering() const; WillChange will_change() const; diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h index c5be01a87f4..72d5321baf0 100644 --- a/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Libraries/LibWeb/CSS/ComputedValues.h @@ -258,6 +258,7 @@ public: }; } static CSS::ScrollbarWidth scrollbar_width() { return CSS::ScrollbarWidth::Auto; } + static CSS::ShapeRendering shape_rendering() { return CSS::ShapeRendering::Auto; } static WillChange will_change() { return WillChange::make_auto(); } }; @@ -539,6 +540,7 @@ public: CSS::MixBlendMode mix_blend_mode() const { return m_noninherited.mix_blend_mode; } Optional view_transition_name() const { return m_noninherited.view_transition_name; } TouchActionData touch_action() const { return m_noninherited.touch_action; } + CSS::ShapeRendering shape_rendering() const { return m_noninherited.shape_rendering; } CSS::LengthBox const& inset() const { return m_noninherited.inset; } const CSS::LengthBox& margin() const { return m_noninherited.margin; } @@ -838,6 +840,8 @@ protected: Color flood_color { InitialValues::flood_color() }; float flood_opacity { InitialValues::flood_opacity() }; + + CSS::ShapeRendering shape_rendering { InitialValues::shape_rendering() }; } m_noninherited; }; @@ -1027,6 +1031,7 @@ public: void set_clip_rule(CSS::ClipRule value) { m_inherited.clip_rule = value; } void set_flood_color(Color value) { m_noninherited.flood_color = value; } void set_flood_opacity(float value) { m_noninherited.flood_opacity = value; } + void set_shape_rendering(CSS::ShapeRendering value) { m_noninherited.shape_rendering = value; } void set_cx(LengthPercentage cx) { m_noninherited.cx = move(cx); } void set_cy(LengthPercentage cy) { m_noninherited.cy = move(cy); } diff --git a/Libraries/LibWeb/CSS/Enums.json b/Libraries/LibWeb/CSS/Enums.json index 9aa65c89aa5..21e0d614342 100644 --- a/Libraries/LibWeb/CSS/Enums.json +++ b/Libraries/LibWeb/CSS/Enums.json @@ -632,6 +632,12 @@ "thin", "none" ], + "shape-rendering": [ + "auto", + "optimizespeed", + "crispedges", + "geometricprecision" + ], "stroke-linecap": [ "butt", "square", diff --git a/Libraries/LibWeb/CSS/Keywords.json b/Libraries/LibWeb/CSS/Keywords.json index 43ec9afe3b9..42a5fd79d1b 100644 --- a/Libraries/LibWeb/CSS/Keywords.json +++ b/Libraries/LibWeb/CSS/Keywords.json @@ -151,6 +151,7 @@ "copy", "cover", "crisp-edges", + "crispedges", "crop", "cross", "crosshair", diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json index b1a61dad32e..f9ff69606fa 100644 --- a/Libraries/LibWeb/CSS/Properties.json +++ b/Libraries/LibWeb/CSS/Properties.json @@ -3060,6 +3060,15 @@ "none" ] }, + "shape-rendering": { + "affects-layout": true, + "animation-type": "discrete", + "inherited": true, + "initial": "auto", + "valid-types": [ + "shape-rendering" + ] + }, "stop-color": { "affects-layout": false, "animation-type": "by-computed-value", diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index 30a74b0e349..9a7e9d9388b 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -913,6 +913,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style) computed_values.set_stroke_width(stroke_width.as_length().length()); else if (stroke_width.is_percentage()) computed_values.set_stroke_width(CSS::LengthPercentage { stroke_width.as_percentage().percentage() }); + computed_values.set_shape_rendering(computed_style.shape_rendering()); auto const& mask_image = computed_style.property(CSS::PropertyID::MaskImage); if (mask_image.is_url()) { @@ -1035,6 +1036,7 @@ void NodeWithStyle::apply_style(CSS::ComputedProperties const& computed_style) computed_values.set_mix_blend_mode(computed_style.mix_blend_mode()); computed_values.set_view_transition_name(computed_style.view_transition_name()); computed_values.set_contain(computed_style.contain()); + computed_values.set_shape_rendering(computed_values.shape_rendering()); computed_values.set_will_change(computed_style.will_change()); computed_values.set_caret_color(computed_style.caret_color(*this)); diff --git a/Libraries/LibWeb/SVG/SVGElement.cpp b/Libraries/LibWeb/SVG/SVGElement.cpp index 6de3b6bf811..bd584b86ce7 100644 --- a/Libraries/LibWeb/SVG/SVGElement.cpp +++ b/Libraries/LibWeb/SVG/SVGElement.cpp @@ -80,6 +80,7 @@ static ReadonlySpan attribute_style_properties() NamedPropertyID(CSS::PropertyID::R, { SVG::TagNames::circle }), NamedPropertyID(CSS::PropertyID::Rx, { SVG::TagNames::ellipse, SVG::TagNames::rect }), NamedPropertyID(CSS::PropertyID::Ry, { SVG::TagNames::ellipse, SVG::TagNames::rect }), + NamedPropertyID(CSS::PropertyID::ShapeRendering), NamedPropertyID(CSS::PropertyID::StopColor), NamedPropertyID(CSS::PropertyID::StopOpacity), NamedPropertyID(CSS::PropertyID::Stroke), diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt index 485084195b1..ae4ce63f441 100644 --- a/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt +++ b/Tests/LibWeb/Text/expected/css/CSSStyleDeclaration-has-indexed-property-getter.txt @@ -43,6 +43,7 @@ All properties associated with getComputedStyle(document.body): "math-style", "pointer-events", "quotes", + "shape-rendering", "stroke", "stroke-dasharray", "stroke-dashoffset", diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt index a08c9cfcec9..af6237ac200 100644 --- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt +++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt @@ -634,6 +634,8 @@ All supported properties and their default values exposed from CSSStylePropertie 'scrollbar-gutter': 'auto' 'scrollbarWidth': 'auto' 'scrollbar-width': 'auto' +'shapeRendering': 'auto' +'shape-rendering': 'auto' 'stopColor': 'rgb(0, 0, 0)' 'stop-color': 'rgb(0, 0, 0)' 'stopOpacity': '1' diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt index aedba5a6cbc..3bbea46c802 100644 --- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt +++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt @@ -41,6 +41,7 @@ math-shift: normal math-style: normal pointer-events: auto quotes: auto +shape-rendering: auto stroke: none stroke-dasharray: none stroke-dashoffset: 0 @@ -90,7 +91,7 @@ background-position-x: 0% background-position-y: 0% background-repeat: repeat background-size: auto -block-size: 1380px +block-size: 1395px border-block-end-color: rgb(0, 0, 0) border-block-end-style: none border-block-end-width: 0px @@ -166,7 +167,7 @@ grid-row-start: auto grid-template-areas: none grid-template-columns: none grid-template-rows: none -height: 2520px +height: 2535px inline-size: 784px inset-block-end: auto inset-block-start: auto diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt index 13536380301..805a803af23 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-cascade/all-prop-revert-layer.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 256 tests +Found 257 tests -249 Pass +250 Pass 7 Fail Pass accent-color Pass border-collapse @@ -45,6 +45,7 @@ Pass math-shift Pass math-style Pass pointer-events Pass quotes +Pass shape-rendering Pass stroke Pass stroke-dasharray Pass stroke-dashoffset diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/shorthand-values.txt b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/shorthand-values.txt index 0ccfa5c34a2..1f0465c77f7 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/cssom/shorthand-values.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/cssom/shorthand-values.txt @@ -2,15 +2,15 @@ Harness status: OK Found 20 tests -14 Pass -6 Fail +15 Pass +5 Fail Pass The serialization of border: 1px; border-top: 1px; should be canonical. Pass The serialization of border: 1px solid red; should be canonical. Pass The serialization of border: 1px red; should be canonical. Pass The serialization of border: red; should be canonical. Fail The serialization of border-top: 1px; border-right: 1px; border-bottom: 1px; border-left: 1px; border-image: none; should be canonical. Fail The serialization of border-top: 1px; border-right: 1px; border-bottom: 1px; border-left: 1px; should be canonical. -Fail The serialization of border-top: 1px; border-right: 2px; border-bottom: 3px; border-left: 4px; should be canonical. +Pass The serialization of border-top: 1px; border-right: 2px; border-bottom: 3px; border-left: 4px; should be canonical. Fail The serialization of border: 1px; border-top: 2px; should be canonical. Fail The serialization of border: 1px; border-top: 1px !important; should be canonical. Fail The serialization of border: 1px; border-top-color: red; should be canonical. diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-invalid.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-invalid.txt new file mode 100644 index 00000000000..c7141314e7e --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-invalid.txt @@ -0,0 +1,7 @@ +Harness status: OK + +Found 2 tests + +2 Pass +Pass e.style['shape-rendering'] = "optimizelegibility" should not set the property value +Pass e.style['shape-rendering'] = "auto optimizespeed" should not set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-valid.txt new file mode 100644 index 00000000000..0765009f20c --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/painting/parsing/shape-rendering-valid.txt @@ -0,0 +1,9 @@ +Harness status: OK + +Found 4 tests + +4 Pass +Pass e.style['shape-rendering'] = "auto" should set the property value +Pass e.style['shape-rendering'] = "optimizespeed" should set the property value +Pass e.style['shape-rendering'] = "crispedges" should set the property value +Pass e.style['shape-rendering'] = "geometricprecision" should set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-irrelevant.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-irrelevant.txt index c88e2d4a92d..c5f5cc3ba5a 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-irrelevant.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-irrelevant.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 46 tests +Found 47 tests -43 Pass +44 Pass 3 Fail Pass clip-path presentation attribute supported on an irrelevant element Pass clip-rule presentation attribute supported on an irrelevant element @@ -30,6 +30,7 @@ Pass mask presentation attribute supported on an irrelevant element Pass opacity presentation attribute supported on an irrelevant element Pass overflow presentation attribute supported on an irrelevant element Pass pointer-events presentation attribute supported on an irrelevant element +Pass shape-rendering presentation attribute supported on an irrelevant element Pass stop-color presentation attribute supported on an irrelevant element Pass stop-opacity presentation attribute supported on an irrelevant element Pass stroke presentation attribute supported on an irrelevant element diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-relevant.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-relevant.txt index f677f3653df..01c2c276dc8 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-relevant.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-relevant.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 56 tests +Found 57 tests -52 Pass +53 Pass 4 Fail Pass clip-path presentation attribute supported on a relevant element Pass clip-rule presentation attribute supported on a relevant element @@ -36,6 +36,7 @@ Pass pointer-events presentation attribute supported on a relevant element Pass r presentation attribute supported on a relevant element Pass rx presentation attribute supported on a relevant element Pass ry presentation attribute supported on a relevant element +Pass shape-rendering presentation attribute supported on a relevant element Pass stop-color presentation attribute supported on a relevant element Pass stop-opacity presentation attribute supported on a relevant element Pass stroke presentation attribute supported on a relevant element diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-unknown.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-unknown.txt index e85f90447a6..3bf0c173c4c 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-unknown.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/styling/presentation-attributes-unknown.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 46 tests +Found 47 tests -43 Pass +44 Pass 3 Fail Pass clip-path presentation attribute supported on an unknown SVG element Pass clip-rule presentation attribute supported on an unknown SVG element @@ -30,6 +30,7 @@ Pass mask presentation attribute supported on an unknown SVG element Pass opacity presentation attribute supported on an unknown SVG element Pass overflow presentation attribute supported on an unknown SVG element Pass pointer-events presentation attribute supported on an unknown SVG element +Pass shape-rendering presentation attribute supported on an unknown SVG element Pass stop-color presentation attribute supported on an unknown SVG element Pass stop-opacity presentation attribute supported on an unknown SVG element Pass stroke presentation attribute supported on an unknown SVG element diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-invalid.svg b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-invalid.svg new file mode 100644 index 00000000000..15c090707ae --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-invalid.svg @@ -0,0 +1,20 @@ + + + SVG Painting: parsing shape-rendering with invalid values + + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-valid.svg b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-valid.svg new file mode 100644 index 00000000000..8df53791da6 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/painting/parsing/shape-rendering-valid.svg @@ -0,0 +1,22 @@ + + + SVG Painting: parsing shape-rendering with valid values + + + + + + + + + +