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