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

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

Webmaster