NOTE: The current preferred location for bug reports is the GitHub issue tracker.
Bug 144 - Smarter table header cell / data cell association algorithm.
Smarter table header cell / data cell association algorithm.
Status: NEW
Product: Validator.nu
Classification: Unclassified
Component: Non-schema checkers
HEAD
All All
: P2 normal
Assigned To: Nobody
http://svn.whatwg.org/webapps/source?...
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-03-23 12:10 CET by Nobody
Modified: 2009-11-23 17:16 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 Nobody 2008-03-23 12:10:34 CET
Index: source
===================================================================
--- source	(revision 1376)
+++ source	(revision 1377)
@@ -17645,7 +17645,7 @@
   with coordinates (<var title="">x</var>, <var title="">y</var>)
   where <span>0&nbsp;&le;&nbsp;<var
   title="">x</var>&nbsp;&lt;&nbsp;<var title="">x<sub
-  title="">width</sub></var>-1</span> and <span><var
+  title="">width</sub></var></span> and <span><var
   title="">group<sub title="">y</sub></var>&nbsp;&le;&nbsp;<var
   title="">y</var>&nbsp;&lt;&nbsp;<var title="">group<sub
   title="">y</sub></var>+<var title="">height</var></span>. Row groups
@@ -17663,7 +17663,7 @@
   title="">x</var>&nbsp;&lt;&nbsp;<var title="">group<sub
   title="">x</sub></var>+<var title="">width</var></span> and
   <span>0&nbsp;&le;&nbsp;<var title="">y</var>&nbsp;&lt;&nbsp;<var
-  title="">y<sub title="">height</sub></var>-1</span>. Column groups
+  title="">y<sub title="">height</sub></var></span>. Column groups
   correspond to <code>colgroup</code> elements. Not every column is
   necessarily in a column group.</p>
 
@@ -18379,36 +18379,52 @@
 
      <li>
 
+      <p>Let <var title="">header<sub title="">width</sub></var> be
+      the width of the header cell.</p>
+
+     </li>
+
+     <li>
+
+      <p>Let <var title="">header<sub title="">height</sub></var> be
+      the height of the header cell.</p>
+
+     </li>
+
+     <li>
+
+      <p>Let <var title="">data cells</var> be a list of data cells,
+      initially empty.</p>
+
+     </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>
 
-      <!-- XXX this entire switch statement should be changed around
-      so that it just defines the area to assign headers in, and the
-      direction to do the assigning in, and then defers to a set of
-      steps below it that then does the assigning. Then, we can
-      support colspaning/rowspaning headers and can stop when we hit
-      other headers, if we want to do that. -->
-
       <dl class="switch">
 
        <dt>If it is in the <em title="attr-th-scope-row">row</em> state</dt>
 
        <dd>
 
-        <p>Assign the header cell to any data cells anchored at slots
-        with coordinates (<var title="">data<sub
-        title="">x</sub></var>, <var title="">data<sub
-        title="">y</sub></var>) where <span><var title="">header<sub
-        title="">x</sub></var>&nbsp;&lt;&nbsp;<var title="">data<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">x<sub
-        title="">width</sub></var></span> and <span><var
-        title="">data<sub title="">y</sub></var>&nbsp;=&nbsp;<var
-        title="">header<sub title="">y</sub></var></span>, except for
-        any data cells corresponding to <code>td</code> elements that
-        have a <code title="attr-td-headers">headers</code> attribute
-        specified.</p>
+        <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>
 
@@ -18416,18 +18432,19 @@
 
        <dd>
 
-        <p>Assign the header cell to any data cells anchored at slots
-        with coordinates (<var title="">data<sub
-        title="">x</sub></var>, <var title="">data<sub
-        title="">y</sub></var>) where <span><var title="">data<sub
-        title="">x</sub></var>&nbsp;=&nbsp;<var title="">header<sub
-        title="">x</sub></var></span> and <span><var
-        title="">header<sub title="">y</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">data<sub title="">y</sub></var>&nbsp;&le;&nbsp;<var
-        title="">y<sub title="">height</sub></var></span>, except for any
-        data cells corresponding to <code>td</code> elements that have
-        a <code title="attr-td-headers">headers</code> attribute
-        specified.</p>
+        <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>
 
        </dd>
 
@@ -18436,26 +18453,24 @@
        <dd>
 
         <p>If the header cell is not in a <span
-        title="concept-row-group">row group</span>, then don't assign
-        the header cell to any data cells.</p>
+        title="concept-row-group">row group</span>, then do
+        nothing.</p>
 
-        <p>Otherwise, let (1, <var title="">group<sub
+        <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 assign the header cell to any data cells
-        anchored at slots with coordinates (<var title="">data<sub
-        title="">x</sub></var>, <var title="">data<sub
-        title="">y</sub></var>) where <span><var title="">header<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">data<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">x<sub
+        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="">data<sub title="">y</sub></var>&nbsp;&lt;&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>, except for any data cells
-        corresponding to <code>td</code> elements that have a <code
-        title="attr-td-headers">headers</code> attribute
-        specified.</p>
+        title="">height</var></span>, to the <var title="">data
+        cells</var> list.</p>
 
        </dd>
 
@@ -18464,26 +18479,24 @@
        <dd>
 
         <p>If the header cell is not in a <span
-        title="concept-column-group">column group</span>, then don't
-        assign the header cell to any data cells.</p>
+        title="concept-column-group">column group</span>, then do
+        nothing.</p>
 
         <p>Otherwise, let (<var title="">group<sub
-        title="">x</sub></var>, 1) be the slot at which the column
+        title="">x</sub></var>, 0) be the slot at which the column
         group is anchored, let <var title="">width</var> be the number
-        of columns in the column group, and assign the header cell to
-        any data cells anchored at slots with coordinates (<var
-        title="">data<sub title="">x</sub></var>, <var
-        title="">data<sub title="">y</sub></var>) where <span><var
-        title="">header<sub title="">x</sub></var>&nbsp;&le;&nbsp;<var
-        title="">data<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="">data<sub
-        title="">y</sub></var>&nbsp;&le;&nbsp;<var title="">y<sub
-        title="">height</sub></var></span>, except for any data cells
-        corresponding to <code>td</code> elements that have a <code
-        title="attr-td-headers">headers</code> attribute
-        specified.</p>
+        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>
 
        </dd>
 
@@ -18491,40 +18504,168 @@
 
        <dd>
 
-        <p>If the header cell is not in the first row of the table, or
-        not in the first cell of a row, then don't assign the header
-        cell to any data cells.</p>
-
-        <p class="big-issue">This is shortly to be made better and
-        more magical.</p>
-
-        <p>Otherwise, if the header cell is in the first row of the
-        table, assign the header cell to any data cells anchored at
-        slots with coordinates (<var title="">data<sub
-        title="">x</sub></var>, <var title="">data<sub
-        title="">y</sub></var>) where <span><var title="">data<sub
-        title="">x</sub></var>&nbsp;=&nbsp;<var title="">header<sub
-        title="">x</sub></var></span> and <span><var
-        title="">header<sub title="">y</sub></var>&nbsp;&lt;&nbsp;<var
-        title="">data<sub title="">y</sub></var>&nbsp;&le;&nbsp;<var
-        title="">y<sub title="">height</sub></var></span>, except for any
-        data cells corresponding to <code>td</code> elements that have
-        a <code title="attr-td-headers">headers</code> attribute
-        specified.</p>
-
-        <p>Otherwise, the header cell is in the first column of the
-        table; assign the header cell to any data cells anchored at
-        slots with coordinates (<var title="">data<sub
-        title="">x</sub></var>, <var title="">data<sub
-        title="">y</sub></var>) where <span><var title="">header<sub
-        title="">x</sub></var>&nbsp;&lt;&nbsp;<var title="">data<sub
-        title="">x</sub></var>&nbsp;&le;&nbsp;<var title="">x<sub
-        title="">width</sub></var></span> and <span><var
-        title="">data<sub title="">y</sub></var>&nbsp;=&nbsp;<var
-        title="">header<sub title="">y</sub></var></span>, except for
-        any data cells corresponding to <code>td</code> elements that
-        have a <code title="attr-td-headers">headers</code> attribute
-        specified.</p>
+        <p>Run these steps:</p>
+
+        <ol>
+
+         <li>
+
+          <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>. <a
+          href="#refsUNICODE">[UNICODE]</a></p>
+
+         </li>
+
+         <li>
+
+          <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><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 labelled <i>vertical</i>.</p>
+
+         </li>
+
+         <li>
+
+          <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 labelled <i>vertical</i>.</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="">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>
+
+         <li>
+
+          <p>Increase <var title="">x</var> by 1.</p>
+
+         </li>
+
+         <li>
+
+          <p>Jump up to the step above labelled <i>horizontal</i>.</p>
+
+         </li>
+
+         <li>
+
+          <p>Let <var title="">y</var> equal <var title="">header<sub
+          title="">y</sub></var>.</p>
+
+         </li>
+
+         <li>
+
+          <p><i>Vertical</i>: 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>
+
+         <li>
+
+          <p>If <var title="">y</var> is equal to <var title="">y<sub
+          title="">height</sub></var>, then jump to the step below
+          labelled <i>end</i>.</p>
+
+         </li>
+
+         <li>
+
+          <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>
+
+          <ol>
+
+           <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>
+
+           </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 labelled <i>end</i>.</p>
+
+           </li>
+
+          </ol>
+
+         </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>
+
+          <p>Increase <var title="">y</var> by 1.</p>
+
+         </li>
+
+         <li>
+
+          <p>Jump up to the step above labelled <i>vertical</i>.</p>
+
+         </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>
+
+         </li>
+
+        </ol>
 
        </dd>
 
@@ -18532,6 +18673,15 @@
 
      </li>
 
+     <li>
+
+      <p>Assign the header cell to all the data cells <var
+      title="">data cells</var> that correspond to <code>td</code>
+      elements that do not have a <code
+      title="attr-td-headers">headers</code> attribute specified.</p>
+
+     </li>
+
     </ol>
 
    </li>
@@ -18591,6 +18741,33 @@
 
   </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 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
+  characters in the Unicode character class Zs. <a
+  href="#refsUNICODE">[UNICODE]</a></p>
+
+  <p>User agents may remove <span title="empty data cell">empty data
+  cells</span> when analysing data in a <span title="concept
+  table">table</span>.</p>
+
 
   <h3 id="forms">Forms</h3>
   <!-- XXX everything in WF2 -->