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