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

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

Webmaster