Annotation of html5/spec/interactive-elements.html, revision 1.181

1.2       mike        1: <!DOCTYPE HTML>
1.6       mike        2: <html lang="en-US-x-Hixie"><head><title>4.11 Interactive elements &#8212; HTML 5</title><style type="text/css">
1.1       mike        3:    pre { margin-left: 2em; white-space: pre-wrap; }
                      4:    h2 { margin: 3em 0 1em 0; }
                      5:    h3 { margin: 2.5em 0 1em 0; }
                      6:    h4 { margin: 2.5em 0 0.75em 0; }
                      7:    h5, h6 { margin: 2.5em 0 1em; }
                      8:    h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
                      9:    h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
                     10:    p { margin: 1em 0; }
                     11:    hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
                     12:    dl, dd { margin-top: 0; margin-bottom: 0; }
                     13:    dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
                     14:    dt + dt { margin-top: 0; }
                     15:    dd dt { margin-top: 0.25em; margin-bottom: 0; }
                     16:    dd p { margin-top: 0; }
                     17:    dd dl + p { margin-top: 1em; }
                     18:    dd table + p { margin-top: 1em; }
                     19:    p + * > li, dd li { margin: 1em 0; }
                     20:    dt, dfn { font-weight: bold; font-style: normal; }
                     21:    dt dfn { font-style: italic; }
                     22:    pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
                     23:    pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
                     24:    pre em { font-weight: bolder; font-style: normal; }
                     25:    @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
                     26:    var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
                     27:    table { border-collapse: collapse; border-style: hidden hidden none hidden; }
                     28:    table thead { border-bottom: solid; }
                     29:    table tbody th:first-child { border-left: solid; }
                     30:    table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
                     31:    blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
                     32: 
                     33:    .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
                     34:    .matrix, .matrix td { border: none; text-align: right; }
                     35:    .matrix { margin-left: 2em; }
                     36:    .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
                     37:    .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
                     38:    .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
1.2       mike       39:    .applies th > * { display: block; }
1.1       mike       40:    .applies thead code { display: block; }
                     41:    .applies td { text-align: center; }
                     42:    .applies .yes { background: yellow; }
                     43: 
                     44:    .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
                     45:    img.extra { float: right; }
                     46:    pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
                     47:    pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
                     48:    pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
                     49:    pre.css:first-line { color: #AAAA50; }
                     50:    dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #EEFFEE; }
                     51:    hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
                     52:    dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
                     53:    dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
                     54:    dl.domintro dd p { margin: 0.5em 0; }
                     55:    dl.switch { padding-left: 2em; }
                     56:    dl.switch > dt { text-indent: -1.5em; }
                     57:    dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
                     58:    dl.triple { padding: 0 0 0 1em; }
                     59:    dl.triple dt, dl.triple dd { margin: 0; display: inline }
                     60:    dl.triple dt:after { content: ':'; }
                     61:    dl.triple dd:after { content: '\A'; white-space: pre; }
                     62:    .diff-old { text-decoration: line-through; color: silver; background: transparent; }
                     63:    .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
                     64:    a .diff-new { border-bottom: 1px blue solid; }
                     65: 
                     66:    h2 { page-break-before: always; }
                     67:    h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
                     68:    h1 + h2, hr + h2.no-toc { page-break-before: auto; }
                     69: 
                     70:    p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
                     71: 
                     72:    div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
                     73:    div.head p { margin: 0; }
                     74:    div.head h1 { margin: 0; }
                     75:    div.head .logo { float: right; margin: 0 1em; }
                     76:    div.head .logo img { border: none } /* remove border from top image */
                     77:    div.head dl { margin: 1em 0; }
                     78:    p.copyright { font-size: x-small; font-style: oblique; margin: 0; }
                     79: 
                     80:    body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
                     81:    body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
                     82:    body > .toc > li > * { margin-bottom: 0.5em; }
                     83:    body > .toc > li > * > li > * { margin-bottom: 0.25em; }
                     84:    .toc, .toc li { list-style: none; }
                     85: 
                     86:    .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
                     87:    .brief li { margin: 0; padding: 0; }
                     88:    .brief li p { margin: 0; padding: 0; }
                     89: 
                     90:    .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
                     91:    .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
                     92:    .category-list li { display: inline; }
                     93:    .category-list li:not(:last-child)::after { content: ', '; }
                     94:    .category-list li > span, .category-list li > a { text-transform: lowercase; }
                     95:    .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
                     96: 
                     97:    .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
                     98:    .XXX > :first-child { margin-top: 0; }
                     99:    p .XXX { line-height: 3em; }
1.153     mike      100:    .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
                    101:    .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
                    102:    .annotation :link, .annotation :visited { color: inherit; }
                    103:    .annotation :link:hover, .annotation :visited:hover { background: transparent; }
                    104:    .annotation span { border: none ! important; }
1.1       mike      105:    .note { color: green; background: transparent; font-family: sans-serif; }
                    106:    .warning { color: red; background: transparent; }
                    107:    .note, .warning { font-weight: bolder; font-style: italic; }
                    108:    p.note, div.note { padding: 0.5em 2em; }
                    109:    span.note { padding: 0 2em; }
                    110:    .note p:first-child, .warning p:first-child { margin-top: 0; }
                    111:    .note p:last-child, .warning p:last-child { margin-bottom: 0; }
                    112:    .warning:before { font-style: normal; }
                    113:    p.note:before { content: 'Note: '; }
                    114:    p.warning:before { content: '\26A0 Warning! '; }
                    115: 
                    116:    .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
                    117:    .bookkeeping { font-size: 0.8em; margin: 2em 0; }
                    118:    .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
                    119: 
                    120:    h4 { position: relative; z-index: 3; }
                    121:    h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
                    122:    .element {
                    123:      background: #EEEEFF;
                    124:      color: black;
                    125:      margin: 0 0 1em 0.15em;
                    126:      padding: 0 1em 0.25em 0.75em;
                    127:      border-left: solid #9999FF 0.25em;
                    128:      position: relative;
                    129:      z-index: 1;
                    130:    }
                    131:    .element:before {
                    132:      position: absolute;
                    133:      z-index: 2;
                    134:      top: 0;
                    135:      left: -1.15em;
                    136:      height: 2em;
                    137:      width: 0.9em;
                    138:      background: #EEEEFF;
                    139:      content: ' ';
                    140:      border-style: none none solid solid;
                    141:      border-color: #9999FF;
                    142:      border-width: 0.25em;
                    143:    }
                    144: 
1.143     mike      145:    .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
                    146:    td > .example:only-child { margin: 0 0 0 0.1em; }
1.1       mike      147: 
                    148:    .tall-and-narrow {
                    149:      font-size: 0.6em;
                    150:      column-width: 25em;
                    151:      column-gap: 1em;
                    152:      -moz-column-width: 25em;
                    153:      -moz-column-gap: 1em;
                    154:      -webkit-column-width: 25em;
                    155:      -webkit-column-gap: 1em;
                    156:    }
                    157: 
                    158:    ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
                    159:    ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
                    160:    ul.domTree li li { list-style: none; }
                    161:    ul.domTree li:first-child::before { position: absolute; top: 0; height: 0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    162:    ul.domTree li:not(:last-child)::after { position: absolute; top: 0; bottom: -0.6em; left: -0.75em; width: 0.5em; border-style: none none solid solid; content: ''; border-width: 0.1em; }
                    163:    ul.domTree span { font-style: italic; font-family: serif; }
                    164:    ul.domTree .t1 code { color: purple; font-weight: bold; }
                    165:    ul.domTree .t2 { font-style: normal; font-family: monospace; }
                    166:    ul.domTree .t2 .name { color: black; font-weight: bold; }
                    167:    ul.domTree .t2 .value { color: blue; font-weight: normal; }
                    168:    ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
                    169:    ul.domTree .t7 code, .domTree .t8 code { color: green; }
                    170:    ul.domTree .t10 code { color: teal; }
                    171: 
1.152     mike      172:   </style><link href="data:text/css," rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D" rel="alternate stylesheet" title="Highlight implementation requirements"><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet" type="text/css"><!-- ZZZ ED vs WD -->
1.2       mike      173:   <script src="link-fixup.js"></script>
                    174:   <link href="forms.html" title="4.10 Forms" rel="prev">
                    175:   <link href="spec.html#contents" title="Table of contents" rel="index">
1.45      mike      176:   <link href="microdata.html" title="5 Microdata" rel="next">
1.10      mike      177:   </head><body onload="fixBrokenLink(); fixBrokenLink()"><div class="head">
1.1       mike      178:    <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.177     mike      179:    <h1>HTML5</h1>
1.1       mike      180:    <h2 class="no-num no-toc" id="a-vocabulary-and-associated-apis-for-html-and-xhtml">A vocabulary and associated APIs for HTML and XHTML</h2>
1.117     mike      181:    </div><nav>
1.1       mike      182:    <a href="forms.html">&#8592; 4.10 Forms</a> &#8211;
1.2       mike      183:    <a href="spec.html#contents">Table of contents</a> &#8211;
1.45      mike      184:    <a href="microdata.html">5 Microdata &#8594;</a>
1.181   ! mike      185:   </nav><p>This is revision 1.2886.</p>
1.5       mike      186: 
1.1       mike      187: 
1.153     mike      188:   <h3 id="interactive-elements"><span class="secno">4.11 </span>Interactive elements</h3><h4 id="the-details-element"><span class="secno">4.11.1 </span>The <dfn><code>details</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
                    189:    <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
                    190:    <dd><a href="embedded-content-0.html#interactive-content">Interactive content</a>.</dd>
1.1       mike      191:    <dt>Contexts in which this element may be used:</dt>
1.153     mike      192:    <dd>Where <a href="dom.html#flow-content">flow content</a> is expected.</dd>
1.1       mike      193:    <dt>Content model:</dt>
1.153     mike      194:    <dd>One <code><a href="#the-legend-element">legend</a></code> element followed by <a href="dom.html#flow-content">flow content</a>.</dd>
1.1       mike      195:    <dt>Content attributes:</dt>
                    196:    <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
                    197:    <dd><code title="attr-details-open"><a href="#attr-details-open">open</a></code></dd>
                    198:    <dt>DOM interface:</dt>
                    199:    <dd>
                    200: <pre class="idl">interface <dfn id="htmldetailselement">HTMLDetailsElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
                    201:            attribute boolean <a href="#dom-details-open" title="dom-details-open">open</a>;
                    202: };</pre>
                    203:    </dd>
                    204:   </dl><p>The <code><a href="#the-details-element">details</a></code> element <a href="the-xhtml-syntax.html#represents">represents</a> additional
1.117     mike      205:   information or controls which the user can obtain on demand.</p><p class="note">The <code><a href="#the-details-element">details</a></code> element is not appropriate
1.1       mike      206:   for footnotes. Please see <a href="text-level-semantics.html#footnotes">the section on
1.117     mike      207:   footnotes</a> for details on how to mark up footnotes.</p><p>The first element child of a <code><a href="#the-details-element">details</a></code> element, <span class="impl">if it is</span> a <code><a href="#the-legend-element">legend</a></code> element,
                    208:   <a href="the-xhtml-syntax.html#represents">represents</a> the summary of the details.</p><div class="impl">
1.1       mike      209: 
                    210:   <p>If the first element is not a <code><a href="#the-legend-element">legend</a></code> element, the
                    211:   UA should provide its own legend (e.g. "Details").</p>
                    212: 
1.117     mike      213:   </div><p>The <dfn id="attr-details-open" title="attr-details-open"><code>open</code></dfn>
1.1       mike      214:   content attribute is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a>. If present,
                    215:   it indicates that the details are to be shown to the user. If the
1.117     mike      216:   attribute is absent, the details are not to be shown.</p><div class="impl">
1.1       mike      217: 
                    218:   <p>If the attribute is removed, then the details should be
                    219:   hidden. If the attribute is added, the details should be shown.</p>
                    220: 
                    221:   <p>The user agent should allow the user to request that the details
                    222:   be shown or hidden. To honor a request for the details to be shown,
                    223:   the user agent must set the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute on the element to
                    224:   the value <code title="">open</code>. To honor a request for the
                    225:   details to be hidden, the user agent must remove the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute from the
                    226:   element.</p>
                    227: 
                    228:   <p>The <dfn id="dom-details-open" title="dom-details-open"><code>open</code></dfn>
                    229:   attribute must <a href="infrastructure.html#reflect">reflect</a> the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> content attribute.</p>
                    230: 
1.117     mike      231:   </div><!-- v2DATAGRID
1.80      mike      232:   <h4 id="datagrid">The <dfn><code>datagrid</code></dfn> element</h4>
                    233: 
                    234:   <dl class="element">
                    235:    <dt>Categories</dt>
                    236:    <dd><span>Flow content</span>.</dd>
                    237:    <dd><span>Interactive content</span>.</dd>
                    238:    <dd><span>Sectioning root</span>.</dd>
1.1       mike      239:    <dt>Contexts in which this element may be used:</dt>
1.80      mike      240:    <dd>Where <span>flow content</span> is expected.</dd>
1.1       mike      241:    <dt>Content model:</dt>
1.80      mike      242:    <dd><span>Flow content</span>.</dd>
1.1       mike      243:    <dt>Content attributes:</dt>
1.80      mike      244:    <dd><span>Global attributes</span></dd>
                    245: <!- -v2DGS:
1.1       mike      246:    <dd><code title="attr-datagrid-multiple">multiple</code></dd>
1.80      mike      247: - ->
                    248:    <dd><code title="attr-datagrid-disabled">disabled</code></dd>
1.1       mike      249:    <dt>DOM interface:</dt>
                    250:    <dd>
1.80      mike      251: <pre class="idl">interface <dfn>HTMLDataGridElement</dfn> : <span>HTMLElement</span> {
                    252: <!- -v2DGS:
1.1       mike      253:            attribute boolean <span title="dom-datagrid-multiple">multiple</span>;
1.80      mike      254: - ->           attribute boolean <span title="dom-datagrid-disabled">disabled</span>;
                    255:            attribute <span>DataGridListener</span> <span title="dom-datagrid-listener">listener</span>;
                    256: <!- - v2DGS:
1.1       mike      257:   readonly attribute <span>DataGridSelection</span> <span title="dom-datagrid-selection">selection</span>;
1.80      mike      258: - ->
1.1       mike      259:   // columns
1.81      mike      260:   void <span title="dom-datagrid-addColumn">addColumn</span>(in <span>Column</span> id, in DOMString label, in DOMString type, optional in HTMLImageElement icon, optional in boolean sortable, optional in boolean hidden);
1.80      mike      261:            attribute DOMString <span title="dom-datagrid-sortColumn">sortColumn</span>;
                    262:            attribute boolean <span title="dom-datagrid-sortAscending">sortAscending</span>;
                    263:   void <span title="dom-datagrid-clearColumns">clearColumns</span>();
1.1       mike      264: 
                    265:   // rows
1.80      mike      266:   void <span title="dom-datagrid-renotify">renotify</span>();
                    267:   void <span title="dom-datagrid-setRowCount">setRowCount</span>(in long childCount, in long rowCount);
                    268:   void <span title="dom-datagrid-setRows">setRows</span>(in <span>RowList</span> rows);
                    269:   void <span title="dom-datagrid-insertRows">insertRows</span>(in <span>RowList</span> rows);
                    270:   void <span title="dom-datagrid-deleteRows">deleteRows</span>(in <span>RowIDList</span> rows);
                    271:   void <span title="dom-datagrid-repaint">repaint</span>(in <span>RowID</span> row, in DOMString column);
                    272:   void <span title="dom-datagrid-clearRows">clearRows</span>();
                    273: <!- -
1.1       mike      274:  v2: opening and closing a row
                    275:      moving a row's actual ID
                    276:       - imagine new mail moving a thread up; you just want to add the new mail to the thread and move the thread's first mail to the top
                    277:       - though actually that should probably just be done using display sorting
1.80      mike      278: - ->
1.1       mike      279: };
                    280: 
1.80      mike      281: typedef DOMString <dfn>Column</dfn>;
                    282: typedef sequence&lt;<span>Column</span>> <dfn>ColumnList</dfn>;
1.81      mike      283: typedef sequence&lt;any> <dfn>Cell</dfn>; // <span>Column</span>, any... (exact types expected depend on the column type)
1.80      mike      284: typedef sequence&lt;<span>Cell</span>> <dfn>CellList</dfn>;
1.81      mike      285: typedef sequence&lt;any> <dfn>Row</dfn>; // <span>RowID</span>, long, long, <span>CellList</span>, optional boolean, optional long
1.80      mike      286: typedef sequence&lt;<span>Row</span>> <dfn>RowList</dfn>;
                    287: typedef sequence&lt;unsigned long> <dfn>RowID</dfn>;
                    288: typedef sequence&lt;<span>RowID</span>> <dfn>RowIDList</dfn>;
1.1       mike      289: 
                    290: [Callback=FunctionOnly, NoInterfaceObject]
1.80      mike      291: interface <dfn>RenderingContext2DCallback</dfn> {
                    292:   DOMString <span title="dom-Rendering2DContextCallback-handleEvent">handleEvent</span>(in <span>CanvasRenderingContext2D</span> context, in unsigned long width, in unsigned long height);
1.1       mike      293: };</pre>
                    294:    </dd>
1.80      mike      295:   </dl>
                    296: 
                    297:  <!- - v2:
                    298:    * datagrid: cells that are links (<a href=""></a>)
                    299:   - ->
                    300: 
                    301:   <p>The <code>datagrid</code> element <span>represents</span> an
                    302:   interactive representation of tree, list, or tabular data.</p>
                    303: 
                    304:   <p>The data being presented is provided by script using the methods
                    305:   described in the following sections.</p>
                    306: 
                    307: <!- -v2DGS:
1.1       mike      308:   <p>The <dfn
                    309:   title="attr-datagrid-multiple"><code>multiple</code></dfn> attribute
                    310:   is a <span>boolean attribute</span>. When set, it indicates that the
                    311:   user can select more than one row at a time.</p>
1.80      mike      312: - ->
                    313: 
                    314:   <p>The <dfn
                    315:   title="attr-datagrid-disabled"><code>disabled</code></dfn> attribute
                    316:   is a <span>boolean attribute</span> used to disable the
1.1       mike      317:   control. <span class="impl">When the attribute is set, the user
1.80      mike      318:   agent must disable the <code>datagrid</code>, preventing the user
                    319:   from interacting with it. The <code>datagrid</code> element should
1.1       mike      320:   still continue to update itself when the underlying data changes,
                    321:   though, as described in the next few sections. However, conformance
1.80      mike      322:   requirements stating that <code>datagrid</code> elements must react
1.1       mike      323:   to users in particular ways do not apply when the
1.80      mike      324:   <code>datagrid</code> is disabled.</span></p>
                    325: 
                    326:   <div class="impl">
1.1       mike      327: 
1.80      mike      328:   <!- -vsDGS: multiple - ->
1.1       mike      329: 
1.80      mike      330:   <p>The <dfn
                    331:   title="dom-datagrid-disabled"><code>disabled</code></dfn> DOM
                    332:   attribute must <span>reflect</span> the content attribute of the
1.1       mike      333:   same name.</p>
                    334: 
1.80      mike      335:   </div>
                    336: 
                    337:   <!- - v2DGPA: One possible thing to be added is a way to detect when a
1.1       mike      338:   row/selection has been deleted, activated, etc, by the user (delete
1.80      mike      339:   key, enter key, etc). (v2DGPA = <datagrid> Perform Action) - ->
                    340: 
                    341: 
                    342:   <h5>Introduction</h5>
                    343: 
                    344:   <p><i>This section is non-normative.</i></p>
                    345: 
                    346:   <p>In the <code>datagrid</code> data model, data is structured as a
1.1       mike      347:   set of rows representing a tree, each row being split into a number
                    348:   of columns. The columns are always present in the data model,
1.80      mike      349:   although individual columns might be hidden in the presentation.</p>
                    350: 
                    351:   <hr>
                    352: 
                    353:   <p>Each row can have child rows. Child rows may be hidden or
                    354:   shown, by closing or opening (respectively) the parent row.</p>
                    355: 
                    356:   <p>Rows are referred to by the path along the tree that one would
1.1       mike      357:   take to reach the row, using zero-based indices. Thus, the first row
                    358:   of a list is row "0", the second row is row "1"; the first child row
                    359:   of the first row is row "0,0", the second child row of the first row
                    360:   is row "0,1"; the fourth child of the seventh child of the third
1.80      mike      361:   child of the tenth row is "9,2,6,3", etc.</p>
                    362: 
                    363:   <p>The chains of numbers that give a row's path, or identifier, are
1.1       mike      364:   represented by arrays of positions, represented in IDL by the
1.80      mike      365:   <span>RowID</span> interface.</p>
                    366: 
                    367:   <p>The root of the tree is represented by an empty array.</p>
                    368: 
                    369:   <hr>
                    370: 
                    371:   <p>Each column has a string that is used to identify it in the API,
1.1       mike      372:   a label that is shown to users interacting with the column, a type,
1.80      mike      373:   and optionally an icon.</p>
                    374: 
                    375:   <p>The possible types are as follows:</p>
                    376: 
                    377:   <table>
                    378:    <thead>
                    379:     <tr>
                    380:      <td>Keyword
                    381:      <td>Description
                    382:    <tbody>
                    383:     <tr>
                    384:      <td><code title="datagrid-type-text">text</code>
                    385:      <td>Simple text.
                    386:     <tr>
                    387:      <td><code title="datagrid-type-editable">editable</code>
                    388:      <td>Editable text.
                    389:     <tr>
                    390:      <td><code title="datagrid-type-checkable">checkable</code>
                    391:      <td>Text with a check box.
                    392:     <tr>
                    393:      <td><code title="datagrid-type-list">list</code>
                    394:      <td>A list of values that the user can switch between.
                    395:     <tr>
                    396:      <td><code title="datagrid-type-progress">progress</code>
                    397:      <td>A progress bar.
                    398:     <tr>
                    399:      <td><code title="datagrid-type-meter">meter</code>
                    400:      <td>A gauge.
                    401:     <tr>
                    402:      <td><code title="datagrid-type-custom">custom</code>
                    403:      <td>A canvas onto which arbitrary content can be drawn.
                    404:   </table>
                    405: 
                    406:   <p>Each column can be flagged as sortable, in which case the user
                    407:   will be able to sort the view using that column.</p>
                    408: 
                    409:   <p>Columns are not necessarily visible. A column can be created
1.1       mike      410:   invisible by default. The user can select which columns are to be
1.80      mike      411:   shown.</p>
                    412: 
                    413:   <p>When no columns have been added to the <code>datagrid</code>, a
1.1       mike      414:   column with no name, whose identifier is the empty string, whose
1.80      mike      415:   type is <code title="datagrid-type-text">text</code>, and which is
1.1       mike      416:   not sortable, is implied. This column is removed if any explicit
1.80      mike      417:   columns are declared.</p>
                    418: 
                    419:   <p>Each cell uses the type given for its column, so all cells in a
                    420:   column present the same type of information.</p>
                    421: 
                    422: <!- -v2DGS:
1.1       mike      423:   <p>Selection of data in a <code>datagrid</code> operates at the row
                    424:   level. If the <code title="attr-datagrid-multiple">multiple</code>
                    425:   attribute is present, multiple rows can be selected at once,
                    426:   otherwise the user can only select one row at a time.</p>
1.80      mike      427: - ->
                    428: 
                    429:   <!- - v2DGDND: selection should draggable to and from datagrids - ->
                    430: 
                    431: 
                    432:   <h6>Example: a <code>datagrid</code> backed by a static <code>table</code> element</h6>
                    433: 
                    434:   ...
                    435: 
                    436: 
                    437:   <h6>Example: a <code>datagrid</code> backed by nested <code>ol</code> elements</h6>
                    438: 
                    439:   ...
                    440: 
                    441: 
                    442:   <h6>Example: a <code>datagrid</code> backed by a server</h6>
                    443: 
                    444:   ...
                    445: 
                    446: 
                    447:   <h5>Populating the <code>datagrid</code></h5>
                    448: 
                    449:   <dl class="domintro">
                    450: 
                    451:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-listener">listener</code> [ = <var title="">value</var> ]</dt>
1.1       mike      452:    <dd>
                    453: 
                    454:     <p>Return the current object that is configured as the
1.80      mike      455:     <code>datagrid</code> listener, if any. Returns null if there is
1.1       mike      456:     none.</p>
                    457: 
                    458:     <p>The listener is an object provided by the script author that
1.80      mike      459:     receives notifications when the <code>datagrid</code> needs row
1.1       mike      460:     data to render itself, when the user opens and closes rows with
                    461:     children, when the user edits a cell, and when the user invokes a
1.80      mike      462:     row's context menu. (The <code>DataGridListener</code> interface
1.1       mike      463:     used for this purpose is described in the next section.)</p>
                    464: 
                    465:     <p>Can be set, to change the current listener.</p>
                    466: 
                    467:    </dd>
                    468: 
                    469: 
1.80      mike      470:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-renotify">renotify</code>()</dt>
1.1       mike      471:    <dd>
                    472: 
1.80      mike      473:     <p>Causes the <code>datagrid</code> to resend notifications to the
1.1       mike      474:     listener (if any) for any rows or cells that the
1.80      mike      475:     <code>datagrid</code> does not yet have information for.</p>
1.1       mike      476: 
1.80      mike      477:     <!- - useful, e.g., if there is a server error and the script loses
                    478:     track of what rows it's supposed to be reporting. - ->
1.1       mike      479: 
                    480:    </dd>
                    481: 
                    482: 
1.80      mike      483:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-addColumn">addColumn</code>(<var title="">id</var>, <var title="">label</var>, <var title="">type</var> [, <var title="">icon</var> [, <var title="">sortable</var> [, <var title="">hidden</var> ] ] ] )</dt>
1.1       mike      484:    <dd>
                    485: 
1.80      mike      486:     <p>Adds a column to the <code>datagrid</code>.</p>
1.1       mike      487: 
                    488:     <p>If a column with the given identifier has already been added,
                    489:     it just replaces the information for that column.</p>
                    490: 
                    491:     <p>The possible types are enumerated in the previous section.</p>
                    492: 
                    493:    </dd>
                    494: 
                    495: 
1.80      mike      496:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortColumn">sortColumn</code> [ = <var title="">value</var> ]</dt>
1.1       mike      497:    <dd>
                    498: 
                    499:     <p>Returns the identifier of the column by which the data is to be
                    500:     sorted.</p>
                    501: 
                    502:     <p>Can be set, to indicate that the sort order has changed. This
1.80      mike      503:     will cause the <code>datagrid</code> to clear its position
                    504:     information for rows, so <code
                    505:     title="dom-datagrid-setRows">setRows()</code> will have to be
1.1       mike      506:     called again with the new sort order.</p>
                    507: 
                    508:     <p>The columns are not actually sorted by the
1.80      mike      509:     <code>datagrid</code>; the data has to be sorted by the script
                    510:     that adds the rows to the <code>datagrid</code>.</p>
1.1       mike      511: 
                    512:    </dd>
                    513: 
                    514: 
1.80      mike      515:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortAscending">sortAscending</code> [ = <var title="">value</var> ]</dt>
1.1       mike      516:    <dd>
                    517: 
                    518:     <p>Returns true if the data is to be sorted with smaller values
                    519:     first; otherwise, returns false, indicating that bigger values are
                    520:     to be put first.</p>
                    521: 
                    522:     <p>Can be set, to indicate that the order is about to change.</p>
                    523: 
                    524:    </dd>
                    525: 
                    526: 
1.80      mike      527:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearColumns">clearColumns</code>()</dt>
1.1       mike      528:    <dd>
                    529: 
1.80      mike      530:     <p>Removes all the columns in the <code>datagrid</code>,
1.1       mike      531:     reinstating the implied column.</p>
                    532: 
                    533:    </dd>
                    534: 
                    535: 
1.80      mike      536:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRowCount">setRowCount</code>(<var title="">childCount</var>, <var title="">rowCount</var>)</dt>
1.1       mike      537:    <dd>
                    538: 
1.80      mike      539:     <p>Sets the numbers of rows in the <code>datagrid</code>,
1.1       mike      540:     excluding rows that are descendants of rows that are closed.</p>
                    541: 
1.80      mike      542:     <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1       mike      543:     arguments contradict each other or previously declared information
1.80      mike      544:     (e.g. declaring that the <code>datagrid</code> has three rows when
1.1       mike      545:     the 12th row has been declared).</p>
                    546: 
                    547:    </dd>
                    548: 
                    549: 
1.80      mike      550:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRows">setRows</code>(<var title="">rows</var>)</dt>
1.1       mike      551:    <dd>
                    552: 
1.80      mike      553:     <p>Updates data for rows in the <code>datagrid</code>, or fills in
                    554:     data for rows previously implied by a call to <code
                    555:     title="dom-datagrid-setRowCount">setRowCount()</code> but not
1.1       mike      556:     previously declared.</p>
                    557: 
                    558:     <p>The <var title="">rows</var> argument is an array of rows, each
                    559:     represented by a further array consisting of:</p>
                    560: 
1.80      mike      561:     <ol class="brief">
                    562: 
                    563:      <li>A <code>RowID</code> object identifying the row.</li>
1.1       mike      564: 
                    565:      <li>An integer giving the position of the row in its parent,
1.80      mike      566:      given the current sort order, or &#x2212;1 to set other row data
1.1       mike      567:      without setting a position or changing a previously declared
                    568:      position.</li>
                    569: 
                    570:      <li>An integer giving the number of children of the row, or 0 if
1.80      mike      571:      the row has no children, or &#x2212;1 if the row has children but
1.1       mike      572:      the count is currently unknown. If the number of children has
                    573:      already been set to 0 or a positive integer, then passing
1.80      mike      574:      &#x2212;1 leaves the previous count unchanged.</li>
1.1       mike      575: 
                    576:      <li>An array giving the data for zero or more cells in the row,
                    577:      as described below.</li>
                    578: 
                    579:      <li>A boolean declaring whether the row is open or not. This
                    580:      entry, if omitted, is assumed to be false (closed), unless the
                    581:      row has already been declared as open.</li>
                    582: 
                    583:      <li>An integer giving the number of rows that are descendants of
                    584:      this row, excluding those that are descendants of descendants of
                    585:      this row that are closed. This entry can be omitted if the row is
                    586:      closed or if it has already been declared.</li>
                    587: 
1.80      mike      588:     </ol>
                    589: 
                    590:     <p>The array giving the data for the cells in the row consists of
1.1       mike      591:     a further set of arrays, one per cell. The first item of each of
                    592:     these arrays is the column's identifier; the subsequent values
                    593:     vary based on the type of the column, as follows:</p>
                    594: 
1.80      mike      595:     <dl>
                    596: 
                    597:      <dt><code title="datagrid-type-text">text</code></dt>
1.1       mike      598:      <dd>
1.80      mike      599:       <ol class="brief">
                    600:        <li>A string giving the cell's value.
                    601:        <li>Optionally, an <code>img</code> element giving an icon for the cell.
                    602:       </ol>
                    603:      </dd>
1.1       mike      604: 
1.80      mike      605:      <dt><code title="datagrid-type-editable">editable</code></dt>
1.1       mike      606:      <dd>
1.80      mike      607:       <ol class="brief">
                    608:        <li>A string giving the cell's value.
                    609:        <li>Optionally, a <code>datalist</code> element giving a set of predefined options.
                    610:        <li>Optionally, an <code>img</code> element giving an icon for the cell.
                    611:       </ol>
                    612:      </dd>
1.1       mike      613: 
1.80      mike      614:      <dt><code title="datagrid-type-checkable">checkable</code></dt>
1.1       mike      615:      <dd>
1.80      mike      616:       <ol class="brief">
                    617:        <li>A string giving the cell's value.
                    618:        <li>A boolean, indicating whether the cell is checked (true) or not (false).
                    619:        <li>Optionally, a boolean indicating whether the value of the cell is obscured as indeterminate (true), or not (false).
                    620:        <li>Optionally, an <code>img</code> element giving an icon for the cell.
                    621:       </ol>
                    622:      </dd>
1.1       mike      623: 
1.80      mike      624:      <dt><code title="datagrid-type-list">list</code></dt>
1.1       mike      625:      <dd>
1.80      mike      626:       <ol class="brief">
                    627:        <li>A string giving the cell's current value.
                    628:        <li>A <code>select</code> element giving the <span title="concept-select-option-list">list of options</span>.
                    629:        <li>Optionally, an <code>img</code> element giving an icon for the cell.
                    630:       </ol>
                    631:      </dd>
1.1       mike      632: 
1.80      mike      633:      <dt><code title="datagrid-type-progress">progress</code></dt>
1.1       mike      634:      <dd>
1.80      mike      635:       <ol class="brief">
                    636:        <li>A value in the range 0.0 (no progress) to 1.0 (task complete).
                    637:       </ol>
                    638:      </dd>
1.1       mike      639: 
1.80      mike      640:      <dt><code title="datagrid-type-meter">meter</code></dt>
1.1       mike      641:      <dd>
1.80      mike      642:       <ol class="brief">
                    643:        <li>A number giving the cell's value.
                    644:        <li>Optionally, a number giving the maximum value, if it's not 1.
                    645:        <li>Optionally, a number giving the minimum value, if it's not 0.
                    646:        <li>Optionally, a number giving the highest value that is considered "low".
                    647:        <li>Optionally, a number giving the lowest value that is considered "high".
                    648:        <li>Optionally, a number giving the value that is considered optimal.
                    649:       </ol>
                    650:      </dd>
1.1       mike      651: 
1.80      mike      652:      <dt><code title="datagrid-type-custom">custom</code></dt>
1.1       mike      653:      <dd>
1.80      mike      654:       <ol class="brief">
                    655:        <li>A number giving the minimum width of the cell, in CSS pixels, that is desired.
                    656:        <li>A number giving the minimum height of the cell, in CSS pixels, that is desired.
                    657:        <li>A function that is passed a <code>CanvasRenderingContext2D</code> object, along with the width and height (in CSS pixels) of the cell that the context will draw on.
                    658:       </ol>
                    659:      </dd>
                    660: 
                    661:     </dl>
1.1       mike      662: 
1.80      mike      663:     <p>While the rows in a single call to the <code
                    664:     title="dom-datagrid-setRows">setRows()</code> method can be in any
1.1       mike      665:     order, for each row, it is important that all its ancestor rows
                    666:     and all its open previous siblings are also declared, either in
                    667:     the same call or in an earlier one.</p>
                    668: 
1.80      mike      669:     <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1       mike      670:     arguments contradict each other or previously declared information
                    671:     (e.g. saying that a row's position is 5 when the parent row only
                    672:     has 3 children, or naming a column that doesn't exist, or
                    673:     declaring a row without declaring its parent, or changing the
                    674:     number of children that a row has while that row and its ancestors
                    675:     are all open).</p>
                    676: 
                    677:    </dd>
                    678: 
                    679: 
1.80      mike      680:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-insertRows">insertRows</code>(<var title="">rows</var>)</dt>
1.1       mike      681:    <dd>
                    682: 
1.80      mike      683:     <p>Inserts the given rows into the <code>datagrid</code>,
                    684:     increasing the numbers of rows that the <code>datagrid</code>
1.1       mike      685:     assumes are present.</p>
                    686: 
                    687:     <p>The <var title="">rows</var> argument is an array of rows in
1.80      mike      688:     the same structure as the argument to the <code
                    689:     title="dom-datagrid-setRows">setRows()</code> method described
1.1       mike      690:     above, with the same expectations of consistency (a given row's
                    691:     ancestors and earlier open siblings being listed either earlier or
1.80      mike      692:     in the same call as a given row). However, unlike with the <code
                    693:     title="dom-datagrid-setRows">setRows()</code> method, if a row is
1.1       mike      694:     inserted along with its child, the child is not included in the
1.80      mike      695:     child and row counts of the parent row; every row in the <var
                    696:     title="">rows</var> argument will increase its parent's counts
1.1       mike      697:     automatically.</p>
                    698: 
1.80      mike      699:     <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1       mike      700:     arguments contradict each other or previously declared
                    701:     information.</p>
                    702: 
                    703:    </dd>
                    704: 
                    705: 
1.80      mike      706:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-deleteRows">deleteRows</code>(<var title="">rows</var>)</dt>
1.1       mike      707:    <dd>
                    708: 
1.80      mike      709:     <p>Removes the given rows from the <code>datagrid</code>, and
1.1       mike      710:     updates the number of rows known to be in the
1.80      mike      711:     <code>datagrid</code> accordingly. The argument is an array of
                    712:     <code>RowID</code> objects identifying the rows to remove.</p>
1.1       mike      713: 
1.80      mike      714:     <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the argument
                    715:     includes a row the <code>datagrid</code> doesn't know about.</p>
                    716:     <!- - since otherwise behaviour might depend on where the user
                    717:     scrolled! - ->
1.1       mike      718: 
                    719:    </dd>
                    720: 
                    721: 
1.80      mike      722:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-repaint">repaint</code>(<var title="">row</var>, <var title="">column</var>)</dt>
1.1       mike      723:    <dd>
                    724: 
1.80      mike      725:     <p>If the given column's type is <code
                    726:     title="datagrid-type-custom">custom</code>, then causes the
                    727:     <code>datagrid</code> to reinvoke the function that obtains the
1.1       mike      728:     desired rendering.</p>
                    729: 
                    730:    </dd>
                    731: 
                    732: 
1.80      mike      733:    <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearRows">clearRows</code>()</dt>
1.1       mike      734:    <dd>
                    735: 
1.80      mike      736:     <p>Clears the <code>datagrid</code> of all row data, resetting it
                    737:     to empty<!- - v2DGS:, and clears the selection- ->.</p>
1.1       mike      738: 
                    739:    </dd>
                    740: 
1.80      mike      741:   </dl>
                    742: 
                    743: 
                    744:   <div class="impl">
1.1       mike      745: 
1.80      mike      746:   <h6>The listener</h6>
1.1       mike      747: 
1.80      mike      748:   <p>The <dfn
                    749:   title="dom-datagrid-listener"><code>listener</code></dfn> DOM
1.1       mike      750:   attribute allows authors to specify an object that will receive all
1.80      mike      751:   the notifications from the <code>datagrid</code>. Initially, its
1.1       mike      752:   value must be null. On getting, it must return its value. On
                    753:   setting, its value must be set to the new value, and then the user
1.80      mike      754:   agent must <span>queue a task</span> to call the <code
                    755:   title="dom-listener-initialize">initialize()</code> method with the
                    756:   <code>datagrid</code> element as its only argument.</p>
1.1       mike      757: 
                    758: 
1.80      mike      759:   <h6>The columns</h6>
1.1       mike      760: 
1.80      mike      761:   <p>The columns are represented by the <dfn>column list</dfn>, an
1.1       mike      762:   ordered list of entries for columns, each of which consists of:</p>
                    763: 
1.80      mike      764:   <dl>
                    765: 
                    766:    <dt>An identifier</dt>
1.1       mike      767: 
                    768:    <dd>A string used to identify the column in the API.</dd>
                    769: 
                    770:    <dt>A label</dt>
                    771: 
                    772:    <dd>A string used in the user interface.</dd>
                    773: 
                    774:    <dt>A type</dt>
                    775: 
                    776:    <dd>One of the types described below.</dd>
                    777: 
                    778:    <dt>An icon</dt>
                    779: 
1.80      mike      780:    <dd>An image, copied from an <code>img</code> element when the
1.1       mike      781:    column was declared.</dd>
                    782: 
                    783:    <dt>Whether the column is sortable</dt>
                    784: 
                    785:    <dd>A boolean indicating whether the user can request that the data
                    786:    be sorted by this column (true), or not (false).</dd>
                    787: 
                    788:    <dt>Whether the column is visible</dt>
                    789: 
                    790:    <dd>A boolean indicating whether the column is part of the
1.80      mike      791:    <code>datagrid</code>'s rendering.</dd>
1.1       mike      792: 
1.80      mike      793:   </dl>
                    794: 
                    795:   <p>Initially, the <span>column list</span> must have a single
                    796:   column, the <dfn>default column</dfn>, whose identifier is the empty
                    797:   string, whose label is the empty string, whose type is <code
                    798:   title="datagrid-type-text">text</code>, with no icon, which is not
1.1       mike      799:   sortable, and which <em>is</em> visible.</p>
                    800: 
1.80      mike      801:   <hr>
                    802: 
                    803:   <p>The <dfn title="dom-datagrid-addColumn"><code>addColumn(<var
                    804:   title="">id</var>, <var title="">label</var>, <var
                    805:   title="">type</var>, <var title="">icon</var>, <var
                    806:   title="">sortable</var>, <var title="">hidden</var>)</code></dfn>
1.1       mike      807:   method must run the following steps:</p>
                    808: 
1.80      mike      809:   <ol>
                    810: 
                    811:    <li><p>If there is already an entry in <span>column list</span>,
                    812:    other than the <span>default column</span>, whose identifier is
                    813:    <var title="">id</var>, throw a <code>DATAGRID_MODEL_ERR</code>
1.1       mike      814:    exception and abort these steps.</p></li>
                    815: 
                    816:    <li>
                    817: 
                    818:     <p>If <var title="">type</var> is not a string equal to one of the
1.80      mike      819:     <span>allowed <code>datagrid</code> column types</span>, then
                    820:     throw a <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1       mike      821:     steps.</p>
                    822: 
                    823:    </li>
                    824: 
                    825:    <li><p>If the <var title="">icon</var> argument is present and not
1.80      mike      826:    null, but the given <code>img</code> element's <code
                    827:    title="dom-img-complete">complete</code> attribute is false, then
1.1       mike      828:    let <var title="">icon</var> be null.</p></li>
                    829: 
                    830:    <li><p>If the <var title="">icon</var> argument is present and not
1.80      mike      831:    null, then copy the image data from that <code>img</code> element,
1.1       mike      832:    and let <var title="">image</var> be the copy of that image
                    833:    data. Otherwise, let <var title="">image</var> be nothing.</p></li>
                    834: 
1.80      mike      835:    <li><p>Append a new entry to the <span>column list</span>, with
1.1       mike      836:    <var title="">id</var> as its identifier, <var title="">label</var>
1.80      mike      837:    as its label, <var title="">type</var> as its type, and <var
                    838:    title="">image</var> as its icon. Let the column be sortable if the
1.1       mike      839:    <var title="">sortable</var> argument is present and true, and make
                    840:    it visible unless the <var title="">hidden</var> argument is
                    841:    present and true.</p></li>
                    842: 
1.80      mike      843:    <li><p>If the <span>column list</span> contains the <span>default
                    844:    column</span>, then remove the <span>default column</span> from the
                    845:    <span>column list</span>, discard any data for cells in that column
                    846:    in any rows in the <code>datagrid</code>, set <code
                    847:    title="dom-datagrid-sortColumn">sortColumn</code> to <var
                    848:    title="">id</var>, set <code
                    849:    title="dom-datagrid-sortAscending">sortAscending</code> to true,
                    850:    and run the <span><code>datagrid</code> resort
                    851:    steps</span>.</p></li>
                    852: 
                    853:   </ol>
                    854: 
                    855:   <hr>
1.1       mike      856: 
1.80      mike      857:   <p>The <dfn
                    858:   title="dom-datagrid-sortColumn"><code>sortColumn</code></dfn> DOM
1.1       mike      859:   attribute gives the current column used for sorting. Initially, its
                    860:   value must be the empty string. On getting, it must return its
                    861:   current value. On setting, if the new value doesn't match the
1.80      mike      862:   identifier of one of the columns in the <span>column list</span>,
                    863:   then the user agent must throw a <code>DATAGRID_MODEL_ERR</code>
1.1       mike      864:   exception. Otherwise, if the new value is not the same as its
                    865:   current value, then the user agent must set the attribute to the new
1.80      mike      866:   value, and then run the <span><code>datagrid</code> resort
                    867:   steps</span>.</p>
1.1       mike      868: 
1.80      mike      869:   <p>The <dfn
                    870:   title="dom-datagrid-sortAscending"><code>sortAscending</code></dfn>
1.1       mike      871:   DOM attribute specifies the direction that the tree is sorted in,
                    872:   ascending (true) or descending (false). Initially, its value must be
                    873:   true (ascending). On getting, it must return its current value. On
                    874:   setting, if the new value is not the same as its current value, then
                    875:   the user agent must set the attribute to the new value, and then run
1.80      mike      876:   the <span><code>datagrid</code> resort steps</span>.</p>
1.1       mike      877: 
                    878:   <p>When a column is marked as being sortable, the user agent should
                    879:   allow the user to select that column to be the column used for
                    880:   sorting, and should allow the user to chose whether the sort order
                    881:   is ascending or descending.</p>
                    882: 
                    883:   <p>When the user changes the sort order in this manner, the user
1.80      mike      884:   agent must update the <code
                    885:   title="dom-datagrid-sortColumn">sortColumn</code> and <code
                    886:   title="dom-datagrid-sortAscending">sortAscending</code> attributes
                    887:   appropriately, and then run the <span><code>datagrid</code> resort
                    888:   steps</span>.</p>
1.1       mike      889: 
1.80      mike      890:   <p class="note">The <span><code>datagrid</code> resort steps</span>
1.1       mike      891:   are described in the next section.</p>
                    892: 
1.80      mike      893:   <hr>
1.1       mike      894: 
1.80      mike      895:   <p>The <dfn
                    896:   title="dom-datagrid-clearColumns"><code>clearColumns()</code></dfn>
                    897:   method, if the <span>column list</span> doesn't contain the
                    898:   <span>default column</span>, must empty the <span>column
                    899:   list</span>, append the <span>default column</span> to the now empty
                    900:   <span>column list</span>, discard any data for cells in all rows in
                    901:   the <code>datagrid</code>, set <code
                    902:   title="dom-datagrid-sortColumn">sortColumn</code> to the empty
                    903:   string, set <code
                    904:   title="dom-datagrid-sortAscending">sortAscending</code> to true, and
                    905:   run the <span><code>datagrid</code> resort steps</span>. (If the
                    906:   <span>column list</span> is already just the <span>default
                    907:   column</span>, then the method does nothing.)</p>
1.1       mike      908: 
                    909: 
1.80      mike      910:   <h6>The rows</h6>
                    911: 
                    912:   <p>A <code>datagrid</code> element is intended to show a
1.1       mike      913:   representation of a tree, where typically the user only sees a
                    914:   small part of the tree at a time.</p>
                    915: 
1.80      mike      916:   <p>To make this efficient, the <code>datagrid</code> element
1.1       mike      917:   <em>actually</em> shows a small part of a <em>sparse</em> tree, so
                    918:   that only relevant parts of the data structure need be loaded at any
                    919:   time. Specifically, the model requires only that all the ancestor
                    920:   rows of the displayed rows be loaded, as well as any open earlier
                    921:   siblings (in the displayed sort order) of the displayed rows.</p>
                    922: 
1.80      mike      923:   <p>Conceptually, therefore, a <code>datagrid</code> has a number of
1.1       mike      924:   related sparse data structures backing it.</p>
                    925: 
1.80      mike      926:   <p>The first is the <dfn>natural order sparse data tree</dfn>. This
1.1       mike      927:   is the structure in which rows are entered as they are declared, in
                    928:   their natural order. This can differ from the order actually
                    929:   displayed to the user. It consists of nested sparse lists of
1.80      mike      930:   rows. In the <span>natural order sparse data tree</span>, a row will
1.1       mike      931:   always have all its parents already declared. Once a row is added to
1.80      mike      932:   this structure, it can only be removed by the <code
                    933:   title="dom-datagrid-deleteRows">deleteRows()</code> and <code
                    934:   title="dom-datagrid-clearRows">clearRows()</code> methods. The order of
1.1       mike      935:   nodes in this tree never changes; to move a node in this tree, it
                    936:   has to be removed and then another row (with the same data)
                    937:   reinserted elsewhere.</p>
                    938: 
1.80      mike      939:   <p>The second structure is the <dfn>display order sparse data
1.1       mike      940:   tree</dfn>. This is a similar structure that contains a subset of
1.80      mike      941:   the rows in the <span>natural order sparse data tree</span>, ordered
                    942:   in the order given by the <code
                    943:   title="dom-datagrid-sortAscending">sortAscending</code> and <code
                    944:   title="dom-datagrid-sortColumn">sortColumn</code> attributes, and
1.1       mike      945:   excluding rows with one or more ancestors that are closed. This tree
1.80      mike      946:   is cleared whenever the <code
                    947:   title="dom-datagrid-sortAscending">sortAscending</code> and <code
                    948:   title="dom-datagrid-sortColumn">sortColumn</code> attributes
1.1       mike      949:   change.</p>
                    950: 
1.80      mike      951:   <p>The third structure is the <dfn>display order sparse data
1.1       mike      952:   list</dfn>. This structure is a flattened representation of the
1.80      mike      953:   <span>display order sparse data tree</span>.</p>
1.1       mike      954: 
1.80      mike      955:   <p>At any time, a number of consecutive rows in the <span>display
                    956:   order sparse data list</span> are physically visible to the
                    957:   user. The <code>datagrid</code> fires notifications to a <span
                    958:   title="dom-datagrid-listener">listener</span> (provided by script),
1.1       mike      959:   and the listener, or other some script, is expected to feed the
1.80      mike      960:   <code>datagrid</code> with the information needed to render the
1.1       mike      961:   control.</p>
                    962: 
1.80      mike      963:   <p>A <code>datagrid</code> has a <dfn>pending <code>datagrid</code>
                    964:   rows list</dfn>, which is a list of rows in the <span>display order
                    965:   sparse data list</span> for which the <code>datagrid</code> has sent
1.1       mike      966:   notifications requesting information but not yet received
                    967:   information about.</p>
                    968: 
1.80      mike      969:   <p>A <code>datagrid</code> also has a <dfn>pending
1.1       mike      970:   <code>datagrid</code> <em>cells</em> list</dfn>, which is a list of
1.80      mike      971:   row/column pairs (cells) for which the <code>datagrid</code> has
1.1       mike      972:   sent notifications requesting information but not yet received
                    973:   information about.</p>
                    974: 
                    975:   <p>User agents may discard information about rows that are not
                    976:   displayed and that are not ancestors or open earlier siblings of
                    977:   rows or ancestors of rows that are displayed.</p>
                    978: 
1.80      mike      979:   <hr>
                    980: 
                    981:   <p>These structures are different views of the collection of rows
                    982:   that form the <code>datagrid</code>. Each row has the following
1.1       mike      983:   information associated with it:</p>
                    984: 
1.80      mike      985:   <dl>
                    986: 
                    987:    <dt>A parent</dt>
1.1       mike      988: 
1.80      mike      989:    <dd><p>Either another row, or the <code>datagrid</code> itself. This
                    990:    is the parent of the row in the <span>natural order sparse data
                    991:    tree</span> and the <span>display order sparse data tree</span>
                    992:    for the <code>datagrid</code>.</p></dd>
1.1       mike      993: 
                    994:    <dt>A natural order position relative to the other rows with the
                    995:    same parent</dt>
                    996: 
                    997:    <dd>
                    998: 
                    999:     <p>This is the number of rows that precede this row under the same
1.80      mike     1000:     parent in the <span>natural order sparse data tree</span>. This
1.1       mike     1001:     number can't be changed relative to other rows in the same parent;
                   1002:     to change the relative natural order of data in the
1.80      mike     1003:     <code>datagrid</code>, the original rows have to be removed and
1.1       mike     1004:     new rows (with the same data but different natural positions)
                   1005:     inserted in their place. (The exact number of a row can change, as
                   1006:     new rows can be inserted above it.)</p>
                   1007: 
1.80      mike     1008:     <p>A row can be identified by a <code>RowID</code> object. This is
1.1       mike     1009:     an array of numbers, consisting of the natural order positions of
                   1010:     each ancestor row and the row itself, starting from the furthest
                   1011:     ancestor. Thus, for instance, the fourth child row of the first
1.80      mike     1012:     child row of the second row in a <code>datagrid</code> would be
                   1013:     identified by a <code>RowID</code> object whose value is <code
                   1014:     title="">[1, 0, 3]</code>. A row's identifier changes if rows are
                   1015:     <span title="dom-datagrid-insertRows">inserted before it</span> in
                   1016:     the <code>datagrid</code>.</p>
1.1       mike     1017: 
                   1018:    </dd>
                   1019: 
                   1020:    <dt>A display order position relative to the other rows with
                   1021:    the same parent</dt>
                   1022: 
                   1023:    <dd><p>This is the number of rows that precede this row under the
1.80      mike     1024:    same parent in the <span>display order sparse data
                   1025:    tree</span>. This number can be unknown. If the sort order
                   1026:    changes, then this information is lost (as the <span>display order
                   1027:    sparse data tree</span> is cleared).</p></dd>
1.1       mike     1028: 
                   1029:    <dt>A child count</dt>
                   1030: 
                   1031:    <dd><p>The number of rows that have this row as a parent. If this is
1.80      mike     1032:    zero, the row cannot be opened. If this is &#x2212;1, then the
1.1       mike     1033:    child count is unknown but the row can be opened. This value can be
1.80      mike     1034:    changed by the <code title="dom-datagrid-setRows">setRows()</code>
                   1035:    method only if the current value is &#x2212;1 or if the row or one
1.1       mike     1036:    of its ancestors is closed. Otherwise, it can only be changed
1.80      mike     1037:    indirectly using the <code
                   1038:    title="dom-datagrid-insertRows">insertRows()</code> and <code
                   1039:    title="dom-datagrid-deleteRows">deleteRows()</code> methods.</p></dd>
1.1       mike     1040: 
                   1041:    <dt>An open flag</dt>
                   1042: 
                   1043:    <dd><p>A boolean indicating whether the row is open (true) or
                   1044:    closed (false). Once set, the flag can only be changed by the user
                   1045:    or while one of the row's ancestors is itself closed. A row can
                   1046:    also be in a third state, "opening", which is treated as closed for
                   1047:    all purposes except that the user agent may indicate that the row
                   1048:    is in this special state, and except that when the row is updated
                   1049:    to have a row count, the row will switch to being open.</p></dd>
                   1050: 
                   1051:    <dt>A row count</dt>
                   1052: 
                   1053:    <dd><p>The number of rows that have this row as a parent or
                   1054:    ancestor, and that do not have an ancestor that is a descendant of
1.80      mike     1055:    this row that is itself closed. If this is &#x2212;1, then the row
                   1056:    count is unknown. This value can be changed by the <code
                   1057:    title="dom-datagrid-setRows">setRows()</code> method only if the
1.1       mike     1058:    row or one of its ancestors is closed (or opening, but not
1.80      mike     1059:    open). Otherwise, it can only be changed indirectly using the <code
                   1060:    title="dom-datagrid-insertRows">insertRows()</code> and <code
                   1061:    title="dom-datagrid-deleteRows">deleteRows()</code>
1.1       mike     1062:    methods.</p></dd>
                   1063: 
                   1064:    <dt>Cells</dt>
                   1065: 
                   1066:    <dd><p>The data that applies to this row. Cell data is discussed in
                   1067:    more detail below.</p></dd>
                   1068: 
1.80      mike     1069:   </dl>
                   1070: 
                   1071:   <p>The <code>datagrid</code> itself also has a <dfn title="datagrid
                   1072:   child count">child count</dfn> and a <dfn title="datagrid row
1.1       mike     1073:   count">row count</dfn>, which are analogous to the child counts and
                   1074:   row counts for rows. Initially, these must be zero.</p>
                   1075: 
1.80      mike     1076:   <hr>
                   1077: 
                   1078:   <p>The <dfn><code>datagrid</code> resort steps</dfn>, which are
1.1       mike     1079:   invoked when the sort order changes as described in the previous
                   1080:   section, are as follows:</p>
                   1081: 
1.80      mike     1082:   <ol>
1.1       mike     1083: 
1.80      mike     1084:    <li>
                   1085: 
                   1086:     <p>Clear the <span>display order sparse data tree</span>
1.1       mike     1087:     (i.e. mark the display order position of all the rows in the
1.80      mike     1088:     <code>datagrid</code> as unknown).</p>
1.1       mike     1089: 
                   1090:     <p>User agents may cache the position information of rows for
1.80      mike     1091:     various values of <code
                   1092:     title="dom-datagrid-sortColumn">sortColumn</code> and <code
                   1093:     title="dom-datagrid-sortAscending">sortAscending</code>, instead
1.1       mike     1094:     of discarding the information altogether. If the user agent caches
                   1095:     this information, and has information that applies to the current
1.80      mike     1096:     values of <code title="dom-datagrid-sortColumn">sortColumn</code>
                   1097:     and <code title="dom-datagrid-sortAscending">sortAscending</code>,
                   1098:     then the user agent may repopulate the <span>display order sparse
                   1099:     data tree</span> from this information.</p>
1.1       mike     1100: 
                   1101:    </li>
                   1102: 
                   1103:    <li>
                   1104: 
1.80      mike     1105:     <p>Clear the <span>pending <code>datagrid</code> rows list</span>
                   1106:     and the <span>pending <code>datagrid</code> cells list</span>.</p>
1.1       mike     1107: 
                   1108:    </li>
                   1109: 
                   1110:    <li>
                   1111: 
1.80      mike     1112:     <p>Invoke the <span><code>datagrid</code> update display
                   1113:     algorithm</span>.</p>
1.1       mike     1114: 
                   1115:    </li>
                   1116: 
1.80      mike     1117:    <!- - v2: queue a task to fire an event, or tell the listener the
                   1118:    sort order changed, or something - ->
                   1119: 
                   1120:   </ol>
1.1       mike     1121: 
1.80      mike     1122:   <hr>
1.1       mike     1123: 
1.80      mike     1124:   <p>The <dfn
                   1125:   title="dom-datagrid-renotify"><code>renotify()</code></dfn> method
                   1126:   must empty the <span>pending <code>datagrid</code> rows list</span>
                   1127:   and the <span>pending <code>datagrid</code> cells list</span>, and
                   1128:   invoke the <span><code>datagrid</code> update display
                   1129:   algorithm</span>.</p>
                   1130: 
                   1131:   <hr>
                   1132: 
                   1133:   <p>The <dfn title="dom-datagrid-setRowCount"><code>setRowCount(<var
                   1134:   title="">childCount</var>, <var
                   1135:   title="">rowCount</var>)</code></dfn> method must run the following
1.1       mike     1136:   steps:</p>
                   1137: 
1.80      mike     1138:   <ol>
1.1       mike     1139: 
1.80      mike     1140:    <li>
                   1141: 
                   1142:     <p>Set the <span><code>datagrid</code> child count</span> to <var
                   1143:     title="">childCount</var>, the <span><code>datagrid</code> row
                   1144:     count</span> to <var title="">rowCount</var>.</p>
1.1       mike     1145: 
                   1146:    </li>
                   1147: 
                   1148:    <li>
                   1149: 
1.80      mike     1150:     <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1       mike     1151:     then revert the changes made in the previous step, throw a
1.80      mike     1152:     <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1       mike     1153:     steps.</p>
                   1154: 
                   1155:    </li>
                   1156: 
                   1157:    <li>
                   1158: 
1.80      mike     1159:     <p>Invoke the <span><code>datagrid</code> update display
                   1160:     algorithm</span>.</p>
1.1       mike     1161: 
                   1162:    </li>
                   1163: 
1.80      mike     1164:   </ol>
                   1165: 
                   1166:   <hr>
                   1167: 
                   1168:   <p>The <dfn title="dom-datagrid-setRows"><code>setRows(<var
                   1169:   title="">rows</var>)</code></dfn> method must run the following
1.1       mike     1170:   steps:</p>
                   1171: 
1.80      mike     1172:   <ol>
1.1       mike     1173: 
1.80      mike     1174:    <li>
                   1175: 
                   1176:     <p><span title="type-check a RowList object">Type-check the <var
                   1177:     title="">rows</var> argument</span>. If this fails, throw a
1.1       mike     1178:     <code>TypeError</code> exception, and abort these steps.</p>
                   1179: 
                   1180:    </li>
                   1181: 
                   1182:    <li>
                   1183: 
1.80      mike     1184:     <p><span title="partially sort a RowList object">Partially sort
                   1185:     the <var title="">rows</var> argument</span>.</p>
1.1       mike     1186: 
                   1187:    </li>
                   1188: 
                   1189:    <li>
                   1190: 
1.80      mike     1191:     <p>For each <code>Row</code> object in the <var
                   1192:     title="">rows</var> argument, in order, perform the appropriate
1.1       mike     1193:     steps from the list below.</p>
                   1194: 
1.80      mike     1195:     <p class="note">The changes made to the <code>datagrid</code>'s
1.1       mike     1196:     data structures in this step get reverted (as required below) if
                   1197:     any consistency errors are detected either in this step or the
                   1198:     next.</p>
                   1199: 
1.80      mike     1200:     <dl>
                   1201: 
                   1202:      <dt>If there already exists a row in the <code>datagrid</code>'s
                   1203:      <span>natural order sparse data tree</span> with the same
                   1204:      identifier as given by the <code>Row</code> object's
                   1205:      <code>RowID</code> object, and that row and all its ancestors are
1.1       mike     1206:      open</dt>
                   1207: 
                   1208:      <dd>
                   1209: 
                   1210:       <p>If one of the following conditions is true, then revert all
                   1211:       the changes done in this step, throw a
1.80      mike     1212:       <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1       mike     1213:       steps:</p>
                   1214: 
1.80      mike     1215:       <ul>
                   1216: 
                   1217:        <li>The value of the <code>Row</code> object's second entry is
                   1218:        neither &#x2212;1 nor equal to the child count of the
1.1       mike     1219:        preexisting row.</li>
                   1220: 
1.80      mike     1221:        <li>The <code>Row</code> object has fewer than four
1.1       mike     1222:        entries or more than six entries.</li>
                   1223: 
1.80      mike     1224:        <li>The <code>Row</code> object has five or more entries, and
1.1       mike     1225:        its fifth entry is false.</li>
                   1226: 
1.80      mike     1227:        <li>The <code>Row</code> object has six entries, and its sixth
1.1       mike     1228:        entry is not equal to the row count of the preexisting
                   1229:        row.</li>
                   1230: 
1.80      mike     1231:       </ul>
                   1232: 
                   1233:      </dd>
1.1       mike     1234: 
1.80      mike     1235:      <dt>If there already exists a row in the <code>datagrid</code>'s
                   1236:      <span>natural order sparse data tree</span> with the same
                   1237:      identifier as given by the <code>Row</code> object's
                   1238:      <code>RowID</code> object, but either that row or one of its
1.1       mike     1239:      ancestors is closed</dt>
                   1240: 
                   1241:      <dd>
                   1242: 
                   1243:       <p>Set the preexisting row's child count to the value of the
1.80      mike     1244:       <code>Row</code> object's second entry.</p>
1.1       mike     1245: 
1.80      mike     1246:       <p>If the <code>Row</code> object has five or more entries, and
1.1       mike     1247:       either its fifth entry is true and the preexisting row is closed
                   1248:       but not opening, or its fifth entry is false and the preexisting
                   1249:       row is open, then: if the preexisting row has no ancestor row
                   1250:       that is closed, then revert all the changes done in this step,
1.80      mike     1251:       throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1       mike     1252:       these steps; otherwise, if the fifth entry is false, then close
                   1253:       the row; otherwise, open the row.</p>
                   1254: 
1.80      mike     1255:       <p>If the <code>Row</code> object has six entries, set the
                   1256:       preexisting row's row count to the value of the <code>Row</code>
1.1       mike     1257:       object's sixth entry.</p>
                   1258: 
                   1259:       <p>If the preexisting row is opening, then: increase the
1.80      mike     1260:       <span><code>datagrid</code> row count</span> and the row counts
1.1       mike     1261:       of any ancestor rows by the number of rows that the preexisting
1.80      mike     1262:       row now has in its row count, then open the row.</p> <!- - we
1.1       mike     1263:       should also "update the <span>pending <code>datagrid</code> rows
                   1264:       list</span> and the <span>pending <code>datagrid</code> cells
1.80      mike     1265:       list</span> accordingly" - ->
1.1       mike     1266: 
                   1267: 
                   1268:      </dd>
                   1269: 
1.80      mike     1270:      <dt>There does not exist a row in the <code>datagrid</code>'s
                   1271:      <span>natural order sparse data tree</span> with the same
                   1272:      identifier as given by the <code>Row</code> object's
                   1273:      <code>RowID</code> object</dt>
1.1       mike     1274: 
                   1275:      <dd>
                   1276: 
1.80      mike     1277:       <p>If the <code>RowID</code> object has a length greater than 1,
1.1       mike     1278:       then verify that there is a row identified by the
1.80      mike     1279:       <code>RowID</code> consisting of all but the last number in the
                   1280:       <code>Row</code> object's <code>RowID</code>. If there is no
                   1281:       such row present in the <span>natural order sparse data
                   1282:       tree</span>, then revert all the changes done in this step,
                   1283:       throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1       mike     1284:       these steps.</p>
                   1285: 
1.80      mike     1286:       <p>Create a row and insert it into the <span>natural order
                   1287:       sparse data tree</span>, such that its parent is the row
                   1288:       identified by the <code>RowID</code> consisting of all but the
                   1289:       last number in the <code>Row</code> object's <code>RowID</code>,
                   1290:       or the <code>datagrid</code> if the length of the
                   1291:       <code>Row</code> object's <code>RowID</code> is 1; with its
1.1       mike     1292:       natural order position being the last number of the
1.80      mike     1293:       <code>Row</code> object's <code>RowID</code>; with the child
                   1294:       count being the value of the third entry of the <code>Row</code>
1.1       mike     1295:       object; with the row being marked closed unless the
1.80      mike     1296:       <code>Row</code> object has five or more entries and its fifth
1.1       mike     1297:       entry is true, in which case the row is open; and with its row
1.80      mike     1298:       count being &#x2212;1 unless the <code>Row</code> object has six
1.1       mike     1299:       entries, in which case the row count is equal to the value of
1.80      mike     1300:       the <code>Row</code> object's sixth entry.</p>
1.1       mike     1301: 
                   1302:      </dd>
                   1303: 
1.80      mike     1304:     </dl>
                   1305: 
                   1306:    </li>
1.1       mike     1307: 
                   1308:    <li>
                   1309: 
1.80      mike     1310:     <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1       mike     1311:     then revert the changes made in the previous step, throw a
1.80      mike     1312:     <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1       mike     1313:     steps.</p>
                   1314: 
                   1315:    </li>
                   1316: 
                   1317:    <li>
                   1318: 
1.80      mike     1319:     <p>For each <code>Row</code> object in the <var
                   1320:     title="">rows</var> argument, in order, <span title="apply a Row
                   1321:     object">apply the <code>Row</code> object</span>.</p>
1.1       mike     1322: 
                   1323:    </li>
                   1324: 
                   1325:    <li>
                   1326: 
1.80      mike     1327:     <p>Invoke the <span><code>datagrid</code> update display
                   1328:     algorithm</span>.</p>
1.1       mike     1329: 
                   1330:    </li>
                   1331: 
1.80      mike     1332:   </ol>
                   1333: 
                   1334:   <hr>
                   1335: 
                   1336:   <p>The <dfn title="dom-datagrid-insertRows"><code>insertRows(<var
                   1337:   title="">rows</var>)</code></dfn> method must run the following
1.1       mike     1338:   steps:</p>
                   1339: 
1.80      mike     1340:   <ol>
                   1341: 
                   1342:    <li>
1.1       mike     1343: 
1.80      mike     1344:     <p><span title="type-check a RowList object">Type-check the <var
                   1345:     title="">rows</var> argument</span>. If this fails, throw a
1.1       mike     1346:     <code>TypeError</code> exception, and abort these steps.</p>
                   1347: 
                   1348:    </li>
                   1349: 
                   1350:    <li>
                   1351: 
1.80      mike     1352:     <p><span title="partially sort a RowList object">Partially sort
                   1353:     the <var title="">rows</var> argument</span>.</p>
1.1       mike     1354: 
                   1355:    </li>
                   1356: 
                   1357:    <li>
                   1358: 
1.80      mike     1359:     <p>For each <code>Row</code> object in the <var
                   1360:     title="">rows</var> argument, in order, run the following
1.1       mike     1361:     steps:</p>
                   1362: 
1.80      mike     1363:     <p class="note">The changes made to the <code>datagrid</code>'s
1.1       mike     1364:     data structures in this step get reverted (as required below) if
                   1365:     any consistency errors are detected either in this step or the
                   1366:     next.</p>
                   1367: 
1.80      mike     1368:     <ol>
                   1369: 
                   1370:      <li>
1.1       mike     1371: 
                   1372:       <p>Let <var title="">parent</var> be the row identified by the
1.80      mike     1373:       <code>RowID</code> consisting of all but the last number in the
                   1374:       <code>Row</code> object's <code>RowID</code>, or the
                   1375:       <code>datagrid</code> itself if the <code>Row</code> object's
                   1376:       <code>RowID</code> has length 0.</p>
                   1377: 
                   1378:       <p>If there is no such row present in the <span>natural order
                   1379:       sparse data tree</span>, then revert all the changes done in
                   1380:       this algorithm, throw a <code>DATAGRID_MODEL_ERR</code>
1.1       mike     1381:       exception, and abort these steps.</p>
                   1382: 
                   1383:      </li>
                   1384: 
                   1385:      <li>
                   1386: 
                   1387:       <p>Increment by one the natural order position of all rows whose
                   1388:       parent is <var title="">parent</var> and whose natural order
                   1389:       position is equal to or greater than the last number of the
1.80      mike     1390:       <code>Row</code> object's <code>RowID</code>.</p>
1.1       mike     1391: 
                   1392:      </li>
                   1393: 
                   1394:      <li>
                   1395: 
1.80      mike     1396:       <p>If the value of the <code>Row</code> object's second entry is
                   1397:       not &#x2212;1, then increment by one the display order position
1.1       mike     1398:       of all rows whose parent is <var title="">parent</var> and whose
                   1399:       display order position is equal to or greater than the value of
1.80      mike     1400:       the <code>Row</code> object's second entry.</p>
1.1       mike     1401: 
1.80      mike     1402:      <!- -(Not sure how to really say this.)
1.1       mike     1403:       <p>Update the <span>pending <code>datagrid</code> rows
                   1404:       list</span> and the <span>pending <code>datagrid</code> cells
                   1405:       list</span> accordingly.</p>
1.80      mike     1406:      - ->
1.1       mike     1407: 
                   1408:      </li>
                   1409: 
                   1410:      <li>
                   1411: 
1.80      mike     1412:       <p>Create a row and insert it into the <span>natural order
                   1413:       sparse data tree</span>, such that its parent is <var
                   1414:       title="">parent</var>; with its natural order position being the
                   1415:       last number of the <code>Row</code> object's <code>RowID</code>;
1.1       mike     1416:       with the child count being the value of the third entry of the
1.80      mike     1417:       <code>Row</code> object; with the row being marked closed unless
                   1418:       the <code>Row</code> object has five or more entries and its
1.1       mike     1419:       fifth entry is true, in which case the row is open; and with its
1.80      mike     1420:       row count being &#x2212;1 unless the <code>Row</code> object has
1.1       mike     1421:       six entries, in which case the row count is equal to the value
1.80      mike     1422:       of the <code>Row</code> object's sixth entry.</p>
1.1       mike     1423: 
                   1424:      </li>
                   1425: 
1.80      mike     1426:     </ol>
                   1427: 
                   1428:    </li>
1.1       mike     1429: 
                   1430:    <li>
                   1431: 
1.80      mike     1432:     <p>For each <code>Row</code> object in the <var
                   1433:     title="">rows</var> argument, in order, <span title="apply a Row
                   1434:     object">apply the <code>Row</code> object</span>.</p>
1.1       mike     1435: 
                   1436:    </li>
                   1437: 
                   1438:    <li>
                   1439: 
1.80      mike     1440:     <p>Invoke the <span><code>datagrid</code> update display
                   1441:     algorithm</span>.</p>
1.1       mike     1442: 
                   1443:    </li>
                   1444: 
1.80      mike     1445:   </ol>
                   1446: 
                   1447:   <hr>
                   1448: 
                   1449:   <p>When an algorithm requires the user agent to <dfn>type-check a
1.1       mike     1450:   <code>RowList</code> object</dfn> (an array), each entry in the
                   1451:   object must be checked against the following requirements. If any
                   1452:   are false, then the type-check fails, otherwise it passes.</p>
                   1453: 
1.80      mike     1454:   <ul>
                   1455: 
                   1456:    <li><p>The entry is a <code>Row</code> object (an
1.1       mike     1457:    array).</p></li>
                   1458: 
1.80      mike     1459:    <li><p>The first value in the <code>Row</code> is a
                   1460:    <code>RowID</code> object (also an array), whose length is at least
1.1       mike     1461:    1, and whose values are all integers greater than or equal to
                   1462:    zero.</p></li>
                   1463: 
1.80      mike     1464:    <li><p>The numbers in the <code>RowID</code> object do not exactly
                   1465:    match any of the other entries in the <code>RowList</code> object
                   1466:    (i.e. no two <code>Row</code> objects have the same
1.1       mike     1467:    identifier).</p></li>
                   1468: 
1.80      mike     1469:    <li><p>The second value in the <code>Row</code> is an integer that
                   1470:    is either &#x2212;1, zero, or a positive integer.</p></li>
1.1       mike     1471: 
1.80      mike     1472:    <li><p>The third value in the <code>Row</code> is an integer that
                   1473:    is either &#x2212;1, zero, or a positive integer.</p></li>
1.1       mike     1474: 
1.80      mike     1475:    <li><p>The fourth value in the <code>Row</code> is a
                   1476:    <code>CellList</code> object (yet another array).</p></li>
1.1       mike     1477: 
1.80      mike     1478:    <li><p>Each entry in the <span>CellList</span> object is a
                   1479:    <code>Cell</code> object (again, an array).</p></li>
1.1       mike     1480: 
1.80      mike     1481:    <li><p>Each <code>Cell</code> object in the <span>CellList</span>
                   1482:    object has as its first value a <code>Column</code> object (a
1.1       mike     1483:    string), and its value is the identifier of one of the columns in
1.80      mike     1484:    the <span>column list</span>.</p></li>
1.1       mike     1485: 
                   1486:    <li>
                   1487: 
1.80      mike     1488:     <p>Each <code>Cell</code> object in the <span>CellList</span>
1.1       mike     1489:     object has as its second and subsequent entries values that match
                   1490:     the following requirements, as determined by the type of the
                   1491:     column identified by the first entry:</p>
                   1492: 
1.80      mike     1493:     <dl>
                   1494: 
                   1495:      <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1       mike     1496:      <dd>
                   1497: 
                   1498:       <p>The second entry's value is a string, and either there are
                   1499:       only two entries, or there are three, and the third entry is
1.80      mike     1500:       an <code>img</code> element.</p>
1.1       mike     1501: 
1.80      mike     1502:       <p>If there is an <code>img</code> element specified, its <code
                   1503:       title="dom-img-complete">complete</code> attribute is true.</p>
1.1       mike     1504: 
                   1505:      </dd>
                   1506: 
1.80      mike     1507:      <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1       mike     1508:      <dd>
                   1509: 
                   1510:       <p>The second entry's value is a string, and either there are
                   1511:       only two entries, or the third entry is a
1.80      mike     1512:       <code>datalist</code> element, and either there are only three
1.1       mike     1513:       entries, or there are four, and the fourth entry is an
1.80      mike     1514:       <code>img</code> element.</p>
1.1       mike     1515: 
1.80      mike     1516:       <p>If there is an <code>img</code> element specified, its <code
                   1517:       title="dom-img-complete">complete</code> attribute is true.</p>
1.1       mike     1518: 
                   1519:      </dd>
                   1520: 
1.80      mike     1521:      <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1       mike     1522:      <dd>
                   1523: 
                   1524:       <p>The second entry's value is a string, the third entry is a
                   1525:       boolean, and either there are only three entries, or the
                   1526:       fourth entry is also a boolean, and either there are only four
                   1527:       entries, or there are five, and the fifth entry is an
1.80      mike     1528:       <code>img</code> element.</p>
1.1       mike     1529: 
1.80      mike     1530:       <p>If there is an <code>img</code> element specified, its <code
                   1531:       title="dom-img-complete">complete</code> attribute is true.</p>
1.1       mike     1532: 
                   1533:      </dd>
                   1534: 
1.80      mike     1535:      <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1       mike     1536:      <dd>
                   1537: 
                   1538:       <p>The second entry's value is a string, the third entry is a
1.80      mike     1539:       <code>select</code> element, and either there are only three
1.1       mike     1540:       entries, or there are four, and the fourth entry is an
1.80      mike     1541:       <code>img</code> element.</p>
1.1       mike     1542: 
1.80      mike     1543:       <p>If there is an <code>img</code> element specified, its <code
                   1544:       title="dom-img-complete">complete</code> attribute is true.</p>
1.1       mike     1545: 
                   1546:      </dd>
                   1547: 
1.80      mike     1548:      <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1       mike     1549:      <dd>
                   1550: 
                   1551:       <p>There are only two entries, the second entry's value is a
                   1552:       number, and the number's value is between 0.0 and 1.0
                   1553:       inclusive.</p>
                   1554: 
                   1555:      </dd>
                   1556: 
1.80      mike     1557:      <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1       mike     1558:      <dd>
                   1559: 
                   1560:       <p>There are at least two, but possibly up to seven, entries,
                   1561:       all entries but the first one are numbers, and the following
                   1562:       relationships hold:</p>
                   1563: 
1.80      mike     1564:       <ul class="brief">
                   1565: 
                   1566:        <li>The second entry is less than the third, or less than 1.0
1.1       mike     1567:        if the third is absent.</li>
                   1568: 
                   1569:        <li>The second entry is greater than the fourth, or greater
                   1570:        than 0.0 if the fourth is absent.</li>
                   1571: 
                   1572:        <li>If there are at least three entries, the third entry is
                   1573:        greater than the fourth, or greater than zero if the fourth
                   1574:        is absent.</li>
                   1575: 
                   1576:        <li>If there are at least five entries, the fifth is not
                   1577:        greater than the third and not less than the fourth.</li>
                   1578: 
                   1579:        <li>If there are at least six entries, the sixth is not
                   1580:        greater than the third and not less than the fifth.</li>
                   1581: 
                   1582:        <li>If there are at least seven entries, the fifth is not
                   1583:        greater than the third and not less than the fourth.</li>
                   1584: 
1.80      mike     1585:       </ul>
1.1       mike     1586: 
1.80      mike     1587:      </dd>
                   1588: 
                   1589:      <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1       mike     1590:      <dd>
                   1591: 
                   1592:       <p>There are four entries, the second and third are numbers
                   1593:       that are integers greater than zero, and the fourth is a
                   1594:       <code>Rendering2DContextCallback</code> object (a
                   1595:       function).</p>
                   1596: 
                   1597:      </dd>
                   1598: 
1.80      mike     1599:     </dl>
                   1600: 
                   1601:    </li>
1.1       mike     1602: 
1.80      mike     1603:    <li><p>Either there are only four values in the <code>Row</code>,
                   1604:    or the fifth value in the <code>Row</code> is a boolean.</p></li>
1.1       mike     1605: 
                   1606:    <li><p>Either there are only four or five values in the
1.80      mike     1607:    <code>Row</code>, or there are six, and the sixth value in the
                   1608:    <code>Row</code> an integer that is greater than or equal to
1.1       mike     1609:    zero.</p></li>
                   1610: 
1.80      mike     1611:   </ul>
                   1612: 
                   1613:   <p>Where the above requirements say that a value is to be a string,
1.1       mike     1614:   the user agent must apply the ToString() conversion operator to the
                   1615:   value, assume that the value was indeed a string, and use the result
                   1616:   in the rest of the algorithm as if it had that had been the value
1.98      mike     1617:   passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1       mike     1618: 
                   1619:   <p>Where the above requirements say that a value is to be a number,
                   1620:   the user agent must first apply the ToNumber() conversion operator
1.60      mike     1621:   to the value, and then verify that the result is neither an Infinity
                   1622:   value nor a Not-a-Number (NaN) value. If this result is indeed
                   1623:   acceptable (i.e. finite), the user agent must use the result in the
                   1624:   rest of the algorithm as if it had that had been the value passed to
1.98      mike     1625:   the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1       mike     1626: 
                   1627:   <p>Where the above requirements say that a value is to be an
                   1628:   integer, the user agent must first apply the ToNumber() conversion
                   1629:   operator to the value, and then verify that the result is a finite
                   1630:   integer. If so, the user agent must use the result in the rest of
                   1631:   the algorithm as if it had that had been the value passed to the
1.98      mike     1632:   method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1       mike     1633: 
                   1634:   <p>Where the above requirements say that a value is to be a boolean,
                   1635:   the user agent must apply the ToBoolean() conversion operator to the
                   1636:   value, assume that the value was indeed a boolean, and use the
                   1637:   result in the rest of the algorithm as if it had that had been the
1.98      mike     1638:   value passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.80      mike     1639: 
                   1640:   <hr>
1.1       mike     1641: 
1.80      mike     1642:   <p>When an algorithm requires the user agent to <dfn>audit the
                   1643:   <code>datagrid</code></dfn>, the <code>datagrid</code> must be
1.1       mike     1644:   checked against the following requirements. If any are false, then
                   1645:   the audit fails, otherwise it passes.</p>
                   1646: 
1.80      mike     1647:   <ul>
                   1648: 
                   1649:    <li>There is no row whose natural order position is greater than or
                   1650:    equal to the child count of its parent row in the <span>natural
                   1651:    order sparse data tree</span>.</li>
1.1       mike     1652: 
                   1653:    <li>There is no row whose display order position is greater than or
1.80      mike     1654:    equal to the child count of its parent row in the <span>display
                   1655:    order sparse data tree</span>.</li>
1.1       mike     1656: 
                   1657:    <li>There is no row such that the sum of that row's child count and
                   1658:    the row counts all the open rows that are direct children of that
1.80      mike     1659:    row in the <span>natural order sparse data tree</span> is less than
1.1       mike     1660:    that row's row count.</li>
                   1661: 
                   1662:    <li>Of the rows whose child count is equal to the number of rows
1.80      mike     1663:    that are direct children of that row in the <span>natural order
                   1664:    sparse data tree</span>, there is none such that the sum of that
1.1       mike     1665:    row's child count and the row counts of all the open rows that are
1.80      mike     1666:    direct children of that row in the <span>natural order sparse data
                   1667:    tree</span> is greater than that row's row count.</li>
                   1668: 
                   1669:   </ul>
1.1       mike     1670: 
1.80      mike     1671:   <p>For the purposes of this audit, the <code>datagrid</code> must be
1.1       mike     1672:   treated as the parent row of all the rows that are direct children
1.80      mike     1673:   of the <code>datagrid</code> in the <span>natural order sparse data
                   1674:   tree</span> and the <span>display order sparse data tree</span>. The
                   1675:   child count of this implied row is the <span><code>datagrid</code>
                   1676:   child count</span>, and the row count of this implied row is the
                   1677:   <span><code>datagrid</code> row count</span>.</p>
                   1678: 
                   1679:   <hr>
1.1       mike     1680: 
1.80      mike     1681:   <p>When an algorithm requires the user agent to <dfn>partially sort
1.1       mike     1682:   a <code>RowList</code> object</dfn> (an array), the entries in the
1.80      mike     1683:   object must be resorted such that <code>Row</code> objects are
1.1       mike     1684:   listed after any of their ancestors and after any of their earlier
1.80      mike     1685:   siblings. In other words, for any two <code>Row</code> objects <var
                   1686:   title="">a</var> and <var title="">b</var> in the
                   1687:   <code>RowList</code>, where <var title="">a</var> is before <var
                   1688:   title="">b</var> after the sort, the following conditions must
1.1       mike     1689:   hold:</p>
                   1690: 
1.80      mike     1691:   <ul>
                   1692: 
                   1693:    <li><p>If their <code>RowID</code> objects are the same length and
1.1       mike     1694:    have values that are equal except for the last value, then the last
1.80      mike     1695:    value of <var title="">a</var>'s <code>RowID</code>'s last value
                   1696:    must be less than <var title="">b</var>'s <code>RowID</code>'s last
1.1       mike     1697:    value (i.e. earlier siblings must come before their later
                   1698:    siblings).</p></li>
                   1699: 
1.80      mike     1700:    <li><p>If their <code>RowID</code> objects are not the same length,
1.1       mike     1701:    but the values in the shorter of the two are the same as the first
                   1702:    few values in the longer one, then <var title="">a</var>'s
1.80      mike     1703:    <code>RowID</code> must be the shorter one (i.e. ancestors must
1.1       mike     1704:    come before their descendants).</p></li>
                   1705: 
1.80      mike     1706:   </ul>
                   1707: 
                   1708:   <hr>
                   1709: 
                   1710:   <p>The <dfn title="dom-datagrid-deleteRows"><code>deleteRows(<var
                   1711:   title="">rows</var>)</code></dfn> method must run the following
1.1       mike     1712:   steps:</p>
                   1713: 
1.80      mike     1714:   <ol>
                   1715: 
                   1716:    <li>
1.1       mike     1717: 
                   1718:     <p>If any of the entries in <var title="">rows</var> are not
1.80      mike     1719:     <code>RowID</code> objects consisting of one or more entries whose
1.1       mike     1720:     values are all integers that are greater than or equal to zero,
                   1721:     then throw a <code>TypeError</code> exception and abort these
                   1722:     steps.</p>
                   1723: 
                   1724:     <p>To check if a value is an integer, the user agent must first
                   1725:     apply the ToNumber() conversion operator to the value, and then
                   1726:     verify that the result is a finite integer. If so, the user agent
                   1727:     must use the result in the rest of the algorithm as if it had that
1.80      mike     1728:     had been the value passed to the method. <a
1.98      mike     1729:     href="#refsECMA262">[ECMA262]</a></p>
1.1       mike     1730: 
                   1731:    </li>
                   1732: 
                   1733:    <li>
                   1734: 
1.80      mike     1735:     <p>If any of the <code>RowID</code> objects in the <var
                   1736:     title="">rows</var> argument identify a row that isn't present in
                   1737:     the <span>natural order sparse data tree</span>, then throw a
                   1738:     <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1       mike     1739:     steps.</p>
                   1740: 
                   1741:    </li>
                   1742: 
                   1743:    <li>
                   1744: 
                   1745:     <p>If any row is listed twice in the <var title="">rows</var>
1.80      mike     1746:     argument, then throw a <code>DATAGRID_MODEL_ERR</code> exception
1.1       mike     1747:     and abort these steps.</p>
                   1748: 
                   1749:    </li>
                   1750: 
                   1751:    <li>
                   1752: 
                   1753:     <p>Sort the <var title="">rows</var> argument such that the
                   1754:     entries are given in the same order as the rows they identify
                   1755:     would be visited in a pre-order, depth first traversal of the
1.80      mike     1756:     <span>natural order sparse data tree</span>.</p>
1.1       mike     1757: 
                   1758:    </li>
                   1759: 
                   1760:    <li>
                   1761: 
                   1762:     <p>For each row identified by entries in <var title="">rows</var>,
                   1763:     <em>in reverse order</em>, run the following steps:</p>
                   1764: 
1.80      mike     1765:     <ol>
                   1766: 
                   1767:      <li>
1.1       mike     1768: 
                   1769:       <p>Decrement the child count of the row's parent row, if that
                   1770:       child count is greater than zero. If the row has no parent,
1.80      mike     1771:       decrement the <span><code>datagrid</code> child
                   1772:       count</span>.</p>
1.1       mike     1773: 
                   1774:       <p>If the row has a parent row, and its child count is now zero,
                   1775:       then close that row.</p>
                   1776: 
                   1777:      </li>
                   1778: 
                   1779:      <li>
                   1780: 
                   1781:       <p>Let <var title="">delta</var> be one more than the row's row
                   1782:       count if the row is open and its row count is greater than zero;
                   1783:       otherwise, let <var title="">delta</var> be one.</p>
                   1784: 
                   1785:      </li>
                   1786: 
                   1787:      <li>
                   1788: 
                   1789:       <p>Let <var title="">ancestor</var> be the row.</p>
                   1790: 
                   1791:      </li>
                   1792: 
                   1793:      <li>
                   1794: 
                   1795:       <p><i>Row count loop</i>: Let <var title="">ancestor</var> be
                   1796:       <var title="">ancestor</var>'s parent row, if any, or null if it
                   1797:       has none.</p>
                   1798: 
                   1799:      </li>
                   1800: 
                   1801:      <li>
                   1802: 
                   1803:       <p>If <var title="">ancestor</var> is null, then decrement the
1.80      mike     1804:       <span><code>datagrid</code> row count</span> by <var
                   1805:       title="">delta</var>. Otherwise, if <var title="">ancestor</var>
                   1806:       is open, then decrement its row count by <var
                   1807:       title="">delta</var>.</p>
1.1       mike     1808: 
                   1809:      </li>
                   1810: 
                   1811:      <li>
                   1812: 
                   1813:       <p>If <var title="">ancestor</var> is not null, then jump back
                   1814:       to the step labeled <i>row count loop</i> above.</p>
                   1815: 
                   1816:      </li>
                   1817: 
                   1818:      <li>
                   1819: 
                   1820:       <p>Let <var title="">parent</var> be the row's parent, or the
1.80      mike     1821:       <code>datagrid</code> if the row has no parent.</p>
1.1       mike     1822: 
                   1823:      </li>
                   1824: 
                   1825:      <li>
                   1826: 
                   1827:       <p>Decrement by one the natural order position of all rows whose
                   1828:       parent is <var title="">parent</var> and whose natural order
                   1829:       position is equal to or greater than the row's own natural order
                   1830:       position.</p>
                   1831: 
                   1832:      </li>
                   1833: 
                   1834:      <li>
                   1835: 
1.80      mike     1836:       <p>If the row is in the <span>display order sparse data
                   1837:       tree</span>, then decrement by one the display order position of
1.1       mike     1838:       all rows whose parent is <var title="">parent</var> and whose
                   1839:       display order position is equal to or greater than the row's own
                   1840:       display order position.</p>
                   1841: 
                   1842:      </li>
                   1843: 
                   1844:      <li>
                   1845: 
                   1846:       <p>Clear the row and its descendants from the
1.80      mike     1847:       <code>Datagrid</code>.</p>
1.1       mike     1848: 
                   1849:      </li>
                   1850: 
1.80      mike     1851:     </ol>
                   1852: 
                   1853:    </li>
1.1       mike     1854: 
                   1855:    <li>
                   1856: 
1.80      mike     1857:     <p>Invoke the <span><code>datagrid</code> update display
                   1858:     algorithm</span>.</p>
1.1       mike     1859: 
                   1860:    </li>
                   1861: 
1.80      mike     1862:   </ol>
1.1       mike     1863: 
1.80      mike     1864:   <hr>
                   1865: 
                   1866:   <p>The <dfn
                   1867:   title="dom-datagrid-clearRows"><code>clearRows()</code></dfn> method
                   1868:   must empty the <span>natural order sparse data tree</span>, reset
                   1869:   both the <span><code>datagrid</code> child count</span> and the
                   1870:   <span><code>datagrid</code> row count</span> to zero, and invoke the
                   1871:   <span><code>datagrid</code> update display algorithm</span>.</p>
                   1872: 
                   1873:   <hr>
                   1874: 
                   1875:   <p>The <dfn title="dom-datagrid-repaint"><code>repaint(<var
                   1876:   title="">row</var>, <var title="">column</var>)</code></dfn> method
1.1       mike     1877:   must cause the user agent to clear its cache for the cell specified
1.80      mike     1878:   by the identifier <var title="">row</var> and the column <var
                   1879:   title="">column</var>, if that column's type is <code
                   1880:   title="datagrid-type-custom">custom</code>. If the given column has
                   1881:   not been declared, or its type is not <code
                   1882:   title="datagrid-type-custom">custom</code>, then the user agent must
                   1883:   throw a <code>DATAGRID_MODEL_ERR</code> exception. If the given row
1.1       mike     1884:   is not known, then the method must do nothing. If the cell is indeed
                   1885:   cleared, the user agent must reinvoke the previously registered
1.80      mike     1886:   <code>RenderingContext2DCallback</code> callback when it needs to
1.1       mike     1887:   repaint that row.</p>
                   1888: 
1.80      mike     1889:   <hr>
                   1890: 
                   1891:   <p>If a row has a child count that isn't zero, then the user agent
1.1       mike     1892:   should offer to the user the option of opening and closing the
                   1893:   row.</p>
                   1894: 
                   1895:   <p>When a row is opened, if the row's row count is greater than
                   1896:   zero, then the user agent must increase the
1.80      mike     1897:   <span><code>datagrid</code> row count</span> and the row counts of
1.1       mike     1898:   any ancestor rows by the number of rows that the newly opened row
1.80      mike     1899:   has in its row count<!- - we should also "update the <span>pending
1.1       mike     1900:   <code>datagrid</code> rows list</span> and the <span>pending
1.80      mike     1901:   <code>datagrid</code> cells list</span> accordingly" - ->, then must
                   1902:   mark the row as open, then may fill in the <span>display order
                   1903:   sparse data tree</span> with any information that the user agent has
1.1       mike     1904:   cached about the display order positions of descendants of the newly
1.80      mike     1905:   opened row, and then must invoke the <code
                   1906:   title="dom-listener-rowOpened">rowOpened()</code> method on the
                   1907:   current <code title="dom-datagrid-listener">listener</code> with as
                   1908:   its first argument a <code>RowID</code> object identifying the row
1.1       mike     1909:   that was opened and as its second argument the boolean false, and
1.80      mike     1910:   then must invoke the <span><code>datagrid</code> update display
                   1911:   algorithm</span>.</p>
1.1       mike     1912: 
                   1913:   <p>On the other hand, when a row is opened and the row's row count
1.80      mike     1914:   is &#x2212;1, then the user agent must mark the row as opening, and
                   1915:   then must invoke the <code
                   1916:   title="dom-listener-rowOpened">rowOpened()</code> method on the
                   1917:   current <code title="dom-datagrid-listener">listener</code> with as
                   1918:   its first argument a <code>RowID</code> object identifying the row
1.1       mike     1919:   that was opened and as its second argument the boolean true.</p>
                   1920: 
                   1921:   <p>When a row is closed, the user agent must decrease the
1.80      mike     1922:   <span><code>datagrid</code> row count</span> and the row counts of
1.1       mike     1923:   any ancestor rows by the number of rows that the newly closed row
1.80      mike     1924:   has in its row count, and then must invoke the <code
                   1925:   title="dom-listener-rowOpened">rowOpened()</code> method on the
                   1926:   current <code title="dom-datagrid-listener">listener</code> with as
                   1927:   its first and only argument a <code>RowID</code> object identifying
1.1       mike     1928:   the row that was opened.</p>
                   1929: 
                   1930: 
                   1931: 
1.80      mike     1932:   <h6>The cells</h6>
1.1       mike     1933: 
                   1934:   <p>Each row has one cell per column. Each cell has the same type as
1.80      mike     1935:   its column. The <dfn>allowed <code>datagrid</code> column
1.1       mike     1936:   types</dfn>, what they represent, and the requirements for when the
                   1937:   user interacts with them, are as follows:</p>
                   1938: 
1.80      mike     1939:   <dl>
                   1940: 
                   1941:    <dt><dfn title="datagrid-type-text"><code>text</code></dfn></dt>
1.1       mike     1942:    <dd>
                   1943: 
                   1944:     <p>The cell represents some text and an optional image.</p>
                   1945: 
                   1946:    </dd>
                   1947: 
1.80      mike     1948:    <dt><dfn title="datagrid-type-editable"><code>editable</code></dfn></dt>
1.1       mike     1949:    <dd>
                   1950: 
                   1951:     <p>The cells represents some editable text, an optional
1.80      mike     1952:     <code>datalist</code> giving autocompletion hints, and an
1.1       mike     1953:     optional image.</p>
                   1954: 
1.80      mike     1955:     <p>If there is a <code>datalist</code> element, the user agent
1.1       mike     1956:     should offer the suggestions represented by that element to the
1.80      mike     1957:     user. The user agent may use the suggestion's <span
                   1958:     title="concept-option-label">label</span> to identify the
1.1       mike     1959:     suggestion. If the user selects a suggestion, then the editable
1.80      mike     1960:     text must be set to the selected suggestion's <span
                   1961:     title="concept-option-value">value</span>, as if the user had
1.1       mike     1962:     written that value himself.</p>
                   1963: 
                   1964:     <p>When the user edits the value, either directly or using the
1.80      mike     1965:     <code>datalist</code>, the user agent must invoke the <code
                   1966:     title="dom-listener-cellChanged">cellChanged()</code> method on
                   1967:     the current <code title="dom-datagrid-listener">listener</code>
                   1968:     with as its first argument a <code>RowID</code> identifying the
1.1       mike     1969:     cell's row, as its second argument the identifier of the cell's
                   1970:     column, as its third argument the new value, and as its fourth
                   1971:     argument the previous value.</p>
                   1972: 
                   1973:    </dd>
                   1974: 
1.80      mike     1975:    <dt><dfn title="datagrid-type-checkable"><code>checkable</code></dfn></dt>
1.1       mike     1976:    <dd>
                   1977: 
                   1978:     <p>The cell represents some text, a check box that optionally has
                   1979:     its value obscured as indeterminate, and an optional image.</p>
                   1980: 
                   1981:     <p>When the user checks or unchecks the check box, the user agent
                   1982:     must change the check box's state appropriately and stop obscuring
                   1983:     the check box as indeterminate (if it is obscuring it), and then
1.80      mike     1984:     must invoke the <code
                   1985:     title="dom-listener-cellChanged">cellChanged()</code> method on
                   1986:     the current <code title="dom-datagrid-listener">listener</code>
                   1987:     with as its first argument a <code>RowID</code> identifying the
1.1       mike     1988:     cell's row, as its second argument the identifier of the cell's
                   1989:     column, as its third argument true if the check box is now checked
                   1990:     and false otherwise, and as its fourth argument true if the check
                   1991:     box was previously checked and false otherwise.</p>
                   1992: 
                   1993:    </dd>
                   1994: 
1.80      mike     1995:    <dt><dfn title="datagrid-type-list"><code>list</code></dfn></dt>
1.1       mike     1996:    <dd>
                   1997: 
                   1998:     <p>The cell represents some text giving the current value selected
1.80      mike     1999:     from a dropdown list of options, a <code>select</code> element
1.1       mike     2000:     giving the list of options, and an optional image.</p>
                   2001: 
                   2002:     <p>The user agent should allow the user to change the value of the
1.80      mike     2003:     cell from its current value to one of the <span
                   2004:     title="concept-option-value">values</span> given by
                   2005:     <code>option</code> elements in the <span
                   2006:     title="concept-select-option-list">list of options</span> (if
                   2007:     any). The user agent may use the <code>option</code> elements'
                   2008:     <span title="concept-option-label">labels</span> to annotate each
1.1       mike     2009:     option.</p>
                   2010: 
1.80      mike     2011:     <p>When the user selects a new value from the <code>select</code>
                   2012:     element's <span title="concept-select-option-list">list of
                   2013:     options</span>, the user agent must invoke the <code
                   2014:     title="dom-listener-cellChanged">cellChanged()</code> method on
                   2015:     the current <code title="dom-datagrid-listener">listener</code>
                   2016:     with as its first argument a <code>RowID</code> identifying the
1.1       mike     2017:     cell's row, as its second argument the identifier of the cell's
                   2018:     column, as its third argument the new value, and as its fourth
                   2019:     argument the previous value.</p>
                   2020: 
                   2021:    </dd>
                   2022: 
1.80      mike     2023:    <dt><dfn title="datagrid-type-progress"><code>progress</code></dfn></dt>
1.1       mike     2024:    <dd>
                   2025: 
                   2026:     <p>The cell represents a (determinate) progress bar whose value is
                   2027:     between 0.0, indicating no progress, and 1.0, indicating the task
                   2028:     is complete.</p>
                   2029: 
                   2030:    </dd>
                   2031: 
1.80      mike     2032:    <dt><dfn title="datagrid-type-meter"><code>meter</code></dfn></dt>
1.1       mike     2033:    <dd>
                   2034: 
                   2035:     <p>The cell represents a gauge, described by one to six
                   2036:     numbers.</p>
                   2037: 
                   2038:     <p>The gauge's actual value is given by the first number.</p>
                   2039: 
                   2040:     <p>If there is a second number, then that number is the maximum
                   2041:     value. Otherwise, the maximum value is 1.0.</p>
                   2042: 
                   2043:     <p>If there is a third number, then that number is the minimum
                   2044:     value. Otherwise, the minimum value is 1.0.</p>
                   2045: 
                   2046:     <p>If there is a fourth number, then that number is the low
                   2047:     boundary. Otherwise, the low boundary is the minimum value.</p>
                   2048: 
                   2049:     <p>If there is a fifth number, then that number is the high
                   2050:     boundary. Otherwise, the high boundary is the maximum value.</p>
                   2051: 
                   2052:     <p>If there is a sixth number, then the optimal point is the sixth
                   2053:     number. Otherwise, the optimum point is the midpoint between the
                   2054:     minimum value and the maximum value.</p>
                   2055: 
1.80      mike     2056:     <!- - next two paragraphs copied from <meter>: - ->
1.1       mike     2057: 
                   2058:     <p>If the optimum point is equal to the low boundary or the high
                   2059:     boundary, or anywhere in between them, then the region between the
                   2060:     low and high boundaries of the gauge must be treated as the
                   2061:     optimum region, and the low and high parts, if any, must be
                   2062:     treated as suboptimal. Otherwise, if the optimum point is less
                   2063:     than the low boundary, then the region between the minimum value
                   2064:     and the low boundary must be treated as the optimum region, the
                   2065:     region between the low boundary and the high boundary must be
                   2066:     treated as a suboptimal region, and the region between the high
                   2067:     boundary and the maximum value must be treated as an even less
                   2068:     good region. Finally, if the optimum point is higher than the high
                   2069:     boundary, then the situation is reversed; the region between the
                   2070:     high boundary and the maximum value must be treated as the optimum
                   2071:     region, the region between the high boundary and the low boundary
                   2072:     must be treated as a suboptimal region, and the remaining region
                   2073:     between the low boundary and the minimum value must be treated as
                   2074:     an even less good region.</p>
                   2075: 
                   2076:     <p>User agents should indicate the relative position of the actual
                   2077:     value to the minimum and maximum values, and the relationship
                   2078:     between the actual value and the three regions of the gauge.</p>
                   2079: 
                   2080:    </dd>
                   2081: 
1.80      mike     2082:    <dt><dfn title="datagrid-type-custom"><code>custom</code></dfn></dt>
1.1       mike     2083:    <dd>
                   2084: 
                   2085:     <p>The cell represents a dynamically generated graphical image.</p>
                   2086: 
                   2087:     <p>The cell will have minimum dimensions (specified in CSS
                   2088:     pixels), and a callback (in the form of a
1.80      mike     2089:     <code>RenderingContext2DCallback</code> object) to get a rendering
1.1       mike     2090:     for the cell.</p>
                   2091: 
                   2092:     <p>The user agent should not allow the cell to be rendered with
                   2093:     dimensions less than the given minimum width and height.</p>
                   2094: 
                   2095:     <p>When the user agent needs to render the cell, the user agent
1.80      mike     2096:     must <span>queue a task</span> to invoke the
                   2097:     <span>RenderingContext2DCallback</span> callback, passing it a
                   2098:     newly created <code>CanvasRenderingContext2D</code> object whose
                   2099:     <code title="dom-context-2d-canvas">canvas</code> DOM attribute is
1.1       mike     2100:     null as the first argument, the actual cell width in CSS pixels as
                   2101:     the second argument, and the actual cell height in CSS pixels as
                   2102:     the third argument.</p>
                   2103: 
                   2104:     <p>If the user agent is able to render graphics, then it must
                   2105:     render the graphics commands that the callback executed on the
1.80      mike     2106:     provided <code>CanvasRenderingContext2D</code> object onto the
1.1       mike     2107:     cell once the callback returns. The image must be clipped to the
                   2108:     dimensions of the cell. The coordinate space of the cell must be
                   2109:     aligned with that used by the 2D context such that the top left
                   2110:     corner of the cell is the 0,0 origin, with the coordinate space
                   2111:     increasing its <var title="">x</var> dimension towards the right
                   2112:     of the cell and its <var title="">y</var> axis towards the bottom
                   2113:     of the cell, and with the image not scaled (so that one CSS pixel
                   2114:     on the final rendering matches one CSS pixel in the coordinate
                   2115:     space used by the 2D context).</p>
                   2116: 
                   2117:     <p>The user agent must then decouple the
1.80      mike     2118:     <code>CanvasRenderingContext2D</code> object and any objects that
                   2119:     it created (such as <code>CanvasPattern</code> objects or
                   2120:     <code>ImageData</code> objects) from any real drawing surface.</p>
1.1       mike     2121: 
                   2122:     <p>If the user agent is unable to render graphics, then it must
                   2123:     render the text string returned by the callback instead.</p>
                   2124: 
                   2125:    </dd>
                   2126: 
1.80      mike     2127:   </dl>
                   2128: 
                   2129:   <hr>
                   2130: 
                   2131:   <p>When an algorithm requires the user agent to <dfn>apply a
1.1       mike     2132:   <code>Row</code> object</dfn>, the user agent must run the following
                   2133:   steps:</p>
                   2134: 
1.80      mike     2135:   <ol>
                   2136: 
                   2137:    <li>
                   2138: 
                   2139:     <p>If the value of the <code>Row</code> object's second entry is
                   2140:     not &#x2212;1, then run these substeps:</p>
1.1       mike     2141: 
1.80      mike     2142:     <ol>
1.1       mike     2143: 
1.80      mike     2144:      <li><p>If there is a row with the same parent as the row
                   2145:      specified by the <code>Row</code> object's <code>RowID</code>
1.1       mike     2146:      object, whose display order position is currently the same as the
1.80      mike     2147:      value of the <code>Row</code> object's second entry, then remove
                   2148:      that row from the <span>display order sparse data
                   2149:      tree</span>.</p></li>
1.1       mike     2150: 
                   2151:      <li><p>Set the display order position of the row specified by the
1.80      mike     2152:      <code>Row</code> object's <code>RowID</code> to the value of the
                   2153:      <code>Row</code> object's second entry, updating its position in
                   2154:      the <span>display order sparse data tree</span>
1.1       mike     2155:      accordingly.</p></li>
                   2156: 
1.80      mike     2157:      <li><p>If the row is in the <span>pending
                   2158:      <code>datagrid</code> rows list</span>, remove it.</p></li>
                   2159: 
                   2160:     </ol>
1.1       mike     2161: 
1.80      mike     2162:    </li>
1.1       mike     2163: 
                   2164:    <li>
                   2165: 
1.80      mike     2166:     <p>If the fourth entry in the <code>Row</code> object (a
                   2167:     <code>CellList</code> object, an array) is not empty, then for
                   2168:     each <code>Cell</code> object in that array update the cell that
1.1       mike     2169:     corresponds to the column identified by the value of the first
1.80      mike     2170:     entry of the <code>Cell</code> object, by using the appropriate
1.1       mike     2171:     set of steps given below as determined by the type of the
1.80      mike     2172:     column. Then, if the cell is in the <span>pending
                   2173:     <code>datagrid</code> cells list</span>, remove it.</p>
1.1       mike     2174: 
1.80      mike     2175:     <dl>
                   2176: 
                   2177:      <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1       mike     2178:      <dd>
                   2179: 
                   2180:       <p>Update the cell's text to the value given in the
1.80      mike     2181:       <code>Cell</code> object's second entry.</p>
1.1       mike     2182: 
1.80      mike     2183:       <p>If the <code>Cell</code> object has three entries, then copy
                   2184:       the image data from the <code>img</code> element given in the
1.1       mike     2185:       third entry, and let the cell's image be given by that image
                   2186:       data. Otherwise, update the cell to have no image.</p>
                   2187: 
                   2188:      </dd>
                   2189: 
1.80      mike     2190:      <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1       mike     2191:      <dd>
                   2192: 
                   2193:       <p>Update the cell's text to the value given in the
1.80      mike     2194:       <code>Cell</code> object's second entry.</p>
1.1       mike     2195: 
1.80      mike     2196:       <p>If the <code>Cell</code> object has three entries, then let
                   2197:       the <code>datalist</code> element given in the third entry be
                   2198:       the <code>datalist</code> element giving autocompletion
1.1       mike     2199:       hints. Otherwise, update the cell to have no
1.80      mike     2200:       <code>datalist</code> element.</p>
1.1       mike     2201: 
1.80      mike     2202:       <p>If the <code>Cell</code> object has four entries, then copy
                   2203:       the image data from the <code>img</code> element given in the
1.1       mike     2204:       fourth entry, and let the cell's image be given by that image
                   2205:       data. Otherwise, update the cell to have no image.</p>
                   2206: 
                   2207:      </dd>
                   2208: 
1.80      mike     2209:      <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1       mike     2210:      <dd>
                   2211: 
                   2212:       <p>Update the cell's text to the value given in the
1.80      mike     2213:       <code>Cell</code> object's second entry.</p>
1.1       mike     2214: 
                   2215:       <p>Update the cell's checked state to match the value of the
                   2216:       third entry: checked if true, unchecked otherwise.</p>
                   2217: 
1.80      mike     2218:       <p>If the <code>Cell</code> object has four entries and the
1.1       mike     2219:       fourth entry is true, then update the cell to be obscured as
                   2220:       indeterminate. Otherwise, the cell's state is not obscured.</p>
                   2221: 
1.80      mike     2222:       <p>If the <code>Cell</code> object has five entries, then copy
                   2223:       the image data from the <code>img</code> element given in the
1.1       mike     2224:       fifth entry, and let the cell's image be given by that image
                   2225:       data. Otherwise, update the cell to have no image.</p>
                   2226: 
                   2227:      </dd>
                   2228: 
1.80      mike     2229:      <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1       mike     2230:      <dd>
                   2231: 
                   2232:       <p>Update the cell's text to the value given in the
1.80      mike     2233:       <code>Cell</code> object's second entry, and the
                   2234:       <code>select</code> element to be the one given in the
                   2235:       <code>Cell</code> object's third entry</p>
1.1       mike     2236: 
1.80      mike     2237:       <p>If the <code>Cell</code> object has four entries, then copy
                   2238:       the image data from the <code>img</code> element given in the
1.1       mike     2239:       fourth entry, and let the cell's image be given by that image
                   2240:       data. Otherwise, update the cell to have no image.</p>
                   2241: 
                   2242:      </dd>
                   2243: 
1.80      mike     2244:      <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1       mike     2245:      <dd>
                   2246: 
                   2247:       <p>Update the cell to be a progress bar whose progress, on the
                   2248:       scale of 0.0 (no progress) to 1.0 (task complete) is given by
1.80      mike     2249:       the value in the <code>Cell</code> object's second entry.</p>
1.1       mike     2250: 
                   2251:      </dd>
                   2252: 
1.80      mike     2253:      <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1       mike     2254:      <dd>
                   2255: 
                   2256:       <p>Update the cell to be a gauge configured with the numbers
                   2257:       given by the second and subsequent entries of the
1.80      mike     2258:       <code>Cell</code> object.</p>
1.1       mike     2259: 
                   2260:      </dd>
                   2261: 
1.80      mike     2262:      <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1       mike     2263:      <dd>
                   2264: 
                   2265:       <p>Update the cell's minimum width to be the length in CSS
1.80      mike     2266:       pixels given by the <code>Cell</code> object's second entry.</p>
1.1       mike     2267: 
                   2268:       <p>Update the cell's minimum height to be the length in CSS
1.80      mike     2269:       pixels given by the <code>Cell</code> object's third entry.</p>
1.1       mike     2270: 
                   2271:       <p>Update the cell's callback to be the
1.80      mike     2272:       <code>RenderingContext2DCallback</code> object given by the
                   2273:       <code>Cell</code> object's fourth entry.</p>
1.1       mike     2274: 
                   2275:      </dd>
                   2276: 
1.80      mike     2277:     </dl>
                   2278: 
                   2279:    </li>
1.1       mike     2280: 
1.80      mike     2281:   </ol>
                   2282: 
                   2283:   <hr>
                   2284: 
                   2285:   <p>When the user agent is to run the <dfn><code>datagrid</code>
                   2286:   update display algorithm</dfn>, the user agent must invoke the <code
                   2287:   title="dom-listener-getRows">getRows()</code> and <code
                   2288:   title="dom-listener-getCells">getCells()</code> methods on the
                   2289:   current <code title="dom-datagrid-listener">listener</code> such
                   2290:   that all the current visible rows in the <span>display order sparse
                   2291:   data list</span>, and all the cells in the currently visible columns
1.1       mike     2292:   on all the currently visible rows, have been covered.</p>
                   2293: 
1.80      mike     2294:   <p>A row is considered covered if it is present in the <span>pending
                   2295:   <code>datagrid</code> rows list</span>, or if the <code
                   2296:   title="dom-listener-getRows">getRows()</code> method is invoked with
1.1       mike     2297:   a range that includes the row in question.</p>
                   2298: 
                   2299:   <p>A cell is considered covered if it is present in the
1.80      mike     2300:   <span>pending <code>datagrid</code> cells list</span>, or if the
                   2301:   <code title="dom-listener-getRows">getRows()</code> method is
1.1       mike     2302:   invoked with a range that includes the row in question and a list of
1.80      mike     2303:   columns that includes the cell's column, or if the <code
                   2304:   title="dom-listener-getCells">getCells()</code> method is invoked
1.1       mike     2305:   with a list of rows and columns that intersects the cell in
1.80      mike     2306:   question. However, the <code
                   2307:   title="dom-listener-getCells">getCells()</code> method can only be
                   2308:   used if the row is already present in the <span>display order sparse
                   2309:   data list</span>.</p>
1.1       mike     2310: 
1.80      mike     2311:   <p>The <code title="dom-listener-getRows">getRows()</code> method,
1.1       mike     2312:   if used, must be invoked with five arguments. The first argument
1.80      mike     2313:   must be the index in the <span>display order sparse data list</span>
1.1       mike     2314:   to the first row that the user agent is requesting, known as the
                   2315:   <i>anchor row</i>. The second argument must be the number of
                   2316:   consecutive cells for which the user agent is requesting
1.80      mike     2317:   information. The third argument must be the <code>RowID</code> of
                   2318:   the row that is the nearest ancestor in the <span>display order
                   2319:   sparse data <em>tree</em></span> of the anchor row. If this is the
                   2320:   <code>datagrid</code>, then the <code>RowID</code> object must be an
1.1       mike     2321:   empty array. The fourth argument must be the display order position
1.80      mike     2322:   of the anchor row in the <span>display order sparse data
                   2323:   tree</span>, assuming that the row identified in the third argument
1.1       mike     2324:   is indeed the anchor row's parent row. The fifth and final argument
                   2325:   must be an array of the identifiers of the columns for which the
                   2326:   user agent is requesting information, in the order they were added
1.80      mike     2327:   to the <code>datagrid</code>.</p>
1.1       mike     2328: 
1.80      mike     2329:   <p>As the <code title="dom-listener-getRows">getRows()</code> method
                   2330:   is invoked, the <span>pending <code>datagrid</code> rows list</span>
1.1       mike     2331:   must be updated to include the rows for which information has been
                   2332:   requested, excluding rows for which information is already
1.80      mike     2333:   available; and the <span>pending <code>datagrid</code> cells
                   2334:   list</span> must be updated to include the cells for which
1.1       mike     2335:   information has been requested on those rows.</p>
                   2336: 
1.80      mike     2337:   <p>The <code title="dom-listener-getCells">getCells()</code> method,
1.1       mike     2338:   if used, must be invoked with two arguments. The first argument must
1.80      mike     2339:   be an array of <code>RowID</code> objects identifying the rows for
1.1       mike     2340:   which information is being requested. The second argument must be an
                   2341:   array of the identifiers of the columns for which the user agent is
                   2342:   requesting information, in the order they were added to the
1.80      mike     2343:   <code>datagrid</code>.</p>
1.1       mike     2344: 
1.80      mike     2345:   <p>As the <code title="dom-listener-getCells">getCells()</code>
                   2346:   method is invoked, the <span>pending <code>datagrid</code> cells
                   2347:   list</span> must be updated to include the cells for which
1.1       mike     2348:   information has been requested.</p>
                   2349: 
                   2350:   <p>Calls to these methods should be batched so that the rows and
                   2351:   cells to be covered are handled by the fewest number of calls to
                   2352:   these methods as possible. To this end, user agents may invoke the
1.80      mike     2353:   <code title="dom-listener-getRows">getRows()</code> method for a set
1.1       mike     2354:   of rows that includes some rows that are already in the
1.80      mike     2355:   <span>display order sparse data list</span>, and similarly may
                   2356:   invoke the <code title="dom-listener-getCells">getCells()</code>
1.1       mike     2357:   method with row/column combinations that cover some cells for which
                   2358:   data is already known. Generally, however, user agents should avoid
                   2359:   invoking these methods with arguments that cause information to be
                   2360:   requested when it has already been requested or is already
                   2361:   known.</p>
                   2362: 
                   2363:   <div class="example">
                   2364: 
                   2365:    <p>For example, consider a case represented by the following table,
                   2366:    where the cells marked "Yes" indicate that the data has already
                   2367:    been obtained, the cells marked "Pending" indicate that the data
                   2368:    has been previously requested but not yet obtained, and the cells
                   2369:    with just a dash indicate that no information has ever been
                   2370:    obtained, or any information that had been obtained has now been
                   2371:    discarded.</p>
                   2372: 
1.80      mike     2373:    <table>
                   2374:     <tr> <td>        <th> Row   <th> Column A  <th> Column B
                   2375:     <tr> <th> Row 1  <td> -     <td> -         <td> -
                   2376:     <tr> <th> Row 2  <td> Yes   <td> Yes       <td> Yes
                   2377:     <tr> <th> Row 3  <td> Yes   <td> Yes       <td> Yes
                   2378:     <tr> <th> Row 4  <td> Yes   <td> Yes       <td> Yes
                   2379:     <tr> <th> Row 5  <td> -     <td> -         <td> -
                   2380:     <tr> <th> Row 6  <td> -     <td> -         <td> -
                   2381:     <tr> <th> Row 7  <td> Yes   <td> Pending   <td> -
                   2382:     <tr> <th> Row 8  <td> Yes   <td> Pending   <td> Pending
                   2383:    </table>
                   2384: 
                   2385:    <p>Thus, rows 2, 3, 4, 7, and 8 are already covered, as are the
1.1       mike     2386:    cells from those rows except for the cell in column B of row 7.</p>
                   2387: 
                   2388:    <p>Now consider what happens if all of these rows become visible at
                   2389:    once. The user agent has several choices, including (but not
                   2390:    limited to) the following:</p>
                   2391: 
1.80      mike     2392:    <ul>
                   2393: 
                   2394:     <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1       mike     2395:     method for rows 1 through 8 and columns A and B all at once.</li>
                   2396: 
1.80      mike     2397:     <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1       mike     2398:     method for row 1, then fire it again for rows 5 through 7.</li>
                   2399: 
1.80      mike     2400:     <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1       mike     2401:     method for row 1, then fire it again for rows 5 and 6, and then
1.80      mike     2402:     fire the <code title="dom-listener-getCells">getCells()</code>
1.1       mike     2403:     method for row 7 column B.</li>
                   2404: 
1.80      mike     2405:    </ul>
                   2406: 
                   2407:    <p>All three options are allowed, but the latter two are preferable
1.1       mike     2408:    to the former, as they minimise the amount of redundant information
                   2409:    requested.</p>
                   2410: 
                   2411:    <p>In any case, the data model now looks like this:</p>
                   2412: 
1.80      mike     2413:    <table>
                   2414:     <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
                   2415:     <tr> <th> Row 1  <td> Pending <td> Pending   <td> Pending   <td> -
                   2416:     <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2417:     <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2418:     <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2419:     <tr> <th> Row 5  <td> Pending <td> Pending   <td> Pending   <td> -
                   2420:     <tr> <th> Row 6  <td> Pending <td> Pending   <td> Pending   <td> -
                   2421:     <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> -
                   2422:     <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> -
                   2423:    </table>
                   2424: 
                   2425:    <p>Now consider the case where a third column, column C, is added
1.1       mike     2426:    to the data model. The user agent once again has several choices,
                   2427:    including (but not limited to) the following:</p>
                   2428: 
1.80      mike     2429:    <ul>
                   2430: 
                   2431:     <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1       mike     2432:     method for rows 1 through 8 again, this time listing just column
                   2433:     C.</li>
                   2434: 
1.80      mike     2435:     <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1       mike     2436:     method for row 1, then fire it again for rows 5 and 6, and then
1.80      mike     2437:     fire the <code title="dom-listener-getCells">getCells()</code>
1.1       mike     2438:     method for the other rows (in all three cases, listing just column
                   2439:     C).</li>
                   2440: 
1.80      mike     2441:    </ul>
                   2442: 
                   2443:    <p>The two options here are as bad as each other; the former
1.1       mike     2444:    involves a lot of overlap, but the latter involves a lot of method
                   2445:    calls. Unfortunately the user agent can't do the obvious thing,
1.80      mike     2446:    namely just to invoke the <code
                   2447:    title="dom-listener-getCells">getCells()</code> method for all the
1.1       mike     2448:    rows listing just column C, because it doesn't have the row
                   2449:    information for all the rows yet (rows 1, 5 and 6 are still
                   2450:    pending).</p>
                   2451: 
                   2452:    <p>In any case, the data model now looks like this:</p>
                   2453: 
1.80      mike     2454:    <table>
                   2455:     <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
                   2456:     <tr> <th> Row 1  <td> Pending <td> Pending   <td> Pending   <td> Pending
                   2457:     <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2458:     <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2459:     <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2460:     <tr> <th> Row 5  <td> Pending <td> Pending   <td> Pending   <td> Pending
                   2461:     <tr> <th> Row 6  <td> Pending <td> Pending   <td> Pending   <td> Pending
                   2462:     <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2463:     <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2464:    </table>
                   2465: 
                   2466:    <p>If at this point the user scrolls around anywhere within this
                   2467:    <code>datagrid</code>, the user agent won't fire the <code
                   2468:    title="dom-listener-getRows">getRows()</code> and <code
                   2469:    title="dom-listener-getCells">getCells()</code> methods, because
1.1       mike     2470:    all of the rows and cells are covered.</p>
                   2471: 
                   2472:    <p>Now consider the case where the user agent receives row
                   2473:    information, but no cell information, for rows 1, 5, and 6:</p>
                   2474: 
1.80      mike     2475:    <table>
                   2476:     <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
                   2477:     <tr> <th> Row 1  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2478:     <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2479:     <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2480:     <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> Pending
                   2481:     <tr> <th> Row 5  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2482:     <tr> <th> Row 6  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2483:     <tr> <th> Row 7  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2484:     <tr> <th> Row 8  <td> Yes     <td> Pending   <td> Pending   <td> Pending
                   2485:    </table>
                   2486: 
                   2487:    <p>The user agent still won't fire any methods when the user
1.1       mike     2488:    scrolls, because the data is still covered. But if the script then
1.80      mike     2489:    calls the <code title="dom-datagrid-renotify">renotify()</code>
1.1       mike     2490:    method, the "Pending" flags would get reset, and the model would
                   2491:    now look like this:</p>
                   2492: 
1.80      mike     2493:    <table>
                   2494:     <tr> <td>        <th> Row     <th> Column A  <th> Column B  <th> Column C
                   2495:     <tr> <th> Row 1  <td> Yes     <td> -         <td> -         <td> -
                   2496:     <tr> <th> Row 2  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2497:     <tr> <th> Row 3  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2498:     <tr> <th> Row 4  <td> Yes     <td> Yes       <td> Yes       <td> -
                   2499:     <tr> <th> Row 5  <td> Yes     <td> -         <td> -         <td> -
                   2500:     <tr> <th> Row 6  <td> Yes     <td> -         <td> -         <td> -
                   2501:     <tr> <th> Row 7  <td> Yes     <td> -         <td> -         <td> -
                   2502:     <tr> <th> Row 8  <td> Yes     <td> -         <td> -         <td> -
                   2503:    </table>
                   2504: 
                   2505:    <p>Now, assuming that all eight rows and all three columns are
1.1       mike     2506:    still visible, the user agent has the following choices (amongst
                   2507:    others):</p>
                   2508: 
1.80      mike     2509:    <ul>
                   2510: 
                   2511:     <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1       mike     2512:     method for rows 1 through 8, listing all three columns.</li>
                   2513: 
1.80      mike     2514:     <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1       mike     2515:     method for rows 1 and 5 through 8, listing all three columns, and
                   2516:     then fire the method for rows 2 through 4, listing just column
                   2517:     C.</li>
                   2518: 
1.80      mike     2519:     <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1       mike     2520:     method for rows 1 and 5 through 8, listing just columns A abd B,
                   2521:     and then fire the method for rows 1 through 8, listing just column
                   2522:     C.</li>
                   2523: 
1.80      mike     2524:    </ul>
                   2525: 
                   2526:    <p>Here the latter two are preferable because they result in less
1.1       mike     2527:    overlap than the first.</p>
                   2528: 
                   2529:   </div>
                   2530: 
1.80      mike     2531:   <hr>
                   2532: 
                   2533:   <p>The <span>task source</span> for tasks queued on behalf of a
                   2534:   <code>datagrid</code> is the <span>DOM manipulation task
                   2535:   source</span>.</p>
                   2536: 
                   2537:   </div>
                   2538: 
                   2539: 
                   2540:   <h5>Listening to notifications from the <code>datagrid</code></h5>
1.1       mike     2541: 
1.80      mike     2542:   <p><i>The conformance criteria in this section apply to any
                   2543:   implementation of the <code>DataGridListener</code> interface,
1.1       mike     2544:   including (and most commonly) the content author's
1.80      mike     2545:   implementation(s).</i></p>
                   2546: 
                   2547:   <pre class="idl">// To be implemented by Web authors as a JS object
1.81      mike     2548: [NoInterfaceObject]
                   2549: interface <dfn>DataGridListener</dfn> {
1.80      mike     2550:   void <span title="dom-listener-initialize">initialize</span>(in <span>HTMLDataGridElement</span> datagrid);
                   2551: 
                   2552:   void <span title="dom-listener-getRows">getRows</span>(in unsigned long rowIndex, in unsigned long rowCount, in <span>RowID</span> parentRow, in unsigned long position, in <span>ColumnList</span> columns);
                   2553:   void <span title="dom-listener-getCells">getCells</span>(in <span>RowIDList</span> rows, in <span>ColumnList</span> columns);
                   2554:   void <span title="dom-listener-rowOpened">rowOpened</span>(in <span>RowID</span> row, in boolean rowCountNeeded);
                   2555:   void <span title="dom-listener-rowClosed">rowClosed</span>(in <span>RowID</span> row);
                   2556: 
                   2557:   void <span title="dom-listener-cellChanged">cellChanged</span>(in <span>RowID</span> row, in <span>Column</span> column, in any newValue, in any prevValue);
                   2558:   <span>HTMLMenuElement</span> <span title="dom-listener-getRowMenu">getRowMenu</span>(in <span>RowID</span> row);
                   2559: <!- -vsDGDND
1.1       mike     2560:   boolean <span title="dom-listener-canDrop">canDrop</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
                   2561:   boolean <span title="dom-listener-dropped">dropped</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
1.80      mike     2562: - -><!- -v2DGPA
1.1       mike     2563:   void <span title="dom-listener-performAction">performAction</span>(in <span>RowID</span> row, in DOMString action);
1.80      mike     2564: - ->};</pre>
                   2565: 
                   2566:   <p>The <code>DataGridListener</code> interface, once implemented by
                   2567:   an object in a script and hooked up to a <code>datagrid</code> using
                   2568:   the <code title="dom-datagrid-listener">listener</code> DOM
                   2569:   attribute, receives notifications when the <code>datagrid</code>
                   2570:   needs information (such as which rows exist) for display.</p>
                   2571: 
                   2572:   <p>The following methods may be usefully implemented:</p>
                   2573: 
                   2574:   <dl>
                   2575: 
                   2576:    <dt><dfn title="dom-listener-initialize"><code>initialize(<var title="">datagrid</var>)</code></dfn></dt>
1.1       mike     2577: 
                   2578:    <dd>
                   2579: 
1.80      mike     2580:     <p>Called by the <code>datagrid</code> element (the one given by
                   2581:     the <var title="">datagrid</var> argument) when the <code
                   2582:     title="dom-datagrid-listener">listener</code> attribute is
1.1       mike     2583:     set.</p>
                   2584: 
                   2585:    </dd>
                   2586: 
1.80      mike     2587:    <dt><dfn title="dom-listener-getRows"><code>getRows(<var title="">rowIndex</var>, <var title="">rowCount</var>, <var title="">parentRow</var>, <var title="">position</var>, <var title="">columns</var>)</code></dfn></dt>
1.1       mike     2588: 
                   2589:    <dd>
                   2590: 
1.80      mike     2591:     <p>Called by the <code>datagrid</code> element when the user agent
1.1       mike     2592:     finds itself needing to render rows for which it is lacking
                   2593:     information.</p>
                   2594: 
                   2595:     <p>The <var title="">rowIndex</var> argument gives the flattened
                   2596:     index of the first row for which it needs information, ignoring
1.80      mike     2597:     the tree structure of the <code>datagrid</code> model, where zero
1.1       mike     2598:     is the first row of the entire tree.</p>
                   2599: 
                   2600:     <p>The <var title="">rowCount</var> argument gives the number of
                   2601:     rows for which the user agent would like information.</p>
                   2602: 
                   2603:     <p>The <var title="">parentRow</var> argument gives the
1.80      mike     2604:     <code>RowID</code> object identifying the nearest ancestor of the
1.1       mike     2605:     first row that the user agent is aware of. After the sort order
                   2606:     has changed, this will typically be the root of the tree
1.80      mike     2607:     (identified by a <code>RowID</code> object consisting of an empty
1.1       mike     2608:     array).
                   2609: 
1.80      mike     2610:     <p>The <var title="">columns</var> argument gives the columns for
1.1       mike     2611:     which the user agent is lacking information, as an array of column
1.80      mike     2612:     identifiers (as passed to <code
                   2613:     title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1       mike     2614: 
                   2615:    </dd>
                   2616: 
1.80      mike     2617:    <dt><dfn title="dom-listener-getCells"><code>getCells(<var title="">rows</var>, <var title="">columns</var>)</code></dfn></dt>
1.1       mike     2618: 
                   2619:    <dd>
                   2620: 
1.80      mike     2621:     <p>Called by the <code>datagrid</code> element when the user agent
1.1       mike     2622:     finds itself needing to render cells for which it is lacking
                   2623:     information in rows that it does know about.</p>
                   2624: 
                   2625:     <p>The <var title="">rows</var> argument gives an array of
1.80      mike     2626:     <code>RowID</code> objects identifying the various rows for which
1.1       mike     2627:     the user agent is lacking information.</p>
                   2628: 
                   2629:     <p>The <var title="">columns</var> argument gives the columns for
                   2630:     which the user agent is lacking information, as an array of column
1.80      mike     2631:     identifiers (as passed to <code
                   2632:     title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1       mike     2633: 
                   2634:    </dd>
                   2635: 
1.80      mike     2636:    <dt><dfn title="dom-listener-rowOpened"><code>rowOpened(<var title="">row</var>, <var title="">rowCountNeeded</var>)</code></dfn></dt>
1.1       mike     2637: 
                   2638:    <dd>
                   2639: 
1.80      mike     2640:     <p>Called by the <code>datagrid</code> element when the user has
1.1       mike     2641:     opened a row.</p>
                   2642: 
                   2643:     <p>The <var title="">row</var> argument gives an
1.80      mike     2644:     <code>RowID</code> object identifying the row that was opened.</p>
1.1       mike     2645: 
                   2646:     <p>If the user agent also knows how many children that row has,
                   2647:     then the <var title="">rowCountNeeded</var> argument will be
                   2648:     false. Otherwise, the argument will be true, and the row will
1.80      mike     2649:     remain closed until the <code
                   2650:     title="dom-datagrid-setRows">setRows()</code> method is called
1.1       mike     2651:     with an accurate row count.</p>
                   2652: 
                   2653:    </dd>
                   2654: 
1.80      mike     2655:    <dt><dfn title="dom-listener-rowClosed"><code>rowClosed(<var title="">row</var>)</code></dfn></dt>
1.1       mike     2656: 
                   2657:    <dd>
                   2658: 
1.80      mike     2659:     <p>Called by the <code>datagrid</code> element when the user has
1.1       mike     2660:     opened a row.</p>
                   2661: 
                   2662:     <p>The <var title="">row</var> argument gives an
1.80      mike     2663:     <code>RowID</code> object identifying the row that was closed.</p>
1.1       mike     2664: 
                   2665:    </dd>
                   2666: 
1.80      mike     2667:    <dt><dfn title="dom-listener-cellChanged"><code>cellChanged(<var title="">row</var>, <var title="">column</var>, <var title="">newValue</var>, <var title="">prevValue</var>)</code></dfn></dt>
1.1       mike     2668: 
                   2669:    <dd>
                   2670: 
1.80      mike     2671:     <p>Called by the <code>datagrid</code> element when the user has
1.1       mike     2672:     edited a cell or checked a check box in a cell.</p>
                   2673: 
                   2674:     <p>The <var title="">row</var> argument gives an
1.80      mike     2675:     <code>RowID</code> object identifying the row of the cell, and the
1.1       mike     2676:     <var title="">column</var> argument gives the identifier of the
                   2677:     cell's column.</p>
                   2678: 
                   2679:     <p>The <var title="">newValue</var> argument gives the new value,
                   2680:     and the <var title="">prevValue</var> argument gives the previous
                   2681:     value.</p>
                   2682: 
                   2683:    </dd>
                   2684: 
1.80      mike     2685:    <dt><dfn title="dom-listener-getRowMenu"><code>getRowMenu(<var title="">row</var>)</code></dfn></dt>
1.1       mike     2686: 
1.80      mike     2687:    <dd>Must return an <code>HTMLMenuElement</code> object that is to
1.1       mike     2688:    be used as a context menu for row <var title="">row</var>, or null
                   2689:    if there is no particular context menu. May be omitted if none of
                   2690:    the rows have a special context menu. As this method is called
                   2691:    immediately before showing the menu in question, no precautions
                   2692:    need to be taken if the return value of this method changes.</dd>
                   2693: 
1.80      mike     2694:    <!- -v2DGDND, v2DFPA- ->
1.1       mike     2695: 
1.80      mike     2696:   </dl>
                   2697: 
                   2698:   <div class="impl">
1.1       mike     2699: 
1.80      mike     2700:   <p>Objects that implement the <code>DataGridListener</code>
1.1       mike     2701:   interface may omit any or all of the methods. When a method is
                   2702:   omitted, a user agent intending to call that method must instead
                   2703:   skip the method call, and must assume that the method's return value
                   2704:   is null.</p>
                   2705: 
1.80      mike     2706:   </div>
                   2707: 
                   2708: 
                   2709: 
                   2710: <!- - v2DGS: <datagrid> selection (search for the bits marked "..." to see what needs filling in, at a minimum)
1.1       mike     2711: 
                   2712:   <h5>The selection</h5>
                   2713: 
                   2714:   <pre class="idl">interface <dfn>DataGridSelection</dfn> {
                   2715:   readonly attribute unsigned long <span title="dom-DataGridSelection-length">length</span>;
1.81      mike     2716:   getter <span>RowID</span> <span title="dom-DataGridSelection-item">item</span>(in unsigned long index);
1.1       mike     2717:   boolean <span title="dom-DataGridSelection-isSelected">isSelected</span>(in <span>RowID</span> row);
                   2718:   void <span title="dom-DataGridSelection-setSelected">setSelected</span>(in <span>RowID</span> row, in boolean selected);
                   2719:   void <span title="dom-DataGridSelection-selectAll">selectAll</span>();
                   2720:   void <span title="dom-DataGridSelection-clear">clear</span>();
                   2721: };</pre>
                   2722: 
                   2723:   <dl class="domintro">
                   2724: 
                   2725:    ...
                   2726: 
                   2727:   </dl>
                   2728: 
                   2729:   <div class="impl">
                   2730: 
                   2731:   <p>Each <code>datagrid</code> element must keep track of which rows
                   2732:   are currently selected. Initially, no rows are selected. This can be
                   2733:   changed using the methods described in this section.</p>
                   2734: 
                   2735:   <p>The selection of a <code>datagrid</code> is represented by its
                   2736:   <dfn title="dom-datagrid-selection"><code>selection</code></dfn> DOM
                   2737:   attribute, which must be a <code>DataGridSelection</code> object.</p>
                   2738: 
                   2739:   <p><code>DataGridSelection</code> objects represent the rows in the
                   2740:   selection. In the selection the rows must be ordered in their
                   2741:   natural order (and not, e.g., the display order). A row with an
                   2742:   ancestor that is closed cannot be selected.</p>
                   2743: 
                   2744:   <p>The <dfn
                   2745:   title="dom-DataGridSelection-length"><code>length</code></dfn>
                   2746:   attribute must return the number of rows currently present in the
                   2747:   selection. This is the <var
                   2748:   title="dom-DataGridSelection-length">length</var>.</p>
                   2749: 
                   2750:   <p>The object's <span>indices of the supported indexed
                   2751:   properties</span> are the numbers in the range zero to <span title=""><var
                   2752:   title="dom-DataGridSelection-length">length</var>-1</span>, unless
                   2753:   the <var title="dom-DataGridSelection-length">length</var> is zero,
                   2754:   in which case there are no <span>supported indexed
                   2755:   properties</span>.</p>
                   2756: 
                   2757:   <p>The <dfn title="dom-DataGridSelection-item"><code>item(<var
                   2758:   title="">index</var>)</code></dfn> method must return a
                   2759:   <code>RowID</code> object identifying the <var
                   2760:   title="">index</var>th row in the selection. If the argument is out
                   2761:   of range (less than zero or greater than the number of selected rows
                   2762:   minus one), then it must raise an <code>INDEX_SIZE_ERR</code>
1.98      mike     2763:   exception. <a href="#refsDOMCORE">[DOMCORE]</a></p>
1.1       mike     2764: 
                   2765:   <p>The <dfn
                   2766:   title="dom-DataGridSelection-isSelected"><code>isSelected()</code></dfn>
                   2767:   method must return the selected state of the row specified by its
                   2768:   argument. If the specified row is in the <span>natural order sparse
                   2769:   data tree</span> and is selected, the method must return true,
                   2770:   otherwise it must return false.</p>
                   2771: 
                   2772:   <p>The <dfn
                   2773:   title="dom-DataGridSelection-setSelected"><code>setSelected()</code></dfn>
                   2774:   method takes two arguments, <var title="">row</var> and <var
                   2775:   title="">selected</var>. When invoked, it must set the selection
                   2776:   state of row <var title="">row</var> to selected if <var
                   2777:   title="">selected</var> is true, and unselected if it is false. If
                   2778:   <var title="">row</var> does not specify a row in the <span>natural
                   2779:   order sparse data tree</span> ...
                   2780: 
                   2781:   <p>The <dfn
                   2782:   title="dom-DataGridSelection-selectAll"><code>selectAll()</code></dfn>
                   2783:   method must ...
                   2784: 
                   2785:   <p>The <dfn
                   2786:   title="dom-DataGridSelection-clear"><code>clear()</code></dfn>
                   2787:   method must mark all the rows in the <code>datagrid</code> as not
                   2788:   selected. After a call to <code
                   2789:   title="dom-DataGridSelection-clear">clear()</code>, the <code
                   2790:   title="dom-DataGridSelection-length">length</code> attribute will
                   2791:   return zero.</p>
                   2792: 
                   2793:   <p>If the <code>datagrid</code> element has a <code
                   2794:   title="attr-datagrid-multiple">multiple</code> attribute, then the
                   2795:   user agent should allow the user to select any number of rows (zero
                   2796:   or more). If the attribute is not present, then the user agent
                   2797:   should allow the user to select a row, and must not allow the user
                   2798:   to select more than a single row at a time; selecting another one
                   2799:   must unselect all the other rows.</p>
                   2800: 
                   2801:   <p class="note">This only applies to the user. Scripts can select
                   2802:   multiple rows even when the <code
                   2803:   title="attr-datagrid-multiple">multiple</code> attribute is
                   2804:   absent.</p>
                   2805: 
                   2806:   ...event on selection change?...
                   2807: 
                   2808:   </div>
                   2809: 
                   2810:   <p class="note">The <code>DataGridSelection</code> interface has no
                   2811:   relation to the <code>Selection</code> interface.</p>
                   2812: 
1.80      mike     2813: - ->
                   2814: 
                   2815: 
                   2816: <!- -vsDGDND
1.1       mike     2817:   <h5>Drag and drop in <code>datagrid</code>s</h5>
                   2818: 
                   2819:   <p><i>This section only applies to interactive user agents.</i></p>
                   2820: 
                   2821:   ...define drag and drop in datagrids; selectiondraggable...
1.80      mike     2822: - ->
                   2823: 
1.153     mike     2824: --><h4 id="the-command"><span class="secno">4.11.2 </span>The <dfn><code>command</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p><dl class="element"><dt>Categories</dt>
                   2825:    <dd><a href="dom.html#metadata-content">Metadata content</a>.</dd>
                   2826:    <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
                   2827:    <dd><a href="dom.html#phrasing-content">Phrasing content</a>.</dd>
1.1       mike     2828:    <dt>Contexts in which this element may be used:</dt>
1.153     mike     2829:    <dd>Where <a href="dom.html#metadata-content">metadata content</a> is expected.</dd>
                   2830:    <dd>Where <a href="dom.html#phrasing-content">phrasing content</a> is expected.</dd>
1.1       mike     2831:    <dt>Content model:</dt>
                   2832:    <dd>Empty.</dd>
                   2833:    <dt>Content attributes:</dt>
                   2834:    <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
                   2835:    <dd><code title="attr-command-type"><a href="#attr-command-type">type</a></code></dd>
                   2836:    <dd><code title="attr-command-label"><a href="#attr-command-label">label</a></code></dd>
                   2837:    <dd><code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code></dd>
                   2838:    <dd><code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code></dd>
                   2839:    <dd><code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code></dd>
                   2840:    <dd><code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code></dd>
                   2841:    <!--<dd><code title="attr-command-default">default</code></dd>-->
                   2842:    <dd>Also, the <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute has special semantics on this element.</dd>
                   2843:    <dt>DOM interface:</dt>
                   2844:    <dd>
                   2845: <pre class="idl">interface <dfn id="htmlcommandelement">HTMLCommandElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
                   2846:            attribute DOMString <a href="#dom-command-type" title="dom-command-type">type</a>;
                   2847:            attribute DOMString <a href="#dom-command-label" title="dom-command-label">label</a>;
                   2848:            attribute DOMString <a href="#dom-command-icon" title="dom-command-icon">icon</a>;
                   2849:            attribute boolean <a href="#dom-command-disabled" title="dom-command-disabled">disabled</a>;
                   2850:            attribute boolean <a href="#dom-command-checked" title="dom-command-checked">checked</a>;
                   2851:            attribute DOMString <a href="#dom-command-radiogroup" title="dom-command-radiogroup">radiogroup</a>;<!--
                   2852:            attribute boolean <span title="dom-command-default">default</span>;-->
                   2853: };</pre>
                   2854:    </dd>
                   2855:   </dl><p>The <code><a href="#the-command">command</a></code> element represents a command that the user
1.117     mike     2856:   can invoke.</p><p>The <dfn id="attr-command-type" title="attr-command-type"><code>type</code></dfn>
1.1       mike     2857:   attribute indicates the kind of command: either a normal command
                   2858:   with an associated action, or a state or option that can be toggled,
1.117     mike     2859:   or a selection of one item from a list of items.</p><p>The attribute is an <a href="infrastructure.html#enumerated-attribute">enumerated attribute</a> with three
1.1       mike     2860:   keywords and states. The keyword "<dfn id="attr-command-type-keyword-command" title="attr-command-type-keyword-command"><code>command</code></dfn>"
                   2861:   maps to the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state, the
                   2862:   <dfn id="attr-command-type-keyword-checkbox" title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
                   2863:   maps to the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a>, and the
                   2864:   "<dfn id="attr-command-type-keyword-radio" title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
                   2865:   keyword maps to the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state. The
1.117     mike     2866:   <i>missing value default</i> is the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state.</p><dl><dt>The <dfn id="attr-command-type-state-command" title="attr-command-type-state-command">Command</dfn> state</dt>
1.1       mike     2867: 
                   2868:    <dd><p>The element <a href="the-xhtml-syntax.html#represents">represents</a> a normal command with an associated action.</p></dd>
                   2869: 
                   2870:    <dt>The <dfn id="attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>
                   2871: 
                   2872:    <dd><p>The element <a href="the-xhtml-syntax.html#represents">represents</a> a state or option that can be toggled.</p></dd>
                   2873: 
                   2874:    <dt>The <dfn id="attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</dfn> state</dt>
                   2875: 
                   2876:    <dd><p>The element <a href="the-xhtml-syntax.html#represents">represents</a> a selection of one item from a list of items.</p></dd>
                   2877: 
                   2878:   </dl><p>The <dfn id="attr-command-label" title="attr-command-label"><code>label</code></dfn>
1.117     mike     2879:   attribute gives the name of the command, as shown to the user.</p><p>The <dfn id="attr-command-title" title="attr-command-title"><code>title</code></dfn>
1.1       mike     2880:   attribute gives a hint describing the command, which might be shown
1.117     mike     2881:   to the user to help him.</p><p>The <dfn id="attr-command-icon" title="attr-command-icon"><code>icon</code></dfn>
1.1       mike     2882:   attribute gives a picture that represents the command. If the
                   2883:   attribute is specified, the attribute's value must contain a
                   2884:   <a href="infrastructure.html#valid-url">valid URL</a>. <span class="impl">To obtain the
                   2885:   <a href="infrastructure.html#absolute-url">absolute URL</a> of the icon, the attribute's value must be
                   2886:   <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolved</a> relative to the
1.117     mike     2887:   element.</span></p><!-- this is affected by the base URL being
1.1       mike     2888:   changed, so users of this should cache the image once they've
1.117     mike     2889:   fetched it once, at least until the relative url changes again --><p>The <dfn id="attr-command-disabled" title="attr-command-disabled"><code>disabled</code></dfn> attribute
1.1       mike     2890:   is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a> that, if present, indicates that
1.117     mike     2891:   the command is not available in the current state.</p><p class="note">The distinction between <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> and <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> is subtle. A command would be
1.1       mike     2892:   disabled if, in the same context, it could be enabled if only
                   2893:   certain aspects of the situation were changed. A command would be
                   2894:   marked as hidden if, in that situation, the command will never be
                   2895:   enabled. For example, in the context menu for a water faucet, the
                   2896:   command "open" might be disabled if the faucet is already open, but
                   2897:   the command "eat" would be marked hidden since the faucet could
1.117     mike     2898:   never be eaten.</p><p>The <dfn id="attr-command-checked" title="attr-command-checked"><code>checked</code></dfn>
1.1       mike     2899:   attribute is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a> that, if present,
                   2900:   indicates that the command is selected. The attribute must be
                   2901:   omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code>
                   2902:   attribute is in either the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state or
                   2903:   the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a>
1.117     mike     2904:   state.</p><p>The <dfn id="attr-command-radiogroup" title="attr-command-radiogroup"><code>radiogroup</code></dfn>
1.1       mike     2905:   attribute gives the name of the group of commands that will be
                   2906:   toggled when the command itself is toggled, for commands whose <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute has the value "<code title="">radio</code>". The scope of the name is the child list of
1.117     mike     2907:   the parent element. The attribute must be omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state.</p><!--
1.1       mike     2908:   <p>If the <code>command</code> element is used when <span
                   2909:   title="menu generation">generating</span> a <span>context
                   2910:   menu</span>, then the <dfn
                   2911:   title="attr-command-default"><code>default</code></dfn> attribute
                   2912:   indicates, if present, that the command is the one that would have
                   2913:   been invoked if the user had directly activated the menu's subject
                   2914:   instead of using its context menu. The <code
                   2915:   title="attr-command-default">default</code> attribute is a
                   2916:   <span>boolean attribute</span>. The attribute must be omitted unless
                   2917:   the <code title="attr-command-type">type</code> attribute is in the
                   2918:   <span title="attr-command-type-state-command">Command</span>
                   2919:   state.</p>
                   2920: 
                   2921:   <div class="example">
                   2922: 
                   2923:    ...an example that shows an element that, if double-clicked,
                   2924:    invokes an action, but that also has a context menu, showing the
                   2925:    various <code>command</code> attributes off, and that has a default
                   2926:    command...
                   2927: 
                   2928:   </div>
1.117     mike     2929: --><div class="impl">
1.1       mike     2930: 
                   2931:   <p>The <dfn id="dom-command-type" title="dom-command-type"><code>type</code></dfn>, <dfn id="dom-command-label" title="dom-command-label"><code>label</code></dfn>, <dfn id="dom-command-icon" title="dom-command-icon"><code>icon</code></dfn>, <dfn id="dom-command-disabled" title="dom-command-disabled"><code>disabled</code></dfn>, <dfn id="dom-command-checked" title="dom-command-checked"><code>checked</code></dfn>, and <dfn id="dom-command-radiogroup" title="dom-command-radiogroup"><code>radiogroup</code></dfn><!--,
                   2932:   and <dfn title="dom-command-default"><code>default</code></dfn>-->
                   2933:   DOM attributes must <a href="infrastructure.html#reflect">reflect</a> the respective content
                   2934:   attributes of the same name.</p>
                   2935: 
1.153     mike     2936:   <p>The element's <a href="embedded-content-0.html#activation-behavior">activation behavior</a> depends on the
1.1       mike     2937:   value of the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute
                   2938:   of the element, as follows:</p>
                   2939: 
                   2940:   <dl class="switch"><dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
                   2941:    in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state</dt>
                   2942: 
                   2943:    <dd><p>If the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, the UA must
                   2944:    remove that attribute. Otherwise, the UA must add a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, with the
                   2945:    literal value <code title="">checked</code>. The UA must then
                   2946:    <a href="browsers.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the
                   2947:    element.</p></dd>
                   2948: 
                   2949: 
                   2950:    <dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
                   2951:    in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state</dt>
                   2952: 
                   2953:    <dd><p>If the element has a parent, then the UA must walk the list
                   2954:    of child nodes of that parent element, and for each node that is a
                   2955:    <code><a href="#the-command">command</a></code> element, if that element has a <code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code> attribute whose
                   2956:    value exactly matches the current element's (treating missing <code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code> attributes as if
                   2957:    they were the empty string), and has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, must remove
                   2958:    that attribute.</p>
                   2959: 
                   2960:    <p>Then, the element's <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute attribute
                   2961:    must be set to the literal value <code title="">checked</code> and
                   2962:    the user agent must <a href="browsers.html#fire-a-click-event">fire a <code title="event-click">click</code>
                   2963:    event</a> at the element.</p></dd>
                   2964: 
                   2965: 
                   2966:    <dt>Otherwise</dt>
                   2967: 
1.153     mike     2968:    <dd><p>The element has no <a href="embedded-content-0.html#activation-behavior">activation behavior</a>.</p></dd>
1.1       mike     2969: 
                   2970:   </dl><p class="note">Firing a synthetic <code title="event-click">click</code> event at the element does not cause
                   2971:   any of the actions described above to happen.</p>
                   2972: 
                   2973:   <!-- v2COMMAND: the command="" attribute to make a <command> element
                   2974:   reflect the state of another command, so that the script can update
                   2975:   one place in the page and have context menus, toolbars, shortcuts,
                   2976:   etc, automatically update. Once we add this, expose the Triggers
                   2977:   facet again. -->
                   2978: 
1.117     mike     2979:   </div><p class="note"><code><a href="#the-command">command</a></code> elements are not rendered
1.153     mike     2980:   unless they <a href="#menus" title="menu">form part of a menu</a>.</p><h4 id="menus"><span class="secno">4.11.3 </span>The <dfn><code>menu</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p><dl class="element"><dt>Categories</dt>
                   2981:    <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
                   2982:    <dd>If the element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#tool-bar-state" title="tool bar state">tool bar</a> state: <a href="embedded-content-0.html#interactive-content">Interactive content</a>.</dd>
1.1       mike     2983:    <dt>Contexts in which this element may be used:</dt>
1.153     mike     2984:    <dd>Where <a href="dom.html#flow-content">flow content</a> is expected.</dd>
1.1       mike     2985:    <dt>Content model:</dt>
                   2986:    <dd>Either: Zero or more <code><a href="semantics.html#the-li-element">li</a></code> elements.</dd>
1.153     mike     2987:    <dd>Or: <a href="dom.html#flow-content">Flow content</a>.</dd>
1.1       mike     2988:    <dt>Content attributes:</dt>
                   2989:    <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
                   2990:    <dd><code title="attr-menu-type"><a href="#attr-menu-type">type</a></code></dd>
                   2991:    <dd><code title="attr-menu-label"><a href="#attr-menu-label">label</a></code></dd>
                   2992:    <dt>DOM interface:</dt>
                   2993:    <dd>
                   2994: <pre class="idl">interface <dfn id="htmlmenuelement">HTMLMenuElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
                   2995:            attribute DOMString <a href="#dom-menu-type" title="dom-menu-type">type</a>;
                   2996:            attribute DOMString <a href="#dom-menu-label" title="dom-menu-label">label</a>;
                   2997: };</pre>
1.117     mike     2998:   </dd></dl><p>The <code><a href="#menus">menu</a></code> element represents a list of commands.</p><!-- v2 idea: <menu> should get an icon, like <command> --><p>The <dfn id="attr-menu-type" title="attr-menu-type"><code>type</code></dfn> attribute
1.1       mike     2999:   is an <a href="infrastructure.html#enumerated-attribute">enumerated attribute</a> indicating the kind of menu
                   3000:   being declared. The attribute has three states. The <code title="attr-menu-type-context">context</code> keyword maps to the
                   3001:   <dfn id="context-menu-state" title="context menu state">context menu</dfn> state, in which
                   3002:   the element is declaring a context menu. The <code title="attr-menu-type-toolbar">toolbar</code> keyword maps to the
                   3003:   <dfn id="tool-bar-state" title="tool bar state">tool bar</dfn> state, in which the
                   3004:   element is declaring a tool bar. The attribute may also be
                   3005:   omitted. The <i>missing value default</i> is the <dfn id="list-state" title="list
                   3006:   state">list</dfn> state, which indicates that the element is merely
                   3007:   a list of commands that is neither declaring a context menu nor
1.117     mike     3008:   defining a tool bar.</p><p>If a <code><a href="#menus">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#context-menu-state" title="context menu state">context menu</a> state, then the
1.1       mike     3009:   element <a href="the-xhtml-syntax.html#represents">represents</a> the commands of a context menu, and
                   3010:   the user can only interact with the commands if that context menu is
1.117     mike     3011:   activated.</p><p>If a <code><a href="#menus">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#tool-bar-state" title="tool bar state">tool bar</a> state, then the element
1.1       mike     3012:   <a href="the-xhtml-syntax.html#represents">represents</a> a list of active commands that the user can
1.117     mike     3013:   immediately interact with.</p><p>If a <code><a href="#menus">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#list-state" title="list state">list</a> state, then the element either
1.1       mike     3014:   <a href="the-xhtml-syntax.html#represents">represents</a> an unordered list of items (each represented
                   3015:   by an <code><a href="semantics.html#the-li-element">li</a></code> element), each of which represents a command
                   3016:   that the user can perform or activate, or, if the element has no
1.153     mike     3017:   <code><a href="semantics.html#the-li-element">li</a></code> element children, <a href="dom.html#flow-content">flow content</a>
1.117     mike     3018:   describing available commands.</p><p>The <dfn id="attr-menu-label" title="attr-menu-label"><code>label</code></dfn>
1.1       mike     3019:   attribute gives the label of the menu. It is used by user agents to
                   3020:   display nested menus in the UI. For example, a context menu
                   3021:   containing another menu would use the nested menu's <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute for the submenu's
1.117     mike     3022:   menu label.</p><div class="impl">
1.1       mike     3023: 
                   3024:   <p>The <dfn id="dom-menu-type" title="dom-menu-type"><code>type</code></dfn> and <dfn id="dom-menu-label" title="dom-menu-label"><code>label</code></dfn> DOM attributes must
                   3025:   <a href="infrastructure.html#reflect">reflect</a> the respective content attributes of the same
                   3026:   name.</p>
                   3027: 
1.148     mike     3028:   </div><h5 id="menus-intro"><span class="secno">4.11.3.1 </span>Introduction</h5><p><i>This section is non-normative.</i></p><p>The <code><a href="#menus">menu</a></code> element is used to define context menus and
                   3029:   tool bars.</p><p>For example, the following represents a toolbar with three menu
                   3030:   buttons on it, each of which has a dropdown menu with a series of
                   3031:   options:</p><pre>&lt;menu type="toolbar"&gt;
1.1       mike     3032:  &lt;li&gt;
                   3033:   &lt;menu label="File"&gt;
                   3034:    &lt;button type="button" onclick="fnew()"&gt;New...&lt;/button&gt;
                   3035:    &lt;button type="button" onclick="fopen()"&gt;Open...&lt;/button&gt;
                   3036:    &lt;button type="button" onclick="fsave()" id="save"&gt;Save&lt;/button&gt;
                   3037:    &lt;button type="button" onclick="fsaveas()"&gt;Save as...&lt;/button&gt;
                   3038:   &lt;/menu&gt;
                   3039:  &lt;/li&gt;
                   3040:  &lt;li&gt;
                   3041:   &lt;menu label="Edit"&gt;
                   3042:    &lt;button type="button" onclick="ecopy()"&gt;Copy&lt;/button&gt;
                   3043:    &lt;button type="button" onclick="ecut()"&gt;Cut&lt;/button&gt;
                   3044:    &lt;button type="button" onclick="epaste()"&gt;Paste&lt;/button&gt;
                   3045:   &lt;/menu&gt;
                   3046:  &lt;/li&gt;
                   3047:  &lt;li&gt;
                   3048:   &lt;menu label="Help"&gt;
                   3049:    &lt;li&gt;&lt;a href="help.html"&gt;Help&lt;/a&gt;&lt;/li&gt;
                   3050:    &lt;li&gt;&lt;a href="about.html"&gt;About&lt;/a&gt;&lt;/li&gt;
                   3051:   &lt;/menu&gt;
                   3052:  &lt;/li&gt;
1.148     mike     3053: &lt;/menu&gt;</pre><p>In a supporting user agent, this might look like this:</p><p><img alt="A toolbar with three buttons, labeled 'File', 'Edit', and 'Help'; where if you select the 'Edit' button you get a drop-down menu with three more options, 'Copy', 'Cut', and 'Paste'." src="images/sample-toolbar-1.png"></p><p>In a legacy user agent, the above would look like a bulleted list
                   3054:   with three items, the first of which has four buttons, the second of
                   3055:   which has three, and the third of which has two nested bullet points
                   3056:   with two items consisting of links.</p><hr><p>The following implements a similar toolbar, with a single button
                   3057:   whose values, when selected, redirect the user to Web sites.</p><pre>&lt;form action="redirect.cgi"&gt;
                   3058:  &lt;menu type="toolbar"&gt;
1.1       mike     3059:   &lt;label for="goto"&gt;Go to...&lt;/label&gt;
                   3060:   &lt;menu label="Go"&gt;
                   3061:    &lt;select id="goto"
                   3062:            onchange="if (this.options[this.selectedIndex].value)
                   3063:                      window.location = this.options[this.selectedIndex].value"&gt;
                   3064:     &lt;option value="" selected="selected"&gt; Select site: &lt;/option&gt;
                   3065:     &lt;option value="http://www.apple.com/"&gt; Apple &lt;/option&gt;
                   3066:     &lt;option value="http://www.mozilla.org/"&gt; Mozilla &lt;/option&gt;
                   3067:     &lt;option value="http://www.opera.com/"&gt; Opera &lt;/option&gt;
                   3068:    &lt;/select&gt;
                   3069:    &lt;span&gt;&lt;input type="submit" value="Go"&gt;&lt;/span&gt;
                   3070:   &lt;/menu&gt;
                   3071:  &lt;/menu&gt;
1.148     mike     3072: &lt;/form&gt;</pre><p>The behavior in supporting user agents is similar to the example
                   3073:   above, but here the legacy behaviour consists of a single
                   3074:   <code><a href="forms.html#the-select-element">select</a></code> element with a submit button. The submit button
                   3075:   doesn't appear in the toolbar, because it is not a direct child of
                   3076:   the <code><a href="#menus">menu</a></code> element or of its <code><a href="semantics.html#the-li-element">li</a></code>
                   3077:   children.</p><div class="impl">
1.1       mike     3078: 
1.131     mike     3079:   <h5 id="building-menus-and-tool-bars"><span class="secno">4.11.3.2 </span><dfn>Building menus and tool bars</dfn></h5>
1.1       mike     3080: 
                   3081:   <p>A menu (or tool bar) consists of a list of zero or more of the
                   3082:   following components:</p>
                   3083: 
                   3084:   <ul class="brief"><li><a href="#concept-command" title="concept-command">Commands</a>, which can be marked as default commands</li>
                   3085:    <li>Separators</li>
                   3086:    <li>Other menus (which allows the list to be nested)</li>
                   3087:   </ul><p>The list corresponding to a particular <code><a href="#menus">menu</a></code> element
                   3088:   is built by iterating over its child nodes. For each child node in
                   3089:   <a href="infrastructure.html#tree-order">tree order</a>, the required behavior depends on what the
                   3090:   node is, as follows:</p>
                   3091: 
                   3092:   <dl class="switch"><dt>An element that <a href="#concept-command" title="concept-command">defines a command</a></dt>
                   3093: 
                   3094:    <dd>Append the command to the menu, respecting its <a href="#concept-facet" title="concept-facet">facets</a><!-- we might need to be
                   3095:    explicit about what this means for each facet, if testing shows
                   3096:    this isn't well-implemented. e.g.: If there's an Icon facet for the
                   3097:    command, it should be <span title="fetch">fetched</span>, and then
                   3098:    that image should be associated with the command, such that each
                   3099:    command only has its image fetched once, to prevent changes to the
                   3100:    base URL from having effects after the image has been fetched
                   3101:    once. (no need to resolve the Icon facet, it's an absolute URL)
                   3102:    -->. <!--If the element is a <code>command</code> element with a
                   3103:    <code title="attr-command-default">default</code> attribute, mark
                   3104:    the command as being a default command.--></dd>
                   3105: 
                   3106: 
                   3107:    <dt>An <code><a href="semantics.html#the-hr-element">hr</a></code> element</dt>
                   3108:    <dt>An <code><a href="forms.html#the-option-element">option</a></code> element that has a <code title="attr-option-value"><a href="forms.html#attr-option-value">value</a></code> attribute set to the empty
                   3109:    string, and has a <code title="attr-option-disabled"><a href="forms.html#attr-option-disabled">disabled</a></code> attribute, and whose
                   3110:    <code>textContent</code> consists of a string of one or more
                   3111:    hyphens (U+002D HYPHEN-MINUS)</dt>
                   3112: 
                   3113:    <dd>Append a separator to the menu.</dd>
                   3114: 
                   3115: 
                   3116:    <dt>An <code><a href="semantics.html#the-li-element">li</a></code> element</dt>
                   3117:    <dt>A <code><a href="forms.html#the-label-element">label</a></code> element</dt>
                   3118: 
                   3119:    <dd>Iterate over the children of the element.</dd>
                   3120: 
                   3121: 
                   3122:    <dt>A <code><a href="#menus">menu</a></code> element with no <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
                   3123:    <dt>A <code><a href="forms.html#the-select-element">select</a></code> element</dt>
                   3124: 
                   3125:    <dd>Append a separator to the menu, then iterate over the children
                   3126:    of the <code><a href="#menus">menu</a></code> or <code><a href="forms.html#the-select-element">select</a></code> element, then
                   3127:    append another separator.</dd>
                   3128: 
                   3129:    <!-- v2: we might want to support <select> in <label> as giving a named submenu -->
                   3130: 
                   3131: 
                   3132:    <dt>A <code><a href="#menus">menu</a></code> element with a <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
                   3133:    <dt>An <code><a href="forms.html#the-optgroup-element">optgroup</a></code> element with a <code title="attr-menu-label"><a href="#attr-menu-label">label</a></code> attribute</dt>
                   3134: 
                   3135:    <dd>Append a submenu to the menu, using the value of the element's
                   3136:    <code title="">label</code> attribute as the label of the menu. The
                   3137:    submenu must be constructed by taking the element and creating a
                   3138:    new menu for it using the complete process described in this
                   3139:    section.</dd>
                   3140: 
                   3141: 
                   3142:    <dt>Any other node</dt>
                   3143: 
                   3144:    <dd><a href="infrastructure.html#ignore">Ignore</a> the node.</dd>
                   3145: 
                   3146:   </dl><p>Once all the nodes have been processed as described above, the
                   3147:   user agent must the post-process the menu as follows:</p>
                   3148: 
                   3149:   <ol><li>Any menu item with no label, or whose label is the empty string, must be removed.</li>
                   3150: 
                   3151:    <li>Any sequence of two or more separators in a row must be collapsed to a single separator.</li>
                   3152: 
                   3153:    <li>Any separator at the start or end of the menu must be removed.</li>
                   3154: 
1.131     mike     3155:   </ol></div><h5 id="context-menus"><span class="secno">4.11.3.3 </span><dfn>Context menus</dfn></h5><p>The <dfn id="attr-contextmenu" title="attr-contextmenu"><code>contextmenu</code></dfn>
1.1       mike     3156:   attribute gives the element's <a href="#context-menus" title="context menus">context
                   3157:   menu</a>. The value must be the ID of a <code><a href="#menus">menu</a></code> element
                   3158:   in the DOM. <span class="impl">If the node that would be obtained by
                   3159:   the invoking the <code>getElementById()</code> method using the
                   3160:   attribute's value as the only argument is null or not a
                   3161:   <code><a href="#menus">menu</a></code> element, then the element has no assigned context
                   3162:   menu. Otherwise, the element's assigned context menu is the element
1.117     mike     3163:   so identified.</span></p><div class="impl">
1.1       mike     3164: 
                   3165:   <p>When an element's context menu is requested (e.g. by the user
                   3166:   right-clicking the element, or pressing a context menu key), the UA
                   3167:   must <a href="browsers.html#fire-a-simple-event">fire a simple event</a> called <code title="event-contextmenu">contextmenu</code> that bubbles and is
                   3168:   cancelable at the element for which the menu was requested.</p>
                   3169: 
                   3170:   <p class="note">Typically, therefore, the firing of the <code title="event-contextmenu">contextmenu</code> event will be the
                   3171:   default action of a <code title="mouseup">mouseup</code> or <code title="event-keyup">keyup</code> event. The exact sequence of events
                   3172:   is UA-dependent, as it will vary based on platform conventions.</p>
                   3173: 
                   3174:   <p>The default action of the <code title="event-contextmenu">contextmenu</code> event depends on
                   3175:   whether the element or one of its ancestors has a context menu
                   3176:   assigned (using the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> attribute) or not. If
                   3177:   there is no context menu assigned, the default action must be for
                   3178:   the user agent to show its default context menu, if it has one.</p>
                   3179: 
                   3180:   <p>If the element or one of its ancestors <em>does</em> have a
                   3181:   context menu assigned, then the user agent must <a href="browsers.html#fire-a-simple-event">fire a simple
                   3182:   event</a> called <code title="event-show">show</code> at the
                   3183:   <code><a href="#menus">menu</a></code> element of the context menu of the nearest
                   3184:   ancestor (including the element itself) with one assigned.</p>
                   3185:   <!-- v2: include modifier key information -->
                   3186: 
                   3187:   <p>The default action of <em>this</em> event is that the user agent
                   3188:   must show a context menu <a href="#building-menus-and-tool-bars" title="building menus and tool
                   3189:   bars">built</a> from the <code><a href="#menus">menu</a></code> element.</p>
                   3190: 
                   3191:   <p>The user agent may also provide access to its default context
                   3192:   menu, if any, with the context menu shown. For example, it could
                   3193:   merge the menu items from the two menus together, or provide the
                   3194:   page's context menu as a submenu of the default menu.</p>
                   3195: 
                   3196:   <p>If the user dismisses the menu without making a selection,
                   3197:   nothing in particular happens.</p>
                   3198: 
                   3199:   <p>If the user selects a menu item that represents a <span title="concept-commands">command</span>, then the UA must invoke
                   3200:   that command's <a href="#command-facet-action" title="command-facet-Action">Action</a>.</p>
                   3201: 
                   3202:   <p>Context menus must not, while being shown, reflect changes in the
                   3203:   DOM; they are constructed as the default action of the <code title="event-show">show</code> event and must remain like that until
                   3204:   dismissed.</p>
                   3205: 
                   3206:   <p>User agents may provide means for bypassing the context menu
                   3207:   processing model, ensuring that the user can always access the UA's
                   3208:   default context menus. For example, the user agent could handle
                   3209:   right-clicks that have the Shift key depressed in such a way that it
                   3210:   does not fire the <code title="event-contextmenu">contextmenu</code>
                   3211:   event and instead always shows the default context menu.</p>
                   3212: 
                   3213:   <p>The <dfn id="dom-contextmenu" title="dom-contextMenu"><code>contextMenu</code></dfn>
                   3214:   attribute must <a href="infrastructure.html#reflect">reflect</a> the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> content attribute.</p>
                   3215: 
1.117     mike     3216:   </div><div class="impl">
1.1       mike     3217: 
1.131     mike     3218:   <h5 id="tool-bars"><span class="secno">4.11.3.4 </span><dfn>Tool bars</dfn></h5>
1.1       mike     3219: 
                   3220:   <p>When a <code><a href="#menus">menu</a></code> element has a <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute in the <a href="#tool-bar-state" title="tool bar state">tool bar</a> state, then the user agent
                   3221:   must <a href="#building-menus-and-tool-bars" title="building menus and tool bars">build</a> the
                   3222:   menu for that <code><a href="#menus">menu</a></code> element, and use the result in the
                   3223:   rendering.</p>
                   3224: 
                   3225:   <p>The user agent must reflect changes made to the
                   3226:   <code><a href="#menus">menu</a></code>'s DOM, by immediately <a href="#building-menus-and-tool-bars" title="building menus
                   3227:   and tool bars">rebuilding</a> the menu.</p>
                   3228: 
1.131     mike     3229:   </div><h4 id="commands"><span class="secno">4.11.4 </span>Commands</h4><p>A <dfn id="concept-command" title="concept-command">command</dfn> is the abstraction
1.51      mike     3230:   behind menu items, buttons, and links.<!--v2COMMAND: Once a command
                   3231:   is defined, other parts of the interface can refer to the same
                   3232:   command, allowing many access points to a single feature to share
1.117     mike     3233:   aspects such as the disabled state.--></p><p id="facets">Commands are defined to have the following
                   3234:   <dfn id="concept-facet" title="concept-facet">facets</dfn>:</p><dl><dt><dfn id="command-facet-type" title="command-facet-Type">Type</dfn></dt>
1.1       mike     3235: 
                   3236:    <dd>The kind of command: "command", meaning it is a normal command;
                   3237:    "radio", meaning that triggering the command will, amongst other
                   3238:    things, set the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked
                   3239:    State</a> to true (and probably uncheck some other commands); or
                   3240:    "checkbox", meaning that triggering the command will, amongst other
                   3241:    things, toggle the value of the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>.</dd>
                   3242: 
                   3243:    <dt><dfn id="command-facet-id" title="command-facet-ID">ID</dfn></dt>
                   3244: 
                   3245:    <dd>The name of the command, for referring to the command from the
                   3246:    markup or from script. If a command has no ID, it is an
                   3247:    <dfn id="anonymous-command">anonymous command</dfn>.</dd>
                   3248: 
                   3249:    <dt><dfn id="command-facet-label" title="command-facet-Label">Label</dfn></dt>
                   3250: 
                   3251:    <dd>The name of the command as seen by the user.</dd>
                   3252: 
                   3253:    <dt><dfn id="command-facet-hint" title="command-facet-Hint">Hint</dfn></dt>
                   3254: 
                   3255:    <dd>A helpful or descriptive string that can be shown to the
                   3256:    user.</dd>
                   3257: 
                   3258:    <dt><dfn id="command-facet-icon" title="command-facet-Icon">Icon</dfn></dt>
                   3259: 
                   3260:    <dd>An <a href="infrastructure.html#absolute-url">absolute URL</a> identifying a graphical image that
                   3261:    represents the action. A command might not have an Icon.</dd> <!--
                   3262:    changing base URLs might change the icon -->
                   3263: 
                   3264:    <dt><dfn id="command-facet-accesskey" title="command-facet-AccessKey">Access Key</dfn></dt>
                   3265: 
                   3266:    <dd>A key combination selected by the user agent that triggers the
                   3267:    command. A command might not have an Access Key.</dd>
                   3268: 
                   3269:    <dt><dfn id="command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</dfn></dt>
                   3270: 
                   3271:    <dd>Whether the command is hidden or not (basically, whether it
                   3272:    should be shown in menus).</dd>
                   3273: 
                   3274:    <dt><dfn id="command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</dfn></dt>
                   3275: 
                   3276:    <dd>Whether the command is relevant and can be triggered or not.</dd>
                   3277: 
                   3278:    <dt><dfn id="command-facet-checkedstate" title="command-facet-CheckedState">Checked State</dfn></dt>
                   3279: 
                   3280:    <dd>Whether the command is checked or not.</dd>
                   3281: 
                   3282:    <dt><dfn id="command-facet-action" title="command-facet-Action">Action</dfn></dt>
                   3283: 
                   3284:    <dd>The actual effect that triggering the command will have. This
                   3285:    could be a scripted event handler, a <a href="infrastructure.html#url">URL</a> to which to
                   3286:    <a href="history.html#navigate">navigate</a>, or a form submission.</dd>
                   3287: 
                   3288: <!-- v2COMMAND
                   3289:    <dt><dfn title="command-facet-Triggers">Triggers</dfn></dt>
                   3290: 
                   3291:    <dd>The list of elements that can trigger the command. The element
                   3292:    defining a command is always in the list of elements that can
                   3293:    trigger the command. For anonymous commands, only the element
                   3294:    defining the command is on the list, since other elements have no
                   3295:    way to refer to it.</dd>
                   3296: -->
                   3297: 
                   3298:   </dl><p>These facets are exposed on elements using the <dfn id="command-api">command
1.117     mike     3299:   API</dfn>:</p><dl class="domintro"><dt><var title="">element</var> . <code title="dom-command-ro-commandType"><a href="#dom-command-ro-commandtype">commandType</a></code></dt>
1.1       mike     3300: 
                   3301:    <dd>
                   3302: 
                   3303:     <p>Exposes the <a href="#command-facet-type" title="command-facet-Type">Type</a> facet of the command.</p>
                   3304: 
                   3305:    </dd>
                   3306: 
                   3307:    <dt><var title="">element</var> . <code title="dom-id"><a href="dom.html#dom-id">id</a></code></dt>
                   3308: 
                   3309:    <dd>
                   3310: 
                   3311:     <p>Exposes the <a href="#command-facet-id" title="command-facet-ID">ID</a> facet of the command.</p>
                   3312: 
                   3313:    </dd>
                   3314: 
                   3315:    <dt><var title="">element</var> . <code title="dom-command-ro-label"><a href="#dom-command-ro-label">label</a></code></dt>
                   3316: 
                   3317:    <dd>
                   3318: 
                   3319:     <p>Exposes the <a href="#command-facet-label" title="command-facet-Label">Label</a> facet of the command.</p>
                   3320: 
                   3321:    </dd>
                   3322: 
                   3323:    <dt><var title="">element</var> . <code title="dom-title"><a href="dom.html#dom-title">title</a></code></dt>
                   3324: 
                   3325:    <dd>
                   3326: 
                   3327:     <p>Exposes the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> facet of the command.</p>
                   3328: 
                   3329:    </dd>
                   3330: 
                   3331:    <dt><var title="">element</var> . <code title="dom-command-ro-icon"><a href="#dom-command-ro-icon">icon</a></code></dt>
                   3332: 
                   3333:    <dd>
                   3334: 
                   3335:     <p>Exposes the <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> facet of the command.</p>
                   3336: 
                   3337:    </dd>
                   3338: 
                   3339:    <dt><var title="">element</var> . <code title="dom-accessKeyLabel"><a href="editing.html#dom-accesskeylabel">accessKeyLabel</a></code></dt>
                   3340: 
                   3341:    <dd>
                   3342: 
                   3343:     <p>Exposes the <a href="#command-facet-accesskey" title="command-facet-AccessKey">Access Key</a> facet of the command.</p>
                   3344: 
                   3345:    </dd>
                   3346: 
                   3347:    <dt><var title="">element</var> . <code title="dom-hidden"><a href="editing.html#dom-hidden">hidden</a></code></dt>
                   3348: 
                   3349:    <dd>
                   3350: 
                   3351:     <p>Exposes the <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a> facet of the command.</p>
                   3352: 
                   3353:    </dd>
                   3354: 
                   3355:    <dt><var title="">element</var> . <code title="dom-command-ro-disabled"><a href="#dom-command-ro-disabled">disabled</a></code></dt>
                   3356: 
                   3357:    <dd>
                   3358: 
                   3359:     <p>Exposes the <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a> facet of the command.</p>
                   3360: 
                   3361:    </dd>
                   3362: 
                   3363:    <dt><var title="">element</var> . <code title="dom-command-ro-checked"><a href="#dom-command-ro-checked">checked</a></code></dt>
                   3364: 
                   3365:    <dd>
                   3366: 
                   3367:     <p>Exposes the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a> facet of the command.</p>
                   3368: 
                   3369:    </dd>
                   3370: 
                   3371:    <dt><var title="">element</var> . <code title="dom-click"><a href="editing.html#dom-click">click</a></code>()</dt>
                   3372: 
                   3373:    <dd>
                   3374: 
                   3375:     <p>Triggers the <a href="#command-facet-action" title="command-facet-Action">Action</a> of the command.</p>
                   3376: 
                   3377:    </dd>
                   3378: 
                   3379: <!--v2COMMAND
                   3380:    <dt><var title="">element</var> . <code title="dom-command-ro-triggers">triggers</code></dt>
                   3381: 
                   3382:    <dd>
                   3383: 
                   3384:     <p>Exposes the <span title="command-facet-Triggers">Triggers</span> facet of the command.</p>
                   3385: 
                   3386:    </dd>
                   3387: -->
                   3388: 
                   3389:   </dl><div class="impl">
                   3390: 
                   3391:   <p>The <dfn id="dom-command-ro-commandtype" title="dom-command-ro-commandType"><code>commandType</code></dfn>
                   3392:   attribute must return a string whose value is either "<code title="">command</code>", "<code title="">radio</code>", or "<code title="">checked</code>", depending on whether the <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command defined by the
                   3393:   element is "command", "radio", or "checked" respectively. If the
                   3394:   element does not define a command, it must return null.</p>
                   3395: 
                   3396:   <p>The <dfn id="dom-command-ro-label" title="dom-command-ro-label"><code>label</code></dfn>
                   3397:   attribute must return the command's <a href="#command-facet-label" title="command-facet-Label">Label</a>, or null if the element
                   3398:   does not define a command or does not specify a <a href="#command-facet-label" title="command-facet-Label">Label</a>. This attribute will be
                   3399:   shadowed by the <code title="">label</code> DOM attribute on
                   3400:   <code><a href="forms.html#the-option-element">option</a></code> and <code><a href="#the-command">command</a></code> elements.</p>
                   3401: 
                   3402:   <p>The <dfn id="dom-command-ro-icon" title="dom-command-ro-icon"><code>icon</code></dfn>
                   3403:   attribute must return the <a href="infrastructure.html#absolute-url">absolute URL</a> of the command's
                   3404:   <a href="#command-facet-icon" title="command-facet-Icon">Icon</a>. If the element does
                   3405:   not specify an icon, or if the element does not define a command,
                   3406:   then the attribute must return null. This attribute will be shadowed
                   3407:   by the <code title="dom-command-icon"><a href="#dom-command-icon">icon</a></code> DOM attribute on
                   3408:   <code><a href="#the-command">command</a></code> elements.</p>
                   3409: 
                   3410:   <p>The <dfn id="dom-command-ro-disabled" title="dom-command-ro-disabled"><code>disabled</code></dfn>
                   3411:   attribute must return true if the command's <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a> is that
                   3412:   the command is disabled, and false if the command is not
                   3413:   disabled. This attribute is not affected by the command's <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>. If the
                   3414:   element does not define a command, the attribute must return
                   3415:   false. This attribute will be shadowed by the <code title="">disabled</code> attribute on <code><a href="forms.html#the-button-element">button</a></code>,
                   3416:   <code><a href="forms.html#the-input-element">input</a></code>, <code><a href="forms.html#the-option-element">option</a></code>, and <code><a href="#the-command">command</a></code>
                   3417:   elements.</p>
                   3418: 
                   3419:   <p>The <dfn id="dom-command-ro-checked" title="dom-command-ro-checked"><code>checked</code></dfn> attribute
                   3420:   must return true if the command's <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a> is that the
                   3421:   command is checked, and false if it is that the command is not
                   3422:   checked. If the element does not define a command, the attribute
                   3423:   must return false. This attribute will be shadowed by the <code title="">checked</code> attribute on <code><a href="forms.html#the-input-element">input</a></code> and
                   3424:   <code><a href="#the-command">command</a></code> elements.</p>
                   3425: 
                   3426: <!--v2COMMAND
                   3427:   <p>The <dfn
                   3428:   title="dom-command-ro-triggers"><code>triggers</code></dfn>
                   3429:   attribute must return a list containing the elements that can
                   3430:   trigger the command (the command's <span
                   3431:   title="command-facet-Triggers">Triggers</span>). The list must be
                   3432:   <span>live</span>. While the element does not define a command, the
                   3433:   list must be empty.</p>
                   3434: -->
                   3435: 
                   3436:   <p class="note">The <a href="#command-facet-id" title="command-facet-ID">ID</a> facet
                   3437:   is exposed by the the <code title="dom-id"><a href="dom.html#dom-id">id</a></code> DOM attribute,
                   3438:   the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> facet is exposed by
                   3439:   the <code title="dom-title"><a href="dom.html#dom-title">title</a></code> DOM attribute, the <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> facet is exposed by
                   3440:   the <code title="dom-accessKeyLabel"><a href="editing.html#dom-accesskeylabel">accessKeyLabel</a></code> DOM
                   3441:   attribute, and the <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden
                   3442:   State</a> facet is exposed by the <code title="dom-hidden"><a href="editing.html#dom-hidden">hidden</a></code> DOM attribute.</p>
                   3443: 
1.117     mike     3444:   </div><hr><dl class="domintro"><dt><var title="">document</var> . <code title="dom-document-commands"><a href="#dom-document-commands">commands</a></code></dt>
1.1       mike     3445:    <dd>
1.153     mike     3446:     <p>Returns an <code><a href="infrastructure.html#htmlcollection">HTMLCollection</a></code> of the elements in the
1.1       mike     3447:     <code>Document</code> that define commands and have IDs.</p>
                   3448:    </dd>
                   3449: 
                   3450:   </dl><div class="impl">
                   3451: 
                   3452:   <p>The <dfn id="dom-document-commands" title="dom-document-commands"><code>commands</code></dfn> attribute
                   3453:   of the document's <code><a href="dom.html#htmldocument">HTMLDocument</a></code> interface must return an
1.153     mike     3454:   <code><a href="infrastructure.html#htmlcollection">HTMLCollection</a></code> rooted at the <code>Document</code>
1.1       mike     3455:   node, whose filter matches only elements that <a href="#concept-command" title="concept-command">define commands</a> and have <a href="#command-facet-id" title="command-facet-ID">IDs</a>.</p>
                   3456: 
1.117     mike     3457:   </div><hr><p>User agents may expose the <a href="#concept-command" title="concept-command">commands</a> whose <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a> facet is false
1.1       mike     3458:   (visible), e.g. in the user agent's menu bar. User agents are
                   3459:   encouraged to do this especially for commands that have <a href="#command-facet-accesskey" title="command-facet-AccessKey">Access Keys</a>, as a way to
1.117     mike     3460:   advertise those keys to the user.</p><div class="impl">
1.1       mike     3461: 
1.131     mike     3462:   <h5 id="using-the-a-element-to-define-a-command"><span class="secno">4.11.4.1 </span><dfn title="a-command">Using the <code>a</code> element to define a command</dfn></h5>
1.1       mike     3463: 
                   3464:   <p>An <code><a href="text-level-semantics.html#the-a-element">a</a></code> element with an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute <a href="#concept-command" title="concept-command">defines a command</a>.</p>
                   3465: 
                   3466:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3467:   is "command".</p>
                   3468: 
                   3469:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3470:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3471:   element, if the attribute is present and not empty. Otherwise the
                   3472:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3473: 
                   3474:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3475:   is the string given by the element's <code>textContent</code> DOM
                   3476:   attribute.</p>
                   3477: 
                   3478:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3479:   is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
                   3480:   of the element. If the attribute is not present, the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> is the empty string.</p>
                   3481: 
                   3482:   <p>The <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> of the command
                   3483:   is the <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from <a href="infrastructure.html#resolve-a-url" title="resolve
1.153     mike     3484:   a url">resolving</a> the value of the <code title="attr-img-src"><a href="text-level-semantics.html#attr-img-src">src</a></code> attribute of the first
                   3485:   <code><a href="text-level-semantics.html#the-img-element">img</a></code> element descendant of the element, relative to that
1.1       mike     3486:   element, if there is such an element and resolving its attribute is
                   3487:   successful. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
                   3488: 
                   3489:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3490:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
                   3491:   any.</p>
                   3492: 
                   3493:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
                   3494:   of the command is true (hidden) if the element has a <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> attribute, and false
                   3495:   otherwise.</p>
                   3496: 
                   3497:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3498:   State</a> facet of the command is always false. (The command is
                   3499:   always enabled.)</p>
                   3500: 
                   3501:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3502:   of the command is always false. (The command is never checked.)</p>
                   3503: 
                   3504:   <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
                   3505:   command is to <a href="browsers.html#fire-a-click-event" title="fire a click event">fire a <code title="event-click">click</code> event</a> at the element.</p>
                   3506: 
                   3507: 
1.131     mike     3508:   <h5 id="using-the-button-element-to-define-a-command"><span class="secno">4.11.4.2 </span><dfn title="button-command">Using the <code>button</code> element to define a command</dfn></h5>
1.1       mike     3509: 
                   3510:   <p>A <code><a href="forms.html#the-button-element">button</a></code> element always <a href="#concept-command" title="concept-command">defines a command</a>.</p>
                   3511: 
                   3512:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a>, <a href="#command-facet-id" title="command-facet-ID">ID</a>, <a href="#command-facet-label" title="command-facet-Label">Label</a>, <a href="#command-facet-hint" title="command-facet-Hint">Hint</a>, <a href="#command-facet-icon" title="command-facet-Icon">Icon</a>, <a href="#command-facet-accesskey" title="command-facet-AccessKey">Access Key</a>, <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>, <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>, and <a href="#command-facet-action" title="command-facet-Action">Action</a> facets of the command are
                   3513:   determined <a href="#using-the-a-element-to-define-a-command" title="a-command">as for <code>a</code>
                   3514:   elements</a> (see the previous section).</p>
                   3515: 
                   3516:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3517:   State</a> of the command mirrors the <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a> state of the button.</p>
                   3518: 
                   3519: 
1.131     mike     3520:   <h5 id="using-the-input-element-to-define-a-command"><span class="secno">4.11.4.3 </span><dfn title="input-command">Using the <code>input</code> element to define a command</dfn></h5>
1.1       mike     3521: 
1.39      mike     3522:   <p>An <code><a href="forms.html#the-input-element">input</a></code> element whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in one of the <a href="forms.html#submit-button-state" title="attr-input-type-submit">Submit Button</a>, <a href="forms.html#reset-button-state" title="attr-input-type-reset">Reset Button</a>, <a href="forms.html#image-button-state" title="attr-input-type-image">Image Button</a>, <a href="forms.html#button-state" title="attr-input-type-button">Button</a>, <a href="forms.html#radio-button-state" title="attr-input-type-radio">Radio Button</a>, or <a href="forms.html#checkbox-state" title="attr-input-type-checkbox">Checkbox</a> states <a href="#concept-command" title="concept-command">defines a command</a>.</p>
1.1       mike     3523: 
                   3524:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3525:   is "radio" if the <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code>
                   3526:   attribute is in the <code title="attr-input-type-radio"><a href="forms.html#radio-button-state">Radio
                   3527:   Button</a></code> state, "checkbox" if the <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <code title="attr-input-type-checkbox"><a href="forms.html#checkbox-state">Checkbox</a></code> state, and
                   3528:   "command" otherwise.</p>
                   3529: 
                   3530:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3531:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3532:   element, if the attribute is present and not empty. Otherwise the
                   3533:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3534: 
                   3535:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3536:   depends on the Type of the command:</p>
                   3537: 
                   3538:   <p>If the <a href="#command-facet-type" title="command-facet-Type">Type</a> is "command",
                   3539:   then it is the string given by the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code> attribute, if any, and a
                   3540:   UA-dependent, locale-dependent value that the UA uses to label the
                   3541:   button itself if the attribute is absent.</p>
                   3542: 
                   3543:   <p>Otherwise, the <a href="#command-facet-type" title="command-facet-Type">Type</a> is
                   3544:   "radio" or "checkbox". If the element is a <a href="forms.html#labeled-control">labeled
                   3545:   control</a>, the <code>textContent</code> of the first
                   3546:   <code><a href="forms.html#the-label-element">label</a></code> element in <a href="infrastructure.html#tree-order">tree order</a> whose
                   3547:   <a href="forms.html#labeled-control">labeled control</a> is the element in question is the <a href="#command-facet-label" title="command-facet-Label">Label</a> (in DOM terms, this is the
                   3548:   string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise,
                   3549:   the value of the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code>
                   3550:   attribute, if present, is the <a href="#command-facet-label" title="command-facet-Label">Label</a>. Otherwise, the <a href="#command-facet-label" title="command-facet-Label">Label</a> is the empty string.</p>
                   3551: 
                   3552:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3553:   is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
                   3554:   of the <code><a href="forms.html#the-input-element">input</a></code> element. If the attribute is not present, the
                   3555:   <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> is the empty
                   3556:   string.</p>
                   3557: 
1.39      mike     3558:   <p>If the element's <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code>
                   3559:   attribute is in the <a href="forms.html#image-button-state" title="attr-input-type-image">Image
1.153     mike     3560:   Button</a> state, and the element has a <code title="attr-img-src"><a href="text-level-semantics.html#attr-img-src">src</a></code> attribute, and that attribute's
1.39      mike     3561:   value can be successfully <a href="infrastructure.html#resolve-a-url" title="resolve a
                   3562:   url">resolved</a> relative to the element, then the <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> of the command is the
                   3563:   <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from resolving that attribute
                   3564:   that way. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
1.1       mike     3565: 
                   3566:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3567:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
                   3568:   any.</p>
                   3569: 
                   3570:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
                   3571:   of the command is true (hidden) if the element has a <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> attribute, and false
                   3572:   otherwise.</p>
                   3573: 
                   3574:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3575:   State</a> of the command mirrors the <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a> state of the
                   3576:   control.</p>
                   3577: 
                   3578:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3579:   of the command is true if the command is of <a href="#command-facet-type" title="command-facet-Type">Type</a> "radio" or "checkbox" and the
                   3580:   element is <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checked</a>
                   3581:   attribute, and false otherwise.</p>
                   3582: 
                   3583:   <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.153     mike     3584:   command, if the element has a defined <a href="embedded-content-0.html#activation-behavior">activation
                   3585:   behavior</a>, is to <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation
1.1       mike     3586:   steps</a> on the element. Otherwise, it is just to <a href="browsers.html#fire-a-click-event">fire a
                   3587:   <code title="event-click">click</code> event</a> at the
                   3588:   element.</p>
                   3589: 
                   3590: 
1.131     mike     3591:   <h5 id="using-the-option-element-to-define-a-command"><span class="secno">4.11.4.4 </span><dfn title="option-command">Using the <code>option</code> element to define a command</dfn></h5>
1.1       mike     3592: 
                   3593:   <p>An <code><a href="forms.html#the-option-element">option</a></code> element with an ancestor
                   3594:   <code><a href="forms.html#the-select-element">select</a></code> element and either no <code title="attr-option-value"><a href="forms.html#attr-option-value">value</a></code> attribute or a <code title="attr-option-value"><a href="forms.html#attr-option-value">value</a></code> attribute that is not the
                   3595:   empty string <a href="#concept-command" title="concept-command">defines a
                   3596:   command</a>.</p>
                   3597: 
                   3598:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3599:   is "radio" if the <code><a href="forms.html#the-option-element">option</a></code>'s nearest ancestor
                   3600:   <code><a href="forms.html#the-select-element">select</a></code> element has no <code title="attr-select-multiple"><a href="forms.html#attr-select-multiple">multiple</a></code> attribute, and
                   3601:   "checkbox" if it does.</p>
                   3602: 
                   3603:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3604:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3605:   element, if the attribute is present and not empty. Otherwise the
                   3606:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3607: 
                   3608:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3609:   is the value of the <code><a href="forms.html#the-option-element">option</a></code> element's <code title="attr-option-label"><a href="forms.html#attr-option-label">label</a></code> attribute, if there is one,
                   3610:   or the value of the <code><a href="forms.html#the-option-element">option</a></code> element's
                   3611:   <code>textContent</code> DOM attribute if there isn't.</p>
                   3612: 
                   3613:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3614:   is the string given by the element's <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute, if any, and the empty
                   3615:   string if the attribute is absent.</p>
                   3616: 
                   3617:   <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
                   3618:   command.</p>
                   3619: 
                   3620:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3621:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
                   3622:   any.</p>
                   3623: 
                   3624:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
                   3625:   of the command is true (hidden) if the element has a <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> attribute, and false
                   3626:   otherwise.</p>
                   3627: 
                   3628:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3629:   State</a> of the command is true (disabled) if the element is
                   3630:   <a href="forms.html#concept-option-disabled" title="concept-option-disabled">disabled</a> or if its
                   3631:   nearest ancestor <code><a href="forms.html#the-select-element">select</a></code> element is <a href="forms.html#concept-option-disabled" title="concept-option-disabled">disabled</a>, and false
                   3632:   otherwise.</p>
                   3633: 
                   3634:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3635:   of the command is true (checked) if the element's <a href="forms.html#concept-option-selectedness" title="concept-option-selectedness">selectedness</a> is true, and
                   3636:   false otherwise.</p>
                   3637: 
                   3638:   <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
                   3639:   command depends on its <a href="#command-facet-type" title="command-facet-Type">Type</a>. If the command is of <a href="#command-facet-type" title="command-facet-Type">Type</a> "radio" then it must <a href="forms.html#concept-select-pick" title="concept-select-pick">pick</a> the <code><a href="forms.html#the-option-element">option</a></code>
                   3640:   element. Otherwise, it must <a href="forms.html#concept-select-toggle" title="concept-select-toggle">toggle</a> the <code><a href="forms.html#the-option-element">option</a></code>
                   3641:   element.</p>
                   3642: 
                   3643: 
1.131     mike     3644:   <h5 id="using-the-command-element-to-define-a-command"><span class="secno">4.11.4.5 </span>Using the <dfn title="command-element"><code>command</code></dfn> element to define
1.1       mike     3645:   a command</h5>
                   3646: 
                   3647:   <p>A <code><a href="#the-command">command</a></code> element <a href="#concept-command" title="concept-command">defines a command</a>.</p>
                   3648: 
                   3649:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3650:   is "radio" if the <code><a href="#the-command">command</a></code>'s <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
                   3651:   "<code>radio</code>", "checkbox" if the attribute's value is
                   3652:   "<code>checkbox</code>", and "command" otherwise.</p>
                   3653: 
                   3654:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3655:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3656:   element, if the attribute is present and not empty. Otherwise the
                   3657:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3658: 
                   3659:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3660:   is the value of the element's <code title="attr-command-label"><a href="#attr-command-label">label</a></code> attribute, if there is one,
                   3661:   or the empty string if it doesn't.</p>
                   3662: 
                   3663:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3664:   is the string given by the element's <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute, if any, and the
                   3665:   empty string if the attribute is absent.</p>
                   3666: 
                   3667:   <p>The <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command
                   3668:   is the <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from <a href="infrastructure.html#resolve-a-url" title="resolve
                   3669:   a url">resolving</a> the value of the element's <code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code> attribute, relative to the
                   3670:   element, if it has such an attribute and resolving it is
                   3671:   successful. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
                   3672: 
                   3673:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3674:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
                   3675:   any.</p>
                   3676: 
                   3677:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
                   3678:   of the command is true (hidden) if the element has a <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> attribute, and false
                   3679:   otherwise.</p>
                   3680: 
                   3681:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3682:   State</a> of the command is true (disabled) if the element has a
                   3683:   <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> attribute, and
                   3684:   false otherwise.</p>
                   3685: 
                   3686:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3687:   of the command is true (checked) if the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, and false
                   3688:   otherwise.</p>
                   3689: 
                   3690:   <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.153     mike     3691:   command, if the element has a defined <a href="embedded-content-0.html#activation-behavior">activation
                   3692:   behavior</a>, is to <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation
1.1       mike     3693:   steps</a> on the element. Otherwise, it is just to <a href="browsers.html#fire-a-click-event">fire a
                   3694:   <code title="event-click">click</code> event</a> at the
                   3695:   element.</p>
                   3696: 
                   3697: 
                   3698: 
                   3699: 
                   3700: 
1.131     mike     3701:   <h5 id="using-the-accesskey-attribute-on-a-label-element-to-define-a-command"><span class="secno">4.11.4.6 </span><dfn title="label-command">Using the <code title="attr-accesskey">accesskey</code> attribute on a <code>label</code> element to define a command</dfn></h5>
1.1       mike     3702: 
                   3703:   <p>A <code><a href="forms.html#the-label-element">label</a></code> element that has an <a href="editing.html#assigned-access-key">assigned access
                   3704:   key</a> and a <a href="forms.html#labeled-control">labeled control</a> and whose
                   3705:   <a href="forms.html#labeled-control">labeled control</a> <a href="#concept-command" title="concept-command">defines a
                   3706:   command</a>, itself <a href="#concept-command" title="concept-command">defines a
                   3707:   command</a>.</p>
                   3708: 
                   3709:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3710:   is "command".</p>
                   3711: 
                   3712:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3713:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3714:   element, if the attribute is present and not empty. Otherwise the
                   3715:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3716: 
                   3717:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3718:   is the string given by the element's <code>textContent</code> DOM
                   3719:   attribute.</p>
                   3720: 
                   3721:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3722:   is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
                   3723:   of the element.</p>
                   3724: 
                   3725:   <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
                   3726:   command.</p>
                   3727: 
                   3728:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3729:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
                   3730: 
                   3731:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>,
                   3732:   <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a>, and
                   3733:   <a href="#command-facet-action" title="command-facet-Action">Action</a> facets of the
                   3734:   command are the same as the respective facets of the element's
                   3735:   <a href="forms.html#labeled-control">labeled control</a>.</p>
                   3736: 
                   3737:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3738:   of the command is always false. (The command is never checked.)</p>
                   3739: 
                   3740: 
                   3741: 
1.131     mike     3742:   <h5 id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command"><span class="secno">4.11.4.7 </span><dfn title="legend-command">Using the <code title="attr-accesskey">accesskey</code> attribute on a <code>legend</code> element to define a command</dfn></h5>
1.1       mike     3743: 
                   3744:   <p>A <code><a href="#the-legend-element">legend</a></code> element that has an <a href="editing.html#assigned-access-key">assigned access
                   3745:   key</a> and is a child of a <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element that
                   3746:   has a descendant that is not a descendant of the <code><a href="#the-legend-element">legend</a></code>
                   3747:   element and is neither a <code><a href="forms.html#the-label-element">label</a></code> element nor a
                   3748:   <code><a href="#the-legend-element">legend</a></code> element but that <a href="#concept-command" title="concept-command">defines a command</a>, itself <a href="#concept-command" title="concept-command">defines a command</a>.</p>
                   3749: 
                   3750:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3751:   is "command".</p>
                   3752: 
                   3753:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3754:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3755:   element, if the attribute is present and not empty. Otherwise the
                   3756:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3757: 
                   3758:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3759:   is the string given by the element's <code>textContent</code> DOM
                   3760:   attribute.</p>
                   3761: 
                   3762:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3763:   is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
                   3764:   of the element.</p>
                   3765: 
                   3766:   <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
                   3767:   command.</p>
                   3768: 
                   3769:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3770:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
                   3771: 
                   3772:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>,
                   3773:   <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a>, and
                   3774:   <a href="#command-facet-action" title="command-facet-Action">Action</a> facets of the
                   3775:   command are the same as the respective facets of the first element
                   3776:   in <a href="infrastructure.html#tree-order">tree order</a> that is a descendant of the parent of the
                   3777:   <code><a href="#the-legend-element">legend</a></code> element that <a href="#concept-command" title="concept-command">defines a command</a> but is not a
                   3778:   descendant of the <code><a href="#the-legend-element">legend</a></code> element and is neither a
                   3779:   <code><a href="forms.html#the-label-element">label</a></code> nor a <code><a href="#the-legend-element">legend</a></code> element.</p>
                   3780: 
                   3781:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3782:   of the command is always false. (The command is never checked.)</p>
                   3783: 
                   3784: 
                   3785: 
1.131     mike     3786:   <h5 id="using-the-accesskey-attribute-to-define-a-command-on-other-elements"><span class="secno">4.11.4.8 </span><dfn title="accesskey-command">Using the <code title="attr-accesskey">accesskey</code> attribute to define a command on other elements</dfn></h5>
1.1       mike     3787: 
1.28      mike     3788:   <p>An element that has an <a href="editing.html#assigned-access-key">assigned access key</a> <a href="#concept-command" title="concept-command">defines a command</a>.</p>
                   3789: 
                   3790:   <p>If one of the other sections that define elements that <a href="#concept-command" title="concept-command">define commands</a> define that this
                   3791:   element <a href="#concept-command" title="concept-command">defines a command</a>, then
                   3792:   that section applies to this element, and this section does
                   3793:   not. Otherwise, this section applies to that element.</p>
1.1       mike     3794: 
                   3795:   <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
                   3796:   is "command".</p>
                   3797: 
                   3798:   <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
                   3799:   the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
                   3800:   element, if the attribute is present and not empty. Otherwise the
                   3801:   command is an <a href="#anonymous-command">anonymous command</a>.</p>
                   3802: 
                   3803:   <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
                   3804:   depends on the element. If the element is a <a href="forms.html#labeled-control">labeled
                   3805:   control</a>, the <code>textContent</code> of the first
                   3806:   <code><a href="forms.html#the-label-element">label</a></code> element in <a href="infrastructure.html#tree-order">tree order</a> whose
                   3807:   <a href="forms.html#labeled-control">labeled control</a> is the element in question is the <a href="#command-facet-label" title="command-facet-Label">Label</a> (in DOM terms, this is the
                   3808:   string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise, the
                   3809:   <a href="#command-facet-label" title="command-facet-Label">Label</a> is the
                   3810:   <code>textContent</code> of the element itself.</p>
                   3811: 
                   3812:   <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
                   3813:   is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
                   3814:   of the element. If the attribute is not present, the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> is the empty string.</p>
                   3815: 
                   3816:   <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
                   3817:   command.</p>
                   3818: 
                   3819:   <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
                   3820:   command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
                   3821: 
                   3822:   <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
                   3823:   of the command is true (hidden) if the element has a <code title="attr-hidden"><a href="editing.html#the-hidden-attribute">hidden</a></code> attribute, and false
                   3824:   otherwise.</p>
                   3825: 
                   3826:   <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
                   3827:   State</a> facet of the command is always false. (The command is
                   3828:   always enabled.)</p>
                   3829: 
                   3830:   <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
                   3831:   of the command is always false. (The command is never checked.)</p>
                   3832: 
                   3833:   <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.153     mike     3834:   command, if the element has a defined <a href="embedded-content-0.html#activation-behavior">activation
                   3835:   behavior</a>, is to <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation
1.28      mike     3836:   steps</a> on the element. Otherwise, if the element is
                   3837:   <a href="editing.html#focusable">focusable</a>, the <a href="#command-facet-action" title="command-facet-Action">Action</a> of the command is to run
                   3838:   the <a href="editing.html#focusing-steps">focusing steps</a> for the element and then to
                   3839:   <a href="browsers.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at
                   3840:   the element. Otherwise, <a href="#command-facet-action" title="command-facet-Action">Action</a> of the command is just to
                   3841:   <a href="browsers.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at
                   3842:   the element.</p>
1.1       mike     3843: 
1.153     mike     3844:   </div><h3 id="miscellaneous-elements"><span class="secno">4.12 </span>Miscellaneous elements</h3><h4 id="the-legend-element"><span class="secno">4.12.1 </span>The <dfn><code>legend</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
1.1       mike     3845:    <dd>None.</dd>
                   3846:    <dt>Contexts in which this element may be used:</dt>
                   3847:    <dd>As the first child of a <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element.</dd>
                   3848:    <dd>As the first child of a <code><a href="#the-details-element">details</a></code> element.</dd>
1.153     mike     3849:    <dd>As the first or last child of a <code><a href="text-level-semantics.html#the-figure-element">figure</a></code> element, if there are no other <code><a href="#the-legend-element">legend</a></code> element children of that element.</dd>
1.1       mike     3850:    <dt>Content model:</dt>
1.153     mike     3851:    <dd>When the parent node is a <code><a href="text-level-semantics.html#the-figure-element">figure</a></code> element: <a href="dom.html#flow-content">flow content</a>, but with no descendant <code><a href="text-level-semantics.html#the-figure-element">figure</a></code> elements.</dd>
                   3852:    <dd>Otherwise: <a href="dom.html#phrasing-content">phrasing content</a>.</dd>
1.1       mike     3853:    <dt>Content attributes:</dt>
                   3854:    <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
                   3855:    <dt>DOM interface:</dt>
                   3856:    <dd>
                   3857:     <pre class="idl">interface <dfn id="htmllegendelement">HTMLLegendElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
                   3858:   readonly attribute <a href="forms.html#htmlformelement">HTMLFormElement</a> <a href="#dom-legend-form" title="dom-legend-form">form</a>;
                   3859: };</pre>
                   3860:    </dd>
                   3861:   </dl><p>The <code><a href="#the-legend-element">legend</a></code> element <a href="the-xhtml-syntax.html#represents">represents</a> a title
                   3862:   or explanatory caption for the rest of the contents of the
1.117     mike     3863:   <code><a href="#the-legend-element">legend</a></code> element's parent element.</p><dl class="domintro"><dt><var title="">legend</var> . <code title="dom-legend-form"><a href="#dom-legend-form">form</a></code></dt>
1.1       mike     3864: 
                   3865:    <dd>
                   3866: 
                   3867:     <p>Returns the element's <code><a href="forms.html#the-form-element">form</a></code> element, if any, or
                   3868:     null otherwise.</p>
                   3869: 
                   3870:    </dd>
                   3871: 
                   3872:   </dl><div class="impl">
                   3873: 
                   3874:   <p>The <dfn id="dom-legend-form" title="dom-legend-form"><code>form</code></dfn> DOM
                   3875:   attribute's behavior depends on whether the <code><a href="#the-legend-element">legend</a></code>
                   3876:   element is in a <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element or not. If the
                   3877:   <code><a href="#the-legend-element">legend</a></code> has a <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element as its
                   3878:   parent, then the <code title="dom-legend-form"><a href="#dom-legend-form">form</a></code> DOM
                   3879:   attribute must return the same value as the <code title="dom-fae-form"><a href="forms.html#dom-fae-form">form</a></code> DOM attribute on that
                   3880:   <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element. Otherwise, it must return null.</p>
                   3881: 
1.153     mike     3882:   </div><h4 id="the-div-element"><span class="secno">4.12.2 </span>The <dfn><code>div</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Implemented and widely deployed</i></p><dl class="element"><dt>Categories</dt>
                   3883:    <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
1.1       mike     3884:    <dd><a href="editing.html#formatblock-candidate"><code title="">formatBlock</code> candidate</a>.</dd>
                   3885:    <dt>Contexts in which this element may be used:</dt>
1.153     mike     3886:    <dd>Where <a href="dom.html#flow-content">flow content</a> is expected.</dd>
1.1       mike     3887:    <dt>Content model:</dt>
1.153     mike     3888:    <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
1.1       mike     3889:    <dt>Content attributes:</dt>
                   3890:    <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
                   3891:    <dt>DOM interface:</dt>
                   3892:    <dd>
                   3893:     <pre class="idl">interface <dfn id="htmldivelement">HTMLDivElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {};</pre>
                   3894:    </dd>
                   3895:   </dl><p>The <code><a href="#the-div-element">div</a></code> element has no special meaning at all. It
                   3896:   <a href="the-xhtml-syntax.html#represents">represents</a> its children. It can be used with the <code title="attr-class"><a href="dom.html#classes">class</a></code>, <code title="attr-lang"><a href="dom.html#attr-lang">lang</a></code>, and <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attributes to mark up semantics
1.117     mike     3897:   common to a group of consecutive elements.</p><p class="note">Authors are strongly encouraged to view the
1.1       mike     3898:   <code><a href="#the-div-element">div</a></code> element as an element of last resort, for when no
                   3899:   other element is suitable. Use of the <code><a href="#the-div-element">div</a></code> element
                   3900:   instead of more appropriate elements leads to poor accessibility for
1.117     mike     3901:   readers and poor maintainability for authors.</p><div class="example">
1.1       mike     3902: 
                   3903:    <p>For example, a blog post would be marked up using
                   3904:    <code><a href="semantics.html#the-article-element">article</a></code>, a chapter using <code><a href="semantics.html#the-section-element">section</a></code>, a
                   3905:    page's navigation aids using <code><a href="semantics.html#the-nav-element">nav</a></code>, and a group of form
                   3906:    controls using <code><a href="forms.html#the-fieldset-element">fieldset</a></code>.</p>
                   3907: 
                   3908:    <p>On the other hand, <code><a href="#the-div-element">div</a></code> elements can be useful for
                   3909:    stylistic purposes or to wrap multiple paragraphs within a section
                   3910:    that are all to be annotated in a similar way. In the following
                   3911:    example, we see <code><a href="#the-div-element">div</a></code> elements used as a way to set the
                   3912:    language of two paragraphs at once, instead of setting the language
                   3913:    on the two paragraph elements separately:</p>
                   3914: 
                   3915:    <pre>&lt;article lang="en-US"&gt;
                   3916:  &lt;h1&gt;My use of language and my cats&lt;/h1&gt;
                   3917:  &lt;p&gt;My cat's behavior hasn't changed much since her absence, except
                   3918:  that she plays her new physique to the neighbors regularly, in an
                   3919:  attempt to get pets.&lt;/p&gt;
                   3920:  &lt;div lang="en-GB"&gt;
                   3921:   &lt;p&gt;My other cat, coloured black and white, is a sweetie. He followed
                   3922:   us to the pool today, walking down the pavement with us. Yesterday
                   3923:   he apparently visited our neighbours. I wonder if he recognises that
                   3924:   their flat is a mirror image of ours.&lt;/p&gt;
                   3925:   &lt;p&gt;Hm, I just noticed that in the last paragraph I used British
                   3926:   English. But I'm supposed to write in American English. So I
                   3927:   shouldn't say "pavement" or "flat" or "colour"...&lt;/p&gt;
                   3928:  &lt;/div&gt;
                   3929:  &lt;p&gt;I should say "sidewalk" and "apartment" and "color"!&lt;/p&gt;
                   3930: &lt;/article&gt;</pre>
                   3931: 
1.117     mike     3932:   </div><div class="impl">
1.1       mike     3933: 
1.153     mike     3934:   <h3 id="matching-html-elements-using-selectors"><span class="secno">4.13 </span>Matching HTML elements using selectors</h3><p class="XXX annotation"><b>Status: </b><i>Working draft</i></p>
1.1       mike     3935: 
                   3936:   <p>There are a number of dynamic selectors that can be used with
                   3937:   HTML. This section defines when these selectors match HTML
                   3938:   elements.</p>
                   3939: 
                   3940:   <dl><dt><dfn id="selector-link" title="selector-link"><code>:link</code></dfn></dt>
                   3941:    <dt><dfn id="selector-visited" title="selector-visited"><code>:visited</code></dfn></dt>
                   3942: 
                   3943:    <dd>
                   3944: 
                   3945:     <p>All <code><a href="text-level-semantics.html#the-a-element">a</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute, all
                   3946:     <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute, and all
                   3947:     <code><a href="semantics.html#the-link-element">link</a></code> elements that have an <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code> attribute, must match one of
                   3948:     <code title="selector-link"><a href="#selector-link">:link</a></code> and <code title="selector-visited"><a href="#selector-visited">:visited</a></code>.</p>
                   3949: 
                   3950:    </dd>
                   3951: 
                   3952: 
                   3953:    <dt><dfn id="selector-active" title="selector-active"><code>:active</code></dfn></dt>
                   3954: 
                   3955:    <dd>
                   3956: 
                   3957:     <p>The <code title="selector-active"><a href="#selector-active">:active</a></code> pseudo-class
                   3958:     must match the following elements between the time the user begins
1.95      mike     3959:     to activate the element and the time the user stops activating
1.1       mike     3960:     the element:</p>
                   3961: 
                   3962:     <ul><li><code><a href="text-level-semantics.html#the-a-element">a</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute</li>
                   3963: 
                   3964:      <li><code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute</li>
                   3965: 
                   3966:      <li><code><a href="semantics.html#the-link-element">link</a></code> elements that have an <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code> attribute</li>
                   3967: 
                   3968:      <li><code><a href="forms.html#the-button-element">button</a></code> elements that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   3969: 
                   3970:      <li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#submit-button-state" title="attr-input-type-submit">Submit Button</a>, <a href="forms.html#image-button-state" title="attr-input-type-image">Image Button</a>, <a href="forms.html#reset-button-state" title="attr-input-type-reset">Reset Button</a>, or <a href="forms.html#button-state" title="attr-input-type-button">Button</a> state</li>
                   3971: 
                   3972:      <li><code><a href="#the-command">command</a></code> elements that do not have a <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> attribute</li>
                   3973: 
                   3974:      <li>any other element, if it is <a href="editing.html#specially-focusable">specially
                   3975:      focusable</a></li>
                   3976: 
                   3977:     </ul><p class="example">For example, if the user is using a keyboard to
                   3978:     push a <code><a href="forms.html#the-button-element">button</a></code> element by pressing the space bar, the
                   3979:     element would match this pseudo-class in between the time that the
                   3980:     element received the <code title="event-keydown">keydown</code>
                   3981:     event and the time the element received the <code title="event-keyup">keyup</code> event.</p>
                   3982: 
                   3983:    </dd>
                   3984: 
                   3985: 
                   3986:    <dt><dfn id="selector-enabled" title="selector-enabled"><code>:enabled</code></dfn></dt>
                   3987: 
                   3988:    <dd>
                   3989: 
                   3990:     <p>The <code title="selector-enabled"><a href="#selector-enabled">:enabled</a></code> pseudo-class
                   3991:     must match the following elements:</p>
                   3992: 
                   3993:     <ul><li><code><a href="text-level-semantics.html#the-a-element">a</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute</li>
                   3994: 
                   3995:      <li><code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that have an <code title="attr-hyperlink-href"><a href="history.html#attr-hyperlink-href">href</a></code> attribute</li>
                   3996: 
                   3997:      <li><code><a href="semantics.html#the-link-element">link</a></code> elements that have an <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code> attribute</li>
                   3998: 
                   3999:      <li><code><a href="forms.html#the-button-element">button</a></code> elements that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4000: 
                   4001:      <li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute are not in the
                   4002:      <a href="forms.html#hidden-state" title="attr-input-type-hidden">Hidden</a> state and that
                   4003:      are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4004: 
                   4005:      <li><code><a href="forms.html#the-select-element">select</a></code> elements that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4006: 
                   4007:      <li><code><a href="forms.html#the-textarea-element">textarea</a></code> elements that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4008: 
                   4009:      <li><code><a href="forms.html#the-option-element">option</a></code> elements that do not have a <code title="attr-option-disabled"><a href="forms.html#attr-option-disabled">disabled</a></code> attribute</li>
                   4010: 
                   4011:      <li><code><a href="#the-command">command</a></code> elements that do not have a <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> attribute</li>
                   4012: 
                   4013:      <li><code><a href="semantics.html#the-li-element">li</a></code> elements that are children of
                   4014:      <code><a href="#menus">menu</a></code> elements, and that have a child element that
                   4015:      defines a <a href="#concept-command" title="concept-command">command</a>, if the
                   4016:      first such element's <a href="#command-facet-disabledstate" title="command-facet-disabledstate">Disabled State</a> facet
                   4017:      is false (not disabled)</li>
                   4018: 
                   4019:     </ul></dd>
                   4020: 
                   4021: 
                   4022:    <dt><dfn id="selector-disabled" title="selector-disabled"><code>:disabled</code></dfn></dt>
                   4023: 
                   4024:    <dd>
                   4025: 
                   4026:     <p>The <code title="selector-disabled"><a href="#selector-disabled">:disabled</a></code>
                   4027:     pseudo-class must match the following elements:</p>
                   4028: 
1.131     mike     4029:     <ul><li><code><a href="forms.html#the-button-element">button</a></code> elements that are <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
1.1       mike     4030: 
                   4031:      <li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute are not in the
                   4032:      <a href="forms.html#hidden-state" title="attr-input-type-hidden">Hidden</a> state and that
                   4033:      are <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4034: 
                   4035:      <li><code><a href="forms.html#the-select-element">select</a></code> elements that are <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4036: 
                   4037:      <li><code><a href="forms.html#the-textarea-element">textarea</a></code> elements that are <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4038: 
                   4039:      <li><code><a href="forms.html#the-option-element">option</a></code> elements that have a <code title="attr-option-disabled"><a href="forms.html#attr-option-disabled">disabled</a></code> attribute</li>
                   4040: 
                   4041:      <li><code><a href="#the-command">command</a></code> elements that have a <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> attribute</li>
                   4042: 
                   4043:      <li><code><a href="semantics.html#the-li-element">li</a></code> elements that are children of
                   4044:      <code><a href="#menus">menu</a></code> elements, and that have a child element that
                   4045:      defines a <a href="#concept-command" title="concept-command">command</a>, if the
                   4046:      first such element's <a href="#command-facet-disabledstate" title="command-facet-disabledstate">Disabled State</a> facet
                   4047:      is true (disabled)</li>
                   4048: 
                   4049:     </ul></dd>
                   4050: 
                   4051: 
                   4052:    <dt><dfn id="selector-checked" title="selector-checked"><code>:checked</code></dfn></dt>
                   4053: 
                   4054:    <dd>
                   4055: 
                   4056:     <p>The <code title="selector-checked"><a href="#selector-checked">:checked</a></code> pseudo-class
                   4057:     must match the following elements:</p>
                   4058: 
                   4059:     <ul><li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#checkbox-state" title="attr-input-type-checkbox">Checkbox</a> state and whose
                   4060:      <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> state is
                   4061:      true</li>
                   4062: 
                   4063:      <li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#radio-button-state" title="attr-input-type-radio">Radio Button</a> state and whose
                   4064:      <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> state is
                   4065:      true</li>
                   4066: 
                   4067:      <li><code><a href="#the-command">command</a></code> elements whose <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state
                   4068:      and that have a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code>
                   4069:      attribute</li>
                   4070: 
                   4071:      <li><code><a href="#the-command">command</a></code> elements whose <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state and that
                   4072:      have a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code>
                   4073:      attribute</li>
                   4074: 
                   4075:     </ul></dd>
                   4076: 
                   4077: 
                   4078:    <dt><dfn id="selector-indeterminate" title="selector-indeterminate"><code>:indeterminate</code></dfn></dt>
                   4079: 
                   4080:    <dd>
                   4081: 
                   4082:     <p>The <code title="selector-indeterminate"><a href="#selector-indeterminate">:indeterminate</a></code>
                   4083:     pseudo-class must match <code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#checkbox-state" title="attr-input-type-checkbox">Checkbox</a> state and whose
                   4084:     <code title="dom-input-indeterminate"><a href="forms.html#dom-input-indeterminate">indeterminate</a></code> DOM
                   4085:     attribute is set to true.</p>
                   4086: 
                   4087:    </dd>
                   4088: 
                   4089: 
                   4090:    <dt><dfn id="selector-default" title="selector-default"><code>:default</code></dfn></dt>
                   4091: 
                   4092:    <dd>
                   4093: 
                   4094:     <p>The <code title="selector-default"><a href="#selector-default">:default</a></code> pseudo-class
                   4095:     must match the following elements:</p>
                   4096: 
                   4097:     <ul><li><code><a href="forms.html#the-button-element">button</a></code> elements that are their form's
                   4098:      <a href="forms.html#default-button">default button</a></li>
                   4099: 
                   4100:      <li><code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#submit-button-state" title="attr-input-type-submit">Submit Button</a> or <a href="forms.html#image-button-state" title="attr-input-type-image">Image Button</a> state, and that
                   4101:      are their form's <a href="forms.html#default-button">default button</a></li>
                   4102: <!--
                   4103:      <li><code>command</code> elements that have a <code
                   4104:      title="attr-command-default">default</code> attribute</li>
                   4105: -->
                   4106:     </ul></dd>
                   4107: 
                   4108: 
                   4109:    <dt><dfn id="selector-valid" title="selector-valid"><code>:valid</code></dfn></dt>
                   4110: 
                   4111:    <dd>
                   4112: 
                   4113:     <p>The <code title="selector-valid"><a href="#selector-valid">:valid</a></code> pseudo-class
                   4114:     must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for
                   4115:     constraint validation">candidates for constraint validation</a>
                   4116:     and that <a href="forms.html#concept-fv-valid" title="concept-fv-valid">satisfy their
                   4117:     constraints</a>.</p>
                   4118: 
                   4119:    </dd>
                   4120: 
                   4121: 
                   4122:    <dt><dfn id="selector-invalid" title="selector-invalid"><code>:invalid</code></dfn></dt>
                   4123: 
                   4124:    <dd>
                   4125: 
                   4126:     <p>The <code title="selector-invalid"><a href="#selector-invalid">:invalid</a></code> pseudo-class
                   4127:     must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for
                   4128:     constraint validation">candidates for constraint validation</a>
                   4129:     but that do not <a href="forms.html#concept-fv-valid" title="concept-fv-valid">satisfy their
                   4130:     constraints</a>.</p>
                   4131: 
                   4132:    </dd>
                   4133: 
                   4134: 
                   4135:    <dt><dfn id="selector-in-range" title="selector-in-range"><code>:in-range</code></dfn></dt>
                   4136: 
                   4137:    <dd>
                   4138: 
                   4139:     <p>The <code title="selector-in-range"><a href="#selector-in-range">:in-range</a></code>
                   4140:     pseudo-class must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for constraint validation">candidates for
                   4141:     constraint validation</a> and that are neither <a href="forms.html#suffering-from-an-underflow">suffering
                   4142:     from an underflow</a> nor <a href="forms.html#suffering-from-an-overflow">suffering from an
                   4143:     overflow</a>.</p>
                   4144: 
                   4145:    </dd>
                   4146: 
                   4147: 
                   4148:    <dt><dfn id="selector-out-of-range" title="selector-out-of-range"><code>:out-of-range</code></dfn></dt>
                   4149: 
                   4150:    <dd>
                   4151: 
                   4152:     <p>The <code title="selector-out-of-range"><a href="#selector-out-of-range">:out-of-range</a></code>
                   4153:     pseudo-class must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for constraint validation">candidates for
                   4154:     constraint validation</a> and that are <a href="forms.html#suffering-from-an-underflow">suffering from an
                   4155:     underflow</a> or <a href="forms.html#suffering-from-an-overflow">suffering from an overflow</a>.</p>
                   4156: 
                   4157:    </dd>
                   4158: 
                   4159: 
                   4160:    <dt><dfn id="selector-required" title="selector-required"><code>:required</code></dfn></dt>
                   4161: 
                   4162:    <dd>
                   4163: 
                   4164:     <p>The <code title="selector-required"><a href="#selector-required">:required</a></code>
                   4165:     pseudo-class must match the following elements:</p>
                   4166: 
                   4167:     <ul><li><code><a href="forms.html#the-input-element">input</a></code> elements that are <i title="concept-input-required"><a href="forms.html#concept-input-required">required</a></i></li>
                   4168: 
                   4169:      <li><code><a href="forms.html#the-textarea-element">textarea</a></code> elements that have a <code title="attr-textarea-required"><a href="forms.html#attr-textarea-required">required</a></code>
                   4170:      attribute</li>
                   4171: 
                   4172:     </ul></dd>
                   4173: 
                   4174: 
                   4175:    <dt><dfn id="selector-optional" title="selector-optional"><code>:optional</code></dfn></dt>
                   4176: 
                   4177:    <dd>
                   4178: 
                   4179:     <p>The <code title="selector-optional"><a href="#selector-optional">:optional</a></code>
                   4180:     pseudo-class must match the following elements:</p>
                   4181: 
                   4182:     <ul><li><code><a href="forms.html#the-button-element">button</a></code> elements</li>
                   4183: 
                   4184:      <li><code><a href="forms.html#the-input-element">input</a></code> elements that are not <i title="concept-input-required"><a href="forms.html#concept-input-required">required</a></i></li>
                   4185: 
                   4186:      <li><code><a href="forms.html#the-select-element">select</a></code> elements</li>
                   4187: 
                   4188:      <li><code><a href="forms.html#the-textarea-element">textarea</a></code> elements that do not have a <code title="attr-textarea-required"><a href="forms.html#attr-textarea-required">required</a></code>
                   4189:      attribute</li>
                   4190: 
                   4191:     </ul></dd>
                   4192: 
                   4193: 
                   4194:    <dt><dfn id="selector-read-only" title="selector-read-only"><code>:read-only</code></dfn></dt>
                   4195:    <dt><dfn id="selector-read-write" title="selector-read-write"><code>:read-write</code></dfn></dt>
                   4196: 
                   4197:    <dd>
                   4198: 
                   4199:     <p>The <code title="selector-read-write"><a href="#selector-read-write">:read-write</a></code>
                   4200:     pseudo-class must match the following elements:</p>
                   4201: 
                   4202:     <ul><li><code><a href="forms.html#the-input-element">input</a></code> elements to which the <code title="attr-input-readonly"><a href="forms.html#attr-input-readonly">readonly</a></code> attribute applies,
                   4203:      but that are not <i title="concept-input-immutable"><a href="forms.html#concept-input-immutable">immutable</a></i>
                   4204:      (i.e. that do not have the <code title="attr-input-readonly"><a href="forms.html#attr-input-readonly">readonly</a></code> attribute specified
                   4205:      and that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a>)</li>
                   4206: 
                   4207:      <li><code><a href="forms.html#the-textarea-element">textarea</a></code> elements that do not have a <code title="attr-textarea-readonly"><a href="forms.html#attr-textarea-readonly">readonly</a></code> attribute, and
                   4208:      that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
                   4209: 
                   4210:      <li>any element that is <a href="editing.html#editable">editable</a></li>
                   4211: 
                   4212:     </ul><p>The <code title="selector-read-only"><a href="#selector-read-only">:read-only</a></code>
                   4213:     pseudo-class must match all other <a href="infrastructure.html#html-elements">HTML elements</a>.</p>
                   4214: 
                   4215:    </dd>
                   4216: 
                   4217:   </dl><p class="note">Another section of this specification defines the
                   4218:   <i><a href="history.html#target-element">target element</a></i> used with the <code title="selector-target">:target</code> pseudo-class.</p>
                   4219: 
                   4220:   <p class="note">This specification does not define when an element
                   4221:   matches the <code title="selector-hover">:hover</code>, <code title="selector-focus">:focus</code>, or <code title="selector-lang()">:lang()</code> dynamic pseudo-classes, as
                   4222:   those are all defined in sufficient detail in a language-agnostic
1.98      mike     4223:   fashion in the Selectors specification. <a href="references.html#refsSELECTORS">[SELECTORS]</a></p>
1.1       mike     4224: 
1.117     mike     4225:   </div></body></html>

Webmaster