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

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

Webmaster