[html5] r5227 - [giow] (2) Redefine getContext() so that the handling of multple context types i [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Aug 2 15:16:58 PDT 2010


Author: ianh
Date: 2010-08-02 15:16:55 -0700 (Mon, 02 Aug 2010)
New Revision: 5227

Modified:
   complete.html
   index
   source
Log:
[giow] (2) Redefine getContext() so that the handling of multple context types is defined.

Modified: complete.html
===================================================================
--- complete.html	2010-07-30 01:37:40 UTC (rev 5226)
+++ complete.html	2010-08-02 22:16:55 UTC (rev 5227)
@@ -209,7 +209,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
    <hgroup><h1>Web Applications 1.0</h1>
-    <h2 class="no-num no-toc">Draft Standard — 30 July 2010</h2>
+    <h2 class="no-num no-toc">Draft Standard — 2 August 2010</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -29576,38 +29576,100 @@
   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.</p>
+  <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>
 
-  <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>
+<!--2DCONTEXT-->
 
+    <p>This specification defines the "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>" context below. There is also
+    a specification that defines a "<code title=canvas-context-webgl>webgl</code>" context. <a href=#refsWEBGL>[WEBGL]</a></p>
+
+<!--2DCONTEXT-->
+
+    <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><a href=#canvas-context-2d>2d</a></code>" context after getting a
+    "<code title=canvas-context-webgl>webgl</code>" context).</p>
+
    </dd>
 
-  </dl><!--2DCONTEXT--><p>This specification only defines one context, with the name "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>". <span class=impl>If <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> is called with
-  that exact string for its <var title="">contextId</var> argument,
-  then the UA must return a reference to an object implementing
-  <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>. Other specifications may
-  define their own contexts, which would return different
-  objects.</span></p>
+  </dl><div class=impl>
 
-  <!--2DCONTEXT-->
+  <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>
 
-  <div class=impl>
+  <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>
 
-  <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>
+  <ol><li><p>Let <var title="">contextId</var> be the argument to the
+   method.</li>
 
-  <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>
+   <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>
@@ -29708,20 +29770,18 @@
 
   <!-- v2: we're on v4. suggestions for next version are marked v5. -->
 
-  <p>When the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code>
-  method of a <code><a href=#the-canvas-element>canvas</a></code> element is invoked with <dfn id=canvas-context-2d title=canvas-context-2d><code>2d</code></dfn> as the argument, a
-  <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object is returned.</p>
-
   
 
+  <p>This specification defines the <dfn id=canvas-context-2d title=canvas-context-2d><code>2d</code></dfn> context type, whose
+  API is implemented using the <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>
+  interface.</p>
+
   <div class=impl>
 
+  <p>When the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code>
+  method of a <code><a href=#the-canvas-element>canvas</a></code> element is is to <a href=#getcontext-return title=getContext-return>return a new object for the <var title="">contextId</var></a> <code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>, the user agent must return a
+  new <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object.</p>
 
-  <p>There is only one <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object
-  per canvas, so calling the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> method with the
-  <code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code> argument a second time
-  must return the same object.</p>
-
   </div>
 
   <p>The 2D context represents a flat Cartesian surface whose origin
@@ -44681,7 +44741,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
@@ -68773,8 +68833,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>
@@ -94540,6 +94600,10 @@
    addresses in HTML5</a></cite>, D. Connolly,
    C. Sperberg-McQueen.</dd>
 
+   <dt id=refsWEBGL>[WEBGL]</dt>
+   <dd><cite><a href=https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html>WebGL
+   Specification</a></cite>, C. Marrin. Khronos Group.</dd>
+
    <dt id=refsWEBIDL>[WEBIDL]</dt>
    <!--
    <dd><cite><a href="http://www.w3.org/TR/WebIDL/">Web

Modified: index
===================================================================
--- index	2010-07-30 01:37:40 UTC (rev 5226)
+++ index	2010-08-02 22:16:55 UTC (rev 5227)
@@ -213,7 +213,7 @@
 
   <header class=head id=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
    <hgroup><h1>HTML5 (including next generation additions still in development)</h1>
-    <h2 class="no-num no-toc">Draft Standard — 30 July 2010</h2>
+    <h2 class="no-num no-toc">Draft Standard — 2 August 2010</h2>
    </hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
    <p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
    <!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -29503,38 +29503,100 @@
   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.</p>
+  <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>
 
-  <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>
+<!--2DCONTEXT-->
 
+    <p>This specification defines the "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>" context below. There is also
+    a specification that defines a "<code title=canvas-context-webgl>webgl</code>" context. <a href=#refsWEBGL>[WEBGL]</a></p>
+
+<!--2DCONTEXT-->
+
+    <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><a href=#canvas-context-2d>2d</a></code>" context after getting a
+    "<code title=canvas-context-webgl>webgl</code>" context).</p>
+
    </dd>
 
-  </dl><!--2DCONTEXT--><p>This specification only defines one context, with the name "<code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>". <span class=impl>If <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> is called with
-  that exact string for its <var title="">contextId</var> argument,
-  then the UA must return a reference to an object implementing
-  <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>. Other specifications may
-  define their own contexts, which would return different
-  objects.</span></p>
+  </dl><div class=impl>
 
-  <!--2DCONTEXT-->
+  <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>
 
-  <div class=impl>
+  <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>
 
-  <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>
+  <ol><li><p>Let <var title="">contextId</var> be the argument to the
+   method.</li>
 
-  <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>
+   <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>
@@ -29635,20 +29697,18 @@
 
   <!-- v2: we're on v4. suggestions for next version are marked v5. -->
 
-  <p>When the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code>
-  method of a <code><a href=#the-canvas-element>canvas</a></code> element is invoked with <dfn id=canvas-context-2d title=canvas-context-2d><code>2d</code></dfn> as the argument, a
-  <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object is returned.</p>
-
   
 
+  <p>This specification defines the <dfn id=canvas-context-2d title=canvas-context-2d><code>2d</code></dfn> context type, whose
+  API is implemented using the <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>
+  interface.</p>
+
   <div class=impl>
 
+  <p>When the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code>
+  method of a <code><a href=#the-canvas-element>canvas</a></code> element is is to <a href=#getcontext-return title=getContext-return>return a new object for the <var title="">contextId</var></a> <code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code>, the user agent must return a
+  new <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object.</p>
 
-  <p>There is only one <code><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object
-  per canvas, so calling the <code title=dom-canvas-getContext><a href=#dom-canvas-getcontext>getContext()</a></code> method with the
-  <code title=canvas-context-2d><a href=#canvas-context-2d>2d</a></code> argument a second time
-  must return the same object.</p>
-
   </div>
 
   <p>The 2D context represents a flat Cartesian surface whose origin
@@ -44608,7 +44668,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
@@ -68726,8 +68786,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>
@@ -87709,6 +87769,10 @@
    Guidelines (WCAG) 2.0</a></cite>, B. Caldwell, M. Cooper, L. Reid,
    G. Vanderheiden. W3C.</dd>
 
+   <dt id=refsWEBGL>[WEBGL]</dt>
+   <dd><cite><a href=https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html>WebGL
+   Specification</a></cite>, C. Marrin. Khronos Group.</dd>
+
    <dt id=refsWEBIDL>[WEBIDL]</dt>
    <!--
    <dd><cite><a href="http://www.w3.org/TR/WebIDL/">Web

Modified: source
===================================================================
--- source	2010-07-30 01:37:40 UTC (rev 5226)
+++ source	2010-08-02 22:16:55 UTC (rev 5227)
@@ -32327,11 +32327,7 @@
   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>context</dfn> using the <dfn
-  title="dom-canvas-getContext"><code>getContext(<var
-  title="">contextId</var>)</code></dfn> method of the
-  <code>canvas</code> element.</p>
+  <hr>
 
   <dl class="domintro">
 
@@ -32339,41 +32335,123 @@
 
    <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>
+<!--END w3c-html--><!--2DCONTEXT-->
 
+    <p>This specification defines the "<code
+    title="canvas-context-2d">2d</code>" context below. There is also
+    a specification that defines a "<code
+    title="canvas-context-webgl">webgl</code>" context. <a
+    href="#refsWEBGL">[WEBGL]</a></p>
+
+<!--START w3c-html--><!--2DCONTEXT-->
+
+    <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>
 
-  <!--END w3c-html--><!--2DCONTEXT-->
+  <div class="impl">
 
-  <p>This specification only defines one context, with the name "<code
-  title="canvas-context-2d">2d</code>". <span class="impl">If <code
-  title="dom-canvas-getContext">getContext()</code> is called with
-  that exact string for its <var title="">contextId</var> argument,
-  then the UA must return a reference to an object implementing
-  <code>CanvasRenderingContext2D</code>. Other specifications may
-  define their own contexts, which would return different
-  objects.</span></p>
+  <p>A <code>canvas</code> element can have a <dfn>primary
+  context</dfn>, which is the first context to have been obtained for
+  that element. When created, a <code>canvas</code> element must not
+  have a <span>primary context</span>.</p>
 
-  <!--START w3c-html--><!--2DCONTEXT-->
-  <!--END complete--><!--END epub--><!--END html-->
-  <p>Contexts are defined by other specifications, for example the 2D
-  Context specification. <a href="#refs2DCONTEXT">[2DCONTEXT]</a></p>
-  <!--START complete--><!--START epub--><!--START html-->
+  <p>The <dfn title="dom-canvas-getContext"><code>getContext(<var
+  title="">contextId</var>)</code></dfn> method of the
+  <code>canvas</code> element, when invoked, must run the following
+  steps:</p>
 
-  <div class="impl">
+  <ol>
 
+   <li><p>Let <var title="">contextId</var> be the argument to the
+   method.</p></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.</p></li>
+
+   <li><p>If the element has a <span>primary context</span> 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></p></li>
+
+   <li><p>If the element does not have a <span>primary context</span>,
+   let the element's <span>primary context</span> be <var
+   title="">contextId</var>.</p></li>
+
+   <li><p>If the <code
+   title="dom-canvas-getContext">getContext()</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.</p></li>
+
+   <li><p><dfn 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></p></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.</p></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.</p></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.</p></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>.</p>
+  title="">context</var></code>, for example,
+  <code>moz-3d</code>. Such contexts should be registered in the
+  WHATWG Wiki CanvasContexts page.</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 <span>case-sensitive</span>.</p>
-
   </div>
 
   <hr>
@@ -32497,28 +32575,22 @@
 
   <!-- v2: we're on v4. suggestions for next version are marked v5. -->
 
-  <p>When the <code title="dom-canvas-getContext">getContext()</code>
-  method of a <code>canvas</code> element is invoked with <dfn
-  title="canvas-context-2d"><code>2d</code></dfn> as the argument, a
-  <code>CanvasRenderingContext2D</code> object is returned.</p>
-
   <!--START 2dcontext-->
 
+  <p>This specification defines the <dfn
+  title="canvas-context-2d"><code>2d</code></dfn> context type, whose
+  API is implemented using the <code>CanvasRenderingContext2D</code>
+  interface.</p>
+
   <div class="impl">
 
-  <!--END html--><!--END complete--><!--END epub-->
   <p>When the <code title="dom-canvas-getContext">getContext()</code>
-  method of a <code>canvas</code> element is invoked with <dfn
-  title="canvas-context-2d"><code>2d</code></dfn> as the argument, a
-  <code>CanvasRenderingContext2D</code> object must be returned.</p>
-  <!--START html--><!--START complete--><!--START epub-->
+  method of a <code>canvas</code> element is is to <span
+  title="getContext-return">return a new object for the <var
+  title="">contextId</var></span> <code
+  title="canvas-context-2d">2d</code>, the user agent must return a
+  new <code>CanvasRenderingContext2D</code> object.</p>
 
-  <p>There is only one <code>CanvasRenderingContext2D</code> object
-  per canvas, so calling the <code
-  title="dom-canvas-getContext">getContext()</code> method with the
-  <code title="canvas-context-2d">2d</code> argument a second time
-  must return the same object.</p>
-
   </div>
 
   <p>The 2D context represents a flat Cartesian surface whose origin
@@ -50022,7 +50094,7 @@
   <p>When an element with the <code
   title="attr-fe-autofocus">autofocus</code> attribute specified is
   <span title="insert an element into a document">inserted into a
-  document</span>, user agents should run the following steps:</p>~
+  document</span>, user agents should run the following steps:</p>
 
   <ol>
 
@@ -78038,8 +78110,9 @@
      deleted</a>.</p></li>
      <li><p>Invoke the <span>HTML fragment parsing algorithm</span>
      with an arbitrary orphan <code>body</code> element owned by the
-     same <code>Document</code> as the <i>context</i> element and with
-     the <var title="">value</var> argument as <i>input</i>.</p></li>
+     same <code>Document</code> as the <i title="">context</i> element
+     and with the <var title="">value</var> argument as <i
+     title="">input</i>.</p></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.</p></li>
@@ -108456,6 +108529,11 @@
    addresses in HTML5</a></cite>, D. Connolly,
    C. Sperberg-McQueen.</dd>
 
+   <dt id="refsWEBGL">[WEBGL]</dt>
+   <dd><cite><a
+   href="https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/doc/spec/WebGL-spec.html">WebGL
+   Specification</a></cite>, C. Marrin. Khronos Group.</dd>
+
    <dt id="refsWEBIDL">[WEBIDL]</dt>
    <!--
    <dd><cite><a href="http://www.w3.org/TR/WebIDL/">Web




More information about the Commit-Watchers mailing list