Skip to content

Truly independent web browser

LibWeb: Preserve SVG currentTranslate object identity

Andreas Kling9e26497abdfc
diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Libraries/LibWeb/SVG/SVGSVGElement.cpp
index c6da73055df..bf831265d84 100644
--- a/Libraries/LibWeb/SVG/SVGSVGElement.cpp
+++ b/Libraries/LibWeb/SVG/SVGSVGElement.cpp
@@ -43,6 +43,7 @@ void SVGSVGElement::visit_edges(Visitor& visitor)
{
Base::visit_edges(visitor);
SVGFitToViewBox::visit_edges(visitor);
+ visitor.visit(m_current_translate);
visitor.visit(m_active_view_element);
visitor.visit(m_time_container);
}
@@ -213,10 +214,13 @@ void SVGSVGElement::set_current_scale(float)
dbgln("(STUBBED) SVGSVGElement::set_current_scale(). Called on: {}", debug_description());
}
+// https://svgwg.org/svg2-draft/struct.html#__svg__SVGSVGElement__currentTranslate
+// On getting currentTranslate, the SVGSVGElement object's current translate point object is returned.
GC::Ref<Geometry::DOMPointReadOnly> SVGSVGElement::current_translate() const
{
- dbgln("(STUBBED) SVGSVGElement::current_translate(). Called on: {}", debug_description());
- return Geometry::DOMPointReadOnly::create();
+ if (!m_current_translate)
+ m_current_translate = Geometry::DOMPointReadOnly::create();
+ return *m_current_translate;
}
GC::Ref<DOM::NodeList> SVGSVGElement::get_intersection_list(GC::Ref<Geometry::DOMRectReadOnly>, GC::Ptr<SVGElement>) const
diff --git a/Libraries/LibWeb/SVG/SVGSVGElement.h b/Libraries/LibWeb/SVG/SVGSVGElement.h
index 350042ed18f..48b19937932 100644
--- a/Libraries/LibWeb/SVG/SVGSVGElement.h
+++ b/Libraries/LibWeb/SVG/SVGSVGElement.h
@@ -131,6 +131,8 @@ private:
mutable Optional<Optional<CSS::Length>> m_cached_width_attribute_length;
mutable Optional<Optional<CSS::Length>> m_cached_height_attribute_length;
+ mutable GC::Ptr<Geometry::DOMPointReadOnly> m_current_translate;
+
GC::Ptr<SVGViewElement> m_active_view_element;
GC::Ptr<SMILTimeContainer> m_time_container;
diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt
index 9ac8fa2ba17..db192c652cf 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/svg/types/SameObject-identity.txt
@@ -2,8 +2,7 @@ Harness status: OK
Found 81 tests
-80 Pass
-1 Fail
+81 Pass
Pass SVGAnimatedLength: rect.x
Pass SVGAnimatedLength: rect.y
Pass SVGAnimatedLength: rect.width
@@ -83,5 +82,5 @@ Pass SVGPointList: poly.points
Pass SVGPointList: poly.animatedPoints
Pass SVGStringList: rect.requiredExtensions
Pass SVGStringList: rect.systemLanguage
-Fail DOMPointReadOnly: root.currentTranslate
+Pass DOMPointReadOnly: root.currentTranslate
Pass DOMTokenList: anchor.relList
\ No newline at end of file