diff --git a/Tests/LibWeb/Ref/manifest.json b/Tests/LibWeb/Ref/manifest.json index a7c9958fa7..a34d1489f6 100644 --- a/Tests/LibWeb/Ref/manifest.json +++ b/Tests/LibWeb/Ref/manifest.json @@ -17,5 +17,6 @@ "svg-gradient-spreadMethod.html": "svg-gradient-spreadMethod-ref.html", "svg-radialGradient.html": "svg-radialGradient-ref.html", "svg-symbol.html": "svg-symbol-ref.html", - "border-radius-shrink-zero-sized-box.html": "border-radius-shrink-zero-sized-box-ref.html" + "border-radius-shrink-zero-sized-box.html": "border-radius-shrink-zero-sized-box-ref.html", + "svg-file-matches-html-file.svg": "svg-file-matches-html-file.html" } diff --git a/Tests/LibWeb/Ref/svg-file-matches-html-file.html b/Tests/LibWeb/Ref/svg-file-matches-html-file.html new file mode 100644 index 0000000000..ca773b9b33 --- /dev/null +++ b/Tests/LibWeb/Ref/svg-file-matches-html-file.html @@ -0,0 +1,13 @@ + + + + + + + + + diff --git a/Tests/LibWeb/Ref/svg-file-matches-html-file.svg b/Tests/LibWeb/Ref/svg-file-matches-html-file.svg new file mode 100644 index 0000000000..afed25d319 --- /dev/null +++ b/Tests/LibWeb/Ref/svg-file-matches-html-file.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index a11d88446e..e79aaff018 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -111,7 +111,7 @@ Gfx::AffineTransform SVGGraphicsElement::get_transform() const { Gfx::AffineTransform transform = m_transform; for (auto* svg_ancestor = shadow_including_first_ancestor_of_type(); svg_ancestor; svg_ancestor = svg_ancestor->shadow_including_first_ancestor_of_type()) { - transform = Gfx::AffineTransform { svg_ancestor->m_transform }.multiply(transform); + transform = Gfx::AffineTransform { svg_ancestor->element_transform() }.multiply(transform); } return transform; } diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h index 6edeaa3320..996f9d35ba 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.h @@ -53,6 +53,11 @@ protected: virtual void initialize(JS::Realm&) override; + virtual Gfx::AffineTransform element_transform() const + { + return m_transform; + } + Optional svg_paint_computed_value_to_gfx_paint_style(SVGPaintContext const& paint_context, Optional const& paint_value) const; Gfx::AffineTransform m_transform = {}; diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp index 82daab7074..d784f52084 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.cpp @@ -72,13 +72,16 @@ Optional SVGUseElement::parse_id_from_href(DeprecatedString const& h return href.substring_view(id_seperator.value() + 1); } +Gfx::AffineTransform SVGUseElement::element_transform() const +{ + // 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 + return Base::element_transform().translate(m_x.value_or(0), m_y.value_or(0)); +} + void SVGUseElement::inserted() { Base::inserted(); - - // 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 - m_transform.translate(m_x.value_or(0), m_y.value_or(0)); } void SVGUseElement::svg_element_changed(SVGElement& svg_element) diff --git a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h index 496da7b3fb..591221bc57 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGUseElement.h +++ b/Userland/Libraries/LibWeb/SVG/SVGUseElement.h @@ -34,6 +34,8 @@ public: JS::GCPtr instance_root() const; JS::GCPtr animated_instance_root() const; + virtual Gfx::AffineTransform element_transform() const override; + private: SVGUseElement(DOM::Document&, DOM::QualifiedName);