Skip to content

Commit

Permalink
[act] (0) Smarter table header cell / data cell association algorithm.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@1377 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 22, 2008
1 parent 2860529 commit 028f452
Show file tree
Hide file tree
Showing 2 changed files with 473 additions and 194 deletions.
294 changes: 198 additions & 96 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<h1 id=html-5>HTML 5</h1>

<h2 class="no-num no-toc" id=working>Working Draft &mdash; 20 March 2008</h2>
<h2 class="no-num no-toc" id=working>Working Draft &mdash; 21 March 2008</h2>

<p>You can take part in this work. <a
href="http://www.whatwg.org/mailing-list">Join the working group's
Expand Down Expand Up @@ -20151,7 +20151,7 @@ notes on what would need to be defined for dashed lines:
title="">height</var> such that the row group covers all the slots 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="">x<sub 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
Expand All @@ -20169,7 +20169,7 @@ notes on what would need to be defined for dashed lines:
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><a href="#colgroup">colgroup</a></code> elements. Not
every column is necessarily in a column group.

Expand Down Expand Up @@ -20696,137 +20696,213 @@ notes on what would need to be defined for dashed lines:
title="">header<sub title="">y</sub></var>) be the coordinate of the
slot to which the header cell is anchored.</p>

<li>
<p>Let <var title="">header<sub title="">width</sub></var> be the width
of the header cell.</p>

<li>
<p>Let <var title="">header<sub title="">height</sub></var> be the
height of the header cell.</p>

<li>
<p>Let <var title="">data cells</var> be a list of data cells,
initially empty.</p>

<li>
<p>Examine the <code title=attr-th-scope><a
href="#scope0">scope</a></code> attribute of the <code><a
href="#th">th</a></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><a
href="#row">row</a></em> state

<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><a href="#td">td</a></code>
elements that have a <code title=attr-td-headers><a
href="#headers">headers</a></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>

<dt>If it is in the <em title=attr-th-scope-col><a
href="#col0">column</a></em> state

<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><a href="#td">td</a></code>
elements that have a <code title=attr-td-headers><a
href="#headers">headers</a></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>

<dt>If it is in the <em title=attr-th-scope-rowgroup><a
href="#rowgroup">row group</a></em> state

<dd>
<p>If the header cell is not in a <a href="#row-group"
title=concept-row-group>row group</a>, then don't assign the header
cell to any data cells.</p>
title=concept-row-group>row group</a>, then do nothing.</p>

<p>Otherwise, let (1, <var title="">group<sub title="">y</sub></var>)
<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 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="">group<sub title="">y</sub></var>+<var
title="">height</var></span>, except for any data cells
corresponding to <code><a href="#td">td</a></code> elements that
have a <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute specified.</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="">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>

<dt>If it is in the <em title=attr-th-scope-colgroup><a
href="#colgroup0">column group</a></em> state

<dd>
<p>If the header cell is not in a <a href="#column0"
title=concept-column-group>column group</a>, then don't assign the
header cell to any data cells.</p>
title=concept-column-group>column group</a>, then do nothing.</p>

<p>Otherwise, let (<var title="">group<sub title="">x</sub></var>, 1)
<p>Otherwise, let (<var title="">group<sub 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><a href="#td">td</a></code> elements that
have a <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute specified.</p>
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>

<dt>Otherwise, it is in the <em title="">auto</em> state

<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><a href="#td">td</a></code>
elements that have a <code title=attr-td-headers><a
href="#headers">headers</a></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><a href="#td">td</a></code>
elements that have a <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute specified.</p>
<p>Run these steps:</p>

<ol>
<li>
<p>If the header cell is <a href="#equivalent">equivalent to a wide
cell</a>, 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>
<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>
<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>
<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>
<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>
<p>Increase <var title="">x</var> by 1.</p>

<li>
<p>Jump up to the step above labelled <i>horizontal</i>.</p>

<li>
<p>Let <var title="">y</var> equal <var title="">header<sub
title="">y</sub></var>.</p>

<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>
<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>
<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 <a
href="#equivalent">equivalent to a wide cell</a>, 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>
<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>
</ol>

<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>
<p>Increase <var title="">y</var> by 1.</p>

<li>
<p>Jump up to the step above labelled <i>vertical</i>.</p>

<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>
</ol>
</dl>

<li>
<p>Assign the header cell to all the data cells <var title="">data
cells</var> that correspond to <code><a href="#td">td</a></code>
elements that do not have a <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute specified.</p>
</ol>

<li>
Expand Down Expand Up @@ -20866,6 +20942,32 @@ notes on what would need to be defined for dashed lines:
</ol>
</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
id=equivalent>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 <a
href="#empty0" title="empty data cell">empty data cells</a>.

<p>A data cell is said to be an <dfn id=empty0>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>User agents may remove <a href="#empty0" title="empty data cell">empty
data cells</a> when analysing data in a <span title="concept
table">table</span>.

<h3 id=forms><span class=secno>3.14 </span>Forms</h3>
<!-- XXX everything in WF2 -->

Expand Down
Loading

0 comments on commit 028f452

Please sign in to comment.