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

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

Webmaster