mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement the SVGGeometryElement.pathLength
attribute
This commit is contained in:
parent
410e82c9fd
commit
caf45f2317
Notes:
github-actions[bot]
2025-07-11 23:50:23 +00:00
Author: https://github.com/tcl3
Commit: caf45f2317
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5410
Reviewed-by: https://github.com/shannonbooth
6 changed files with 54 additions and 10 deletions
|
@ -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<Layout::Node> SVGGeometryElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::SVGGeometryBox>(document(), *this, move(style));
|
||||
|
@ -38,4 +44,11 @@ GC::Ref<Geometry::DOMPoint> SVGGeometryElement::get_point_at_length(float distan
|
|||
return Geometry::DOMPoint::construct_impl(realm(), 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
GC::Ref<SVGAnimatedNumber> SVGGeometryElement::path_length()
|
||||
{
|
||||
if (!m_path_length)
|
||||
m_path_length = SVGAnimatedNumber::create(realm(), *this, AttributeNames::pathLength, 0.f);
|
||||
return *m_path_length;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,16 @@ public:
|
|||
float get_total_length();
|
||||
GC::Ref<Geometry::DOMPoint> get_point_at_length(float distance);
|
||||
|
||||
GC::Ref<SVGAnimatedNumber> 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<SVGAnimatedNumber> m_path_length;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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 = {});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
Harness status: OK
|
||||
|
||||
Found 1 tests
|
||||
|
||||
1 Pass
|
||||
Pass line supports pathLength attribute
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:h="http://www.w3.org/1999/xhtml">
|
||||
<metadata>
|
||||
<h:link rel="help" href="https://www.w3.org/TR/SVG2/shapes.html#InterfaceSVGLineElement"/>
|
||||
<h:link rel="help" href="https://www.w3.org/TR/SVG2/types.html#InterfaceSVGGeometryElement"/>
|
||||
<h:meta name="assert" content="The pathLength IDL attribute reflects the ‘pathLength’ content attribute."/>
|
||||
</metadata>
|
||||
<line id="interval" x1="300" y1="400" x2="500" y2="400" pathLength="25"/>
|
||||
<h:script src="../../resources/testharness.js"/>
|
||||
<h:script src="../../resources/testharnessreport.js"/>
|
||||
<script><![CDATA[
|
||||
test(function() {
|
||||
var interval = document.getElementById('interval');
|
||||
assert_not_equals(interval.pathLength, undefined, "pathLength is defined for SVGLineElement");
|
||||
assert_equals(interval.pathLength.baseVal, 25);
|
||||
}, 'line supports pathLength attribute');
|
||||
]]></script>
|
||||
</svg>
|
After Width: | Height: | Size: 957 B |
Loading…
Add table
Add a link
Reference in a new issue