diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp index e546e032aed..23091d26065 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.cpp +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.cpp @@ -22,6 +22,12 @@ void SVGGeometryElement::initialize(JS::Realm& realm) Base::initialize(realm); } +void SVGGeometryElement::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_path_length); +} + GC::Ptr SVGGeometryElement::create_layout_node(GC::Ref style) { return heap().allocate(document(), *this, move(style)); @@ -38,4 +44,11 @@ GC::Ref SVGGeometryElement::get_point_at_length(float distan return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0); } +GC::Ref SVGGeometryElement::path_length() +{ + if (!m_path_length) + m_path_length = SVGAnimatedNumber::create(realm(), *this, AttributeNames::pathLength, 0.f); + return *m_path_length; +} + } diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.h b/Libraries/LibWeb/SVG/SVGGeometryElement.h index 39e4aa52824..ed1bda781f2 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.h +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.h @@ -23,10 +23,16 @@ public: float get_total_length(); GC::Ref get_point_at_length(float distance); + GC::Ref path_length(); + protected: SVGGeometryElement(DOM::Document& document, DOM::QualifiedName qualified_name); virtual void initialize(JS::Realm&) override; + virtual void visit_edges(Cell::Visitor&) override; + +private: + GC::Ptr m_path_length; }; } diff --git a/Libraries/LibWeb/SVG/SVGGeometryElement.idl b/Libraries/LibWeb/SVG/SVGGeometryElement.idl index e2b181034de..115c0fc5e4d 100644 --- a/Libraries/LibWeb/SVG/SVGGeometryElement.idl +++ b/Libraries/LibWeb/SVG/SVGGeometryElement.idl @@ -5,7 +5,7 @@ // https://svgwg.org/svg2-draft/types.html#InterfaceSVGGeometryElement [Exposed=Window] interface SVGGeometryElement : SVGGraphicsElement { - [FIXME, SameObject] readonly attribute SVGAnimatedNumber pathLength; + [SameObject] readonly attribute SVGAnimatedNumber pathLength; [FIXME] boolean isPointInFill(optional DOMPointInit point = {}); [FIXME] boolean isPointInStroke(optional DOMPointInit point = {}); diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt index 3f912693e9a..40ed1a69e6e 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/idlharness.window.txt @@ -2,8 +2,8 @@ Harness status: OK Found 1781 tests -927 Pass -854 Fail +934 Pass +847 Fail Pass idl_test setup Pass idl_test validation Pass Partial interface Document: original interface defined @@ -80,7 +80,7 @@ Pass SVGGeometryElement interface object name Pass SVGGeometryElement interface: existence and properties of interface prototype object Pass SVGGeometryElement interface: existence and properties of interface prototype object's "constructor" property Pass SVGGeometryElement interface: existence and properties of interface prototype object's @@unscopables property -Fail SVGGeometryElement interface: attribute pathLength +Pass SVGGeometryElement interface: attribute pathLength Fail SVGGeometryElement interface: operation isPointInFill(optional DOMPointInit) Fail SVGGeometryElement interface: operation isPointInStroke(optional DOMPointInit) Pass SVGGeometryElement interface: operation getTotalLength() @@ -866,7 +866,7 @@ Pass SVGRectElement interface: objects.rect must inherit property "width" with t Pass SVGRectElement interface: objects.rect must inherit property "height" with the proper type Pass SVGRectElement interface: objects.rect must inherit property "rx" with the proper type Pass SVGRectElement interface: objects.rect must inherit property "ry" with the proper type -Fail SVGGeometryElement interface: objects.rect must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.rect must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.rect must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.rect with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.rect must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type @@ -900,7 +900,7 @@ Pass Stringification of objects.circle Pass SVGCircleElement interface: objects.circle must inherit property "cx" with the proper type Pass SVGCircleElement interface: objects.circle must inherit property "cy" with the proper type Pass SVGCircleElement interface: objects.circle must inherit property "r" with the proper type -Fail SVGGeometryElement interface: objects.circle must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.circle must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.circle must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.circle with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.circle must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type @@ -936,7 +936,7 @@ Pass SVGEllipseElement interface: objects.ellipse must inherit property "cx" wit Pass SVGEllipseElement interface: objects.ellipse must inherit property "cy" with the proper type Pass SVGEllipseElement interface: objects.ellipse must inherit property "rx" with the proper type Pass SVGEllipseElement interface: objects.ellipse must inherit property "ry" with the proper type -Fail SVGGeometryElement interface: objects.ellipse must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.ellipse must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.ellipse must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.ellipse with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.ellipse must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type @@ -972,7 +972,7 @@ Pass SVGLineElement interface: objects.line must inherit property "x1" with the Pass SVGLineElement interface: objects.line must inherit property "y1" with the proper type Pass SVGLineElement interface: objects.line must inherit property "x2" with the proper type Pass SVGLineElement interface: objects.line must inherit property "y2" with the proper type -Fail SVGGeometryElement interface: objects.line must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.line must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.line must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.line with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.line must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type @@ -1036,7 +1036,7 @@ Pass SVGPolylineElement must be primary interface of objects.polyline Pass Stringification of objects.polyline Fail SVGPolylineElement interface: objects.polyline must inherit property "points" with the proper type Fail SVGPolylineElement interface: objects.polyline must inherit property "animatedPoints" with the proper type -Fail SVGGeometryElement interface: objects.polyline must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.polyline must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.polyline must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.polyline with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.polyline must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type @@ -1068,7 +1068,7 @@ Pass SVGPolygonElement must be primary interface of objects.polygon Pass Stringification of objects.polygon Fail SVGPolygonElement interface: objects.polygon must inherit property "points" with the proper type Fail SVGPolygonElement interface: objects.polygon must inherit property "animatedPoints" with the proper type -Fail SVGGeometryElement interface: objects.polygon must inherit property "pathLength" with the proper type +Pass SVGGeometryElement interface: objects.polygon must inherit property "pathLength" with the proper type Fail SVGGeometryElement interface: objects.polygon must inherit property "isPointInFill(optional DOMPointInit)" with the proper type Pass SVGGeometryElement interface: calling isPointInFill(optional DOMPointInit) on objects.polygon with too few arguments must throw TypeError Fail SVGGeometryElement interface: objects.polygon must inherit property "isPointInStroke(optional DOMPointInit)" with the proper type diff --git a/Tests/LibWeb/Text/expected/wpt-import/svg/shapes/line-pathLength.txt b/Tests/LibWeb/Text/expected/wpt-import/svg/shapes/line-pathLength.txt new file mode 100644 index 00000000000..b21d0da2c25 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/svg/shapes/line-pathLength.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass line supports pathLength attribute \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/svg/shapes/line-pathLength.svg b/Tests/LibWeb/Text/input/wpt-import/svg/shapes/line-pathLength.svg new file mode 100644 index 00000000000..3b24ef9b253 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/svg/shapes/line-pathLength.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + +