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

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

Webmaster