diff --git a/Libraries/LibWeb/SVG/SVGEllipseElement.cpp b/Libraries/LibWeb/SVG/SVGEllipseElement.cpp index 4da7396588d28..cf37ca90f04b6 100644 --- a/Libraries/LibWeb/SVG/SVGEllipseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGEllipseElement.cpp @@ -19,27 +19,29 @@ SVGEllipseElement::SVGEllipseElement(DOM::Document& document, DOM::QualifiedName { } -void SVGEllipseElement::attribute_changed(Utf16FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) -{ - Base::attribute_changed(name, old_value, value, namespace_); - - if (name == SVG::AttributeNames::cx) { - m_center_x = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::cy) { - m_center_y = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::rx) { - m_radius_x = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::ry) { - m_radius_y = AttributeParser::parse_number_percentage(value.value_or({})); - } -} - Gfx::Path SVGEllipseElement::get_path(CSSPixelSize viewport_size) { - float rx = m_radius_x.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()); - float ry = m_radius_y.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()); - float cx = m_center_x.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()); - float cy = m_center_y.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()); + auto const& computed_values = this->computed_values(); + + auto computed_rx = computed_values->rx(); + auto computed_ry = computed_values->ry(); + + float rx = computed_rx.to_px_or_zero(viewport_size.width()).to_float(); + float ry = computed_ry.to_px_or_zero(viewport_size.height()).to_float(); + + // https://svgwg.org/svg2-draft/geometry.html#RxProperty + // When the computed value of ‘rx’ is auto, the used radius is equal to the absolute length used for ry, creating a + // circular arc. If both ‘rx’ and ‘ry’ have a computed value of auto, the used value is 0. + if (computed_rx.is_auto()) + rx = computed_ry.to_px_or_zero(viewport_size.height()).to_float(); + + // When the computed value of ‘ry’ is auto, the used radius is equal to the absolute length used for rx, creating a + // circular arc. If both ‘rx’ and ‘ry’ have a computed value of auto, the used value is 0. + if (computed_ry.is_auto()) + ry = computed_rx.to_px_or_zero(viewport_size.width()).to_float(); + + float cx = computed_values->cx().to_px(viewport_size.width()).to_float(); + float cy = computed_values->cy().to_px(viewport_size.height()).to_float(); Gfx::Path path; // A negative radius is invalid. If only one radius is invalid, SVG uses diff --git a/Libraries/LibWeb/SVG/SVGEllipseElement.h b/Libraries/LibWeb/SVG/SVGEllipseElement.h index 830acc873f482..d4f19b895c715 100644 --- a/Libraries/LibWeb/SVG/SVGEllipseElement.h +++ b/Libraries/LibWeb/SVG/SVGEllipseElement.h @@ -19,8 +19,6 @@ class SVGEllipseElement final : public SVGGeometryElement { public: virtual ~SVGEllipseElement() override = default; - virtual void attribute_changed(Utf16FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; - virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; // AD-HOC: The spec states that the cx, cy, rx and ry IDL attributes reflect the respective computed values and their @@ -41,11 +39,6 @@ class SVGEllipseElement final : public SVGGeometryElement { private: SVGEllipseElement(DOM::Document&, DOM::QualifiedName); - - Optional m_center_x; - Optional m_center_y; - Optional m_radius_x; - Optional m_radius_y; }; } diff --git a/Libraries/LibWeb/SVG/SVGImageElement.cpp b/Libraries/LibWeb/SVG/SVGImageElement.cpp index b98b112c85808..3fcd65f32e9cb 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.cpp +++ b/Libraries/LibWeb/SVG/SVGImageElement.cpp @@ -7,6 +7,7 @@ #include "SVGImageElement.h" #include #include +#include #include #include #include @@ -55,15 +56,7 @@ void SVGImageElement::attribute_changed(Utf16FlyString const& name, Optional width; - if (m_width.has_value()) - width = m_width->resolve_relative_to(viewport_size.width().to_float()); + auto computed_values = this->computed_values(); - Optional height; - if (m_height.has_value()) - height = m_height->resolve_relative_to(viewport_size.height().to_float()); + // https://w3c.github.io/svgwg/svg2-draft/embedded.html#Placement + // Computation of automatically-sized values follows the Default Sizing Algorithm defined for replaced elements in + // CSS layout [css-images-3]. In particular, when the referenced resource does not have an intrinsic size (such as + // image types with no defined dimensions), it is assumed to have a width of 300px and a height of 150px. + auto specified_width = computed_values->width().is_length_percentage() ? computed_values->width().to_px(viewport_size.width()) : Optional {}; + auto specified_height = computed_values->height().is_length_percentage() ? computed_values->height().to_px(viewport_size.height()) : Optional {}; - if (!height.has_value() && width.has_value() && intrinsic_aspect_ratio().has_value()) - height = width.value() / intrinsic_aspect_ratio().value().to_float(); + CSS::SizeWithAspectRatio intrinsic_size_with_aspect_ratio { this->intrinsic_width(), this->intrinsic_height(), this->intrinsic_aspect_ratio() }; - if (!width.has_value() && height.has_value() && intrinsic_aspect_ratio().has_value()) - width = height.value() * intrinsic_aspect_ratio().value().to_float(); + CSSPixelSize default_size {}; - if (!width.has_value() && intrinsic_width().has_value()) - width = intrinsic_width()->to_float(); + if (decoded_image_data()) + default_size = CSSPixelSize { 300, 150 }; - if (!height.has_value() && intrinsic_height().has_value()) - height = intrinsic_height()->to_float(); + auto sizing = CSS::run_default_sizing_algorithm(specified_width, specified_height, intrinsic_size_with_aspect_ratio, default_size); return { - m_x.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()), - m_y.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()), - width.value_or(0.0f), - height.value_or(0.0f), + computed_values->x().to_px(viewport_size.width()).to_float(), + computed_values->y().to_px(viewport_size.height()).to_float(), + sizing.width().to_float(), + sizing.height().to_float() }; } diff --git a/Libraries/LibWeb/SVG/SVGImageElement.h b/Libraries/LibWeb/SVG/SVGImageElement.h index 4956d7de31839..e7ffd7df45cac 100644 --- a/Libraries/LibWeb/SVG/SVGImageElement.h +++ b/Libraries/LibWeb/SVG/SVGImageElement.h @@ -67,11 +67,6 @@ class SVGImageElement final virtual RefPtr create_layout_node(NonnullRefPtr) override; virtual void decoded_image_data_did_update() override { set_needs_repaint(); } - Optional m_x; - Optional m_y; - Optional m_width; - Optional m_height; - Optional m_href; GC::Ptr m_resource_request; diff --git a/Libraries/LibWeb/SVG/SVGRectElement.cpp b/Libraries/LibWeb/SVG/SVGRectElement.cpp index 635ae61d2afcc..8dda19225965d 100644 --- a/Libraries/LibWeb/SVG/SVGRectElement.cpp +++ b/Libraries/LibWeb/SVG/SVGRectElement.cpp @@ -5,10 +5,6 @@ */ #include -#include -#include -#include -#include #include namespace Web::SVG { @@ -20,31 +16,20 @@ SVGRectElement::SVGRectElement(DOM::Document& document, DOM::QualifiedName quali { } -void SVGRectElement::attribute_changed(Utf16FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) -{ - Base::attribute_changed(name, old_value, value, namespace_); - - if (name == SVG::AttributeNames::x) { - m_x = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::y) { - m_y = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::width) { - m_width = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::height) { - m_height = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::rx) { - m_radius_x = AttributeParser::parse_number_percentage(value.value_or({})); - } else if (name == SVG::AttributeNames::ry) { - m_radius_y = AttributeParser::parse_number_percentage(value.value_or({})); - } -} - Gfx::Path SVGRectElement::get_path(CSSPixelSize viewport_size) { - float width = m_width.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()); - float height = m_height.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()); - float x = m_x.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()); - float y = m_y.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()); + auto computed_values = this->computed_values(); + + auto computed_width = computed_values->width(); + auto computed_height = computed_values->height(); + + // FIXME: to_px rounds prematurely here - we shouldn't round to fixed point CSSPixels until converting to CSS pixel + // space from SVG user space - this likely extends to other SVG geometry elements as well. + auto width = computed_width.is_length_percentage() ? computed_width.length_percentage().to_px(viewport_size.width()).to_double() : 0.0; + auto height = computed_height.is_length_percentage() ? computed_height.length_percentage().to_px(viewport_size.height()).to_double() : 0.0; + + auto x = computed_values->x().to_px(viewport_size.width()).to_double(); + auto y = computed_values->y().to_px(viewport_size.height()).to_double(); Gfx::Path path; // Non-positive dimensions disable rendering. In particular, a negative @@ -53,7 +38,7 @@ Gfx::Path SVGRectElement::get_path(CSSPixelSize viewport_size) if (width <= 0 || height <= 0) return path; - auto corner_radii = calculate_used_corner_radius_values(viewport_size); + auto corner_radii = calculate_used_corner_radius_values(width, height); float rx = corner_radii.width(); float ry = corner_radii.height(); @@ -106,45 +91,66 @@ Gfx::Path SVGRectElement::get_path(CSSPixelSize viewport_size) return path; } -Gfx::FloatSize SVGRectElement::calculate_used_corner_radius_values(CSSPixelSize viewport_size) const +Gfx::FloatSize SVGRectElement::calculate_used_corner_radius_values(float used_width, float used_height) const { - // 1. Let rx and ry be length values. - float rx = 0; - float ry = 0; - - // 2. If neither ‘rx’ nor ‘ry’ are properly specified, then set both rx and ry to 0. (This will result in square corners.) - if (!m_radius_x.has_value() && !m_radius_y.has_value()) { - rx = 0; - ry = 0; - } - // 3. Otherwise, if a properly specified value is provided for ‘rx’, but not for ‘ry’, then set both rx and ry to the value of ‘rx’. - else if (m_radius_x.has_value() && !m_radius_y.has_value()) { - rx = m_radius_x.value().resolve_relative_to(viewport_size.width().to_float()); - ry = m_radius_x.value().resolve_relative_to(viewport_size.width().to_float()); - } - // 4. Otherwise, if a properly specified value is provided for ‘ry’, but not for ‘rx’, then set both rx and ry to the value of ‘ry’. - else if (m_radius_y.has_value() && !m_radius_x.has_value()) { - rx = m_radius_y.value().resolve_relative_to(viewport_size.height().to_float()); - ry = m_radius_y.value().resolve_relative_to(viewport_size.height().to_float()); - } - // 5. Otherwise, both ‘rx’ and ‘ry’ were specified properly. Set rx to the value of ‘rx’ and ry to the value of ‘ry’. - else { - rx = m_radius_x.value().resolve_relative_to(viewport_size.width().to_float()); - ry = m_radius_y.value().resolve_relative_to(viewport_size.height().to_float()); + // The used values for rx and ry are determined from the computed values by following these steps in order: + + auto const& computed_values = this->computed_values(); + + auto computed_rx = computed_values->rx(); + auto computed_ry = computed_values->ry(); + + // 1. If both rx and ry have a computed value of auto (since auto is the initial value for both properties, this + // will also occur if neither are specified by the author or if all author-supplied values are invalid), then + // the used value of both rx and ry is 0. (This will result in square corners.) + if (computed_rx.is_auto() && computed_ry.is_auto()) + return { 0, 0 }; + + // 2. Otherwise, convert specified values to absolute values as follows: + float used_rx; + float used_ry; + + { + // 1. If rx is set to a length value or a percentage, but ry is auto, calculate an absolute length equivalent + // for rx, resolving percentages against the used width of the rectangle; the absolute value for ry is the + // same. + if (!computed_rx.is_auto() && computed_ry.is_auto()) { + used_rx = computed_rx.to_px_or_zero(CSSPixels { used_width }).to_float(); + used_ry = used_rx; + } + + // 2. If ry is set to a length value or a percentage, but rx is auto, calculate the absolute length equivalent + // for ry, resolving percentages against the used height of the rectangle; the absolute value for rx is the + // same. + if (!computed_ry.is_auto() && computed_rx.is_auto()) { + used_ry = computed_ry.to_px_or_zero(CSSPixels { used_height }).to_float(); + used_rx = used_ry; + } + + // 3. If both rx and ry were set to lengths or percentages, absolute values are generated individually, + // resolving rx percentages against the used width, and resolving ry percentages against the used height. + if (!computed_rx.is_auto() && !computed_ry.is_auto()) { + used_rx = computed_rx.to_px_or_zero(CSSPixels { used_width }).to_float(); + used_ry = computed_ry.to_px_or_zero(CSSPixels { used_height }).to_float(); + } } - // 6. If rx is greater than half of ‘width’, then set rx to half of ‘width’. - auto half_width = m_width.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()) / 2; - if (rx > half_width) - rx = half_width; + // 3. Finally, apply clamping to generate the used values: + { + // 1. If the absolute rx (after the above steps) is greater than half of the used width, then the used value of + // rx is half of the used width. + if (used_rx > used_width / 2) + used_rx = used_width / 2; + + // 2. If the absolute ry (after the above steps) is greater than half of the used height, then the used value of + // ry is half of the used height. + if (used_ry > used_height / 2) + used_ry = used_height / 2; - // 7. If ry is greater than half of ‘height’, then set ry to half of ‘height’. - auto half_height = m_height.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()) / 2; - if (ry > half_height) - ry = half_height; + // 3. Otherwise, the used values of rx and ry are the absolute values computed previously. + } - // 8. The effective values of ‘rx’ and ‘ry’ are rx and ry, respectively. - return { rx, ry }; + return { used_rx, used_ry }; } // Reflected length accessors are generated by SVGElement's reflection macro. diff --git a/Libraries/LibWeb/SVG/SVGRectElement.h b/Libraries/LibWeb/SVG/SVGRectElement.h index 6d877f825e4f3..b9da19b07d1a6 100644 --- a/Libraries/LibWeb/SVG/SVGRectElement.h +++ b/Libraries/LibWeb/SVG/SVGRectElement.h @@ -19,8 +19,6 @@ class SVGRectElement final : public SVGGeometryElement { public: virtual ~SVGRectElement() override = default; - virtual void attribute_changed(Utf16FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; - virtual Gfx::Path get_path(CSSPixelSize viewport_size) override; // AD-HOC: The spec states that the x, y, width, height, rx and ry IDL attributes reflect the respective computed values @@ -48,14 +46,7 @@ class SVGRectElement final : public SVGGeometryElement { private: SVGRectElement(DOM::Document&, DOM::QualifiedName); - Gfx::FloatSize calculate_used_corner_radius_values(CSSPixelSize viewport_size) const; - - Optional m_x; - Optional m_y; - Optional m_width; - Optional m_height; - Optional m_radius_x; - Optional m_radius_y; + Gfx::FloatSize calculate_used_corner_radius_values(float used_width, float used_height) const; }; } diff --git a/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Libraries/LibWeb/SVG/SVGUseElement.cpp index dd97fba63b0c6..1a51113c6858b 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -170,12 +170,7 @@ void SVGUseElement::attribute_changed(Utf16FlyString const& name, Optionalcomputed_values().width().to_px(0), svg_svg_layout_node->computed_values().height().to_px(0) }; } - auto x = m_x.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.width().to_float()); - auto y = m_y.value_or(NumberPercentage::create_number(0)).resolve_relative_to(viewport_size.height().to_float()); + auto computed_values = this->computed_values(); + + auto x = computed_values->x().to_px(viewport_size.width()).to_float(); + auto y = computed_values->y().to_px(viewport_size.height()).to_float(); // The x and y properties define an additional transformation (translate(x,y), where x and y represent the computed value of the corresponding property) // to be applied to the ‘use’ element, after any transformations specified with other properties diff --git a/Libraries/LibWeb/SVG/SVGUseElement.h b/Libraries/LibWeb/SVG/SVGUseElement.h index d4df573b44d9c..18f1123c161f4 100644 --- a/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Libraries/LibWeb/SVG/SVGUseElement.h @@ -83,8 +83,6 @@ class SVGUseElement final void register_for_referenced_element_changes(); void unregister_for_referenced_element_changes(); - Optional m_x; - Optional m_y; bool m_needs_document_complete_reclone { false }; Optional m_href; diff --git a/Tests/LibWeb/Layout/expected/svg/rect-percentages.txt b/Tests/LibWeb/Layout/expected/svg/rect-percentages.txt index 677eecce829ca..a82922566514e 100644 --- a/Tests/LibWeb/Layout/expected/svg/rect-percentages.txt +++ b/Tests/LibWeb/Layout/expected/svg/rect-percentages.txt @@ -3,14 +3,14 @@ Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children BlockContainer at [8,8] [8+0+0 784 0+0+8] [8+0+0 200 0+0+8] children: inline frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 300x200] baseline: 200 SVGSVGBox at [8,8] [0+0+0 300 0+0+0] [0+0+0 200 0+0+0] [SVG] children: not-inline - SVGGeometryBox at [83,108] [0+0+0 99 0+0+0] [0+0+0 99 0+0+0] children: not-inline + SVGGeometryBox at [83,108] [0+0+0 98.953125 0+0+0] [0+0+0 98.953125 0+0+0] children: not-inline TextNode <#text> (not painted) ViewportPaintable (Viewport<#document>) [0,0 800x600] PaintableWithLines (BlockContainer) [0,0 800x216] PaintableWithLines (BlockContainer) [8,8 784x200] SVGSVGPaintable (SVGSVGBox) [8,8 300x200] - SVGPathPaintable (SVGGeometryBox) [83,108 99x99] + SVGPathPaintable (SVGGeometryBox) [83,108 98.953125x98.953125] SC for Viewport<#document> [0,0 800x600] (z-index: auto) SC for BlockContainer [0,0 800x216] (z-index: auto) diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-images/object-position-svg-001-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-images/object-position-svg-001-ref.html deleted file mode 100644 index 61c386d88f645..0000000000000 --- a/Tests/LibWeb/Ref/expected/wpt-import/css/css-images/object-position-svg-001-ref.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - CSS Reftest Reference - - - - -
-
-
-
-
-
-
- - diff --git a/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport-ref.html new file mode 100644 index 0000000000000..70576349bc034 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport-ref.html @@ -0,0 +1,18 @@ + +Changing container size of SVG with calc() cx/cy/rx/ry on <ellipse> (reference) +
+ + + + + + +
+
+ + + + + + +
diff --git a/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-ref.svg b/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-ref.svg new file mode 100644 index 0000000000000..57e6f4d5e854c --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/svg/geometry/reftests/ellipse-ref.svg @@ -0,0 +1,4 @@ + + + diff --git a/Tests/LibWeb/Ref/expected/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath-ref.html new file mode 100644 index 0000000000000..a3305134d8a21 --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath-ref.html @@ -0,0 +1,15 @@ + + + + + + + + + + XXXXXXXX + XXXXXXXX + + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-position-svg-001o.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-position-svg-001o.html deleted file mode 100644 index f001c46a264a4..0000000000000 --- a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-position-svg-001o.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - CSS Test: various 'object-position' values on a fixed-size object element, with a SVG image and 'object-fit:contain'. - - - - - - - - - - - - - - - - - diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/support/colors-16x8.svg b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/support/colors-16x8.svg deleted file mode 100644 index 08e36594026d0..0000000000000 --- a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/support/colors-16x8.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - diff --git a/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-001.svg b/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-001.svg new file mode 100644 index 0000000000000..1097497f605fa --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-001.svg @@ -0,0 +1,17 @@ + + Ellipse coordinates and radii specified by properties + + + + + diff --git a/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport.html b/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport.html new file mode 100644 index 0000000000000..83f57bc08a869 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/svg/geometry/reftests/ellipse-calc-dynamic-viewport.html @@ -0,0 +1,29 @@ + + +Changing container size of SVG with calc() cx/cy/rx/ry on <ellipse> + + + +
+ + + + + + +
+
+ + + + + + +
+ diff --git a/Tests/LibWeb/Ref/input/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath.html b/Tests/LibWeb/Ref/input/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath.html new file mode 100644 index 0000000000000..a37665bd95f19 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/svg/shapes/reftests/ellipse-auto-rx-textpath.html @@ -0,0 +1,20 @@ + + +SVG ellipse with auto rx/ry referenced from <textPath> resolves per SVG 2 + + + + + + + + + + + + XXXXXXXX + XXXXXXXX + + diff --git a/Tests/LibWeb/Text/expected/SVG/use-element-css-x-y.txt b/Tests/LibWeb/Text/expected/SVG/use-element-css-x-y.txt new file mode 100644 index 0000000000000..fa3d26eaa433d --- /dev/null +++ b/Tests/LibWeb/Text/expected/SVG/use-element-css-x-y.txt @@ -0,0 +1,2 @@ +computed: x=50px y=40px +client rect: x=50 y=40 width=10 height=10 diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/height-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/height-computed.txt new file mode 100644 index 0000000000000..47db1fd0563ea --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/height-computed.txt @@ -0,0 +1,40 @@ +Harness status: OK + +Found 34 tests + +19 Pass +15 Fail +Pass SVG Geometry Properties: getComputedStyle().height, initial +Pass SVG Geometry Properties: getComputedStyle().height, presentation attribute +Pass SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().height, inline style but "display: none" +Pass SVG Geometry Properties: getComputedStyle().height, initial +Pass SVG Geometry Properties: getComputedStyle().height, presentation attribute +Pass SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().height, inline style but "display: none" +Pass SVG Geometry Properties: getComputedStyle().height, initial +Pass SVG Geometry Properties: getComputedStyle().height, presentation attribute +Pass SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().height, inline style but "display: none" +Fail SVG Geometry Properties: getComputedStyle().height, initial +Fail SVG Geometry Properties: getComputedStyle().height, presentation attribute +Fail SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().height, inline style but "display: none" +Fail SVG Geometry Properties: getComputedStyle().height, initial +Fail SVG Geometry Properties: getComputedStyle().height, initial (with dummy attribute) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (percentage) +Fail SVG Geometry Properties: getComputedStyle().height, initial +Fail SVG Geometry Properties: getComputedStyle().height, initial (with dummy attribute) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (auto) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().height, inline style (percentage) \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/width-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/width-computed.txt new file mode 100644 index 0000000000000..69b8b097eae3d --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/parsing/width-computed.txt @@ -0,0 +1,40 @@ +Harness status: OK + +Found 34 tests + +19 Pass +15 Fail +Pass SVG Geometry Properties: getComputedStyle().width, initial +Pass SVG Geometry Properties: getComputedStyle().width, presentation attribute +Pass SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (pixels) +Pass SVG Geometry Properties: getComputedStyle().width, inline style but "display: none" +Pass SVG Geometry Properties: getComputedStyle().width, initial +Pass SVG Geometry Properties: getComputedStyle().width, presentation attribute +Pass SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (pixels) +Pass SVG Geometry Properties: getComputedStyle().width, inline style but "display: none" +Pass SVG Geometry Properties: getComputedStyle().width, initial +Pass SVG Geometry Properties: getComputedStyle().width, presentation attribute +Fail SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (pixels) +Pass SVG Geometry Properties: getComputedStyle().width, inline style but "display: none" +Fail SVG Geometry Properties: getComputedStyle().width, initial +Fail SVG Geometry Properties: getComputedStyle().width, presentation attribute +Fail SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Pass SVG Geometry Properties: getComputedStyle().width, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Pass SVG Geometry Properties: getComputedStyle().width, inline style but "display: none" +Fail SVG Geometry Properties: getComputedStyle().width, initial +Fail SVG Geometry Properties: getComputedStyle().width, initial (with dummy attribute) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (pixels) +Fail SVG Geometry Properties: getComputedStyle().width, initial +Fail SVG Geometry Properties: getComputedStyle().width, initial (with dummy attribute) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (percentage) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (auto) +Fail SVG Geometry Properties: getComputedStyle().width, inline style (pixels) \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.txt new file mode 100644 index 0000000000000..b66eb2542649d --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.txt @@ -0,0 +1,37 @@ +Harness status: OK + +Found 32 tests + +32 Pass +Pass 'auto' sizing with 256x256 png image, attributes width='64' height='64' +Pass 'auto' sizing with 256x256 png image, attributes width='128' height='64' and CSS 'width:auto' +Pass 'auto' sizing with 256x256 png image, attributes width='64' height='128' and CSS 'height:auto' +Pass 'auto' sizing with 256x256 png image, attributes width='64' height='64' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with default sized svg image, attributes width='50' height='50' +Pass 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with 200x100 svg image, attributes width='50' height='50' and CSS 'width:auto' +Pass 'auto' sizing with 200x100 svg image, without attributes width and height and CSS 'width:auto' +Pass 'auto' sizing with 200x100 svg image, attributes height='50' and 'width:auto' +Pass 'auto' sizing with 200x100 svg image, attributes width='50' and CSS height:auto +Pass 'auto' sizing with default sized svg image, attributes width='200' height='200' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with default sized svg image, attributes height='200' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with default sized svg image, attributes width='200' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with default sized svg image, without attributes width and height, no css width/height specified +Pass 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified +Pass 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' +Pass 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' +Pass 'auto' sizing with default sized svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified +Pass 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' +Pass 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' +Pass 'auto' sizing with svg image width='200' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified +Pass 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' +Pass 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' +Pass 'auto' sizing with svg image height='100' viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and no css width/height specified +Pass 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto' +Pass 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'height:auto' +Pass 'auto' sizing with 200x100 svg image viewBox='0 0 400 100', attributes width='60' height='60' and CSS 'width:auto; height:auto' +Pass 'auto' sizing with default sized svg image, attributes width='60' height='60' and CSS 'height:auto' +Pass 'auto' sizing with default sized svg image, attributes width='60' height='60' and CSS 'width:auto' \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.txt new file mode 100644 index 0000000000000..3861f6f25d564 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.txt @@ -0,0 +1,26 @@ +Harness status: OK + +Found 20 tests + +18 Pass +2 Fail +Pass image with zero width +Pass image with zero height +Pass image with zero width and height +Pass image with no width/height attributes +Pass foreignObject with zero width +Pass foreignObject with zero height +Pass foreignObject with zero width and height +Pass foreignObject with no width/height attributes +Fail empty nested SVG element +Pass empty nested SVG with no attributes +Pass empty nested SVG with zero width and height +Pass anchor element wrapping zero-dimension rect +Fail anchor element with zero-dim and normal child: zero-dim child does not affect bbox +Pass zero-dim rect with translate transform +Pass rect with negative width and scale(2) (not rendered) +Pass zero-dim rect inside rotated group (not rendered) +Pass zero-width rect with scale(3) (not rendered) +Pass zero-radius circle with translate (not rendered) +Pass group with translate transform — bbox in group's local coords +Pass rotated group with zero-dim child — bbox is zero \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/SVG/use-element-css-x-y.html b/Tests/LibWeb/Text/input/SVG/use-element-css-x-y.html new file mode 100644 index 0000000000000..6b81b5bc9220b --- /dev/null +++ b/Tests/LibWeb/Text/input/SVG/use-element-css-x-y.html @@ -0,0 +1,28 @@ + + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/height-computed.svg b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/height-computed.svg new file mode 100644 index 0000000000000..057b21516f4ce --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/height-computed.svg @@ -0,0 +1,134 @@ + + + SVG Geometry Properties: getComputedStyle().height + + + + + + + + + + + + + + + + + + + + + + + + + + + + Some content + Some content + Some content + Some content + Some content + Some content + + + + + + + + + Text1 + Text2 + Text3 + Text3 + Text3 + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/width-computed.svg b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/width-computed.svg new file mode 100644 index 0000000000000..84ad61a380eb7 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/parsing/width-computed.svg @@ -0,0 +1,134 @@ + + + SVG Geometry Properties: getComputedStyle().width + + + + + + + + + + + + + + + + + + + + + + + + + + + + Some content + Some content + Some content + Some content + Some content + Some content + + + + + + + + + Text1 + Text2 + Text3 + Text3 + Text3 + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.html b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.html new file mode 100644 index 0000000000000..c2b023ea71dc9 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.html @@ -0,0 +1,98 @@ + +<svg:image> 'auto' sizing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.html b/Tests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.html new file mode 100644 index 0000000000000..14962bc00bca4 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGGraphicsElement.getBBox-08.html @@ -0,0 +1,166 @@ + +SVGGraphicsElement.prototype.getBBox for image, foreignObject, containers, and transforms + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +