Skip to content

Commit e811cf1

Browse files
authored
Cleanup Path2D constructor
This reverts f635643 which added a constructor that did not get implemented. (Verified for Chrome, Firefox, and Safari by inspecting IDL.) It also changes the constructor signature slightly to more idiomatic IDL and makes various editorial improvements.
1 parent 200ac13 commit e811cf1

File tree

1 file changed

+21
-116
lines changed

1 file changed

+21
-116
lines changed

source

Lines changed: 21 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -59915,10 +59915,7 @@ interface <dfn>ImageData</dfn> {
5991559915
readonly attribute <span data-x="idl-Uint8ClampedArray">Uint8ClampedArray</span> <span data-x="dom-imagedata-data">data</span>;
5991659916
};
5991759917

59918-
[<span data-x="dom-Path2D">Constructor</span>,
59919-
<span data-x="dom-Path2D-copy">Constructor</span>(<span>Path2D</span> path),
59920-
<span data-x="dom-Path2D-merge">Constructor</span>(sequence&lt;<span>Path2D</span>&gt; paths, optional <span>CanvasFillRule</span> fillRule = "<span data-x="dom-context-2d-fillRule-nonzero">nonzero</span>"),
59921-
<span data-x="dom-Path2D-withdata">Constructor</span>(DOMString d),
59918+
[<span data-x="dom-Path2D">Constructor</span>(optional (<span>Path2D</span> or DOMString) path),
5992259919
Exposed=(Window,Worker)]
5992359920
interface <dfn>Path2D</dfn> {
5992459921
void <span data-x="dom-Path2D-addPath">addPath</span>(<span>Path2D</span> path, optional <span>DOMMatrix2DInit</span> transform);
@@ -61784,143 +61781,51 @@ try {
6178461781
add text to paths.</p>
6178561782

6178661783
<dl class="domintro">
61787-
6178861784
<dt><var>path</var> = new <code subdfn data-x="dom-Path2D">Path2D</code>()</dt>
61785+
<dd><p>Creates a new empty <code>Path2D</code> object.</p></dd>
6178961786

61787+
<dt><var>path</var> = new <code data-x="dom-Path2D">Path2D</code>(<var>path</var>)</dt>
6179061788
<dd>
61789+
<p>When <var>path</var> is a <code>Path2D</code> object, returns a copy.</p>
6179161790

61792-
<p>Creates a new empty <code>Path2D</code> object.</p>
61793-
61794-
</dd>
61795-
61796-
<dt><var>path</var> = new <code subdfn data-x="dom-Path2D-copy">Path2D</code>(<var>path</var>)</dt>
61797-
61798-
<dd>
61799-
61800-
<p>Creates a new <code>Path2D</code> object that is a copy of the argument.</p>
61801-
61802-
</dd>
61803-
61804-
<dt><var>path</var> = new <code subdfn data-x="dom-Path2D-merge">Path2D</code>(<var>paths</var> [, <var>fillRule</var> ] )</dt>
61805-
61806-
<dd>
61807-
61808-
<p>Creates a new <code>Path2D</code> object that describes a path that outlines the given <var>paths</var>, using the given fill rule.</p>
61809-
61810-
</dd>
61811-
61812-
<dt><var>path</var> = new <code subdfn data-x="dom-Path2D-withdata">Path2D</code>(<var>d</var>)</dt>
61813-
61814-
<dd>
61815-
61816-
<p>Creates a new path with the path described by the argument, interpreted as SVG path data. <ref spec=SVG></p>
61817-
61791+
<p>When <var>path</var> is a string, creates the path described by the argument, interpreted as
61792+
SVG path data. <ref spec=SVG>
6181861793
</dd>
6181961794

6182061795
<dt><var>path</var> . <code subdfn data-x="dom-Path2D-addPath">addPath</code>(<var>path</var> [, <var>transform</var> ] )</dt>
61821-
61822-
<dd>
61823-
61824-
<p>Adds to the path the path given by the argument.</p>
61825-
61826-
</dd>
61827-
61796+
<dd><p>Adds to the path the path given by the argument.</p></dd>
6182861797
</dl>
6182961798

6183061799
<div w-nodev>
6183161800

61832-
<p>The <dfn><code data-x="dom-Path2D">Path2D()</code></dfn> constructor, when invoked, must return a
61833-
newly created <code>Path2D</code> object.</p>
61834-
61835-
<hr>
61836-
61837-
<p>The <dfn><code data-x="dom-Path2D-copy">Path2D(<var>path</var>)</code></dfn>
61838-
constructor, when invoked, must return a newly created <code>Path2D</code> object, to which the
61839-
subpaths of the argument are added. (In other words, it returns a copy of the argument.)</p>
61840-
61841-
<hr>
61842-
61843-
<p>The <dfn><code data-x="dom-Path2D-merge">Path2D(<var>paths</var>,
61844-
<var>fillRule</var>)</code></dfn> constructor, when invoked, must run these steps:</p>
61801+
<p>The <dfn><code data-x="dom-Path2D">Path2D(<var>path</var>)</code></dfn> constructor, when
61802+
invoked, must run these steps:</p>
6184561803

6184661804
<ol>
61805+
<li><p>Let <var>output</var> be a new <code>Path2D</code> object.</p></li>
6184761806

61848-
<li>
61807+
<li><p>If <var>path</var> is not given, then return <var>output</var>.</p></li>
6184961808

61850-
<p>Run the appropriate step from the following list, based on the constructor's second
61851-
argument:</p>
61852-
61853-
<dl class="switch">
61854-
61855-
<dt>If it is "nonzero"</dt>
61856-
61857-
<dd>
61858-
61859-
<p>Let <var>merged path</var> be a <span data-x="concept-path">path</span> that
61860-
consists of a set of non-overlapping subpaths that exactly outline the points from which, in
61861-
any of the <span data-x="concept-path">paths</span> provided in the constructor's first
61862-
argument, the number of times a half-infinite straight line drawn from that point crosses a
61863-
subpath going in one direction is not equal to the number of times it crosses a subpath going
61864-
in the other direction.</p>
61865-
61866-
</dd>
61867-
61868-
<dt>If it is "evenodd"</dt>
61869-
61870-
<dd>
61871-
61872-
<p>Let <var>merged path</var> be a <span data-x="concept-path">path</span> that
61873-
consists of a set of non-overlapping subpaths that exactly outline the points from which, in
61874-
any of the <span data-x="concept-path">paths</span> provided in the constructor's first
61875-
argument, the number of times a half-infinite straight line drawn from that point crosses that
61876-
path is odd.</p>
61877-
61878-
</dd>
61879-
61880-
</dl>
61881-
61882-
<p>The subpaths in <var>merged path</var> must be oriented such that for any point,
61883-
the number of times a half-infinite straight line drawn from that point crosses a subpath is
61884-
even if and only if the number of times a half-infinite straight line drawn from that same point
61885-
crosses a subpath going in one direction is equal to the number of times it crosses a subpath
61886-
going in the other direction.</p>
61887-
61888-
</li>
61889-
61890-
<li><p>Add all the subpaths in <var>merged path</var> to the <code>Path2D</code>
61891-
object.</p></li>
61892-
61893-
<li><p>Set the <code>Path2D</code> object's <span>need new subpath</span> flag.</p></li>
61894-
61895-
</ol>
61896-
61897-
<hr>
61898-
61899-
<p>The <dfn><code data-x="dom-Path2D-withdata">Path2D(<var>d</var>)</code></dfn>
61900-
constructor, when invoked, must run these steps:</p>
61901-
61902-
<ol>
61809+
<li><p>If <var>path</var> is a <code>Path2D</code> object, then add all subpaths of
61810+
<var>path</var> to <var>output</var> and return <var>output</var>. (In other words, it returns a
61811+
copy of the argument.)</p></li>
6190361812

6190461813
<li>
61905-
61906-
<p>Parse and interpret the <var>d</var> argument according to the SVG specification's
61907-
rules for path data, thus obtaining an SVG path. <ref spec=SVG></p>
61814+
<p>Let <var>svgPath</var> be the result of parsing and interpreting <var>path</var> according to
61815+
the SVG specification's rules for path data. <ref spec=SVG></p>
6190861816

6190961817
<p class="note">The resulting path could be empty. SVG defines error handling rules for parsing
6191061818
and applying path data.</p>
61911-
6191261819
</li>
6191361820

61914-
<li><p>Let (<var>x</var>, <var>y</var>) be the last point in the SVG
61915-
path.</p></li>
61821+
<li><p>Let (<var>x</var>, <var>y</var>) be the last point in <var>svgPath</var>.</p></li>
6191661822

61917-
<li><p>Create a new <code>Path2D</code> object and add all the subpaths in the SVG path, if any,
61918-
to that <code>Path2D</code> object. </p>
61823+
<li><p>Add all the subpaths, if any, from <var>svgPath</var> to <var>output</var>.</p></li>
6191961824

61920-
<li><p>Create a new subpath in the <code>Path2D</code> object with (<var>x</var>, <var>y</var>) as the only point in the subpath.</p></li>
61921-
61922-
<li><p>Return the <code>Path2D</code> object as the constructed object.</p></li>
61825+
<li><p>Create a new subpath in <var>output</var> with (<var>x</var>, <var>y</var>) as the only
61826+
point in the subpath.</p></li>
6192361827

61828+
<li><p>Return <var>output</var>.</p></li>
6192461829
</ol>
6192561830

6192661831
<hr>

0 commit comments

Comments
 (0)