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

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

Webmaster