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

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

Webmaster