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

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

Webmaster