hixie: Redefine getContext() so that the handling of multple context types is defined. (whatwg r5227)

hixie: Redefine getContext() so that the handling of multple context
types is defined. (whatwg r5227)

http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.4161&r2=1.4162&f=h
http://html5.org/tools/web-apps-tracker?from=5226&to=5227

===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.4161
retrieving revision 1.4162
diff -u -d -r1.4161 -r1.4162
--- Overview.html 30 Jul 2010 01:37:46 -0000 1.4161
+++ Overview.html 2 Aug 2010 22:17:02 -0000 1.4162
@@ -308,7 +308,7 @@
 
    <h1>HTML5</h1>
    <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
-   <h2 class="no-num no-toc" id="editor-s-draft-30-july-2010">Editor's Draft 30 July 2010</h2>
+   <h2 class="no-num no-toc" id="editor-s-draft-2-august-2010">Editor's Draft 2 August 2010</h2>
    <dl><dt>Latest Published Version:</dt>
     <dd><a href="http://www.w3.org/TR/html5/">http://www.w3.org/TR/html5/</a></dd>
     <dt>Latest Editor's Draft:</dt>
@@ -414,7 +414,7 @@
   Group</a> is the W3C working group responsible for this
   specification's progress along the W3C Recommendation
   track.
-  This specification is the 30 July 2010 Editor's Draft.
+  This specification is the 2 August 2010 Editor's Draft.
   </p><!-- UNDER NO CIRCUMSTANCES IS THE PRECEDING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- relationship to other work (required) --><p>Work on this specification is also done at the <a href="http://www.whatwg.org/">WHATWG</a>. The W3C HTML working group
   actively pursues convergence with the WHATWG, as required by the <a href="http://www.w3.org/2007/03/HTML-WG-charter">W3C HTML working
   group charter</a>.</p><!-- UNDER NO CIRCUMSTANCES IS THE FOLLOWING PARAGRAPH TO BE REMOVED OR EDITED WITHOUT TALKING TO IAN FIRST --><!-- required patent boilerplate --><p>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5
@@ -22942,27 +22942,93 @@
   context.fillRect(0,100,50,50);
   canvas.width = canvas.width; // clears the canvas
   context.fillRect(100,0,50,50); // only this square remains</pre>
-  </div><p>To draw on the canvas, authors must first obtain a reference to a
-  <dfn id="context">context</dfn> using the <dfn id="dom-canvas-getcontext" title="dom-canvas-getContext"><code>getContext(<var title="">contextId</var>)</code></dfn> method of the
-  <code><a href="#the-canvas-element">canvas</a></code> element.<dl class="domintro"><dt><var title="">context</var> = <var title="">canvas</var> . <code title="dom-canvas-getContext"><a href="#dom-canvas-getcontext">getContext</a></code>(<var title="">contextId</var>)</dt>
+  </div><hr><dl class="domintro"><dt><var title="">context</var> = <var title="">canvas</var> . <code title="dom-canvas-getContext"><a href="#dom-canvas-getcontext">getContext</a></code>(<var title="">contextId</var>)</dt>
 
    <dd>
 
-    <p>Returns an object that exposes an API for drawing on the canvas.</p>
+    <p>Returns an object that exposes an API for drawing on the
+    canvas. The argument specifies the desired API.</p>
 
-    <p>Returns null if the given context ID is not supported.</p>
+
+    <p>The list of defined contexts is given on the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
+    CanvasContexts page</a>. <a href="#refsWHATWGWIKI">[WHATWGWIKI]</a>
+
+    <p>Returns null if the given context ID is not supported or if the
+    canvas has already been initialised with some other (incompatible)
+    context type (e.g. trying to get a "<code title="canvas-context-2d">2d</code>" context after getting a
+    "<code title="canvas-context-webgl">webgl</code>" context).</p>
 
    </dd>
 
-  </dl><p>Contexts are defined by other specifications, for example the 2D
-  Context specification. <a href="#refs2DCONTEXT">[2DCONTEXT]</a><div class="impl">
+  </dl><div class="impl">
 
-  <p>Vendors may also define experimental contexts using the syntax
-  <code><var title="">vendorname</var>-<var title="">context</var></code>, for example, <code>moz-3d</code>.</p>
+  <p>A <code><a href="#the-canvas-element">canvas</a></code> element can have a <dfn id="primary-context">primary
+  context</dfn>, which is the first context to have been obtained for
+  that element. When created, a <code><a href="#the-canvas-element">canvas</a></code> element must not
+  have a <a href="#primary-context">primary context</a>.</p>
 
-  <p>When the UA is passed an empty string or a string specifying a
-  context that it does not support, then it must return null. String
-  comparisons must be <a href="#case-sensitive">case-sensitive</a>.</p>
+  <p>The <dfn id="dom-canvas-getcontext" title="dom-canvas-getContext"><code>getContext(<var title="">contextId</var>)</code></dfn> method of the
+  <code><a href="#the-canvas-element">canvas</a></code> element, when invoked, must run the following
+  steps:</p>
+
+  <ol><li><p>Let <var title="">contextId</var> be the argument to the
+   method.</li>
+
+   <li><p>If <var title="">contextId</var> is not the name of a
+   context supported by the user agent, return null and abort these
+   steps.</li>
+
+   <li><p>If the element has a <a href="#primary-context">primary context</a> and that
+   context's entry in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
+   CanvasContexts page</a> does not list <var title="">contextId</var>
+   as a context with which it is compatible, return null and abort
+   these steps. <a href="#refsWHATWGWIKI">[WHATWGWIKI]</a></li>
+
+   <li><p>If the element does not have a <a href="#primary-context">primary context</a>,
+   let the element's <a href="#primary-context">primary context</a> be <var title="">contextId</var>.</li>
+
+   <li><p>If the <code title="dom-canvas-getContext"><a href="#dom-canvas-getcontext">getContext()</a></code> method has
+   already been invoked on this element for the same <var title="">contextId</var>, return the same object as was returned
+   that time, and abort these steps.</li>
+
+   <li><p><dfn id="getcontext-return" title="getContext-return">Return a new object for <var title="">contextId</var></dfn>, as defined by the specification
+   given for <var title="">contextId</var>'s entry in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
+   CanvasContexts page</a>. <a href="#refsWHATWGWIKI">[WHATWGWIKI]</a></li>
+
+  </ol><p>New context types may be registered in the <a href="http://wiki.whatwg.org/wiki/CanvasContexts">WHATWG Wiki
+  CanvasContexts page</a>. <a href="#refsWHATWGWIKI">[WHATWGWIKI]</a></p>
+
+  <p>Anyone is free to edit the WHATWG Wiki CanvasContexts page at any
+  time to add a new context type. These new context types must be
+  specified with the following information:</p>
+
+  <dl><dt>Keyword</dt>
+
+   <dd><p>The value of <var title="">contextID</var> that will return
+   the object for the new API.</dd>
+
+
+   <dt>Specification</dt>
+
+   <dd><p>A link to a formal specification of the context type's
+   API. It could be another page on the Wiki, or a link to an external
+   page. If the type does not have a formal specification, an informal
+   description can be substituted until such time as a formal
+   specification is available.</dd>
+
+
+   <dt>Compatible with</dt>
+
+   <dd><p>The list of context types that are compatible with this one
+   (i.e. that operate on the same underlying bitmap). This list must
+   be transitive and symmetric; if one context type is defined as
+   compatible with another, then all types it is compatible with must
+   be compatible with all types the other is compatible with.</dd>
+
+  </dl><p>Vendors may also define experimental contexts using the syntax
+  <code><var title="">vendorname</var>-<var title="">context</var></code>, for example,
+  <code>moz-3d</code>. Such contexts should be registered in the
+  WHATWG Wiki CanvasContexts page.</p>
 
   </div><hr><dl class="domintro"><dt><var title="">url</var> = <var title="">canvas</var> . <code title="dom-canvas-toDataURL"><a href="#dom-canvas-todataurl">toDataURL</a></code>( [ <var title="">type</var>, ... ])</dt>
 
@@ -33728,7 +33794,7 @@
 
   <p>When an element with the <code title="attr-fe-autofocus"><a href="#attr-fe-autofocus">autofocus</a></code> attribute specified is
   <a href="#insert-an-element-into-a-document" title="insert an element into a document">inserted into a
-  document</a>, user agents should run the following steps:</p>~
+  document</a>, user agents should run the following steps:</p>
 
   <ol><li><p>If the <code><a href="#document">Document</a></code>'s <a href="#browsing-context">browsing context</a>
    had the <a href="#sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context
@@ -51291,8 +51357,8 @@
      deleted</a>.</li>
      <li><p>Invoke the <a href="#html-fragment-parsing-algorithm">HTML fragment parsing algorithm</a>
      with an arbitrary orphan <code><a href="#the-body-element-0">body</a></code> element owned by the
-     same <code><a href="#document">Document</a></code> as the <i><a href="#context">context</a></i> element and with
-     the <var title="">value</var> argument as <i><a href="#the-input-element">input</a></i>.</li>
+     same <code><a href="#document">Document</a></code> as the <i title="">context</i> element
+     and with the <var title="">value</var> argument as <i title="">input</i>.</li>
      <li><p>Insert the nodes returned by the previous step into the
      document at the location of the caret, firing any mutation events
      as appropriate.</li>
@@ -67187,11 +67253,7 @@
 
   </table><p class="note">See also <a href="#mediaevents">media element
   events</a>, <a href="#appcacheevents">application cache events</a>,
-  and <a href="#dndevents">drag-and-drop events</a>.<h2 class="no-num" id="references">References</h2><p class="XXX annotation"><b>Status: </b><i>Implemented and widely deployed</i></p><!--REFS--><p>All references are normative unless marked "Non-normative".</p><!-- Dates are only included for standards older than the Web, because the newer ones keep changing. --><dl><dt id="refs2DCONTEXT">[2DCONTEXT]</dt>
-   <dd><cite><a href="http://dev.w3.org/html5/2dcontext/">HTML Canvas
-   2D Context</a></cite>, I. Hickson. W3C.</dd>
-
-   <dt id="refsABNF">[ABNF]</dt>
+  and <a href="#dndevents">drag-and-drop events</a>.<h2 class="no-num" id="references">References</h2><p class="XXX annotation"><b>Status: </b><i>Implemented and widely deployed</i></p><!--REFS--><p>All references are normative unless marked "Non-normative".</p><!-- Dates are only included for standards older than the Web, because the newer ones keep changing. --><dl><dt id="refsABNF">[ABNF]</dt>
    <dd><cite><a href="http://www.ietf.org/rfc/std/std68.txt">Augmented
    BNF for Syntax Specifications: ABNF</a></cite>, D. Crocker,
    P. Overell. IETF.</dd>

Received on Monday, 2 August 2010 22:17:50 UTC