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

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

Webmaster