Skip to content

Commit

Permalink
[giow] (0) Define an API to clear all the hit regions, for authors wh…
Browse files Browse the repository at this point in the history
…o don't need to use clearRect() since everything they paint is opaque.

Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=26404
Affected topics: Canvas

git-svn-id: http://svn.whatwg.org/webapps@8747 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Sep 4, 2014
1 parent 91b3199 commit 7d2f817
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 22 deletions.
31 changes: 20 additions & 11 deletions complete.html
Expand Up @@ -46067,6 +46067,7 @@ <h5 id=2dcontext>4.12.4.2 The 2D rendering context</h5>
// hit regions
void <a href=#dom-context-2d-addhitregion id=2dcontext:dom-context-2d-addhitregion>addHitRegion</a>(optional <a href=#hitregionoptions id=2dcontext:hitregionoptions>HitRegionOptions</a> options);
void <a href=#dom-context-2d-removehitregion id=2dcontext:dom-context-2d-removehitregion>removeHitRegion</a>(DOMString id);
void <a href=#dom-context-2d-clearhitregions id=2dcontext:dom-context-2d-clearhitregions>clearHitRegions</a>();

// <a href=#pixel-manipulation id=2dcontext:pixel-manipulation>pixel manipulation</a>
<a href=#imagedata id=2dcontext:imagedata>ImageData</a> <a href=#dom-context-2d-createimagedata id=2dcontext:dom-context-2d-createimagedata>createImageData</a>(double sw, double sh);
Expand Down Expand Up @@ -48729,6 +48730,10 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
same pixels before the removed regions were added, overlapping them, do not resume their
previous role.</p>

<dt><var>context</var> . <code id=hit-regions:dom-context-2d-clearhitregions><a href=#dom-context-2d-clearhitregions>clearHitRegions</a></code>()<dd>

<p>Removes all hit regions from the canvas bitmap.</p>

</dl>


Expand Down Expand Up @@ -48943,6 +48948,10 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
one.<li><p><a href=#garbage-collect-the-regions id=hit-regions:garbage-collect-the-regions-2>Garbage-collect the regions</a> of the rendering context's <a href=#scratch-bitmap id=hit-regions:scratch-bitmap-8>scratch
bitmap</a>.</ol>

<p>When the <dfn id=dom-context-2d-clearhitregions><code>clearHitRegions()</code></dfn>
method is invoked, the user agent must remove all the <a href=#hit-region id=hit-regions:hit-region-21>hit regions</a>
from the rendering context's <a href=#scratch-bitmap id=hit-regions:scratch-bitmap-9>scratch bitmap</a>'s <a href=#hit-region-list id=hit-regions:hit-region-list-10>hit region list</a>.</p>



<hr>
Expand All @@ -48959,7 +48968,7 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>

<dl class=domintro><dt><var>event</var> . <code id=hit-regions:dom-mouseevent-region-3><a href=#dom-mouseevent-region>region</a></code><dd>

<p>If the mouse was over a <a href=#hit-region id=hit-regions:hit-region-21>hit region</a>, then this returns the <a href="#hit-region's-id" id="hit-regions:hit-region's-id-4">hit region's
<p>If the mouse was over a <a href=#hit-region id=hit-regions:hit-region-22>hit region</a>, then this returns the <a href="#hit-region's-id" id="hit-regions:hit-region's-id-4">hit region's
ID</a>, if it has one.</p>

<p>Otherwise, returns null.</p>
Expand All @@ -48986,8 +48995,8 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
requirements not been applied.</p>

<ol><li><p>If the pointing device is not indicating a pixel on the <code id=hit-regions:the-canvas-element-15><a href=#the-canvas-element>canvas</a></code>, then act as
normal and abort these steps.<li><p>If the <code id=hit-regions:the-canvas-element-16><a href=#the-canvas-element>canvas</a></code> element has no <a href=#hit-region-list id=hit-regions:hit-region-list-10>hit region list</a>, then act as normal
and abort these steps.<li><p>Let <var>pixel</var> be the pixel indicated by the pointing device.<li><p>Let <var>region</var> be the <a href=#hit-region id=hit-regions:hit-region-22>hit region</a> that is <a href=#the-region-for-a-pixel id=hit-regions:the-region-for-a-pixel>the region for the pixel</a> <var>pixel</var> on this
normal and abort these steps.<li><p>If the <code id=hit-regions:the-canvas-element-16><a href=#the-canvas-element>canvas</a></code> element has no <a href=#hit-region-list id=hit-regions:hit-region-list-11>hit region list</a>, then act as normal
and abort these steps.<li><p>Let <var>pixel</var> be the pixel indicated by the pointing device.<li><p>Let <var>region</var> be the <a href=#hit-region id=hit-regions:hit-region-23>hit region</a> that is <a href=#the-region-for-a-pixel id=hit-regions:the-region-for-a-pixel>the region for the pixel</a> <var>pixel</var> on this
<code id=hit-regions:the-canvas-element-17><a href=#the-canvas-element>canvas</a></code> element's bitmap, if any.<li><p>If there is no <var>region</var>, then act as normal and abort these
steps.<li><p>Let <var>id</var> be the <var>region</var>'s <a href="#hit-region's-id" id="hit-regions:hit-region's-id-6">ID</a>, if any.<li><p>If there is an <var>id</var>, then initialise the event object's <code id=hit-regions:dom-mouseevent-region-4><a href=#dom-mouseevent-region>region</a></code> attribute to <var>id</var>.<li><p>Let <var>control</var> be the <a href=#the-control-represented-by-a-region id=hit-regions:the-control-represented-by-a-region>control represented by</a> <var>region</var> for this <code id=hit-regions:the-canvas-element-18><a href=#the-canvas-element>canvas</a></code>
element, if any.<li><p>If there is a <var>control</var>, then target the event object at <var>control</var> instead of the <code id=hit-regions:the-canvas-element-19><a href=#the-canvas-element>canvas</a></code> element.<li><p>Continue dispatching the event, but with the updated event object and target as given in
Expand All @@ -49005,7 +49014,7 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>

<dl class=domintro><dt><var>touch</var> . <code id=hit-regions:dom-touch-region-2><a href=#dom-touch-region>region</a></code><dd>

<p>If the <a href=#touch-point id=hit-regions:touch-point>touch point</a> was over a <a href=#hit-region id=hit-regions:hit-region-23>hit region</a> when it was first placed
<p>If the <a href=#touch-point id=hit-regions:touch-point>touch point</a> was over a <a href=#hit-region id=hit-regions:hit-region-24>hit region</a> when it was first placed
on the surface, then this returns the <a href="#hit-region's-id" id="hit-regions:hit-region's-id-7">hit region's ID</a>, if it has one.</p>

<p>Otherwise, returns null.</p>
Expand All @@ -49020,9 +49029,9 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
surface: <a href=#refsTOUCH>[TOUCH]</a></p>

<ol><li><p>If the <a href=#touch-point id=hit-regions:touch-point-3>touch point</a> is not on a pixel on the <code id=hit-regions:the-canvas-element-20><a href=#the-canvas-element>canvas</a></code>, then return
null and abort these steps.<li><p>If the <code id=hit-regions:the-canvas-element-21><a href=#the-canvas-element>canvas</a></code> element has no <a href=#hit-region-list id=hit-regions:hit-region-list-11>hit region list</a>, then return null
null and abort these steps.<li><p>If the <code id=hit-regions:the-canvas-element-21><a href=#the-canvas-element>canvas</a></code> element has no <a href=#hit-region-list id=hit-regions:hit-region-list-12>hit region list</a>, then return null
and abort these steps.<li><p>Let <var>pixel</var> be the pixel that the <a href=#touch-point id=hit-regions:touch-point-4>touch point</a> is
on.<li><p>Let <var>region</var> be the <a href=#hit-region id=hit-regions:hit-region-24>hit region</a> that is <a href=#the-region-for-a-pixel id=hit-regions:the-region-for-a-pixel-2>the region for the pixel</a> <var>pixel</var> on this
on.<li><p>Let <var>region</var> be the <a href=#hit-region id=hit-regions:hit-region-25>hit region</a> that is <a href=#the-region-for-a-pixel id=hit-regions:the-region-for-a-pixel-2>the region for the pixel</a> <var>pixel</var> on this
<code id=hit-regions:the-canvas-element-22><a href=#the-canvas-element>canvas</a></code> element's bitmap, if any.<li><p>If there is no <var>region</var>, then return null and abort these
steps.<li><p>Let <var>id</var> be the <var>region</var>'s <a href="#hit-region's-id" id="hit-regions:hit-region's-id-8">ID</a>, if any, or else null.<li><p>Return <var>id</var>.</ol>

Expand All @@ -49040,17 +49049,17 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
<hr>

<p>User agents are encouraged to make use of the information present in a <code id=hit-regions:the-canvas-element-25><a href=#the-canvas-element>canvas</a></code>
element's <a href=#hit-region-list id=hit-regions:hit-region-list-12>hit region list</a> to improve the accessibility of <code id=hit-regions:the-canvas-element-26><a href=#the-canvas-element>canvas</a></code>
element's <a href=#hit-region-list id=hit-regions:hit-region-list-13>hit region list</a> to improve the accessibility of <code id=hit-regions:the-canvas-element-26><a href=#the-canvas-element>canvas</a></code>
elements.</p>

<p>Each <a href=#hit-region id=hit-regions:hit-region-25>hit region</a> should be handled in a fashion equivalent to a node in a virtual
<p>Each <a href=#hit-region id=hit-regions:hit-region-26>hit region</a> should be handled in a fashion equivalent to a node in a virtual
DOM tree rooted at the <code id=hit-regions:the-canvas-element-27><a href=#the-canvas-element>canvas</a></code> element. The hierarchy of this virtual DOM tree must
match the hierarchy of the <a href=#hit-region id=hit-regions:hit-region-26>hit regions</a>, as described by the <a href="#hit-region's-parent" id="hit-regions:hit-region's-parent-12">parent</a> of each region. Regions without a <a href="#hit-region's-parent" id="hit-regions:hit-region's-parent-13">parent</a> must be treated as children of the <code id=hit-regions:the-canvas-element-28><a href=#the-canvas-element>canvas</a></code> element for
match the hierarchy of the <a href=#hit-region id=hit-regions:hit-region-27>hit regions</a>, as described by the <a href="#hit-region's-parent" id="hit-regions:hit-region's-parent-12">parent</a> of each region. Regions without a <a href="#hit-region's-parent" id="hit-regions:hit-region's-parent-13">parent</a> must be treated as children of the <code id=hit-regions:the-canvas-element-28><a href=#the-canvas-element>canvas</a></code> element for
the purpose of this virtual DOM tree. For each node in such a DOM tree, the <a href="#hit-region's-bounding-circumference" id="hit-regions:hit-region's-bounding-circumference-2">hit region's
bounding circumference</a> gives the region of the screen to use when representing the node (if
appropriate).</p>

<p>The semantics of a <a href=#hit-region id=hit-regions:hit-region-27>hit region</a> for the purposes of this virtual DOM tree are those
<p>The semantics of a <a href=#hit-region id=hit-regions:hit-region-28>hit region</a> for the purposes of this virtual DOM tree are those
of the <a href=#the-control-represented-by-a-region id=hit-regions:the-control-represented-by-a-region-2>the control represented by the
region</a>, if it has one, or else of a non-interactive element whose ARIA role, if any, is
that given by the <a href="#hit-region's-aria-role" id="hit-regions:hit-region's-aria-role-3">hit region's ARIA role</a>, and whose textual representation, if any,
Expand All @@ -49062,7 +49071,7 @@ <h6 id=hit-regions>4.12.4.2.15 Hit regions</h6>
element's bitmap, then the element's position relative to the document should be presented as if
it was that region in the <code id=hit-regions:the-canvas-element-31><a href=#the-canvas-element>canvas</a></code> element's virtual DOM tree.</p>

<p>The semantics of a <a href=#hit-region id=hit-regions:hit-region-28>hit region</a> for the purposes of this virtual DOM tree are those
<p>The semantics of a <a href=#hit-region id=hit-regions:hit-region-29>hit region</a> for the purposes of this virtual DOM tree are those
of the <a href=#the-control-represented-by-a-region id=hit-regions:the-control-represented-by-a-region-3>the control represented by the
region</a>, if it has one, or else of a non-interactive element whose ARIA role, if any, is
that given by the <a href="#hit-region's-aria-role" id="hit-regions:hit-region's-aria-role-4">hit region's ARIA role</a>, and whose textual representation, if any,
Expand Down

0 comments on commit 7d2f817

Please sign in to comment.