Skip to content

Commit

Permalink
[] (0) Add support for headers='' to the table model.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@1375 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Mar 18, 2008
1 parent 6e9dd83 commit b9e27b6
Show file tree
Hide file tree
Showing 2 changed files with 417 additions and 217 deletions.
304 changes: 196 additions & 108 deletions index
Expand Up @@ -19914,22 +19914,45 @@ notes on what would need to be defined for dashed lines:

<dd><code title=attr-tdth-rowspan><a href="#rowspan">rowspan</a></code>

<dd><code title=attr-td-headers><a href="#headers">headers</a></code>

<dt>DOM interface:

<dd>
<pre
class=idl>interface <dfn id=htmltabledatacellelement>HTMLTableDataCellElement</dfn> : <a href="#htmltablecellelement">HTMLTableCellElement</a> {
attribute DOMString <a href="#headers0" title=dom-td-headers>headers</a>;
};</pre>
</dl>

<p>The <code><a href="#td">td</a></code> element represents a data <a
href="#cell" title=concept-cell>cell</a> in a table.

<p>The <code><a href="#th">th</a></code> element may have a <dfn id=headers
title=attr-td-headers><code>headers</code></dfn> content attribute
specified. The <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute, if specified, must contain a
string consisting of an <a href="#unordered">unordered set of unique
space-separated tokens</a>, each of which must have the value of an ID of
a <code><a href="#th">th</a></code> element taking part in the same <a
href="#table1" title=concept-table>table</a> as the <code><a
href="#td">td</a></code> element (as defined by the <a
href="#table0">table model</a>).

<p>The exact effect of the attribute is described in detail in the <a
href="#algorithm2">algorithm for assigning header cells to data cells</a>,
which user agents must apply to determine the relationships between data
cells and header cells.

<p>The <code><a href="#td">td</a></code> element and its <code
title=attr-tdth-colspan><a href="#colspan">colspan</a></code> and <code
title=attr-tdth-rowspan><a href="#rowspan">rowspan</a></code> attributes
take part in the <a href="#table0">table model</a>.

<p>The <dfn id=headers0 title=dom-td-headers><code>headers</code></dfn> DOM
attribute must <a href="#reflect">reflect</a> the content attribute of the
same name.

<h4 id=the-th><span class=secno>3.13.10 </span>The <dfn
id=th><code>th</code></dfn> element</h4>

Expand Down Expand Up @@ -20014,10 +20037,9 @@ notes on what would need to be defined for dashed lines:
cells and header cells.

<p>The <code><a href="#th">th</a></code> element and its <code
title=attr-tdth-colspan><a href="#colspan">colspan</a></code>, <code
title=attr-tdth-rowspan><a href="#rowspan">rowspan</a></code>, and <code
title=attr-th-scope><a href="#scope0">scope</a></code> attributes take
part in the <a href="#table0">table model</a>.
title=attr-tdth-colspan><a href="#colspan">colspan</a></code> and <code
title=attr-tdth-rowspan><a href="#rowspan">rowspan</a></code> attributes
take part in the <a href="#table0">table model</a>.

<p>The <dfn id=scope1 title=dom-th-scope><code>scope</code></dfn> DOM
attribute must <a href="#reflect">reflect</a> the content attribute of the
Expand Down Expand Up @@ -20668,119 +20690,185 @@ notes on what would need to be defined for dashed lines:
id=algorithm2>algorithm for assigning header cells to data cells</dfn> is
as follows.

<p>For each header cell in the table, in <a href="#tree-order">tree
order</a>:

<ol>
<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>For each header cell in the table, in <a href="#tree-order">tree
order</a>, run these substeps:</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>
<ol>
<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>

<dl class=switch>
<dt>If it is in the <em title=attr-th-scope-row><a
href="#row">row</a></em> state
<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="">max</sub></var></span> and <span><var
title="">data<sub title="">y</sub></var>&nbsp;=&nbsp;<var
title="">header<sub title="">y</sub></var></span>.</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="">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="">max</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>

<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="">max</sub></var></span>.</p>

<dt>If it is in the <em title=attr-th-scope-rowgroup><a
href="#rowgroup">row group</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="">max</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>

<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>

<p>Otherwise, let (1, <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="">max</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>.</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="#row-group"
title=concept-row-group>row group</a>, then don't assign the header
cell to any data cells.</p>

<p>Otherwise, let (1, <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="">max</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>

<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>

<p>Otherwise, let (<var title="">group<sub title="">x</sub></var>, 1)
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="">max</sub></var></span>.</p>

<dt>Otherwise, it is in the <em title="">auto</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>

<p>Otherwise, let (<var title="">group<sub title="">x</sub></var>, 1)
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="">max</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>

<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>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="">max</sub></var></span>.</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="">max</sub></var></span> and <span><var
title="">data<sub title="">y</sub></var>&nbsp;=&nbsp;<var
title="">header<sub title="">y</sub></var></span>.</p>
</dl>
<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="">max</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="">max</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>
</dl>
</ol>

<li>
<p>For each data cell in the table, in <a href="#tree-order">tree
order</a>, run these substeps:</p>

<ol>
<li>
<p>If the data cell corresponds to a <code><a href="#td">td</a></code>
element that does not have a <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute specified, then skip
these substeps and move on to the next data cell (if any).</p>

<li>
<p>Otherwise, take the value of the <code title=attr-td-headers><a
href="#headers">headers</a></code> attribute and <a href="#split"
title="split a string on spaces">split it on spaces</a>, letting <var
title="">id list</var> be the list of tokens obtained.</p>

<li> <!-- XXX if nothing was added to this subalgorithm, then make it
a single paragraph instead of a nested list. -->

<p>For each token in the <var title="">id list</var>, run the following
steps:</p>

<ol>
<li>
<p>Let <var title="">id</var> be the token.

<li>
<p>If there is a header cell in the <a href="#table1"
title=concept-table>table</a> whose corresponding <code><a
href="#th">th</a></code> element has an ID that is equal to the
value of <var title="">id</var>, then assign that header cell to the
data cell.
</ol>
</ol>
</ol>

<h3 id=forms><span class=secno>3.14 </span>Forms</h3>
Expand Down

0 comments on commit b9e27b6

Please sign in to comment.