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

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

Webmaster