Add isPointIn{Fill,Stroke} methods, and an SVGMarkerList to access the markers painted on a markable element. (ACTION-3275)
authorCameron McCormack <cam@mcc.id.au>
Sat, 15 Sep 2012 02:15:32 +1000
changeset 369 9f46c2f1cb89
parent 368 13274fa208d7
child 370 36db2d0d9b62
Add isPointIn{Fill,Stroke} methods, and an SVGMarkerList to access the markers painted on a markable element. (ACTION-3275)
master/definitions.xml
master/painting.html
master/paths.html
master/shapes.html
master/text.html
master/types.html
--- a/master/definitions.xml	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/definitions.xml	Sat Sep 15 02:15:32 2012 +1000
@@ -1057,6 +1057,7 @@
   <interface name='SVGLocatableElement' href='types.html#InterfaceSVGLocatableElement'/>
   <interface name='SVGTransformableElement' href='types.html#InterfaceSVGTransformableElement'/>
   <interface name='SVGGraphicsElement' href='types.html#InterfaceSVGGraphicsElement'/>
+  <interface name='SVGGeometryElement' href='types.html#InterfaceSVGGeometryElement'/>
   <interface name='SVGDefinitionElement' href='types.html#InterfaceSVGDefinitionElement'/>
   <interface name='SVGTests' href='types.html#InterfaceSVGTests'/>
   <interface name='SVGURIReference' href='types.html#InterfaceSVGURIReference'/>
@@ -1108,7 +1109,10 @@
   <interface name='SVGGlyphRefElement' href='text.html#InterfaceSVGGlyphRefElement'/>
   <interface name='SVGTextContentElement' href='text.html#InterfaceSVGTextContentElement'/>
   <interface name='SVGTextPositioningElement' href='text.html#InterfaceSVGTextPositioningElement'/>
+  <interface name='SVGMarkableElement' href='painting.html#InterfaceSVGMarkableElement'/>
   <interface name='SVGMarkerElement' href='painting.html#InterfaceSVGMarkerElement'/>
+  <interface name='SVGMarkerInstance' href='painting.html#InterfaceSVGMarkerInstance'/>
+  <interface name='SVGMarkerList' href='painting.html#InterfaceSVGMarkerList'/>
   <interface name='SVGColorProfileElement' href='color.html#InterfaceSVGColorProfileElement'/>
   <interface name='SVGColorProfileRule' href='color.html#InterfaceSVGColorProfileRule'/>
   <interface name='SVGLinearGradientElement' href='pservers.html#InterfaceSVGLinearGradientElement'/>
--- a/master/painting.html	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/painting.html	Sat Sep 15 02:15:32 2012 +1000
@@ -3390,6 +3390,161 @@
 <p class="issue">There are some missing definitions of 
 SVGPaint members here.  The interface might be going away, however.</p>
 
+
+<div class="ready-for-wg-review">
+<h3 id="InterfaceSVGMarkerInstance">Interface SVGMarkerInstance</h3>
+
+<p>The <a>SVGMarkerInstance</a> interface is used to represent an instance
+of a marker that is on a <a>markable element</a>.  An <a>SVGMarkerInstance</a>
+can represent any kind of marker, including <a>positioned markers</a>.</p>
+
+<p class="issue">What should we do about liveness?  If it is live, we
+could have it know what index it is for, and always return information
+about the marker at that index (and return null for the element if
+that index is no longer valid).</p>
+
+<pre class='idl'>interface <b>SVGMarkerInstance</b> {
+  readonly attribute <a>SVGMarkerElement</a> element;
+  readonly attribute float position;
+  readonly attribute <a>SVGPoint</a> point;
+  readonly attribute float angle;
+};</pre>
+
+<dl class="interface">
+  <dt class="attributes-header">Attributes:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGMarkerInstance__element" class="attribute first-child"><b>element</b><span class="idl-type-parenthetical"> (readonly <a>SVGMarkerElement</a>)</span></dt>
+      <dd class="attribute">The <a>'marker element'</a> element that defines
+      the marker.  If the marker is a <a>vertex marker</a>, <a>segment marker</a>
+      or <a>repeating marker</a>, then this will be the <a>'marker element'</a>
+      element that the relevant marker property referenced.  If the marker is
+      a <a>positioned marker</a>, then this will be the child <a>'marker element'</a>
+      element of the <a>markable element</a>.</dd>
+
+      <dt id="__svg__SVGMarkerInstance__position" class="attribute"><b>position</b><span class="idl-type-parenthetical"> (readonly float)</span></dt>
+      <dd class="attribute">The distance along the <a>equivalent path</a> of the
+      <a>markable element</a> that the marker is positioned at.</dd>
+
+      <dt id="__svg__SVGMarkerInstance__point" class="attribute"><b>point</b><span class="idl-type-parenthetical"> (readonly <a>SVGPoint</a>)</span></dt>
+      <dd class="attribute">The point, in the user space of the
+      <a>markable element</a>, that the marker is positioned at.
+      The <a>SVGPoint</a> object is read only.</dd>
+
+      <dt id="__svg__SVGMarkerInstance__angle" class="attribute"><b>angle</b><span class="idl-type-parenthetical"> (readonly float)</span></dt>
+      <dd class="attribute">The orientation of the marker relative to a
+      vector pointing in the direction of the positive y-axis of the
+      <a>markable element</a>'s user space.</dd>
+    </dl>
+  </dd>
+</dl>
+
+
+<h3 id="InterfaceSVGMarkerList">Interface SVGMarkerList</h3>
+
+<p>The <a>SVGMarkerList</a> interface is used to expose the list of markers that
+are painted on a given <a>markable element</a>.  This list includes all
+<a>vertex markers</a>, <a>segment markers</a>, <a>repeating markers</a> and
+<a>positioned markers</a>.  The list of <a>SVGMarkerInstance</a> objects
+is maintained in the order that the markers are painted (see
+<a href='painting.html#Markers'>Markers</a>).</p>
+
+<pre class='idl'>interface <b>SVGMarkerList</b> {
+  readonly attribute unsigned long <a href='#__svg__SVGMarkerList__length'>length</a>;
+  getter <a>SVGMarkerInstance</a>? <a href='#__svg__SVGMarkerList__item'>item</a>(unsigned long index);
+};</pre>
+
+<dl class="interface">
+  <dt class="attributes-header">Attributes:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGMarkerList__length" class="attribute first-child"><b>length</b><span class="idl-type-parenthetical"> (readonly unsigned long)</span></dt>
+      <dd class="attribute">The number of markers on this element.</dd>
+    </dl>
+  </dd>
+  <dt class="operations-header">Operations:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGMarkerList__item" class="operation first-child"><a>SVGMarkerInstance</a>? <b>item</b>(unsigned long <var>index</var>)</dt>
+      <dd class="operation">
+        Gets the <a>SVGMarkerInstance</a> at the given position in the
+        list of markers on this element.
+        <dl class="operation">
+          <dt class="parameters-header">Parameters</dt>
+          <dd>
+            <ol class="parameters">
+              <li class="parameter first-child">
+                <div>unsigned long <var>index</var></div>
+                <div>The index of the <a>SVGMarkerInstance</a> to return.</div>
+              </li>
+            </ol>
+          </dd>
+          <dt class="returns-header">Returns</dt>
+          <dd>Returns the <a>SVGMarkerInstance</a> at position <var>index</var>
+          in the list of markers on this element, or null if <var>index</var>
+          is out of range.</dd>
+        </dl>
+      </dd>
+    </dl>
+  </dd>
+</dl>
+
+
+<h3 id="InterfaceSVGMarkableElement">Interface SVGMarkableElement</h3>
+
+<p>The <a>SVGMarkableElement</a> interface is implemented on all
+<a>markable elements</a>, and provides access to the markers that are placed on
+the element's path.</p>
+
+<pre class='idl'>[NoInterfaceObject]
+interface <b>SVGMarkableElement</b> {
+  readonly attribute <a>SVGMarkerList</a> <a href='#__svg__SVGMarkableElement__markers'>markers</a>;
+
+  long <a href='#__svg__SVGMarkableElement__getMarkerIndexFromPoint'>getMarkerIndexFromPoint</a>(<a>SVGPoint</a> point);
+};</pre>
+
+<dl class="interface">
+  <dt class="attributes-header">Attributes:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGMarkableElement__markers" class="attribute first-child"><b>markers</b><span class="idl-type-parenthetical"> (readonly <a>SVGMarkerList</a>)</span></dt>
+      <dd class="attribute">The list of markers on this element.</dd>
+    </dl>
+  </dd>
+  <dt class="operations-header">Operations:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGMarkableElement__getMarkerIndexFromPoint" class="operation first-child">long <b>getMarkerIndexFromPoint</b>(<a>SVGPoint</a> point)</dt>
+      <dd class="operation">
+        Returns the index into the <a>SVGMarkerList</a> of the marker that is at
+        the specified point.  Normal hit testing rules apply; the value of the
+        <a>'pointer-events'</a> property on the elements that comprise the markers,
+        as well as its value on this element, is honored, and the top-most marker
+        is selected when there are multiple markers whose content is at the given
+        point.
+        <dl class="operation">
+          <dt class="parameters-header">Parameters</dt>
+          <dd>
+            <ol class="parameters">
+              <li class="parameter first-child">
+                <div><a>SVGPoint</a> <var>point</var></div>
+                <div>The point to check for intersection with the markers
+                on this element.  The <a>SVGPoint</a> is interpreted as a
+                point in the user space of this element.</div>
+              </li>
+            </ol>
+          </dd>
+          <dt class="returns-header">Returns</dt>
+          <dd>The index into this element's <a>SVGMarkerList</a> of the marker
+          at the given point, or -1 if there is no such marker.</dd>
+        </dl>
+      </dd>
+    </dl>
+  </dd>
+</dl>
+</div>
+
+
 <h3 id="InterfaceSVGMarkerElement">Interface SVGMarkerElement</h3>
 
 
--- a/master/paths.html	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/paths.html	Sat Sep 15 02:15:32 2012 +1000
@@ -2485,7 +2485,7 @@
 
 The <a>SVGPathElement</a> interface corresponds to the <a>'path'</a>
 element.
-<pre class="idl">interface <b>SVGPathElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGPathElement</b> : <a>SVGGeometryElement</a> {
 
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedNumber">SVGAnimatedNumber</a> <a href="paths.html#__svg__SVGPathElement__pathLength">pathLength</a>;
 
@@ -2513,7 +2513,8 @@
   <a class="idlinterface" href="paths.html#InterfaceSVGPathSegCurvetoQuadraticSmoothRel">SVGPathSegCurvetoQuadraticSmoothRel</a> <a href="paths.html#__svg__SVGPathElement__createSVGPathSegCurvetoQuadraticSmoothRel">createSVGPathSegCurvetoQuadraticSmoothRel</a>(float x, float y);
 };
 
-<a>SVGPathElement</a> implements <a>SVGAnimatedPathData</a>;</pre><dl class="interface">
+<a>SVGPathElement</a> implements <a>SVGAnimatedPathData</a>;
+<a>SVGPathElement</a> implements <a>SVGMarkableElement</a>;</pre><dl class="interface">
 <dt class="attributes-header">Attributes:</dt>
 <dd>
 <dl class="attributes">
--- a/master/shapes.html	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/shapes.html	Sat Sep 15 02:15:32 2012 +1000
@@ -92,7 +92,7 @@
   <tr>
     <th>DOM Interface:</th>
     <td>
-<pre class="idl">interface <b>SVGRectElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGRectElement</b> : <a>SVGGeometryElement</a> {
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__x">x</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__y">y</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__width">width</a>;
@@ -683,7 +683,7 @@
 
 The <a>SVGRectElement</a> interface corresponds to the <a>'rect'</a>
 element.
-<pre class="idl">interface <b>SVGRectElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGRectElement</b> : <a>SVGGeometryElement</a> {
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__x">x</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__y">y</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGRectElement__width">width</a>;
@@ -756,7 +756,7 @@
 
 The <a>SVGCircleElement</a> interface corresponds to the <a>'circle'</a>
 element.
-<pre class="idl">interface <b>SVGCircleElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGCircleElement</b> : <a>SVGGeometryElement</a> {
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGCircleElement__cx">cx</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGCircleElement__cy">cy</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGCircleElement__r">r</a>;
@@ -802,7 +802,7 @@
 
 The <a>SVGEllipseElement</a> interface corresponds to the <a>'ellipse'</a>
 element.
-<pre class="idl">interface <b>SVGEllipseElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGEllipseElement</b> : <a>SVGGeometryElement</a> {
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGEllipseElement__cx">cx</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGEllipseElement__cy">cy</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGEllipseElement__rx">rx</a>;
@@ -857,12 +857,14 @@
 
 The <a>SVGLineElement</a> interface corresponds to the <a>'line'</a>
 element.
-<pre class="idl">interface <b>SVGLineElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGLineElement</b> : <a>SVGGeometryElement</a> {
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGLineElement__x1">x1</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGLineElement__y1">y1</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGLineElement__x2">x2</a>;
   readonly attribute <a class="idlinterface" href="types.html#InterfaceSVGAnimatedLength">SVGAnimatedLength</a> <a href="shapes.html#__svg__SVGLineElement__y2">y2</a>;
-};</pre><dl class="interface">
+};
+
+<a>SVGLineElement</a> implements <a>SVGMarkableElement</a>;</pre><dl class="interface">
 <dt class="attributes-header">Attributes:</dt>
 <dd>
 <dl class="attributes">
@@ -962,10 +964,11 @@
 
 <p>The <a>SVGPolylineElement</a> interface corresponds to the <a>'polyline'</a> element.</p>
 
-<pre class="idl">interface <b>SVGPolylineElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGPolylineElement</b> : <a>SVGGeometryElement</a> {
 };
 
-<a>SVGPolylineElement</a> implements <a>SVGAnimatedPoints</a>;</pre>
+<a>SVGPolylineElement</a> implements <a>SVGAnimatedPoints</a>;
+<a>SVGPolylineElement</a> implements <a>SVGMarkableElement</a>;</pre>
 
 </edit:with>
 
@@ -976,10 +979,11 @@
 
 <p>The <a>SVGPolygonElement</a> interface corresponds to the <a>'polygon'</a> element.</p>
 
-<pre class="idl">interface <b>SVGPolygonElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGPolygonElement</b> : <a>SVGGeometryElement</a> {
 };
 
-<a>SVGPolygonElement</a> implements <a>SVGAnimatedPoints</a>;</pre>
+<a>SVGPolygonElement</a> implements <a>SVGAnimatedPoints</a>;
+<a>SVGPolygonElement</a> implements <a>SVGMarkableElement</a>;</pre>
 
 </edit:with>
 
--- a/master/text.html	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/text.html	Sat Sep 15 02:15:32 2012 +1000
@@ -4759,7 +4759,7 @@
 will return 2 since there are two UTF-16 code units (the surrogate pair)
 used to represent that one character.
 </p>
-<pre class="idl">interface <b>SVGTextContentElement</b> : <a>SVGGraphicsElement</a> {
+<pre class="idl">interface <b>SVGTextContentElement</b> : <a>SVGGeometryElement</a> {
 
   // lengthAdjust Types
   const unsigned short <a href="text.html#__svg__SVGTextContentElement__LENGTHADJUST_UNKNOWN">LENGTHADJUST_UNKNOWN</a> = 0;
--- a/master/types.html	Fri Sep 14 20:03:58 2012 +1000
+++ b/master/types.html	Sat Sep 15 02:15:32 2012 +1000
@@ -4490,6 +4490,73 @@
 <a>SVGGraphicsElement</a> implements <a>SVGTests</a>;</pre>
 
 
+<div class="ready-for-wg-review">
+<h3 id="InterfaceSVGGeometryElement">Interface SVGGeometryElement</h3>
+
+<p>Interface <a>SVGGeometryElement</a> represents SVG elements whose rendering
+is defined by geometry and which can be filled and stroked.  This includes
+paths, text and the basic shapes.</p>
+
+<pre class="idl">interface <b>SVGGeometryElement</b> : <a>SVGGraphicsElement</a> {
+  bool isPointInFill(<a>SVGPoint</a> point);
+  bool isPointInStroke(<a>SVGPoint</a> point);
+};</pre>
+
+<dl class="interface">
+  <dt class="operations-header">Operations:</dt>
+  <dd>
+    <dl class="attributes">
+      <dt id="__svg__SVGGeometryElement__isPointInFill" class="operation first-child">bool <b>isPointInFill</b>(<a>SVGPoint</a> point)</dt>
+      <dd class="operation">
+        Returns whether the specified point is within the fill of the element.
+        Normal hit testing rules apply; the value of the <a>'pointer-events'</a>
+	property on the element determines whether a point is considered to be
+	within the fill.
+        <dl class="operation">
+          <dt class="parameters-header">Parameters</dt>
+          <dd>
+            <ol class="parameters">
+              <li class="parameter first-child">
+                <div><a>SVGPoint</a> <var>point</var></div>
+                <div>The point to check for intersection with the fill
+                of this element.  The <a>SVGPoint</a> is interpreted as a
+                as a point in the user space of this element.</div>
+              </li>
+            </ol>
+          </dd>
+          <dt class="returns-header">Returns</dt>
+          <dd>true if the point is within the fill of this shape,
+	  or false otherwise.</dd>
+        </dl>
+      </dd>
+      <dt id="__svg__SVGGeometryElement__isPointInStroke" class="operation">bool <b>isPointInStroke</b>(<a>SVGPoint</a> point)</dt>
+      <dd class="operation">
+        Returns whether the specified point is within the stroke of the element.
+        Normal hit testing rules apply; the value of the <a>'pointer-events'</a>
+	property on the element determines whether a point is considered to be
+	within the stroke.
+        <dl class="operation">
+          <dt class="parameters-header">Parameters</dt>
+          <dd>
+            <ol class="parameters">
+              <li class="parameter first-child">
+                <div><a>SVGPoint</a> <var>point</var></div>
+                <div>The point to check for intersection with the stroke
+                of this element.  The <a>SVGPoint</a> is interpreted as a
+                as a point in the user space of this element.</div>
+              </li>
+            </ol>
+          </dd>
+          <dt class="returns-header">Returns</dt>
+          <dd>true if the point is within the stroke of this shape,
+	  or false otherwise.</dd>
+        </dl>
+      </dd>
+    </dl>
+  </dd>
+</dl>
+</div>
+
 <h3 id="InterfaceSVGDefinitionElement">Interface SVGDefinitionElement</h3>
 
 <p>Interface <a>SVGGraphicsElement</a> represents SVG elements whose primary purpose