NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 412 - * Header cells can now themselves have headers. * Reversed the way the header association algorithm is presented, such that it starts from a cell and reports the headers rather than generating the list of headers for each cell on a header-by-header...
* Header cells can now themselves have headers. * Reversed the way the header...
Status: NEW
Product: Validator.nu
Classification: Unclassified
Component: General
HEAD
All All
: P2 normal
Assigned To: Nobody
http://svn.whatwg.org/webapps/source?...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-01-04 16:54 CET by Henri Sivonen
Modified: 2009-11-23 17:17 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henri Sivonen 2009-01-04 16:54:34 CET
Index: source
===================================================================
--- source	(revision 2546)
+++ source	(revision 2547)
@@ -24531,43 +24531,23 @@
    <dt>Element-specific attributes:</dt>
    <dd><code title="attr-tdth-colspan">colspan</code></dd>
    <dd><code title="attr-tdth-rowspan">rowspan</code></dd>
-   <dd><code title="attr-td-headers">headers</code></dd>
-   <!-- XXXv2 char, to specify the decimal character used in numeric cells -->
+   <dd><code title="attr-tdth-headers">headers</code></dd>
+   <!-- v2 char, to specify the decimal character used in numeric cells -->
    <dt>DOM interface:</dt>
    <dd>
-    <pre class="idl">interface <dfn>HTMLTableDataCellElement</dfn> : <span>HTMLTableCellElement</span> {
-           attribute DOMString <span title="dom-td-headers">headers</span>;
-};</pre>
+    <pre class="idl">interface <dfn>HTMLTableDataCellElement</dfn> : <span>HTMLTableCellElement</span> {};</pre>
    </dd>
   </dl>
 
   <p>The <code>td</code> element represents a data <span
   title="concept-cell">cell</span> in a table.</p>
 
-  <p>The <code>td</code> element may have a <dfn
-  title="attr-td-headers"><code>headers</code></dfn> content attribute
-  specified. The <code title="attr-td-headers">headers</code>
-  attribute, if specified, must contain a string consisting of an
-  <span>unordered set of unique space-separated tokens</span>, each of
-  which must have the value of an ID of a <code>th</code> element
-  taking part in the same <span title="concept-table">table</span> as
-  the <code>td</code> element (as defined by the <span>table
-  model</span>).</p>
-
-  <p>The exact effect of the attribute is described in detail in the
-  <span>algorithm for assigning header cells to data cells</span>,
-  which user agents must apply to determine the relationships between
-  data cells and header cells.</p>
-
-  <p>The <code>td</code> element and its <code
-  title="attr-tdth-colspan">colspan</code> and <code
-  title="attr-tdth-rowspan">rowspan</code> attributes take part in the
+  <p class="note">The <code>td</code> element and its <code
+  title="attr-tdth-colspan">colspan</code>, <code
+  title="attr-tdth-rowspan">rowspan</code>, and <code
+  title="attr-tdth-headers">headers</code> attributes take part in the
   <span>table model</span>.</p>
 
-  <p>The <dfn title="dom-td-headers"><code>headers</code></dfn> DOM
-  attribute must <span>reflect</span> the content attribute of the
-  same name.</p>
-
 
   <h4>The <dfn><code>th</code></dfn> element</h4>
 
@@ -24581,6 +24561,7 @@
    <dt>Element-specific attributes:</dt>
    <dd><code title="attr-tdth-colspan">colspan</code></dd>
    <dd><code title="attr-tdth-rowspan">rowspan</code></dd>
+   <dd><code title="attr-tdth-headers">headers</code></dd>
    <dd><code title="attr-th-scope">scope</code></dd>
    <dt>DOM interface:</dt>
    <dd>
@@ -24604,30 +24585,38 @@
    <dt>The <dfn title="attr-th-scope-row"><code>row</code></dfn>
    keyword, which maps to the <i>row</i> state</dt>
 
-   <dd>The <i>row</i> state means the header cell applies to all the
-   remaining cells in the row.</dd>
+   <dd>The <i>row</i> state means the header cell applies to some of
+   the subsequent cells in the same row(s).</dd>
 
    <dt>The <dfn title="attr-th-scope-col"><code>col</code></dfn>
    keyword, which maps to the <i>column</i> state</dt>
 
-   <dd>The <i>column</i> state means the header cell applies to all
-   the remaining cells in the column.</dd>
+   <dd>The <i>column</i> state means the header cell applies to some
+   of the subsequent cells in the same column(s).</dd>
 
    <dt>The <dfn
    title="attr-th-scope-rowgroup"><code>rowgroup</code></dfn> keyword,
    which maps to the <i>row group</i> state</dt>
 
-   <dd>The <i>row group</i> state means the header cell applies to
-   all the remaining cells in the row group.</dd>
+   <dd>The <i>row group</i> state means the header cell applies to all
+   the remaining cells in the row group. A <code>th</code> element's
+   <code title="attr-th-scope">scope</code> attribute must not be in
+   the <span title="attr-th-scope-rowgroup">row group</span> state if
+   the element is not anchored in a <span
+   title="concept-row-group">row group</span>.</dd>
 
    <dt>The <dfn
    title="attr-th-scope-colgroup"><code>colgroup</code></dfn> keyword,
    which maps to the <i>column group</i> state</dt>
 
-   <dd>The <i>column group</i> state means the header cell applies
-   to all the remaining cells in the column group.</dd>
+   <dd>The <i>column group</i> state means the header cell applies to
+   all the remaining cells in the column group. A <code>th</code>
+   element's <code title="attr-th-scope">scope</code> attribute must
+   not be in the <span title="attr-th-scope-colgroup">column
+   group</span> state if the element is not anchored in a <span
+   title="concept-column-group">column group</span>.</dd>
 
-   <dt>The <i>auto</i> state</dt>
+   <dt>The <dfn title="attr-th-scope-auto">auto</dfn> state</dt>
 
    <dd>The <i>auto</i> state makes the header cell apply to a set of
    cells selected based on context.</dd>
@@ -24637,14 +24626,11 @@
   <p>The <code title="attr-th-scope">scope</code> attribute's
   <i>missing value default</i> is the <i>auto</i> state.</p>
 
-  <p>The exact effect of these values is described in detail in the
-  <span>algorithm for assigning header cells to data cells</span>,
-  which user agents must apply to determine the relationships between
-  data cells and header cells.</p>
-
-  <p>The <code>th</code> element and its <code
-  title="attr-tdth-colspan">colspan</code> and <code
-  title="attr-tdth-rowspan">rowspan</code> attributes take part in the
+  <p class="note">The <code>th</code> element and its <code
+  title="attr-tdth-colspan">colspan</code>, <code
+  title="attr-tdth-rowspan">rowspan</code>, <code
+  title="attr-tdth-headers">headers</code>, and <code
+  title="attr-th-scope">scope</code> attributes take part in the
   <span>table model</span>.</p>
 
   <p>The <dfn title="dom-th-scope"><code>scope</code></dfn> DOM
@@ -24664,6 +24650,22 @@
   attribute specified, whose value must be a <span>valid non-negative
   integer</span>.</p>
 
+  <p>The <code>td</code> and <code>th</code> element may have a <dfn
+  title="attr-tdth-headers"><code>headers</code></dfn> content
+  attribute specified. The <code
+  title="attr-tdth-headers">headers</code> attribute, if specified,
+  must contain a string consisting of an <span>unordered set of unique
+  space-separated tokens</span>, each of which must have the value of
+  an ID of a <code>th</code> element taking part in the same <span
+  title="concept-table">table</span> as the <code>td</code> or
+  <code>th</code> element (as defined by the <span>table
+  model</span>).</p>
+
+  <p class="note">The <code title="attr-tdth-colspan">colspan</code>,
+  <code title="attr-tdth-rowspan">rowspan</code>, and <code
+  title="attr-tdth-headers">headers</code> attributes take part in the
+  <span>table model</span>.</p>
+
   <p>The <code>td</code> and <code>th</code> elements implement
   interfaces that inherit from the <code>HTMLTableCellElement</code>
   interface:</p>
@@ -24671,6 +24673,7 @@
   <pre class="idl">interface <dfn>HTMLTableCellElement</dfn> : <span>HTMLElement</span> {
            attribute long <span title="dom-tdth-colSpan">colSpan</span>;
            attribute long <span title="dom-tdth-rowSpan">rowSpan</span>;
+           attribute DOMString <span title="dom-tdth-headers">headers</span>;
   readonly attribute long <span title="dom-tdth-cellIndex">cellIndex</span>;
 };</pre>
 
@@ -24686,6 +24689,10 @@
   attribute as a non-negative integer</span> returns an error, is also
   1.</p>
 
+  <p>The <dfn title="dom-tdth-headers"><code>headers</code></dfn> DOM
+  attribute must <span>reflect</span> the content attribute of the
+  same name.</p>
+
   <p>The <dfn title="dom-tdth-cellIndex"><code>cellIndex</code></dfn>
   DOM attribute must, if the element has a parent <code>tr</code>
   element, return the index of the cell's element in the parent
@@ -24729,9 +24736,12 @@
   title="">y</var>&nbsp;&lt;&nbsp;<var title="">cell<sub
   title="">y</sub></var>+<var title="">height</var></span>. Cells can
   either be <em>data cells</em> or <em>header cells</em>. Data cells
-  correspond to <code>td</code> elements, and have zero or more
-  associated header cells. Header cells correspond to <code>th</code>
-  elements.</p>
+  correspond to <code>td</code> elements, and header cells correspond
+  to <code>th</code> elements. Cells of both types can have zero or
+  more associated header cells.</p>
+
+  <p>It is possible, in certain error cases, for two cells to occupy
+  the same slot.</p>
 
   <p>A <dfn title="concept-row">row</dfn> is a complete set of slots
   from <span><var title="">x</var>=0</span> to <span><var
@@ -25437,10 +25447,11 @@
 
     <p>If the <var title="">current cell</var> element is a
     <code>th</code> element, let this new cell <var title="">c</var>
-    be a header cell; otherwise, let it be a data cell. To establish
-    what header cells apply to a data cell, use the <span>algorithm
-    for assigning header cells to data cells</span> described in the
-    next section.</p>
+    be a header cell; otherwise, let it be a data cell.</p>
+
+    <p>To establish which header cells apply to the <var
+    title="">current cell</var> element, use the <span>algorithm for
+    assigning header cells</span> described in the next section.</p>
 
     <p>If any of the slots involved already had a <span
     title="concept-cell">cell</span> covering them, then this is a
@@ -25510,408 +25521,430 @@
 
   <h5 id="header-and-data-cell-semantics">Forming relationships between data cells and header cells</h5>
 
-  <p>Each data cell can be assigned zero or more header cells. The
-  <dfn>algorithm for assigning header cells to data cells</dfn> is as
-  follows.</p>
+  <p>Each cell can be assigned zero or more header cells. The
+  <dfn>algorithm for assigning header cells</dfn> to a cell <var
+  title="">principal cell</var> is as follows.</p>
 
   <ol>
 
+
+   <!-- INITIALIZATION -->
+
    <li>
 
-    <p>For each header cell in the table, in <span>tree order</span>,
-    run these substeps:</p>
+    <p>Let <var title="">header list</var> be an empty list of
+    cells.</p>
 
-    <ol>
+   </li>
 
-     <li>
+   <li>
 
-      <p>Let (<var title="">header<sub title="">x</sub></var>, <var
-      title="">header<sub title="">y</sub></var>) be the coordinate of
-      the slot to which the header cell is anchored.</p>
+    <p>Let (<var title="">principal<sub title="">x</sub></var>, <var
+    title="">principal<sub title="">y</sub></var>) be the coordinate
+    of the slot to which the <var title="">principal cell</var> is
+    anchored.</p>
 
-     </li>
+   </li>
 
-     <li>
+   <li>
 
-      <p>Let <var title="">header<sub title="">width</sub></var> be
-      the width of the header cell.</p>
+    <dl class="switch">
 
-     </li>
+     <dt>If the <var title="">principal cell</var> has a <code
+     title="attr-tdth-headers">headers</code> attribute specified</dt>
 
-     <li>
+     <dd>
 
-      <p>Let <var title="">header<sub title="">height</sub></var> be
-      the height of the header cell.</p>
+      <!-- HEADERS="" -->
 
-     </li>
+      <ol>
 
-     <li>
+       <li>
 
-      <p>Let <var title="">data cells</var> be a list of data cells,
-      initially empty.</p>
+        <p>Take the value of the <var title="">principal cell</var>'s
+        <code title="attr-tdth-headers">headers</code> attribute and
+        <span title="split a string on spaces">split it on
+        spaces</span>, letting <var title="">id list</var> be the list
+        of tokens obtained.</p>
 
-     </li>
+       </li>
 
-     <li>
+       <li>
 
-      <p>Examine the <code title="attr-th-scope">scope</code>
-      attribute of the <code>th</code> element corresponding to the
-      header cell, and, based on its state, apply the appropriate
-      substep:</p>
+        <!-- support headers="" to <td> for legacy compat -->
+        <!-- note that it's not conforming though -->
+        <p>For each token in the <var title="">id list</var>, if the
+        first element in the <code>Document</code> with an ID equal to
+        the token is a cell in the same <span
+        title="concept-table">table</span>, and that cell is not the
+        <var title="">principal cell</var>, then add that cell to <var
+        title="">header list</var>.</p>
 
-      <dl class="switch">
+       </li>
 
-       <dt>If it is in the <i title="attr-th-scope-row">row</i> state</dt>
+      </ol>
 
-       <dd>
+     </dd>
 
-        <p>Add all the data cells that cover slots with coordinates
-        (<var title="">slot<sub title="">x</sub></var>, <var
-        title="">slot<sub title="">y</sub></var>), where <span><var
-        title="">header<sub title="">x</sub></var>+<var
-        title="">header<sub
-        title="">width</sub></var>&nbsp;&le;&nbsp;<var
-        title="">slot<sub title="">x</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">x<sub title="">width</sub></var></span> and
-        <span><var title="">header<sub
-        title="">y</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-        title="">y</sub></var>&nbsp;&lt;&nbsp;<var title="">header<sub
-        title="">y</sub></var>+<var title="">header<sub
-        title="">height</sub></var></span>, to the <var title="">data
-        cells</var> list.</p>
 
-       </dd>
+     <dt>If <var title="">principal cell</var> does not have a <code
+     title="attr-tdth-headers">headers</code> attribute specified</dt>
 
-       <dt>If it is in the <i title="attr-th-scope-col">column</i> state</dt>
+     <dd>
 
-       <dd>
+      <ol>
 
-        <p>Add all the data cells that cover slots with coordinates
-        (<var title="">slot<sub title="">x</sub></var>, <var
-        title="">slot<sub title="">y</sub></var>), where <span><var
-        title="">header<sub title="">x</sub></var>&nbsp;&le;&nbsp;<var
-        title="">slot<sub title="">x</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">header<sub title="">x</sub></var>+<var
-        title="">header<sub title="">width</sub></var></span> and
-        <span><var title="">header<sub title="">y</sub></var>+<var
-        title="">header<sub
-        title="">height</sub></var>&nbsp;&le;&nbsp;<var
-        title="">slot<sub title="">y</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">y<sub title="">height</sub></var></span>, to the <var
-        title="">data cells</var> list.</p>
+       <li>
 
-       </dd>
+        <p>Let <var title="">principal<sub title="">width</sub></var>
+        be the width of the <var title="">principal cell</var>.</p>
 
-       <dt>If it is in the <i title="attr-th-scope-rowgroup">row group</i> state</dt>
+       </li>
 
-       <dd>
+       <li>
 
-        <p>If the header cell is not in a <span
-        title="concept-row-group">row group</span>, then do
-        nothing.</p>
-
-        <p>Otherwise, let (0, <var title="">group<sub
-        title="">y</sub></var>) be the slot at which the row group is
-        anchored, let <var title="">height</var> be the number of rows
-        in the row group, and add all the data cells that cover slots
-        with coordinates (<var title="">slot<sub
-        title="">x</sub></var>, <var title="">slot<sub
-        title="">y</sub></var>), where <span><var title="">header<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-        title="">x</sub></var>&nbsp;&lt;&nbsp;<var title="">x<sub
-        title="">width</sub></var></span> and <span><var
-        title="">header<sub title="">y</sub></var>&nbsp;&le;&nbsp;<var
-        title="">slot<sub title="">y</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">group<sub title="">y</sub></var>+<var
-        title="">height</var></span>, to the <var title="">data
-        cells</var> list.</p>
+        <p>Let <var title="">principal<sub title="">height</sub></var>
+        be the height of the <var title="">principal cell</var>.</p>
 
-       </dd>
+       </li>
 
-       <dt>If it is in the <i title="attr-th-scope-colgroup">column group</i> state</dt>
 
-       <dd>
+       <!-- HORIZONTAL -->
 
-        <p>If the header cell is not anchored in a <span
-        title="concept-column-group">column group</span>, then do
-        nothing.</p>
-
-        <p>Otherwise, let (<var title="">group<sub
-        title="">x</sub></var>, 0) be the slot at which that column
-        group is anchored, let <var title="">width</var> be the number
-        of columns in the column group, and add all the data cells
-        that cover slots with coordinates (<var title="">slot<sub
-        title="">x</sub></var>, <var title="">slot<sub
-        title="">y</sub></var>), where <span><var title="">header<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-        title="">x</sub></var>&nbsp;&lt;&nbsp;<var title="">group<sub
-        title="">x</sub></var>+<var title="">width</var></span> and
-        <span><var title="">header<sub
-        title="">y</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-        title="">y</sub></var>&nbsp;&lt;&nbsp;<var title="">y<sub
-        title="">height</sub></var></span>, to the <var title="">data
-        cells</var> list.</p>
+       <li>
 
-       </dd>
+        <p>For each value of <var title="">y</var> from <var
+        title="">principal<sub title="">y</sub></var> to <span><var
+        title="">principal<sub title="">y</sub></var>+<var
+        title="">principal<sub title="">height</sub></var>-1</span>,
+        run the <span>internal algorithm for scanning and assigning
+        header cells</span>, with the <var title="">principal
+        cell</var>, the <var title="">header list</var>, the initial
+        coordinate (<var title="">principal<sub
+        title="">x</sub></var>,<var title="">y</var>), and the
+        increments <span>&Delta;<var title="">x</var>=&#x2212;1</span>
+        and <span>&Delta;<var title="">y</var>=0</span>.</p>
 
-       <dt>Otherwise, it is in the <i title="">auto</i> state</dt>
+       </li>
 
-       <dd>
 
-        <p>Run these steps:</p>
+       <!-- VERTICAL -->
 
-        <ol>
+       <li>
 
-         <li>
+        <p>For each value of <var title="">x</var> from <var
+        title="">principal<sub title="">x</sub></var> to <span><var
+        title="">principal<sub title="">x</sub></var>+<var
+        title="">principal<sub title="">width</sub></var>-1</span>,
+        run the <span>internal algorithm for scanning and assigning
+        header cells</span>, with the <var title="">principal
+        cell</var>, the <var title="">header list</var>, the initial
+        coordinate (<var title="">x</var>,<var title="">principal<sub
+        title="">y</sub></var>), and the increments <span>&Delta;<var
+        title="">x</var>=0</span> and <span>&Delta;<var
+        title="">y</var>=&#x2212;1</span>.</p>
 
-          <p>If the header cell is <span>equivalent to a wide
-          cell</span>, let <var title="">header<sub
-          title="">width</sub></var> equal <span><var title="">x<sub
-          title="">width</sub></var>-<var title="">header<sub
-          title="">x</sub></var></span>.</p>
+       </li>
 
-         </li>
 
-         <li>
+       <!-- ROW GROUP HEADERS -->
 
-          <p>Let <var title="">x</var> equal <span><var
-          title="">header<sub title="">x</sub></var>+<var
-          title="">header<sub title="">width</sub></var></span>.</p>
+       <li>
 
-         </li>
+        <p>If the <var title="">principal cell</var> is anchored in a
+        <span title="concept-row-group">row group</span>, then add all
+        header cells that are <span title="row group header">row group
+        headers</span> and are anchored in the same row group with an
+        <var title="">x</var>-coordinate less than or equal to
+        <span><var title="">principal<sub title="">x</sub></var>+<var
+        title="">principal<sub title="">width</sub></var>-1</span> and
+        a <var title="">y</var>-coordinate less than or equal to
+        <span><var title="">principal<sub title="">y</sub></var>+<var
+        title="">principal<sub title="">height</sub></var>-1</span> to
+        <var title="">header list</var>.</p>
 
-         <li>
+       </li>
 
-          <p>Let <var title="">y</var> equal <span><var
-          title="">header<sub title="">y</sub></var>+<var
-          title="">header<sub title="">height</sub></var></span>.</p>
 
-         </li>
+       <!-- COLUMN GROUP HEADERS -->
 
-         <li>
+       <li>
 
-          <p><i>Horizontal</i>: If <var title="">x</var> is equal to
-          <var title="">x<sub title="">width</sub></var>, then jump
-          down to the step below labeled <i>vertical</i>.</p>
+        <p>If the <var title="">principal cell</var> is anchored in a
+        <span title="concept-column-group">column group</span>, then
+        add all header cells that are <span title="column group
+        header">column group headers</span> and are anchored in the
+        same column group with an <var title="">x</var>-coordinate
+        less than or equal to <span><var title="">principal<sub
+        title="">x</sub></var>+<var title="">principal<sub
+        title="">width</sub></var>-1</span> and a <var
+        title="">y</var>-coordinate less than or equal to <span><var
+        title="">principal<sub title="">y</sub></var>+<var
+        title="">principal<sub title="">height</sub></var>-1</span> to
+        <var title="">header list</var>.</p>
 
-         </li>
+       </li>
 
-         <li>
+      </ol>
 
-          <p>If there is a header cell anchored at (<var
-          title="">x</var>, <var title="">header<sub
-          title="">y</sub></var>) with height <var title="">header<sub
-          title="">height</sub></var>, then jump down to the step
-          below labeled <i>vertical</i>.</p>
+     </dd>
 
-         </li>
+    </dl>
 
-         <li>
+   </li>
 
-          <p>Add all the data cells that cover slots with coordinates
-          (<var title="">slot<sub title="">x</sub></var>, <var
-          title="">slot<sub title="">y</sub></var>), where <span><var
-          title="">slot<sub title="">x</sub></var>&nbsp;=&nbsp;<var
-          title="">x</var></span> and <span><var title="">header<sub
-          title="">y</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-          title="">y</sub></var>&nbsp;&lt;&nbsp;<var
-          title="">header<sub title="">y</sub></var>+<var
-          title="">header<sub title="">height</sub></var></span>, to
-          the <var title="">data cells</var> list.</p>
 
-         </li>
+   <!-- CLEANUP -->
 
-         <li>
+   <li>
 
-          <p>Increase <var title="">x</var> by 1.</p>
+    <p>Remove all the <span title="empty cell">empty cells</span> from
+    the <var title="">header list</var>.</p>
 
-         </li>
+   </li>
 
-         <li>
+   <li>
 
-          <p>Jump up to the step above labeled <i>horizontal</i>.</p>
+    <p>Remove any duplicates from the <var title="">header
+    list</var>.</p>
 
-         </li>
+   </li>
 
-         <li>
+   <li>
 
-          <p><i>Vertical</i>: If <var title="">y</var> is equal to
-          <var title="">y<sub title="">height</sub></var>, then jump
-          to the step below labeled <i>end</i>.</p>
+    <p>Assign the headers in the <var title="">header list</var> to
+    the <var title="">principal cell</var>.</p>
 
-         </li>
+   </li>
 
-         <li>
+  </ol>
 
-          <p>If there is a header cell <var title="">cell</var>
-          anchored at (<var title="">header<sub
-          title="">x</sub></var>, <var title="">y</var>), then follow
-          these substeps:</p>
+  <p>The <dfn>internal algorithm for scanning and assigning header
+  cells</dfn>, given a <var title="">principal cell</var>, a <var
+  title="">header list</var>, a (<var title="">initial<sub
+  title="">x</sub></var>, <var title="">initial<sub
+  title="">y</sub></var>) initial coordinate, and &Delta;<var
+  title="">x</var> and &Delta;<var title="">y</var> increments, is as
+  follows:</p>
 
-          <ol>
+  <ol>
 
-           <li>
+   <li>
 
-            <p>If the header cell <var title="">cell</var> is
-            <span>equivalent to a wide cell</span>, then let <var
-            title="">width</var> be <span><var title="">x<sub
-            title="">width</sub></var>-<var title="">header<sub
-            title="">x</sub></var></span>. Otherwise, let <var
-            title="">width</var> be the width of the header cell <var
-            title="">cell</var>.</p>
+    <p>Let <var title="">x</var> equal <var title="">initial<sub
+    title="">x</sub></var>.</p>
 
-           </li>
+   </li>
 
-           <li>
+   <li>
 
-            <p>If <var title="">width</var> is equal to <var
-            title="">header<sub title="">width</sub></var>, then jump
-            to the step below labeled <i>end</i>.</p>
+    <p>Let <var title="">y</var> equal <var title="">initial<sub
+    title="">y</sub></var>.</p>
 
-           </li>
+   </li>
 
-          </ol>
+   <li>
 
-         </li>
+    <p>Let <var title="">opaque headers</var> be an empty list of
+    cells.</p>
 
-         <li>
+   </li>
 
-          <p>Add all the data cells that cover slots with coordinates
-          (<var title="">slot<sub title="">x</sub></var>, <var
-          title="">slot<sub title="">y</sub></var>), where <span><var
-          title="">header<sub
-          title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-          title="">x</sub></var>&nbsp;&lt;&nbsp;<var
-          title="">header<sub title="">x</sub></var>+<var
-          title="">header<sub title="">width</sub></var></span> and
-          <span><var title="">slot<sub
-          title="">y</sub></var>&nbsp;=&nbsp;<var
-          title="">y</var></span>, to the <var title="">data
-          cells</var> list.</p>
+   <li>
 
-         </li>
+    <dl class="switch">
 
-         <li>
+     <dt>If <var title="">principal cell</var> is a header cell</dt>
 
-          <p>Increase <var title="">y</var> by 1.</p>
+     <dd><p>Let <var title="">in header block</var> be true, and let
+     <var title="">headers from current header block</var> be a list
+     of cells containing just the <var title="">principal
+     cell</var>.</p></dd>
 
-         </li>
+     <dt>Otherwise</dt>
 
-         <li>
+     <dd><p>Let <var title="">in header block</var> be false and let
+     <var title="">headers from current header block</var> be an
+     empty list of cells.</p>
 
-          <p>Jump up to the step above labeled <i>vertical</i>.</p>
+    </dl>
 
-         </li>
+   </li>
 
-         <li>
+   <li>
 
-          <p><i>End</i>: Coalesce all the duplicate entries in the
-          <var title="">data cells</var> list, so that each data cell
-          is only present once, in tree order.</p>
+    <p><i>Loop</i>: Increment <var title="">x</var> by &Delta;<var
+    title="">x</var>; increment <var title="">y</var> by &Delta;<var
+    title="">y</var>.</p>
 
-         </li>
+    <p class="note">For each invocation of this algorithm, one of
+    &Delta;<var title="">x</var> and &Delta;<var title="">y</var> will
+    be &#x2212;1, and the other will be 0.</p>
 
-        </ol>
+   </li>
 
-       </dd>
+   <li>
 
-      </dl>
+    <p>If either <var title="">x</var> or <var title="">y</var> is
+    less than 0, then abort this internal algorithm.</p>
 
-     </li>
+   </li>
 
-     <li>
+   <li>
 
-      <p>Assign the header cell to all the data cells in the <var
-      title="">data cells</var> list that correspond to
-      <code>td</code> elements that do not have a <code
-      title="attr-td-headers">headers</code> attribute specified.</p>
+    <p>If there is no cell covering slot (<var title="">x</var>,
+    <var title="">y</var>), or if there is more than one cell
+    covering slot (<var title="">x</var>, <var title="">y</var>),
+    return to the substep marked <i>loop</i>.</p>
 
-     </li>
+   </li>
 
-    </ol>
+   <li>
+
+    <p>Let <var title="">current cell</var> be the cell covering
+    slot (<var title="">x</var>, <var title="">y</var>).</p>
 
    </li>
 
    <li>
 
-    <p>For each data cell in the table, in <span>tree order</span>,
-    run these substeps:</p>
+    <dl class="switch">
 
-    <ol>
+     <dt>If <var title="">current cell</var> is a header cell</dt>
 
-     <li>
+     <dd>
 
-      <p>If the data cell corresponds to a <code>td</code> element
-      that does not have a <code
-      title="attr-td-headers">headers</code> attribute specified, then
-      skip these substeps and move on to the next data cell (if
-      any).</p>
+      <ol>
 
-     </li>
+       <li><p>Set <var title="">in header block</var> to
+       true.</p></li>
 
-     <li>
+       <li><p>Add <var title="">current cell</var> to <var
+       title="">headers from current header block</var>.</p></li>
 
-      <p>Otherwise, take the value of the <code
-      title="attr-td-headers">headers</code> attribute and <span
-      title="split a string on spaces">split it on spaces</span>,
-      letting <var title="">id list</var> be the list of tokens
-      obtained.</p>
+       <li><p>Let <var title="">blocked</var> be false.</p></li>
 
-     </li>
+       <li>
 
-     <li>
+        <dl class="switch">
 
-      <!-- XXX if nothing was added to this subalgorithm, then make it
-      a single paragraph instead of a nested list. -->
+         <dt>If &Delta;<var title="">x</var> is 0</dt>
 
-      <p>For each token in the <var title="">id list</var>, run the
-      following steps:</p>
+         <dd>
 
-      <ol>
+          <p>If there is no cell in the <var title="">opaque
+          headers</var> list anchored with the same <var
+          title="">x</var>-coordinate as the <var title="">current
+          cell</var>, and with the same width as <var title="">current
+          cell</var>, then let <var title="">blocked</var> be
+          true.</p>
+
+          <p>If the <var title="">current cell</var> is not a
+          <span>column header</span>, then let <var
+          title="">blocked</var> be true.</p>
+
+         </dd>
 
-       <li><p>Let <var title="">id</var> be the token.</p></li>
+         <dt>If &Delta;<var title="">y</var> is 0</dt>
 
-       <li><p>If there is a header cell in the <span
-       title="concept-table">table</span> whose corresponding
-       <code>th</code> element has an ID that is equal to the value of
-       <var title="">id</var>, then assign the first such header cell
-       in tree order to the data cell.</p></li>
+         <dd>
+
+          <p>If there is no cell in the <var title="">opaque
+          headers</var> list anchored with the same <var
+          title="">y</var>-coordinate as the <var title="">current
+          cell</var>, and with the same height as <var
+          title="">current cell</var>, then let <var
+          title="">blocked</var> be true.</p>
+
+          <p>If the <var title="">current cell</var> is not a
+          <span>row header</span>, then let <var
+          title="">blocked</var> be true.</p>
+
+         </dd>
+
+        </dl>
+
+       </li>
+
+       <li><p>If <var title="">blocked</var> is false, then add the
+       <var title="">current cell</var> to the <var title="">headers
+       list</var>.</p></li>
 
       </ol>
 
-     </li>
+     </dd>
 
-    </ol>
+     <dt>If <var title="">current cell</var> is a data cell and <var title="">in header block</var> is true</dt>
+
+     <dd><p>Set <var title="">in header block</var> to false. Add
+     all the cells in <var title="">headers from current header
+     block</var> to the <var title="">opaque headers</var> list, and
+     empty the <var title="">headers from current header block</var>
+     list.</p>
+
+    </dl>
+
+   </li>
+
+   <li>
+
+    <p>Return to the step marked <i>loop</i>.</p>
 
    </li>
 
   </ol>
 
-  <p>A header cell anchored at (<var title="">header<sub
-  title="">x</sub></var>, <var title="">header<sub
-  title="">y</sub></var>) with width <var title="">header<sub
-  title="">width</sub></var> and height <var title="">header<sub
-  title="">height</sub></var> is said to be <dfn>equivalent to a wide
-  cell</dfn> if all the slots with coordinates (<var title="">slot<sub
-  title="">x</sub></var>, <var title="">slot<sub
-  title="">y</sub></var>), where <span><var title="">header<sub
-  title="">x</sub></var>+<var title="">header<sub
-  title="">width</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-  title="">x</sub></var>&nbsp;&lt;&nbsp;<var title="">x<sub
-  title="">width</sub></var></span> and <span><var title="">header<sub
-  title="">y</sub></var>&nbsp;&le;&nbsp;<var title="">slot<sub
-  title="">y</sub></var>&nbsp;&lt;&nbsp;<var title="">header<sub
-  title="">y</sub></var>+<var title="">header<sub
-  title="">height</sub></var></span>, are all either empty or covered
-  by <span title="empty data cell">empty data cells</span>.</p>
+  <p>A header cell anchored at the slot with coordinate (<var
+  title="">x</var>, <var title="">y</var>) with width <var
+  title="">width</var> and height <var title="">height</var> is said
+  to be a <dfn>column header</dfn> if any of the following conditions
+  are true:</p>
 
-  <p>A data cell is said to be an <dfn>empty data cell</dfn> if it
-  contains no elements and its text content, if any, consists only of
-  <span>White_Space</span> characters.</p>
+  <ul>
+
+   <li>The cell's <code title="attr-th-scope">scope</code> attribute
+   is in the <span title="attr-th-scope-col">column</span> state</li>
+
+   <li>The cell's <code title="attr-th-scope">scope</code> attribute
+   is in the <span title="attr-th-scope-auto">auto</span> state, and
+   there are no data cells in any of the cells covering slots with
+   <var title="">y</var>-coordinates <var title="">y</var>
+   .. <span><var title="">y</var>+<var
+   title="">height</var>-1</span>.</li>
 
-  <p>User agents may remove <span title="empty data cell">empty data
-  cells</span> when analyzing data in a <span
-  title="concept-table">table</span>.</p>
+  </ul>
+
+  <p>A header cell anchored at the slot with coordinate (<var
+  title="">x</var>, <var title="">y</var>) with width <var
+  title="">width</var> and height <var title="">height</var> is said
+  to be a <dfn>row header</dfn> if any of the following conditions
+  are true:</p>
+
+  <ul>
+
+   <li>The cell's <code title="attr-th-scope">scope</code> attribute
+   is in the <span title="attr-th-scope-row">row</span> state</li>
+
+   <li>The cell's <code title="attr-th-scope">scope</code> attribute
+   is in the <span title="attr-th-scope-auto">auto</span> state, and
+   the cells is not a <span>column header</span>, and there are no
+   data cells in any of the cells covering slots with <var
+   title="">x</var>-coordinates <var title="">x</var> .. <span><var
+   title="">x</var>+<var title="">width</var>-1</span>.</li>
+
+  </ul>
+
+  <p>A header cell is said to be a <dfn>column group header</dfn> if
+  its <code title="attr-th-scope">scope</code> attribute is in the
+  <span title="attr-th-scope-colgroup">column group</span> state.</p>
+
+  <p>A header cell is said to be a <dfn>row group header</dfn> if
+  its <code title="attr-th-scope">scope</code> attribute is in the
+  <span title="attr-th-scope-rowgroup">row group</span> state.</p>
+
+  <p>A cell is said to be an <dfn>empty cell</dfn> if it contains no
+  elements and its text content, if any, consists only of
+  <span>White_Space</span> characters.</p>
Comment 1 Henri Sivonen 2009-08-21 10:20:11 CEST
The original summary for this bug was longer than 255 characters, and so it was truncated when Bugzilla was upgraded. The original summary was:

* Header cells can now themselves have headers. * Reversed the way the header association algorithm is presented, such   that it starts from a cell and reports the headers rather than   generating the list of headers for each cell on a header-by-header   basis. * Made it so that if headers="" points to a <td> element, the   association is now set up, despite being non-conforming. * Header cells that are automatically associating now no longer stop   associating when they hit equivalent cells until they have also hit   a data cell. * The "col" and "row" scope values now act like the implied auto value   except that they force the direction. * Empty header cells no longer get automatically associated. * Removed the wide header cell heuristic. * Made headers="" use the same ID discovery mechanism as   getElementById() (namely, first match), to avoid implementations   having to support multiple such mechanisms. * Made the spec define if a header is a column header or a row header   in the case where scope="" is omitted. * Made scope=rowgroup and scope=colgroup non-conforming when not in an   appropriate group.