Annotation of html5/spec/interactive-elements.html, revision 1.997
1.866 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.885 mike 2: <!DOCTYPE html>
1.987 mike 3: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie" class="split chapter"><head><title>4.11 Interactive elements — HTML5 </title><style type="text/css">
1.1 mike 4: pre { margin-left: 2em; white-space: pre-wrap; }
5: h2 { margin: 3em 0 1em 0; }
6: h3 { margin: 2.5em 0 1em 0; }
7: h4 { margin: 2.5em 0 0.75em 0; }
8: h5, h6 { margin: 2.5em 0 1em; }
9: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
10: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
11: p { margin: 1em 0; }
12: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
13: dl, dd { margin-top: 0; margin-bottom: 0; }
14: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
15: dt + dt { margin-top: 0; }
16: dd dt { margin-top: 0.25em; margin-bottom: 0; }
17: dd p { margin-top: 0; }
18: dd dl + p { margin-top: 1em; }
19: dd table + p { margin-top: 1em; }
20: p + * > li, dd li { margin: 1em 0; }
21: dt, dfn { font-weight: bold; font-style: normal; }
22: dt dfn { font-style: italic; }
23: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
24: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
25: pre em { font-weight: bolder; font-style: normal; }
26: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
27: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
28: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
1.974 mike 29: table thead, table tbody { border-bottom: solid; }
1.1 mike 30: table tbody th:first-child { border-left: solid; }
1.469 mike 31: table tbody th { text-align: left; }
1.1 mike 32: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
33: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
34:
35: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
36: .matrix, .matrix td { border: none; text-align: right; }
37: .matrix { margin-left: 2em; }
38: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
39: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
40: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
41:
42: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
43: img.extra { float: right; }
44: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
45: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
46: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
47: pre.css:first-line { color: #AAAA50; }
1.834 mike 48: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 49: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
50: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
51: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
52: dl.domintro dd p { margin: 0.5em 0; }
53: dl.switch { padding-left: 2em; }
54: dl.switch > dt { text-indent: -1.5em; }
55: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
56: dl.triple { padding: 0 0 0 1em; }
57: dl.triple dt, dl.triple dd { margin: 0; display: inline }
58: dl.triple dt:after { content: ':'; }
59: dl.triple dd:after { content: '\A'; white-space: pre; }
60: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
61: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
62: a .diff-new { border-bottom: 1px blue solid; }
63:
64: h2 { page-break-before: always; }
65: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
66: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
67:
68: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
69:
70: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
71: div.head p { margin: 0; }
72: div.head h1 { margin: 0; }
73: div.head .logo { float: right; margin: 0 1em; }
74: div.head .logo img { border: none } /* remove border from top image */
75: div.head dl { margin: 1em 0; }
1.665 mike 76: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 77:
78: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
79: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
80: body > .toc > li > * { margin-bottom: 0.5em; }
81: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
82: .toc, .toc li { list-style: none; }
83:
84: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
85: .brief li { margin: 0; padding: 0; }
86: .brief li p { margin: 0; padding: 0; }
87:
88: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
89: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
90: .category-list li { display: inline; }
91: .category-list li:not(:last-child)::after { content: ', '; }
92: .category-list li > span, .category-list li > a { text-transform: lowercase; }
93: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
94:
95: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
96: .XXX > :first-child { margin-top: 0; }
97: p .XXX { line-height: 3em; }
1.153 mike 98: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
99: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
100: .annotation :link, .annotation :visited { color: inherit; }
101: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
102: .annotation span { border: none ! important; }
1.1 mike 103: .note { color: green; background: transparent; font-family: sans-serif; }
104: .warning { color: red; background: transparent; }
105: .note, .warning { font-weight: bolder; font-style: italic; }
106: p.note, div.note { padding: 0.5em 2em; }
107: span.note { padding: 0 2em; }
108: .note p:first-child, .warning p:first-child { margin-top: 0; }
109: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
110: .warning:before { font-style: normal; }
111: p.note:before { content: 'Note: '; }
112: p.warning:before { content: '\26A0 Warning! '; }
113:
114: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
115: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
116: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
1.996 mike 117: .bookkeeping dt { margin: 0.5em 2em 0; }
118: .bookkeeping dd { margin: 0 3em 0.5em; }
1.1 mike 119:
120: h4 { position: relative; z-index: 3; }
121: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
122: .element {
123: background: #EEEEFF;
124: color: black;
125: margin: 0 0 1em 0.15em;
126: padding: 0 1em 0.25em 0.75em;
127: border-left: solid #9999FF 0.25em;
128: position: relative;
129: z-index: 1;
130: }
131: .element:before {
132: position: absolute;
133: z-index: 2;
134: top: 0;
135: left: -1.15em;
136: height: 2em;
137: width: 0.9em;
138: background: #EEEEFF;
139: content: ' ';
140: border-style: none none solid solid;
141: border-color: #9999FF;
142: border-width: 0.25em;
143: }
144:
1.143 mike 145: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
146: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 147:
148: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
149: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
150: ul.domTree li li { list-style: none; }
151: 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; }
152: 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; }
153: ul.domTree span { font-style: italic; font-family: serif; }
154: ul.domTree .t1 code { color: purple; font-weight: bold; }
155: ul.domTree .t2 { font-style: normal; font-family: monospace; }
156: ul.domTree .t2 .name { color: black; font-weight: bold; }
157: ul.domTree .t2 .value { color: blue; font-weight: normal; }
158: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
159: ul.domTree .t7 code, .domTree .t8 code { color: green; }
160: ul.domTree .t10 code { color: teal; }
161:
1.730 mike 162: body.dfnEnabled dfn { cursor: pointer; }
163: .dfnPanel {
164: display: inline;
165: position: absolute;
166: z-index: 10;
167: height: auto;
168: width: auto;
169: padding: 0.5em 0.75em;
170: font: small sans-serif, Droid Sans Fallback;
171: background: #DDDDDD;
172: color: black;
173: border: outset 0.2em;
174: }
175: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
176: .dfnPanel :link, .dfnPanel :visited { color: black; }
177: .dfnPanel p { font-weight: bolder; }
178: .dfnPanel * + p { margin-top: 0.25em; }
179: .dfnPanel li { list-style-position: inside; }
180:
1.665 mike 181: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
182: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
183: #configUI p label { display: block; }
184: #configUI #updateUI, #configUI .loginUI { text-align: center; }
185: #configUI input[type=button] { display: block; margin: auto; }
1.995 mike 186:
1.261 mike 187: </style><style type="text/css">
188:
1.286 mike 189: .applies thead th > * { display: block; }
190: .applies thead code { display: block; }
191: .applies tbody th { whitespace: nowrap; }
192: .applies td { text-align: center; }
193: .applies .yes { background: yellow; }
194:
1.997 ! mike 195: .matrix, .matrix td { border: hidden; text-align: right; }
1.261 mike 196: .matrix { margin-left: 2em; }
197:
198: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
199: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
200: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
201:
202: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
203: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
204: #table-example-1 caption { padding-bottom: 0.5em; }
205: #table-example-1 thead, #table-example-1 tbody { border: none; }
206: #table-example-1 th, #table-example-1 td { border: solid thin; }
207: #table-example-1 th { font-weight: normal; }
208: #table-example-1 td { border-style: none solid; vertical-align: top; }
209: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
210: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
211: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
212: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
213: #table-example-1 tbody td:first-child::after { content: leader(". "); }
214: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
215: #table-example-1 tbody td:first-child + td { width: 10em; }
216: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
217: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
218:
219: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
220: .apple-table-examples * { font-family: "Times", serif; }
221: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
222: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
223: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
224: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
225: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
226: .apple-table-examples td { text-align: right; vertical-align: top; }
227: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
228: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
229: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
230: .apple-table-examples sup { line-height: 0; }
231:
1.718 mike 232: .details-example img { vertical-align: top; }
233:
1.875 mike 234: #named-character-references-table {
235: font-size: 0.6em;
236: column-width: 28em;
237: column-gap: 1em;
238: -moz-column-width: 28em;
239: -moz-column-gap: 1em;
240: -webkit-column-width: 28em;
241: -webkit-column-gap: 1em;
242: }
243: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
244: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
245:
1.988 mike 246: .glyph.control { color: red; }
247:
1.990 mike 248: @font-face {
249: font-family: 'Essays1743';
250: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743.ttf');
251: }
252: @font-face {
253: font-family: 'Essays1743';
254: font-weight: bold;
255: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Bold.ttf');
256: }
257: @font-face {
258: font-family: 'Essays1743';
259: font-style: italic;
260: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-Italic.ttf');
261: }
262: @font-face {
263: font-family: 'Essays1743';
264: font-style: italic;
265: font-weight: bold;
266: src: url('http://www.whatwg.org/specs/web-apps/current-work/fonts/Essays1743-BoldItalic.ttf');
267: }
268:
1.866 mike 269: </style><style type="text/css">
1.874 mike 270: .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
271: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%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%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.665 mike 272: function getCookie(name) {
273: var params = location.search.substr(1).split("&");
274: for (var index = 0; index < params.length; index++) {
275: if (params[index] == name)
276: return "1";
277: var data = params[index].split("=");
278: if (data[0] == name)
279: return unescape(data[1]);
280: }
281: var cookies = document.cookie.split("; ");
282: for (var index = 0; index < cookies.length; index++) {
283: var data = cookies[index].split("=");
284: if (data[0] == name)
285: return unescape(data[1]);
286: }
287: return null;
288: }
289: function load(script) {
290: var e = document.createElement('script');
291: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
292: document.body.appendChild(e);
293: }
294: function init() {
295: if (location.search == '?slow-browser')
296: return;
297: var configUI = document.createElement('div');
298: configUI.id = 'configUI';
299: document.body.appendChild(configUI);
300: // load('reviewer.js'); // would need cross-site XHR
301: if (document.getElementById('head'))
302: load('toc.js');
303: load('styler.js');
304: // load('updater.js'); // would need cross-site XHR
1.718 mike 305: load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.665 mike 306: // load('status.js'); // would need cross-site XHR
307: if (getCookie('profile') == '1')
308: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
309: fixBrokenLink();
310: }
1.993 mike 311: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.987 mike 312: <script src="link-fixup.js"></script>
313: <link href="association-of-controls-and-forms.html" title="4.10.18 Association of controls and forms" rel="prev">
1.2 mike 314: <link href="spec.html#contents" title="Table of contents" rel="index">
1.987 mike 315: <link href="commands.html" title="4.11.5 Commands" rel="next">
1.665 mike 316: </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1 mike 317: <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.989 mike 318:
1.177 mike 319: <h1>HTML5</h1>
1.868 mike 320: </div><div>
1.987 mike 321: <a href="association-of-controls-and-forms.html">← 4.10.18 Association of controls and forms</a> –
1.2 mike 322: <a href="spec.html#contents">Table of contents</a> –
1.987 mike 323: <a href="commands.html">4.11.5 Commands →</a>
324: <ol class="toc"><li><ol><li><a href="interactive-elements.html#interactive-elements"><span class="secno">4.11 </span>Interactive elements</a>
325: <ol><li><a href="interactive-elements.html#the-details-element"><span class="secno">4.11.1 </span>The <code>details</code> element</a></li><li><a href="interactive-elements.html#the-summary-element"><span class="secno">4.11.2 </span>The <code>summary</code> element</a></li><li><a href="interactive-elements.html#the-command"><span class="secno">4.11.3 </span>The <code>command</code> element</a></li><li><a href="interactive-elements.html#menus"><span class="secno">4.11.4 </span>The <code>menu</code> element</a>
326: <ol><li><a href="interactive-elements.html#menus-intro"><span class="secno">4.11.4.1 </span>Introduction</a></li><li><a href="interactive-elements.html#building-menus-and-toolbars"><span class="secno">4.11.4.2 </span>Building menus and toolbars</a></li><li><a href="interactive-elements.html#context-menus"><span class="secno">4.11.4.3 </span>Context menus</a></li><li><a href="interactive-elements.html#toolbars"><span class="secno">4.11.4.4 </span>Toolbars</a></li></ol></li></ol></li></ol></li></ol></div>
1.1 mike 327:
1.992 mike 328: <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.987 mike 329: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
330: <dd><a href="sections.html#sectioning-root">Sectioning root</a>.</dd>
331: <dd><a href="content-models.html#interactive-content">Interactive content</a>.</dd>
1.1 mike 332: <dt>Contexts in which this element may be used:</dt>
1.987 mike 333: <dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 334: <dt>Content model:</dt>
1.987 mike 335: <dd>One <code><a href="#the-summary-element">summary</a></code> element followed by <a href="content-models.html#flow-content">flow content</a>.</dd>
1.1 mike 336: <dt>Content attributes:</dt>
1.987 mike 337: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 338: <dd><code title="attr-details-open"><a href="#attr-details-open">open</a></code></dd>
339: <dt>DOM interface:</dt>
340: <dd>
1.987 mike 341: <pre class="idl">interface <dfn id="htmldetailselement">HTMLDetailsElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 342: attribute boolean <a href="#dom-details-open" title="dom-details-open">open</a>;
343: };</pre>
344: </dd>
1.987 mike 345: </dl><p>The <code><a href="#the-details-element">details</a></code> element <a href="rendering.html#represents">represents</a> a
1.307 mike 346: disclosure widget from which the user can obtain additional
347: information or controls.</p><p class="note">The <code><a href="#the-details-element">details</a></code> element is not appropriate
1.987 mike 348: for footnotes. Please see <a href="links.html#footnotes">the section on
1.729 mike 349: footnotes</a> for details on how to mark up footnotes.</p><p>The <span class="impl">first</span> <code><a href="#the-summary-element">summary</a></code> element
1.987 mike 350: child of the element, if any, <a href="rendering.html#represents">represents</a> the summary or
1.729 mike 351: legend of the details. <span class="impl">If there is no child
352: <code><a href="#the-summary-element">summary</a></code> element, the user agent should provide its own
353: legend (e.g. "Details").</span></p><p>The <dfn id="attr-details-open" title="attr-details-open"><code>open</code></dfn>
1.987 mike 354: content attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a>. If present,
1.1 mike 355: it indicates that the details are to be shown to the user. If the
1.117 mike 356: attribute is absent, the details are not to be shown.</p><div class="impl">
1.1 mike 357:
358: <p>If the attribute is removed, then the details should be
359: hidden. If the attribute is added, the details should be shown.</p>
360:
361: <p>The user agent should allow the user to request that the details
362: be shown or hidden. To honor a request for the details to be shown,
363: the user agent must set the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute on the element to
364: the value <code title="">open</code>. To honor a request for the
365: 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
366: element.</p>
367:
368: <p>The <dfn id="dom-details-open" title="dom-details-open"><code>open</code></dfn>
1.987 mike 369: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> content attribute.</p>
1.1 mike 370:
1.271 mike 371: </div><div class="example">
372:
373: <p>The following example shows the <code><a href="#the-details-element">details</a></code> element
374: being used to hide technical details in a progress report.</p>
375:
376: <pre><section class="progress window">
377: <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
378: <details>
1.876 mike 379: <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary>
1.729 mike 380: <dl>
381: <dt>Transfer rate:</dt> <dd>452KB/s</dd>
382: <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd>
383: <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd>
384: <dt>Duration:</dt> <dd>01:16:27</dd>
385: <dt>Color profile:</dt> <dd>SD (6-1-6)</dd>
386: <dt>Dimensions:</dt> <dd>320×240</dd>
387: </dl>
1.271 mike 388: </details>
389: </section></pre>
390:
1.718 mike 391: </div><div class="example">
392:
393: <p>The following shows how a <code><a href="#the-details-element">details</a></code> element can be
394: used to hide some controls by default:</p>
395:
396: <pre><details>
1.729 mike 397: <summary>Name & Extension:</summary>
398: <p><input type=text name=fn value="Pillar Magazine.pdf">
399: <p><label><input type=checkbox name=ext checked> Hide extension</label>
1.718 mike 400: </details></pre>
401:
402: <p>One could use this in conjuction with other <code><a href="#the-details-element">details</a></code>
403: in a list to allow the user to collapse a set of fields down to a
404: small set of headings, with the ability to open each one.</p>
405:
406: <p class="details-example"><img alt="" src="http://dev.w3.org/html5/spec/images/sample-details-1.png"><img alt="" src="http://dev.w3.org/html5/spec/images/sample-details-2.png"></p>
407:
1.729 mike 408: <p>In these examples, the summary really just summarises what the
409: controls can change, and not the actual values, which is less than
410: ideal.</p>
411:
412: </div><h4 id="the-summary-element"><span class="secno">4.11.2 </span>The <dfn><code>summary</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
413: <dd>None.</dd>
414: <dt>Contexts in which this element may be used:</dt>
415: <dd>As the first child of a <code><a href="#the-details-element">details</a></code> element.</dd>
416: <dt>Content model:</dt>
1.987 mike 417: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.729 mike 418: <dt>Content attributes:</dt>
1.987 mike 419: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.729 mike 420: <dt>DOM interface:</dt>
1.987 mike 421: <dd>Uses <code><a href="elements.html#htmlelement">HTMLElement</a></code>.</dd>
422: </dl><p>The <code><a href="#the-summary-element">summary</a></code> element <a href="rendering.html#represents">represents</a> a
1.729 mike 423: summary, caption, or legend for the rest of the contents of the
424: <code><a href="#the-summary-element">summary</a></code> element's parent <code><a href="#the-details-element">details</a></code>
425: element<span class="impl">, if any</span>.</p><!-- v2DATAGRID
1.80 mike 426: <h4 id="datagrid">The <dfn><code>datagrid</code></dfn> element</h4>
427:
428: <dl class="element">
429: <dt>Categories</dt>
430: <dd><span>Flow content</span>.</dd>
431: <dd><span>Interactive content</span>.</dd>
432: <dd><span>Sectioning root</span>.</dd>
1.1 mike 433: <dt>Contexts in which this element may be used:</dt>
1.80 mike 434: <dd>Where <span>flow content</span> is expected.</dd>
1.1 mike 435: <dt>Content model:</dt>
1.80 mike 436: <dd><span>Flow content</span>.</dd>
1.1 mike 437: <dt>Content attributes:</dt>
1.80 mike 438: <dd><span>Global attributes</span></dd>
439: <!- -v2DGS:
1.1 mike 440: <dd><code title="attr-datagrid-multiple">multiple</code></dd>
1.80 mike 441: - ->
442: <dd><code title="attr-datagrid-disabled">disabled</code></dd>
1.1 mike 443: <dt>DOM interface:</dt>
444: <dd>
1.80 mike 445: <pre class="idl">interface <dfn>HTMLDataGridElement</dfn> : <span>HTMLElement</span> {
446: <!- -v2DGS:
1.1 mike 447: attribute boolean <span title="dom-datagrid-multiple">multiple</span>;
1.80 mike 448: - -> attribute boolean <span title="dom-datagrid-disabled">disabled</span>;
449: attribute <span>DataGridListener</span> <span title="dom-datagrid-listener">listener</span>;
450: <!- - v2DGS:
1.1 mike 451: readonly attribute <span>DataGridSelection</span> <span title="dom-datagrid-selection">selection</span>;
1.80 mike 452: - ->
1.1 mike 453: // columns
1.395 mike 454: 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 455: attribute DOMString <span title="dom-datagrid-sortColumn">sortColumn</span>;
456: attribute boolean <span title="dom-datagrid-sortAscending">sortAscending</span>;
457: void <span title="dom-datagrid-clearColumns">clearColumns</span>();
1.1 mike 458:
459: // rows
1.80 mike 460: void <span title="dom-datagrid-renotify">renotify</span>();
461: void <span title="dom-datagrid-setRowCount">setRowCount</span>(in long childCount, in long rowCount);
462: void <span title="dom-datagrid-setRows">setRows</span>(in <span>RowList</span> rows);
463: void <span title="dom-datagrid-insertRows">insertRows</span>(in <span>RowList</span> rows);
464: void <span title="dom-datagrid-deleteRows">deleteRows</span>(in <span>RowIDList</span> rows);
465: void <span title="dom-datagrid-repaint">repaint</span>(in <span>RowID</span> row, in DOMString column);
466: void <span title="dom-datagrid-clearRows">clearRows</span>();
467: <!- -
1.1 mike 468: v2: opening and closing a row
469: moving a row's actual ID
470: - 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
471: - though actually that should probably just be done using display sorting
1.80 mike 472: - ->
1.1 mike 473: };
474:
1.80 mike 475: typedef DOMString <dfn>Column</dfn>;
476: typedef sequence<<span>Column</span>> <dfn>ColumnList</dfn>;
1.81 mike 477: typedef sequence<any> <dfn>Cell</dfn>; // <span>Column</span>, any... (exact types expected depend on the column type)
1.80 mike 478: typedef sequence<<span>Cell</span>> <dfn>CellList</dfn>;
1.81 mike 479: typedef sequence<any> <dfn>Row</dfn>; // <span>RowID</span>, long, long, <span>CellList</span>, optional boolean, optional long
1.80 mike 480: typedef sequence<<span>Row</span>> <dfn>RowList</dfn>;
481: typedef sequence<unsigned long> <dfn>RowID</dfn>;
482: typedef sequence<<span>RowID</span>> <dfn>RowIDList</dfn>;
1.1 mike 483:
484: [Callback=FunctionOnly, NoInterfaceObject]
1.80 mike 485: interface <dfn>RenderingContext2DCallback</dfn> {
486: DOMString <span title="dom-Rendering2DContextCallback-handleEvent">handleEvent</span>(in <span>CanvasRenderingContext2D</span> context, in unsigned long width, in unsigned long height);
1.1 mike 487: };</pre>
488: </dd>
1.80 mike 489: </dl>
490:
491: <!- - v2:
492: * datagrid: cells that are links (<a href=""></a>)
493: - ->
494:
495: <p>The <code>datagrid</code> element <span>represents</span> an
496: interactive representation of tree, list, or tabular data.</p>
497:
498: <p>The data being presented is provided by script using the methods
499: described in the following sections.</p>
500:
501: <!- -v2DGS:
1.1 mike 502: <p>The <dfn
503: title="attr-datagrid-multiple"><code>multiple</code></dfn> attribute
504: is a <span>boolean attribute</span>. When set, it indicates that the
505: user can select more than one row at a time.</p>
1.80 mike 506: - ->
507:
508: <p>The <dfn
509: title="attr-datagrid-disabled"><code>disabled</code></dfn> attribute
510: is a <span>boolean attribute</span> used to disable the
1.1 mike 511: control. <span class="impl">When the attribute is set, the user
1.80 mike 512: agent must disable the <code>datagrid</code>, preventing the user
513: from interacting with it. The <code>datagrid</code> element should
1.1 mike 514: still continue to update itself when the underlying data changes,
515: though, as described in the next few sections. However, conformance
1.80 mike 516: requirements stating that <code>datagrid</code> elements must react
1.1 mike 517: to users in particular ways do not apply when the
1.80 mike 518: <code>datagrid</code> is disabled.</span></p>
519:
520: <div class="impl">
1.1 mike 521:
1.80 mike 522: <!- -vsDGS: multiple - ->
1.1 mike 523:
1.80 mike 524: <p>The <dfn
1.186 mike 525: title="dom-datagrid-disabled"><code>disabled</code></dfn> IDL
1.80 mike 526: attribute must <span>reflect</span> the content attribute of the
1.1 mike 527: same name.</p>
528:
1.80 mike 529: </div>
530:
531: <!- - v2DGPA: One possible thing to be added is a way to detect when a
1.1 mike 532: row/selection has been deleted, activated, etc, by the user (delete
1.80 mike 533: key, enter key, etc). (v2DGPA = <datagrid> Perform Action) - ->
534:
535:
536: <h5>Introduction</h5>
537:
538: <p><i>This section is non-normative.</i></p>
539:
540: <p>In the <code>datagrid</code> data model, data is structured as a
1.1 mike 541: set of rows representing a tree, each row being split into a number
542: of columns. The columns are always present in the data model,
1.80 mike 543: although individual columns might be hidden in the presentation.</p>
544:
545: <hr>
546:
547: <p>Each row can have child rows. Child rows may be hidden or
548: shown, by closing or opening (respectively) the parent row.</p>
549:
550: <p>Rows are referred to by the path along the tree that one would
1.1 mike 551: take to reach the row, using zero-based indices. Thus, the first row
552: of a list is row "0", the second row is row "1"; the first child row
553: of the first row is row "0,0", the second child row of the first row
554: is row "0,1"; the fourth child of the seventh child of the third
1.80 mike 555: child of the tenth row is "9,2,6,3", etc.</p>
556:
557: <p>The chains of numbers that give a row's path, or identifier, are
1.1 mike 558: represented by arrays of positions, represented in IDL by the
1.80 mike 559: <span>RowID</span> interface.</p>
560:
561: <p>The root of the tree is represented by an empty array.</p>
562:
563: <hr>
564:
565: <p>Each column has a string that is used to identify it in the API,
1.1 mike 566: a label that is shown to users interacting with the column, a type,
1.80 mike 567: and optionally an icon.</p>
568:
569: <p>The possible types are as follows:</p>
570:
571: <table>
572: <thead>
573: <tr>
574: <td>Keyword
575: <td>Description
576: <tbody>
577: <tr>
578: <td><code title="datagrid-type-text">text</code>
579: <td>Simple text.
580: <tr>
581: <td><code title="datagrid-type-editable">editable</code>
582: <td>Editable text.
583: <tr>
584: <td><code title="datagrid-type-checkable">checkable</code>
585: <td>Text with a check box.
586: <tr>
587: <td><code title="datagrid-type-list">list</code>
588: <td>A list of values that the user can switch between.
589: <tr>
590: <td><code title="datagrid-type-progress">progress</code>
591: <td>A progress bar.
592: <tr>
593: <td><code title="datagrid-type-meter">meter</code>
594: <td>A gauge.
595: <tr>
596: <td><code title="datagrid-type-custom">custom</code>
597: <td>A canvas onto which arbitrary content can be drawn.
598: </table>
599:
600: <p>Each column can be flagged as sortable, in which case the user
601: will be able to sort the view using that column.</p>
602:
603: <p>Columns are not necessarily visible. A column can be created
1.1 mike 604: invisible by default. The user can select which columns are to be
1.80 mike 605: shown.</p>
606:
607: <p>When no columns have been added to the <code>datagrid</code>, a
1.1 mike 608: column with no name, whose identifier is the empty string, whose
1.80 mike 609: type is <code title="datagrid-type-text">text</code>, and which is
1.1 mike 610: not sortable, is implied. This column is removed if any explicit
1.80 mike 611: columns are declared.</p>
612:
613: <p>Each cell uses the type given for its column, so all cells in a
614: column present the same type of information.</p>
615:
616: <!- -v2DGS:
1.1 mike 617: <p>Selection of data in a <code>datagrid</code> operates at the row
618: level. If the <code title="attr-datagrid-multiple">multiple</code>
619: attribute is present, multiple rows can be selected at once,
620: otherwise the user can only select one row at a time.</p>
1.80 mike 621: - ->
622:
623: <!- - v2DGDND: selection should draggable to and from datagrids - ->
624:
625:
626: <h6>Example: a <code>datagrid</code> backed by a static <code>table</code> element</h6>
627:
628: ...
629:
630:
631: <h6>Example: a <code>datagrid</code> backed by nested <code>ol</code> elements</h6>
632:
633: ...
634:
635:
636: <h6>Example: a <code>datagrid</code> backed by a server</h6>
637:
638: ...
639:
640:
641: <h5>Populating the <code>datagrid</code></h5>
642:
643: <dl class="domintro">
644:
645: <dt><var title="">datagrid</var> . <code title="dom-datagrid-listener">listener</code> [ = <var title="">value</var> ]</dt>
1.1 mike 646: <dd>
647:
648: <p>Return the current object that is configured as the
1.80 mike 649: <code>datagrid</code> listener, if any. Returns null if there is
1.1 mike 650: none.</p>
651:
652: <p>The listener is an object provided by the script author that
1.80 mike 653: receives notifications when the <code>datagrid</code> needs row
1.1 mike 654: data to render itself, when the user opens and closes rows with
655: children, when the user edits a cell, and when the user invokes a
1.80 mike 656: row's context menu. (The <code>DataGridListener</code> interface
1.1 mike 657: used for this purpose is described in the next section.)</p>
658:
659: <p>Can be set, to change the current listener.</p>
660:
661: </dd>
662:
663:
1.80 mike 664: <dt><var title="">datagrid</var> . <code title="dom-datagrid-renotify">renotify</code>()</dt>
1.1 mike 665: <dd>
666:
1.80 mike 667: <p>Causes the <code>datagrid</code> to resend notifications to the
1.1 mike 668: listener (if any) for any rows or cells that the
1.80 mike 669: <code>datagrid</code> does not yet have information for.</p>
1.1 mike 670:
1.80 mike 671: <!- - useful, e.g., if there is a server error and the script loses
672: track of what rows it's supposed to be reporting. - ->
1.1 mike 673:
674: </dd>
675:
676:
1.80 mike 677: <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 678: <dd>
679:
1.80 mike 680: <p>Adds a column to the <code>datagrid</code>.</p>
1.1 mike 681:
682: <p>If a column with the given identifier has already been added,
683: it just replaces the information for that column.</p>
684:
685: <p>The possible types are enumerated in the previous section.</p>
686:
687: </dd>
688:
689:
1.80 mike 690: <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortColumn">sortColumn</code> [ = <var title="">value</var> ]</dt>
1.1 mike 691: <dd>
692:
693: <p>Returns the identifier of the column by which the data is to be
694: sorted.</p>
695:
696: <p>Can be set, to indicate that the sort order has changed. This
1.80 mike 697: will cause the <code>datagrid</code> to clear its position
698: information for rows, so <code
699: title="dom-datagrid-setRows">setRows()</code> will have to be
1.1 mike 700: called again with the new sort order.</p>
701:
702: <p>The columns are not actually sorted by the
1.80 mike 703: <code>datagrid</code>; the data has to be sorted by the script
704: that adds the rows to the <code>datagrid</code>.</p>
1.1 mike 705:
706: </dd>
707:
708:
1.80 mike 709: <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortAscending">sortAscending</code> [ = <var title="">value</var> ]</dt>
1.1 mike 710: <dd>
711:
712: <p>Returns true if the data is to be sorted with smaller values
713: first; otherwise, returns false, indicating that bigger values are
714: to be put first.</p>
715:
716: <p>Can be set, to indicate that the order is about to change.</p>
717:
718: </dd>
719:
720:
1.80 mike 721: <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearColumns">clearColumns</code>()</dt>
1.1 mike 722: <dd>
723:
1.80 mike 724: <p>Removes all the columns in the <code>datagrid</code>,
1.1 mike 725: reinstating the implied column.</p>
726:
727: </dd>
728:
729:
1.80 mike 730: <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRowCount">setRowCount</code>(<var title="">childCount</var>, <var title="">rowCount</var>)</dt>
1.1 mike 731: <dd>
732:
1.80 mike 733: <p>Sets the numbers of rows in the <code>datagrid</code>,
1.1 mike 734: excluding rows that are descendants of rows that are closed.</p>
735:
1.80 mike 736: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 737: arguments contradict each other or previously declared information
1.80 mike 738: (e.g. declaring that the <code>datagrid</code> has three rows when
1.1 mike 739: the 12th row has been declared).</p>
740:
741: </dd>
742:
743:
1.80 mike 744: <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRows">setRows</code>(<var title="">rows</var>)</dt>
1.1 mike 745: <dd>
746:
1.80 mike 747: <p>Updates data for rows in the <code>datagrid</code>, or fills in
748: data for rows previously implied by a call to <code
749: title="dom-datagrid-setRowCount">setRowCount()</code> but not
1.1 mike 750: previously declared.</p>
751:
752: <p>The <var title="">rows</var> argument is an array of rows, each
753: represented by a further array consisting of:</p>
754:
1.80 mike 755: <ol class="brief">
756:
757: <li>A <code>RowID</code> object identifying the row.</li>
1.1 mike 758:
759: <li>An integer giving the position of the row in its parent,
1.80 mike 760: given the current sort order, or −1 to set other row data
1.1 mike 761: without setting a position or changing a previously declared
762: position.</li>
763:
764: <li>An integer giving the number of children of the row, or 0 if
1.80 mike 765: the row has no children, or −1 if the row has children but
1.1 mike 766: the count is currently unknown. If the number of children has
767: already been set to 0 or a positive integer, then passing
1.80 mike 768: −1 leaves the previous count unchanged.</li>
1.1 mike 769:
770: <li>An array giving the data for zero or more cells in the row,
771: as described below.</li>
772:
773: <li>A boolean declaring whether the row is open or not. This
774: entry, if omitted, is assumed to be false (closed), unless the
775: row has already been declared as open.</li>
776:
777: <li>An integer giving the number of rows that are descendants of
778: this row, excluding those that are descendants of descendants of
779: this row that are closed. This entry can be omitted if the row is
780: closed or if it has already been declared.</li>
781:
1.80 mike 782: </ol>
783:
784: <p>The array giving the data for the cells in the row consists of
1.1 mike 785: a further set of arrays, one per cell. The first item of each of
786: these arrays is the column's identifier; the subsequent values
787: vary based on the type of the column, as follows:</p>
788:
1.80 mike 789: <dl>
790:
791: <dt><code title="datagrid-type-text">text</code></dt>
1.1 mike 792: <dd>
1.80 mike 793: <ol class="brief">
794: <li>A string giving the cell's value.
795: <li>Optionally, an <code>img</code> element giving an icon for the cell.
796: </ol>
797: </dd>
1.1 mike 798:
1.80 mike 799: <dt><code title="datagrid-type-editable">editable</code></dt>
1.1 mike 800: <dd>
1.80 mike 801: <ol class="brief">
802: <li>A string giving the cell's value.
803: <li>Optionally, a <code>datalist</code> element giving a set of predefined options.
804: <li>Optionally, an <code>img</code> element giving an icon for the cell.
805: </ol>
806: </dd>
1.1 mike 807:
1.80 mike 808: <dt><code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 809: <dd>
1.80 mike 810: <ol class="brief">
811: <li>A string giving the cell's value.
812: <li>A boolean, indicating whether the cell is checked (true) or not (false).
813: <li>Optionally, a boolean indicating whether the value of the cell is obscured as indeterminate (true), or not (false).
814: <li>Optionally, an <code>img</code> element giving an icon for the cell.
815: </ol>
816: </dd>
1.1 mike 817:
1.80 mike 818: <dt><code title="datagrid-type-list">list</code></dt>
1.1 mike 819: <dd>
1.80 mike 820: <ol class="brief">
821: <li>A string giving the cell's current value.
822: <li>A <code>select</code> element giving the <span title="concept-select-option-list">list of options</span>.
823: <li>Optionally, an <code>img</code> element giving an icon for the cell.
824: </ol>
825: </dd>
1.1 mike 826:
1.80 mike 827: <dt><code title="datagrid-type-progress">progress</code></dt>
1.1 mike 828: <dd>
1.80 mike 829: <ol class="brief">
830: <li>A value in the range 0.0 (no progress) to 1.0 (task complete).
831: </ol>
832: </dd>
1.1 mike 833:
1.80 mike 834: <dt><code title="datagrid-type-meter">meter</code></dt>
1.1 mike 835: <dd>
1.80 mike 836: <ol class="brief">
837: <li>A number giving the cell's value.
838: <li>Optionally, a number giving the maximum value, if it's not 1.
839: <li>Optionally, a number giving the minimum value, if it's not 0.
840: <li>Optionally, a number giving the highest value that is considered "low".
841: <li>Optionally, a number giving the lowest value that is considered "high".
842: <li>Optionally, a number giving the value that is considered optimal.
843: </ol>
844: </dd>
1.1 mike 845:
1.80 mike 846: <dt><code title="datagrid-type-custom">custom</code></dt>
1.1 mike 847: <dd>
1.80 mike 848: <ol class="brief">
849: <li>A number giving the minimum width of the cell, in CSS pixels, that is desired.
850: <li>A number giving the minimum height of the cell, in CSS pixels, that is desired.
851: <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.
852: </ol>
853: </dd>
854:
855: </dl>
1.1 mike 856:
1.80 mike 857: <p>While the rows in a single call to the <code
858: title="dom-datagrid-setRows">setRows()</code> method can be in any
1.1 mike 859: order, for each row, it is important that all its ancestor rows
860: and all its open previous siblings are also declared, either in
861: the same call or in an earlier one.</p>
862:
1.80 mike 863: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 864: arguments contradict each other or previously declared information
865: (e.g. saying that a row's position is 5 when the parent row only
866: has 3 children, or naming a column that doesn't exist, or
867: declaring a row without declaring its parent, or changing the
868: number of children that a row has while that row and its ancestors
869: are all open).</p>
870:
871: </dd>
872:
873:
1.80 mike 874: <dt><var title="">datagrid</var> . <code title="dom-datagrid-insertRows">insertRows</code>(<var title="">rows</var>)</dt>
1.1 mike 875: <dd>
876:
1.80 mike 877: <p>Inserts the given rows into the <code>datagrid</code>,
878: increasing the numbers of rows that the <code>datagrid</code>
1.1 mike 879: assumes are present.</p>
880:
881: <p>The <var title="">rows</var> argument is an array of rows in
1.80 mike 882: the same structure as the argument to the <code
883: title="dom-datagrid-setRows">setRows()</code> method described
1.1 mike 884: above, with the same expectations of consistency (a given row's
885: ancestors and earlier open siblings being listed either earlier or
1.80 mike 886: in the same call as a given row). However, unlike with the <code
887: title="dom-datagrid-setRows">setRows()</code> method, if a row is
1.1 mike 888: inserted along with its child, the child is not included in the
1.80 mike 889: child and row counts of the parent row; every row in the <var
890: title="">rows</var> argument will increase its parent's counts
1.1 mike 891: automatically.</p>
892:
1.80 mike 893: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 894: arguments contradict each other or previously declared
895: information.</p>
896:
897: </dd>
898:
899:
1.80 mike 900: <dt><var title="">datagrid</var> . <code title="dom-datagrid-deleteRows">deleteRows</code>(<var title="">rows</var>)</dt>
1.1 mike 901: <dd>
902:
1.80 mike 903: <p>Removes the given rows from the <code>datagrid</code>, and
1.1 mike 904: updates the number of rows known to be in the
1.80 mike 905: <code>datagrid</code> accordingly. The argument is an array of
906: <code>RowID</code> objects identifying the rows to remove.</p>
1.1 mike 907:
1.80 mike 908: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the argument
909: includes a row the <code>datagrid</code> doesn't know about.</p>
910: <!- - since otherwise behaviour might depend on where the user
911: scrolled! - ->
1.1 mike 912:
913: </dd>
914:
915:
1.80 mike 916: <dt><var title="">datagrid</var> . <code title="dom-datagrid-repaint">repaint</code>(<var title="">row</var>, <var title="">column</var>)</dt>
1.1 mike 917: <dd>
918:
1.80 mike 919: <p>If the given column's type is <code
920: title="datagrid-type-custom">custom</code>, then causes the
921: <code>datagrid</code> to reinvoke the function that obtains the
1.1 mike 922: desired rendering.</p>
923:
924: </dd>
925:
926:
1.80 mike 927: <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearRows">clearRows</code>()</dt>
1.1 mike 928: <dd>
929:
1.80 mike 930: <p>Clears the <code>datagrid</code> of all row data, resetting it
931: to empty<!- - v2DGS:, and clears the selection- ->.</p>
1.1 mike 932:
933: </dd>
934:
1.80 mike 935: </dl>
936:
937:
938: <div class="impl">
1.1 mike 939:
1.80 mike 940: <h6>The listener</h6>
1.1 mike 941:
1.80 mike 942: <p>The <dfn
1.186 mike 943: title="dom-datagrid-listener"><code>listener</code></dfn> IDL
1.1 mike 944: attribute allows authors to specify an object that will receive all
1.80 mike 945: the notifications from the <code>datagrid</code>. Initially, its
1.1 mike 946: value must be null. On getting, it must return its value. On
947: setting, its value must be set to the new value, and then the user
1.80 mike 948: agent must <span>queue a task</span> to call the <code
949: title="dom-listener-initialize">initialize()</code> method with the
950: <code>datagrid</code> element as its only argument.</p>
1.1 mike 951:
952:
1.80 mike 953: <h6>The columns</h6>
1.1 mike 954:
1.80 mike 955: <p>The columns are represented by the <dfn>column list</dfn>, an
1.1 mike 956: ordered list of entries for columns, each of which consists of:</p>
957:
1.80 mike 958: <dl>
959:
960: <dt>An identifier</dt>
1.1 mike 961:
962: <dd>A string used to identify the column in the API.</dd>
963:
964: <dt>A label</dt>
965:
966: <dd>A string used in the user interface.</dd>
967:
968: <dt>A type</dt>
969:
970: <dd>One of the types described below.</dd>
971:
972: <dt>An icon</dt>
973:
1.80 mike 974: <dd>An image, copied from an <code>img</code> element when the
1.1 mike 975: column was declared.</dd>
976:
977: <dt>Whether the column is sortable</dt>
978:
979: <dd>A boolean indicating whether the user can request that the data
980: be sorted by this column (true), or not (false).</dd>
981:
982: <dt>Whether the column is visible</dt>
983:
984: <dd>A boolean indicating whether the column is part of the
1.80 mike 985: <code>datagrid</code>'s rendering.</dd>
1.1 mike 986:
1.80 mike 987: </dl>
988:
989: <p>Initially, the <span>column list</span> must have a single
990: column, the <dfn>default column</dfn>, whose identifier is the empty
991: string, whose label is the empty string, whose type is <code
992: title="datagrid-type-text">text</code>, with no icon, which is not
1.1 mike 993: sortable, and which <em>is</em> visible.</p>
994:
1.80 mike 995: <hr>
996:
997: <p>The <dfn title="dom-datagrid-addColumn"><code>addColumn(<var
998: title="">id</var>, <var title="">label</var>, <var
999: title="">type</var>, <var title="">icon</var>, <var
1000: title="">sortable</var>, <var title="">hidden</var>)</code></dfn>
1.1 mike 1001: method must run the following steps:</p>
1002:
1.80 mike 1003: <ol>
1004:
1005: <li><p>If there is already an entry in <span>column list</span>,
1006: other than the <span>default column</span>, whose identifier is
1007: <var title="">id</var>, throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 1008: exception and abort these steps.</p></li>
1009:
1010: <li>
1011:
1012: <p>If <var title="">type</var> is not a string equal to one of the
1.80 mike 1013: <span>allowed <code>datagrid</code> column types</span>, then
1014: throw a <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1 mike 1015: steps.</p>
1016:
1017: </li>
1018:
1019: <li><p>If the <var title="">icon</var> argument is present and not
1.80 mike 1020: null, but the given <code>img</code> element's <code
1021: title="dom-img-complete">complete</code> attribute is false, then
1.1 mike 1022: let <var title="">icon</var> be null.</p></li>
1023:
1024: <li><p>If the <var title="">icon</var> argument is present and not
1.80 mike 1025: null, then copy the image data from that <code>img</code> element,
1.1 mike 1026: and let <var title="">image</var> be the copy of that image
1027: data. Otherwise, let <var title="">image</var> be nothing.</p></li>
1028:
1.80 mike 1029: <li><p>Append a new entry to the <span>column list</span>, with
1.1 mike 1030: <var title="">id</var> as its identifier, <var title="">label</var>
1.80 mike 1031: as its label, <var title="">type</var> as its type, and <var
1032: title="">image</var> as its icon. Let the column be sortable if the
1.1 mike 1033: <var title="">sortable</var> argument is present and true, and make
1034: it visible unless the <var title="">hidden</var> argument is
1035: present and true.</p></li>
1036:
1.80 mike 1037: <li><p>If the <span>column list</span> contains the <span>default
1038: column</span>, then remove the <span>default column</span> from the
1039: <span>column list</span>, discard any data for cells in that column
1040: in any rows in the <code>datagrid</code>, set <code
1041: title="dom-datagrid-sortColumn">sortColumn</code> to <var
1042: title="">id</var>, set <code
1043: title="dom-datagrid-sortAscending">sortAscending</code> to true,
1044: and run the <span><code>datagrid</code> resort
1045: steps</span>.</p></li>
1046:
1047: </ol>
1048:
1049: <hr>
1.1 mike 1050:
1.80 mike 1051: <p>The <dfn
1.186 mike 1052: title="dom-datagrid-sortColumn"><code>sortColumn</code></dfn> IDL
1.1 mike 1053: attribute gives the current column used for sorting. Initially, its
1054: value must be the empty string. On getting, it must return its
1055: current value. On setting, if the new value doesn't match the
1.80 mike 1056: identifier of one of the columns in the <span>column list</span>,
1057: then the user agent must throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 1058: exception. Otherwise, if the new value is not the same as its
1059: current value, then the user agent must set the attribute to the new
1.80 mike 1060: value, and then run the <span><code>datagrid</code> resort
1061: steps</span>.</p>
1.1 mike 1062:
1.80 mike 1063: <p>The <dfn
1064: title="dom-datagrid-sortAscending"><code>sortAscending</code></dfn>
1.186 mike 1065: IDL attribute specifies the direction that the tree is sorted in,
1.1 mike 1066: ascending (true) or descending (false). Initially, its value must be
1067: true (ascending). On getting, it must return its current value. On
1068: setting, if the new value is not the same as its current value, then
1069: the user agent must set the attribute to the new value, and then run
1.80 mike 1070: the <span><code>datagrid</code> resort steps</span>.</p>
1.1 mike 1071:
1072: <p>When a column is marked as being sortable, the user agent should
1073: allow the user to select that column to be the column used for
1074: sorting, and should allow the user to chose whether the sort order
1075: is ascending or descending.</p>
1076:
1077: <p>When the user changes the sort order in this manner, the user
1.80 mike 1078: agent must update the <code
1079: title="dom-datagrid-sortColumn">sortColumn</code> and <code
1080: title="dom-datagrid-sortAscending">sortAscending</code> attributes
1081: appropriately, and then run the <span><code>datagrid</code> resort
1082: steps</span>.</p>
1.1 mike 1083:
1.80 mike 1084: <p class="note">The <span><code>datagrid</code> resort steps</span>
1.1 mike 1085: are described in the next section.</p>
1086:
1.80 mike 1087: <hr>
1.1 mike 1088:
1.80 mike 1089: <p>The <dfn
1090: title="dom-datagrid-clearColumns"><code>clearColumns()</code></dfn>
1091: method, if the <span>column list</span> doesn't contain the
1092: <span>default column</span>, must empty the <span>column
1093: list</span>, append the <span>default column</span> to the now empty
1094: <span>column list</span>, discard any data for cells in all rows in
1095: the <code>datagrid</code>, set <code
1096: title="dom-datagrid-sortColumn">sortColumn</code> to the empty
1097: string, set <code
1098: title="dom-datagrid-sortAscending">sortAscending</code> to true, and
1099: run the <span><code>datagrid</code> resort steps</span>. (If the
1100: <span>column list</span> is already just the <span>default
1101: column</span>, then the method does nothing.)</p>
1.1 mike 1102:
1103:
1.80 mike 1104: <h6>The rows</h6>
1105:
1106: <p>A <code>datagrid</code> element is intended to show a
1.1 mike 1107: representation of a tree, where typically the user only sees a
1108: small part of the tree at a time.</p>
1109:
1.80 mike 1110: <p>To make this efficient, the <code>datagrid</code> element
1.1 mike 1111: <em>actually</em> shows a small part of a <em>sparse</em> tree, so
1112: that only relevant parts of the data structure need be loaded at any
1113: time. Specifically, the model requires only that all the ancestor
1114: rows of the displayed rows be loaded, as well as any open earlier
1115: siblings (in the displayed sort order) of the displayed rows.</p>
1116:
1.80 mike 1117: <p>Conceptually, therefore, a <code>datagrid</code> has a number of
1.1 mike 1118: related sparse data structures backing it.</p>
1119:
1.80 mike 1120: <p>The first is the <dfn>natural order sparse data tree</dfn>. This
1.1 mike 1121: is the structure in which rows are entered as they are declared, in
1122: their natural order. This can differ from the order actually
1123: displayed to the user. It consists of nested sparse lists of
1.80 mike 1124: rows. In the <span>natural order sparse data tree</span>, a row will
1.1 mike 1125: always have all its parents already declared. Once a row is added to
1.80 mike 1126: this structure, it can only be removed by the <code
1127: title="dom-datagrid-deleteRows">deleteRows()</code> and <code
1128: title="dom-datagrid-clearRows">clearRows()</code> methods. The order of
1.1 mike 1129: nodes in this tree never changes; to move a node in this tree, it
1130: has to be removed and then another row (with the same data)
1131: reinserted elsewhere.</p>
1132:
1.80 mike 1133: <p>The second structure is the <dfn>display order sparse data
1.1 mike 1134: tree</dfn>. This is a similar structure that contains a subset of
1.80 mike 1135: the rows in the <span>natural order sparse data tree</span>, ordered
1136: in the order given by the <code
1137: title="dom-datagrid-sortAscending">sortAscending</code> and <code
1138: title="dom-datagrid-sortColumn">sortColumn</code> attributes, and
1.1 mike 1139: excluding rows with one or more ancestors that are closed. This tree
1.80 mike 1140: is cleared whenever the <code
1141: title="dom-datagrid-sortAscending">sortAscending</code> and <code
1142: title="dom-datagrid-sortColumn">sortColumn</code> attributes
1.1 mike 1143: change.</p>
1144:
1.80 mike 1145: <p>The third structure is the <dfn>display order sparse data
1.1 mike 1146: list</dfn>. This structure is a flattened representation of the
1.80 mike 1147: <span>display order sparse data tree</span>.</p>
1.1 mike 1148:
1.80 mike 1149: <p>At any time, a number of consecutive rows in the <span>display
1150: order sparse data list</span> are physically visible to the
1151: user. The <code>datagrid</code> fires notifications to a <span
1152: title="dom-datagrid-listener">listener</span> (provided by script),
1.1 mike 1153: and the listener, or other some script, is expected to feed the
1.80 mike 1154: <code>datagrid</code> with the information needed to render the
1.1 mike 1155: control.</p>
1156:
1.80 mike 1157: <p>A <code>datagrid</code> has a <dfn>pending <code>datagrid</code>
1158: rows list</dfn>, which is a list of rows in the <span>display order
1159: sparse data list</span> for which the <code>datagrid</code> has sent
1.1 mike 1160: notifications requesting information but not yet received
1161: information about.</p>
1162:
1.80 mike 1163: <p>A <code>datagrid</code> also has a <dfn>pending
1.1 mike 1164: <code>datagrid</code> <em>cells</em> list</dfn>, which is a list of
1.80 mike 1165: row/column pairs (cells) for which the <code>datagrid</code> has
1.1 mike 1166: sent notifications requesting information but not yet received
1167: information about.</p>
1168:
1169: <p>User agents may discard information about rows that are not
1170: displayed and that are not ancestors or open earlier siblings of
1171: rows or ancestors of rows that are displayed.</p>
1172:
1.80 mike 1173: <hr>
1174:
1175: <p>These structures are different views of the collection of rows
1176: that form the <code>datagrid</code>. Each row has the following
1.1 mike 1177: information associated with it:</p>
1178:
1.80 mike 1179: <dl>
1180:
1181: <dt>A parent</dt>
1.1 mike 1182:
1.80 mike 1183: <dd><p>Either another row, or the <code>datagrid</code> itself. This
1184: is the parent of the row in the <span>natural order sparse data
1185: tree</span> and the <span>display order sparse data tree</span>
1186: for the <code>datagrid</code>.</p></dd>
1.1 mike 1187:
1188: <dt>A natural order position relative to the other rows with the
1189: same parent</dt>
1190:
1191: <dd>
1192:
1193: <p>This is the number of rows that precede this row under the same
1.80 mike 1194: parent in the <span>natural order sparse data tree</span>. This
1.1 mike 1195: number can't be changed relative to other rows in the same parent;
1196: to change the relative natural order of data in the
1.80 mike 1197: <code>datagrid</code>, the original rows have to be removed and
1.1 mike 1198: new rows (with the same data but different natural positions)
1199: inserted in their place. (The exact number of a row can change, as
1200: new rows can be inserted above it.)</p>
1201:
1.80 mike 1202: <p>A row can be identified by a <code>RowID</code> object. This is
1.1 mike 1203: an array of numbers, consisting of the natural order positions of
1204: each ancestor row and the row itself, starting from the furthest
1205: ancestor. Thus, for instance, the fourth child row of the first
1.80 mike 1206: child row of the second row in a <code>datagrid</code> would be
1207: identified by a <code>RowID</code> object whose value is <code
1208: title="">[1, 0, 3]</code>. A row's identifier changes if rows are
1209: <span title="dom-datagrid-insertRows">inserted before it</span> in
1210: the <code>datagrid</code>.</p>
1.1 mike 1211:
1212: </dd>
1213:
1214: <dt>A display order position relative to the other rows with
1215: the same parent</dt>
1216:
1217: <dd><p>This is the number of rows that precede this row under the
1.80 mike 1218: same parent in the <span>display order sparse data
1219: tree</span>. This number can be unknown. If the sort order
1220: changes, then this information is lost (as the <span>display order
1221: sparse data tree</span> is cleared).</p></dd>
1.1 mike 1222:
1223: <dt>A child count</dt>
1224:
1225: <dd><p>The number of rows that have this row as a parent. If this is
1.80 mike 1226: zero, the row cannot be opened. If this is −1, then the
1.1 mike 1227: child count is unknown but the row can be opened. This value can be
1.80 mike 1228: changed by the <code title="dom-datagrid-setRows">setRows()</code>
1229: method only if the current value is −1 or if the row or one
1.1 mike 1230: of its ancestors is closed. Otherwise, it can only be changed
1.80 mike 1231: indirectly using the <code
1232: title="dom-datagrid-insertRows">insertRows()</code> and <code
1233: title="dom-datagrid-deleteRows">deleteRows()</code> methods.</p></dd>
1.1 mike 1234:
1235: <dt>An open flag</dt>
1236:
1237: <dd><p>A boolean indicating whether the row is open (true) or
1238: closed (false). Once set, the flag can only be changed by the user
1239: or while one of the row's ancestors is itself closed. A row can
1240: also be in a third state, "opening", which is treated as closed for
1241: all purposes except that the user agent may indicate that the row
1242: is in this special state, and except that when the row is updated
1243: to have a row count, the row will switch to being open.</p></dd>
1244:
1245: <dt>A row count</dt>
1246:
1247: <dd><p>The number of rows that have this row as a parent or
1248: ancestor, and that do not have an ancestor that is a descendant of
1.80 mike 1249: this row that is itself closed. If this is −1, then the row
1250: count is unknown. This value can be changed by the <code
1251: title="dom-datagrid-setRows">setRows()</code> method only if the
1.1 mike 1252: row or one of its ancestors is closed (or opening, but not
1.80 mike 1253: open). Otherwise, it can only be changed indirectly using the <code
1254: title="dom-datagrid-insertRows">insertRows()</code> and <code
1255: title="dom-datagrid-deleteRows">deleteRows()</code>
1.1 mike 1256: methods.</p></dd>
1257:
1258: <dt>Cells</dt>
1259:
1260: <dd><p>The data that applies to this row. Cell data is discussed in
1261: more detail below.</p></dd>
1262:
1.80 mike 1263: </dl>
1264:
1265: <p>The <code>datagrid</code> itself also has a <dfn title="datagrid
1266: child count">child count</dfn> and a <dfn title="datagrid row
1.1 mike 1267: count">row count</dfn>, which are analogous to the child counts and
1268: row counts for rows. Initially, these must be zero.</p>
1269:
1.80 mike 1270: <hr>
1271:
1272: <p>The <dfn><code>datagrid</code> resort steps</dfn>, which are
1.1 mike 1273: invoked when the sort order changes as described in the previous
1274: section, are as follows:</p>
1275:
1.80 mike 1276: <ol>
1.1 mike 1277:
1.80 mike 1278: <li>
1279:
1280: <p>Clear the <span>display order sparse data tree</span>
1.1 mike 1281: (i.e. mark the display order position of all the rows in the
1.80 mike 1282: <code>datagrid</code> as unknown).</p>
1.1 mike 1283:
1284: <p>User agents may cache the position information of rows for
1.80 mike 1285: various values of <code
1286: title="dom-datagrid-sortColumn">sortColumn</code> and <code
1287: title="dom-datagrid-sortAscending">sortAscending</code>, instead
1.1 mike 1288: of discarding the information altogether. If the user agent caches
1289: this information, and has information that applies to the current
1.80 mike 1290: values of <code title="dom-datagrid-sortColumn">sortColumn</code>
1291: and <code title="dom-datagrid-sortAscending">sortAscending</code>,
1292: then the user agent may repopulate the <span>display order sparse
1293: data tree</span> from this information.</p>
1.1 mike 1294:
1295: </li>
1296:
1297: <li>
1298:
1.80 mike 1299: <p>Clear the <span>pending <code>datagrid</code> rows list</span>
1300: and the <span>pending <code>datagrid</code> cells list</span>.</p>
1.1 mike 1301:
1302: </li>
1303:
1304: <li>
1305:
1.80 mike 1306: <p>Invoke the <span><code>datagrid</code> update display
1307: algorithm</span>.</p>
1.1 mike 1308:
1309: </li>
1310:
1.80 mike 1311: <!- - v2: queue a task to fire an event, or tell the listener the
1312: sort order changed, or something - ->
1313:
1314: </ol>
1.1 mike 1315:
1.80 mike 1316: <hr>
1.1 mike 1317:
1.80 mike 1318: <p>The <dfn
1319: title="dom-datagrid-renotify"><code>renotify()</code></dfn> method
1320: must empty the <span>pending <code>datagrid</code> rows list</span>
1321: and the <span>pending <code>datagrid</code> cells list</span>, and
1322: invoke the <span><code>datagrid</code> update display
1323: algorithm</span>.</p>
1324:
1325: <hr>
1326:
1327: <p>The <dfn title="dom-datagrid-setRowCount"><code>setRowCount(<var
1328: title="">childCount</var>, <var
1329: title="">rowCount</var>)</code></dfn> method must run the following
1.1 mike 1330: steps:</p>
1331:
1.80 mike 1332: <ol>
1.1 mike 1333:
1.80 mike 1334: <li>
1335:
1336: <p>Set the <span><code>datagrid</code> child count</span> to <var
1337: title="">childCount</var>, the <span><code>datagrid</code> row
1338: count</span> to <var title="">rowCount</var>.</p>
1.1 mike 1339:
1340: </li>
1341:
1342: <li>
1343:
1.80 mike 1344: <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1 mike 1345: then revert the changes made in the previous step, throw a
1.80 mike 1346: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1347: steps.</p>
1348:
1349: </li>
1350:
1351: <li>
1352:
1.80 mike 1353: <p>Invoke the <span><code>datagrid</code> update display
1354: algorithm</span>.</p>
1.1 mike 1355:
1356: </li>
1357:
1.80 mike 1358: </ol>
1359:
1360: <hr>
1361:
1362: <p>The <dfn title="dom-datagrid-setRows"><code>setRows(<var
1363: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1364: steps:</p>
1365:
1.80 mike 1366: <ol>
1.1 mike 1367:
1.80 mike 1368: <li>
1369:
1370: <p><span title="type-check a RowList object">Type-check the <var
1371: title="">rows</var> argument</span>. If this fails, throw a
1.1 mike 1372: <code>TypeError</code> exception, and abort these steps.</p>
1373:
1374: </li>
1375:
1376: <li>
1377:
1.80 mike 1378: <p><span title="partially sort a RowList object">Partially sort
1379: the <var title="">rows</var> argument</span>.</p>
1.1 mike 1380:
1381: </li>
1382:
1383: <li>
1384:
1.80 mike 1385: <p>For each <code>Row</code> object in the <var
1386: title="">rows</var> argument, in order, perform the appropriate
1.1 mike 1387: steps from the list below.</p>
1388:
1.80 mike 1389: <p class="note">The changes made to the <code>datagrid</code>'s
1.1 mike 1390: data structures in this step get reverted (as required below) if
1391: any consistency errors are detected either in this step or the
1392: next.</p>
1393:
1.80 mike 1394: <dl>
1395:
1396: <dt>If there already exists a row in the <code>datagrid</code>'s
1397: <span>natural order sparse data tree</span> with the same
1398: identifier as given by the <code>Row</code> object's
1399: <code>RowID</code> object, and that row and all its ancestors are
1.1 mike 1400: open</dt>
1401:
1402: <dd>
1403:
1404: <p>If one of the following conditions is true, then revert all
1405: the changes done in this step, throw a
1.80 mike 1406: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1407: steps:</p>
1408:
1.80 mike 1409: <ul>
1410:
1411: <li>The value of the <code>Row</code> object's second entry is
1412: neither −1 nor equal to the child count of the
1.1 mike 1413: preexisting row.</li>
1414:
1.80 mike 1415: <li>The <code>Row</code> object has fewer than four
1.1 mike 1416: entries or more than six entries.</li>
1417:
1.80 mike 1418: <li>The <code>Row</code> object has five or more entries, and
1.1 mike 1419: its fifth entry is false.</li>
1420:
1.80 mike 1421: <li>The <code>Row</code> object has six entries, and its sixth
1.1 mike 1422: entry is not equal to the row count of the preexisting
1423: row.</li>
1424:
1.80 mike 1425: </ul>
1426:
1427: </dd>
1.1 mike 1428:
1.80 mike 1429: <dt>If there already exists a row in the <code>datagrid</code>'s
1430: <span>natural order sparse data tree</span> with the same
1431: identifier as given by the <code>Row</code> object's
1432: <code>RowID</code> object, but either that row or one of its
1.1 mike 1433: ancestors is closed</dt>
1434:
1435: <dd>
1436:
1437: <p>Set the preexisting row's child count to the value of the
1.80 mike 1438: <code>Row</code> object's second entry.</p>
1.1 mike 1439:
1.80 mike 1440: <p>If the <code>Row</code> object has five or more entries, and
1.1 mike 1441: either its fifth entry is true and the preexisting row is closed
1442: but not opening, or its fifth entry is false and the preexisting
1443: row is open, then: if the preexisting row has no ancestor row
1444: that is closed, then revert all the changes done in this step,
1.80 mike 1445: throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1 mike 1446: these steps; otherwise, if the fifth entry is false, then close
1447: the row; otherwise, open the row.</p>
1448:
1.80 mike 1449: <p>If the <code>Row</code> object has six entries, set the
1450: preexisting row's row count to the value of the <code>Row</code>
1.1 mike 1451: object's sixth entry.</p>
1452:
1453: <p>If the preexisting row is opening, then: increase the
1.80 mike 1454: <span><code>datagrid</code> row count</span> and the row counts
1.1 mike 1455: of any ancestor rows by the number of rows that the preexisting
1.80 mike 1456: row now has in its row count, then open the row.</p> <!- - we
1.1 mike 1457: should also "update the <span>pending <code>datagrid</code> rows
1458: list</span> and the <span>pending <code>datagrid</code> cells
1.80 mike 1459: list</span> accordingly" - ->
1.1 mike 1460:
1461:
1462: </dd>
1463:
1.80 mike 1464: <dt>There does not exist a row in the <code>datagrid</code>'s
1465: <span>natural order sparse data tree</span> with the same
1466: identifier as given by the <code>Row</code> object's
1467: <code>RowID</code> object</dt>
1.1 mike 1468:
1469: <dd>
1470:
1.80 mike 1471: <p>If the <code>RowID</code> object has a length greater than 1,
1.1 mike 1472: then verify that there is a row identified by the
1.80 mike 1473: <code>RowID</code> consisting of all but the last number in the
1474: <code>Row</code> object's <code>RowID</code>. If there is no
1475: such row present in the <span>natural order sparse data
1476: tree</span>, then revert all the changes done in this step,
1477: throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1 mike 1478: these steps.</p>
1479:
1.80 mike 1480: <p>Create a row and insert it into the <span>natural order
1481: sparse data tree</span>, such that its parent is the row
1482: identified by the <code>RowID</code> consisting of all but the
1483: last number in the <code>Row</code> object's <code>RowID</code>,
1484: or the <code>datagrid</code> if the length of the
1485: <code>Row</code> object's <code>RowID</code> is 1; with its
1.1 mike 1486: natural order position being the last number of the
1.80 mike 1487: <code>Row</code> object's <code>RowID</code>; with the child
1488: count being the value of the third entry of the <code>Row</code>
1.1 mike 1489: object; with the row being marked closed unless the
1.80 mike 1490: <code>Row</code> object has five or more entries and its fifth
1.1 mike 1491: entry is true, in which case the row is open; and with its row
1.80 mike 1492: count being −1 unless the <code>Row</code> object has six
1.1 mike 1493: entries, in which case the row count is equal to the value of
1.80 mike 1494: the <code>Row</code> object's sixth entry.</p>
1.1 mike 1495:
1496: </dd>
1497:
1.80 mike 1498: </dl>
1499:
1500: </li>
1.1 mike 1501:
1502: <li>
1503:
1.80 mike 1504: <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1 mike 1505: then revert the changes made in the previous step, throw a
1.80 mike 1506: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1507: steps.</p>
1508:
1509: </li>
1510:
1511: <li>
1512:
1.80 mike 1513: <p>For each <code>Row</code> object in the <var
1514: title="">rows</var> argument, in order, <span title="apply a Row
1515: object">apply the <code>Row</code> object</span>.</p>
1.1 mike 1516:
1517: </li>
1518:
1519: <li>
1520:
1.80 mike 1521: <p>Invoke the <span><code>datagrid</code> update display
1522: algorithm</span>.</p>
1.1 mike 1523:
1524: </li>
1525:
1.80 mike 1526: </ol>
1527:
1528: <hr>
1529:
1530: <p>The <dfn title="dom-datagrid-insertRows"><code>insertRows(<var
1531: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1532: steps:</p>
1533:
1.80 mike 1534: <ol>
1535:
1536: <li>
1.1 mike 1537:
1.80 mike 1538: <p><span title="type-check a RowList object">Type-check the <var
1539: title="">rows</var> argument</span>. If this fails, throw a
1.1 mike 1540: <code>TypeError</code> exception, and abort these steps.</p>
1541:
1542: </li>
1543:
1544: <li>
1545:
1.80 mike 1546: <p><span title="partially sort a RowList object">Partially sort
1547: the <var title="">rows</var> argument</span>.</p>
1.1 mike 1548:
1549: </li>
1550:
1551: <li>
1552:
1.80 mike 1553: <p>For each <code>Row</code> object in the <var
1554: title="">rows</var> argument, in order, run the following
1.1 mike 1555: steps:</p>
1556:
1.80 mike 1557: <p class="note">The changes made to the <code>datagrid</code>'s
1.1 mike 1558: data structures in this step get reverted (as required below) if
1559: any consistency errors are detected either in this step or the
1560: next.</p>
1561:
1.80 mike 1562: <ol>
1563:
1564: <li>
1.1 mike 1565:
1566: <p>Let <var title="">parent</var> be the row identified by the
1.80 mike 1567: <code>RowID</code> consisting of all but the last number in the
1568: <code>Row</code> object's <code>RowID</code>, or the
1569: <code>datagrid</code> itself if the <code>Row</code> object's
1570: <code>RowID</code> has length 0.</p>
1571:
1572: <p>If there is no such row present in the <span>natural order
1573: sparse data tree</span>, then revert all the changes done in
1574: this algorithm, throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 1575: exception, and abort these steps.</p>
1576:
1577: </li>
1578:
1579: <li>
1580:
1581: <p>Increment by one the natural order position of all rows whose
1582: parent is <var title="">parent</var> and whose natural order
1583: position is equal to or greater than the last number of the
1.80 mike 1584: <code>Row</code> object's <code>RowID</code>.</p>
1.1 mike 1585:
1586: </li>
1587:
1588: <li>
1589:
1.80 mike 1590: <p>If the value of the <code>Row</code> object's second entry is
1591: not −1, then increment by one the display order position
1.1 mike 1592: of all rows whose parent is <var title="">parent</var> and whose
1593: display order position is equal to or greater than the value of
1.80 mike 1594: the <code>Row</code> object's second entry.</p>
1.1 mike 1595:
1.80 mike 1596: <!- -(Not sure how to really say this.)
1.1 mike 1597: <p>Update the <span>pending <code>datagrid</code> rows
1598: list</span> and the <span>pending <code>datagrid</code> cells
1599: list</span> accordingly.</p>
1.80 mike 1600: - ->
1.1 mike 1601:
1602: </li>
1603:
1604: <li>
1605:
1.80 mike 1606: <p>Create a row and insert it into the <span>natural order
1607: sparse data tree</span>, such that its parent is <var
1608: title="">parent</var>; with its natural order position being the
1609: last number of the <code>Row</code> object's <code>RowID</code>;
1.1 mike 1610: with the child count being the value of the third entry of the
1.80 mike 1611: <code>Row</code> object; with the row being marked closed unless
1612: the <code>Row</code> object has five or more entries and its
1.1 mike 1613: fifth entry is true, in which case the row is open; and with its
1.80 mike 1614: row count being −1 unless the <code>Row</code> object has
1.1 mike 1615: six entries, in which case the row count is equal to the value
1.80 mike 1616: of the <code>Row</code> object's sixth entry.</p>
1.1 mike 1617:
1618: </li>
1619:
1.80 mike 1620: </ol>
1621:
1622: </li>
1.1 mike 1623:
1624: <li>
1625:
1.80 mike 1626: <p>For each <code>Row</code> object in the <var
1627: title="">rows</var> argument, in order, <span title="apply a Row
1628: object">apply the <code>Row</code> object</span>.</p>
1.1 mike 1629:
1630: </li>
1631:
1632: <li>
1633:
1.80 mike 1634: <p>Invoke the <span><code>datagrid</code> update display
1635: algorithm</span>.</p>
1.1 mike 1636:
1637: </li>
1638:
1.80 mike 1639: </ol>
1640:
1641: <hr>
1642:
1643: <p>When an algorithm requires the user agent to <dfn>type-check a
1.1 mike 1644: <code>RowList</code> object</dfn> (an array), each entry in the
1645: object must be checked against the following requirements. If any
1646: are false, then the type-check fails, otherwise it passes.</p>
1647:
1.80 mike 1648: <ul>
1649:
1650: <li><p>The entry is a <code>Row</code> object (an
1.1 mike 1651: array).</p></li>
1652:
1.80 mike 1653: <li><p>The first value in the <code>Row</code> is a
1654: <code>RowID</code> object (also an array), whose length is at least
1.1 mike 1655: 1, and whose values are all integers greater than or equal to
1656: zero.</p></li>
1657:
1.80 mike 1658: <li><p>The numbers in the <code>RowID</code> object do not exactly
1659: match any of the other entries in the <code>RowList</code> object
1660: (i.e. no two <code>Row</code> objects have the same
1.1 mike 1661: identifier).</p></li>
1662:
1.80 mike 1663: <li><p>The second value in the <code>Row</code> is an integer that
1664: is either −1, zero, or a positive integer.</p></li>
1.1 mike 1665:
1.80 mike 1666: <li><p>The third value in the <code>Row</code> is an integer that
1667: is either −1, zero, or a positive integer.</p></li>
1.1 mike 1668:
1.80 mike 1669: <li><p>The fourth value in the <code>Row</code> is a
1670: <code>CellList</code> object (yet another array).</p></li>
1.1 mike 1671:
1.80 mike 1672: <li><p>Each entry in the <span>CellList</span> object is a
1673: <code>Cell</code> object (again, an array).</p></li>
1.1 mike 1674:
1.80 mike 1675: <li><p>Each <code>Cell</code> object in the <span>CellList</span>
1676: object has as its first value a <code>Column</code> object (a
1.1 mike 1677: string), and its value is the identifier of one of the columns in
1.80 mike 1678: the <span>column list</span>.</p></li>
1.1 mike 1679:
1680: <li>
1681:
1.80 mike 1682: <p>Each <code>Cell</code> object in the <span>CellList</span>
1.1 mike 1683: object has as its second and subsequent entries values that match
1684: the following requirements, as determined by the type of the
1685: column identified by the first entry:</p>
1686:
1.80 mike 1687: <dl>
1688:
1689: <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1 mike 1690: <dd>
1691:
1692: <p>The second entry's value is a string, and either there are
1693: only two entries, or there are three, and the third entry is
1.80 mike 1694: an <code>img</code> element.</p>
1.1 mike 1695:
1.80 mike 1696: <p>If there is an <code>img</code> element specified, its <code
1697: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1698:
1699: </dd>
1700:
1.80 mike 1701: <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1 mike 1702: <dd>
1703:
1704: <p>The second entry's value is a string, and either there are
1705: only two entries, or the third entry is a
1.80 mike 1706: <code>datalist</code> element, and either there are only three
1.1 mike 1707: entries, or there are four, and the fourth entry is an
1.80 mike 1708: <code>img</code> element.</p>
1.1 mike 1709:
1.80 mike 1710: <p>If there is an <code>img</code> element specified, its <code
1711: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1712:
1713: </dd>
1714:
1.80 mike 1715: <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 1716: <dd>
1717:
1718: <p>The second entry's value is a string, the third entry is a
1719: boolean, and either there are only three entries, or the
1720: fourth entry is also a boolean, and either there are only four
1721: entries, or there are five, and the fifth entry is an
1.80 mike 1722: <code>img</code> element.</p>
1.1 mike 1723:
1.80 mike 1724: <p>If there is an <code>img</code> element specified, its <code
1725: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1726:
1727: </dd>
1728:
1.80 mike 1729: <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1 mike 1730: <dd>
1731:
1732: <p>The second entry's value is a string, the third entry is a
1.80 mike 1733: <code>select</code> element, and either there are only three
1.1 mike 1734: entries, or there are four, and the fourth entry is an
1.80 mike 1735: <code>img</code> element.</p>
1.1 mike 1736:
1.80 mike 1737: <p>If there is an <code>img</code> element specified, its <code
1738: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1739:
1740: </dd>
1741:
1.80 mike 1742: <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1 mike 1743: <dd>
1744:
1745: <p>There are only two entries, the second entry's value is a
1746: number, and the number's value is between 0.0 and 1.0
1747: inclusive.</p>
1748:
1749: </dd>
1750:
1.80 mike 1751: <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1 mike 1752: <dd>
1753:
1754: <p>There are at least two, but possibly up to seven, entries,
1755: all entries but the first one are numbers, and the following
1756: relationships hold:</p>
1757:
1.80 mike 1758: <ul class="brief">
1759:
1760: <li>The second entry is less than the third, or less than 1.0
1.1 mike 1761: if the third is absent.</li>
1762:
1763: <li>The second entry is greater than the fourth, or greater
1764: than 0.0 if the fourth is absent.</li>
1765:
1766: <li>If there are at least three entries, the third entry is
1767: greater than the fourth, or greater than zero if the fourth
1768: is absent.</li>
1769:
1770: <li>If there are at least five entries, the fifth is not
1771: greater than the third and not less than the fourth.</li>
1772:
1773: <li>If there are at least six entries, the sixth is not
1774: greater than the third and not less than the fifth.</li>
1775:
1776: <li>If there are at least seven entries, the fifth is not
1777: greater than the third and not less than the fourth.</li>
1778:
1.80 mike 1779: </ul>
1.1 mike 1780:
1.80 mike 1781: </dd>
1782:
1783: <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1 mike 1784: <dd>
1785:
1786: <p>There are four entries, the second and third are numbers
1787: that are integers greater than zero, and the fourth is a
1788: <code>Rendering2DContextCallback</code> object (a
1789: function).</p>
1790:
1791: </dd>
1792:
1.80 mike 1793: </dl>
1794:
1795: </li>
1.1 mike 1796:
1.80 mike 1797: <li><p>Either there are only four values in the <code>Row</code>,
1798: or the fifth value in the <code>Row</code> is a boolean.</p></li>
1.1 mike 1799:
1800: <li><p>Either there are only four or five values in the
1.80 mike 1801: <code>Row</code>, or there are six, and the sixth value in the
1802: <code>Row</code> an integer that is greater than or equal to
1.1 mike 1803: zero.</p></li>
1804:
1.80 mike 1805: </ul>
1806:
1807: <p>Where the above requirements say that a value is to be a string,
1.718 mike 1808: the user agent must apply the ToString() abstract operation to the
1.1 mike 1809: value, assume that the value was indeed a string, and use the result
1810: in the rest of the algorithm as if it had that had been the value
1.98 mike 1811: passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1812:
1813: <p>Where the above requirements say that a value is to be a number,
1.718 mike 1814: the user agent must first apply the ToNumber() abstract operation
1.60 mike 1815: to the value, and then verify that the result is neither an Infinity
1816: value nor a Not-a-Number (NaN) value. If this result is indeed
1817: acceptable (i.e. finite), the user agent must use the result in the
1818: rest of the algorithm as if it had that had been the value passed to
1.98 mike 1819: the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1820:
1821: <p>Where the above requirements say that a value is to be an
1.718 mike 1822: integer, the user agent must first apply the ToNumber() abstract
1823: operation to the value, and then verify that the result is a finite
1.1 mike 1824: integer. If so, the user agent must use the result in the rest of
1825: the algorithm as if it had that had been the value passed to the
1.98 mike 1826: method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1827:
1828: <p>Where the above requirements say that a value is to be a boolean,
1.718 mike 1829: the user agent must apply the ToBoolean() abstract operation to the
1.1 mike 1830: value, assume that the value was indeed a boolean, and use the
1831: result in the rest of the algorithm as if it had that had been the
1.98 mike 1832: value passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.80 mike 1833:
1834: <hr>
1.1 mike 1835:
1.80 mike 1836: <p>When an algorithm requires the user agent to <dfn>audit the
1837: <code>datagrid</code></dfn>, the <code>datagrid</code> must be
1.1 mike 1838: checked against the following requirements. If any are false, then
1839: the audit fails, otherwise it passes.</p>
1840:
1.80 mike 1841: <ul>
1842:
1843: <li>There is no row whose natural order position is greater than or
1844: equal to the child count of its parent row in the <span>natural
1845: order sparse data tree</span>.</li>
1.1 mike 1846:
1847: <li>There is no row whose display order position is greater than or
1.80 mike 1848: equal to the child count of its parent row in the <span>display
1849: order sparse data tree</span>.</li>
1.1 mike 1850:
1851: <li>There is no row such that the sum of that row's child count and
1852: the row counts all the open rows that are direct children of that
1.80 mike 1853: row in the <span>natural order sparse data tree</span> is less than
1.1 mike 1854: that row's row count.</li>
1855:
1856: <li>Of the rows whose child count is equal to the number of rows
1.80 mike 1857: that are direct children of that row in the <span>natural order
1858: sparse data tree</span>, there is none such that the sum of that
1.1 mike 1859: row's child count and the row counts of all the open rows that are
1.80 mike 1860: direct children of that row in the <span>natural order sparse data
1861: tree</span> is greater than that row's row count.</li>
1862:
1863: </ul>
1.1 mike 1864:
1.80 mike 1865: <p>For the purposes of this audit, the <code>datagrid</code> must be
1.1 mike 1866: treated as the parent row of all the rows that are direct children
1.80 mike 1867: of the <code>datagrid</code> in the <span>natural order sparse data
1868: tree</span> and the <span>display order sparse data tree</span>. The
1869: child count of this implied row is the <span><code>datagrid</code>
1870: child count</span>, and the row count of this implied row is the
1871: <span><code>datagrid</code> row count</span>.</p>
1872:
1873: <hr>
1.1 mike 1874:
1.80 mike 1875: <p>When an algorithm requires the user agent to <dfn>partially sort
1.1 mike 1876: a <code>RowList</code> object</dfn> (an array), the entries in the
1.80 mike 1877: object must be resorted such that <code>Row</code> objects are
1.1 mike 1878: listed after any of their ancestors and after any of their earlier
1.80 mike 1879: siblings. In other words, for any two <code>Row</code> objects <var
1880: title="">a</var> and <var title="">b</var> in the
1881: <code>RowList</code>, where <var title="">a</var> is before <var
1882: title="">b</var> after the sort, the following conditions must
1.1 mike 1883: hold:</p>
1884:
1.80 mike 1885: <ul>
1886:
1887: <li><p>If their <code>RowID</code> objects are the same length and
1.1 mike 1888: have values that are equal except for the last value, then the last
1.80 mike 1889: value of <var title="">a</var>'s <code>RowID</code>'s last value
1890: must be less than <var title="">b</var>'s <code>RowID</code>'s last
1.1 mike 1891: value (i.e. earlier siblings must come before their later
1892: siblings).</p></li>
1893:
1.80 mike 1894: <li><p>If their <code>RowID</code> objects are not the same length,
1.1 mike 1895: but the values in the shorter of the two are the same as the first
1896: few values in the longer one, then <var title="">a</var>'s
1.80 mike 1897: <code>RowID</code> must be the shorter one (i.e. ancestors must
1.1 mike 1898: come before their descendants).</p></li>
1899:
1.80 mike 1900: </ul>
1901:
1902: <hr>
1903:
1904: <p>The <dfn title="dom-datagrid-deleteRows"><code>deleteRows(<var
1905: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1906: steps:</p>
1907:
1.80 mike 1908: <ol>
1909:
1910: <li>
1.1 mike 1911:
1912: <p>If any of the entries in <var title="">rows</var> are not
1.80 mike 1913: <code>RowID</code> objects consisting of one or more entries whose
1.1 mike 1914: values are all integers that are greater than or equal to zero,
1915: then throw a <code>TypeError</code> exception and abort these
1916: steps.</p>
1917:
1918: <p>To check if a value is an integer, the user agent must first
1.718 mike 1919: apply the ToNumber() abstract operation to the value, and then
1.1 mike 1920: verify that the result is a finite integer. If so, the user agent
1921: must use the result in the rest of the algorithm as if it had that
1.80 mike 1922: had been the value passed to the method. <a
1.98 mike 1923: href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1924:
1925: </li>
1926:
1927: <li>
1928:
1.80 mike 1929: <p>If any of the <code>RowID</code> objects in the <var
1930: title="">rows</var> argument identify a row that isn't present in
1931: the <span>natural order sparse data tree</span>, then throw a
1932: <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1 mike 1933: steps.</p>
1934:
1935: </li>
1936:
1937: <li>
1938:
1939: <p>If any row is listed twice in the <var title="">rows</var>
1.80 mike 1940: argument, then throw a <code>DATAGRID_MODEL_ERR</code> exception
1.1 mike 1941: and abort these steps.</p>
1942:
1943: </li>
1944:
1945: <li>
1946:
1947: <p>Sort the <var title="">rows</var> argument such that the
1948: entries are given in the same order as the rows they identify
1949: would be visited in a pre-order, depth first traversal of the
1.80 mike 1950: <span>natural order sparse data tree</span>.</p>
1.1 mike 1951:
1952: </li>
1953:
1954: <li>
1955:
1956: <p>For each row identified by entries in <var title="">rows</var>,
1957: <em>in reverse order</em>, run the following steps:</p>
1958:
1.80 mike 1959: <ol>
1960:
1961: <li>
1.1 mike 1962:
1963: <p>Decrement the child count of the row's parent row, if that
1964: child count is greater than zero. If the row has no parent,
1.80 mike 1965: decrement the <span><code>datagrid</code> child
1966: count</span>.</p>
1.1 mike 1967:
1968: <p>If the row has a parent row, and its child count is now zero,
1969: then close that row.</p>
1970:
1971: </li>
1972:
1973: <li>
1974:
1975: <p>Let <var title="">delta</var> be one more than the row's row
1976: count if the row is open and its row count is greater than zero;
1977: otherwise, let <var title="">delta</var> be one.</p>
1978:
1979: </li>
1980:
1981: <li>
1982:
1983: <p>Let <var title="">ancestor</var> be the row.</p>
1984:
1985: </li>
1986:
1987: <li>
1988:
1989: <p><i>Row count loop</i>: Let <var title="">ancestor</var> be
1990: <var title="">ancestor</var>'s parent row, if any, or null if it
1991: has none.</p>
1992:
1993: </li>
1994:
1995: <li>
1996:
1997: <p>If <var title="">ancestor</var> is null, then decrement the
1.80 mike 1998: <span><code>datagrid</code> row count</span> by <var
1999: title="">delta</var>. Otherwise, if <var title="">ancestor</var>
2000: is open, then decrement its row count by <var
2001: title="">delta</var>.</p>
1.1 mike 2002:
2003: </li>
2004:
2005: <li>
2006:
2007: <p>If <var title="">ancestor</var> is not null, then jump back
2008: to the step labeled <i>row count loop</i> above.</p>
2009:
2010: </li>
2011:
2012: <li>
2013:
2014: <p>Let <var title="">parent</var> be the row's parent, or the
1.80 mike 2015: <code>datagrid</code> if the row has no parent.</p>
1.1 mike 2016:
2017: </li>
2018:
2019: <li>
2020:
2021: <p>Decrement by one the natural order position of all rows whose
2022: parent is <var title="">parent</var> and whose natural order
2023: position is equal to or greater than the row's own natural order
2024: position.</p>
2025:
2026: </li>
2027:
2028: <li>
2029:
1.80 mike 2030: <p>If the row is in the <span>display order sparse data
2031: tree</span>, then decrement by one the display order position of
1.1 mike 2032: all rows whose parent is <var title="">parent</var> and whose
2033: display order position is equal to or greater than the row's own
2034: display order position.</p>
2035:
2036: </li>
2037:
2038: <li>
2039:
2040: <p>Clear the row and its descendants from the
1.80 mike 2041: <code>Datagrid</code>.</p>
1.1 mike 2042:
2043: </li>
2044:
1.80 mike 2045: </ol>
2046:
2047: </li>
1.1 mike 2048:
2049: <li>
2050:
1.80 mike 2051: <p>Invoke the <span><code>datagrid</code> update display
2052: algorithm</span>.</p>
1.1 mike 2053:
2054: </li>
2055:
1.80 mike 2056: </ol>
1.1 mike 2057:
1.80 mike 2058: <hr>
2059:
2060: <p>The <dfn
2061: title="dom-datagrid-clearRows"><code>clearRows()</code></dfn> method
2062: must empty the <span>natural order sparse data tree</span>, reset
2063: both the <span><code>datagrid</code> child count</span> and the
2064: <span><code>datagrid</code> row count</span> to zero, and invoke the
2065: <span><code>datagrid</code> update display algorithm</span>.</p>
2066:
2067: <hr>
2068:
2069: <p>The <dfn title="dom-datagrid-repaint"><code>repaint(<var
2070: title="">row</var>, <var title="">column</var>)</code></dfn> method
1.1 mike 2071: must cause the user agent to clear its cache for the cell specified
1.80 mike 2072: by the identifier <var title="">row</var> and the column <var
2073: title="">column</var>, if that column's type is <code
2074: title="datagrid-type-custom">custom</code>. If the given column has
2075: not been declared, or its type is not <code
2076: title="datagrid-type-custom">custom</code>, then the user agent must
2077: throw a <code>DATAGRID_MODEL_ERR</code> exception. If the given row
1.1 mike 2078: is not known, then the method must do nothing. If the cell is indeed
2079: cleared, the user agent must reinvoke the previously registered
1.80 mike 2080: <code>RenderingContext2DCallback</code> callback when it needs to
1.1 mike 2081: repaint that row.</p>
2082:
1.80 mike 2083: <hr>
2084:
2085: <p>If a row has a child count that isn't zero, then the user agent
1.1 mike 2086: should offer to the user the option of opening and closing the
2087: row.</p>
2088:
2089: <p>When a row is opened, if the row's row count is greater than
2090: zero, then the user agent must increase the
1.80 mike 2091: <span><code>datagrid</code> row count</span> and the row counts of
1.1 mike 2092: any ancestor rows by the number of rows that the newly opened row
1.80 mike 2093: has in its row count<!- - we should also "update the <span>pending
1.1 mike 2094: <code>datagrid</code> rows list</span> and the <span>pending
1.80 mike 2095: <code>datagrid</code> cells list</span> accordingly" - ->, then must
2096: mark the row as open, then may fill in the <span>display order
2097: sparse data tree</span> with any information that the user agent has
1.1 mike 2098: cached about the display order positions of descendants of the newly
1.80 mike 2099: opened row, and then must invoke the <code
2100: title="dom-listener-rowOpened">rowOpened()</code> method on the
2101: current <code title="dom-datagrid-listener">listener</code> with as
2102: its first argument a <code>RowID</code> object identifying the row
1.1 mike 2103: that was opened and as its second argument the boolean false, and
1.80 mike 2104: then must invoke the <span><code>datagrid</code> update display
2105: algorithm</span>.</p>
1.1 mike 2106:
2107: <p>On the other hand, when a row is opened and the row's row count
1.80 mike 2108: is −1, then the user agent must mark the row as opening, and
2109: then must invoke the <code
2110: title="dom-listener-rowOpened">rowOpened()</code> method on the
2111: current <code title="dom-datagrid-listener">listener</code> with as
2112: its first argument a <code>RowID</code> object identifying the row
1.1 mike 2113: that was opened and as its second argument the boolean true.</p>
2114:
2115: <p>When a row is closed, the user agent must decrease the
1.80 mike 2116: <span><code>datagrid</code> row count</span> and the row counts of
1.1 mike 2117: any ancestor rows by the number of rows that the newly closed row
1.80 mike 2118: has in its row count, and then must invoke the <code
2119: title="dom-listener-rowOpened">rowOpened()</code> method on the
2120: current <code title="dom-datagrid-listener">listener</code> with as
2121: its first and only argument a <code>RowID</code> object identifying
1.1 mike 2122: the row that was opened.</p>
2123:
2124:
2125:
1.80 mike 2126: <h6>The cells</h6>
1.1 mike 2127:
2128: <p>Each row has one cell per column. Each cell has the same type as
1.80 mike 2129: its column. The <dfn>allowed <code>datagrid</code> column
1.1 mike 2130: types</dfn>, what they represent, and the requirements for when the
2131: user interacts with them, are as follows:</p>
2132:
1.80 mike 2133: <dl>
2134:
2135: <dt><dfn title="datagrid-type-text"><code>text</code></dfn></dt>
1.1 mike 2136: <dd>
2137:
2138: <p>The cell represents some text and an optional image.</p>
2139:
2140: </dd>
2141:
1.80 mike 2142: <dt><dfn title="datagrid-type-editable"><code>editable</code></dfn></dt>
1.1 mike 2143: <dd>
2144:
2145: <p>The cells represents some editable text, an optional
1.80 mike 2146: <code>datalist</code> giving autocompletion hints, and an
1.1 mike 2147: optional image.</p>
2148:
1.80 mike 2149: <p>If there is a <code>datalist</code> element, the user agent
1.1 mike 2150: should offer the suggestions represented by that element to the
1.80 mike 2151: user. The user agent may use the suggestion's <span
2152: title="concept-option-label">label</span> to identify the
1.1 mike 2153: suggestion. If the user selects a suggestion, then the editable
1.80 mike 2154: text must be set to the selected suggestion's <span
2155: title="concept-option-value">value</span>, as if the user had
1.1 mike 2156: written that value himself.</p>
2157:
2158: <p>When the user edits the value, either directly or using the
1.80 mike 2159: <code>datalist</code>, the user agent must invoke the <code
2160: title="dom-listener-cellChanged">cellChanged()</code> method on
2161: the current <code title="dom-datagrid-listener">listener</code>
2162: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2163: cell's row, as its second argument the identifier of the cell's
2164: column, as its third argument the new value, and as its fourth
2165: argument the previous value.</p>
2166:
2167: </dd>
2168:
1.80 mike 2169: <dt><dfn title="datagrid-type-checkable"><code>checkable</code></dfn></dt>
1.1 mike 2170: <dd>
2171:
2172: <p>The cell represents some text, a check box that optionally has
2173: its value obscured as indeterminate, and an optional image.</p>
2174:
2175: <p>When the user checks or unchecks the check box, the user agent
2176: must change the check box's state appropriately and stop obscuring
2177: the check box as indeterminate (if it is obscuring it), and then
1.80 mike 2178: must invoke the <code
2179: title="dom-listener-cellChanged">cellChanged()</code> method on
2180: the current <code title="dom-datagrid-listener">listener</code>
2181: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2182: cell's row, as its second argument the identifier of the cell's
2183: column, as its third argument true if the check box is now checked
2184: and false otherwise, and as its fourth argument true if the check
2185: box was previously checked and false otherwise.</p>
2186:
2187: </dd>
2188:
1.80 mike 2189: <dt><dfn title="datagrid-type-list"><code>list</code></dfn></dt>
1.1 mike 2190: <dd>
2191:
2192: <p>The cell represents some text giving the current value selected
1.80 mike 2193: from a dropdown list of options, a <code>select</code> element
1.1 mike 2194: giving the list of options, and an optional image.</p>
2195:
2196: <p>The user agent should allow the user to change the value of the
1.80 mike 2197: cell from its current value to one of the <span
2198: title="concept-option-value">values</span> given by
2199: <code>option</code> elements in the <span
2200: title="concept-select-option-list">list of options</span> (if
2201: any). The user agent may use the <code>option</code> elements'
2202: <span title="concept-option-label">labels</span> to annotate each
1.1 mike 2203: option.</p>
2204:
1.80 mike 2205: <p>When the user selects a new value from the <code>select</code>
2206: element's <span title="concept-select-option-list">list of
2207: options</span>, the user agent must invoke the <code
2208: title="dom-listener-cellChanged">cellChanged()</code> method on
2209: the current <code title="dom-datagrid-listener">listener</code>
2210: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2211: cell's row, as its second argument the identifier of the cell's
2212: column, as its third argument the new value, and as its fourth
2213: argument the previous value.</p>
2214:
2215: </dd>
2216:
1.80 mike 2217: <dt><dfn title="datagrid-type-progress"><code>progress</code></dfn></dt>
1.1 mike 2218: <dd>
2219:
2220: <p>The cell represents a (determinate) progress bar whose value is
2221: between 0.0, indicating no progress, and 1.0, indicating the task
2222: is complete.</p>
2223:
2224: </dd>
2225:
1.80 mike 2226: <dt><dfn title="datagrid-type-meter"><code>meter</code></dfn></dt>
1.1 mike 2227: <dd>
2228:
2229: <p>The cell represents a gauge, described by one to six
2230: numbers.</p>
2231:
2232: <p>The gauge's actual value is given by the first number.</p>
2233:
2234: <p>If there is a second number, then that number is the maximum
2235: value. Otherwise, the maximum value is 1.0.</p>
2236:
2237: <p>If there is a third number, then that number is the minimum
2238: value. Otherwise, the minimum value is 1.0.</p>
2239:
2240: <p>If there is a fourth number, then that number is the low
2241: boundary. Otherwise, the low boundary is the minimum value.</p>
2242:
2243: <p>If there is a fifth number, then that number is the high
2244: boundary. Otherwise, the high boundary is the maximum value.</p>
2245:
2246: <p>If there is a sixth number, then the optimal point is the sixth
2247: number. Otherwise, the optimum point is the midpoint between the
2248: minimum value and the maximum value.</p>
2249:
1.80 mike 2250: <!- - next two paragraphs copied from <meter>: - ->
1.1 mike 2251:
2252: <p>If the optimum point is equal to the low boundary or the high
2253: boundary, or anywhere in between them, then the region between the
2254: low and high boundaries of the gauge must be treated as the
2255: optimum region, and the low and high parts, if any, must be
2256: treated as suboptimal. Otherwise, if the optimum point is less
2257: than the low boundary, then the region between the minimum value
2258: and the low boundary must be treated as the optimum region, the
2259: region between the low boundary and the high boundary must be
2260: treated as a suboptimal region, and the region between the high
2261: boundary and the maximum value must be treated as an even less
2262: good region. Finally, if the optimum point is higher than the high
2263: boundary, then the situation is reversed; the region between the
2264: high boundary and the maximum value must be treated as the optimum
2265: region, the region between the high boundary and the low boundary
2266: must be treated as a suboptimal region, and the remaining region
2267: between the low boundary and the minimum value must be treated as
2268: an even less good region.</p>
2269:
2270: <p>User agents should indicate the relative position of the actual
2271: value to the minimum and maximum values, and the relationship
2272: between the actual value and the three regions of the gauge.</p>
2273:
2274: </dd>
2275:
1.80 mike 2276: <dt><dfn title="datagrid-type-custom"><code>custom</code></dfn></dt>
1.1 mike 2277: <dd>
2278:
2279: <p>The cell represents a dynamically generated graphical image.</p>
2280:
2281: <p>The cell will have minimum dimensions (specified in CSS
2282: pixels), and a callback (in the form of a
1.80 mike 2283: <code>RenderingContext2DCallback</code> object) to get a rendering
1.1 mike 2284: for the cell.</p>
2285:
2286: <p>The user agent should not allow the cell to be rendered with
2287: dimensions less than the given minimum width and height.</p>
2288:
2289: <p>When the user agent needs to render the cell, the user agent
1.80 mike 2290: must <span>queue a task</span> to invoke the
2291: <span>RenderingContext2DCallback</span> callback, passing it a
2292: newly created <code>CanvasRenderingContext2D</code> object whose
1.186 mike 2293: <code title="dom-context-2d-canvas">canvas</code> IDL attribute is
1.1 mike 2294: null as the first argument, the actual cell width in CSS pixels as
2295: the second argument, and the actual cell height in CSS pixels as
2296: the third argument.</p>
2297:
2298: <p>If the user agent is able to render graphics, then it must
2299: render the graphics commands that the callback executed on the
1.80 mike 2300: provided <code>CanvasRenderingContext2D</code> object onto the
1.1 mike 2301: cell once the callback returns. The image must be clipped to the
2302: dimensions of the cell. The coordinate space of the cell must be
2303: aligned with that used by the 2D context such that the top left
2304: corner of the cell is the 0,0 origin, with the coordinate space
2305: increasing its <var title="">x</var> dimension towards the right
2306: of the cell and its <var title="">y</var> axis towards the bottom
2307: of the cell, and with the image not scaled (so that one CSS pixel
2308: on the final rendering matches one CSS pixel in the coordinate
2309: space used by the 2D context).</p>
2310:
2311: <p>The user agent must then decouple the
1.80 mike 2312: <code>CanvasRenderingContext2D</code> object and any objects that
2313: it created (such as <code>CanvasPattern</code> objects or
2314: <code>ImageData</code> objects) from any real drawing surface.</p>
1.1 mike 2315:
2316: <p>If the user agent is unable to render graphics, then it must
2317: render the text string returned by the callback instead.</p>
2318:
2319: </dd>
2320:
1.80 mike 2321: </dl>
2322:
2323: <hr>
2324:
2325: <p>When an algorithm requires the user agent to <dfn>apply a
1.1 mike 2326: <code>Row</code> object</dfn>, the user agent must run the following
2327: steps:</p>
2328:
1.80 mike 2329: <ol>
2330:
2331: <li>
2332:
2333: <p>If the value of the <code>Row</code> object's second entry is
2334: not −1, then run these substeps:</p>
1.1 mike 2335:
1.80 mike 2336: <ol>
1.1 mike 2337:
1.80 mike 2338: <li><p>If there is a row with the same parent as the row
2339: specified by the <code>Row</code> object's <code>RowID</code>
1.1 mike 2340: object, whose display order position is currently the same as the
1.80 mike 2341: value of the <code>Row</code> object's second entry, then remove
2342: that row from the <span>display order sparse data
2343: tree</span>.</p></li>
1.1 mike 2344:
2345: <li><p>Set the display order position of the row specified by the
1.80 mike 2346: <code>Row</code> object's <code>RowID</code> to the value of the
2347: <code>Row</code> object's second entry, updating its position in
2348: the <span>display order sparse data tree</span>
1.1 mike 2349: accordingly.</p></li>
2350:
1.80 mike 2351: <li><p>If the row is in the <span>pending
2352: <code>datagrid</code> rows list</span>, remove it.</p></li>
2353:
2354: </ol>
1.1 mike 2355:
1.80 mike 2356: </li>
1.1 mike 2357:
2358: <li>
2359:
1.80 mike 2360: <p>If the fourth entry in the <code>Row</code> object (a
2361: <code>CellList</code> object, an array) is not empty, then for
2362: each <code>Cell</code> object in that array update the cell that
1.1 mike 2363: corresponds to the column identified by the value of the first
1.80 mike 2364: entry of the <code>Cell</code> object, by using the appropriate
1.1 mike 2365: set of steps given below as determined by the type of the
1.80 mike 2366: column. Then, if the cell is in the <span>pending
2367: <code>datagrid</code> cells list</span>, remove it.</p>
1.1 mike 2368:
1.80 mike 2369: <dl>
2370:
2371: <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1 mike 2372: <dd>
2373:
2374: <p>Update the cell's text to the value given in the
1.80 mike 2375: <code>Cell</code> object's second entry.</p>
1.1 mike 2376:
1.80 mike 2377: <p>If the <code>Cell</code> object has three entries, then copy
2378: the image data from the <code>img</code> element given in the
1.1 mike 2379: third entry, and let the cell's image be given by that image
2380: data. Otherwise, update the cell to have no image.</p>
2381:
2382: </dd>
2383:
1.80 mike 2384: <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1 mike 2385: <dd>
2386:
2387: <p>Update the cell's text to the value given in the
1.80 mike 2388: <code>Cell</code> object's second entry.</p>
1.1 mike 2389:
1.80 mike 2390: <p>If the <code>Cell</code> object has three entries, then let
2391: the <code>datalist</code> element given in the third entry be
2392: the <code>datalist</code> element giving autocompletion
1.1 mike 2393: hints. Otherwise, update the cell to have no
1.80 mike 2394: <code>datalist</code> element.</p>
1.1 mike 2395:
1.80 mike 2396: <p>If the <code>Cell</code> object has four entries, then copy
2397: the image data from the <code>img</code> element given in the
1.1 mike 2398: fourth entry, and let the cell's image be given by that image
2399: data. Otherwise, update the cell to have no image.</p>
2400:
2401: </dd>
2402:
1.80 mike 2403: <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 2404: <dd>
2405:
2406: <p>Update the cell's text to the value given in the
1.80 mike 2407: <code>Cell</code> object's second entry.</p>
1.1 mike 2408:
2409: <p>Update the cell's checked state to match the value of the
2410: third entry: checked if true, unchecked otherwise.</p>
2411:
1.80 mike 2412: <p>If the <code>Cell</code> object has four entries and the
1.1 mike 2413: fourth entry is true, then update the cell to be obscured as
2414: indeterminate. Otherwise, the cell's state is not obscured.</p>
2415:
1.80 mike 2416: <p>If the <code>Cell</code> object has five entries, then copy
2417: the image data from the <code>img</code> element given in the
1.1 mike 2418: fifth entry, and let the cell's image be given by that image
2419: data. Otherwise, update the cell to have no image.</p>
2420:
2421: </dd>
2422:
1.80 mike 2423: <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1 mike 2424: <dd>
2425:
2426: <p>Update the cell's text to the value given in the
1.80 mike 2427: <code>Cell</code> object's second entry, and the
2428: <code>select</code> element to be the one given in the
2429: <code>Cell</code> object's third entry</p>
1.1 mike 2430:
1.80 mike 2431: <p>If the <code>Cell</code> object has four entries, then copy
2432: the image data from the <code>img</code> element given in the
1.1 mike 2433: fourth entry, and let the cell's image be given by that image
2434: data. Otherwise, update the cell to have no image.</p>
2435:
2436: </dd>
2437:
1.80 mike 2438: <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1 mike 2439: <dd>
2440:
2441: <p>Update the cell to be a progress bar whose progress, on the
2442: scale of 0.0 (no progress) to 1.0 (task complete) is given by
1.80 mike 2443: the value in the <code>Cell</code> object's second entry.</p>
1.1 mike 2444:
2445: </dd>
2446:
1.80 mike 2447: <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1 mike 2448: <dd>
2449:
2450: <p>Update the cell to be a gauge configured with the numbers
2451: given by the second and subsequent entries of the
1.80 mike 2452: <code>Cell</code> object.</p>
1.1 mike 2453:
2454: </dd>
2455:
1.80 mike 2456: <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1 mike 2457: <dd>
2458:
2459: <p>Update the cell's minimum width to be the length in CSS
1.80 mike 2460: pixels given by the <code>Cell</code> object's second entry.</p>
1.1 mike 2461:
2462: <p>Update the cell's minimum height to be the length in CSS
1.80 mike 2463: pixels given by the <code>Cell</code> object's third entry.</p>
1.1 mike 2464:
2465: <p>Update the cell's callback to be the
1.80 mike 2466: <code>RenderingContext2DCallback</code> object given by the
2467: <code>Cell</code> object's fourth entry.</p>
1.1 mike 2468:
2469: </dd>
2470:
1.80 mike 2471: </dl>
2472:
2473: </li>
1.1 mike 2474:
1.80 mike 2475: </ol>
2476:
2477: <hr>
2478:
2479: <p>When the user agent is to run the <dfn><code>datagrid</code>
2480: update display algorithm</dfn>, the user agent must invoke the <code
2481: title="dom-listener-getRows">getRows()</code> and <code
2482: title="dom-listener-getCells">getCells()</code> methods on the
2483: current <code title="dom-datagrid-listener">listener</code> such
2484: that all the current visible rows in the <span>display order sparse
2485: data list</span>, and all the cells in the currently visible columns
1.1 mike 2486: on all the currently visible rows, have been covered.</p>
2487:
1.80 mike 2488: <p>A row is considered covered if it is present in the <span>pending
2489: <code>datagrid</code> rows list</span>, or if the <code
2490: title="dom-listener-getRows">getRows()</code> method is invoked with
1.1 mike 2491: a range that includes the row in question.</p>
2492:
2493: <p>A cell is considered covered if it is present in the
1.80 mike 2494: <span>pending <code>datagrid</code> cells list</span>, or if the
2495: <code title="dom-listener-getRows">getRows()</code> method is
1.1 mike 2496: invoked with a range that includes the row in question and a list of
1.80 mike 2497: columns that includes the cell's column, or if the <code
2498: title="dom-listener-getCells">getCells()</code> method is invoked
1.1 mike 2499: with a list of rows and columns that intersects the cell in
1.80 mike 2500: question. However, the <code
2501: title="dom-listener-getCells">getCells()</code> method can only be
2502: used if the row is already present in the <span>display order sparse
2503: data list</span>.</p>
1.1 mike 2504:
1.80 mike 2505: <p>The <code title="dom-listener-getRows">getRows()</code> method,
1.1 mike 2506: if used, must be invoked with five arguments. The first argument
1.80 mike 2507: must be the index in the <span>display order sparse data list</span>
1.1 mike 2508: to the first row that the user agent is requesting, known as the
2509: <i>anchor row</i>. The second argument must be the number of
2510: consecutive cells for which the user agent is requesting
1.80 mike 2511: information. The third argument must be the <code>RowID</code> of
2512: the row that is the nearest ancestor in the <span>display order
2513: sparse data <em>tree</em></span> of the anchor row. If this is the
2514: <code>datagrid</code>, then the <code>RowID</code> object must be an
1.1 mike 2515: empty array. The fourth argument must be the display order position
1.80 mike 2516: of the anchor row in the <span>display order sparse data
2517: tree</span>, assuming that the row identified in the third argument
1.1 mike 2518: is indeed the anchor row's parent row. The fifth and final argument
2519: must be an array of the identifiers of the columns for which the
2520: user agent is requesting information, in the order they were added
1.80 mike 2521: to the <code>datagrid</code>.</p>
1.1 mike 2522:
1.80 mike 2523: <p>As the <code title="dom-listener-getRows">getRows()</code> method
2524: is invoked, the <span>pending <code>datagrid</code> rows list</span>
1.1 mike 2525: must be updated to include the rows for which information has been
2526: requested, excluding rows for which information is already
1.80 mike 2527: available; and the <span>pending <code>datagrid</code> cells
2528: list</span> must be updated to include the cells for which
1.1 mike 2529: information has been requested on those rows.</p>
2530:
1.80 mike 2531: <p>The <code title="dom-listener-getCells">getCells()</code> method,
1.1 mike 2532: if used, must be invoked with two arguments. The first argument must
1.80 mike 2533: be an array of <code>RowID</code> objects identifying the rows for
1.1 mike 2534: which information is being requested. The second argument must be an
2535: array of the identifiers of the columns for which the user agent is
2536: requesting information, in the order they were added to the
1.80 mike 2537: <code>datagrid</code>.</p>
1.1 mike 2538:
1.80 mike 2539: <p>As the <code title="dom-listener-getCells">getCells()</code>
2540: method is invoked, the <span>pending <code>datagrid</code> cells
2541: list</span> must be updated to include the cells for which
1.1 mike 2542: information has been requested.</p>
2543:
2544: <p>Calls to these methods should be batched so that the rows and
2545: cells to be covered are handled by the fewest number of calls to
2546: these methods as possible. To this end, user agents may invoke the
1.80 mike 2547: <code title="dom-listener-getRows">getRows()</code> method for a set
1.1 mike 2548: of rows that includes some rows that are already in the
1.80 mike 2549: <span>display order sparse data list</span>, and similarly may
2550: invoke the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2551: method with row/column combinations that cover some cells for which
2552: data is already known. Generally, however, user agents should avoid
2553: invoking these methods with arguments that cause information to be
2554: requested when it has already been requested or is already
2555: known.</p>
2556:
2557: <div class="example">
2558:
2559: <p>For example, consider a case represented by the following table,
2560: where the cells marked "Yes" indicate that the data has already
2561: been obtained, the cells marked "Pending" indicate that the data
2562: has been previously requested but not yet obtained, and the cells
2563: with just a dash indicate that no information has ever been
2564: obtained, or any information that had been obtained has now been
2565: discarded.</p>
2566:
1.80 mike 2567: <table>
2568: <tr> <td> <th> Row <th> Column A <th> Column B
2569: <tr> <th> Row 1 <td> - <td> - <td> -
2570: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes
2571: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes
2572: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes
2573: <tr> <th> Row 5 <td> - <td> - <td> -
2574: <tr> <th> Row 6 <td> - <td> - <td> -
2575: <tr> <th> Row 7 <td> Yes <td> Pending <td> -
2576: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending
2577: </table>
2578:
2579: <p>Thus, rows 2, 3, 4, 7, and 8 are already covered, as are the
1.1 mike 2580: cells from those rows except for the cell in column B of row 7.</p>
2581:
2582: <p>Now consider what happens if all of these rows become visible at
2583: once. The user agent has several choices, including (but not
2584: limited to) the following:</p>
2585:
1.80 mike 2586: <ul>
2587:
2588: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2589: method for rows 1 through 8 and columns A and B all at once.</li>
2590:
1.80 mike 2591: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2592: method for row 1, then fire it again for rows 5 through 7.</li>
2593:
1.80 mike 2594: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2595: method for row 1, then fire it again for rows 5 and 6, and then
1.80 mike 2596: fire the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2597: method for row 7 column B.</li>
2598:
1.80 mike 2599: </ul>
2600:
2601: <p>All three options are allowed, but the latter two are preferable
1.1 mike 2602: to the former, as they minimise the amount of redundant information
2603: requested.</p>
2604:
2605: <p>In any case, the data model now looks 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> Pending <td> Pending <td> Pending <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> Pending <td> Pending <td> Pending <td> -
2614: <tr> <th> Row 6 <td> Pending <td> Pending <td> Pending <td> -
2615: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> -
2616: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> -
2617: </table>
2618:
2619: <p>Now consider the case where a third column, column C, is added
1.1 mike 2620: to the data model. The user agent once again has several choices,
2621: including (but not limited to) the following:</p>
2622:
1.80 mike 2623: <ul>
2624:
2625: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2626: method for rows 1 through 8 again, this time listing just column
2627: C.</li>
2628:
1.80 mike 2629: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2630: method for row 1, then fire it again for rows 5 and 6, and then
1.80 mike 2631: fire the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2632: method for the other rows (in all three cases, listing just column
2633: C).</li>
2634:
1.80 mike 2635: </ul>
2636:
2637: <p>The two options here are as bad as each other; the former
1.1 mike 2638: involves a lot of overlap, but the latter involves a lot of method
2639: calls. Unfortunately the user agent can't do the obvious thing,
1.80 mike 2640: namely just to invoke the <code
2641: title="dom-listener-getCells">getCells()</code> method for all the
1.1 mike 2642: rows listing just column C, because it doesn't have the row
2643: information for all the rows yet (rows 1, 5 and 6 are still
2644: pending).</p>
2645:
2646: <p>In any case, the data model now looks like this:</p>
2647:
1.80 mike 2648: <table>
2649: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2650: <tr> <th> Row 1 <td> Pending <td> Pending <td> Pending <td> Pending
2651: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> Pending
2652: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> Pending
2653: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> Pending
2654: <tr> <th> Row 5 <td> Pending <td> Pending <td> Pending <td> Pending
2655: <tr> <th> Row 6 <td> Pending <td> Pending <td> Pending <td> Pending
2656: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> Pending
2657: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> Pending
2658: </table>
2659:
2660: <p>If at this point the user scrolls around anywhere within this
2661: <code>datagrid</code>, the user agent won't fire the <code
2662: title="dom-listener-getRows">getRows()</code> and <code
2663: title="dom-listener-getCells">getCells()</code> methods, because
1.1 mike 2664: all of the rows and cells are covered.</p>
2665:
2666: <p>Now consider the case where the user agent receives row
2667: information, but no cell information, for rows 1, 5, and 6:</p>
2668:
1.80 mike 2669: <table>
2670: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2671: <tr> <th> Row 1 <td> Yes <td> Pending <td> Pending <td> Pending
2672: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> Pending
2673: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> Pending
2674: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> Pending
2675: <tr> <th> Row 5 <td> Yes <td> Pending <td> Pending <td> Pending
2676: <tr> <th> Row 6 <td> Yes <td> Pending <td> Pending <td> Pending
2677: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> Pending
2678: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> Pending
2679: </table>
2680:
2681: <p>The user agent still won't fire any methods when the user
1.1 mike 2682: scrolls, because the data is still covered. But if the script then
1.80 mike 2683: calls the <code title="dom-datagrid-renotify">renotify()</code>
1.1 mike 2684: method, the "Pending" flags would get reset, and the model would
2685: now look like this:</p>
2686:
1.80 mike 2687: <table>
2688: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2689: <tr> <th> Row 1 <td> Yes <td> - <td> - <td> -
2690: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> -
2691: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> -
2692: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> -
2693: <tr> <th> Row 5 <td> Yes <td> - <td> - <td> -
2694: <tr> <th> Row 6 <td> Yes <td> - <td> - <td> -
2695: <tr> <th> Row 7 <td> Yes <td> - <td> - <td> -
2696: <tr> <th> Row 8 <td> Yes <td> - <td> - <td> -
2697: </table>
2698:
2699: <p>Now, assuming that all eight rows and all three columns are
1.1 mike 2700: still visible, the user agent has the following choices (amongst
2701: others):</p>
2702:
1.80 mike 2703: <ul>
2704:
2705: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2706: method for rows 1 through 8, listing all three columns.</li>
2707:
1.80 mike 2708: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2709: method for rows 1 and 5 through 8, listing all three columns, and
2710: then fire the method for rows 2 through 4, listing just column
2711: C.</li>
2712:
1.80 mike 2713: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2714: method for rows 1 and 5 through 8, listing just columns A abd B,
2715: and then fire the method for rows 1 through 8, listing just column
2716: C.</li>
2717:
1.80 mike 2718: </ul>
2719:
2720: <p>Here the latter two are preferable because they result in less
1.1 mike 2721: overlap than the first.</p>
2722:
2723: </div>
2724:
1.80 mike 2725: <hr>
2726:
2727: <p>The <span>task source</span> for tasks queued on behalf of a
2728: <code>datagrid</code> is the <span>DOM manipulation task
2729: source</span>.</p>
2730:
2731: </div>
2732:
2733:
2734: <h5>Listening to notifications from the <code>datagrid</code></h5>
1.1 mike 2735:
1.80 mike 2736: <p><i>The conformance criteria in this section apply to any
2737: implementation of the <code>DataGridListener</code> interface,
1.1 mike 2738: including (and most commonly) the content author's
1.80 mike 2739: implementation(s).</i></p>
2740:
2741: <pre class="idl">// To be implemented by Web authors as a JS object
1.81 mike 2742: [NoInterfaceObject]
2743: interface <dfn>DataGridListener</dfn> {
1.80 mike 2744: void <span title="dom-listener-initialize">initialize</span>(in <span>HTMLDataGridElement</span> datagrid);
2745:
2746: 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);
2747: void <span title="dom-listener-getCells">getCells</span>(in <span>RowIDList</span> rows, in <span>ColumnList</span> columns);
2748: void <span title="dom-listener-rowOpened">rowOpened</span>(in <span>RowID</span> row, in boolean rowCountNeeded);
2749: void <span title="dom-listener-rowClosed">rowClosed</span>(in <span>RowID</span> row);
2750:
2751: void <span title="dom-listener-cellChanged">cellChanged</span>(in <span>RowID</span> row, in <span>Column</span> column, in any newValue, in any prevValue);
2752: <span>HTMLMenuElement</span> <span title="dom-listener-getRowMenu">getRowMenu</span>(in <span>RowID</span> row);
2753: <!- -vsDGDND
1.1 mike 2754: boolean <span title="dom-listener-canDrop">canDrop</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
2755: boolean <span title="dom-listener-dropped">dropped</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
1.80 mike 2756: - -><!- -v2DGPA
1.1 mike 2757: void <span title="dom-listener-performAction">performAction</span>(in <span>RowID</span> row, in DOMString action);
1.80 mike 2758: - ->};</pre>
2759:
2760: <p>The <code>DataGridListener</code> interface, once implemented by
2761: an object in a script and hooked up to a <code>datagrid</code> using
1.186 mike 2762: the <code title="dom-datagrid-listener">listener</code> IDL
1.80 mike 2763: attribute, receives notifications when the <code>datagrid</code>
2764: needs information (such as which rows exist) for display.</p>
2765:
2766: <p>The following methods may be usefully implemented:</p>
2767:
2768: <dl>
2769:
2770: <dt><dfn title="dom-listener-initialize"><code>initialize(<var title="">datagrid</var>)</code></dfn></dt>
1.1 mike 2771:
2772: <dd>
2773:
1.80 mike 2774: <p>Called by the <code>datagrid</code> element (the one given by
2775: the <var title="">datagrid</var> argument) when the <code
2776: title="dom-datagrid-listener">listener</code> attribute is
1.1 mike 2777: set.</p>
2778:
2779: </dd>
2780:
1.80 mike 2781: <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 2782:
2783: <dd>
2784:
1.80 mike 2785: <p>Called by the <code>datagrid</code> element when the user agent
1.1 mike 2786: finds itself needing to render rows for which it is lacking
2787: information.</p>
2788:
2789: <p>The <var title="">rowIndex</var> argument gives the flattened
2790: index of the first row for which it needs information, ignoring
1.80 mike 2791: the tree structure of the <code>datagrid</code> model, where zero
1.1 mike 2792: is the first row of the entire tree.</p>
2793:
2794: <p>The <var title="">rowCount</var> argument gives the number of
2795: rows for which the user agent would like information.</p>
2796:
2797: <p>The <var title="">parentRow</var> argument gives the
1.80 mike 2798: <code>RowID</code> object identifying the nearest ancestor of the
1.1 mike 2799: first row that the user agent is aware of. After the sort order
2800: has changed, this will typically be the root of the tree
1.80 mike 2801: (identified by a <code>RowID</code> object consisting of an empty
1.1 mike 2802: array).
2803:
1.80 mike 2804: <p>The <var title="">columns</var> argument gives the columns for
1.1 mike 2805: which the user agent is lacking information, as an array of column
1.80 mike 2806: identifiers (as passed to <code
2807: title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1 mike 2808:
2809: </dd>
2810:
1.80 mike 2811: <dt><dfn title="dom-listener-getCells"><code>getCells(<var title="">rows</var>, <var title="">columns</var>)</code></dfn></dt>
1.1 mike 2812:
2813: <dd>
2814:
1.80 mike 2815: <p>Called by the <code>datagrid</code> element when the user agent
1.1 mike 2816: finds itself needing to render cells for which it is lacking
2817: information in rows that it does know about.</p>
2818:
2819: <p>The <var title="">rows</var> argument gives an array of
1.80 mike 2820: <code>RowID</code> objects identifying the various rows for which
1.1 mike 2821: the user agent is lacking information.</p>
2822:
2823: <p>The <var title="">columns</var> argument gives the columns for
2824: which the user agent is lacking information, as an array of column
1.80 mike 2825: identifiers (as passed to <code
2826: title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1 mike 2827:
2828: </dd>
2829:
1.80 mike 2830: <dt><dfn title="dom-listener-rowOpened"><code>rowOpened(<var title="">row</var>, <var title="">rowCountNeeded</var>)</code></dfn></dt>
1.1 mike 2831:
2832: <dd>
2833:
1.80 mike 2834: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2835: opened a row.</p>
2836:
2837: <p>The <var title="">row</var> argument gives an
1.80 mike 2838: <code>RowID</code> object identifying the row that was opened.</p>
1.1 mike 2839:
2840: <p>If the user agent also knows how many children that row has,
2841: then the <var title="">rowCountNeeded</var> argument will be
2842: false. Otherwise, the argument will be true, and the row will
1.80 mike 2843: remain closed until the <code
2844: title="dom-datagrid-setRows">setRows()</code> method is called
1.1 mike 2845: with an accurate row count.</p>
2846:
2847: </dd>
2848:
1.80 mike 2849: <dt><dfn title="dom-listener-rowClosed"><code>rowClosed(<var title="">row</var>)</code></dfn></dt>
1.1 mike 2850:
2851: <dd>
2852:
1.80 mike 2853: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2854: opened a row.</p>
2855:
2856: <p>The <var title="">row</var> argument gives an
1.80 mike 2857: <code>RowID</code> object identifying the row that was closed.</p>
1.1 mike 2858:
2859: </dd>
2860:
1.80 mike 2861: <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 2862:
2863: <dd>
2864:
1.80 mike 2865: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2866: edited a cell or checked a check box in a cell.</p>
2867:
2868: <p>The <var title="">row</var> argument gives an
1.80 mike 2869: <code>RowID</code> object identifying the row of the cell, and the
1.1 mike 2870: <var title="">column</var> argument gives the identifier of the
2871: cell's column.</p>
2872:
2873: <p>The <var title="">newValue</var> argument gives the new value,
2874: and the <var title="">prevValue</var> argument gives the previous
2875: value.</p>
2876:
2877: </dd>
2878:
1.80 mike 2879: <dt><dfn title="dom-listener-getRowMenu"><code>getRowMenu(<var title="">row</var>)</code></dfn></dt>
1.1 mike 2880:
1.80 mike 2881: <dd>Must return an <code>HTMLMenuElement</code> object that is to
1.1 mike 2882: be used as a context menu for row <var title="">row</var>, or null
2883: if there is no particular context menu. May be omitted if none of
2884: the rows have a special context menu. As this method is called
2885: immediately before showing the menu in question, no precautions
2886: need to be taken if the return value of this method changes.</dd>
2887:
1.80 mike 2888: <!- -v2DGDND, v2DFPA- ->
1.1 mike 2889:
1.80 mike 2890: </dl>
2891:
2892: <div class="impl">
1.1 mike 2893:
1.80 mike 2894: <p>Objects that implement the <code>DataGridListener</code>
1.1 mike 2895: interface may omit any or all of the methods. When a method is
2896: omitted, a user agent intending to call that method must instead
2897: skip the method call, and must assume that the method's return value
2898: is null.</p>
2899:
1.80 mike 2900: </div>
2901:
2902:
2903:
2904: <!- - v2DGS: <datagrid> selection (search for the bits marked "..." to see what needs filling in, at a minimum)
1.1 mike 2905:
2906: <h5>The selection</h5>
2907:
2908: <pre class="idl">interface <dfn>DataGridSelection</dfn> {
2909: readonly attribute unsigned long <span title="dom-DataGridSelection-length">length</span>;
1.81 mike 2910: getter <span>RowID</span> <span title="dom-DataGridSelection-item">item</span>(in unsigned long index);
1.1 mike 2911: boolean <span title="dom-DataGridSelection-isSelected">isSelected</span>(in <span>RowID</span> row);
2912: void <span title="dom-DataGridSelection-setSelected">setSelected</span>(in <span>RowID</span> row, in boolean selected);
2913: void <span title="dom-DataGridSelection-selectAll">selectAll</span>();
2914: void <span title="dom-DataGridSelection-clear">clear</span>();
2915: };</pre>
2916:
2917: <dl class="domintro">
2918:
2919: ...
2920:
2921: </dl>
2922:
2923: <div class="impl">
2924:
2925: <p>Each <code>datagrid</code> element must keep track of which rows
2926: are currently selected. Initially, no rows are selected. This can be
2927: changed using the methods described in this section.</p>
2928:
2929: <p>The selection of a <code>datagrid</code> is represented by its
1.186 mike 2930: <dfn title="dom-datagrid-selection"><code>selection</code></dfn> IDL
1.1 mike 2931: attribute, which must be a <code>DataGridSelection</code> object.</p>
2932:
2933: <p><code>DataGridSelection</code> objects represent the rows in the
2934: selection. In the selection the rows must be ordered in their
2935: natural order (and not, e.g., the display order). A row with an
2936: ancestor that is closed cannot be selected.</p>
2937:
2938: <p>The <dfn
2939: title="dom-DataGridSelection-length"><code>length</code></dfn>
2940: attribute must return the number of rows currently present in the
2941: selection. This is the <var
2942: title="dom-DataGridSelection-length">length</var>.</p>
2943:
2944: <p>The object's <span>indices of the supported indexed
2945: properties</span> are the numbers in the range zero to <span title=""><var
2946: title="dom-DataGridSelection-length">length</var>-1</span>, unless
2947: the <var title="dom-DataGridSelection-length">length</var> is zero,
2948: in which case there are no <span>supported indexed
2949: properties</span>.</p>
2950:
2951: <p>The <dfn title="dom-DataGridSelection-item"><code>item(<var
2952: title="">index</var>)</code></dfn> method must return a
2953: <code>RowID</code> object identifying the <var
2954: title="">index</var>th row in the selection. If the argument is out
2955: of range (less than zero or greater than the number of selected rows
2956: minus one), then it must raise an <code>INDEX_SIZE_ERR</code>
1.98 mike 2957: exception. <a href="#refsDOMCORE">[DOMCORE]</a></p>
1.1 mike 2958:
2959: <p>The <dfn
2960: title="dom-DataGridSelection-isSelected"><code>isSelected()</code></dfn>
2961: method must return the selected state of the row specified by its
2962: argument. If the specified row is in the <span>natural order sparse
2963: data tree</span> and is selected, the method must return true,
2964: otherwise it must return false.</p>
2965:
2966: <p>The <dfn
2967: title="dom-DataGridSelection-setSelected"><code>setSelected()</code></dfn>
2968: method takes two arguments, <var title="">row</var> and <var
2969: title="">selected</var>. When invoked, it must set the selection
2970: state of row <var title="">row</var> to selected if <var
2971: title="">selected</var> is true, and unselected if it is false. If
2972: <var title="">row</var> does not specify a row in the <span>natural
2973: order sparse data tree</span> ...
2974:
2975: <p>The <dfn
2976: title="dom-DataGridSelection-selectAll"><code>selectAll()</code></dfn>
2977: method must ...
2978:
2979: <p>The <dfn
2980: title="dom-DataGridSelection-clear"><code>clear()</code></dfn>
2981: method must mark all the rows in the <code>datagrid</code> as not
2982: selected. After a call to <code
2983: title="dom-DataGridSelection-clear">clear()</code>, the <code
2984: title="dom-DataGridSelection-length">length</code> attribute will
2985: return zero.</p>
2986:
2987: <p>If the <code>datagrid</code> element has a <code
2988: title="attr-datagrid-multiple">multiple</code> attribute, then the
2989: user agent should allow the user to select any number of rows (zero
2990: or more). If the attribute is not present, then the user agent
2991: should allow the user to select a row, and must not allow the user
2992: to select more than a single row at a time; selecting another one
2993: must unselect all the other rows.</p>
2994:
2995: <p class="note">This only applies to the user. Scripts can select
2996: multiple rows even when the <code
2997: title="attr-datagrid-multiple">multiple</code> attribute is
2998: absent.</p>
2999:
3000: ...event on selection change?...
3001:
3002: </div>
3003:
3004: <p class="note">The <code>DataGridSelection</code> interface has no
3005: relation to the <code>Selection</code> interface.</p>
3006:
1.80 mike 3007: - ->
3008:
3009:
3010: <!- -vsDGDND
1.1 mike 3011: <h5>Drag and drop in <code>datagrid</code>s</h5>
3012:
3013: <p><i>This section only applies to interactive user agents.</i></p>
3014:
3015: ...define drag and drop in datagrids; selectiondraggable...
1.80 mike 3016: - ->
3017:
1.886 mike 3018: --><h4 id="the-command"><span class="secno">4.11.3 </span>The <dfn><code>command</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
1.987 mike 3019: <dd><a href="content-models.html#metadata-content">Metadata content</a>.</dd>
3020: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
3021: <dd><a href="content-models.html#phrasing-content">Phrasing content</a>.</dd>
1.1 mike 3022: <dt>Contexts in which this element may be used:</dt>
1.987 mike 3023: <dd>Where <a href="content-models.html#metadata-content">metadata content</a> is expected.</dd>
3024: <dd>Where <a href="content-models.html#phrasing-content">phrasing content</a> is expected.</dd>
1.1 mike 3025: <dt>Content model:</dt>
3026: <dd>Empty.</dd>
3027: <dt>Content attributes:</dt>
1.987 mike 3028: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 3029: <dd><code title="attr-command-type"><a href="#attr-command-type">type</a></code></dd>
3030: <dd><code title="attr-command-label"><a href="#attr-command-label">label</a></code></dd>
3031: <dd><code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code></dd>
3032: <dd><code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code></dd>
3033: <dd><code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code></dd>
3034: <dd><code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code></dd>
3035: <!--<dd><code title="attr-command-default">default</code></dd>-->
3036: <dd>Also, the <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute has special semantics on this element.</dd>
3037: <dt>DOM interface:</dt>
3038: <dd>
1.987 mike 3039: <pre class="idl">interface <dfn id="htmlcommandelement">HTMLCommandElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 3040: attribute DOMString <a href="#dom-command-type" title="dom-command-type">type</a>;
3041: attribute DOMString <a href="#dom-command-label" title="dom-command-label">label</a>;
3042: attribute DOMString <a href="#dom-command-icon" title="dom-command-icon">icon</a>;
3043: attribute boolean <a href="#dom-command-disabled" title="dom-command-disabled">disabled</a>;
3044: attribute boolean <a href="#dom-command-checked" title="dom-command-checked">checked</a>;
3045: attribute DOMString <a href="#dom-command-radiogroup" title="dom-command-radiogroup">radiogroup</a>;<!--
3046: attribute boolean <span title="dom-command-default">default</span>;-->
3047: };</pre>
3048: </dd>
3049: </dl><p>The <code><a href="#the-command">command</a></code> element represents a command that the user
1.117 mike 3050: can invoke.</p><p>The <dfn id="attr-command-type" title="attr-command-type"><code>type</code></dfn>
1.1 mike 3051: attribute indicates the kind of command: either a normal command
3052: with an associated action, or a state or option that can be toggled,
1.987 mike 3053: or a selection of one item from a list of items.</p><p>The attribute is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> with three
1.289 mike 3054: keywords and states. The "<dfn id="attr-command-type-keyword-command" title="attr-command-type-keyword-command"><code>command</code></dfn>"
3055: keyword maps to the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state, the
1.520 mike 3056: "<dfn id="attr-command-type-keyword-checkbox" title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
1.289 mike 3057: keyword maps to the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state, and
3058: the "<dfn id="attr-command-type-keyword-radio" title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
1.1 mike 3059: keyword maps to the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state. The
1.117 mike 3060: <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 3061:
1.987 mike 3062: <dd><p>The element <a href="rendering.html#represents">represents</a> a normal command with an associated action.</p></dd>
1.1 mike 3063:
3064: <dt>The <dfn id="attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>
3065:
1.987 mike 3066: <dd><p>The element <a href="rendering.html#represents">represents</a> a state or option that can be toggled.</p></dd>
1.1 mike 3067:
3068: <dt>The <dfn id="attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</dfn> state</dt>
3069:
1.987 mike 3070: <dd><p>The element <a href="rendering.html#represents">represents</a> a selection of one item from a list of items.</p></dd>
1.1 mike 3071:
3072: </dl><p>The <dfn id="attr-command-label" title="attr-command-label"><code>label</code></dfn>
1.718 mike 3073: attribute gives the name of the command, as shown to the user. The
3074: <code title="attr-command-label"><a href="#attr-command-label">label</a></code> attribute must be
3075: specified and must have a value that is not the empty string.</p><p>The <dfn id="attr-command-title" title="attr-command-title"><code>title</code></dfn>
1.1 mike 3076: attribute gives a hint describing the command, which might be shown
1.117 mike 3077: 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 3078: attribute gives a picture that represents the command. If the
3079: attribute is specified, the attribute's value must contain a
1.987 mike 3080: <a href="urls.html#valid-non-empty-url-potentially-surrounded-by-spaces">valid non-empty URL potentially surrounded by
3081: spaces</a>. <span class="impl">To obtain the <a href="urls.html#absolute-url">absolute
1.913 mike 3082: URL</a> of the icon when the attribute's value is not the empty
1.987 mike 3083: string, the attribute's value must be <a href="urls.html#resolve-a-url" title="resolve a
1.913 mike 3084: url">resolved</a> relative to the element. When the attribute is
1.987 mike 3085: absent, or its value is the empty string, or <a href="urls.html#resolve-a-url" title="resolve a
1.913 mike 3086: url">resolving</a> its value fails, there is no icon.</span></p><!-- this is affected by the base URL being changed, so users of
3087: this should cache the image once they've fetched it once, at least
3088: until the relative url changes again --><p>The <dfn id="attr-command-disabled" title="attr-command-disabled"><code>disabled</code></dfn> attribute
1.987 mike 3089: is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present, indicates that
1.117 mike 3090: 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 3091: disabled if, in the same context, it could be enabled if only
3092: certain aspects of the situation were changed. A command would be
3093: marked as hidden if, in that situation, the command will never be
3094: enabled. For example, in the context menu for a water faucet, the
3095: command "open" might be disabled if the faucet is already open, but
3096: the command "eat" would be marked hidden since the faucet could
1.117 mike 3097: never be eaten.</p><p>The <dfn id="attr-command-checked" title="attr-command-checked"><code>checked</code></dfn>
1.987 mike 3098: attribute is a <a href="common-microsyntaxes.html#boolean-attribute">boolean attribute</a> that, if present,
1.1 mike 3099: indicates that the command is selected. The attribute must be
3100: omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code>
3101: attribute is in either the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state or
3102: the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a>
1.117 mike 3103: state.</p><p>The <dfn id="attr-command-radiogroup" title="attr-command-radiogroup"><code>radiogroup</code></dfn>
1.1 mike 3104: attribute gives the name of the group of commands that will be
3105: 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 3106: 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 3107: <p>If the <code>command</code> element is used when <span
3108: title="menu generation">generating</span> a <span>context
3109: menu</span>, then the <dfn
3110: title="attr-command-default"><code>default</code></dfn> attribute
3111: indicates, if present, that the command is the one that would have
3112: been invoked if the user had directly activated the menu's subject
3113: instead of using its context menu. The <code
3114: title="attr-command-default">default</code> attribute is a
3115: <span>boolean attribute</span>. The attribute must be omitted unless
3116: the <code title="attr-command-type">type</code> attribute is in the
3117: <span title="attr-command-type-state-command">Command</span>
3118: state.</p>
3119:
3120: <div class="example">
3121:
3122: ...an example that shows an element that, if double-clicked,
3123: invokes an action, but that also has a context menu, showing the
3124: various <code>command</code> attributes off, and that has a default
3125: command...
3126:
3127: </div>
1.117 mike 3128: --><div class="impl">
1.1 mike 3129:
3130: <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><!--,
3131: and <dfn title="dom-command-default"><code>default</code></dfn>-->
1.987 mike 3132: IDL attributes must <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content
1.1 mike 3133: attributes of the same name.</p>
3134:
1.987 mike 3135: <p>The element's <a href="content-models.html#activation-behavior">activation behavior</a> depends on the
1.1 mike 3136: value of the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute
3137: of the element, as follows:</p>
3138:
3139: <dl class="switch"><dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
3140: in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state</dt>
3141:
3142: <dd><p>If the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, the UA must
3143: 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
3144: literal value <code title="">checked</code>. The UA must then
1.788 mike 3145: <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the
1.1 mike 3146: element.</p></dd>
3147:
3148:
3149: <dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
3150: in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state</dt>
3151:
3152: <dd><p>If the element has a parent, then the UA must walk the list
3153: of child nodes of that parent element, and for each node that is a
3154: <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
3155: 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
3156: they were the empty string), and has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, must remove
3157: that attribute.</p>
3158:
3159: <p>Then, the element's <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute attribute
3160: must be set to the literal value <code title="">checked</code> and
1.788 mike 3161: the user agent must <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code>
1.1 mike 3162: event</a> at the element.</p></dd>
3163:
3164:
3165: <dt>Otherwise</dt>
3166:
1.987 mike 3167: <dd><p>The element has no <a href="content-models.html#activation-behavior">activation behavior</a>.</p></dd>
1.1 mike 3168:
1.875 mike 3169: </dl><p class="note">Firing a synthetic <code title="event-click"><a href="infrastructure.html#event-click">click</a></code> event at the element does not cause
1.1 mike 3170: any of the actions described above to happen.</p>
3171:
3172: <!-- v2COMMAND: the command="" attribute to make a <command> element
3173: reflect the state of another command, so that the script can update
3174: one place in the page and have context menus, toolbars, shortcuts,
3175: etc, automatically update. Once we add this, expose the Triggers
3176: facet again. -->
3177:
1.117 mike 3178: </div><p class="note"><code><a href="#the-command">command</a></code> elements are not rendered
1.520 mike 3179: unless they <a href="#menus" title="menu">form part of a menu</a>.</p><div class="example">
3180:
3181: <p>Here is an example of a toolbar with three buttons that let the
3182: user toggle between left, center, and right alignment. One could
3183: imagine such a toolbar as part of a text editor. The toolbar also
3184: has a separator followed by another button labeled "Publish",
3185: though that button is disabled.</p>
3186:
3187: <pre><menu type="toolbar">
3188: <command type="radio" radiogroup="alignment" checked="checked"
3189: label="Left" icon="icons/alL.png" onclick="setAlign('left')">
3190: <command type="radio" radiogroup="alignment"
3191: label="Center" icon="icons/alC.png" onclick="setAlign('center')">
3192: <command type="radio" radiogroup="alignment"
3193: label="Right" icon="icons/alR.png" onclick="setAlign('right')">
3194: <hr>
3195: <command type="command" disabled
3196: label="Publish" icon="icons/pub.png" onclick="publish()">
3197: </menu></pre>
3198:
1.886 mike 3199: </div><h4 id="menus"><span class="secno">4.11.4 </span>The <dfn><code>menu</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
1.987 mike 3200: <dd><a href="content-models.html#flow-content">Flow content</a>.</dd>
3201: <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="content-models.html#interactive-content">Interactive content</a>.</dd>
1.1 mike 3202: <dt>Contexts in which this element may be used:</dt>
1.987 mike 3203: <dd>Where <a href="content-models.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 3204: <dt>Content model:</dt>
1.987 mike 3205: <dd>Either: Zero or more <code><a href="grouping-content.html#the-li-element">li</a></code> elements.</dd>
3206: <dd>Or: <a href="content-models.html#flow-content">Flow content</a>.</dd>
1.1 mike 3207: <dt>Content attributes:</dt>
1.987 mike 3208: <dd><a href="elements.html#global-attributes">Global attributes</a></dd>
1.1 mike 3209: <dd><code title="attr-menu-type"><a href="#attr-menu-type">type</a></code></dd>
3210: <dd><code title="attr-menu-label"><a href="#attr-menu-label">label</a></code></dd>
3211: <dt>DOM interface:</dt>
3212: <dd>
1.987 mike 3213: <pre class="idl">interface <dfn id="htmlmenuelement">HTMLMenuElement</dfn> : <a href="elements.html#htmlelement">HTMLElement</a> {
1.1 mike 3214: attribute DOMString <a href="#dom-menu-type" title="dom-menu-type">type</a>;
3215: attribute DOMString <a href="#dom-menu-label" title="dom-menu-label">label</a>;
3216: };</pre>
1.117 mike 3217: </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.987 mike 3218: is an <a href="common-microsyntaxes.html#enumerated-attribute">enumerated attribute</a> indicating the kind of menu
1.1 mike 3219: being declared. The attribute has three states. The <code title="attr-menu-type-context">context</code> keyword maps to the
3220: <dfn id="context-menu-state" title="context menu state">context menu</dfn> state, in which
3221: the element is declaring a context menu. The <code title="attr-menu-type-toolbar">toolbar</code> keyword maps to the
1.385 mike 3222: <dfn id="toolbar-state" title="toolbar state">toolbar</dfn> state, in which the
3223: element is declaring a toolbar. The attribute may also be
1.1 mike 3224: omitted. The <i>missing value default</i> is the <dfn id="list-state" title="list
3225: state">list</dfn> state, which indicates that the element is merely
3226: a list of commands that is neither declaring a context menu nor
1.385 mike 3227: 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.987 mike 3228: element <a href="rendering.html#represents">represents</a> the commands of a context menu, and
1.1 mike 3229: the user can only interact with the commands if that context menu is
1.385 mike 3230: 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.987 mike 3231: <a href="rendering.html#represents">represents</a> a list of active commands that the user can
1.117 mike 3232: 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.987 mike 3233: <a href="rendering.html#represents">represents</a> an unordered list of items (each represented
3234: by an <code><a href="grouping-content.html#the-li-element">li</a></code> element), each of which represents a command
1.1 mike 3235: that the user can perform or activate, or, if the element has no
1.987 mike 3236: <code><a href="grouping-content.html#the-li-element">li</a></code> element children, <a href="content-models.html#flow-content">flow content</a>
1.117 mike 3237: describing available commands.</p><p>The <dfn id="attr-menu-label" title="attr-menu-label"><code>label</code></dfn>
1.1 mike 3238: attribute gives the label of the menu. It is used by user agents to
3239: display nested menus in the UI. For example, a context menu
3240: 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 3241: menu label.</p><div class="impl">
1.1 mike 3242:
1.186 mike 3243: <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.987 mike 3244: <a href="common-dom-interfaces.html#reflect">reflect</a> the respective content attributes of the same
1.1 mike 3245: name.</p>
3246:
1.886 mike 3247: </div><h5 id="menus-intro"><span class="secno">4.11.4.1 </span>Introduction</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><i>This section is non-normative.</i></p><p>The <code><a href="#menus">menu</a></code> element is used to define context menus and
1.385 mike 3248: toolbars.</p><p>For example, the following represents a toolbar with three menu
1.148 mike 3249: buttons on it, each of which has a dropdown menu with a series of
3250: options:</p><pre><menu type="toolbar">
1.1 mike 3251: <li>
3252: <menu label="File">
3253: <button type="button" onclick="fnew()">New...</button>
3254: <button type="button" onclick="fopen()">Open...</button>
1.290 mike 3255: <button type="button" onclick="fsave()">Save</button>
1.1 mike 3256: <button type="button" onclick="fsaveas()">Save as...</button>
3257: </menu>
3258: </li>
3259: <li>
3260: <menu label="Edit">
3261: <button type="button" onclick="ecopy()">Copy</button>
3262: <button type="button" onclick="ecut()">Cut</button>
3263: <button type="button" onclick="epaste()">Paste</button>
3264: </menu>
3265: </li>
3266: <li>
3267: <menu label="Help">
3268: <li><a href="help.html">Help</a></li>
3269: <li><a href="about.html">About</a></li>
3270: </menu>
3271: </li>
1.718 mike 3272: </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="http://dev.w3.org/html5/spec/images/sample-toolbar-1.png"></p><p>In a legacy user agent, the above would look like a bulleted list
1.148 mike 3273: with three items, the first of which has four buttons, the second of
3274: which has three, and the third of which has two nested bullet points
3275: with two items consisting of links.</p><hr><p>The following implements a similar toolbar, with a single button
3276: whose values, when selected, redirect the user to Web sites.</p><pre><form action="redirect.cgi">
3277: <menu type="toolbar">
1.1 mike 3278: <label for="goto">Go to...</label>
3279: <menu label="Go">
1.746 mike 3280: <select id="goto"<!--
1.1 mike 3281: onchange="if (this.options[this.selectedIndex].value)
1.746 mike 3282: window.location = this.options[this.selectedIndex].value"-->>
1.1 mike 3283: <option value="" selected="selected"> Select site: </option>
3284: <option value="http://www.apple.com/"> Apple </option>
3285: <option value="http://www.mozilla.org/"> Mozilla </option>
3286: <option value="http://www.opera.com/"> Opera </option>
3287: </select>
3288: <span><input type="submit" value="Go"></span>
3289: </menu>
3290: </menu>
1.148 mike 3291: </form></pre><p>The behavior in supporting user agents is similar to the example
1.875 mike 3292: above, but here the legacy behavior consists of a single
1.987 mike 3293: <code><a href="the-button-element.html#the-select-element">select</a></code> element with a submit button. The submit button
1.148 mike 3294: doesn't appear in the toolbar, because it is not a direct child of
1.987 mike 3295: the <code><a href="#menus">menu</a></code> element or of its <code><a href="grouping-content.html#the-li-element">li</a></code>
1.148 mike 3296: children.</p><div class="impl">
1.1 mike 3297:
1.886 mike 3298: <h5 id="building-menus-and-toolbars"><span class="secno">4.11.4.2 </span><dfn>Building menus and toolbars</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3299:
1.385 mike 3300: <p>A menu (or toolbar) consists of a list of zero or more of the
1.1 mike 3301: following components:</p>
3302:
1.987 mike 3303: <ul class="brief"><li><a href="commands.html#concept-command" title="concept-command">Commands</a>, which can be marked as default commands</li>
1.1 mike 3304: <li>Separators</li>
3305: <li>Other menus (which allows the list to be nested)</li>
3306: </ul><p>The list corresponding to a particular <code><a href="#menus">menu</a></code> element
3307: is built by iterating over its child nodes. For each child node in
3308: <a href="infrastructure.html#tree-order">tree order</a>, the required behavior depends on what the
3309: node is, as follows:</p>
3310:
1.987 mike 3311: <dl class="switch"><dt>An element that <a href="commands.html#concept-command" title="concept-command">defines a command</a></dt>
1.1 mike 3312:
1.987 mike 3313: <dd>Append the command to the menu, respecting its <a href="commands.html#concept-facet" title="concept-facet">facets</a><!-- we might need to be
1.1 mike 3314: explicit about what this means for each facet, if testing shows
3315: this isn't well-implemented. e.g.: If there's an Icon facet for the
1.408 mike 3316: command, it should be <span title="fetch">fetched</span> (this
3317: would be http-origin privacy-sensitive), and then that image should
3318: be associated with the command, such that each command only has its
3319: image fetched once, to prevent changes to the base URL from having
3320: effects after the image has been fetched once. (no need to resolve
3321: the Icon facet, it's an absolute URL) -->. <!--If the element is a
3322: <code>command</code> element with a <code
3323: title="attr-command-default">default</code> attribute, mark the
3324: command as being a default command.--></dd>
1.1 mike 3325:
3326:
1.987 mike 3327: <dt>An <code><a href="grouping-content.html#the-hr-element">hr</a></code> element</dt>
3328: <dt>An <code><a href="the-button-element.html#the-option-element">option</a></code> element that has a <code title="attr-option-value"><a href="the-button-element.html#attr-option-value">value</a></code> attribute set to the empty
3329: string, and has a <code title="attr-option-disabled"><a href="the-button-element.html#attr-option-disabled">disabled</a></code> attribute, and whose
1.804 mike 3330: <code><a href="infrastructure.html#textcontent">textContent</a></code> consists of a string of one or more
1.1 mike 3331: hyphens (U+002D HYPHEN-MINUS)</dt>
3332:
3333: <dd>Append a separator to the menu.</dd>
3334:
3335:
1.987 mike 3336: <dt>An <code><a href="grouping-content.html#the-li-element">li</a></code> element</dt>
1.1 mike 3337: <dt>A <code><a href="forms.html#the-label-element">label</a></code> element</dt>
3338:
3339: <dd>Iterate over the children of the element.</dd>
3340:
3341:
3342: <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>
1.987 mike 3343: <dt>A <code><a href="the-button-element.html#the-select-element">select</a></code> element</dt>
1.1 mike 3344:
3345: <dd>Append a separator to the menu, then iterate over the children
1.987 mike 3346: of the <code><a href="#menus">menu</a></code> or <code><a href="the-button-element.html#the-select-element">select</a></code> element, then
1.1 mike 3347: append another separator.</dd>
3348:
3349: <!-- v2: we might want to support <select> in <label> as giving a named submenu -->
3350:
3351:
3352: <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>
1.987 mike 3353: <dt>An <code><a href="the-button-element.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>
1.1 mike 3354:
3355: <dd>Append a submenu to the menu, using the value of the element's
3356: <code title="">label</code> attribute as the label of the menu. The
3357: submenu must be constructed by taking the element and creating a
3358: new menu for it using the complete process described in this
3359: section.</dd>
3360:
3361:
3362: <dt>Any other node</dt>
3363:
3364: <dd><a href="infrastructure.html#ignore">Ignore</a> the node.</dd>
3365:
3366: </dl><p>Once all the nodes have been processed as described above, the
3367: user agent must the post-process the menu as follows:</p>
3368:
1.521 mike 3369: <ol><li>Except for separators, any menu item with no label, or whose
3370: label is the empty string, must be removed.</li>
1.1 mike 3371:
1.521 mike 3372: <li>Any sequence of two or more separators in a row must be
3373: collapsed to a single separator.</li>
1.1 mike 3374:
1.521 mike 3375: <li>Any separator at the start or end of the menu must be
3376: removed.</li>
1.1 mike 3377:
1.886 mike 3378: </ol></div><h5 id="context-menus"><span class="secno">4.11.4.3 </span><dfn>Context menus</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-contextmenu" title="attr-contextmenu"><code>contextmenu</code></dfn>
1.1 mike 3379: attribute gives the element's <a href="#context-menus" title="context menus">context
3380: menu</a>. The value must be the ID of a <code><a href="#menus">menu</a></code> element
3381: in the DOM. <span class="impl">If the node that would be obtained by
1.875 mike 3382: the invoking the <code title="dom-Document-getElementById"><a href="infrastructure.html#dom-document-getelementbyid">getElementById()</a></code> method
3383: using the attribute's value as the only argument is null or not a
1.1 mike 3384: <code><a href="#menus">menu</a></code> element, then the element has no assigned context
3385: menu. Otherwise, the element's assigned context menu is the element
1.117 mike 3386: so identified.</span></p><div class="impl">
1.1 mike 3387:
3388: <p>When an element's context menu is requested (e.g. by the user
3389: right-clicking the element, or pressing a context menu key), the UA
1.788 mike 3390: must <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-contextmenu">contextmenu</code> that bubbles and is
1.1 mike 3391: cancelable at the element for which the menu was requested.</p>
3392:
3393: <p class="note">Typically, therefore, the firing of the <code title="event-contextmenu">contextmenu</code> event will be the
3394: default action of a <code title="mouseup">mouseup</code> or <code title="event-keyup">keyup</code> event. The exact sequence of events
3395: is UA-dependent, as it will vary based on platform conventions.</p>
3396:
3397: <p>The default action of the <code title="event-contextmenu">contextmenu</code> event depends on
3398: whether the element or one of its ancestors has a context menu
3399: assigned (using the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> attribute) or not. If
3400: there is no context menu assigned, the default action must be for
3401: the user agent to show its default context menu, if it has one.</p>
3402:
3403: <p>If the element or one of its ancestors <em>does</em> have a
1.788 mike 3404: context menu assigned, then the user agent must <a href="webappapis.html#fire-a-simple-event">fire a simple
1.454 mike 3405: event</a> named <code title="event-show">show</code> at the
1.1 mike 3406: <code><a href="#menus">menu</a></code> element of the context menu of the nearest
3407: ancestor (including the element itself) with one assigned.</p>
3408: <!-- v2: include modifier key information -->
3409:
3410: <p>The default action of <em>this</em> event is that the user agent
1.385 mike 3411: must show a context menu <a href="#building-menus-and-toolbars" title="building menus and
3412: toolbars">built</a> from the <code><a href="#menus">menu</a></code> element.</p>
1.1 mike 3413:
3414: <p>The user agent may also provide access to its default context
3415: menu, if any, with the context menu shown. For example, it could
3416: merge the menu items from the two menus together, or provide the
3417: page's context menu as a submenu of the default menu.</p>
3418:
3419: <p>If the user dismisses the menu without making a selection,
3420: nothing in particular happens.</p>
3421:
1.987 mike 3422: <p>If the user selects a menu item that represents a <a href="commands.html#concept-command" title="concept-command">command</a>, then the UA must invoke
3423: that command's <a href="commands.html#command-facet-action" title="command-facet-Action">Action</a>.</p>
1.1 mike 3424:
3425: <p>Context menus must not, while being shown, reflect changes in the
1.521 mike 3426: DOM; they are constructed as the default action of the <code title="event-show">show</code> event and must remain as constructed
3427: until dismissed.</p>
1.1 mike 3428:
3429: <p>User agents may provide means for bypassing the context menu
3430: processing model, ensuring that the user can always access the UA's
3431: default context menus. For example, the user agent could handle
3432: right-clicks that have the Shift key depressed in such a way that it
3433: does not fire the <code title="event-contextmenu">contextmenu</code>
3434: event and instead always shows the default context menu.</p>
3435:
3436: <p>The <dfn id="dom-contextmenu" title="dom-contextMenu"><code>contextMenu</code></dfn>
1.987 mike 3437: attribute must <a href="common-dom-interfaces.html#reflect">reflect</a> the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> content attribute.</p>
1.1 mike 3438:
1.520 mike 3439: </div><div class="example">
3440:
3441: <p>Here is an example of a context menu for an input control:</p>
3442:
3443: <pre><form name="npc">
3444: <label>Character name: <input name=char type=text contextmenu=namemenu required></label>
3445: <menu type=context id=namemenu>
3446: <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
3447: <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
3448: </menu>
3449: </form></pre>
3450:
1.994 mike 3451: <p>This adds two items to the control's context menu, one called
1.520 mike 3452: "Pick random name", and one called "Prefill other fields based on
3453: name". They invoke scripts that are not shown in the example
3454: above.</p>
3455:
1.117 mike 3456: </div><div class="impl">
1.1 mike 3457:
1.886 mike 3458: <h5 id="toolbars"><span class="secno">4.11.4.4 </span><dfn>Toolbars</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3459:
1.385 mike 3460: <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
3461: must <a href="#building-menus-and-toolbars" title="building menus and toolbars">build</a> the
1.1 mike 3462: menu for that <code><a href="#menus">menu</a></code> element, and use the result in the
3463: rendering.</p>
3464:
3465: <p>The user agent must reflect changes made to the
1.385 mike 3466: <code><a href="#menus">menu</a></code>'s DOM, by immediately <a href="#building-menus-and-toolbars" title="building menus
3467: and toolbars">rebuilding</a> the menu.</p>
1.1 mike 3468:
1.117 mike 3469: </div></body></html>
Webmaster