Automatic update from web-platform-tests
[SVG] Implement `getPathData()` on `SVGPathElement`
Implements the `SVGPathData` interface mixin from the SVG Paths spec
[1] on `SVGPathElement`, exposing:
`sequence<SVGPathSegment> getPathData(optional SVGPathDataSettings);`
plus the `SVGPathSegment {type, values}` and `SVGPathDataSettings
{normalize}` dictionaries.
The method reads the `d` attribute base value (ignoring SMIL/CSS) and,
for <use> shadow instances, forwards to `CorrespondingElement()`.
With `{normalize: true}`, segments are reduced to absolute M, L, C,
Z via `SVGPathNormalizer`.
Gated behind the new experimental runtime flag `SVGPathDataAPI`.
Instrumented via `SVGPathElementGetPathData` and
`SVGPathElementGetPathDataNormalized` use counters.
[1] https://svgwg.org/specs/paths/#__svg__SVGPathData__getPathData
Design: https://docs.google.com/document/d/1uCVUqYGKgsCCu7LEtEdO3Yuea-MT-I2XsU6Eoe3mlQI/edit?usp=sharing
Bug: 40441025
Change-Id: I960bf62b31800b44bd5dd71d1e04acde8bed0553
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7859157
Reviewed-by: Fredrik Söderquist <fs@opera.com>
Commit-Queue: Virali Purbey <viralipurbey@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1647018}
--
wpt-commits: 13a109f13381905050713b0d4aab3fdf62a1da06
wpt-pr: 60645
26 lines
964 B
HTML
26 lines
964 B
HTML
<!doctype html>
|
|
<title>SVGPathElement.getPathData() with malformed d attribute</title>
|
|
<link rel="help" href="https://svgwg.org/specs/paths/#InterfaceSVGPathData">
|
|
<link rel="author" title="Virali Purbey" href="mailto:viralipurbey@microsoft.com">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="support/getPathData-helpers.js"></script>
|
|
|
|
<svg>
|
|
<path id="truncated" d="M 10 20 L"/>
|
|
<path id="closepathOnly" d="Z"/>
|
|
</svg>
|
|
<script>
|
|
test(() => {
|
|
// L command is missing its coordinates; parser stops at the error.
|
|
assert_path_data_equals(truncated.getPathData(), [
|
|
{ type: "M", values: [10, 20] }
|
|
]);
|
|
}, "path.getPathData() with malformed d returns segments up to the error");
|
|
|
|
test(() => {
|
|
// Path data must start with a moveto; bare "Z" is invalid.
|
|
assert_path_data_equals(closepathOnly.getPathData(), []);
|
|
}, "path.getPathData() with closepath-only d returns []");
|
|
</script>
|