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

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

Webmaster