HTML5 Tracker

Diff (omit for latest revision)
Filter

Short URL: http://html5.org/r/7023

SVNBugCommentTime (UTC)
7023[Gecko] [Internet Explorer] [Opera] [Webkit] Path objects and drawing text to a path or along a path. Note that there's not yet any way to _use_ the Path objects. That's next...2012-03-09 23:58
Index: source
===================================================================
--- source	(revision 7022)
+++ source	(revision 7023)
@@ -40681,8 +40681,22 @@
   readonly attribute unsigned long <span title="dom-imagedata-width">width</span>;
   readonly attribute unsigned long <span title="dom-imagedata-height">height</span>;
   readonly attribute <span>Uint8ClampedArray</span> <span title="dom-imagedata-data">data</span>;
-};</pre>
+};
 
+[<span title="dom-Path">Constructor</span>(optional <span>Element</span> scope)]
+interface <dfn>Path</dfn> {
+  void <span title="dom-path-addFill">addFill</span>(<span>Path</span> path);
+  void <span title="dom-path-addStroke">addStroke</span>(<span>Path</span> path);
+  void <span title="dom-path-addFillText">addFillText</span>(DOMString text, double x, double y, optional double maxWidth);
+  void <span title="dom-path-addStrokeText">addStrokeText</span>(DOMString text, double x, double y, optional double maxWidth);
+  void <span title="dom-path-addFillText">addFillText</span>(DOMString text, <span>Path</span> path, optional double maxWidth);
+  void <span title="dom-path-addStrokeText">addStrokeText</span>(DOMString text, <span>Path</span> path, optional double maxWidth);
+};
+<span>Path</span> implements <span>CanvasTransformation</span>;
+<span>Path</span> implements <span>CanvasLineStyles</span>;
+<span>Path</span> implements <span>CanvasPathMethods</span>;
+<span>Path</span> implements <span>CanvasText</span>;</pre>
+
  <!-- ARC-ORDER note (see above):
       some demos rely on the precise order of the arc() and arcTo()
       methods, see https://bugzilla.mozilla.org/show_bug.cgi?id=623437
@@ -40751,6 +40765,10 @@
   no way to know which is the "element in question" at the time that
   the color is specified.</p>
 
+  <p class="note">Similar concerns exist with font-related properties;
+  the rules for those are described in detail in the relevant section
+  below.</p>
+
   </div>
 
 
@@ -40868,6 +40886,7 @@
   <dl class="domintro">
 
    <dt><var title="">context</var> . <code title="dom-context-2d-scale">scale</code>(<var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-scale">scale</code>(<var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -40876,6 +40895,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-rotate">rotate</code>(<var title="">angle</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-rotate">rotate</code>(<var title="">angle</var>)</dt>
 
    <dd>
 
@@ -40884,6 +40904,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-translate">translate</code>(<var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-translate">translate</code>(<var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -40892,6 +40913,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-transform">transform</code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-transform">transform</code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt>
 
    <dd>
 
@@ -40900,6 +40922,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-setTransform">setTransform</code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-setTransform">setTransform</code>(<var title="">a</var>, <var title="">b</var>, <var title="">c</var>, <var title="">d</var>, <var title="">e</var>, <var title="">f</var>)</dt>
 
    <dd>
 
@@ -40998,6 +41021,7 @@
   <dl class="domintro">
 
    <dt><var title="">context</var> . <code title="dom-context-2d-lineWidth">lineWidth</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-lineWidth">lineWidth</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41009,6 +41033,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-lineCap">lineCap</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-lineCap">lineCap</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41023,6 +41048,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-lineJoin">lineJoin</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-lineJoin">lineJoin</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41037,6 +41063,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-miterLimit">miterLimit</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-miterLimit">miterLimit</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41200,6 +41227,7 @@
   <dl class="domintro">
 
    <dt><var title="">context</var> . <code title="dom-context-2d-font">font</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-font">font</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41215,6 +41243,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-textAlign">textAlign</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-textAlign">textAlign</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41229,6 +41258,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-textBaseline">textBaseline</code> [ = <var title="">value</var> ]</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-textBaseline">textBaseline</code> [ = <var title="">value</var> ]</dt>
 
    <dd>
 
@@ -41244,9 +41274,13 @@
 
   <div class="impl">
 
-  <p>Objects that implement the <code>CanvasText</code>
-  interface have attributes (defined in this section) that control how
-  text is laid out (rasterized or outlined) by the object.</p>
+  <p>Objects that implement the <code>CanvasText</code> interface have
+  attributes (defined in this section) that control how text is laid
+  out (rasterized or outlined) by the object. Such objects also have a
+  <dfn>font style source node</dfn>. For
+  <code>CanvasRenderingContext2D</code> objects, this is the
+  <code>canvas</code> element. For <code>Path</code> objects, it's the
+  <span>path scope node</span>.</p>
 
   <p>The <dfn title="dom-context-2d-font"><code>font</code></dfn> IDL
   attribute, on setting, must be parsed the same way as the 'font'
@@ -41260,16 +41294,17 @@
   'initial'), then it must be ignored, without assigning a new font
   value. <a href="#refsCSS">[CSS]</a></p>
 
-  <p>Font names must be interpreted in the context of the
-  <code>canvas</code> element's stylesheets; any fonts embedded using
-  <code title="">@font-face</code> must therefore be available once
-  they are loaded. (If a font is referenced before it is fully loaded,
-  then it must be treated as if it was an unknown font, falling back
-  to another as described by the relevant CSS specifications.) <a
+  <p>Font names must be interpreted in the context of the <span>font
+  style source node</span>'s stylesheets when the font is to be used;
+  any fonts embedded using <code title="">@font-face</code> that are
+  visible to that element must therefore be available once they are
+  loaded. (If a reference font is used before it is fully loaded, or
+  if the <span>font style source node</span> does not have that font
+  in scope at the time the font is to be used, then it must be treated
+  as if it was an unknown font, falling back to another as described
+  by the relevant CSS specifications.) <a
   href="#refsCSSFONTS">[CSSFONTS]</a></p>
 
-  <!-- XXX Path objects don't have a canvas -->
-
   <p>Only vector fonts should be used by the user agent; if a user
   agent were to use bitmap fonts then transformations would likely
   make the font look very ugly.</p>
@@ -41300,17 +41335,20 @@
   sans-serif. When the 'font-size' component is set to lengths using
   percentages, 'em' or 'ex' units, or the 'larger' or 'smaller'
   keywords, these must be interpreted relative to the computed value
-  of the 'font-size' property of the corresponding <code>canvas</code>
-  element at the time that the attribute is set. When the
-  'font-weight' component is set to the relative values 'bolder' and
-  'lighter', these must be interpreted relative to the computed value
-  of the 'font-weight' property of the corresponding
-  <code>canvas</code> element at the time that the attribute is set.
-  If the computed values are undefined for a particular case (e.g.
-  because the <code>canvas</code> element is not <span>in a
+
+
+  of the 'font-size' property of the <span>font style source
+  node</span> at the time that the attribute is set, if that is an
+  element. When the 'font-weight' component is set to the relative
+  values 'bolder' and 'lighter', these must be interpreted relative to
+  the computed value of the 'font-weight' property of the <span>font
+  style source node</span> at the time that the attribute is set, if
+  that is an element. If the computed values are undefined for a
+  particular case (e.g. because the <span>font style source
+  node</span> is not an element or is not <span>in a
   <code>Document</code></span>), then the relative keywords must be
   interpreted relative to the normal-weight 10px sans-serif
-  default.</p> <!-- XXX Path canvas issue again, twice -->
+  default.</p>
 
   <p>The <dfn
   title="dom-context-2d-textAlign"><code>textAlign</code></dfn> IDL
@@ -41375,26 +41413,235 @@
 
   </dl>
 
+  <p>The <dfn>text preparation algorithm</dfn> is as follows. It takes
+  as input a string <var title="">text</var>, a
+  <code>CanvasText</code> object <var title="">target</var>, and an
+  optional length <var title="">maxWidth</var>. It returns an array of
+  glyph shapes, each positioned on a common coordinate space, and a
+  <var title="">physical alignment</var> whose value is one of
+  <i>left</i>, <i>right</i>, and <i>center</i>. (Most callers of this
+  algorithm ignore the <var title="">physical alignment</var>.)</p>
 
+  <ol>
 
+   <li><p>If <var title="">maxWidth</var> was provided but is less
+   than or equal to zero, return an empty array.</p></li>
+
+   <li><p>Replace all the <span title="space character">space
+   characters</span> in <var title="">text</var> with U+0020 SPACE
+   characters.</p></li>
+
+   <li><p>Let <var title="">font</var> be the current font of <var
+   title="">target</var>, as given by that object's <code
+   title="dom-context-2d-font">font</code> attribute.</p></li>
+
+   <li>
+
+    <p>Apply the appropriate step from the following list to determine
+    the value of <var title="">direction</var>:</p>
+
+    <dl class="switch">
+
+     <dt>If the <var title="">target</var> object's <span>font style
+     source node</span> is an element</dt>
+
+     <dd>Let <var title="">direction</var> be <span>the
+     directionality</span> of the <var title="">target</var> object's
+     <span>font style source node</span>.</dd>
+
+     <dt>If the <var title="">target</var> object's <span>font style
+     source node</span> is a <code>Document</code> and that
+     <code>Document</code> has a root element child</dt>
+
+     <dd>Let <var title="">direction</var> be <span>the
+     directionality</span> of the <var title="">target</var> object's
+     <span>font style source node</span>'s root element child.</dd>
+
+     <dt>If the <var title="">target</var> object's <span>font style
+     source node</span> is a <code>Document</code> and that
+     <code>Document</code> has no root element child</dt>
+
+     <dd>Let <var title="">direction</var> be '<span
+     title="concept-ltr">ltr</span>'.</dd>
+
+    </dl>
+
+   </li>
+
+   <li><p>Form a hypothetical infinitely-wide CSS line box containing
+   a single inline box containing the text <var title="">text</var>,
+   with all the properties at their initial values except the 'font'
+   property of the inline box set to <var title="">font</var>, the
+   'direction' property of the inline box set to <var
+   title="">direction</var>, and the 'white-space' property set to
+   'pre'. <a href="#refsCSS">[CSS]</a></p></li>
+
+   <!-- if you insert a step here, make sure to adjust the next step's
+   final words -->
+
+   <li><p>If <var title="">maxWidth</var> was provided and the
+   hypothetical width of the inline box in the hypothetical line box
+   is greater than <var title="">maxWidth</var> CSS pixels, then
+   change <var title="">font</var> to have a more condensed font (if
+   one is available or if a reasonably readable one can be synthesized
+   by applying a horizontal scale factor to the font) or a smaller
+   font, and return to the previous step.</p></li>
+
+   <li>
+
+    <p>The <var title="">anchor point</var> is a point on the inline
+    box, and the <var title="">physical alignment</var> is one of the
+    values <i>left</i>, <i>right</i>, and <i>center</i>. These
+    variables are determined by the <code
+    title="dom-context-2d-textAlign">textAlign</code> and <code
+    title="dom-context-2d-textBaseline">textBaseline</code> values as
+    follows:</p>
+
+    <p>Horizontal position:</p>
+
+    <dl>
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">left</code></dt>
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">start</code> and <var title="">direction</var> is
+     'ltr'</dt>
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">end</code> and <var title="">direction</var> is
+     'rtl'</dt>
+
+     <dd>Let the <var title="">anchor point</var>'s horizontal
+     position be the left edge of the inline box, and let <var
+     title="">physical alignment</var> be <i>left</i>.</dd>
+
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">right</code></dt>
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">end</code> and <var title="">direction</var> is
+     'ltr'</dt>
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">start</code> and <var title="">direction</var> is
+     'rtl'</dt>
+
+     <dd>Let the <var title="">anchor point</var>'s horizontal
+     position be the right edge of the inline box, and let <var
+     title="">physical alignment</var> be <i>right</i>.</dd>
+
+
+     <dt>If <code title="dom-context-2d-textAlign">textAlign</code> is
+     <code title="">center</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s horizontal
+     position be half way between the left and right edges of the
+     inline box, and let <var title="">physical alignment</var> be
+     <i>center</i>.</dd>
+
+    </dl>
+
+    <p>Vertical position:</p>
+
+    <dl>
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-top">top</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be the top of the em box of the first available font of the
+     inline box.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-hanging">hanging</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be the hanging baseline of the first available font of the inline
+     box.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-middle">middle</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be half way between the bottom and the top of the em box of the
+     first available font of the inline box.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-alphabetic">alphabetic</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be the alphabetic baseline of the first available font of the inline
+     box.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-ideographic">ideographic</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be the ideographic baseline of the first available font of the inline
+     box.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textBaseline">textBaseline</code> is <code
+     title="dom-context-2d-textBaseline-bottom">bottom</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be the bottom of the em box of the first available font of the
+     inline box.</dd>
+
+    </dl>
+
+   </li>
+
+   <li>
+
+    <p>Let <var title="">result</var> be an array constructed by
+    iterating over each glyph in the inline box from left to right (if
+    any), adding to the array, for each glyph, the shape of the glyph
+    as it is in the inline box, positioned on a coordinate space using
+    CSS pixels with its origin is at the <var title="">anchor
+    point</var>.</p>
+
+   </li>
+
+   <li><p>Return <var title="">result</var>, and, for callers that
+   need it, <var title="">physical alignment</var> as the alignment
+   value.</p></li>
+
+  </ol>
+
+
   <h6>Building paths</h6>
 
   <p>Each object implementing the <code>CanvasPathMethods</code>
-  interface has a <span>path</span>. A <dfn>path</dfn> has a list of
-  zero or more subpaths. Each subpath consists of a list of one or
-  more points, connected by straight or curved lines, and a flag
-  indicating whether the subpath is closed or not. A closed subpath is
-  one where the last point of the subpath is connected to the first
-  point of the subpath by a straight line. Subpaths with fewer than
-  two points are ignored when painting the path.</p>
+  interface has a <span title="concept-path">path</span>. A <dfn
+  title="concept-path">path</dfn> has a list of zero or more subpaths.
+  Each subpath consists of a list of one or more points, connected by
+  straight or curved lines, and a flag indicating whether the subpath
+  is closed or not. A closed subpath is one where the last point of
+  the subpath is connected to the first point of the subpath by a
+  straight line. Subpaths with fewer than two points are ignored when
+  painting the path.</p>
 
   <p>When an object implementing the <code>CanvasPathMethods</code>
-  interface is created, its <span>path</span> must be initialized to
-  zero subpaths.</p>
+  interface is created, its <span title="concept-path">path</span>
+  must be initialized to zero subpaths.</p>
 
   <dl class="domintro">
 
    <dt><var title="">context</var> . <code title="dom-context-2d-moveTo">moveTo</code>(<var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-moveTo">moveTo</code>(<var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -41403,6 +41650,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-closePath">closePath</code>()</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-closePath">closePath</code>()</dt>
 
    <dd>
 
@@ -41411,6 +41659,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-lineTo">lineTo</code>(<var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-lineTo">lineTo</code>(<var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -41419,6 +41668,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-quadraticCurveTo">quadraticCurveTo</code>(<var title="">cpx</var>, <var title="">cpy</var>, <var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-quadraticCurveTo">quadraticCurveTo</code>(<var title="">cpx</var>, <var title="">cpy</var>, <var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -41427,6 +41677,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-bezierCurveTo">bezierCurveTo</code>(<var title="">cp1x</var>, <var title="">cp1y</var>, <var title="">cp2x</var>, <var title="">cp2y</var>, <var title="">x</var>, <var title="">y</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-bezierCurveTo">bezierCurveTo</code>(<var title="">cp1x</var>, <var title="">cp1y</var>, <var title="">cp2x</var>, <var title="">cp2y</var>, <var title="">x</var>, <var title="">y</var>)</dt>
 
    <dd>
 
@@ -41435,6 +41686,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-arcTo">arcTo</code>(<var title="">x1</var>, <var title="">y1</var>, <var title="">x2</var>, <var title="">y2</var>, <var title="">radius</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-arcTo">arcTo</code>(<var title="">x1</var>, <var title="">y1</var>, <var title="">x2</var>, <var title="">y2</var>, <var title="">radius</var>)</dt>
 
    <dd>
 
@@ -41448,6 +41700,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-arc">arc</code>(<var title="">x</var>, <var title="">y</var>, <var title="">radius</var>, <var title="">startAngle</var>, <var title="">endAngle</var> [, <var title="">anticlockwise</var> ] )</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-arc">arc</code>(<var title="">x</var>, <var title="">y</var>, <var title="">radius</var>, <var title="">startAngle</var>, <var title="">endAngle</var> [, <var title="">anticlockwise</var> ] )</dt>
 
    <dd>
 
@@ -41463,6 +41716,7 @@
    </dd>
 
    <dt><var title="">context</var> . <code title="dom-context-2d-rect">rect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-context-2d-rect">rect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
 
    <dd>
 
@@ -41475,11 +41729,12 @@
   <div class="impl">
 
   <p>The following methods allow authors to manipulate the <span
-  title="path">paths</span> of objects implementing the
+  title="concept-path">paths</span> of objects implementing the
   <code>CanvasPathMethods</code> interface.</p>
 
-  <p>The points and lines added to an object's <span>path</span> by
-  these methods must be transformed according to the <span
+  <p>The points and lines added to an object's <span
+  title="concept-path">path</span> by these methods must be
+  transformed according to the <span
   title="dom-context-2d-transformation">current transformation
   matrix</span> of the object implementing the
   <code>CanvasPathMethods</code> interface before they are added to
@@ -41499,12 +41754,13 @@
 
   <p>When the user agent is to <dfn>ensure there is a subpath</dfn>
   for a coordinate (<var title="">x</var>, <var title="">y</var>) on a
-  <span>path</span>, the user agent must check to see if the
-  <span>path</span> has any subpaths, and if it does not, then the
-  user agent must create a new subpath with the point (<var
-  title="">x</var>, <var title="">y</var>) as its first (and only)
-  point, as if the <code title="dom-context-2d-moveTo">moveTo()</code>
-  method had been called.</p>
+  <span title="concept-path">path</span>, the user agent must check to
+  see if the <span title="concept-path">path</span> has any subpaths,
+  and if it does not, then the user agent must create a new subpath
+  with the point (<var title="">x</var>, <var title="">y</var>) as its
+  first (and only) point, as if the <code
+  title="dom-context-2d-moveTo">moveTo()</code> method had been
+  called.</p>
 
 
   <p>The <dfn
@@ -41685,7 +41941,387 @@
 
 
 
+  <h6><code>Path</code> objects</h6>
 
+  <p><code>Path</code> objects can be used to declare paths that are
+  then later used on <code>CanvasRenderingContext2D</code> objects. In
+  addition to many of the APIs described in earlier sections,
+  <code>Path</code> objects have methods to combine paths, and to add
+  text to paths.</p>
+
+  <dl class="domintro">
+
+   <dt><var title="">path</var> = new <code title="dom-path">Path</code>([ <var title="">element</var> ])</dt>
+
+   <dd>
+
+    <p>Creates a new <code>Path</code> object, optionally using a specific element for resolving relative keywords and sizes in font specifications.</p>
+
+   </dd>
+
+   <dt><var title="">path</var> . <code title="dom-path-addFill">addFill</code>(<var title="">path</var>)</dt>
+   <dt><var title="">path</var> . <code title="dom-path-addStroke">addStroke</code>(<var title="">path</var>)</dt>
+
+   <dd>
+
+    <p>Adds to the path the path given by the argument.</p>
+
+   </dd>
+
+   <dt><var title="">path</var> . <code title="dom-path-addFillText">addFillText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ])</dt>
+   <dt><var title="">path</var> . <code title="dom-path-addFillText">addFillText</code>(<var title="">text</var>, <var title="">path</var> [, <var title="">maxWidth</var> ])</dt>
+   <dt><var title="">path</var> . <code title="dom-path-addStrokeText">addStrokeText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ])</dt>
+   <dt><var title="">path</var> . <code title="dom-path-addStrokeText">addStrokeText</code>(<var title="">text</var>, <var title="">path</var> [, <var title="">maxWidth</var> ])</dt>
+
+   <dd>
+
+    <p>Adds to the path a series of subpaths corresponding to the given text. If the arguments give a coordinate, the text is drawn horizontally at the given coordinates. If the arguments give a path, the text is drawn along the path. If a maximum width is provided, the text will be scaled to fit that width if necessary.</p>
+
+   </dd>
+
+  </dl>
+
+  <div class="impl">
+
+  <p>Each <code>Path</code> object has a <dfn>path scope node</dfn>.</p>
+
+  <p>The <dfn title="dom-path"><code>Path()</code></dfn> constructor,
+  when invoked, must return a newly created <code>Path</code> object.
+  If the constructor was passed an argument, then the
+  <code>Path</code> object's <span>path scope node</span> is that
+  element. Otherwise, the object's <span>path scope node</span> is
+  the <code>Document</code> object of the <span>active
+  document</span> of the <span>browsing context</span> of the
+  <code>Window</code> object on which the interface object of the
+  invoked constructor is found.</p>
+
+  <p>The <dfn title="dom-path-addFill"><code>addFill(<var
+  title="">b</var>)</code></dfn> method, when invoked on a
+  <code>Path</code> object <var title="">a</var>, must run the
+  following steps:</p>
+
+  <ol>
+
+   <li><p>If the <code>Path</code> object <var title="">b</var> has
+   no subpaths, abort these steps.</p></li>
+
+   <li><p>Create a copy of all the subpaths in <var title="">b</var>.
+   Let this copy be known as <var title="">c</var>.</p></li>
+
+   <li><p>Transform all the coordinates in <var title="">c</var> by
+   the <span title="dom-context-2d-transformation">current
+   transformation matrix</span> of <var title="">a</var>.</p></li>
+
+   <li><p>Let (<var title="">x</var>, <var title="">y</var>) be the
+   last point in the last subpath of <var title="">c</var>.</p></li>
+
+   <li><p>Add all the subpaths in <var title="">c</var> to <var
+   title="">a</var>.</p></li>
+
+   <li><p>Create a new subpath in <var title="">a</var> with (<var
+   title="">x</var>, <var title="">y</var>) as the only point in the
+   subpath.</p></li>
+
+  </ol>
+
+  <p>The <dfn title="dom-path-addStroke"><code>addStroke(<var
+  title="">b</var>)</code></dfn> method, when invoked on a
+  <code>Path</code> object <var title="">a</var>, must run the
+  following steps:</p>
+
+  <ol>
+
+   <li><p>If the <code>Path</code> object <var title="">b</var> has
+   no subpaths, abort these steps.</p></li>
+
+   <li><p>Create a copy of all the subpaths in <var title="">b</var>.
+   Let this copy be known as <var title="">c</var>.</p></li>
+
+   <li><p>Transform all the coordinates in <var title="">c</var> by
+   the <span title="dom-context-2d-transformation">current
+   transformation matrix</span> of <var title="">a</var>.</p></li>
+
+   <li><p>Create a new list of subpaths <var title="">d</var>,
+   consisting of the subpaths necessary to describe the result of
+   tracing the subpaths in <var title="">c</var>, in the same order,
+   while applying the line styles of <var title="">a</var> (the <code
+   title="dom-context-2d-lineWidth">lineWidth</code>, <code
+   title="dom-context-2d-lineCap">lineCap</code>, <code
+   title="dom-context-2d-lineJoin">lineJoin</code>, and (if
+   appropriate) <code
+   title="dom-context-2d-miterLimit">miterLimit</code> attributes).
+   Subpaths in <var title="">d</var> must wind clockwise, regardless
+   of the direction of paths in <var title="">c</var>.</p>
+
+   <!--
+
+    Because both of these examples result in two lines (assuming
+    non-zero winding rules, things are different under even/odd),
+    there's no "hole" where the lines overlap:
+
+           c.beginPath();
+           c.lineWidth=30;
+           c.moveTo(200,200); // subpath 1
+           c.lineTo(400,200);
+           c.moveTo(400,210); // subpath 2
+           c.lineTo(200,190);
+           c.stroke();
+
+           c.beginPath();
+           c.lineWidth=30;
+           c.moveTo(200,200); // subpath 1
+           c.lineTo(400,200);
+           c.lineTo(300,300);
+           c.closePath();
+           c.moveTo(400,210); // subpath 2
+           c.lineTo(200,190);
+           c.lineTo(300,300);
+           c.closePath();
+           c.stroke();
+
+    ...and we want the same result when you create the two subpaths
+    in each example above as two Paths, stroke them onto a third
+    Path, and then fill that Path on the context.
+
+   -->
+
+   <li><p>Let (<var title="">x</var>, <var title="">y</var>) be the
+   last point in the last subpath of <var title="">d</var>.</p></li>
+
+   <li><p>Add all the subpaths in <var title="">d</var> to <var
+   title="">a</var>.</p></li>
+
+   <li><p>Create a new subpath in <var title="">a</var> with (<var
+   title="">x</var>, <var title="">y</var>) as the only point in the
+   subpath.</p></li>
+
+  </ol>
+
+  <p>The <dfn
+  title="dom-context-2d-addFillText"><code>addFillText()</code></dfn> and
+  <dfn
+  title="dom-context-2d-addStrokeText"><code>addStrokeText()</code></dfn>
+  methods each come in two variants: one rendering text at a given
+  coordinate, and one rendering text along a given path. In both
+  cases, a maximum width can optionally be provided.</p>
+
+  <p>When one of the <code
+  title="dom-context-2d-addStrokeText">addFillText()</code> and <code
+  title="dom-context-2d-addStrokeText">addStrokeText()</code> variants
+  that take as argument an (<var title="">x</var>, <var
+  title="">y</var>) coordinate is invoked, the method must run the
+  following algorithm:</p>
+
+  <ol>
+
+   <li><p>Run the <span>text preparation algorithm</span>, passing it
+   <var title="">text</var>, the <code>Path</code> object, and, if the
+   <var title="">maxWidth</var> argument was provided, that argument.
+   Let <var title="">glyphs</var> be the result.</p>
+
+   <li><p>Move all the shapes in <var title="">glyphs</var> to the
+   right by <var title="">x</var> CSS pixels and down by <var
+   title="">y</var> CSS pixels.</p></li>
+
+   <li><p>Let <var title="">glyph subpaths</var> be a list of subpaths
+   describing the shapes given in <var title="">glyphs</var>, with
+   each CSS pixel in the coordinate space of <var
+   title="">glyphs</var> mapped to one coordinate space unit in <var
+   title="">glyph subpaths</var>. Subpaths in <var title="">glyph
+   subpaths</var> must wind clockwise, regardless of how the user
+   agent's font subsystem renders fonts and regardless of how the
+   fonts themselves are defined.</p>
+
+   <li><p>If the method is <code
+   title="dom-context-2d-addStrokeText">addStrokeText()</code>,
+   replace <var title="">glyph subpaths</var> by a new list of
+   subpaths consisting of the subpaths necessary to describe the
+   result of tracing the subpaths added to <var title="">glyph
+   subpaths</var> in the preview step, in the same order, while
+   applying the line styles of the <code>Path</code> object (the <code
+   title="dom-context-2d-lineWidth">lineWidth</code>, <code
+   title="dom-context-2d-lineCap">lineCap</code>, <code
+   title="dom-context-2d-lineJoin">lineJoin</code>, and (if
+   appropriate) <code
+   title="dom-context-2d-miterLimit">miterLimit</code> attributes).
+   These subpaths in <var title="">glyph subpaths</var> must also all
+   wind clockwise.</p>
+
+   <li><p>Transform all the coordinates in <var title="">glyph
+   subpaths</var> by the <span
+   title="dom-context-2d-transformation">current transformation
+   matrix</span> of the <code>Path</code> object.</p></li>
+
+   <li><p>Let (<var title="">x<sub title="">final</sub></var>, <var
+   title="">y<sub title="">final</sub></var>) be the last point in the
+   last subpath of <var title="">glyph subpaths</var>.</p></li>
+
+   <li><p>Add all the subpaths in <var title="">glyph
+   subpaths</var> to the <code>Path</code> object.</p></li>
+
+   <li><p>Create a new subpath in the <code>Path</code> object with
+   (<var title="">x<sub title="">final</sub></var>, <var
+   title="">y<sub title="">final</sub></var>) as the only point in the
+   subpath.</p></li>
+
+  </ol>
+
+  <p>When one of the <code
+  title="dom-context-2d-addFillText">addFillText()</code> and <code
+  title="dom-context-2d-addStrokeText">addStrokeText()</code> variants
+  that take as argument a <code>Path</code> object is invoked, the
+  method must run the following algorithm:</p>
+
+  <ol>
+
+   <li><p>Let <var title="">target</var> be the <code>Path</code>
+   object on which the method was invoked.</p></li>
+
+   <li><p>Let <var title="">path</var> be the <code>Path</code> object
+   that was provided in the method's arguments.</p></li>
+
+   <li><p>Run the <span>text preparation algorithm</span>, passing it
+   <var title="">text</var>, <var title="">target</var>, and, if the
+   <var title="">maxWidth</var> argument was provided, that argument.
+   Let <var title="">glyphs</var> be the resulting array, and <var
+   title="">physical alignment</var> be the resulting alignment
+   value.</p>
+
+   <li><p>Let <var title="">width</var> be the aggregate length of all
+   the subpaths in <var title="">path</var>, including the distances
+   from the last point of each closed subpath to the first point of
+   that subpath.</p></li>
+
+   <li><p>Define <var title="">L</var> to be a linear coordinate line
+   for of all the subpaths in <var title="">path</var>, with
+   additional lines drawn between the last point and the first point
+   of each closed subpath, such that the first point of the first
+   subpath is defined as point 0, and the last point of the last
+   subpath, if the last subpath is not closed, or the second
+   occurrence first point of that subpath, if it is closed, is defined
+   as point <var title="">width</var>.</p></li>
+
+   <li>
+
+    <p>Let <var title="">offset</var> be determined according to the
+    appropriate step below:</p>
+
+    <dl class="switch">
+
+     <dt>If <var title="">physical alignment</var> is <i>left</i></dt>
+     <dd>Let <var title="">offset</var> be zero.</dd>
+
+     <dt>If <var title="">physical alignment</var> is <i>right</i></dt>
+     <dd>Let <var title="">offset</var> be <var title="">width</var>.</dd>
+
+     <dt>If <var title="">physical alignment</var> is <i>center</i></dt>
+     <dd>Let <var title="">offset</var> be half of <var title="">width</var>.</dd>
+
+    </dl>
+
+   </li>
+
+   <li><p>Move all the shapes in <var title="">glyphs</var> to the
+   right by <var title="">offset</var> CSS pixels.</p></li>
+
+   <li>
+
+    <p>For each glyph <var title="">glyph</var> in the <var
+    title="">glyphs</var> array, run these substeps:</p>
+
+    <ol>
+
+     <li><p>Let <var title="">dx</var> be the <var
+     title="">x</var>-coordinate of the horizontal center of the
+     bounding box of the shape described by <var
+     title="">glyph</var>, in CSS pixels.</p></li>
+
+     <li><p>If <var title="">dx</var> is negative or greater than <var
+     title="">width</var>, skip the remainder of these substeps for
+     this glyph.</p></li>
+
+     <li><p>Recast <var title="">dx</var> to coordinate spaces units
+     in <var title="">path</var>. (This just changes the
+     dimensionality of <var title="">dx</var>, not its numeric
+     value.)</p> <!-- hide this step if people get confused by the
+     pedancy -->
+
+     <li><p>Find the point <var title="">p</var> on <var
+     title="">path</var> (or implied closing lines in <var
+     title="">path</var>) that corresponds to the position <var
+     title="">dx</var> on the coordinate line <var
+     title="">L</var>.</p>
+
+     <li><p>Let <var title="">&theta;</var> be the clockwise angle
+     from the positive x-axis to the side of the line that is
+     tangential to <var title="">path</var> at the point <var
+     title="">p</var> that is going in the same direction as the line
+     at point <var title="">p</var>.</p></li>
+
+     <li><p>Rotate the shape described by <var title="">glyph</var>
+     clockwise by <var title="">&theta;</var> about the point that is
+     at the <var title="">dx</var> coordinate horizontally and the
+     zero coordinate vertically.</p></li>
+
+     <li><p>Let (<var title="">x</var>, <var title="">y</var>) be the
+     coordinate of the point <var title="">p</var>.</p></li>
+
+     <li><p>Move the shape described by <var title="">glyph</var> to
+     the right by <var title="">x</var> and down by <var
+     title="">y</var>.</p></li>
+
+     <li><p>Let <var title="">glyph subpaths</var> be a list of
+     subpaths describing the shape given in <var title="">glyph</var>,
+     with each CSS pixel in the coordinate space of <var
+     title="">glyph</var> mapped to one coordinate space unit in <var
+     title="">glyph subpaths</var>. Subpaths in <var title="">glyph
+     subpaths</var> must wind clockwise, regardless of how the user
+     agent's font subsystem renders fonts and regardless of how the
+     fonts themselves are defined.</p>
+
+     <li><p>If the method is <code
+     title="dom-context-2d-addStrokeText">addStrokeText()</code>,
+     replace <var title="">glyph subpaths</var> by a new list of
+     subpaths consisting of the subpaths necessary to describe the
+     result of tracing the subpaths added to <var title="">glyph
+     subpaths</var> in the preview step, in the same order, while
+     applying the line styles of the <var title="">target</var> object
+     (the <code title="dom-context-2d-lineWidth">lineWidth</code>,
+     <code title="dom-context-2d-lineCap">lineCap</code>, <code
+     title="dom-context-2d-lineJoin">lineJoin</code>, and (if
+     appropriate) <code
+     title="dom-context-2d-miterLimit">miterLimit</code> attributes).
+     These subpaths in <var title="">glyph subpaths</var> must also
+     all wind clockwise.</p>
+
+     <li><p>Transform all the coordinates in <var title="">glyph
+     subpaths</var> by the <span
+     title="dom-context-2d-transformation">current transformation
+     matrix</span> of <var title="">target</var>.</p></li>
+
+     <li><p>Let (<var title="">x<sub title="">final</sub></var>, <var
+     title="">y<sub title="">final</sub></var>) be the last point in
+     the last subpath of <var title="">glyph subpaths</var>. (This
+     coordinate is only used if this is the last glyph
+     processed.)</p></li>
+
+     <li><p>Add all the subpaths in <var title="">glyph subpaths</var>
+     to <var title="">target</var>.</p></li>
+
+    </ol>
+
+   </li>
+
+   <li><p>Create a new subpath in the <code>Path</code> object with
+   (<var title="">x<sub title="">final</sub></var>, <var
+   title="">y<sub title="">final</sub></var>) as the only point in the
+   subpath.</p></li>
+
+  </ol>
+
+  </div>
+
+
   <h6>Fill and stroke styles</h6>
 
   <dl class="domintro">
@@ -42168,12 +42804,424 @@
 
 
 
-  <h6>The current default path</h6>
 
+  <h6>Drawing rectangles to the canvas</h6>
+
+  <p>There are three methods that immediately draw rectangles to the
+  bitmap. They each take four arguments; the first two give the <var
+  title="">x</var> and <var title="">y</var> coordinates of the top
+  left of the rectangle, and the second two give the width <var
+  title="">w</var> and height <var title="">h</var> of the rectangle,
+  respectively.</p>
+
+  <div class="impl">
+
+  <p>The <span title="dom-context-2d-transformation">current
+  transformation matrix</span> must be applied to the following four
+  coordinates, which form the path that must then be closed to get the
+  specified rectangle: <span title="">(<var title="">x</var>, <var
+  title="">y</var>)</span>, <span title="">(<span title=""><var title="">x</var>+<var
+  title="">w</var></span>, <var title="">y</var>)</span>,
+  <span title="">(<span title=""><var title="">x</var>+<var title="">w</var></span>,
+  <span title=""><var title="">y</var>+<var title="">h</var></span>)</span>,
+  <span title="">(<var title="">x</var>, <span title=""><var title="">y</var>+<var
+  title="">h</var></span>)</span>.</p>
+
+  <p>Shapes are painted without affecting the current default path,
+  and are subject to the <span title="clipping region">clipping
+  region</span>, and, with the exception of <code
+  title="dom-context-2d-clearRect">clearRect()</code>, also <span
+  title="shadows">shadow effects</span>, <span
+  title="dom-context-2d-globalAlpha">global alpha</span>, and <span
+  title="dom-context-2d-globalCompositeOperation">global composition
+  operators</span>.</p>
+
+  </div>
+
+  <dl class="domintro">
+
+   <dt><var title="">context</var> . <code title="dom-context-2d-clearRect">clearRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
+
+   <dd>
+
+    <p>Clears all pixels on the canvas in the given rectangle to transparent black.</p>
+
+   </dd>
+
+   <dt><var title="">context</var> . <code title="dom-context-2d-fillRect">fillRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
+
+   <dd>
+
+    <p>Paints the given rectangle onto the canvas, using the current fill style.</p>
+
+   </dd>
+
+   <dt><var title="">context</var> . <code title="dom-context-2d-strokeRect">strokeRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
+
+   <dd>
+
+    <p>Paints the box that outlines the given rectangle onto the canvas, using the current stroke style.</p>
+
+   </dd>
+
+  </dl>
+
+  <div class="impl">
+
+  <p>The <dfn title="dom-context-2d-clearRect"><code>clearRect(<var
+  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
+  title="">h</var>)</code></dfn> method must clear the pixels in the
+  specified rectangle that also intersect the current clipping region
+  to a fully transparent black, erasing any previous image. If either
+  height or width are zero, this method has no effect.</p>
+
+  <p>The <dfn title="dom-context-2d-fillRect"><code>fillRect(<var
+  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
+  title="">h</var>)</code></dfn> method must paint the specified
+  rectangular area using the <code
+  title="dom-context-2d-fillStyle">fillStyle</code>. If either height
+  or width are zero, this method has no effect.</p>
+
+  <p>The <dfn title="dom-context-2d-strokeRect"><code>strokeRect(<var
+  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
+  title="">h</var>)</code></dfn> method must stroke the specified
+  rectangle's path using the <code
+  title="dom-context-2d-strokeStyle">strokeStyle</code>, <code
+  title="dom-context-2d-lineWidth">lineWidth</code>, <code
+  title="dom-context-2d-lineJoin">lineJoin</code>, and (if
+  appropriate) <code
+  title="dom-context-2d-miterLimit">miterLimit</code> attributes. If
+  both height and width are zero, this method has no effect, since
+  there is no path to stroke (it's a point). If only one of the two is
+  zero, then the method will draw a line instead (the path for the
+  outline is just a straight line along the non-zero dimension).</p>
+
+  </div>
+
+
+
+  <h6>Drawing text to the canvas</h6>
+
+  <dl class="domintro">
+
+   <dt><var title="">context</var> . <code title="dom-context-2d-fillText">fillText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt>
+   <dt><var title="">context</var> . <code title="dom-context-2d-strokeText">strokeText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt>
+
+   <dd>
+
+    <p>Fills or strokes (respectively) the given text at the given
+    position. If a maximum width is provided, the text will be scaled
+    to fit that width if necessary.</p>
+
+   </dd>
+
+   <dt><var title="">metrics</var> = <var title="">context</var> . <code title="dom-context-2d-measureText">measureText</code>(<var title="">text</var>)</dt>
+
+   <dd>
+
+    <p>Returns a <code>TextMetrics</code> object with the metrics of the given text in the current font.</p>
+
+   </dd>
+
+   <dt><var title="">metrics</var> . <code title="dom-textmetrics-width">width</code></dt>
+
+   <dd>
+
+    <p>Returns the advance width of the text that was passed to the
+    <code title="dom-context-2d-measureText">measureText()</code>
+    method.</p>
+
+   </dd>
+
+  </dl>
+
+  <div class="impl">
+
+  <p>The <code>CanvasRenderingContext2D</code> interface provides the
+  following methods for rendering text directly to the canvas.</p>
+
+  <p>The <dfn
+  title="dom-context-2d-fillText"><code>fillText()</code></dfn> and
+  <dfn
+  title="dom-context-2d-strokeText"><code>strokeText()</code></dfn>
+  methods take three or four arguments, <var title="">text</var>, <var
+  title="">x</var>, <var title="">y</var>, and optionally <var
+  title="">maxWidth</var>, and render the given <var
+  title="">text</var> at the given (<var title="">x</var>, <var
+  title="">y</var>) coordinates ensuring that the text isn't wider
+  than <var title="">maxWidth</var> if specified, using the current
+  <code title="dom-context-2d-font">font</code>, <code
+  title="dom-context-2d-textAlign">textAlign</code>, and <code
+  title="dom-context-2d-textBaseline">textBaseline</code>
+  values. Specifically, when the methods are called, the user agent
+  must run the following steps:</p>
+
+  <ol>
+
+   <li><p>Run the <span>text preparation algorithm</span>, passing it
+   <var title="">text</var>, the <code>CanvasRenderingContext2D</code>
+   object, and, if the <var title="">maxWidth</var> argument was
+   provided, that argument. Let <var title="">glyphs</var> be the
+   result.</p>
+
+   <li><p>Move all the shapes in <var title="">glyphs</var> to the
+   right by <var title="">x</var> CSS pixels and down by <var
+   title="">y</var> CSS pixels.</p></li>
+
+   <li>
+
+    <p>Paint the shapes given in <var title="">glyphs</var>, as
+    transformed by the <span
+    title="dom-context-2d-transformation">current transformation
+    matrix</span>, with each CSS pixel in the coordinate space of <var
+    title="">glyphs</var> mapped to one coordinate space unit.</p>
+
+    <p>For <code title="dom-context-2d-fillText">fillText()</code>,
+    <code title="dom-context-2d-fillStyle">fillStyle</code> must be
+    applied to the shapes and <code
+    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
+    ignored. For <code
+    title="dom-context-2d-strokeText">strokeText()</code>, the reverse
+    holds and <code
+    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
+    applied to the shape outlines, along with the <code
+    title="dom-context-2d-lineWidth">lineWidth</code>, <code
+    title="dom-context-2d-lineCap">lineCap</code>, <code
+    title="dom-context-2d-lineJoin">lineJoin</code>, and (if
+    appropriate) <code
+    title="dom-context-2d-miterLimit">miterLimit</code> attributes,
+    and <code title="dom-context-2d-fillStyle">fillStyle</code> must
+    be ignored.</p>
+
+    <p>These shapes are painted without affecting the current path,
+    and are subject to <span title="shadows">shadow effects</span>,
+    <span title="dom-context-2d-globalAlpha">global alpha</span>, the
+    <span title="clipping region">clipping region</span>, and <span
+    title="dom-context-2d-globalCompositeOperation">global composition
+    operators</span>.</p>
+
+   </li>
+
+  </ol>
+
+<!--v6DVT - this is commented out until CSS can get its act together
+enough to actual specify vertical text rendering (how long have we
+been waiting now?)
+
+WHEN EDITING THIS, FIX THE PARTS MARKED "&#x0058;&#x0058;&#x0058;" BELOW
+
+ALSO NOTE THAT THIS PROBABLY NEEDS ENTIRELY REVISITING NOW THAT WE
+HAVE REJIGGED HOW TEXT WORKS IN v5
+
+  <p>The <dfn
+  title="dom-context-2d-fillVerticalText"><code>fillVerticalText()</code></dfn>
+  and <dfn
+  title="dom-context-2d-strokeVerticalText"><code>strokeVerticalText()</code></dfn>
+  methods take three or four arguments, <var title="">text</var>, <var
+  title="">x</var>, <var title="">y</var>, and optionally <var
+  title="">maxHeight</var>, and render the given <var
+  title="">text</var> as vertical text at the given (<var
+  title="">x</var>, <var title="">y</var>) coordinates ensuring that
+  the text isn't taller than <var title="">maxHeight</var> if
+  specified, using the current <code
+  title="dom-context-2d-font">font</code> and <code
+  title="dom-context-2d-textAlign">textAlign</code>
+  values. Specifically, when the methods are called, the user agent
+  must run the following steps:</p>
+
+  <ol>
+
+   <li><p>If <var title="">maxHeight</var> is present but less than or
+   equal to zero, return without doing anything; abort these
+   steps.</p></li>
+
+   <li><p>Let <var title="">font</var> be the current font of the
+   context, as given by the <code
+   title="dom-context-2d-font">font</code> attribute.</p></li>
+
+   <li><p>Replace all the <span title="space character">space
+   characters</span> in <var title="">text</var> with U+0020 SPACE
+   characters.</p></li>
+
+   <li><p>Form a <em class="&#x0058;&#x0058;&#x0058;">whatever CSS ends up calling
+   vertical line boxes and inline boxes</em> containing the text <var
+   title="">text</var>, with all the properties at their initial
+   values except the 'font' property of the inline box set to <var
+   title="">font</var> and the 'direction' property of the inline
+   box set to <span>the directionality</span> of the <code>canvas</code>
+   element.</p></li>
+
+   <!- - if you insert a step here, make sure to adjust the next step's
+   final words - ->
+
+   <li><p>If the <var title="">maxHeight</var> argument was specified
+   and the hypothetical height of the <em class="&#x0058;&#x0058;&#x0058;">box</em>
+   in the hypothetical line box is greater than <var
+   title="">maxHeight</var> CSS pixels, then change <var
+   title="">font</var> to have a more condensed font (if one is
+   available or if a reasonably readable one can be synthesized by
+   applying an appropriate scale factor to the font) or a smaller
+   font, and return to the previous step.</p></li>
+
+   <li>
+
+    <p>Let the <var title="">anchor point</var> be a point on the <em
+    class="&#x0058;&#x0058;&#x0058;">inline box</var>, determined by the <code
+    title="dom-context-2d-textAlign">textAlign</code>, as follows:</p>
+
+    <p>Vertical position:</p>
+
+    <dl>
+
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">start</code></dt>
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">left</code> and <span>the directionality</span> of the
+     <code>canvas</code> element is 'ltr'</dt>
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">right</code> and <span>the directionality</span> of the
+     <code>canvas</code> element is 'rtl'</dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical
+     position be the top edge of the <em class="&#x0058;&#x0058;&#x0058;">inline
+     box</em>.</dd>
+
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">end</code></dt>
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">right</code> and <span>the directionality</span> of the
+     <code>canvas</code> element is 'ltr'</dt>
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">left</code> and <span>the directionality</span> of the
+     <code>canvas</code> element is 'rtl'</dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical
+     position be the bottom edge of the <em class="&#x0058;&#x0058;&#x0058;">inline
+     box</em>.</dd>
+
+
+     <dt>If <code
+     title="dom-context-2d-textAlign">textAlign</code> is <code
+     title="">center</code></dt>
+
+     <dd>Let the <var title="">anchor point</var>'s vertical position
+     be half way between the top and bottom edges of the <em
+     class="&#x0058;&#x0058;&#x0058;">inline box</em>.</dd>
+
+    </dl>
+
+    <p>Let the horizontal position be half way between the left and
+    right edges of the em box of the first available font of the <em
+    class="&#x0058;&#x0058;&#x0058;">inline box</em>.</p>
+
+   </li>
+
+   <li>
+
+    <p>Paint the hypothetical inline box as the shape given by the
+    text's glyphs, as transformed by the <span
+    title="dom-context-2d-transformation">current transformation
+    matrix</span>, and anchored and sized so that before applying the
+    <span title="dom-context-2d-transformation">current transformation
+    matrix</span>, the <var title="">anchor point</var> is at (<var
+    title="">x</var>, <var title="">y</var>) and each CSS pixel is
+    mapped to one coordinate space unit.</p>
+
+    <p>For <code
+    title="dom-context-2d-fillVerticalText">fillVerticalText()</code>
+    <code title="dom-context-2d-fillStyle">fillStyle</code> must be
+    applied and <code
+    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
+    ignored. For <code
+    title="dom-context-2d-strokeVerticalText">strokeVerticalText()</code>
+    the reverse holds and <code
+    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
+    applied and <code
+    title="dom-context-2d-fillStyle">fillStyle</code> must be
+    ignored.</p>
+
+    <p>Text is painted without affecting the current path, and is
+    subject to <span title="shadows">shadow effects</span>, <span
+    title="dom-context-2d-globalAlpha">global alpha</span>, the <span
+    title="clipping region">clipping region</span>, and <span
+    title="dom-context-2d-globalCompositeOperation">global composition
+    operators</span>.</p>
+
+   </li>
+
+  </ol>
+
+v6DVT (also check for '- -' bits in the part above) -->
+
+  <p>The <dfn
+  title="dom-context-2d-measureText"><code>measureText()</code></dfn>
+  method takes one argument, <var title="">text</var>. When the method
+  is invoked, the user agent must replace all the <span title="space
+  character">space characters</span> in <var title="">text</var> with
+  U+0020 SPACE characters, and then must form a hypothetical
+  infinitely-wide CSS line box containing a single inline box
+  containing the text <var title="">text</var>, with all the
+  properties at their initial values except the 'white-space' property
+  of the inline element set to 'pre' and the 'font' property of the
+  inline element set to the current font of the context as given by
+  the <code title="dom-context-2d-font">font</code> attribute, and
+  must then create a new <code>TextMetrics</code> object with its
+  <code title="dom-textmetrics-width">width</code> attribute set to
+  the width of that inline box, in CSS pixels.
+<!--ADD-TOPIC:Security-->
+  If doing these measurements requires using a font that has an
+  <span>origin</span> that is not the <span title="same
+  origin">same</span> as that of the <code>Document</code> object that
+  owns the <code>canvas</code> element (even if "using a font" means
+  just checking if that font has a particular glyph in it before
+  falling back to another font), then the method must throw a
+  <code>SecurityError</code> exception.
+<!--REMOVE-TOPIC:Security-->
+  Otherwise, it must return the new <code>TextMetrics</code> object.
+  <a href="#refsCSS">[CSS]</a></p>
+
+  <p>The <code>TextMetrics</code> interface is used for the objects
+  returned from <code
+  title="dom-context-2d-measureText">measureText()</code>. It has one
+  attribute, <dfn
+  title="dom-textmetrics-width"><code>width</code></dfn>, which is set
+  by the <code title="dom-context-2d-measureText">measureText()</code>
+  method.</p>
+
+  <p class="note">Glyphs rendered using <code
+  title="dom-context-2d-fillText">fillText()</code> and <code
+  title="dom-context-2d-strokeText">strokeText()</code> can spill out
+  of the box given by the font size (the em square size) and the width
+  returned by <code
+  title="dom-context-2d-measureText">measureText()</code> (the text
+  width). This version of the specification does not provide a way to
+  obtain the bounding box dimensions of the text. If the text is to be
+  rendered and removed, care needs to be taken to replace the entire
+  area of the canvas that the clipping region covers, not just the box
+  given by the em square height and measured text width.</p>
+
+  </div>
+
+  <p class="note">A future version of the 2D context API may provide a
+  way to render fragments of documents, rendered using CSS, straight
+  to the canvas. This would be provided in preference to a dedicated
+  way of doing multiline layout.</p>
+
+
+
+  <h6>Drawing paths to the canvas</h6>
+
   <p>The context always has a current default path. There is only one
   current default path, it is not part of the <span>drawing
-  state</span>. The current default path is a <span>path</span>, as
-  described in the previous section.</p>
+  state</span>. The current default path is a <span
+  title="concept-path">path</span>, as described in the previous
+  section.</p>
 
   <dl class="domintro">
 
@@ -42560,555 +43608,6 @@
 
 
 
-
-
-  <h6>Drawing rectangles to the canvas</h6>
-
-  <p>There are three methods that immediately draw rectangles to the
-  bitmap. They each take four arguments; the first two give the <var
-  title="">x</var> and <var title="">y</var> coordinates of the top
-  left of the rectangle, and the second two give the width <var
-  title="">w</var> and height <var title="">h</var> of the rectangle,
-  respectively.</p>
-
-  <div class="impl">
-
-  <p>The <span title="dom-context-2d-transformation">current
-  transformation matrix</span> must be applied to the following four
-  coordinates, which form the path that must then be closed to get the
-  specified rectangle: <span title="">(<var title="">x</var>, <var
-  title="">y</var>)</span>, <span title="">(<span title=""><var title="">x</var>+<var
-  title="">w</var></span>, <var title="">y</var>)</span>,
-  <span title="">(<span title=""><var title="">x</var>+<var title="">w</var></span>,
-  <span title=""><var title="">y</var>+<var title="">h</var></span>)</span>,
-  <span title="">(<var title="">x</var>, <span title=""><var title="">y</var>+<var
-  title="">h</var></span>)</span>.</p>
-
-  <p>Shapes are painted without affecting the current default path,
-  and are subject to the <span title="clipping region">clipping
-  region</span>, and, with the exception of <code
-  title="dom-context-2d-clearRect">clearRect()</code>, also <span
-  title="shadows">shadow effects</span>, <span
-  title="dom-context-2d-globalAlpha">global alpha</span>, and <span
-  title="dom-context-2d-globalCompositeOperation">global composition
-  operators</span>.</p>
-
-  </div>
-
-  <dl class="domintro">
-
-   <dt><var title="">context</var> . <code title="dom-context-2d-clearRect">clearRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
-
-   <dd>
-
-    <p>Clears all pixels on the canvas in the given rectangle to transparent black.</p>
-
-   </dd>
-
-   <dt><var title="">context</var> . <code title="dom-context-2d-fillRect">fillRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
-
-   <dd>
-
-    <p>Paints the given rectangle onto the canvas, using the current fill style.</p>
-
-   </dd>
-
-   <dt><var title="">context</var> . <code title="dom-context-2d-strokeRect">strokeRect</code>(<var title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var title="">h</var>)</dt>
-
-   <dd>
-
-    <p>Paints the box that outlines the given rectangle onto the canvas, using the current stroke style.</p>
-
-   </dd>
-
-  </dl>
-
-  <div class="impl">
-
-  <p>The <dfn title="dom-context-2d-clearRect"><code>clearRect(<var
-  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
-  title="">h</var>)</code></dfn> method must clear the pixels in the
-  specified rectangle that also intersect the current clipping region
-  to a fully transparent black, erasing any previous image. If either
-  height or width are zero, this method has no effect.</p>
-
-  <p>The <dfn title="dom-context-2d-fillRect"><code>fillRect(<var
-  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
-  title="">h</var>)</code></dfn> method must paint the specified
-  rectangular area using the <code
-  title="dom-context-2d-fillStyle">fillStyle</code>. If either height
-  or width are zero, this method has no effect.</p>
-
-  <p>The <dfn title="dom-context-2d-strokeRect"><code>strokeRect(<var
-  title="">x</var>, <var title="">y</var>, <var title="">w</var>, <var
-  title="">h</var>)</code></dfn> method must stroke the specified
-  rectangle's path using the <code
-  title="dom-context-2d-strokeStyle">strokeStyle</code>, <code
-  title="dom-context-2d-lineWidth">lineWidth</code>, <code
-  title="dom-context-2d-lineJoin">lineJoin</code>, and (if
-  appropriate) <code
-  title="dom-context-2d-miterLimit">miterLimit</code> attributes. If
-  both height and width are zero, this method has no effect, since
-  there is no path to stroke (it's a point). If only one of the two is
-  zero, then the method will draw a line instead (the path for the
-  outline is just a straight line along the non-zero dimension).</p>
-
-  </div>
-
-
-
-  <h6>Drawing text to the canvas</h6>
-
-  <dl class="domintro">
-
-   <dt><var title="">context</var> . <code title="dom-context-2d-fillText">fillText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt>
-   <dt><var title="">context</var> . <code title="dom-context-2d-strokeText">strokeText</code>(<var title="">text</var>, <var title="">x</var>, <var title="">y</var> [, <var title="">maxWidth</var> ] )</dt>
-
-   <dd>
-
-    <p>Fills or strokes (respectively) the given text at the given
-    position. If a maximum width is provided, the text will be scaled
-    to fit that width if necessary.</p>
-
-   </dd>
-
-   <dt><var title="">metrics</var> = <var title="">context</var> . <code title="dom-context-2d-measureText">measureText</code>(<var title="">text</var>)</dt>
-
-   <dd>
-
-    <p>Returns a <code>TextMetrics</code> object with the metrics of the given text in the current font.</p>
-
-   </dd>
-
-   <dt><var title="">metrics</var> . <code title="dom-textmetrics-width">width</code></dt>
-
-   <dd>
-
-    <p>Returns the advance width of the text that was passed to the
-    <code title="dom-context-2d-measureText">measureText()</code>
-    method.</p>
-
-   </dd>
-
-  </dl>
-
-  <div class="impl">
-
-  <p>The <code>CanvasRenderingContext2D</code> interface provides the
-  following methods for rendering text directly to the canvas.</p>
-
-  <p>The <dfn
-  title="dom-context-2d-fillText"><code>fillText()</code></dfn> and
-  <dfn
-  title="dom-context-2d-strokeText"><code>strokeText()</code></dfn>
-  methods take three or four arguments, <var title="">text</var>, <var
-  title="">x</var>, <var title="">y</var>, and optionally <var
-  title="">maxWidth</var>, and render the given <var
-  title="">text</var> at the given (<var title="">x</var>, <var
-  title="">y</var>) coordinates ensuring that the text isn't wider
-  than <var title="">maxWidth</var> if specified, using the current
-  <code title="dom-context-2d-font">font</code>, <code
-  title="dom-context-2d-textAlign">textAlign</code>, and <code
-  title="dom-context-2d-textBaseline">textBaseline</code>
-  values. Specifically, when the methods are called, the user agent
-  must run the following steps:</p>
-
-  <ol>
-
-   <li><p>If <var title="">maxWidth</var> is present but less than or
-   equal to zero, return without doing anything; abort these
-   steps.</p></li>
-
-   <li><p>Let <var title="">font</var> be the current font of the
-   context, as given by the <code
-   title="dom-context-2d-font">font</code> attribute.</p></li>
-
-   <li><p>Replace all the <span title="space character">space
-   characters</span> in <var title="">text</var> with U+0020 SPACE
-   characters.</p></li>
-
-   <li><p>Form a hypothetical infinitely wide CSS line box containing
-   a single inline box containing the text <var title="">text</var>,
-   with all the properties at their initial values except the 'font'
-   property of the inline box set to <var title="">font</var>, the
-   'direction' property of the inline box set to <span>the
-   directionality</span> of the <code>canvas</code> element, and the
-   'white-space' property set to 'pre'. <a
-   href="#refsCSS">[CSS]</a></p></li>
-
-   <!-- if you insert a step here, make sure to adjust the next step's
-   final words -->
-
-   <li><p>If the <var title="">maxWidth</var> argument was specified
-   and the hypothetical width of the inline box in the hypothetical
-   line box is greater than <var title="">maxWidth</var> CSS pixels,
-   then change <var title="">font</var> to have a more condensed font
-   (if one is available or if a reasonably readable one can be
-   synthesized by applying a horizontal scale factor to the font) or a
-   smaller font, and return to the previous step.</p></li>
-
-   <li>
-
-    <p>Let the <var title="">anchor point</var> be a point on the
-    inline box, determined by the <code
-    title="dom-context-2d-textAlign">textAlign</code> and <code
-    title="dom-context-2d-textBaseline">textBaseline</code> values, as
-    follows:</p>
-
-    <p>Horizontal position:</p>
-
-    <dl>
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">left</code></dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">start</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'ltr'</dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">end</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'rtl'</dt>
-
-     <dd>Let the <var title="">anchor point</var>'s horizontal
-     position be the left edge of the inline box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">right</code></dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">end</code> and  <span>the directionality</span> of the
-     <code>canvas</code> element is 'ltr'</dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">start</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'rtl'</dt>
-
-     <dd>Let the <var title="">anchor point</var>'s horizontal
-     position be the right edge of the inline box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">center</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s horizontal
-     position be half way between the left and right edges of the
-     inline box.</dd>
-
-    </dl>
-
-    <p>Vertical position:</p>
-
-    <dl>
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-top">top</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be the top of the em box of the first available font of the
-     inline box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-hanging">hanging</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be the hanging baseline of the first available font of the inline
-     box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-middle">middle</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be half way between the bottom and the top of the em box of the
-     first available font of the inline box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-alphabetic">alphabetic</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be the alphabetic baseline of the first available font of the inline
-     box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-ideographic">ideographic</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be the ideographic baseline of the first available font of the inline
-     box.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textBaseline">textBaseline</code> is <code
-     title="dom-context-2d-textBaseline-bottom">bottom</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be the bottom of the em box of the first available font of the
-     inline box.</dd>
-
-    </dl>
-
-   </li>
-
-   <li>
-
-    <p>Paint the hypothetical inline box as the shape given by the
-    text's glyphs, as transformed by the <span
-    title="dom-context-2d-transformation">current transformation
-    matrix</span>, and anchored and sized so that before applying the
-    <span title="dom-context-2d-transformation">current transformation
-    matrix</span>, the <var title="">anchor point</var> is at (<var
-    title="">x</var>, <var title="">y</var>) and each CSS pixel is
-    mapped to one coordinate space unit.</p>
-
-    <p>For <code title="dom-context-2d-fillText">fillText()</code>
-    <code title="dom-context-2d-fillStyle">fillStyle</code> must be
-    applied to the glyphs and <code
-    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
-    ignored. For <code
-    title="dom-context-2d-strokeText">strokeText()</code> the reverse
-    holds and <code
-    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
-    applied to the glyph outlines and <code
-    title="dom-context-2d-fillStyle">fillStyle</code> must be
-    ignored.</p>
-
-    <p>Text is painted without affecting the current path, and is
-    subject to <span title="shadows">shadow effects</span>, <span
-    title="dom-context-2d-globalAlpha">global alpha</span>, the <span
-    title="clipping region">clipping region</span>, and <span
-    title="dom-context-2d-globalCompositeOperation">global composition
-    operators</span>.</p>
-
-   </li>
-
-  </ol>
-
-<!--v6DVT - this is commented out until CSS can get its act together
-enough to actual specify vertical text rendering (how long have we
-been waiting now?)
-
-WHEN EDITING THIS, FIX THE PARTS MARKED "&#x0058;&#x0058;&#x0058;" BELOW
-
-  <p>The <dfn
-  title="dom-context-2d-fillVerticalText"><code>fillVerticalText()</code></dfn>
-  and <dfn
-  title="dom-context-2d-strokeVerticalText"><code>strokeVerticalText()</code></dfn>
-  methods take three or four arguments, <var title="">text</var>, <var
-  title="">x</var>, <var title="">y</var>, and optionally <var
-  title="">maxHeight</var>, and render the given <var
-  title="">text</var> as vertical text at the given (<var
-  title="">x</var>, <var title="">y</var>) coordinates ensuring that
-  the text isn't taller than <var title="">maxHeight</var> if
-  specified, using the current <code
-  title="dom-context-2d-font">font</code> and <code
-  title="dom-context-2d-textAlign">textAlign</code>
-  values. Specifically, when the methods are called, the user agent
-  must run the following steps:</p>
-
-  <ol>
-
-   <li><p>If <var title="">maxHeight</var> is present but less than or
-   equal to zero, return without doing anything; abort these
-   steps.</p></li>
-
-   <li><p>Let <var title="">font</var> be the current font of the
-   context, as given by the <code
-   title="dom-context-2d-font">font</code> attribute.</p></li>
-
-   <li><p>Replace all the <span title="space character">space
-   characters</span> in <var title="">text</var> with U+0020 SPACE
-   characters.</p></li>
-
-   <li><p>Form a <em class="&#x0058;&#x0058;&#x0058;">whatever CSS ends up calling
-   vertical line boxes and inline boxes</em> containing the text <var
-   title="">text</var>, with all the properties at their initial
-   values except the 'font' property of the inline box set to <var
-   title="">font</var> and the 'direction' property of the inline
-   box set to <span>the directionality</span> of the <code>canvas</code>
-   element.</p></li>
-
-   <!- - if you insert a step here, make sure to adjust the next step's
-   final words - ->
-
-   <li><p>If the <var title="">maxHeight</var> argument was specified
-   and the hypothetical height of the <em class="&#x0058;&#x0058;&#x0058;">box</em>
-   in the hypothetical line box is greater than <var
-   title="">maxHeight</var> CSS pixels, then change <var
-   title="">font</var> to have a more condensed font (if one is
-   available or if a reasonably readable one can be synthesized by
-   applying an appropriate scale factor to the font) or a smaller
-   font, and return to the previous step.</p></li>
-
-   <li>
-
-    <p>Let the <var title="">anchor point</var> be a point on the <em
-    class="&#x0058;&#x0058;&#x0058;">inline box</var>, determined by the <code
-    title="dom-context-2d-textAlign">textAlign</code>, as follows:</p>
-
-    <p>Vertical position:</p>
-
-    <dl>
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">start</code></dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">left</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'ltr'</dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">right</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'rtl'</dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical
-     position be the top edge of the <em class="&#x0058;&#x0058;&#x0058;">inline
-     box</em>.</dd>
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">end</code></dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">right</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'ltr'</dt>
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">left</code> and <span>the directionality</span> of the
-     <code>canvas</code> element is 'rtl'</dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical
-     position be the bottom edge of the <em class="&#x0058;&#x0058;&#x0058;">inline
-     box</em>.</dd>
-
-
-     <dt> If <code
-     title="dom-context-2d-textAlign">textAlign</code> is <code
-     title="">center</code></dt>
-
-     <dd>Let the <var title="">anchor point</var>'s vertical position
-     be half way between the top and bottom edges of the <em
-     class="&#x0058;&#x0058;&#x0058;">inline box</em>.</dd>
-
-    </dl>
-
-    <p>Let the horizontal position be half way between the left and
-    right edges of the em box of the first available font of the <em
-    class="&#x0058;&#x0058;&#x0058;">inline box</em>.</p>
-
-   </li>
-
-   <li>
-
-    <p>Paint the hypothetical inline box as the shape given by the
-    text's glyphs, as transformed by the <span
-    title="dom-context-2d-transformation">current transformation
-    matrix</span>, and anchored and sized so that before applying the
-    <span title="dom-context-2d-transformation">current transformation
-    matrix</span>, the <var title="">anchor point</var> is at (<var
-    title="">x</var>, <var title="">y</var>) and each CSS pixel is
-    mapped to one coordinate space unit.</p>
-
-    <p>For <code
-    title="dom-context-2d-fillVerticalText">fillVerticalText()</code>
-    <code title="dom-context-2d-fillStyle">fillStyle</code> must be
-    applied and <code
-    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
-    ignored. For <code
-    title="dom-context-2d-strokeVerticalText">strokeVerticalText()</code>
-    the reverse holds and <code
-    title="dom-context-2d-strokeStyle">strokeStyle</code> must be
-    applied and <code
-    title="dom-context-2d-fillStyle">fillStyle</code> must be
-    ignored.</p>
-
-    <p>Text is painted without affecting the current path, and is
-    subject to <span title="shadows">shadow effects</span>, <span
-    title="dom-context-2d-globalAlpha">global alpha</span>, the <span
-    title="clipping region">clipping region</span>, and <span
-    title="dom-context-2d-globalCompositeOperation">global composition
-    operators</span>.</p>
-
-   </li>
-
-  </ol>
-
-v6DVT (also check for '- -' bits in the part above) -->
-
-  <p>The <dfn
-  title="dom-context-2d-measureText"><code>measureText()</code></dfn>
-  method takes one argument, <var title="">text</var>. When the method
-  is invoked, the user agent must replace all the <span title="space
-  character">space characters</span> in <var title="">text</var> with
-  U+0020 SPACE characters, and then must form a hypothetical
-  infinitely wide CSS line box containing a single inline box
-  containing the text <var title="">text</var>, with all the
-  properties at their initial values except the 'white-space' property
-  of the inline element set to 'pre' and the 'font' property of the
-  inline element set to the current font of the context as given by
-  the <code title="dom-context-2d-font">font</code> attribute, and
-  must then create a new <code>TextMetrics</code> object with its
-  <code title="dom-textmetrics-width">width</code> attribute set to
-  the width of that inline box, in CSS pixels.
-<!--ADD-TOPIC:Security-->
-  If doing these measurements requires using a font that has an
-  <span>origin</span> that is not the <span title="same
-  origin">same</span> as that of the <code>Document</code> object that
-  owns the <code>canvas</code> element (even if "using a font" means
-  just checking if that font has a particular glyph in it before
-  falling back to another font), then the method must throw a
-  <code>SecurityError</code> exception.
-<!--REMOVE-TOPIC:Security-->
-  Otherwise, it must return the new <code>TextMetrics</code> object.
-  <a href="#refsCSS">[CSS]</a></p>
-
-  <p>The <code>TextMetrics</code> interface is used for the objects
-  returned from <code
-  title="dom-context-2d-measureText">measureText()</code>. It has one
-  attribute, <dfn
-  title="dom-textmetrics-width"><code>width</code></dfn>, which is set
-  by the <code title="dom-context-2d-measureText">measureText()</code>
-  method.</p>
-
-  <p class="note">Glyphs rendered using <code
-  title="dom-context-2d-fillText">fillText()</code> and <code
-  title="dom-context-2d-strokeText">strokeText()</code> can spill out
-  of the box given by the font size (the em square size) and the width
-  returned by <code
-  title="dom-context-2d-measureText">measureText()</code> (the text
-  width). This version of the specification does not provide a way to
-  obtain the bounding box dimensions of the text. If the text is to be
-  rendered and removed, care needs to be taken to replace the entire
-  area of the canvas that the clipping region covers, not just the box
-  given by the em square height and measured text width.</p>
-
-  <!-- v5: Drawing text along a given path -->
-  <!-- v5: Adding text to a path -->
-  <!-- see also: http://www.w3.org/TR/SVG11/text.html#TextpathLayoutRules -->
-  <!-- see also: http://developer.mozilla.org/en/docs/Drawing_text_using_a_canvas -->
-
-  </div>
-
-  <p class="note">A future version of the 2D context API may provide a
-  way to render fragments of documents, rendered using CSS, straight
-  to the canvas. This would be provided in preference to a dedicated
-  way of doing multiline layout.</p>
-
-
-
   <h6>Drawing images to the canvas</h6>
 
   <p>To draw images onto the canvas, the <dfn

|