Annotation of html5/spec/interactive-elements.html, revision 1.906
1.866 mike 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
1.885 mike 2: <!DOCTYPE html>
1.252 mike 3: <!-- when publishing, change bits marked ZZZ --><html lang="en-US-x-Hixie"><head><title>4.11 Interactive elements — HTML 5</title><style type="text/css">
1.1 mike 4: pre { margin-left: 2em; white-space: pre-wrap; }
5: h2 { margin: 3em 0 1em 0; }
6: h3 { margin: 2.5em 0 1em 0; }
7: h4 { margin: 2.5em 0 0.75em 0; }
8: h5, h6 { margin: 2.5em 0 1em; }
9: h1 + h2, h1 + h2 + h2 { margin: 0.75em 0 0.75em; }
10: h2 + h3, h3 + h4, h4 + h5, h5 + h6 { margin-top: 0.5em; }
11: p { margin: 1em 0; }
12: hr:not(.top) { display: block; background: none; border: none; padding: 0; margin: 2em 0; height: auto; }
13: dl, dd { margin-top: 0; margin-bottom: 0; }
14: dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; }
15: dt + dt { margin-top: 0; }
16: dd dt { margin-top: 0.25em; margin-bottom: 0; }
17: dd p { margin-top: 0; }
18: dd dl + p { margin-top: 1em; }
19: dd table + p { margin-top: 1em; }
20: p + * > li, dd li { margin: 1em 0; }
21: dt, dfn { font-weight: bold; font-style: normal; }
22: dt dfn { font-style: italic; }
23: pre, code { font-size: inherit; font-family: monospace; font-variant: normal; }
24: pre strong { color: black; font: inherit; font-weight: bold; background: yellow; }
25: pre em { font-weight: bolder; font-style: normal; }
26: @media screen { code { color: orangered; } code :link, code :visited { color: inherit; } }
27: var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; }
28: table { border-collapse: collapse; border-style: hidden hidden none hidden; }
29: table thead { border-bottom: solid; }
30: table tbody th:first-child { border-left: solid; }
1.469 mike 31: table tbody th { text-align: left; }
1.1 mike 32: table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; }
33: blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; }
34:
35: .bad, .bad *:not(.XXX) { color: gray; border-color: gray; background: transparent; }
36: .matrix, .matrix td { border: none; text-align: right; }
37: .matrix { margin-left: 2em; }
38: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
39: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
40: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
41:
42: .toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; }
43: img.extra { float: right; }
44: pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; }
45: pre.idl :link, pre.idl :visited { color: inherit; background: transparent; }
46: pre.css { border: solid thin; background: #FFFFEE; color: black; padding: 0.5em 1em; }
47: pre.css:first-line { color: #AAAA50; }
1.834 mike 48: dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
1.1 mike 49: hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
50: dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
51: dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
52: dl.domintro dd p { margin: 0.5em 0; }
53: dl.switch { padding-left: 2em; }
54: dl.switch > dt { text-indent: -1.5em; }
55: dl.switch > dt:before { content: '\21AA'; padding: 0 0.5em 0 0; display: inline-block; width: 1em; text-align: right; line-height: 0.5em; }
56: dl.triple { padding: 0 0 0 1em; }
57: dl.triple dt, dl.triple dd { margin: 0; display: inline }
58: dl.triple dt:after { content: ':'; }
59: dl.triple dd:after { content: '\A'; white-space: pre; }
60: .diff-old { text-decoration: line-through; color: silver; background: transparent; }
61: .diff-chg, .diff-new { text-decoration: underline; color: green; background: transparent; }
62: a .diff-new { border-bottom: 1px blue solid; }
63:
64: h2 { page-break-before: always; }
65: h1, h2, h3, h4, h5, h6 { page-break-after: avoid; }
66: h1 + h2, hr + h2.no-toc { page-break-before: auto; }
67:
68: p > span:not([title=""]):not([class="XXX"]):not([class="impl"]), li > span:not([title=""]):not([class="XXX"]):not([class="impl"]) { border-bottom: solid #9999CC; }
69:
70: div.head { margin: 0 0 1em; padding: 1em 0 0 0; }
71: div.head p { margin: 0; }
72: div.head h1 { margin: 0; }
73: div.head .logo { float: right; margin: 0 1em; }
74: div.head .logo img { border: none } /* remove border from top image */
75: div.head dl { margin: 1em 0; }
1.665 mike 76: div.head p.copyright, div.head p.alt { font-size: x-small; font-style: oblique; margin: 0; }
1.1 mike 77:
78: body > .toc > li { margin-top: 1em; margin-bottom: 1em; }
79: body > .toc.brief > li { margin-top: 0.35em; margin-bottom: 0.35em; }
80: body > .toc > li > * { margin-bottom: 0.5em; }
81: body > .toc > li > * > li > * { margin-bottom: 0.25em; }
82: .toc, .toc li { list-style: none; }
83:
84: .brief { margin-top: 1em; margin-bottom: 1em; line-height: 1.1; }
85: .brief li { margin: 0; padding: 0; }
86: .brief li p { margin: 0; padding: 0; }
87:
88: .category-list { margin-top: -0.75em; margin-bottom: 1em; line-height: 1.5; }
89: .category-list::before { content: '\21D2\A0'; font-size: 1.2em; font-weight: 900; }
90: .category-list li { display: inline; }
91: .category-list li:not(:last-child)::after { content: ', '; }
92: .category-list li > span, .category-list li > a { text-transform: lowercase; }
93: .category-list li * { text-transform: none; } /* don't affect <code> nested in <a> */
94:
95: .XXX { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; }
96: .XXX > :first-child { margin-top: 0; }
97: p .XXX { line-height: 3em; }
1.153 mike 98: .annotation { border: solid thin black; background: #0C479D; color: white; position: relative; margin: 8px 0 20px 0; }
99: .annotation:before { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 6px -6px -6px 6px; background: #333333; z-index: -1; content: ''; }
100: .annotation :link, .annotation :visited { color: inherit; }
101: .annotation :link:hover, .annotation :visited:hover { background: transparent; }
102: .annotation span { border: none ! important; }
1.1 mike 103: .note { color: green; background: transparent; font-family: sans-serif; }
104: .warning { color: red; background: transparent; }
105: .note, .warning { font-weight: bolder; font-style: italic; }
106: p.note, div.note { padding: 0.5em 2em; }
107: span.note { padding: 0 2em; }
108: .note p:first-child, .warning p:first-child { margin-top: 0; }
109: .note p:last-child, .warning p:last-child { margin-bottom: 0; }
110: .warning:before { font-style: normal; }
111: p.note:before { content: 'Note: '; }
112: p.warning:before { content: '\26A0 Warning! '; }
113:
114: .bookkeeping:before { display: block; content: 'Bookkeeping details'; font-weight: bolder; font-style: italic; }
115: .bookkeeping { font-size: 0.8em; margin: 2em 0; }
116: .bookkeeping p { margin: 0.5em 2em; display: list-item; list-style: square; }
117:
118: h4 { position: relative; z-index: 3; }
119: h4 + .element, h4 + div + .element { margin-top: -2.5em; padding-top: 2em; }
120: .element {
121: background: #EEEEFF;
122: color: black;
123: margin: 0 0 1em 0.15em;
124: padding: 0 1em 0.25em 0.75em;
125: border-left: solid #9999FF 0.25em;
126: position: relative;
127: z-index: 1;
128: }
129: .element:before {
130: position: absolute;
131: z-index: 2;
132: top: 0;
133: left: -1.15em;
134: height: 2em;
135: width: 0.9em;
136: background: #EEEEFF;
137: content: ' ';
138: border-style: none none solid solid;
139: border-color: #9999FF;
140: border-width: 0.25em;
141: }
142:
1.143 mike 143: .example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin-left: 2em; padding-left: 1em; }
144: td > .example:only-child { margin: 0 0 0 0.1em; }
1.1 mike 145:
146: ul.domTree, ul.domTree ul { padding: 0 0 0 1em; margin: 0; }
147: ul.domTree li { padding: 0; margin: 0; list-style: none; position: relative; }
148: ul.domTree li li { list-style: none; }
149: 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; }
150: 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; }
151: ul.domTree span { font-style: italic; font-family: serif; }
152: ul.domTree .t1 code { color: purple; font-weight: bold; }
153: ul.domTree .t2 { font-style: normal; font-family: monospace; }
154: ul.domTree .t2 .name { color: black; font-weight: bold; }
155: ul.domTree .t2 .value { color: blue; font-weight: normal; }
156: ul.domTree .t3 code, .domTree .t4 code, .domTree .t5 code { color: gray; }
157: ul.domTree .t7 code, .domTree .t8 code { color: green; }
158: ul.domTree .t10 code { color: teal; }
159:
1.730 mike 160: body.dfnEnabled dfn { cursor: pointer; }
161: .dfnPanel {
162: display: inline;
163: position: absolute;
164: z-index: 10;
165: height: auto;
166: width: auto;
167: padding: 0.5em 0.75em;
168: font: small sans-serif, Droid Sans Fallback;
169: background: #DDDDDD;
170: color: black;
171: border: outset 0.2em;
172: }
173: .dfnPanel * { margin: 0; padding: 0; font: inherit; text-indent: 0; }
174: .dfnPanel :link, .dfnPanel :visited { color: black; }
175: .dfnPanel p { font-weight: bolder; }
176: .dfnPanel * + p { margin-top: 0.25em; }
177: .dfnPanel li { list-style-position: inside; }
178:
1.665 mike 179: #configUI { position: absolute; z-index: 20; top: 10em; right: 1em; width: 11em; font-size: small; }
180: #configUI p { margin: 0.5em 0; padding: 0.3em; background: #EEEEEE; color: black; border: inset thin; }
181: #configUI p label { display: block; }
182: #configUI #updateUI, #configUI .loginUI { text-align: center; }
183: #configUI input[type=button] { display: block; margin: auto; }
1.261 mike 184: </style><style type="text/css">
185:
1.286 mike 186: .applies thead th > * { display: block; }
187: .applies thead code { display: block; }
188: .applies tbody th { whitespace: nowrap; }
189: .applies td { text-align: center; }
190: .applies .yes { background: yellow; }
191:
1.261 mike 192: .matrix, .matrix td { border: none; text-align: right; }
193: .matrix { margin-left: 2em; }
194:
195: .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
196: .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
197: .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }
198:
199: #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
200: #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
201: #table-example-1 caption { padding-bottom: 0.5em; }
202: #table-example-1 thead, #table-example-1 tbody { border: none; }
203: #table-example-1 th, #table-example-1 td { border: solid thin; }
204: #table-example-1 th { font-weight: normal; }
205: #table-example-1 td { border-style: none solid; vertical-align: top; }
206: #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
207: #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
208: #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
209: #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
210: #table-example-1 tbody td:first-child::after { content: leader(". "); }
211: #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
212: #table-example-1 tbody td:first-child + td { width: 10em; }
213: #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
214: #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }
215:
216: .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
217: .apple-table-examples * { font-family: "Times", serif; }
218: .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
219: .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
220: .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
221: .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
222: .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
223: .apple-table-examples td { text-align: right; vertical-align: top; }
224: .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
225: .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
226: .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
227: .apple-table-examples sup { line-height: 0; }
228:
1.718 mike 229: .details-example img { vertical-align: top; }
230:
1.875 mike 231: #named-character-references-table {
232: font-size: 0.6em;
233: column-width: 28em;
234: column-gap: 1em;
235: -moz-column-width: 28em;
236: -moz-column-gap: 1em;
237: -webkit-column-width: 28em;
238: -webkit-column-gap: 1em;
239: }
240: #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
241: #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
242:
1.866 mike 243: </style><style type="text/css">
1.874 mike 244: .domintro:before { display: table; margin: -1em -0.5em -0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: black; font-style: italic; border: solid 2px; background: white; padding: 0 0.25em; }
245: </style><link href="data:text/css," id="complete" rel="stylesheet" title="Complete specification"><link href="data:text/css,.impl%20%7B%20display:%20none;%20%7D%0Ahtml%20%7B%20border:%20solid%20yellow;%20%7D%20.domintro:before%20%7B%20display:%20none;%20%7D" id="author" rel="alternate stylesheet" title="Author documentation only"><link href="data:text/css,.impl%20%7B%20background:%20%23FFEEEE;%20%7D%20.domintro:before%20%7B%20background:%20%23FFEEEE;%20%7D" id="highlight" rel="alternate stylesheet" title="Highlight implementation requirements"><script type="text/javascript">
1.665 mike 246: function getCookie(name) {
247: var params = location.search.substr(1).split("&");
248: for (var index = 0; index < params.length; index++) {
249: if (params[index] == name)
250: return "1";
251: var data = params[index].split("=");
252: if (data[0] == name)
253: return unescape(data[1]);
254: }
255: var cookies = document.cookie.split("; ");
256: for (var index = 0; index < cookies.length; index++) {
257: var data = cookies[index].split("=");
258: if (data[0] == name)
259: return unescape(data[1]);
260: }
261: return null;
262: }
263: function load(script) {
264: var e = document.createElement('script');
265: e.setAttribute('src', 'http://www.whatwg.org/specs/web-apps/current-work/' + script + '?' + encodeURIComponent(location) + '&' + encodeURIComponent(document.referrer));
266: document.body.appendChild(e);
267: }
268: function init() {
269: if (location.search == '?slow-browser')
270: return;
271: var configUI = document.createElement('div');
272: configUI.id = 'configUI';
273: document.body.appendChild(configUI);
274: // load('reviewer.js'); // would need cross-site XHR
275: if (document.getElementById('head'))
276: load('toc.js');
277: load('styler.js');
278: // load('updater.js'); // would need cross-site XHR
1.718 mike 279: load('dfn.js'); // doesn't support split-out specs, but, oh well.
1.665 mike 280: // load('status.js'); // would need cross-site XHR
281: if (getCookie('profile') == '1')
282: document.getElementsByTagName('h2')[0].textContent += '; load: ' + (new Date() - loadTimer) + 'ms';
283: fixBrokenLink();
284: }
1.896 mike 285: </script><link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel="stylesheet" type="text/css">
1.867 mike 286: <script src="link-fixup.js" type="text/javascript"></script>
1.2 mike 287: <link href="forms.html" title="4.10 Forms" rel="prev">
288: <link href="spec.html#contents" title="Table of contents" rel="index">
1.749 mike 289: <link href="browsers.html" title="5 Loading Web pages" rel="next">
1.665 mike 290: </head><body onload="fixBrokenLink(); init()"><div class="head" id="head">
1.1 mike 291: <p><a href="http://www.w3.org/"><img alt="W3C" height="48" src="http://www.w3.org/Icons/w3c_home" width="72"></a></p>
1.177 mike 292: <h1>HTML5</h1>
1.906 ! mike 293: <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><p>This is revision 1.4003.</p>
1.896 mike 294:
1.876 mike 295:
1.868 mike 296: </div><div>
1.1 mike 297: <a href="forms.html">← 4.10 Forms</a> –
1.2 mike 298: <a href="spec.html#contents">Table of contents</a> –
1.749 mike 299: <a href="browsers.html">5 Loading Web pages →</a>
1.868 mike 300: </div>
1.1 mike 301:
1.886 mike 302: <h3 id="interactive-elements"><span class="secno">4.11 </span>Interactive elements</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><h4 id="the-details-element"><span class="secno">4.11.1 </span>The <dfn><code>details</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments. </i><span><a href="http://www.w3.org/html/wg/tracker/issues/93">ISSUE-93</a> (details) blocks progress to Last Call</span></p><dl class="element"><dt>Categories</dt>
1.153 mike 303: <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
1.518 mike 304: <dd><a href="semantics.html#sectioning-root">Sectioning root</a>.</dd>
1.153 mike 305: <dd><a href="embedded-content-0.html#interactive-content">Interactive content</a>.</dd>
1.1 mike 306: <dt>Contexts in which this element may be used:</dt>
1.153 mike 307: <dd>Where <a href="dom.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 308: <dt>Content model:</dt>
1.729 mike 309: <dd>One <code><a href="#the-summary-element">summary</a></code> element followed by <a href="dom.html#flow-content">flow content</a>.</dd>
1.1 mike 310: <dt>Content attributes:</dt>
311: <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
312: <dd><code title="attr-details-open"><a href="#attr-details-open">open</a></code></dd>
313: <dt>DOM interface:</dt>
314: <dd>
315: <pre class="idl">interface <dfn id="htmldetailselement">HTMLDetailsElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
316: attribute boolean <a href="#dom-details-open" title="dom-details-open">open</a>;
317: };</pre>
318: </dd>
1.307 mike 319: </dl><p>The <code><a href="#the-details-element">details</a></code> element <a href="the-xhtml-syntax.html#represents">represents</a> a
320: disclosure widget from which the user can obtain additional
321: information or controls.</p><p class="note">The <code><a href="#the-details-element">details</a></code> element is not appropriate
1.299 mike 322: for footnotes. Please see <a href="#footnotes">the section on
1.729 mike 323: footnotes</a> for details on how to mark up footnotes.</p><p>The <span class="impl">first</span> <code><a href="#the-summary-element">summary</a></code> element
324: child of the element, if any, <a href="the-xhtml-syntax.html#represents">represents</a> the summary or
325: legend of the details. <span class="impl">If there is no child
326: <code><a href="#the-summary-element">summary</a></code> element, the user agent should provide its own
327: legend (e.g. "Details").</span></p><p>The <dfn id="attr-details-open" title="attr-details-open"><code>open</code></dfn>
1.1 mike 328: content attribute is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a>. If present,
329: it indicates that the details are to be shown to the user. If the
1.117 mike 330: attribute is absent, the details are not to be shown.</p><div class="impl">
1.1 mike 331:
332: <p>If the attribute is removed, then the details should be
333: hidden. If the attribute is added, the details should be shown.</p>
334:
335: <p>The user agent should allow the user to request that the details
336: be shown or hidden. To honor a request for the details to be shown,
337: the user agent must set the <code title="attr-details-open"><a href="#attr-details-open">open</a></code> attribute on the element to
338: the value <code title="">open</code>. To honor a request for the
339: 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
340: element.</p>
341:
342: <p>The <dfn id="dom-details-open" title="dom-details-open"><code>open</code></dfn>
343: 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>
344:
1.271 mike 345: </div><div class="example">
346:
347: <p>The following example shows the <code><a href="#the-details-element">details</a></code> element
348: being used to hide technical details in a progress report.</p>
349:
350: <pre><section class="progress window">
351: <h1>Copying "Really Achieving Your Childhood Dreams"</h1>
352: <details>
1.876 mike 353: <summary>Copying... <progress max="375505392" value="97543282"></progress> 25%</summary>
1.729 mike 354: <dl>
355: <dt>Transfer rate:</dt> <dd>452KB/s</dd>
356: <dt>Local filename:</dt> <dd>/home/rpausch/raycd.m4v</dd>
357: <dt>Remote filename:</dt> <dd>/var/www/lectures/raycd.m4v</dd>
358: <dt>Duration:</dt> <dd>01:16:27</dd>
359: <dt>Color profile:</dt> <dd>SD (6-1-6)</dd>
360: <dt>Dimensions:</dt> <dd>320×240</dd>
361: </dl>
1.271 mike 362: </details>
363: </section></pre>
364:
1.718 mike 365: </div><div class="example">
366:
367: <p>The following shows how a <code><a href="#the-details-element">details</a></code> element can be
368: used to hide some controls by default:</p>
369:
370: <pre><details>
1.729 mike 371: <summary>Name & Extension:</summary>
372: <p><input type=text name=fn value="Pillar Magazine.pdf">
373: <p><label><input type=checkbox name=ext checked> Hide extension</label>
1.718 mike 374: </details></pre>
375:
376: <p>One could use this in conjuction with other <code><a href="#the-details-element">details</a></code>
377: in a list to allow the user to collapse a set of fields down to a
378: small set of headings, with the ability to open each one.</p>
379:
380: <p class="details-example"><img alt="" src="http://dev.w3.org/html5/spec/images/sample-details-1.png"><img alt="" src="http://dev.w3.org/html5/spec/images/sample-details-2.png"></p>
381:
1.729 mike 382: <p>In these examples, the summary really just summarises what the
383: controls can change, and not the actual values, which is less than
384: ideal.</p>
385:
386: </div><h4 id="the-summary-element"><span class="secno">4.11.2 </span>The <dfn><code>summary</code></dfn> element</h4><dl class="element"><dt>Categories</dt>
387: <dd>None.</dd>
388: <dt>Contexts in which this element may be used:</dt>
389: <dd>As the first child of a <code><a href="#the-details-element">details</a></code> element.</dd>
390: <dt>Content model:</dt>
391: <dd><a href="dom.html#phrasing-content">Phrasing content</a>.</dd>
392: <dt>Content attributes:</dt>
393: <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
394: <dt>DOM interface:</dt>
395: <dd>Uses <code><a href="dom.html#htmlelement">HTMLElement</a></code>.</dd>
396: </dl><p>The <code><a href="#the-summary-element">summary</a></code> element <a href="the-xhtml-syntax.html#represents">represents</a> a
397: summary, caption, or legend for the rest of the contents of the
398: <code><a href="#the-summary-element">summary</a></code> element's parent <code><a href="#the-details-element">details</a></code>
399: element<span class="impl">, if any</span>.</p><!-- v2DATAGRID
1.80 mike 400: <h4 id="datagrid">The <dfn><code>datagrid</code></dfn> element</h4>
401:
402: <dl class="element">
403: <dt>Categories</dt>
404: <dd><span>Flow content</span>.</dd>
405: <dd><span>Interactive content</span>.</dd>
406: <dd><span>Sectioning root</span>.</dd>
1.1 mike 407: <dt>Contexts in which this element may be used:</dt>
1.80 mike 408: <dd>Where <span>flow content</span> is expected.</dd>
1.1 mike 409: <dt>Content model:</dt>
1.80 mike 410: <dd><span>Flow content</span>.</dd>
1.1 mike 411: <dt>Content attributes:</dt>
1.80 mike 412: <dd><span>Global attributes</span></dd>
413: <!- -v2DGS:
1.1 mike 414: <dd><code title="attr-datagrid-multiple">multiple</code></dd>
1.80 mike 415: - ->
416: <dd><code title="attr-datagrid-disabled">disabled</code></dd>
1.1 mike 417: <dt>DOM interface:</dt>
418: <dd>
1.80 mike 419: <pre class="idl">interface <dfn>HTMLDataGridElement</dfn> : <span>HTMLElement</span> {
420: <!- -v2DGS:
1.1 mike 421: attribute boolean <span title="dom-datagrid-multiple">multiple</span>;
1.80 mike 422: - -> attribute boolean <span title="dom-datagrid-disabled">disabled</span>;
423: attribute <span>DataGridListener</span> <span title="dom-datagrid-listener">listener</span>;
424: <!- - v2DGS:
1.1 mike 425: readonly attribute <span>DataGridSelection</span> <span title="dom-datagrid-selection">selection</span>;
1.80 mike 426: - ->
1.1 mike 427: // columns
1.395 mike 428: void <span title="dom-datagrid-addColumn">addColumn</span>(in <span>Column</span> id, in DOMString label, in DOMString type, in optional HTMLImageElement icon, in optional boolean sortable, in optional boolean hidden);
1.80 mike 429: attribute DOMString <span title="dom-datagrid-sortColumn">sortColumn</span>;
430: attribute boolean <span title="dom-datagrid-sortAscending">sortAscending</span>;
431: void <span title="dom-datagrid-clearColumns">clearColumns</span>();
1.1 mike 432:
433: // rows
1.80 mike 434: void <span title="dom-datagrid-renotify">renotify</span>();
435: void <span title="dom-datagrid-setRowCount">setRowCount</span>(in long childCount, in long rowCount);
436: void <span title="dom-datagrid-setRows">setRows</span>(in <span>RowList</span> rows);
437: void <span title="dom-datagrid-insertRows">insertRows</span>(in <span>RowList</span> rows);
438: void <span title="dom-datagrid-deleteRows">deleteRows</span>(in <span>RowIDList</span> rows);
439: void <span title="dom-datagrid-repaint">repaint</span>(in <span>RowID</span> row, in DOMString column);
440: void <span title="dom-datagrid-clearRows">clearRows</span>();
441: <!- -
1.1 mike 442: v2: opening and closing a row
443: moving a row's actual ID
444: - 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
445: - though actually that should probably just be done using display sorting
1.80 mike 446: - ->
1.1 mike 447: };
448:
1.80 mike 449: typedef DOMString <dfn>Column</dfn>;
450: typedef sequence<<span>Column</span>> <dfn>ColumnList</dfn>;
1.81 mike 451: typedef sequence<any> <dfn>Cell</dfn>; // <span>Column</span>, any... (exact types expected depend on the column type)
1.80 mike 452: typedef sequence<<span>Cell</span>> <dfn>CellList</dfn>;
1.81 mike 453: typedef sequence<any> <dfn>Row</dfn>; // <span>RowID</span>, long, long, <span>CellList</span>, optional boolean, optional long
1.80 mike 454: typedef sequence<<span>Row</span>> <dfn>RowList</dfn>;
455: typedef sequence<unsigned long> <dfn>RowID</dfn>;
456: typedef sequence<<span>RowID</span>> <dfn>RowIDList</dfn>;
1.1 mike 457:
458: [Callback=FunctionOnly, NoInterfaceObject]
1.80 mike 459: interface <dfn>RenderingContext2DCallback</dfn> {
460: DOMString <span title="dom-Rendering2DContextCallback-handleEvent">handleEvent</span>(in <span>CanvasRenderingContext2D</span> context, in unsigned long width, in unsigned long height);
1.1 mike 461: };</pre>
462: </dd>
1.80 mike 463: </dl>
464:
465: <!- - v2:
466: * datagrid: cells that are links (<a href=""></a>)
467: - ->
468:
469: <p>The <code>datagrid</code> element <span>represents</span> an
470: interactive representation of tree, list, or tabular data.</p>
471:
472: <p>The data being presented is provided by script using the methods
473: described in the following sections.</p>
474:
475: <!- -v2DGS:
1.1 mike 476: <p>The <dfn
477: title="attr-datagrid-multiple"><code>multiple</code></dfn> attribute
478: is a <span>boolean attribute</span>. When set, it indicates that the
479: user can select more than one row at a time.</p>
1.80 mike 480: - ->
481:
482: <p>The <dfn
483: title="attr-datagrid-disabled"><code>disabled</code></dfn> attribute
484: is a <span>boolean attribute</span> used to disable the
1.1 mike 485: control. <span class="impl">When the attribute is set, the user
1.80 mike 486: agent must disable the <code>datagrid</code>, preventing the user
487: from interacting with it. The <code>datagrid</code> element should
1.1 mike 488: still continue to update itself when the underlying data changes,
489: though, as described in the next few sections. However, conformance
1.80 mike 490: requirements stating that <code>datagrid</code> elements must react
1.1 mike 491: to users in particular ways do not apply when the
1.80 mike 492: <code>datagrid</code> is disabled.</span></p>
493:
494: <div class="impl">
1.1 mike 495:
1.80 mike 496: <!- -vsDGS: multiple - ->
1.1 mike 497:
1.80 mike 498: <p>The <dfn
1.186 mike 499: title="dom-datagrid-disabled"><code>disabled</code></dfn> IDL
1.80 mike 500: attribute must <span>reflect</span> the content attribute of the
1.1 mike 501: same name.</p>
502:
1.80 mike 503: </div>
504:
505: <!- - v2DGPA: One possible thing to be added is a way to detect when a
1.1 mike 506: row/selection has been deleted, activated, etc, by the user (delete
1.80 mike 507: key, enter key, etc). (v2DGPA = <datagrid> Perform Action) - ->
508:
509:
510: <h5>Introduction</h5>
511:
512: <p><i>This section is non-normative.</i></p>
513:
514: <p>In the <code>datagrid</code> data model, data is structured as a
1.1 mike 515: set of rows representing a tree, each row being split into a number
516: of columns. The columns are always present in the data model,
1.80 mike 517: although individual columns might be hidden in the presentation.</p>
518:
519: <hr>
520:
521: <p>Each row can have child rows. Child rows may be hidden or
522: shown, by closing or opening (respectively) the parent row.</p>
523:
524: <p>Rows are referred to by the path along the tree that one would
1.1 mike 525: take to reach the row, using zero-based indices. Thus, the first row
526: of a list is row "0", the second row is row "1"; the first child row
527: of the first row is row "0,0", the second child row of the first row
528: is row "0,1"; the fourth child of the seventh child of the third
1.80 mike 529: child of the tenth row is "9,2,6,3", etc.</p>
530:
531: <p>The chains of numbers that give a row's path, or identifier, are
1.1 mike 532: represented by arrays of positions, represented in IDL by the
1.80 mike 533: <span>RowID</span> interface.</p>
534:
535: <p>The root of the tree is represented by an empty array.</p>
536:
537: <hr>
538:
539: <p>Each column has a string that is used to identify it in the API,
1.1 mike 540: a label that is shown to users interacting with the column, a type,
1.80 mike 541: and optionally an icon.</p>
542:
543: <p>The possible types are as follows:</p>
544:
545: <table>
546: <thead>
547: <tr>
548: <td>Keyword
549: <td>Description
550: <tbody>
551: <tr>
552: <td><code title="datagrid-type-text">text</code>
553: <td>Simple text.
554: <tr>
555: <td><code title="datagrid-type-editable">editable</code>
556: <td>Editable text.
557: <tr>
558: <td><code title="datagrid-type-checkable">checkable</code>
559: <td>Text with a check box.
560: <tr>
561: <td><code title="datagrid-type-list">list</code>
562: <td>A list of values that the user can switch between.
563: <tr>
564: <td><code title="datagrid-type-progress">progress</code>
565: <td>A progress bar.
566: <tr>
567: <td><code title="datagrid-type-meter">meter</code>
568: <td>A gauge.
569: <tr>
570: <td><code title="datagrid-type-custom">custom</code>
571: <td>A canvas onto which arbitrary content can be drawn.
572: </table>
573:
574: <p>Each column can be flagged as sortable, in which case the user
575: will be able to sort the view using that column.</p>
576:
577: <p>Columns are not necessarily visible. A column can be created
1.1 mike 578: invisible by default. The user can select which columns are to be
1.80 mike 579: shown.</p>
580:
581: <p>When no columns have been added to the <code>datagrid</code>, a
1.1 mike 582: column with no name, whose identifier is the empty string, whose
1.80 mike 583: type is <code title="datagrid-type-text">text</code>, and which is
1.1 mike 584: not sortable, is implied. This column is removed if any explicit
1.80 mike 585: columns are declared.</p>
586:
587: <p>Each cell uses the type given for its column, so all cells in a
588: column present the same type of information.</p>
589:
590: <!- -v2DGS:
1.1 mike 591: <p>Selection of data in a <code>datagrid</code> operates at the row
592: level. If the <code title="attr-datagrid-multiple">multiple</code>
593: attribute is present, multiple rows can be selected at once,
594: otherwise the user can only select one row at a time.</p>
1.80 mike 595: - ->
596:
597: <!- - v2DGDND: selection should draggable to and from datagrids - ->
598:
599:
600: <h6>Example: a <code>datagrid</code> backed by a static <code>table</code> element</h6>
601:
602: ...
603:
604:
605: <h6>Example: a <code>datagrid</code> backed by nested <code>ol</code> elements</h6>
606:
607: ...
608:
609:
610: <h6>Example: a <code>datagrid</code> backed by a server</h6>
611:
612: ...
613:
614:
615: <h5>Populating the <code>datagrid</code></h5>
616:
617: <dl class="domintro">
618:
619: <dt><var title="">datagrid</var> . <code title="dom-datagrid-listener">listener</code> [ = <var title="">value</var> ]</dt>
1.1 mike 620: <dd>
621:
622: <p>Return the current object that is configured as the
1.80 mike 623: <code>datagrid</code> listener, if any. Returns null if there is
1.1 mike 624: none.</p>
625:
626: <p>The listener is an object provided by the script author that
1.80 mike 627: receives notifications when the <code>datagrid</code> needs row
1.1 mike 628: data to render itself, when the user opens and closes rows with
629: children, when the user edits a cell, and when the user invokes a
1.80 mike 630: row's context menu. (The <code>DataGridListener</code> interface
1.1 mike 631: used for this purpose is described in the next section.)</p>
632:
633: <p>Can be set, to change the current listener.</p>
634:
635: </dd>
636:
637:
1.80 mike 638: <dt><var title="">datagrid</var> . <code title="dom-datagrid-renotify">renotify</code>()</dt>
1.1 mike 639: <dd>
640:
1.80 mike 641: <p>Causes the <code>datagrid</code> to resend notifications to the
1.1 mike 642: listener (if any) for any rows or cells that the
1.80 mike 643: <code>datagrid</code> does not yet have information for.</p>
1.1 mike 644:
1.80 mike 645: <!- - useful, e.g., if there is a server error and the script loses
646: track of what rows it's supposed to be reporting. - ->
1.1 mike 647:
648: </dd>
649:
650:
1.80 mike 651: <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 652: <dd>
653:
1.80 mike 654: <p>Adds a column to the <code>datagrid</code>.</p>
1.1 mike 655:
656: <p>If a column with the given identifier has already been added,
657: it just replaces the information for that column.</p>
658:
659: <p>The possible types are enumerated in the previous section.</p>
660:
661: </dd>
662:
663:
1.80 mike 664: <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortColumn">sortColumn</code> [ = <var title="">value</var> ]</dt>
1.1 mike 665: <dd>
666:
667: <p>Returns the identifier of the column by which the data is to be
668: sorted.</p>
669:
670: <p>Can be set, to indicate that the sort order has changed. This
1.80 mike 671: will cause the <code>datagrid</code> to clear its position
672: information for rows, so <code
673: title="dom-datagrid-setRows">setRows()</code> will have to be
1.1 mike 674: called again with the new sort order.</p>
675:
676: <p>The columns are not actually sorted by the
1.80 mike 677: <code>datagrid</code>; the data has to be sorted by the script
678: that adds the rows to the <code>datagrid</code>.</p>
1.1 mike 679:
680: </dd>
681:
682:
1.80 mike 683: <dt><var title="">datagrid</var> . <code title="dom-datagrid-sortAscending">sortAscending</code> [ = <var title="">value</var> ]</dt>
1.1 mike 684: <dd>
685:
686: <p>Returns true if the data is to be sorted with smaller values
687: first; otherwise, returns false, indicating that bigger values are
688: to be put first.</p>
689:
690: <p>Can be set, to indicate that the order is about to change.</p>
691:
692: </dd>
693:
694:
1.80 mike 695: <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearColumns">clearColumns</code>()</dt>
1.1 mike 696: <dd>
697:
1.80 mike 698: <p>Removes all the columns in the <code>datagrid</code>,
1.1 mike 699: reinstating the implied column.</p>
700:
701: </dd>
702:
703:
1.80 mike 704: <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRowCount">setRowCount</code>(<var title="">childCount</var>, <var title="">rowCount</var>)</dt>
1.1 mike 705: <dd>
706:
1.80 mike 707: <p>Sets the numbers of rows in the <code>datagrid</code>,
1.1 mike 708: excluding rows that are descendants of rows that are closed.</p>
709:
1.80 mike 710: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 711: arguments contradict each other or previously declared information
1.80 mike 712: (e.g. declaring that the <code>datagrid</code> has three rows when
1.1 mike 713: the 12th row has been declared).</p>
714:
715: </dd>
716:
717:
1.80 mike 718: <dt><var title="">datagrid</var> . <code title="dom-datagrid-setRows">setRows</code>(<var title="">rows</var>)</dt>
1.1 mike 719: <dd>
720:
1.80 mike 721: <p>Updates data for rows in the <code>datagrid</code>, or fills in
722: data for rows previously implied by a call to <code
723: title="dom-datagrid-setRowCount">setRowCount()</code> but not
1.1 mike 724: previously declared.</p>
725:
726: <p>The <var title="">rows</var> argument is an array of rows, each
727: represented by a further array consisting of:</p>
728:
1.80 mike 729: <ol class="brief">
730:
731: <li>A <code>RowID</code> object identifying the row.</li>
1.1 mike 732:
733: <li>An integer giving the position of the row in its parent,
1.80 mike 734: given the current sort order, or −1 to set other row data
1.1 mike 735: without setting a position or changing a previously declared
736: position.</li>
737:
738: <li>An integer giving the number of children of the row, or 0 if
1.80 mike 739: the row has no children, or −1 if the row has children but
1.1 mike 740: the count is currently unknown. If the number of children has
741: already been set to 0 or a positive integer, then passing
1.80 mike 742: −1 leaves the previous count unchanged.</li>
1.1 mike 743:
744: <li>An array giving the data for zero or more cells in the row,
745: as described below.</li>
746:
747: <li>A boolean declaring whether the row is open or not. This
748: entry, if omitted, is assumed to be false (closed), unless the
749: row has already been declared as open.</li>
750:
751: <li>An integer giving the number of rows that are descendants of
752: this row, excluding those that are descendants of descendants of
753: this row that are closed. This entry can be omitted if the row is
754: closed or if it has already been declared.</li>
755:
1.80 mike 756: </ol>
757:
758: <p>The array giving the data for the cells in the row consists of
1.1 mike 759: a further set of arrays, one per cell. The first item of each of
760: these arrays is the column's identifier; the subsequent values
761: vary based on the type of the column, as follows:</p>
762:
1.80 mike 763: <dl>
764:
765: <dt><code title="datagrid-type-text">text</code></dt>
1.1 mike 766: <dd>
1.80 mike 767: <ol class="brief">
768: <li>A string giving the cell's value.
769: <li>Optionally, an <code>img</code> element giving an icon for the cell.
770: </ol>
771: </dd>
1.1 mike 772:
1.80 mike 773: <dt><code title="datagrid-type-editable">editable</code></dt>
1.1 mike 774: <dd>
1.80 mike 775: <ol class="brief">
776: <li>A string giving the cell's value.
777: <li>Optionally, a <code>datalist</code> element giving a set of predefined options.
778: <li>Optionally, an <code>img</code> element giving an icon for the cell.
779: </ol>
780: </dd>
1.1 mike 781:
1.80 mike 782: <dt><code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 783: <dd>
1.80 mike 784: <ol class="brief">
785: <li>A string giving the cell's value.
786: <li>A boolean, indicating whether the cell is checked (true) or not (false).
787: <li>Optionally, a boolean indicating whether the value of the cell is obscured as indeterminate (true), or not (false).
788: <li>Optionally, an <code>img</code> element giving an icon for the cell.
789: </ol>
790: </dd>
1.1 mike 791:
1.80 mike 792: <dt><code title="datagrid-type-list">list</code></dt>
1.1 mike 793: <dd>
1.80 mike 794: <ol class="brief">
795: <li>A string giving the cell's current value.
796: <li>A <code>select</code> element giving the <span title="concept-select-option-list">list of options</span>.
797: <li>Optionally, an <code>img</code> element giving an icon for the cell.
798: </ol>
799: </dd>
1.1 mike 800:
1.80 mike 801: <dt><code title="datagrid-type-progress">progress</code></dt>
1.1 mike 802: <dd>
1.80 mike 803: <ol class="brief">
804: <li>A value in the range 0.0 (no progress) to 1.0 (task complete).
805: </ol>
806: </dd>
1.1 mike 807:
1.80 mike 808: <dt><code title="datagrid-type-meter">meter</code></dt>
1.1 mike 809: <dd>
1.80 mike 810: <ol class="brief">
811: <li>A number giving the cell's value.
812: <li>Optionally, a number giving the maximum value, if it's not 1.
813: <li>Optionally, a number giving the minimum value, if it's not 0.
814: <li>Optionally, a number giving the highest value that is considered "low".
815: <li>Optionally, a number giving the lowest value that is considered "high".
816: <li>Optionally, a number giving the value that is considered optimal.
817: </ol>
818: </dd>
1.1 mike 819:
1.80 mike 820: <dt><code title="datagrid-type-custom">custom</code></dt>
1.1 mike 821: <dd>
1.80 mike 822: <ol class="brief">
823: <li>A number giving the minimum width of the cell, in CSS pixels, that is desired.
824: <li>A number giving the minimum height of the cell, in CSS pixels, that is desired.
825: <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.
826: </ol>
827: </dd>
828:
829: </dl>
1.1 mike 830:
1.80 mike 831: <p>While the rows in a single call to the <code
832: title="dom-datagrid-setRows">setRows()</code> method can be in any
1.1 mike 833: order, for each row, it is important that all its ancestor rows
834: and all its open previous siblings are also declared, either in
835: the same call or in an earlier one.</p>
836:
1.80 mike 837: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 838: arguments contradict each other or previously declared information
839: (e.g. saying that a row's position is 5 when the parent row only
840: has 3 children, or naming a column that doesn't exist, or
841: declaring a row without declaring its parent, or changing the
842: number of children that a row has while that row and its ancestors
843: are all open).</p>
844:
845: </dd>
846:
847:
1.80 mike 848: <dt><var title="">datagrid</var> . <code title="dom-datagrid-insertRows">insertRows</code>(<var title="">rows</var>)</dt>
1.1 mike 849: <dd>
850:
1.80 mike 851: <p>Inserts the given rows into the <code>datagrid</code>,
852: increasing the numbers of rows that the <code>datagrid</code>
1.1 mike 853: assumes are present.</p>
854:
855: <p>The <var title="">rows</var> argument is an array of rows in
1.80 mike 856: the same structure as the argument to the <code
857: title="dom-datagrid-setRows">setRows()</code> method described
1.1 mike 858: above, with the same expectations of consistency (a given row's
859: ancestors and earlier open siblings being listed either earlier or
1.80 mike 860: in the same call as a given row). However, unlike with the <code
861: title="dom-datagrid-setRows">setRows()</code> method, if a row is
1.1 mike 862: inserted along with its child, the child is not included in the
1.80 mike 863: child and row counts of the parent row; every row in the <var
864: title="">rows</var> argument will increase its parent's counts
1.1 mike 865: automatically.</p>
866:
1.80 mike 867: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the
1.1 mike 868: arguments contradict each other or previously declared
869: information.</p>
870:
871: </dd>
872:
873:
1.80 mike 874: <dt><var title="">datagrid</var> . <code title="dom-datagrid-deleteRows">deleteRows</code>(<var title="">rows</var>)</dt>
1.1 mike 875: <dd>
876:
1.80 mike 877: <p>Removes the given rows from the <code>datagrid</code>, and
1.1 mike 878: updates the number of rows known to be in the
1.80 mike 879: <code>datagrid</code> accordingly. The argument is an array of
880: <code>RowID</code> objects identifying the rows to remove.</p>
1.1 mike 881:
1.80 mike 882: <p>Throws a <code>DATAGRID_MODEL_ERR</code> exception if the argument
883: includes a row the <code>datagrid</code> doesn't know about.</p>
884: <!- - since otherwise behaviour might depend on where the user
885: scrolled! - ->
1.1 mike 886:
887: </dd>
888:
889:
1.80 mike 890: <dt><var title="">datagrid</var> . <code title="dom-datagrid-repaint">repaint</code>(<var title="">row</var>, <var title="">column</var>)</dt>
1.1 mike 891: <dd>
892:
1.80 mike 893: <p>If the given column's type is <code
894: title="datagrid-type-custom">custom</code>, then causes the
895: <code>datagrid</code> to reinvoke the function that obtains the
1.1 mike 896: desired rendering.</p>
897:
898: </dd>
899:
900:
1.80 mike 901: <dt><var title="">datagrid</var> . <code title="dom-datagrid-clearRows">clearRows</code>()</dt>
1.1 mike 902: <dd>
903:
1.80 mike 904: <p>Clears the <code>datagrid</code> of all row data, resetting it
905: to empty<!- - v2DGS:, and clears the selection- ->.</p>
1.1 mike 906:
907: </dd>
908:
1.80 mike 909: </dl>
910:
911:
912: <div class="impl">
1.1 mike 913:
1.80 mike 914: <h6>The listener</h6>
1.1 mike 915:
1.80 mike 916: <p>The <dfn
1.186 mike 917: title="dom-datagrid-listener"><code>listener</code></dfn> IDL
1.1 mike 918: attribute allows authors to specify an object that will receive all
1.80 mike 919: the notifications from the <code>datagrid</code>. Initially, its
1.1 mike 920: value must be null. On getting, it must return its value. On
921: setting, its value must be set to the new value, and then the user
1.80 mike 922: agent must <span>queue a task</span> to call the <code
923: title="dom-listener-initialize">initialize()</code> method with the
924: <code>datagrid</code> element as its only argument.</p>
1.1 mike 925:
926:
1.80 mike 927: <h6>The columns</h6>
1.1 mike 928:
1.80 mike 929: <p>The columns are represented by the <dfn>column list</dfn>, an
1.1 mike 930: ordered list of entries for columns, each of which consists of:</p>
931:
1.80 mike 932: <dl>
933:
934: <dt>An identifier</dt>
1.1 mike 935:
936: <dd>A string used to identify the column in the API.</dd>
937:
938: <dt>A label</dt>
939:
940: <dd>A string used in the user interface.</dd>
941:
942: <dt>A type</dt>
943:
944: <dd>One of the types described below.</dd>
945:
946: <dt>An icon</dt>
947:
1.80 mike 948: <dd>An image, copied from an <code>img</code> element when the
1.1 mike 949: column was declared.</dd>
950:
951: <dt>Whether the column is sortable</dt>
952:
953: <dd>A boolean indicating whether the user can request that the data
954: be sorted by this column (true), or not (false).</dd>
955:
956: <dt>Whether the column is visible</dt>
957:
958: <dd>A boolean indicating whether the column is part of the
1.80 mike 959: <code>datagrid</code>'s rendering.</dd>
1.1 mike 960:
1.80 mike 961: </dl>
962:
963: <p>Initially, the <span>column list</span> must have a single
964: column, the <dfn>default column</dfn>, whose identifier is the empty
965: string, whose label is the empty string, whose type is <code
966: title="datagrid-type-text">text</code>, with no icon, which is not
1.1 mike 967: sortable, and which <em>is</em> visible.</p>
968:
1.80 mike 969: <hr>
970:
971: <p>The <dfn title="dom-datagrid-addColumn"><code>addColumn(<var
972: title="">id</var>, <var title="">label</var>, <var
973: title="">type</var>, <var title="">icon</var>, <var
974: title="">sortable</var>, <var title="">hidden</var>)</code></dfn>
1.1 mike 975: method must run the following steps:</p>
976:
1.80 mike 977: <ol>
978:
979: <li><p>If there is already an entry in <span>column list</span>,
980: other than the <span>default column</span>, whose identifier is
981: <var title="">id</var>, throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 982: exception and abort these steps.</p></li>
983:
984: <li>
985:
986: <p>If <var title="">type</var> is not a string equal to one of the
1.80 mike 987: <span>allowed <code>datagrid</code> column types</span>, then
988: throw a <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1 mike 989: steps.</p>
990:
991: </li>
992:
993: <li><p>If the <var title="">icon</var> argument is present and not
1.80 mike 994: null, but the given <code>img</code> element's <code
995: title="dom-img-complete">complete</code> attribute is false, then
1.1 mike 996: let <var title="">icon</var> be null.</p></li>
997:
998: <li><p>If the <var title="">icon</var> argument is present and not
1.80 mike 999: null, then copy the image data from that <code>img</code> element,
1.1 mike 1000: and let <var title="">image</var> be the copy of that image
1001: data. Otherwise, let <var title="">image</var> be nothing.</p></li>
1002:
1.80 mike 1003: <li><p>Append a new entry to the <span>column list</span>, with
1.1 mike 1004: <var title="">id</var> as its identifier, <var title="">label</var>
1.80 mike 1005: as its label, <var title="">type</var> as its type, and <var
1006: title="">image</var> as its icon. Let the column be sortable if the
1.1 mike 1007: <var title="">sortable</var> argument is present and true, and make
1008: it visible unless the <var title="">hidden</var> argument is
1009: present and true.</p></li>
1010:
1.80 mike 1011: <li><p>If the <span>column list</span> contains the <span>default
1012: column</span>, then remove the <span>default column</span> from the
1013: <span>column list</span>, discard any data for cells in that column
1014: in any rows in the <code>datagrid</code>, set <code
1015: title="dom-datagrid-sortColumn">sortColumn</code> to <var
1016: title="">id</var>, set <code
1017: title="dom-datagrid-sortAscending">sortAscending</code> to true,
1018: and run the <span><code>datagrid</code> resort
1019: steps</span>.</p></li>
1020:
1021: </ol>
1022:
1023: <hr>
1.1 mike 1024:
1.80 mike 1025: <p>The <dfn
1.186 mike 1026: title="dom-datagrid-sortColumn"><code>sortColumn</code></dfn> IDL
1.1 mike 1027: attribute gives the current column used for sorting. Initially, its
1028: value must be the empty string. On getting, it must return its
1029: current value. On setting, if the new value doesn't match the
1.80 mike 1030: identifier of one of the columns in the <span>column list</span>,
1031: then the user agent must throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 1032: exception. Otherwise, if the new value is not the same as its
1033: current value, then the user agent must set the attribute to the new
1.80 mike 1034: value, and then run the <span><code>datagrid</code> resort
1035: steps</span>.</p>
1.1 mike 1036:
1.80 mike 1037: <p>The <dfn
1038: title="dom-datagrid-sortAscending"><code>sortAscending</code></dfn>
1.186 mike 1039: IDL attribute specifies the direction that the tree is sorted in,
1.1 mike 1040: ascending (true) or descending (false). Initially, its value must be
1041: true (ascending). On getting, it must return its current value. On
1042: setting, if the new value is not the same as its current value, then
1043: the user agent must set the attribute to the new value, and then run
1.80 mike 1044: the <span><code>datagrid</code> resort steps</span>.</p>
1.1 mike 1045:
1046: <p>When a column is marked as being sortable, the user agent should
1047: allow the user to select that column to be the column used for
1048: sorting, and should allow the user to chose whether the sort order
1049: is ascending or descending.</p>
1050:
1051: <p>When the user changes the sort order in this manner, the user
1.80 mike 1052: agent must update the <code
1053: title="dom-datagrid-sortColumn">sortColumn</code> and <code
1054: title="dom-datagrid-sortAscending">sortAscending</code> attributes
1055: appropriately, and then run the <span><code>datagrid</code> resort
1056: steps</span>.</p>
1.1 mike 1057:
1.80 mike 1058: <p class="note">The <span><code>datagrid</code> resort steps</span>
1.1 mike 1059: are described in the next section.</p>
1060:
1.80 mike 1061: <hr>
1.1 mike 1062:
1.80 mike 1063: <p>The <dfn
1064: title="dom-datagrid-clearColumns"><code>clearColumns()</code></dfn>
1065: method, if the <span>column list</span> doesn't contain the
1066: <span>default column</span>, must empty the <span>column
1067: list</span>, append the <span>default column</span> to the now empty
1068: <span>column list</span>, discard any data for cells in all rows in
1069: the <code>datagrid</code>, set <code
1070: title="dom-datagrid-sortColumn">sortColumn</code> to the empty
1071: string, set <code
1072: title="dom-datagrid-sortAscending">sortAscending</code> to true, and
1073: run the <span><code>datagrid</code> resort steps</span>. (If the
1074: <span>column list</span> is already just the <span>default
1075: column</span>, then the method does nothing.)</p>
1.1 mike 1076:
1077:
1.80 mike 1078: <h6>The rows</h6>
1079:
1080: <p>A <code>datagrid</code> element is intended to show a
1.1 mike 1081: representation of a tree, where typically the user only sees a
1082: small part of the tree at a time.</p>
1083:
1.80 mike 1084: <p>To make this efficient, the <code>datagrid</code> element
1.1 mike 1085: <em>actually</em> shows a small part of a <em>sparse</em> tree, so
1086: that only relevant parts of the data structure need be loaded at any
1087: time. Specifically, the model requires only that all the ancestor
1088: rows of the displayed rows be loaded, as well as any open earlier
1089: siblings (in the displayed sort order) of the displayed rows.</p>
1090:
1.80 mike 1091: <p>Conceptually, therefore, a <code>datagrid</code> has a number of
1.1 mike 1092: related sparse data structures backing it.</p>
1093:
1.80 mike 1094: <p>The first is the <dfn>natural order sparse data tree</dfn>. This
1.1 mike 1095: is the structure in which rows are entered as they are declared, in
1096: their natural order. This can differ from the order actually
1097: displayed to the user. It consists of nested sparse lists of
1.80 mike 1098: rows. In the <span>natural order sparse data tree</span>, a row will
1.1 mike 1099: always have all its parents already declared. Once a row is added to
1.80 mike 1100: this structure, it can only be removed by the <code
1101: title="dom-datagrid-deleteRows">deleteRows()</code> and <code
1102: title="dom-datagrid-clearRows">clearRows()</code> methods. The order of
1.1 mike 1103: nodes in this tree never changes; to move a node in this tree, it
1104: has to be removed and then another row (with the same data)
1105: reinserted elsewhere.</p>
1106:
1.80 mike 1107: <p>The second structure is the <dfn>display order sparse data
1.1 mike 1108: tree</dfn>. This is a similar structure that contains a subset of
1.80 mike 1109: the rows in the <span>natural order sparse data tree</span>, ordered
1110: in the order given by the <code
1111: title="dom-datagrid-sortAscending">sortAscending</code> and <code
1112: title="dom-datagrid-sortColumn">sortColumn</code> attributes, and
1.1 mike 1113: excluding rows with one or more ancestors that are closed. This tree
1.80 mike 1114: is cleared whenever the <code
1115: title="dom-datagrid-sortAscending">sortAscending</code> and <code
1116: title="dom-datagrid-sortColumn">sortColumn</code> attributes
1.1 mike 1117: change.</p>
1118:
1.80 mike 1119: <p>The third structure is the <dfn>display order sparse data
1.1 mike 1120: list</dfn>. This structure is a flattened representation of the
1.80 mike 1121: <span>display order sparse data tree</span>.</p>
1.1 mike 1122:
1.80 mike 1123: <p>At any time, a number of consecutive rows in the <span>display
1124: order sparse data list</span> are physically visible to the
1125: user. The <code>datagrid</code> fires notifications to a <span
1126: title="dom-datagrid-listener">listener</span> (provided by script),
1.1 mike 1127: and the listener, or other some script, is expected to feed the
1.80 mike 1128: <code>datagrid</code> with the information needed to render the
1.1 mike 1129: control.</p>
1130:
1.80 mike 1131: <p>A <code>datagrid</code> has a <dfn>pending <code>datagrid</code>
1132: rows list</dfn>, which is a list of rows in the <span>display order
1133: sparse data list</span> for which the <code>datagrid</code> has sent
1.1 mike 1134: notifications requesting information but not yet received
1135: information about.</p>
1136:
1.80 mike 1137: <p>A <code>datagrid</code> also has a <dfn>pending
1.1 mike 1138: <code>datagrid</code> <em>cells</em> list</dfn>, which is a list of
1.80 mike 1139: row/column pairs (cells) for which the <code>datagrid</code> has
1.1 mike 1140: sent notifications requesting information but not yet received
1141: information about.</p>
1142:
1143: <p>User agents may discard information about rows that are not
1144: displayed and that are not ancestors or open earlier siblings of
1145: rows or ancestors of rows that are displayed.</p>
1146:
1.80 mike 1147: <hr>
1148:
1149: <p>These structures are different views of the collection of rows
1150: that form the <code>datagrid</code>. Each row has the following
1.1 mike 1151: information associated with it:</p>
1152:
1.80 mike 1153: <dl>
1154:
1155: <dt>A parent</dt>
1.1 mike 1156:
1.80 mike 1157: <dd><p>Either another row, or the <code>datagrid</code> itself. This
1158: is the parent of the row in the <span>natural order sparse data
1159: tree</span> and the <span>display order sparse data tree</span>
1160: for the <code>datagrid</code>.</p></dd>
1.1 mike 1161:
1162: <dt>A natural order position relative to the other rows with the
1163: same parent</dt>
1164:
1165: <dd>
1166:
1167: <p>This is the number of rows that precede this row under the same
1.80 mike 1168: parent in the <span>natural order sparse data tree</span>. This
1.1 mike 1169: number can't be changed relative to other rows in the same parent;
1170: to change the relative natural order of data in the
1.80 mike 1171: <code>datagrid</code>, the original rows have to be removed and
1.1 mike 1172: new rows (with the same data but different natural positions)
1173: inserted in their place. (The exact number of a row can change, as
1174: new rows can be inserted above it.)</p>
1175:
1.80 mike 1176: <p>A row can be identified by a <code>RowID</code> object. This is
1.1 mike 1177: an array of numbers, consisting of the natural order positions of
1178: each ancestor row and the row itself, starting from the furthest
1179: ancestor. Thus, for instance, the fourth child row of the first
1.80 mike 1180: child row of the second row in a <code>datagrid</code> would be
1181: identified by a <code>RowID</code> object whose value is <code
1182: title="">[1, 0, 3]</code>. A row's identifier changes if rows are
1183: <span title="dom-datagrid-insertRows">inserted before it</span> in
1184: the <code>datagrid</code>.</p>
1.1 mike 1185:
1186: </dd>
1187:
1188: <dt>A display order position relative to the other rows with
1189: the same parent</dt>
1190:
1191: <dd><p>This is the number of rows that precede this row under the
1.80 mike 1192: same parent in the <span>display order sparse data
1193: tree</span>. This number can be unknown. If the sort order
1194: changes, then this information is lost (as the <span>display order
1195: sparse data tree</span> is cleared).</p></dd>
1.1 mike 1196:
1197: <dt>A child count</dt>
1198:
1199: <dd><p>The number of rows that have this row as a parent. If this is
1.80 mike 1200: zero, the row cannot be opened. If this is −1, then the
1.1 mike 1201: child count is unknown but the row can be opened. This value can be
1.80 mike 1202: changed by the <code title="dom-datagrid-setRows">setRows()</code>
1203: method only if the current value is −1 or if the row or one
1.1 mike 1204: of its ancestors is closed. Otherwise, it can only be changed
1.80 mike 1205: indirectly using the <code
1206: title="dom-datagrid-insertRows">insertRows()</code> and <code
1207: title="dom-datagrid-deleteRows">deleteRows()</code> methods.</p></dd>
1.1 mike 1208:
1209: <dt>An open flag</dt>
1210:
1211: <dd><p>A boolean indicating whether the row is open (true) or
1212: closed (false). Once set, the flag can only be changed by the user
1213: or while one of the row's ancestors is itself closed. A row can
1214: also be in a third state, "opening", which is treated as closed for
1215: all purposes except that the user agent may indicate that the row
1216: is in this special state, and except that when the row is updated
1217: to have a row count, the row will switch to being open.</p></dd>
1218:
1219: <dt>A row count</dt>
1220:
1221: <dd><p>The number of rows that have this row as a parent or
1222: ancestor, and that do not have an ancestor that is a descendant of
1.80 mike 1223: this row that is itself closed. If this is −1, then the row
1224: count is unknown. This value can be changed by the <code
1225: title="dom-datagrid-setRows">setRows()</code> method only if the
1.1 mike 1226: row or one of its ancestors is closed (or opening, but not
1.80 mike 1227: open). Otherwise, it can only be changed indirectly using the <code
1228: title="dom-datagrid-insertRows">insertRows()</code> and <code
1229: title="dom-datagrid-deleteRows">deleteRows()</code>
1.1 mike 1230: methods.</p></dd>
1231:
1232: <dt>Cells</dt>
1233:
1234: <dd><p>The data that applies to this row. Cell data is discussed in
1235: more detail below.</p></dd>
1236:
1.80 mike 1237: </dl>
1238:
1239: <p>The <code>datagrid</code> itself also has a <dfn title="datagrid
1240: child count">child count</dfn> and a <dfn title="datagrid row
1.1 mike 1241: count">row count</dfn>, which are analogous to the child counts and
1242: row counts for rows. Initially, these must be zero.</p>
1243:
1.80 mike 1244: <hr>
1245:
1246: <p>The <dfn><code>datagrid</code> resort steps</dfn>, which are
1.1 mike 1247: invoked when the sort order changes as described in the previous
1248: section, are as follows:</p>
1249:
1.80 mike 1250: <ol>
1.1 mike 1251:
1.80 mike 1252: <li>
1253:
1254: <p>Clear the <span>display order sparse data tree</span>
1.1 mike 1255: (i.e. mark the display order position of all the rows in the
1.80 mike 1256: <code>datagrid</code> as unknown).</p>
1.1 mike 1257:
1258: <p>User agents may cache the position information of rows for
1.80 mike 1259: various values of <code
1260: title="dom-datagrid-sortColumn">sortColumn</code> and <code
1261: title="dom-datagrid-sortAscending">sortAscending</code>, instead
1.1 mike 1262: of discarding the information altogether. If the user agent caches
1263: this information, and has information that applies to the current
1.80 mike 1264: values of <code title="dom-datagrid-sortColumn">sortColumn</code>
1265: and <code title="dom-datagrid-sortAscending">sortAscending</code>,
1266: then the user agent may repopulate the <span>display order sparse
1267: data tree</span> from this information.</p>
1.1 mike 1268:
1269: </li>
1270:
1271: <li>
1272:
1.80 mike 1273: <p>Clear the <span>pending <code>datagrid</code> rows list</span>
1274: and the <span>pending <code>datagrid</code> cells list</span>.</p>
1.1 mike 1275:
1276: </li>
1277:
1278: <li>
1279:
1.80 mike 1280: <p>Invoke the <span><code>datagrid</code> update display
1281: algorithm</span>.</p>
1.1 mike 1282:
1283: </li>
1284:
1.80 mike 1285: <!- - v2: queue a task to fire an event, or tell the listener the
1286: sort order changed, or something - ->
1287:
1288: </ol>
1.1 mike 1289:
1.80 mike 1290: <hr>
1.1 mike 1291:
1.80 mike 1292: <p>The <dfn
1293: title="dom-datagrid-renotify"><code>renotify()</code></dfn> method
1294: must empty the <span>pending <code>datagrid</code> rows list</span>
1295: and the <span>pending <code>datagrid</code> cells list</span>, and
1296: invoke the <span><code>datagrid</code> update display
1297: algorithm</span>.</p>
1298:
1299: <hr>
1300:
1301: <p>The <dfn title="dom-datagrid-setRowCount"><code>setRowCount(<var
1302: title="">childCount</var>, <var
1303: title="">rowCount</var>)</code></dfn> method must run the following
1.1 mike 1304: steps:</p>
1305:
1.80 mike 1306: <ol>
1.1 mike 1307:
1.80 mike 1308: <li>
1309:
1310: <p>Set the <span><code>datagrid</code> child count</span> to <var
1311: title="">childCount</var>, the <span><code>datagrid</code> row
1312: count</span> to <var title="">rowCount</var>.</p>
1.1 mike 1313:
1314: </li>
1315:
1316: <li>
1317:
1.80 mike 1318: <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1 mike 1319: then revert the changes made in the previous step, throw a
1.80 mike 1320: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1321: steps.</p>
1322:
1323: </li>
1324:
1325: <li>
1326:
1.80 mike 1327: <p>Invoke the <span><code>datagrid</code> update display
1328: algorithm</span>.</p>
1.1 mike 1329:
1330: </li>
1331:
1.80 mike 1332: </ol>
1333:
1334: <hr>
1335:
1336: <p>The <dfn title="dom-datagrid-setRows"><code>setRows(<var
1337: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1338: steps:</p>
1339:
1.80 mike 1340: <ol>
1.1 mike 1341:
1.80 mike 1342: <li>
1343:
1344: <p><span title="type-check a RowList object">Type-check the <var
1345: title="">rows</var> argument</span>. If this fails, throw a
1.1 mike 1346: <code>TypeError</code> exception, and abort these steps.</p>
1347:
1348: </li>
1349:
1350: <li>
1351:
1.80 mike 1352: <p><span title="partially sort a RowList object">Partially sort
1353: the <var title="">rows</var> argument</span>.</p>
1.1 mike 1354:
1355: </li>
1356:
1357: <li>
1358:
1.80 mike 1359: <p>For each <code>Row</code> object in the <var
1360: title="">rows</var> argument, in order, perform the appropriate
1.1 mike 1361: steps from the list below.</p>
1362:
1.80 mike 1363: <p class="note">The changes made to the <code>datagrid</code>'s
1.1 mike 1364: data structures in this step get reverted (as required below) if
1365: any consistency errors are detected either in this step or the
1366: next.</p>
1367:
1.80 mike 1368: <dl>
1369:
1370: <dt>If there already exists a row in the <code>datagrid</code>'s
1371: <span>natural order sparse data tree</span> with the same
1372: identifier as given by the <code>Row</code> object's
1373: <code>RowID</code> object, and that row and all its ancestors are
1.1 mike 1374: open</dt>
1375:
1376: <dd>
1377:
1378: <p>If one of the following conditions is true, then revert all
1379: the changes done in this step, throw a
1.80 mike 1380: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1381: steps:</p>
1382:
1.80 mike 1383: <ul>
1384:
1385: <li>The value of the <code>Row</code> object's second entry is
1386: neither −1 nor equal to the child count of the
1.1 mike 1387: preexisting row.</li>
1388:
1.80 mike 1389: <li>The <code>Row</code> object has fewer than four
1.1 mike 1390: entries or more than six entries.</li>
1391:
1.80 mike 1392: <li>The <code>Row</code> object has five or more entries, and
1.1 mike 1393: its fifth entry is false.</li>
1394:
1.80 mike 1395: <li>The <code>Row</code> object has six entries, and its sixth
1.1 mike 1396: entry is not equal to the row count of the preexisting
1397: row.</li>
1398:
1.80 mike 1399: </ul>
1400:
1401: </dd>
1.1 mike 1402:
1.80 mike 1403: <dt>If there already exists a row in the <code>datagrid</code>'s
1404: <span>natural order sparse data tree</span> with the same
1405: identifier as given by the <code>Row</code> object's
1406: <code>RowID</code> object, but either that row or one of its
1.1 mike 1407: ancestors is closed</dt>
1408:
1409: <dd>
1410:
1411: <p>Set the preexisting row's child count to the value of the
1.80 mike 1412: <code>Row</code> object's second entry.</p>
1.1 mike 1413:
1.80 mike 1414: <p>If the <code>Row</code> object has five or more entries, and
1.1 mike 1415: either its fifth entry is true and the preexisting row is closed
1416: but not opening, or its fifth entry is false and the preexisting
1417: row is open, then: if the preexisting row has no ancestor row
1418: that is closed, then revert all the changes done in this step,
1.80 mike 1419: throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1 mike 1420: these steps; otherwise, if the fifth entry is false, then close
1421: the row; otherwise, open the row.</p>
1422:
1.80 mike 1423: <p>If the <code>Row</code> object has six entries, set the
1424: preexisting row's row count to the value of the <code>Row</code>
1.1 mike 1425: object's sixth entry.</p>
1426:
1427: <p>If the preexisting row is opening, then: increase the
1.80 mike 1428: <span><code>datagrid</code> row count</span> and the row counts
1.1 mike 1429: of any ancestor rows by the number of rows that the preexisting
1.80 mike 1430: row now has in its row count, then open the row.</p> <!- - we
1.1 mike 1431: should also "update the <span>pending <code>datagrid</code> rows
1432: list</span> and the <span>pending <code>datagrid</code> cells
1.80 mike 1433: list</span> accordingly" - ->
1.1 mike 1434:
1435:
1436: </dd>
1437:
1.80 mike 1438: <dt>There does not exist a row in the <code>datagrid</code>'s
1439: <span>natural order sparse data tree</span> with the same
1440: identifier as given by the <code>Row</code> object's
1441: <code>RowID</code> object</dt>
1.1 mike 1442:
1443: <dd>
1444:
1.80 mike 1445: <p>If the <code>RowID</code> object has a length greater than 1,
1.1 mike 1446: then verify that there is a row identified by the
1.80 mike 1447: <code>RowID</code> consisting of all but the last number in the
1448: <code>Row</code> object's <code>RowID</code>. If there is no
1449: such row present in the <span>natural order sparse data
1450: tree</span>, then revert all the changes done in this step,
1451: throw a <code>DATAGRID_MODEL_ERR</code> exception, and abort
1.1 mike 1452: these steps.</p>
1453:
1.80 mike 1454: <p>Create a row and insert it into the <span>natural order
1455: sparse data tree</span>, such that its parent is the row
1456: identified by the <code>RowID</code> consisting of all but the
1457: last number in the <code>Row</code> object's <code>RowID</code>,
1458: or the <code>datagrid</code> if the length of the
1459: <code>Row</code> object's <code>RowID</code> is 1; with its
1.1 mike 1460: natural order position being the last number of the
1.80 mike 1461: <code>Row</code> object's <code>RowID</code>; with the child
1462: count being the value of the third entry of the <code>Row</code>
1.1 mike 1463: object; with the row being marked closed unless the
1.80 mike 1464: <code>Row</code> object has five or more entries and its fifth
1.1 mike 1465: entry is true, in which case the row is open; and with its row
1.80 mike 1466: count being −1 unless the <code>Row</code> object has six
1.1 mike 1467: entries, in which case the row count is equal to the value of
1.80 mike 1468: the <code>Row</code> object's sixth entry.</p>
1.1 mike 1469:
1470: </dd>
1471:
1.80 mike 1472: </dl>
1473:
1474: </li>
1.1 mike 1475:
1476: <li>
1477:
1.80 mike 1478: <p><span>Audit the <code>datagrid</code></span>. If this fails,
1.1 mike 1479: then revert the changes made in the previous step, throw a
1.80 mike 1480: <code>DATAGRID_MODEL_ERR</code> exception, and abort these
1.1 mike 1481: steps.</p>
1482:
1483: </li>
1484:
1485: <li>
1486:
1.80 mike 1487: <p>For each <code>Row</code> object in the <var
1488: title="">rows</var> argument, in order, <span title="apply a Row
1489: object">apply the <code>Row</code> object</span>.</p>
1.1 mike 1490:
1491: </li>
1492:
1493: <li>
1494:
1.80 mike 1495: <p>Invoke the <span><code>datagrid</code> update display
1496: algorithm</span>.</p>
1.1 mike 1497:
1498: </li>
1499:
1.80 mike 1500: </ol>
1501:
1502: <hr>
1503:
1504: <p>The <dfn title="dom-datagrid-insertRows"><code>insertRows(<var
1505: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1506: steps:</p>
1507:
1.80 mike 1508: <ol>
1509:
1510: <li>
1.1 mike 1511:
1.80 mike 1512: <p><span title="type-check a RowList object">Type-check the <var
1513: title="">rows</var> argument</span>. If this fails, throw a
1.1 mike 1514: <code>TypeError</code> exception, and abort these steps.</p>
1515:
1516: </li>
1517:
1518: <li>
1519:
1.80 mike 1520: <p><span title="partially sort a RowList object">Partially sort
1521: the <var title="">rows</var> argument</span>.</p>
1.1 mike 1522:
1523: </li>
1524:
1525: <li>
1526:
1.80 mike 1527: <p>For each <code>Row</code> object in the <var
1528: title="">rows</var> argument, in order, run the following
1.1 mike 1529: steps:</p>
1530:
1.80 mike 1531: <p class="note">The changes made to the <code>datagrid</code>'s
1.1 mike 1532: data structures in this step get reverted (as required below) if
1533: any consistency errors are detected either in this step or the
1534: next.</p>
1535:
1.80 mike 1536: <ol>
1537:
1538: <li>
1.1 mike 1539:
1540: <p>Let <var title="">parent</var> be the row identified by the
1.80 mike 1541: <code>RowID</code> consisting of all but the last number in the
1542: <code>Row</code> object's <code>RowID</code>, or the
1543: <code>datagrid</code> itself if the <code>Row</code> object's
1544: <code>RowID</code> has length 0.</p>
1545:
1546: <p>If there is no such row present in the <span>natural order
1547: sparse data tree</span>, then revert all the changes done in
1548: this algorithm, throw a <code>DATAGRID_MODEL_ERR</code>
1.1 mike 1549: exception, and abort these steps.</p>
1550:
1551: </li>
1552:
1553: <li>
1554:
1555: <p>Increment by one the natural order position of all rows whose
1556: parent is <var title="">parent</var> and whose natural order
1557: position is equal to or greater than the last number of the
1.80 mike 1558: <code>Row</code> object's <code>RowID</code>.</p>
1.1 mike 1559:
1560: </li>
1561:
1562: <li>
1563:
1.80 mike 1564: <p>If the value of the <code>Row</code> object's second entry is
1565: not −1, then increment by one the display order position
1.1 mike 1566: of all rows whose parent is <var title="">parent</var> and whose
1567: display order position is equal to or greater than the value of
1.80 mike 1568: the <code>Row</code> object's second entry.</p>
1.1 mike 1569:
1.80 mike 1570: <!- -(Not sure how to really say this.)
1.1 mike 1571: <p>Update the <span>pending <code>datagrid</code> rows
1572: list</span> and the <span>pending <code>datagrid</code> cells
1573: list</span> accordingly.</p>
1.80 mike 1574: - ->
1.1 mike 1575:
1576: </li>
1577:
1578: <li>
1579:
1.80 mike 1580: <p>Create a row and insert it into the <span>natural order
1581: sparse data tree</span>, such that its parent is <var
1582: title="">parent</var>; with its natural order position being the
1583: last number of the <code>Row</code> object's <code>RowID</code>;
1.1 mike 1584: with the child count being the value of the third entry of the
1.80 mike 1585: <code>Row</code> object; with the row being marked closed unless
1586: the <code>Row</code> object has five or more entries and its
1.1 mike 1587: fifth entry is true, in which case the row is open; and with its
1.80 mike 1588: row count being −1 unless the <code>Row</code> object has
1.1 mike 1589: six entries, in which case the row count is equal to the value
1.80 mike 1590: of the <code>Row</code> object's sixth entry.</p>
1.1 mike 1591:
1592: </li>
1593:
1.80 mike 1594: </ol>
1595:
1596: </li>
1.1 mike 1597:
1598: <li>
1599:
1.80 mike 1600: <p>For each <code>Row</code> object in the <var
1601: title="">rows</var> argument, in order, <span title="apply a Row
1602: object">apply the <code>Row</code> object</span>.</p>
1.1 mike 1603:
1604: </li>
1605:
1606: <li>
1607:
1.80 mike 1608: <p>Invoke the <span><code>datagrid</code> update display
1609: algorithm</span>.</p>
1.1 mike 1610:
1611: </li>
1612:
1.80 mike 1613: </ol>
1614:
1615: <hr>
1616:
1617: <p>When an algorithm requires the user agent to <dfn>type-check a
1.1 mike 1618: <code>RowList</code> object</dfn> (an array), each entry in the
1619: object must be checked against the following requirements. If any
1620: are false, then the type-check fails, otherwise it passes.</p>
1621:
1.80 mike 1622: <ul>
1623:
1624: <li><p>The entry is a <code>Row</code> object (an
1.1 mike 1625: array).</p></li>
1626:
1.80 mike 1627: <li><p>The first value in the <code>Row</code> is a
1628: <code>RowID</code> object (also an array), whose length is at least
1.1 mike 1629: 1, and whose values are all integers greater than or equal to
1630: zero.</p></li>
1631:
1.80 mike 1632: <li><p>The numbers in the <code>RowID</code> object do not exactly
1633: match any of the other entries in the <code>RowList</code> object
1634: (i.e. no two <code>Row</code> objects have the same
1.1 mike 1635: identifier).</p></li>
1636:
1.80 mike 1637: <li><p>The second value in the <code>Row</code> is an integer that
1638: is either −1, zero, or a positive integer.</p></li>
1.1 mike 1639:
1.80 mike 1640: <li><p>The third value in the <code>Row</code> is an integer that
1641: is either −1, zero, or a positive integer.</p></li>
1.1 mike 1642:
1.80 mike 1643: <li><p>The fourth value in the <code>Row</code> is a
1644: <code>CellList</code> object (yet another array).</p></li>
1.1 mike 1645:
1.80 mike 1646: <li><p>Each entry in the <span>CellList</span> object is a
1647: <code>Cell</code> object (again, an array).</p></li>
1.1 mike 1648:
1.80 mike 1649: <li><p>Each <code>Cell</code> object in the <span>CellList</span>
1650: object has as its first value a <code>Column</code> object (a
1.1 mike 1651: string), and its value is the identifier of one of the columns in
1.80 mike 1652: the <span>column list</span>.</p></li>
1.1 mike 1653:
1654: <li>
1655:
1.80 mike 1656: <p>Each <code>Cell</code> object in the <span>CellList</span>
1.1 mike 1657: object has as its second and subsequent entries values that match
1658: the following requirements, as determined by the type of the
1659: column identified by the first entry:</p>
1660:
1.80 mike 1661: <dl>
1662:
1663: <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1 mike 1664: <dd>
1665:
1666: <p>The second entry's value is a string, and either there are
1667: only two entries, or there are three, and the third entry is
1.80 mike 1668: an <code>img</code> element.</p>
1.1 mike 1669:
1.80 mike 1670: <p>If there is an <code>img</code> element specified, its <code
1671: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1672:
1673: </dd>
1674:
1.80 mike 1675: <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1 mike 1676: <dd>
1677:
1678: <p>The second entry's value is a string, and either there are
1679: only two entries, or the third entry is a
1.80 mike 1680: <code>datalist</code> element, and either there are only three
1.1 mike 1681: entries, or there are four, and the fourth entry is an
1.80 mike 1682: <code>img</code> element.</p>
1.1 mike 1683:
1.80 mike 1684: <p>If there is an <code>img</code> element specified, its <code
1685: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1686:
1687: </dd>
1688:
1.80 mike 1689: <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 1690: <dd>
1691:
1692: <p>The second entry's value is a string, the third entry is a
1693: boolean, and either there are only three entries, or the
1694: fourth entry is also a boolean, and either there are only four
1695: entries, or there are five, and the fifth entry is an
1.80 mike 1696: <code>img</code> element.</p>
1.1 mike 1697:
1.80 mike 1698: <p>If there is an <code>img</code> element specified, its <code
1699: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1700:
1701: </dd>
1702:
1.80 mike 1703: <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1 mike 1704: <dd>
1705:
1706: <p>The second entry's value is a string, the third entry is a
1.80 mike 1707: <code>select</code> element, and either there are only three
1.1 mike 1708: entries, or there are four, and the fourth entry is an
1.80 mike 1709: <code>img</code> element.</p>
1.1 mike 1710:
1.80 mike 1711: <p>If there is an <code>img</code> element specified, its <code
1712: title="dom-img-complete">complete</code> attribute is true.</p>
1.1 mike 1713:
1714: </dd>
1715:
1.80 mike 1716: <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1 mike 1717: <dd>
1718:
1719: <p>There are only two entries, the second entry's value is a
1720: number, and the number's value is between 0.0 and 1.0
1721: inclusive.</p>
1722:
1723: </dd>
1724:
1.80 mike 1725: <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1 mike 1726: <dd>
1727:
1728: <p>There are at least two, but possibly up to seven, entries,
1729: all entries but the first one are numbers, and the following
1730: relationships hold:</p>
1731:
1.80 mike 1732: <ul class="brief">
1733:
1734: <li>The second entry is less than the third, or less than 1.0
1.1 mike 1735: if the third is absent.</li>
1736:
1737: <li>The second entry is greater than the fourth, or greater
1738: than 0.0 if the fourth is absent.</li>
1739:
1740: <li>If there are at least three entries, the third entry is
1741: greater than the fourth, or greater than zero if the fourth
1742: is absent.</li>
1743:
1744: <li>If there are at least five entries, the fifth is not
1745: greater than the third and not less than the fourth.</li>
1746:
1747: <li>If there are at least six entries, the sixth is not
1748: greater than the third and not less than the fifth.</li>
1749:
1750: <li>If there are at least seven entries, the fifth is not
1751: greater than the third and not less than the fourth.</li>
1752:
1.80 mike 1753: </ul>
1.1 mike 1754:
1.80 mike 1755: </dd>
1756:
1757: <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1 mike 1758: <dd>
1759:
1760: <p>There are four entries, the second and third are numbers
1761: that are integers greater than zero, and the fourth is a
1762: <code>Rendering2DContextCallback</code> object (a
1763: function).</p>
1764:
1765: </dd>
1766:
1.80 mike 1767: </dl>
1768:
1769: </li>
1.1 mike 1770:
1.80 mike 1771: <li><p>Either there are only four values in the <code>Row</code>,
1772: or the fifth value in the <code>Row</code> is a boolean.</p></li>
1.1 mike 1773:
1774: <li><p>Either there are only four or five values in the
1.80 mike 1775: <code>Row</code>, or there are six, and the sixth value in the
1776: <code>Row</code> an integer that is greater than or equal to
1.1 mike 1777: zero.</p></li>
1778:
1.80 mike 1779: </ul>
1780:
1781: <p>Where the above requirements say that a value is to be a string,
1.718 mike 1782: the user agent must apply the ToString() abstract operation to the
1.1 mike 1783: value, assume that the value was indeed a string, and use the result
1784: in the rest of the algorithm as if it had that had been the value
1.98 mike 1785: passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1786:
1787: <p>Where the above requirements say that a value is to be a number,
1.718 mike 1788: the user agent must first apply the ToNumber() abstract operation
1.60 mike 1789: to the value, and then verify that the result is neither an Infinity
1790: value nor a Not-a-Number (NaN) value. If this result is indeed
1791: acceptable (i.e. finite), the user agent must use the result in the
1792: rest of the algorithm as if it had that had been the value passed to
1.98 mike 1793: the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1794:
1795: <p>Where the above requirements say that a value is to be an
1.718 mike 1796: integer, the user agent must first apply the ToNumber() abstract
1797: operation to the value, and then verify that the result is a finite
1.1 mike 1798: integer. If so, the user agent must use the result in the rest of
1799: the algorithm as if it had that had been the value passed to the
1.98 mike 1800: method. <a href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1801:
1802: <p>Where the above requirements say that a value is to be a boolean,
1.718 mike 1803: the user agent must apply the ToBoolean() abstract operation to the
1.1 mike 1804: value, assume that the value was indeed a boolean, and use the
1805: result in the rest of the algorithm as if it had that had been the
1.98 mike 1806: value passed to the method. <a href="#refsECMA262">[ECMA262]</a></p>
1.80 mike 1807:
1808: <hr>
1.1 mike 1809:
1.80 mike 1810: <p>When an algorithm requires the user agent to <dfn>audit the
1811: <code>datagrid</code></dfn>, the <code>datagrid</code> must be
1.1 mike 1812: checked against the following requirements. If any are false, then
1813: the audit fails, otherwise it passes.</p>
1814:
1.80 mike 1815: <ul>
1816:
1817: <li>There is no row whose natural order position is greater than or
1818: equal to the child count of its parent row in the <span>natural
1819: order sparse data tree</span>.</li>
1.1 mike 1820:
1821: <li>There is no row whose display order position is greater than or
1.80 mike 1822: equal to the child count of its parent row in the <span>display
1823: order sparse data tree</span>.</li>
1.1 mike 1824:
1825: <li>There is no row such that the sum of that row's child count and
1826: the row counts all the open rows that are direct children of that
1.80 mike 1827: row in the <span>natural order sparse data tree</span> is less than
1.1 mike 1828: that row's row count.</li>
1829:
1830: <li>Of the rows whose child count is equal to the number of rows
1.80 mike 1831: that are direct children of that row in the <span>natural order
1832: sparse data tree</span>, there is none such that the sum of that
1.1 mike 1833: row's child count and the row counts of all the open rows that are
1.80 mike 1834: direct children of that row in the <span>natural order sparse data
1835: tree</span> is greater than that row's row count.</li>
1836:
1837: </ul>
1.1 mike 1838:
1.80 mike 1839: <p>For the purposes of this audit, the <code>datagrid</code> must be
1.1 mike 1840: treated as the parent row of all the rows that are direct children
1.80 mike 1841: of the <code>datagrid</code> in the <span>natural order sparse data
1842: tree</span> and the <span>display order sparse data tree</span>. The
1843: child count of this implied row is the <span><code>datagrid</code>
1844: child count</span>, and the row count of this implied row is the
1845: <span><code>datagrid</code> row count</span>.</p>
1846:
1847: <hr>
1.1 mike 1848:
1.80 mike 1849: <p>When an algorithm requires the user agent to <dfn>partially sort
1.1 mike 1850: a <code>RowList</code> object</dfn> (an array), the entries in the
1.80 mike 1851: object must be resorted such that <code>Row</code> objects are
1.1 mike 1852: listed after any of their ancestors and after any of their earlier
1.80 mike 1853: siblings. In other words, for any two <code>Row</code> objects <var
1854: title="">a</var> and <var title="">b</var> in the
1855: <code>RowList</code>, where <var title="">a</var> is before <var
1856: title="">b</var> after the sort, the following conditions must
1.1 mike 1857: hold:</p>
1858:
1.80 mike 1859: <ul>
1860:
1861: <li><p>If their <code>RowID</code> objects are the same length and
1.1 mike 1862: have values that are equal except for the last value, then the last
1.80 mike 1863: value of <var title="">a</var>'s <code>RowID</code>'s last value
1864: must be less than <var title="">b</var>'s <code>RowID</code>'s last
1.1 mike 1865: value (i.e. earlier siblings must come before their later
1866: siblings).</p></li>
1867:
1.80 mike 1868: <li><p>If their <code>RowID</code> objects are not the same length,
1.1 mike 1869: but the values in the shorter of the two are the same as the first
1870: few values in the longer one, then <var title="">a</var>'s
1.80 mike 1871: <code>RowID</code> must be the shorter one (i.e. ancestors must
1.1 mike 1872: come before their descendants).</p></li>
1873:
1.80 mike 1874: </ul>
1875:
1876: <hr>
1877:
1878: <p>The <dfn title="dom-datagrid-deleteRows"><code>deleteRows(<var
1879: title="">rows</var>)</code></dfn> method must run the following
1.1 mike 1880: steps:</p>
1881:
1.80 mike 1882: <ol>
1883:
1884: <li>
1.1 mike 1885:
1886: <p>If any of the entries in <var title="">rows</var> are not
1.80 mike 1887: <code>RowID</code> objects consisting of one or more entries whose
1.1 mike 1888: values are all integers that are greater than or equal to zero,
1889: then throw a <code>TypeError</code> exception and abort these
1890: steps.</p>
1891:
1892: <p>To check if a value is an integer, the user agent must first
1.718 mike 1893: apply the ToNumber() abstract operation to the value, and then
1.1 mike 1894: verify that the result is a finite integer. If so, the user agent
1895: must use the result in the rest of the algorithm as if it had that
1.80 mike 1896: had been the value passed to the method. <a
1.98 mike 1897: href="#refsECMA262">[ECMA262]</a></p>
1.1 mike 1898:
1899: </li>
1900:
1901: <li>
1902:
1.80 mike 1903: <p>If any of the <code>RowID</code> objects in the <var
1904: title="">rows</var> argument identify a row that isn't present in
1905: the <span>natural order sparse data tree</span>, then throw a
1906: <code>DATAGRID_MODEL_ERR</code> exception and abort these
1.1 mike 1907: steps.</p>
1908:
1909: </li>
1910:
1911: <li>
1912:
1913: <p>If any row is listed twice in the <var title="">rows</var>
1.80 mike 1914: argument, then throw a <code>DATAGRID_MODEL_ERR</code> exception
1.1 mike 1915: and abort these steps.</p>
1916:
1917: </li>
1918:
1919: <li>
1920:
1921: <p>Sort the <var title="">rows</var> argument such that the
1922: entries are given in the same order as the rows they identify
1923: would be visited in a pre-order, depth first traversal of the
1.80 mike 1924: <span>natural order sparse data tree</span>.</p>
1.1 mike 1925:
1926: </li>
1927:
1928: <li>
1929:
1930: <p>For each row identified by entries in <var title="">rows</var>,
1931: <em>in reverse order</em>, run the following steps:</p>
1932:
1.80 mike 1933: <ol>
1934:
1935: <li>
1.1 mike 1936:
1937: <p>Decrement the child count of the row's parent row, if that
1938: child count is greater than zero. If the row has no parent,
1.80 mike 1939: decrement the <span><code>datagrid</code> child
1940: count</span>.</p>
1.1 mike 1941:
1942: <p>If the row has a parent row, and its child count is now zero,
1943: then close that row.</p>
1944:
1945: </li>
1946:
1947: <li>
1948:
1949: <p>Let <var title="">delta</var> be one more than the row's row
1950: count if the row is open and its row count is greater than zero;
1951: otherwise, let <var title="">delta</var> be one.</p>
1952:
1953: </li>
1954:
1955: <li>
1956:
1957: <p>Let <var title="">ancestor</var> be the row.</p>
1958:
1959: </li>
1960:
1961: <li>
1962:
1963: <p><i>Row count loop</i>: Let <var title="">ancestor</var> be
1964: <var title="">ancestor</var>'s parent row, if any, or null if it
1965: has none.</p>
1966:
1967: </li>
1968:
1969: <li>
1970:
1971: <p>If <var title="">ancestor</var> is null, then decrement the
1.80 mike 1972: <span><code>datagrid</code> row count</span> by <var
1973: title="">delta</var>. Otherwise, if <var title="">ancestor</var>
1974: is open, then decrement its row count by <var
1975: title="">delta</var>.</p>
1.1 mike 1976:
1977: </li>
1978:
1979: <li>
1980:
1981: <p>If <var title="">ancestor</var> is not null, then jump back
1982: to the step labeled <i>row count loop</i> above.</p>
1983:
1984: </li>
1985:
1986: <li>
1987:
1988: <p>Let <var title="">parent</var> be the row's parent, or the
1.80 mike 1989: <code>datagrid</code> if the row has no parent.</p>
1.1 mike 1990:
1991: </li>
1992:
1993: <li>
1994:
1995: <p>Decrement by one the natural order position of all rows whose
1996: parent is <var title="">parent</var> and whose natural order
1997: position is equal to or greater than the row's own natural order
1998: position.</p>
1999:
2000: </li>
2001:
2002: <li>
2003:
1.80 mike 2004: <p>If the row is in the <span>display order sparse data
2005: tree</span>, then decrement by one the display order position of
1.1 mike 2006: all rows whose parent is <var title="">parent</var> and whose
2007: display order position is equal to or greater than the row's own
2008: display order position.</p>
2009:
2010: </li>
2011:
2012: <li>
2013:
2014: <p>Clear the row and its descendants from the
1.80 mike 2015: <code>Datagrid</code>.</p>
1.1 mike 2016:
2017: </li>
2018:
1.80 mike 2019: </ol>
2020:
2021: </li>
1.1 mike 2022:
2023: <li>
2024:
1.80 mike 2025: <p>Invoke the <span><code>datagrid</code> update display
2026: algorithm</span>.</p>
1.1 mike 2027:
2028: </li>
2029:
1.80 mike 2030: </ol>
1.1 mike 2031:
1.80 mike 2032: <hr>
2033:
2034: <p>The <dfn
2035: title="dom-datagrid-clearRows"><code>clearRows()</code></dfn> method
2036: must empty the <span>natural order sparse data tree</span>, reset
2037: both the <span><code>datagrid</code> child count</span> and the
2038: <span><code>datagrid</code> row count</span> to zero, and invoke the
2039: <span><code>datagrid</code> update display algorithm</span>.</p>
2040:
2041: <hr>
2042:
2043: <p>The <dfn title="dom-datagrid-repaint"><code>repaint(<var
2044: title="">row</var>, <var title="">column</var>)</code></dfn> method
1.1 mike 2045: must cause the user agent to clear its cache for the cell specified
1.80 mike 2046: by the identifier <var title="">row</var> and the column <var
2047: title="">column</var>, if that column's type is <code
2048: title="datagrid-type-custom">custom</code>. If the given column has
2049: not been declared, or its type is not <code
2050: title="datagrid-type-custom">custom</code>, then the user agent must
2051: throw a <code>DATAGRID_MODEL_ERR</code> exception. If the given row
1.1 mike 2052: is not known, then the method must do nothing. If the cell is indeed
2053: cleared, the user agent must reinvoke the previously registered
1.80 mike 2054: <code>RenderingContext2DCallback</code> callback when it needs to
1.1 mike 2055: repaint that row.</p>
2056:
1.80 mike 2057: <hr>
2058:
2059: <p>If a row has a child count that isn't zero, then the user agent
1.1 mike 2060: should offer to the user the option of opening and closing the
2061: row.</p>
2062:
2063: <p>When a row is opened, if the row's row count is greater than
2064: zero, then the user agent must increase the
1.80 mike 2065: <span><code>datagrid</code> row count</span> and the row counts of
1.1 mike 2066: any ancestor rows by the number of rows that the newly opened row
1.80 mike 2067: has in its row count<!- - we should also "update the <span>pending
1.1 mike 2068: <code>datagrid</code> rows list</span> and the <span>pending
1.80 mike 2069: <code>datagrid</code> cells list</span> accordingly" - ->, then must
2070: mark the row as open, then may fill in the <span>display order
2071: sparse data tree</span> with any information that the user agent has
1.1 mike 2072: cached about the display order positions of descendants of the newly
1.80 mike 2073: opened row, and then must invoke the <code
2074: title="dom-listener-rowOpened">rowOpened()</code> method on the
2075: current <code title="dom-datagrid-listener">listener</code> with as
2076: its first argument a <code>RowID</code> object identifying the row
1.1 mike 2077: that was opened and as its second argument the boolean false, and
1.80 mike 2078: then must invoke the <span><code>datagrid</code> update display
2079: algorithm</span>.</p>
1.1 mike 2080:
2081: <p>On the other hand, when a row is opened and the row's row count
1.80 mike 2082: is −1, then the user agent must mark the row as opening, and
2083: then must invoke the <code
2084: title="dom-listener-rowOpened">rowOpened()</code> method on the
2085: current <code title="dom-datagrid-listener">listener</code> with as
2086: its first argument a <code>RowID</code> object identifying the row
1.1 mike 2087: that was opened and as its second argument the boolean true.</p>
2088:
2089: <p>When a row is closed, the user agent must decrease the
1.80 mike 2090: <span><code>datagrid</code> row count</span> and the row counts of
1.1 mike 2091: any ancestor rows by the number of rows that the newly closed row
1.80 mike 2092: has in its row count, and then must invoke the <code
2093: title="dom-listener-rowOpened">rowOpened()</code> method on the
2094: current <code title="dom-datagrid-listener">listener</code> with as
2095: its first and only argument a <code>RowID</code> object identifying
1.1 mike 2096: the row that was opened.</p>
2097:
2098:
2099:
1.80 mike 2100: <h6>The cells</h6>
1.1 mike 2101:
2102: <p>Each row has one cell per column. Each cell has the same type as
1.80 mike 2103: its column. The <dfn>allowed <code>datagrid</code> column
1.1 mike 2104: types</dfn>, what they represent, and the requirements for when the
2105: user interacts with them, are as follows:</p>
2106:
1.80 mike 2107: <dl>
2108:
2109: <dt><dfn title="datagrid-type-text"><code>text</code></dfn></dt>
1.1 mike 2110: <dd>
2111:
2112: <p>The cell represents some text and an optional image.</p>
2113:
2114: </dd>
2115:
1.80 mike 2116: <dt><dfn title="datagrid-type-editable"><code>editable</code></dfn></dt>
1.1 mike 2117: <dd>
2118:
2119: <p>The cells represents some editable text, an optional
1.80 mike 2120: <code>datalist</code> giving autocompletion hints, and an
1.1 mike 2121: optional image.</p>
2122:
1.80 mike 2123: <p>If there is a <code>datalist</code> element, the user agent
1.1 mike 2124: should offer the suggestions represented by that element to the
1.80 mike 2125: user. The user agent may use the suggestion's <span
2126: title="concept-option-label">label</span> to identify the
1.1 mike 2127: suggestion. If the user selects a suggestion, then the editable
1.80 mike 2128: text must be set to the selected suggestion's <span
2129: title="concept-option-value">value</span>, as if the user had
1.1 mike 2130: written that value himself.</p>
2131:
2132: <p>When the user edits the value, either directly or using the
1.80 mike 2133: <code>datalist</code>, the user agent must invoke the <code
2134: title="dom-listener-cellChanged">cellChanged()</code> method on
2135: the current <code title="dom-datagrid-listener">listener</code>
2136: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2137: cell's row, as its second argument the identifier of the cell's
2138: column, as its third argument the new value, and as its fourth
2139: argument the previous value.</p>
2140:
2141: </dd>
2142:
1.80 mike 2143: <dt><dfn title="datagrid-type-checkable"><code>checkable</code></dfn></dt>
1.1 mike 2144: <dd>
2145:
2146: <p>The cell represents some text, a check box that optionally has
2147: its value obscured as indeterminate, and an optional image.</p>
2148:
2149: <p>When the user checks or unchecks the check box, the user agent
2150: must change the check box's state appropriately and stop obscuring
2151: the check box as indeterminate (if it is obscuring it), and then
1.80 mike 2152: must invoke the <code
2153: title="dom-listener-cellChanged">cellChanged()</code> method on
2154: the current <code title="dom-datagrid-listener">listener</code>
2155: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2156: cell's row, as its second argument the identifier of the cell's
2157: column, as its third argument true if the check box is now checked
2158: and false otherwise, and as its fourth argument true if the check
2159: box was previously checked and false otherwise.</p>
2160:
2161: </dd>
2162:
1.80 mike 2163: <dt><dfn title="datagrid-type-list"><code>list</code></dfn></dt>
1.1 mike 2164: <dd>
2165:
2166: <p>The cell represents some text giving the current value selected
1.80 mike 2167: from a dropdown list of options, a <code>select</code> element
1.1 mike 2168: giving the list of options, and an optional image.</p>
2169:
2170: <p>The user agent should allow the user to change the value of the
1.80 mike 2171: cell from its current value to one of the <span
2172: title="concept-option-value">values</span> given by
2173: <code>option</code> elements in the <span
2174: title="concept-select-option-list">list of options</span> (if
2175: any). The user agent may use the <code>option</code> elements'
2176: <span title="concept-option-label">labels</span> to annotate each
1.1 mike 2177: option.</p>
2178:
1.80 mike 2179: <p>When the user selects a new value from the <code>select</code>
2180: element's <span title="concept-select-option-list">list of
2181: options</span>, the user agent must invoke the <code
2182: title="dom-listener-cellChanged">cellChanged()</code> method on
2183: the current <code title="dom-datagrid-listener">listener</code>
2184: with as its first argument a <code>RowID</code> identifying the
1.1 mike 2185: cell's row, as its second argument the identifier of the cell's
2186: column, as its third argument the new value, and as its fourth
2187: argument the previous value.</p>
2188:
2189: </dd>
2190:
1.80 mike 2191: <dt><dfn title="datagrid-type-progress"><code>progress</code></dfn></dt>
1.1 mike 2192: <dd>
2193:
2194: <p>The cell represents a (determinate) progress bar whose value is
2195: between 0.0, indicating no progress, and 1.0, indicating the task
2196: is complete.</p>
2197:
2198: </dd>
2199:
1.80 mike 2200: <dt><dfn title="datagrid-type-meter"><code>meter</code></dfn></dt>
1.1 mike 2201: <dd>
2202:
2203: <p>The cell represents a gauge, described by one to six
2204: numbers.</p>
2205:
2206: <p>The gauge's actual value is given by the first number.</p>
2207:
2208: <p>If there is a second number, then that number is the maximum
2209: value. Otherwise, the maximum value is 1.0.</p>
2210:
2211: <p>If there is a third number, then that number is the minimum
2212: value. Otherwise, the minimum value is 1.0.</p>
2213:
2214: <p>If there is a fourth number, then that number is the low
2215: boundary. Otherwise, the low boundary is the minimum value.</p>
2216:
2217: <p>If there is a fifth number, then that number is the high
2218: boundary. Otherwise, the high boundary is the maximum value.</p>
2219:
2220: <p>If there is a sixth number, then the optimal point is the sixth
2221: number. Otherwise, the optimum point is the midpoint between the
2222: minimum value and the maximum value.</p>
2223:
1.80 mike 2224: <!- - next two paragraphs copied from <meter>: - ->
1.1 mike 2225:
2226: <p>If the optimum point is equal to the low boundary or the high
2227: boundary, or anywhere in between them, then the region between the
2228: low and high boundaries of the gauge must be treated as the
2229: optimum region, and the low and high parts, if any, must be
2230: treated as suboptimal. Otherwise, if the optimum point is less
2231: than the low boundary, then the region between the minimum value
2232: and the low boundary must be treated as the optimum region, the
2233: region between the low boundary and the high boundary must be
2234: treated as a suboptimal region, and the region between the high
2235: boundary and the maximum value must be treated as an even less
2236: good region. Finally, if the optimum point is higher than the high
2237: boundary, then the situation is reversed; the region between the
2238: high boundary and the maximum value must be treated as the optimum
2239: region, the region between the high boundary and the low boundary
2240: must be treated as a suboptimal region, and the remaining region
2241: between the low boundary and the minimum value must be treated as
2242: an even less good region.</p>
2243:
2244: <p>User agents should indicate the relative position of the actual
2245: value to the minimum and maximum values, and the relationship
2246: between the actual value and the three regions of the gauge.</p>
2247:
2248: </dd>
2249:
1.80 mike 2250: <dt><dfn title="datagrid-type-custom"><code>custom</code></dfn></dt>
1.1 mike 2251: <dd>
2252:
2253: <p>The cell represents a dynamically generated graphical image.</p>
2254:
2255: <p>The cell will have minimum dimensions (specified in CSS
2256: pixels), and a callback (in the form of a
1.80 mike 2257: <code>RenderingContext2DCallback</code> object) to get a rendering
1.1 mike 2258: for the cell.</p>
2259:
2260: <p>The user agent should not allow the cell to be rendered with
2261: dimensions less than the given minimum width and height.</p>
2262:
2263: <p>When the user agent needs to render the cell, the user agent
1.80 mike 2264: must <span>queue a task</span> to invoke the
2265: <span>RenderingContext2DCallback</span> callback, passing it a
2266: newly created <code>CanvasRenderingContext2D</code> object whose
1.186 mike 2267: <code title="dom-context-2d-canvas">canvas</code> IDL attribute is
1.1 mike 2268: null as the first argument, the actual cell width in CSS pixels as
2269: the second argument, and the actual cell height in CSS pixels as
2270: the third argument.</p>
2271:
2272: <p>If the user agent is able to render graphics, then it must
2273: render the graphics commands that the callback executed on the
1.80 mike 2274: provided <code>CanvasRenderingContext2D</code> object onto the
1.1 mike 2275: cell once the callback returns. The image must be clipped to the
2276: dimensions of the cell. The coordinate space of the cell must be
2277: aligned with that used by the 2D context such that the top left
2278: corner of the cell is the 0,0 origin, with the coordinate space
2279: increasing its <var title="">x</var> dimension towards the right
2280: of the cell and its <var title="">y</var> axis towards the bottom
2281: of the cell, and with the image not scaled (so that one CSS pixel
2282: on the final rendering matches one CSS pixel in the coordinate
2283: space used by the 2D context).</p>
2284:
2285: <p>The user agent must then decouple the
1.80 mike 2286: <code>CanvasRenderingContext2D</code> object and any objects that
2287: it created (such as <code>CanvasPattern</code> objects or
2288: <code>ImageData</code> objects) from any real drawing surface.</p>
1.1 mike 2289:
2290: <p>If the user agent is unable to render graphics, then it must
2291: render the text string returned by the callback instead.</p>
2292:
2293: </dd>
2294:
1.80 mike 2295: </dl>
2296:
2297: <hr>
2298:
2299: <p>When an algorithm requires the user agent to <dfn>apply a
1.1 mike 2300: <code>Row</code> object</dfn>, the user agent must run the following
2301: steps:</p>
2302:
1.80 mike 2303: <ol>
2304:
2305: <li>
2306:
2307: <p>If the value of the <code>Row</code> object's second entry is
2308: not −1, then run these substeps:</p>
1.1 mike 2309:
1.80 mike 2310: <ol>
1.1 mike 2311:
1.80 mike 2312: <li><p>If there is a row with the same parent as the row
2313: specified by the <code>Row</code> object's <code>RowID</code>
1.1 mike 2314: object, whose display order position is currently the same as the
1.80 mike 2315: value of the <code>Row</code> object's second entry, then remove
2316: that row from the <span>display order sparse data
2317: tree</span>.</p></li>
1.1 mike 2318:
2319: <li><p>Set the display order position of the row specified by the
1.80 mike 2320: <code>Row</code> object's <code>RowID</code> to the value of the
2321: <code>Row</code> object's second entry, updating its position in
2322: the <span>display order sparse data tree</span>
1.1 mike 2323: accordingly.</p></li>
2324:
1.80 mike 2325: <li><p>If the row is in the <span>pending
2326: <code>datagrid</code> rows list</span>, remove it.</p></li>
2327:
2328: </ol>
1.1 mike 2329:
1.80 mike 2330: </li>
1.1 mike 2331:
2332: <li>
2333:
1.80 mike 2334: <p>If the fourth entry in the <code>Row</code> object (a
2335: <code>CellList</code> object, an array) is not empty, then for
2336: each <code>Cell</code> object in that array update the cell that
1.1 mike 2337: corresponds to the column identified by the value of the first
1.80 mike 2338: entry of the <code>Cell</code> object, by using the appropriate
1.1 mike 2339: set of steps given below as determined by the type of the
1.80 mike 2340: column. Then, if the cell is in the <span>pending
2341: <code>datagrid</code> cells list</span>, remove it.</p>
1.1 mike 2342:
1.80 mike 2343: <dl>
2344:
2345: <dt>If the column's type is <code title="datagrid-type-text">text</code></dt>
1.1 mike 2346: <dd>
2347:
2348: <p>Update the cell's text to the value given in the
1.80 mike 2349: <code>Cell</code> object's second entry.</p>
1.1 mike 2350:
1.80 mike 2351: <p>If the <code>Cell</code> object has three entries, then copy
2352: the image data from the <code>img</code> element given in the
1.1 mike 2353: third entry, and let the cell's image be given by that image
2354: data. Otherwise, update the cell to have no image.</p>
2355:
2356: </dd>
2357:
1.80 mike 2358: <dt>If the column's type is <code title="datagrid-type-editable">editable</code></dt>
1.1 mike 2359: <dd>
2360:
2361: <p>Update the cell's text to the value given in the
1.80 mike 2362: <code>Cell</code> object's second entry.</p>
1.1 mike 2363:
1.80 mike 2364: <p>If the <code>Cell</code> object has three entries, then let
2365: the <code>datalist</code> element given in the third entry be
2366: the <code>datalist</code> element giving autocompletion
1.1 mike 2367: hints. Otherwise, update the cell to have no
1.80 mike 2368: <code>datalist</code> element.</p>
1.1 mike 2369:
1.80 mike 2370: <p>If the <code>Cell</code> object has four entries, then copy
2371: the image data from the <code>img</code> element given in the
1.1 mike 2372: fourth entry, and let the cell's image be given by that image
2373: data. Otherwise, update the cell to have no image.</p>
2374:
2375: </dd>
2376:
1.80 mike 2377: <dt>If the column's type is <code title="datagrid-type-checkable">checkable</code></dt>
1.1 mike 2378: <dd>
2379:
2380: <p>Update the cell's text to the value given in the
1.80 mike 2381: <code>Cell</code> object's second entry.</p>
1.1 mike 2382:
2383: <p>Update the cell's checked state to match the value of the
2384: third entry: checked if true, unchecked otherwise.</p>
2385:
1.80 mike 2386: <p>If the <code>Cell</code> object has four entries and the
1.1 mike 2387: fourth entry is true, then update the cell to be obscured as
2388: indeterminate. Otherwise, the cell's state is not obscured.</p>
2389:
1.80 mike 2390: <p>If the <code>Cell</code> object has five entries, then copy
2391: the image data from the <code>img</code> element given in the
1.1 mike 2392: fifth entry, and let the cell's image be given by that image
2393: data. Otherwise, update the cell to have no image.</p>
2394:
2395: </dd>
2396:
1.80 mike 2397: <dt>If the column's type is <code title="datagrid-type-list">list</code></dt>
1.1 mike 2398: <dd>
2399:
2400: <p>Update the cell's text to the value given in the
1.80 mike 2401: <code>Cell</code> object's second entry, and the
2402: <code>select</code> element to be the one given in the
2403: <code>Cell</code> object's third entry</p>
1.1 mike 2404:
1.80 mike 2405: <p>If the <code>Cell</code> object has four entries, then copy
2406: the image data from the <code>img</code> element given in the
1.1 mike 2407: fourth entry, and let the cell's image be given by that image
2408: data. Otherwise, update the cell to have no image.</p>
2409:
2410: </dd>
2411:
1.80 mike 2412: <dt>If the column's type is <code title="datagrid-type-progress">progress</code></dt>
1.1 mike 2413: <dd>
2414:
2415: <p>Update the cell to be a progress bar whose progress, on the
2416: scale of 0.0 (no progress) to 1.0 (task complete) is given by
1.80 mike 2417: the value in the <code>Cell</code> object's second entry.</p>
1.1 mike 2418:
2419: </dd>
2420:
1.80 mike 2421: <dt>If the column's type is <code title="datagrid-type-meter">meter</code></dt>
1.1 mike 2422: <dd>
2423:
2424: <p>Update the cell to be a gauge configured with the numbers
2425: given by the second and subsequent entries of the
1.80 mike 2426: <code>Cell</code> object.</p>
1.1 mike 2427:
2428: </dd>
2429:
1.80 mike 2430: <dt>If the column's type is <code title="datagrid-type-custom">custom</code></dt>
1.1 mike 2431: <dd>
2432:
2433: <p>Update the cell's minimum width to be the length in CSS
1.80 mike 2434: pixels given by the <code>Cell</code> object's second entry.</p>
1.1 mike 2435:
2436: <p>Update the cell's minimum height to be the length in CSS
1.80 mike 2437: pixels given by the <code>Cell</code> object's third entry.</p>
1.1 mike 2438:
2439: <p>Update the cell's callback to be the
1.80 mike 2440: <code>RenderingContext2DCallback</code> object given by the
2441: <code>Cell</code> object's fourth entry.</p>
1.1 mike 2442:
2443: </dd>
2444:
1.80 mike 2445: </dl>
2446:
2447: </li>
1.1 mike 2448:
1.80 mike 2449: </ol>
2450:
2451: <hr>
2452:
2453: <p>When the user agent is to run the <dfn><code>datagrid</code>
2454: update display algorithm</dfn>, the user agent must invoke the <code
2455: title="dom-listener-getRows">getRows()</code> and <code
2456: title="dom-listener-getCells">getCells()</code> methods on the
2457: current <code title="dom-datagrid-listener">listener</code> such
2458: that all the current visible rows in the <span>display order sparse
2459: data list</span>, and all the cells in the currently visible columns
1.1 mike 2460: on all the currently visible rows, have been covered.</p>
2461:
1.80 mike 2462: <p>A row is considered covered if it is present in the <span>pending
2463: <code>datagrid</code> rows list</span>, or if the <code
2464: title="dom-listener-getRows">getRows()</code> method is invoked with
1.1 mike 2465: a range that includes the row in question.</p>
2466:
2467: <p>A cell is considered covered if it is present in the
1.80 mike 2468: <span>pending <code>datagrid</code> cells list</span>, or if the
2469: <code title="dom-listener-getRows">getRows()</code> method is
1.1 mike 2470: invoked with a range that includes the row in question and a list of
1.80 mike 2471: columns that includes the cell's column, or if the <code
2472: title="dom-listener-getCells">getCells()</code> method is invoked
1.1 mike 2473: with a list of rows and columns that intersects the cell in
1.80 mike 2474: question. However, the <code
2475: title="dom-listener-getCells">getCells()</code> method can only be
2476: used if the row is already present in the <span>display order sparse
2477: data list</span>.</p>
1.1 mike 2478:
1.80 mike 2479: <p>The <code title="dom-listener-getRows">getRows()</code> method,
1.1 mike 2480: if used, must be invoked with five arguments. The first argument
1.80 mike 2481: must be the index in the <span>display order sparse data list</span>
1.1 mike 2482: to the first row that the user agent is requesting, known as the
2483: <i>anchor row</i>. The second argument must be the number of
2484: consecutive cells for which the user agent is requesting
1.80 mike 2485: information. The third argument must be the <code>RowID</code> of
2486: the row that is the nearest ancestor in the <span>display order
2487: sparse data <em>tree</em></span> of the anchor row. If this is the
2488: <code>datagrid</code>, then the <code>RowID</code> object must be an
1.1 mike 2489: empty array. The fourth argument must be the display order position
1.80 mike 2490: of the anchor row in the <span>display order sparse data
2491: tree</span>, assuming that the row identified in the third argument
1.1 mike 2492: is indeed the anchor row's parent row. The fifth and final argument
2493: must be an array of the identifiers of the columns for which the
2494: user agent is requesting information, in the order they were added
1.80 mike 2495: to the <code>datagrid</code>.</p>
1.1 mike 2496:
1.80 mike 2497: <p>As the <code title="dom-listener-getRows">getRows()</code> method
2498: is invoked, the <span>pending <code>datagrid</code> rows list</span>
1.1 mike 2499: must be updated to include the rows for which information has been
2500: requested, excluding rows for which information is already
1.80 mike 2501: available; and the <span>pending <code>datagrid</code> cells
2502: list</span> must be updated to include the cells for which
1.1 mike 2503: information has been requested on those rows.</p>
2504:
1.80 mike 2505: <p>The <code title="dom-listener-getCells">getCells()</code> method,
1.1 mike 2506: if used, must be invoked with two arguments. The first argument must
1.80 mike 2507: be an array of <code>RowID</code> objects identifying the rows for
1.1 mike 2508: which information is being requested. The second argument must be an
2509: array of the identifiers of the columns for which the user agent is
2510: requesting information, in the order they were added to the
1.80 mike 2511: <code>datagrid</code>.</p>
1.1 mike 2512:
1.80 mike 2513: <p>As the <code title="dom-listener-getCells">getCells()</code>
2514: method is invoked, the <span>pending <code>datagrid</code> cells
2515: list</span> must be updated to include the cells for which
1.1 mike 2516: information has been requested.</p>
2517:
2518: <p>Calls to these methods should be batched so that the rows and
2519: cells to be covered are handled by the fewest number of calls to
2520: these methods as possible. To this end, user agents may invoke the
1.80 mike 2521: <code title="dom-listener-getRows">getRows()</code> method for a set
1.1 mike 2522: of rows that includes some rows that are already in the
1.80 mike 2523: <span>display order sparse data list</span>, and similarly may
2524: invoke the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2525: method with row/column combinations that cover some cells for which
2526: data is already known. Generally, however, user agents should avoid
2527: invoking these methods with arguments that cause information to be
2528: requested when it has already been requested or is already
2529: known.</p>
2530:
2531: <div class="example">
2532:
2533: <p>For example, consider a case represented by the following table,
2534: where the cells marked "Yes" indicate that the data has already
2535: been obtained, the cells marked "Pending" indicate that the data
2536: has been previously requested but not yet obtained, and the cells
2537: with just a dash indicate that no information has ever been
2538: obtained, or any information that had been obtained has now been
2539: discarded.</p>
2540:
1.80 mike 2541: <table>
2542: <tr> <td> <th> Row <th> Column A <th> Column B
2543: <tr> <th> Row 1 <td> - <td> - <td> -
2544: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes
2545: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes
2546: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes
2547: <tr> <th> Row 5 <td> - <td> - <td> -
2548: <tr> <th> Row 6 <td> - <td> - <td> -
2549: <tr> <th> Row 7 <td> Yes <td> Pending <td> -
2550: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending
2551: </table>
2552:
2553: <p>Thus, rows 2, 3, 4, 7, and 8 are already covered, as are the
1.1 mike 2554: cells from those rows except for the cell in column B of row 7.</p>
2555:
2556: <p>Now consider what happens if all of these rows become visible at
2557: once. The user agent has several choices, including (but not
2558: limited to) the following:</p>
2559:
1.80 mike 2560: <ul>
2561:
2562: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2563: method for rows 1 through 8 and columns A and B all at once.</li>
2564:
1.80 mike 2565: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2566: method for row 1, then fire it again for rows 5 through 7.</li>
2567:
1.80 mike 2568: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2569: method for row 1, then fire it again for rows 5 and 6, and then
1.80 mike 2570: fire the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2571: method for row 7 column B.</li>
2572:
1.80 mike 2573: </ul>
2574:
2575: <p>All three options are allowed, but the latter two are preferable
1.1 mike 2576: to the former, as they minimise the amount of redundant information
2577: requested.</p>
2578:
2579: <p>In any case, the data model now looks like this:</p>
2580:
1.80 mike 2581: <table>
2582: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2583: <tr> <th> Row 1 <td> Pending <td> Pending <td> Pending <td> -
2584: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> -
2585: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> -
2586: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> -
2587: <tr> <th> Row 5 <td> Pending <td> Pending <td> Pending <td> -
2588: <tr> <th> Row 6 <td> Pending <td> Pending <td> Pending <td> -
2589: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> -
2590: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> -
2591: </table>
2592:
2593: <p>Now consider the case where a third column, column C, is added
1.1 mike 2594: to the data model. The user agent once again has several choices,
2595: including (but not limited to) the following:</p>
2596:
1.80 mike 2597: <ul>
2598:
2599: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2600: method for rows 1 through 8 again, this time listing just column
2601: C.</li>
2602:
1.80 mike 2603: <li>Fire the <code title="dom-listener-getRows">getRows()</code>
1.1 mike 2604: method for row 1, then fire it again for rows 5 and 6, and then
1.80 mike 2605: fire the <code title="dom-listener-getCells">getCells()</code>
1.1 mike 2606: method for the other rows (in all three cases, listing just column
2607: C).</li>
2608:
1.80 mike 2609: </ul>
2610:
2611: <p>The two options here are as bad as each other; the former
1.1 mike 2612: involves a lot of overlap, but the latter involves a lot of method
2613: calls. Unfortunately the user agent can't do the obvious thing,
1.80 mike 2614: namely just to invoke the <code
2615: title="dom-listener-getCells">getCells()</code> method for all the
1.1 mike 2616: rows listing just column C, because it doesn't have the row
2617: information for all the rows yet (rows 1, 5 and 6 are still
2618: pending).</p>
2619:
2620: <p>In any case, the data model now looks like this:</p>
2621:
1.80 mike 2622: <table>
2623: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2624: <tr> <th> Row 1 <td> Pending <td> Pending <td> Pending <td> Pending
2625: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> Pending
2626: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> Pending
2627: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> Pending
2628: <tr> <th> Row 5 <td> Pending <td> Pending <td> Pending <td> Pending
2629: <tr> <th> Row 6 <td> Pending <td> Pending <td> Pending <td> Pending
2630: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> Pending
2631: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> Pending
2632: </table>
2633:
2634: <p>If at this point the user scrolls around anywhere within this
2635: <code>datagrid</code>, the user agent won't fire the <code
2636: title="dom-listener-getRows">getRows()</code> and <code
2637: title="dom-listener-getCells">getCells()</code> methods, because
1.1 mike 2638: all of the rows and cells are covered.</p>
2639:
2640: <p>Now consider the case where the user agent receives row
2641: information, but no cell information, for rows 1, 5, and 6:</p>
2642:
1.80 mike 2643: <table>
2644: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2645: <tr> <th> Row 1 <td> Yes <td> Pending <td> Pending <td> Pending
2646: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> Pending
2647: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> Pending
2648: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> Pending
2649: <tr> <th> Row 5 <td> Yes <td> Pending <td> Pending <td> Pending
2650: <tr> <th> Row 6 <td> Yes <td> Pending <td> Pending <td> Pending
2651: <tr> <th> Row 7 <td> Yes <td> Pending <td> Pending <td> Pending
2652: <tr> <th> Row 8 <td> Yes <td> Pending <td> Pending <td> Pending
2653: </table>
2654:
2655: <p>The user agent still won't fire any methods when the user
1.1 mike 2656: scrolls, because the data is still covered. But if the script then
1.80 mike 2657: calls the <code title="dom-datagrid-renotify">renotify()</code>
1.1 mike 2658: method, the "Pending" flags would get reset, and the model would
2659: now look like this:</p>
2660:
1.80 mike 2661: <table>
2662: <tr> <td> <th> Row <th> Column A <th> Column B <th> Column C
2663: <tr> <th> Row 1 <td> Yes <td> - <td> - <td> -
2664: <tr> <th> Row 2 <td> Yes <td> Yes <td> Yes <td> -
2665: <tr> <th> Row 3 <td> Yes <td> Yes <td> Yes <td> -
2666: <tr> <th> Row 4 <td> Yes <td> Yes <td> Yes <td> -
2667: <tr> <th> Row 5 <td> Yes <td> - <td> - <td> -
2668: <tr> <th> Row 6 <td> Yes <td> - <td> - <td> -
2669: <tr> <th> Row 7 <td> Yes <td> - <td> - <td> -
2670: <tr> <th> Row 8 <td> Yes <td> - <td> - <td> -
2671: </table>
2672:
2673: <p>Now, assuming that all eight rows and all three columns are
1.1 mike 2674: still visible, the user agent has the following choices (amongst
2675: others):</p>
2676:
1.80 mike 2677: <ul>
2678:
2679: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2680: method for rows 1 through 8, listing all three columns.</li>
2681:
1.80 mike 2682: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2683: method for rows 1 and 5 through 8, listing all three columns, and
2684: then fire the method for rows 2 through 4, listing just column
2685: C.</li>
2686:
1.80 mike 2687: <li>Fire the <code title="dom-listener-getRows">getCells()</code>
1.1 mike 2688: method for rows 1 and 5 through 8, listing just columns A abd B,
2689: and then fire the method for rows 1 through 8, listing just column
2690: C.</li>
2691:
1.80 mike 2692: </ul>
2693:
2694: <p>Here the latter two are preferable because they result in less
1.1 mike 2695: overlap than the first.</p>
2696:
2697: </div>
2698:
1.80 mike 2699: <hr>
2700:
2701: <p>The <span>task source</span> for tasks queued on behalf of a
2702: <code>datagrid</code> is the <span>DOM manipulation task
2703: source</span>.</p>
2704:
2705: </div>
2706:
2707:
2708: <h5>Listening to notifications from the <code>datagrid</code></h5>
1.1 mike 2709:
1.80 mike 2710: <p><i>The conformance criteria in this section apply to any
2711: implementation of the <code>DataGridListener</code> interface,
1.1 mike 2712: including (and most commonly) the content author's
1.80 mike 2713: implementation(s).</i></p>
2714:
2715: <pre class="idl">// To be implemented by Web authors as a JS object
1.81 mike 2716: [NoInterfaceObject]
2717: interface <dfn>DataGridListener</dfn> {
1.80 mike 2718: void <span title="dom-listener-initialize">initialize</span>(in <span>HTMLDataGridElement</span> datagrid);
2719:
2720: 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);
2721: void <span title="dom-listener-getCells">getCells</span>(in <span>RowIDList</span> rows, in <span>ColumnList</span> columns);
2722: void <span title="dom-listener-rowOpened">rowOpened</span>(in <span>RowID</span> row, in boolean rowCountNeeded);
2723: void <span title="dom-listener-rowClosed">rowClosed</span>(in <span>RowID</span> row);
2724:
2725: void <span title="dom-listener-cellChanged">cellChanged</span>(in <span>RowID</span> row, in <span>Column</span> column, in any newValue, in any prevValue);
2726: <span>HTMLMenuElement</span> <span title="dom-listener-getRowMenu">getRowMenu</span>(in <span>RowID</span> row);
2727: <!- -vsDGDND
1.1 mike 2728: boolean <span title="dom-listener-canDrop">canDrop</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
2729: boolean <span title="dom-listener-dropped">dropped</span>(in <span>RowID</span> row, in <span>RowID</span> position, data);
1.80 mike 2730: - -><!- -v2DGPA
1.1 mike 2731: void <span title="dom-listener-performAction">performAction</span>(in <span>RowID</span> row, in DOMString action);
1.80 mike 2732: - ->};</pre>
2733:
2734: <p>The <code>DataGridListener</code> interface, once implemented by
2735: an object in a script and hooked up to a <code>datagrid</code> using
1.186 mike 2736: the <code title="dom-datagrid-listener">listener</code> IDL
1.80 mike 2737: attribute, receives notifications when the <code>datagrid</code>
2738: needs information (such as which rows exist) for display.</p>
2739:
2740: <p>The following methods may be usefully implemented:</p>
2741:
2742: <dl>
2743:
2744: <dt><dfn title="dom-listener-initialize"><code>initialize(<var title="">datagrid</var>)</code></dfn></dt>
1.1 mike 2745:
2746: <dd>
2747:
1.80 mike 2748: <p>Called by the <code>datagrid</code> element (the one given by
2749: the <var title="">datagrid</var> argument) when the <code
2750: title="dom-datagrid-listener">listener</code> attribute is
1.1 mike 2751: set.</p>
2752:
2753: </dd>
2754:
1.80 mike 2755: <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 2756:
2757: <dd>
2758:
1.80 mike 2759: <p>Called by the <code>datagrid</code> element when the user agent
1.1 mike 2760: finds itself needing to render rows for which it is lacking
2761: information.</p>
2762:
2763: <p>The <var title="">rowIndex</var> argument gives the flattened
2764: index of the first row for which it needs information, ignoring
1.80 mike 2765: the tree structure of the <code>datagrid</code> model, where zero
1.1 mike 2766: is the first row of the entire tree.</p>
2767:
2768: <p>The <var title="">rowCount</var> argument gives the number of
2769: rows for which the user agent would like information.</p>
2770:
2771: <p>The <var title="">parentRow</var> argument gives the
1.80 mike 2772: <code>RowID</code> object identifying the nearest ancestor of the
1.1 mike 2773: first row that the user agent is aware of. After the sort order
2774: has changed, this will typically be the root of the tree
1.80 mike 2775: (identified by a <code>RowID</code> object consisting of an empty
1.1 mike 2776: array).
2777:
1.80 mike 2778: <p>The <var title="">columns</var> argument gives the columns for
1.1 mike 2779: which the user agent is lacking information, as an array of column
1.80 mike 2780: identifiers (as passed to <code
2781: title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1 mike 2782:
2783: </dd>
2784:
1.80 mike 2785: <dt><dfn title="dom-listener-getCells"><code>getCells(<var title="">rows</var>, <var title="">columns</var>)</code></dfn></dt>
1.1 mike 2786:
2787: <dd>
2788:
1.80 mike 2789: <p>Called by the <code>datagrid</code> element when the user agent
1.1 mike 2790: finds itself needing to render cells for which it is lacking
2791: information in rows that it does know about.</p>
2792:
2793: <p>The <var title="">rows</var> argument gives an array of
1.80 mike 2794: <code>RowID</code> objects identifying the various rows for which
1.1 mike 2795: the user agent is lacking information.</p>
2796:
2797: <p>The <var title="">columns</var> argument gives the columns for
2798: which the user agent is lacking information, as an array of column
1.80 mike 2799: identifiers (as passed to <code
2800: title="dom-datagrid-addColumn">addColumn()</code>).</p>
1.1 mike 2801:
2802: </dd>
2803:
1.80 mike 2804: <dt><dfn title="dom-listener-rowOpened"><code>rowOpened(<var title="">row</var>, <var title="">rowCountNeeded</var>)</code></dfn></dt>
1.1 mike 2805:
2806: <dd>
2807:
1.80 mike 2808: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2809: opened a row.</p>
2810:
2811: <p>The <var title="">row</var> argument gives an
1.80 mike 2812: <code>RowID</code> object identifying the row that was opened.</p>
1.1 mike 2813:
2814: <p>If the user agent also knows how many children that row has,
2815: then the <var title="">rowCountNeeded</var> argument will be
2816: false. Otherwise, the argument will be true, and the row will
1.80 mike 2817: remain closed until the <code
2818: title="dom-datagrid-setRows">setRows()</code> method is called
1.1 mike 2819: with an accurate row count.</p>
2820:
2821: </dd>
2822:
1.80 mike 2823: <dt><dfn title="dom-listener-rowClosed"><code>rowClosed(<var title="">row</var>)</code></dfn></dt>
1.1 mike 2824:
2825: <dd>
2826:
1.80 mike 2827: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2828: opened a row.</p>
2829:
2830: <p>The <var title="">row</var> argument gives an
1.80 mike 2831: <code>RowID</code> object identifying the row that was closed.</p>
1.1 mike 2832:
2833: </dd>
2834:
1.80 mike 2835: <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 2836:
2837: <dd>
2838:
1.80 mike 2839: <p>Called by the <code>datagrid</code> element when the user has
1.1 mike 2840: edited a cell or checked a check box in a cell.</p>
2841:
2842: <p>The <var title="">row</var> argument gives an
1.80 mike 2843: <code>RowID</code> object identifying the row of the cell, and the
1.1 mike 2844: <var title="">column</var> argument gives the identifier of the
2845: cell's column.</p>
2846:
2847: <p>The <var title="">newValue</var> argument gives the new value,
2848: and the <var title="">prevValue</var> argument gives the previous
2849: value.</p>
2850:
2851: </dd>
2852:
1.80 mike 2853: <dt><dfn title="dom-listener-getRowMenu"><code>getRowMenu(<var title="">row</var>)</code></dfn></dt>
1.1 mike 2854:
1.80 mike 2855: <dd>Must return an <code>HTMLMenuElement</code> object that is to
1.1 mike 2856: be used as a context menu for row <var title="">row</var>, or null
2857: if there is no particular context menu. May be omitted if none of
2858: the rows have a special context menu. As this method is called
2859: immediately before showing the menu in question, no precautions
2860: need to be taken if the return value of this method changes.</dd>
2861:
1.80 mike 2862: <!- -v2DGDND, v2DFPA- ->
1.1 mike 2863:
1.80 mike 2864: </dl>
2865:
2866: <div class="impl">
1.1 mike 2867:
1.80 mike 2868: <p>Objects that implement the <code>DataGridListener</code>
1.1 mike 2869: interface may omit any or all of the methods. When a method is
2870: omitted, a user agent intending to call that method must instead
2871: skip the method call, and must assume that the method's return value
2872: is null.</p>
2873:
1.80 mike 2874: </div>
2875:
2876:
2877:
2878: <!- - v2DGS: <datagrid> selection (search for the bits marked "..." to see what needs filling in, at a minimum)
1.1 mike 2879:
2880: <h5>The selection</h5>
2881:
2882: <pre class="idl">interface <dfn>DataGridSelection</dfn> {
2883: readonly attribute unsigned long <span title="dom-DataGridSelection-length">length</span>;
1.81 mike 2884: getter <span>RowID</span> <span title="dom-DataGridSelection-item">item</span>(in unsigned long index);
1.1 mike 2885: boolean <span title="dom-DataGridSelection-isSelected">isSelected</span>(in <span>RowID</span> row);
2886: void <span title="dom-DataGridSelection-setSelected">setSelected</span>(in <span>RowID</span> row, in boolean selected);
2887: void <span title="dom-DataGridSelection-selectAll">selectAll</span>();
2888: void <span title="dom-DataGridSelection-clear">clear</span>();
2889: };</pre>
2890:
2891: <dl class="domintro">
2892:
2893: ...
2894:
2895: </dl>
2896:
2897: <div class="impl">
2898:
2899: <p>Each <code>datagrid</code> element must keep track of which rows
2900: are currently selected. Initially, no rows are selected. This can be
2901: changed using the methods described in this section.</p>
2902:
2903: <p>The selection of a <code>datagrid</code> is represented by its
1.186 mike 2904: <dfn title="dom-datagrid-selection"><code>selection</code></dfn> IDL
1.1 mike 2905: attribute, which must be a <code>DataGridSelection</code> object.</p>
2906:
2907: <p><code>DataGridSelection</code> objects represent the rows in the
2908: selection. In the selection the rows must be ordered in their
2909: natural order (and not, e.g., the display order). A row with an
2910: ancestor that is closed cannot be selected.</p>
2911:
2912: <p>The <dfn
2913: title="dom-DataGridSelection-length"><code>length</code></dfn>
2914: attribute must return the number of rows currently present in the
2915: selection. This is the <var
2916: title="dom-DataGridSelection-length">length</var>.</p>
2917:
2918: <p>The object's <span>indices of the supported indexed
2919: properties</span> are the numbers in the range zero to <span title=""><var
2920: title="dom-DataGridSelection-length">length</var>-1</span>, unless
2921: the <var title="dom-DataGridSelection-length">length</var> is zero,
2922: in which case there are no <span>supported indexed
2923: properties</span>.</p>
2924:
2925: <p>The <dfn title="dom-DataGridSelection-item"><code>item(<var
2926: title="">index</var>)</code></dfn> method must return a
2927: <code>RowID</code> object identifying the <var
2928: title="">index</var>th row in the selection. If the argument is out
2929: of range (less than zero or greater than the number of selected rows
2930: minus one), then it must raise an <code>INDEX_SIZE_ERR</code>
1.98 mike 2931: exception. <a href="#refsDOMCORE">[DOMCORE]</a></p>
1.1 mike 2932:
2933: <p>The <dfn
2934: title="dom-DataGridSelection-isSelected"><code>isSelected()</code></dfn>
2935: method must return the selected state of the row specified by its
2936: argument. If the specified row is in the <span>natural order sparse
2937: data tree</span> and is selected, the method must return true,
2938: otherwise it must return false.</p>
2939:
2940: <p>The <dfn
2941: title="dom-DataGridSelection-setSelected"><code>setSelected()</code></dfn>
2942: method takes two arguments, <var title="">row</var> and <var
2943: title="">selected</var>. When invoked, it must set the selection
2944: state of row <var title="">row</var> to selected if <var
2945: title="">selected</var> is true, and unselected if it is false. If
2946: <var title="">row</var> does not specify a row in the <span>natural
2947: order sparse data tree</span> ...
2948:
2949: <p>The <dfn
2950: title="dom-DataGridSelection-selectAll"><code>selectAll()</code></dfn>
2951: method must ...
2952:
2953: <p>The <dfn
2954: title="dom-DataGridSelection-clear"><code>clear()</code></dfn>
2955: method must mark all the rows in the <code>datagrid</code> as not
2956: selected. After a call to <code
2957: title="dom-DataGridSelection-clear">clear()</code>, the <code
2958: title="dom-DataGridSelection-length">length</code> attribute will
2959: return zero.</p>
2960:
2961: <p>If the <code>datagrid</code> element has a <code
2962: title="attr-datagrid-multiple">multiple</code> attribute, then the
2963: user agent should allow the user to select any number of rows (zero
2964: or more). If the attribute is not present, then the user agent
2965: should allow the user to select a row, and must not allow the user
2966: to select more than a single row at a time; selecting another one
2967: must unselect all the other rows.</p>
2968:
2969: <p class="note">This only applies to the user. Scripts can select
2970: multiple rows even when the <code
2971: title="attr-datagrid-multiple">multiple</code> attribute is
2972: absent.</p>
2973:
2974: ...event on selection change?...
2975:
2976: </div>
2977:
2978: <p class="note">The <code>DataGridSelection</code> interface has no
2979: relation to the <code>Selection</code> interface.</p>
2980:
1.80 mike 2981: - ->
2982:
2983:
2984: <!- -vsDGDND
1.1 mike 2985: <h5>Drag and drop in <code>datagrid</code>s</h5>
2986:
2987: <p><i>This section only applies to interactive user agents.</i></p>
2988:
2989: ...define drag and drop in datagrids; selectiondraggable...
1.80 mike 2990: - ->
2991:
1.886 mike 2992: --><h4 id="the-command"><span class="secno">4.11.3 </span>The <dfn><code>command</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
1.153 mike 2993: <dd><a href="dom.html#metadata-content">Metadata content</a>.</dd>
2994: <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
2995: <dd><a href="dom.html#phrasing-content">Phrasing content</a>.</dd>
1.1 mike 2996: <dt>Contexts in which this element may be used:</dt>
1.153 mike 2997: <dd>Where <a href="dom.html#metadata-content">metadata content</a> is expected.</dd>
2998: <dd>Where <a href="dom.html#phrasing-content">phrasing content</a> is expected.</dd>
1.1 mike 2999: <dt>Content model:</dt>
3000: <dd>Empty.</dd>
3001: <dt>Content attributes:</dt>
3002: <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
3003: <dd><code title="attr-command-type"><a href="#attr-command-type">type</a></code></dd>
3004: <dd><code title="attr-command-label"><a href="#attr-command-label">label</a></code></dd>
3005: <dd><code title="attr-command-icon"><a href="#attr-command-icon">icon</a></code></dd>
3006: <dd><code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code></dd>
3007: <dd><code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code></dd>
3008: <dd><code title="attr-command-radiogroup"><a href="#attr-command-radiogroup">radiogroup</a></code></dd>
3009: <!--<dd><code title="attr-command-default">default</code></dd>-->
3010: <dd>Also, the <code title="attr-command-title"><a href="#attr-command-title">title</a></code> attribute has special semantics on this element.</dd>
3011: <dt>DOM interface:</dt>
3012: <dd>
3013: <pre class="idl">interface <dfn id="htmlcommandelement">HTMLCommandElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
3014: attribute DOMString <a href="#dom-command-type" title="dom-command-type">type</a>;
3015: attribute DOMString <a href="#dom-command-label" title="dom-command-label">label</a>;
3016: attribute DOMString <a href="#dom-command-icon" title="dom-command-icon">icon</a>;
3017: attribute boolean <a href="#dom-command-disabled" title="dom-command-disabled">disabled</a>;
3018: attribute boolean <a href="#dom-command-checked" title="dom-command-checked">checked</a>;
3019: attribute DOMString <a href="#dom-command-radiogroup" title="dom-command-radiogroup">radiogroup</a>;<!--
3020: attribute boolean <span title="dom-command-default">default</span>;-->
3021: };</pre>
3022: </dd>
3023: </dl><p>The <code><a href="#the-command">command</a></code> element represents a command that the user
1.117 mike 3024: can invoke.</p><p>The <dfn id="attr-command-type" title="attr-command-type"><code>type</code></dfn>
1.1 mike 3025: attribute indicates the kind of command: either a normal command
3026: with an associated action, or a state or option that can be toggled,
1.117 mike 3027: or a selection of one item from a list of items.</p><p>The attribute is an <a href="infrastructure.html#enumerated-attribute">enumerated attribute</a> with three
1.289 mike 3028: keywords and states. The "<dfn id="attr-command-type-keyword-command" title="attr-command-type-keyword-command"><code>command</code></dfn>"
3029: keyword maps to the <a href="#attr-command-type-state-command" title="attr-command-type-state-command">Command</a> state, the
1.520 mike 3030: "<dfn id="attr-command-type-keyword-checkbox" title="attr-command-type-keyword-checkbox"><code>checkbox</code></dfn>"
1.289 mike 3031: keyword maps to the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state, and
3032: the "<dfn id="attr-command-type-keyword-radio" title="attr-command-type-keyword-radio"><code>radio</code></dfn>"
1.1 mike 3033: keyword maps to the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state. The
1.117 mike 3034: <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 3035:
3036: <dd><p>The element <a href="the-xhtml-syntax.html#represents">represents</a> a normal command with an associated action.</p></dd>
3037:
3038: <dt>The <dfn id="attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</dfn> state</dt>
3039:
3040: <dd><p>The element <a href="the-xhtml-syntax.html#represents">represents</a> a state or option that can be toggled.</p></dd>
3041:
3042: <dt>The <dfn id="attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</dfn> state</dt>
3043:
3044: <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>
3045:
3046: </dl><p>The <dfn id="attr-command-label" title="attr-command-label"><code>label</code></dfn>
1.718 mike 3047: attribute gives the name of the command, as shown to the user. The
3048: <code title="attr-command-label"><a href="#attr-command-label">label</a></code> attribute must be
3049: specified and must have a value that is not the empty string.</p><p>The <dfn id="attr-command-title" title="attr-command-title"><code>title</code></dfn>
1.1 mike 3050: attribute gives a hint describing the command, which might be shown
1.117 mike 3051: 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 3052: attribute gives a picture that represents the command. If the
3053: attribute is specified, the attribute's value must contain a
1.870 mike 3054: <a href="infrastructure.html#valid-non-empty-url">valid non-empty URL</a>. <span class="impl">To obtain the
3055: <a href="infrastructure.html#absolute-url">absolute URL</a> of the icon when the attribute's value is
3056: not the empty string, the attribute's value must be <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolved</a> relative to the element. When
3057: the attribute is absent, or its value is the empty string, or <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolving</a> its value fails, there is no
3058: icon.</span></p><!-- this is affected by the base URL being
1.1 mike 3059: changed, so users of this should cache the image once they've
1.117 mike 3060: 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 3061: is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a> that, if present, indicates that
1.117 mike 3062: 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 3063: disabled if, in the same context, it could be enabled if only
3064: certain aspects of the situation were changed. A command would be
3065: marked as hidden if, in that situation, the command will never be
3066: enabled. For example, in the context menu for a water faucet, the
3067: command "open" might be disabled if the faucet is already open, but
3068: the command "eat" would be marked hidden since the faucet could
1.117 mike 3069: never be eaten.</p><p>The <dfn id="attr-command-checked" title="attr-command-checked"><code>checked</code></dfn>
1.1 mike 3070: attribute is a <a href="infrastructure.html#boolean-attribute">boolean attribute</a> that, if present,
3071: indicates that the command is selected. The attribute must be
3072: omitted unless the <code title="attr-command-type"><a href="#attr-command-type">type</a></code>
3073: attribute is in either the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state or
3074: the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a>
1.117 mike 3075: state.</p><p>The <dfn id="attr-command-radiogroup" title="attr-command-radiogroup"><code>radiogroup</code></dfn>
1.1 mike 3076: attribute gives the name of the group of commands that will be
3077: 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 3078: 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 3079: <p>If the <code>command</code> element is used when <span
3080: title="menu generation">generating</span> a <span>context
3081: menu</span>, then the <dfn
3082: title="attr-command-default"><code>default</code></dfn> attribute
3083: indicates, if present, that the command is the one that would have
3084: been invoked if the user had directly activated the menu's subject
3085: instead of using its context menu. The <code
3086: title="attr-command-default">default</code> attribute is a
3087: <span>boolean attribute</span>. The attribute must be omitted unless
3088: the <code title="attr-command-type">type</code> attribute is in the
3089: <span title="attr-command-type-state-command">Command</span>
3090: state.</p>
3091:
3092: <div class="example">
3093:
3094: ...an example that shows an element that, if double-clicked,
3095: invokes an action, but that also has a context menu, showing the
3096: various <code>command</code> attributes off, and that has a default
3097: command...
3098:
3099: </div>
1.117 mike 3100: --><div class="impl">
1.1 mike 3101:
3102: <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><!--,
3103: and <dfn title="dom-command-default"><code>default</code></dfn>-->
1.186 mike 3104: IDL attributes must <a href="infrastructure.html#reflect">reflect</a> the respective content
1.1 mike 3105: attributes of the same name.</p>
3106:
1.153 mike 3107: <p>The element's <a href="embedded-content-0.html#activation-behavior">activation behavior</a> depends on the
1.1 mike 3108: value of the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute
3109: of the element, as follows:</p>
3110:
3111: <dl class="switch"><dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
3112: in the <a href="#attr-command-type-state-checkbox" title="attr-command-type-state-checkbox">Checkbox</a> state</dt>
3113:
3114: <dd><p>If the element has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, the UA must
3115: 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
3116: literal value <code title="">checked</code>. The UA must then
1.788 mike 3117: <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the
1.1 mike 3118: element.</p></dd>
3119:
3120:
3121: <dt>If the <code title="attr-command-type"><a href="#attr-command-type">type</a></code> attribute is
3122: in the <a href="#attr-command-type-state-radio" title="attr-command-type-state-radio">Radio</a> state</dt>
3123:
3124: <dd><p>If the element has a parent, then the UA must walk the list
3125: of child nodes of that parent element, and for each node that is a
3126: <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
3127: 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
3128: they were the empty string), and has a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute, must remove
3129: that attribute.</p>
3130:
3131: <p>Then, the element's <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code> attribute attribute
3132: must be set to the literal value <code title="">checked</code> and
1.788 mike 3133: the user agent must <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code>
1.1 mike 3134: event</a> at the element.</p></dd>
3135:
3136:
3137: <dt>Otherwise</dt>
3138:
1.153 mike 3139: <dd><p>The element has no <a href="embedded-content-0.html#activation-behavior">activation behavior</a>.</p></dd>
1.1 mike 3140:
1.875 mike 3141: </dl><p class="note">Firing a synthetic <code title="event-click"><a href="infrastructure.html#event-click">click</a></code> event at the element does not cause
1.1 mike 3142: any of the actions described above to happen.</p>
3143:
3144: <!-- v2COMMAND: the command="" attribute to make a <command> element
3145: reflect the state of another command, so that the script can update
3146: one place in the page and have context menus, toolbars, shortcuts,
3147: etc, automatically update. Once we add this, expose the Triggers
3148: facet again. -->
3149:
1.117 mike 3150: </div><p class="note"><code><a href="#the-command">command</a></code> elements are not rendered
1.520 mike 3151: unless they <a href="#menus" title="menu">form part of a menu</a>.</p><div class="example">
3152:
3153: <p>Here is an example of a toolbar with three buttons that let the
3154: user toggle between left, center, and right alignment. One could
3155: imagine such a toolbar as part of a text editor. The toolbar also
3156: has a separator followed by another button labeled "Publish",
3157: though that button is disabled.</p>
3158:
3159: <pre><menu type="toolbar">
3160: <command type="radio" radiogroup="alignment" checked="checked"
3161: label="Left" icon="icons/alL.png" onclick="setAlign('left')">
3162: <command type="radio" radiogroup="alignment"
3163: label="Center" icon="icons/alC.png" onclick="setAlign('center')">
3164: <command type="radio" radiogroup="alignment"
3165: label="Right" icon="icons/alR.png" onclick="setAlign('right')">
3166: <hr>
3167: <command type="command" disabled
3168: label="Publish" icon="icons/pub.png" onclick="publish()">
3169: </menu></pre>
3170:
1.886 mike 3171: </div><h4 id="menus"><span class="secno">4.11.4 </span>The <dfn><code>menu</code></dfn> element</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><dl class="element"><dt>Categories</dt>
1.153 mike 3172: <dd><a href="dom.html#flow-content">Flow content</a>.</dd>
1.385 mike 3173: <dd>If the element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state: <a href="embedded-content-0.html#interactive-content">Interactive content</a>.</dd>
1.1 mike 3174: <dt>Contexts in which this element may be used:</dt>
1.153 mike 3175: <dd>Where <a href="dom.html#flow-content">flow content</a> is expected.</dd>
1.1 mike 3176: <dt>Content model:</dt>
3177: <dd>Either: Zero or more <code><a href="semantics.html#the-li-element">li</a></code> elements.</dd>
1.153 mike 3178: <dd>Or: <a href="dom.html#flow-content">Flow content</a>.</dd>
1.1 mike 3179: <dt>Content attributes:</dt>
3180: <dd><a href="dom.html#global-attributes">Global attributes</a></dd>
3181: <dd><code title="attr-menu-type"><a href="#attr-menu-type">type</a></code></dd>
3182: <dd><code title="attr-menu-label"><a href="#attr-menu-label">label</a></code></dd>
3183: <dt>DOM interface:</dt>
3184: <dd>
3185: <pre class="idl">interface <dfn id="htmlmenuelement">HTMLMenuElement</dfn> : <a href="dom.html#htmlelement">HTMLElement</a> {
3186: attribute DOMString <a href="#dom-menu-type" title="dom-menu-type">type</a>;
3187: attribute DOMString <a href="#dom-menu-label" title="dom-menu-label">label</a>;
3188: };</pre>
1.117 mike 3189: </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 3190: is an <a href="infrastructure.html#enumerated-attribute">enumerated attribute</a> indicating the kind of menu
3191: being declared. The attribute has three states. The <code title="attr-menu-type-context">context</code> keyword maps to the
3192: <dfn id="context-menu-state" title="context menu state">context menu</dfn> state, in which
3193: the element is declaring a context menu. The <code title="attr-menu-type-toolbar">toolbar</code> keyword maps to the
1.385 mike 3194: <dfn id="toolbar-state" title="toolbar state">toolbar</dfn> state, in which the
3195: element is declaring a toolbar. The attribute may also be
1.1 mike 3196: omitted. The <i>missing value default</i> is the <dfn id="list-state" title="list
3197: state">list</dfn> state, which indicates that the element is merely
3198: a list of commands that is neither declaring a context menu nor
1.385 mike 3199: defining a toolbar.</p><p>If a <code><a href="#menus">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#context-menu-state" title="context menu state">context menu</a> state, then the
1.1 mike 3200: element <a href="the-xhtml-syntax.html#represents">represents</a> the commands of a context menu, and
3201: the user can only interact with the commands if that context menu is
1.385 mike 3202: activated.</p><p>If a <code><a href="#menus">menu</a></code> element's <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute is in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state, then the element
1.1 mike 3203: <a href="the-xhtml-syntax.html#represents">represents</a> a list of active commands that the user can
1.117 mike 3204: 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 3205: <a href="the-xhtml-syntax.html#represents">represents</a> an unordered list of items (each represented
3206: by an <code><a href="semantics.html#the-li-element">li</a></code> element), each of which represents a command
3207: that the user can perform or activate, or, if the element has no
1.153 mike 3208: <code><a href="semantics.html#the-li-element">li</a></code> element children, <a href="dom.html#flow-content">flow content</a>
1.117 mike 3209: describing available commands.</p><p>The <dfn id="attr-menu-label" title="attr-menu-label"><code>label</code></dfn>
1.1 mike 3210: attribute gives the label of the menu. It is used by user agents to
3211: display nested menus in the UI. For example, a context menu
3212: 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 3213: menu label.</p><div class="impl">
1.1 mike 3214:
1.186 mike 3215: <p>The <dfn id="dom-menu-type" title="dom-menu-type"><code>type</code></dfn> and <dfn id="dom-menu-label" title="dom-menu-label"><code>label</code></dfn> IDL attributes must
1.1 mike 3216: <a href="infrastructure.html#reflect">reflect</a> the respective content attributes of the same
3217: name.</p>
3218:
1.886 mike 3219: </div><h5 id="menus-intro"><span class="secno">4.11.4.1 </span>Introduction</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><i>This section is non-normative.</i></p><p>The <code><a href="#menus">menu</a></code> element is used to define context menus and
1.385 mike 3220: toolbars.</p><p>For example, the following represents a toolbar with three menu
1.148 mike 3221: buttons on it, each of which has a dropdown menu with a series of
3222: options:</p><pre><menu type="toolbar">
1.1 mike 3223: <li>
3224: <menu label="File">
3225: <button type="button" onclick="fnew()">New...</button>
3226: <button type="button" onclick="fopen()">Open...</button>
1.290 mike 3227: <button type="button" onclick="fsave()">Save</button>
1.1 mike 3228: <button type="button" onclick="fsaveas()">Save as...</button>
3229: </menu>
3230: </li>
3231: <li>
3232: <menu label="Edit">
3233: <button type="button" onclick="ecopy()">Copy</button>
3234: <button type="button" onclick="ecut()">Cut</button>
3235: <button type="button" onclick="epaste()">Paste</button>
3236: </menu>
3237: </li>
3238: <li>
3239: <menu label="Help">
3240: <li><a href="help.html">Help</a></li>
3241: <li><a href="about.html">About</a></li>
3242: </menu>
3243: </li>
1.718 mike 3244: </menu></pre><p>In a supporting user agent, this might look like this:</p><p><img alt="A toolbar with three buttons, labeled 'File', 'Edit', and 'Help'; where if you select the 'Edit' button you get a drop-down menu with three more options, 'Copy', 'Cut', and 'Paste'." src="http://dev.w3.org/html5/spec/images/sample-toolbar-1.png"></p><p>In a legacy user agent, the above would look like a bulleted list
1.148 mike 3245: with three items, the first of which has four buttons, the second of
3246: which has three, and the third of which has two nested bullet points
3247: with two items consisting of links.</p><hr><p>The following implements a similar toolbar, with a single button
3248: whose values, when selected, redirect the user to Web sites.</p><pre><form action="redirect.cgi">
3249: <menu type="toolbar">
1.1 mike 3250: <label for="goto">Go to...</label>
3251: <menu label="Go">
1.746 mike 3252: <select id="goto"<!--
1.1 mike 3253: onchange="if (this.options[this.selectedIndex].value)
1.746 mike 3254: window.location = this.options[this.selectedIndex].value"-->>
1.1 mike 3255: <option value="" selected="selected"> Select site: </option>
3256: <option value="http://www.apple.com/"> Apple </option>
3257: <option value="http://www.mozilla.org/"> Mozilla </option>
3258: <option value="http://www.opera.com/"> Opera </option>
3259: </select>
3260: <span><input type="submit" value="Go"></span>
3261: </menu>
3262: </menu>
1.148 mike 3263: </form></pre><p>The behavior in supporting user agents is similar to the example
1.875 mike 3264: above, but here the legacy behavior consists of a single
1.148 mike 3265: <code><a href="forms.html#the-select-element">select</a></code> element with a submit button. The submit button
3266: doesn't appear in the toolbar, because it is not a direct child of
3267: the <code><a href="#menus">menu</a></code> element or of its <code><a href="semantics.html#the-li-element">li</a></code>
3268: children.</p><div class="impl">
1.1 mike 3269:
1.886 mike 3270: <h5 id="building-menus-and-toolbars"><span class="secno">4.11.4.2 </span><dfn>Building menus and toolbars</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3271:
1.385 mike 3272: <p>A menu (or toolbar) consists of a list of zero or more of the
1.1 mike 3273: following components:</p>
3274:
3275: <ul class="brief"><li><a href="#concept-command" title="concept-command">Commands</a>, which can be marked as default commands</li>
3276: <li>Separators</li>
3277: <li>Other menus (which allows the list to be nested)</li>
3278: </ul><p>The list corresponding to a particular <code><a href="#menus">menu</a></code> element
3279: is built by iterating over its child nodes. For each child node in
3280: <a href="infrastructure.html#tree-order">tree order</a>, the required behavior depends on what the
3281: node is, as follows:</p>
3282:
3283: <dl class="switch"><dt>An element that <a href="#concept-command" title="concept-command">defines a command</a></dt>
3284:
3285: <dd>Append the command to the menu, respecting its <a href="#concept-facet" title="concept-facet">facets</a><!-- we might need to be
3286: explicit about what this means for each facet, if testing shows
3287: this isn't well-implemented. e.g.: If there's an Icon facet for the
1.408 mike 3288: command, it should be <span title="fetch">fetched</span> (this
3289: would be http-origin privacy-sensitive), and then that image should
3290: be associated with the command, such that each command only has its
3291: image fetched once, to prevent changes to the base URL from having
3292: effects after the image has been fetched once. (no need to resolve
3293: the Icon facet, it's an absolute URL) -->. <!--If the element is a
3294: <code>command</code> element with a <code
3295: title="attr-command-default">default</code> attribute, mark the
3296: command as being a default command.--></dd>
1.1 mike 3297:
3298:
3299: <dt>An <code><a href="semantics.html#the-hr-element">hr</a></code> element</dt>
3300: <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
3301: string, and has a <code title="attr-option-disabled"><a href="forms.html#attr-option-disabled">disabled</a></code> attribute, and whose
1.804 mike 3302: <code><a href="infrastructure.html#textcontent">textContent</a></code> consists of a string of one or more
1.1 mike 3303: hyphens (U+002D HYPHEN-MINUS)</dt>
3304:
3305: <dd>Append a separator to the menu.</dd>
3306:
3307:
3308: <dt>An <code><a href="semantics.html#the-li-element">li</a></code> element</dt>
3309: <dt>A <code><a href="forms.html#the-label-element">label</a></code> element</dt>
3310:
3311: <dd>Iterate over the children of the element.</dd>
3312:
3313:
3314: <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>
3315: <dt>A <code><a href="forms.html#the-select-element">select</a></code> element</dt>
3316:
3317: <dd>Append a separator to the menu, then iterate over the children
3318: of the <code><a href="#menus">menu</a></code> or <code><a href="forms.html#the-select-element">select</a></code> element, then
3319: append another separator.</dd>
3320:
3321: <!-- v2: we might want to support <select> in <label> as giving a named submenu -->
3322:
3323:
3324: <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>
3325: <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>
3326:
3327: <dd>Append a submenu to the menu, using the value of the element's
3328: <code title="">label</code> attribute as the label of the menu. The
3329: submenu must be constructed by taking the element and creating a
3330: new menu for it using the complete process described in this
3331: section.</dd>
3332:
3333:
3334: <dt>Any other node</dt>
3335:
3336: <dd><a href="infrastructure.html#ignore">Ignore</a> the node.</dd>
3337:
3338: </dl><p>Once all the nodes have been processed as described above, the
3339: user agent must the post-process the menu as follows:</p>
3340:
1.521 mike 3341: <ol><li>Except for separators, any menu item with no label, or whose
3342: label is the empty string, must be removed.</li>
1.1 mike 3343:
1.521 mike 3344: <li>Any sequence of two or more separators in a row must be
3345: collapsed to a single separator.</li>
1.1 mike 3346:
1.521 mike 3347: <li>Any separator at the start or end of the menu must be
3348: removed.</li>
1.1 mike 3349:
1.886 mike 3350: </ol></div><h5 id="context-menus"><span class="secno">4.11.4.3 </span><dfn>Context menus</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <dfn id="attr-contextmenu" title="attr-contextmenu"><code>contextmenu</code></dfn>
1.1 mike 3351: attribute gives the element's <a href="#context-menus" title="context menus">context
3352: menu</a>. The value must be the ID of a <code><a href="#menus">menu</a></code> element
3353: in the DOM. <span class="impl">If the node that would be obtained by
1.875 mike 3354: the invoking the <code title="dom-Document-getElementById"><a href="infrastructure.html#dom-document-getelementbyid">getElementById()</a></code> method
3355: using the attribute's value as the only argument is null or not a
1.1 mike 3356: <code><a href="#menus">menu</a></code> element, then the element has no assigned context
3357: menu. Otherwise, the element's assigned context menu is the element
1.117 mike 3358: so identified.</span></p><div class="impl">
1.1 mike 3359:
3360: <p>When an element's context menu is requested (e.g. by the user
3361: right-clicking the element, or pressing a context menu key), the UA
1.788 mike 3362: must <a href="webappapis.html#fire-a-simple-event">fire a simple event</a> named <code title="event-contextmenu">contextmenu</code> that bubbles and is
1.1 mike 3363: cancelable at the element for which the menu was requested.</p>
3364:
3365: <p class="note">Typically, therefore, the firing of the <code title="event-contextmenu">contextmenu</code> event will be the
3366: default action of a <code title="mouseup">mouseup</code> or <code title="event-keyup">keyup</code> event. The exact sequence of events
3367: is UA-dependent, as it will vary based on platform conventions.</p>
3368:
3369: <p>The default action of the <code title="event-contextmenu">contextmenu</code> event depends on
3370: whether the element or one of its ancestors has a context menu
3371: assigned (using the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> attribute) or not. If
3372: there is no context menu assigned, the default action must be for
3373: the user agent to show its default context menu, if it has one.</p>
3374:
3375: <p>If the element or one of its ancestors <em>does</em> have a
1.788 mike 3376: context menu assigned, then the user agent must <a href="webappapis.html#fire-a-simple-event">fire a simple
1.454 mike 3377: event</a> named <code title="event-show">show</code> at the
1.1 mike 3378: <code><a href="#menus">menu</a></code> element of the context menu of the nearest
3379: ancestor (including the element itself) with one assigned.</p>
3380: <!-- v2: include modifier key information -->
3381:
3382: <p>The default action of <em>this</em> event is that the user agent
1.385 mike 3383: must show a context menu <a href="#building-menus-and-toolbars" title="building menus and
3384: toolbars">built</a> from the <code><a href="#menus">menu</a></code> element.</p>
1.1 mike 3385:
3386: <p>The user agent may also provide access to its default context
3387: menu, if any, with the context menu shown. For example, it could
3388: merge the menu items from the two menus together, or provide the
3389: page's context menu as a submenu of the default menu.</p>
3390:
3391: <p>If the user dismisses the menu without making a selection,
3392: nothing in particular happens.</p>
3393:
1.402 mike 3394: <p>If the user selects a menu item that represents a <a href="#concept-command" title="concept-command">command</a>, then the UA must invoke
1.1 mike 3395: that command's <a href="#command-facet-action" title="command-facet-Action">Action</a>.</p>
3396:
3397: <p>Context menus must not, while being shown, reflect changes in the
1.521 mike 3398: DOM; they are constructed as the default action of the <code title="event-show">show</code> event and must remain as constructed
3399: until dismissed.</p>
1.1 mike 3400:
3401: <p>User agents may provide means for bypassing the context menu
3402: processing model, ensuring that the user can always access the UA's
3403: default context menus. For example, the user agent could handle
3404: right-clicks that have the Shift key depressed in such a way that it
3405: does not fire the <code title="event-contextmenu">contextmenu</code>
3406: event and instead always shows the default context menu.</p>
3407:
3408: <p>The <dfn id="dom-contextmenu" title="dom-contextMenu"><code>contextMenu</code></dfn>
3409: attribute must <a href="infrastructure.html#reflect">reflect</a> the <code title="attr-contextmenu"><a href="#attr-contextmenu">contextmenu</a></code> content attribute.</p>
3410:
1.520 mike 3411: </div><div class="example">
3412:
3413: <p>Here is an example of a context menu for an input control:</p>
3414:
3415: <pre><form name="npc">
3416: <label>Character name: <input name=char type=text contextmenu=namemenu required></label>
3417: <menu type=context id=namemenu>
3418: <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()">
3419: <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)">
3420: </menu>
3421: </form></pre>
3422:
3423: <p>This adds to items to the control's context menu, one called
3424: "Pick random name", and one called "Prefill other fields based on
3425: name". They invoke scripts that are not shown in the example
3426: above.</p>
3427:
1.117 mike 3428: </div><div class="impl">
1.1 mike 3429:
1.886 mike 3430: <h5 id="toolbars"><span class="secno">4.11.4.4 </span><dfn>Toolbars</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3431:
1.385 mike 3432: <p>When a <code><a href="#menus">menu</a></code> element has a <code title="attr-menu-type"><a href="#attr-menu-type">type</a></code> attribute in the <a href="#toolbar-state" title="toolbar state">toolbar</a> state, then the user agent
3433: must <a href="#building-menus-and-toolbars" title="building menus and toolbars">build</a> the
1.1 mike 3434: menu for that <code><a href="#menus">menu</a></code> element, and use the result in the
3435: rendering.</p>
3436:
3437: <p>The user agent must reflect changes made to the
1.385 mike 3438: <code><a href="#menus">menu</a></code>'s DOM, by immediately <a href="#building-menus-and-toolbars" title="building menus
3439: and toolbars">rebuilding</a> the menu.</p>
1.1 mike 3440:
1.886 mike 3441: </div><h4 id="commands"><span class="secno">4.11.5 </span>Commands</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>A <dfn id="concept-command" title="concept-command">command</dfn> is the abstraction
1.51 mike 3442: behind menu items, buttons, and links.<!--v2COMMAND: Once a command
3443: is defined, other parts of the interface can refer to the same
3444: command, allowing many access points to a single feature to share
1.117 mike 3445: aspects such as the disabled state.--></p><p id="facets">Commands are defined to have the following
3446: <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 3447:
3448: <dd>The kind of command: "command", meaning it is a normal command;
3449: "radio", meaning that triggering the command will, amongst other
3450: things, set the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked
3451: State</a> to true (and probably uncheck some other commands); or
3452: "checkbox", meaning that triggering the command will, amongst other
3453: things, toggle the value of the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>.</dd>
3454:
3455: <dt><dfn id="command-facet-id" title="command-facet-ID">ID</dfn></dt>
3456:
3457: <dd>The name of the command, for referring to the command from the
3458: markup or from script. If a command has no ID, it is an
3459: <dfn id="anonymous-command">anonymous command</dfn>.</dd>
3460:
3461: <dt><dfn id="command-facet-label" title="command-facet-Label">Label</dfn></dt>
3462:
3463: <dd>The name of the command as seen by the user.</dd>
3464:
3465: <dt><dfn id="command-facet-hint" title="command-facet-Hint">Hint</dfn></dt>
3466:
3467: <dd>A helpful or descriptive string that can be shown to the
3468: user.</dd>
3469:
3470: <dt><dfn id="command-facet-icon" title="command-facet-Icon">Icon</dfn></dt>
3471:
3472: <dd>An <a href="infrastructure.html#absolute-url">absolute URL</a> identifying a graphical image that
3473: represents the action. A command might not have an Icon.</dd> <!--
3474: changing base URLs might change the icon -->
3475:
3476: <dt><dfn id="command-facet-accesskey" title="command-facet-AccessKey">Access Key</dfn></dt>
3477:
3478: <dd>A key combination selected by the user agent that triggers the
3479: command. A command might not have an Access Key.</dd>
3480:
3481: <dt><dfn id="command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</dfn></dt>
3482:
3483: <dd>Whether the command is hidden or not (basically, whether it
3484: should be shown in menus).</dd>
3485:
3486: <dt><dfn id="command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</dfn></dt>
3487:
3488: <dd>Whether the command is relevant and can be triggered or not.</dd>
3489:
3490: <dt><dfn id="command-facet-checkedstate" title="command-facet-CheckedState">Checked State</dfn></dt>
3491:
3492: <dd>Whether the command is checked or not.</dd>
3493:
3494: <dt><dfn id="command-facet-action" title="command-facet-Action">Action</dfn></dt>
3495:
3496: <dd>The actual effect that triggering the command will have. This
3497: could be a scripted event handler, a <a href="infrastructure.html#url">URL</a> to which to
3498: <a href="history.html#navigate">navigate</a>, or a form submission.</dd>
3499:
3500: <!-- v2COMMAND
3501: <dt><dfn title="command-facet-Triggers">Triggers</dfn></dt>
3502:
3503: <dd>The list of elements that can trigger the command. The element
3504: defining a command is always in the list of elements that can
3505: trigger the command. For anonymous commands, only the element
3506: defining the command is on the list, since other elements have no
3507: way to refer to it.</dd>
3508: -->
3509:
3510: </dl><p>These facets are exposed on elements using the <dfn id="command-api">command
1.117 mike 3511: 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 3512:
3513: <dd>
3514:
3515: <p>Exposes the <a href="#command-facet-type" title="command-facet-Type">Type</a> facet of the command.</p>
3516:
3517: </dd>
3518:
3519: <dt><var title="">element</var> . <code title="dom-id"><a href="dom.html#dom-id">id</a></code></dt>
3520:
3521: <dd>
3522:
3523: <p>Exposes the <a href="#command-facet-id" title="command-facet-ID">ID</a> facet of the command.</p>
3524:
3525: </dd>
3526:
3527: <dt><var title="">element</var> . <code title="dom-command-ro-label"><a href="#dom-command-ro-label">label</a></code></dt>
3528:
3529: <dd>
3530:
3531: <p>Exposes the <a href="#command-facet-label" title="command-facet-Label">Label</a> facet of the command.</p>
3532:
3533: </dd>
3534:
3535: <dt><var title="">element</var> . <code title="dom-title"><a href="dom.html#dom-title">title</a></code></dt>
3536:
3537: <dd>
3538:
3539: <p>Exposes the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> facet of the command.</p>
3540:
3541: </dd>
3542:
3543: <dt><var title="">element</var> . <code title="dom-command-ro-icon"><a href="#dom-command-ro-icon">icon</a></code></dt>
3544:
3545: <dd>
3546:
3547: <p>Exposes the <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> facet of the command.</p>
3548:
3549: </dd>
3550:
3551: <dt><var title="">element</var> . <code title="dom-accessKeyLabel"><a href="editing.html#dom-accesskeylabel">accessKeyLabel</a></code></dt>
3552:
3553: <dd>
3554:
3555: <p>Exposes the <a href="#command-facet-accesskey" title="command-facet-AccessKey">Access Key</a> facet of the command.</p>
3556:
3557: </dd>
3558:
3559: <dt><var title="">element</var> . <code title="dom-hidden"><a href="editing.html#dom-hidden">hidden</a></code></dt>
3560:
3561: <dd>
3562:
3563: <p>Exposes the <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a> facet of the command.</p>
3564:
3565: </dd>
3566:
3567: <dt><var title="">element</var> . <code title="dom-command-ro-disabled"><a href="#dom-command-ro-disabled">disabled</a></code></dt>
3568:
3569: <dd>
3570:
3571: <p>Exposes the <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a> facet of the command.</p>
3572:
3573: </dd>
3574:
3575: <dt><var title="">element</var> . <code title="dom-command-ro-checked"><a href="#dom-command-ro-checked">checked</a></code></dt>
3576:
3577: <dd>
3578:
3579: <p>Exposes the <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a> facet of the command.</p>
3580:
3581: </dd>
3582:
3583: <dt><var title="">element</var> . <code title="dom-click"><a href="editing.html#dom-click">click</a></code>()</dt>
3584:
3585: <dd>
3586:
3587: <p>Triggers the <a href="#command-facet-action" title="command-facet-Action">Action</a> of the command.</p>
3588:
3589: </dd>
3590:
3591: <!--v2COMMAND
3592: <dt><var title="">element</var> . <code title="dom-command-ro-triggers">triggers</code></dt>
3593:
3594: <dd>
3595:
3596: <p>Exposes the <span title="command-facet-Triggers">Triggers</span> facet of the command.</p>
3597:
3598: </dd>
3599: -->
3600:
3601: </dl><div class="impl">
3602:
3603: <p>The <dfn id="dom-command-ro-commandtype" title="dom-command-ro-commandType"><code>commandType</code></dfn>
1.873 mike 3604: attribute must return a string whose value is either "<code title="">command</code>", "<code title="">radio</code>", or "<code title="">checkbox</code>", depending on whether the <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command defined by the
3605: element is "command", "radio", or "checkbox" respectively. If the
1.1 mike 3606: element does not define a command, it must return null.</p>
3607:
3608: <p>The <dfn id="dom-command-ro-label" title="dom-command-ro-label"><code>label</code></dfn>
3609: attribute must return the command's <a href="#command-facet-label" title="command-facet-Label">Label</a>, or null if the element
3610: does not define a command or does not specify a <a href="#command-facet-label" title="command-facet-Label">Label</a>. This attribute will be
1.186 mike 3611: shadowed by the <code title="">label</code> IDL attribute on
1.871 mike 3612: various elements.</p>
1.1 mike 3613:
3614: <p>The <dfn id="dom-command-ro-icon" title="dom-command-ro-icon"><code>icon</code></dfn>
3615: attribute must return the <a href="infrastructure.html#absolute-url">absolute URL</a> of the command's
3616: <a href="#command-facet-icon" title="command-facet-Icon">Icon</a>. If the element does
3617: not specify an icon, or if the element does not define a command,
3618: then the attribute must return null. This attribute will be shadowed
1.186 mike 3619: by the <code title="dom-command-icon"><a href="#dom-command-icon">icon</a></code> IDL attribute on
1.1 mike 3620: <code><a href="#the-command">command</a></code> elements.</p>
3621:
3622: <p>The <dfn id="dom-command-ro-disabled" title="dom-command-ro-disabled"><code>disabled</code></dfn>
3623: attribute must return true if the command's <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a> is that
3624: the command is disabled, and false if the command is not
3625: disabled. This attribute is not affected by the command's <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>. If the
3626: element does not define a command, the attribute must return
1.871 mike 3627: false. This attribute will be shadowed by the <code title="">disabled</code> IDL attribute on various elements.</p>
1.1 mike 3628:
3629: <p>The <dfn id="dom-command-ro-checked" title="dom-command-ro-checked"><code>checked</code></dfn> attribute
3630: must return true if the command's <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a> is that the
3631: command is checked, and false if it is that the command is not
3632: checked. If the element does not define a command, the attribute
1.290 mike 3633: must return false. This attribute will be shadowed by the <code title="">checked</code> IDL attribute on <code><a href="forms.html#the-input-element">input</a></code> and
1.1 mike 3634: <code><a href="#the-command">command</a></code> elements.</p>
3635:
3636: <!--v2COMMAND
3637: <p>The <dfn
3638: title="dom-command-ro-triggers"><code>triggers</code></dfn>
3639: attribute must return a list containing the elements that can
3640: trigger the command (the command's <span
3641: title="command-facet-Triggers">Triggers</span>). The list must be
1.872 mike 3642: <span>live</span>. The same object must be returned each time. While
3643: the element does not define a command, the list must be empty.</p>
1.1 mike 3644: -->
3645:
3646: <p class="note">The <a href="#command-facet-id" title="command-facet-ID">ID</a> facet
1.665 mike 3647: is exposed by the <code title="dom-id"><a href="dom.html#dom-id">id</a></code> IDL attribute,
1.1 mike 3648: the <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> facet is exposed by
1.186 mike 3649: the <code title="dom-title"><a href="dom.html#dom-title">title</a></code> IDL attribute, the <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> facet is exposed by
3650: the <code title="dom-accessKeyLabel"><a href="editing.html#dom-accesskeylabel">accessKeyLabel</a></code> IDL
1.1 mike 3651: attribute, and the <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden
1.186 mike 3652: State</a> facet is exposed by the <code title="dom-hidden"><a href="editing.html#dom-hidden">hidden</a></code> IDL attribute.</p>
1.1 mike 3653:
1.117 mike 3654: </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 3655: <dd>
1.153 mike 3656: <p>Returns an <code><a href="infrastructure.html#htmlcollection">HTMLCollection</a></code> of the elements in the
1.804 mike 3657: <code><a href="infrastructure.html#document">Document</a></code> that define commands and have IDs.</p>
1.1 mike 3658: </dd>
3659:
3660: </dl><div class="impl">
3661:
3662: <p>The <dfn id="dom-document-commands" title="dom-document-commands"><code>commands</code></dfn> attribute
3663: of the document's <code><a href="dom.html#htmldocument">HTMLDocument</a></code> interface must return an
1.804 mike 3664: <code><a href="infrastructure.html#htmlcollection">HTMLCollection</a></code> rooted at the <code><a href="infrastructure.html#document">Document</a></code>
1.1 mike 3665: 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>
3666:
1.117 mike 3667: </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 3668: (visible), e.g. in the user agent's menu bar. User agents are
3669: 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 3670: advertise those keys to the user.</p><div class="impl">
1.1 mike 3671:
1.886 mike 3672: <h5 id="using-the-a-element-to-define-a-command"><span class="secno">4.11.5.1 </span><dfn title="a-command">Using the <code>a</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3673:
1.748 mike 3674: <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="#attr-hyperlink-href">href</a></code> attribute <a href="#concept-command" title="concept-command">defines a command</a>.</p>
1.1 mike 3675:
3676: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3677: is "command".</p>
3678:
3679: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3680: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3681: element, if the attribute is present and not empty. Otherwise the
3682: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3683:
3684: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
1.804 mike 3685: is the string given by the element's <code><a href="infrastructure.html#textcontent">textContent</a></code> IDL
1.1 mike 3686: attribute.</p>
3687:
3688: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3689: is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
3690: 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>
3691:
3692: <p>The <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> of the command
3693: is the <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from <a href="infrastructure.html#resolve-a-url" title="resolve
1.153 mike 3694: a url">resolving</a> the value of the <code title="attr-img-src"><a href="text-level-semantics.html#attr-img-src">src</a></code> attribute of the first
3695: <code><a href="text-level-semantics.html#the-img-element">img</a></code> element descendant of the element, relative to that
1.1 mike 3696: element, if there is such an element and resolving its attribute is
3697: successful. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
3698:
3699: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3700: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
3701: any.</p>
3702:
3703: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
3704: 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
3705: otherwise.</p>
3706:
3707: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
3708: State</a> facet of the command is always false. (The command is
3709: always enabled.)</p>
3710:
3711: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3712: of the command is always false. (The command is never checked.)</p>
3713:
3714: <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.788 mike 3715: command is to <a href="webappapis.html#fire-a-click-event" title="fire a click event">fire a <code title="event-click">click</code> event</a> at the element.</p>
1.1 mike 3716:
3717:
1.886 mike 3718: <h5 id="using-the-button-element-to-define-a-command"><span class="secno">4.11.5.2 </span><dfn title="button-command">Using the <code>button</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3719:
3720: <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>
3721:
3722: <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
3723: determined <a href="#using-the-a-element-to-define-a-command" title="a-command">as for <code>a</code>
3724: elements</a> (see the previous section).</p>
3725:
3726: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
3727: 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>
3728:
3729:
1.886 mike 3730: <h5 id="using-the-input-element-to-define-a-command"><span class="secno">4.11.5.3 </span><dfn title="input-command">Using the <code>input</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3731:
1.39 mike 3732: <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 3733:
3734: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3735: is "radio" if the <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code>
3736: attribute is in the <code title="attr-input-type-radio"><a href="forms.html#radio-button-state">Radio
3737: 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
3738: "command" otherwise.</p>
3739:
3740: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3741: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3742: element, if the attribute is present and not empty. Otherwise the
3743: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3744:
3745: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
3746: depends on the Type of the command:</p>
3747:
3748: <p>If the <a href="#command-facet-type" title="command-facet-Type">Type</a> is "command",
3749: 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
3750: UA-dependent, locale-dependent value that the UA uses to label the
3751: button itself if the attribute is absent.</p>
3752:
3753: <p>Otherwise, the <a href="#command-facet-type" title="command-facet-Type">Type</a> is
3754: "radio" or "checkbox". If the element is a <a href="forms.html#labeled-control">labeled
1.804 mike 3755: control</a>, the <code><a href="infrastructure.html#textcontent">textContent</a></code> of the first
1.1 mike 3756: <code><a href="forms.html#the-label-element">label</a></code> element in <a href="infrastructure.html#tree-order">tree order</a> whose
3757: <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
3758: string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise,
3759: the value of the <code title="attr-input-value"><a href="forms.html#attr-input-value">value</a></code>
3760: 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>
3761:
3762: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3763: is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
3764: of the <code><a href="forms.html#the-input-element">input</a></code> element. If the attribute is not present, the
3765: <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> is the empty
3766: string.</p>
3767:
1.39 mike 3768: <p>If the element's <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code>
3769: attribute is in the <a href="forms.html#image-button-state" title="attr-input-type-image">Image
1.153 mike 3770: Button</a> state, and the element has a <code title="attr-img-src"><a href="text-level-semantics.html#attr-img-src">src</a></code> attribute, and that attribute's
1.39 mike 3771: value can be successfully <a href="infrastructure.html#resolve-a-url" title="resolve a
3772: 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
3773: <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from resolving that attribute
3774: that way. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
1.1 mike 3775:
3776: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3777: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
3778: any.</p>
3779:
3780: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
3781: 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
3782: otherwise.</p>
3783:
3784: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
3785: State</a> of the command mirrors the <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a> state of the
3786: control.</p>
3787:
3788: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3789: 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
3790: element is <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checked</a>
3791: attribute, and false otherwise.</p>
3792:
3793: <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.153 mike 3794: command, if the element has a defined <a href="embedded-content-0.html#activation-behavior">activation
3795: behavior</a>, is to <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation
1.788 mike 3796: steps</a> on the element. Otherwise, it is just to <a href="webappapis.html#fire-a-click-event">fire a
1.1 mike 3797: <code title="event-click">click</code> event</a> at the
3798: element.</p>
3799:
3800:
1.886 mike 3801: <h5 id="using-the-option-element-to-define-a-command"><span class="secno">4.11.5.4 </span><dfn title="option-command">Using the <code>option</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3802:
3803: <p>An <code><a href="forms.html#the-option-element">option</a></code> element with an ancestor
3804: <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
3805: empty string <a href="#concept-command" title="concept-command">defines a
3806: command</a>.</p>
3807:
3808: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3809: is "radio" if the <code><a href="forms.html#the-option-element">option</a></code>'s nearest ancestor
3810: <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
3811: "checkbox" if it does.</p>
3812:
3813: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3814: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3815: element, if the attribute is present and not empty. Otherwise the
3816: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3817:
3818: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
3819: 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,
3820: or the value of the <code><a href="forms.html#the-option-element">option</a></code> element's
1.804 mike 3821: <code><a href="infrastructure.html#textcontent">textContent</a></code> IDL attribute if there isn't.</p>
1.1 mike 3822:
3823: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3824: 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
3825: string if the attribute is absent.</p>
3826:
3827: <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
3828: command.</p>
3829:
3830: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3831: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
3832: any.</p>
3833:
3834: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
3835: 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
3836: otherwise.</p>
3837:
3838: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
3839: State</a> of the command is true (disabled) if the element is
3840: <a href="forms.html#concept-option-disabled" title="concept-option-disabled">disabled</a> or if its
3841: 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
3842: otherwise.</p>
3843:
3844: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3845: 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
3846: false otherwise.</p>
3847:
3848: <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
3849: 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>
3850: 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>
3851: element.</p>
3852:
3853:
1.729 mike 3854: <h5 id="using-the-command-element-to-define-a-command"><span class="secno">4.11.5.5 </span>Using the <dfn title="command-element"><code>command</code></dfn> element to define
1.886 mike 3855: a command</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3856:
3857: <p>A <code><a href="#the-command">command</a></code> element <a href="#concept-command" title="concept-command">defines a command</a>.</p>
3858:
3859: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3860: 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
3861: "<code>radio</code>", "checkbox" if the attribute's value is
3862: "<code>checkbox</code>", and "command" otherwise.</p>
3863:
3864: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3865: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3866: element, if the attribute is present and not empty. Otherwise the
3867: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3868:
3869: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
3870: 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,
3871: or the empty string if it doesn't.</p>
3872:
3873: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3874: 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
3875: empty string if the attribute is absent.</p>
3876:
3877: <p>The <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command
3878: is the <a href="infrastructure.html#absolute-url">absolute URL</a> obtained from <a href="infrastructure.html#resolve-a-url" title="resolve
3879: 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
3880: element, if it has such an attribute and resolving it is
3881: successful. Otherwise, there is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the command.</p>
3882:
3883: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3884: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>, if
3885: any.</p>
3886:
3887: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
3888: 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
3889: otherwise.</p>
3890:
3891: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
3892: State</a> of the command is true (disabled) if the element has a
3893: <code title="attr-command-disabled"><a href="#attr-command-disabled">disabled</a></code> attribute, and
3894: false otherwise.</p>
3895:
3896: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3897: 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
3898: otherwise.</p>
3899:
3900: <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.153 mike 3901: command, if the element has a defined <a href="embedded-content-0.html#activation-behavior">activation
3902: behavior</a>, is to <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation
1.788 mike 3903: steps</a> on the element. Otherwise, it is just to <a href="webappapis.html#fire-a-click-event">fire a
1.1 mike 3904: <code title="event-click">click</code> event</a> at the
3905: element.</p>
3906:
3907:
3908:
3909:
3910:
1.886 mike 3911: <h5 id="using-the-accesskey-attribute-on-a-label-element-to-define-a-command"><span class="secno">4.11.5.6 </span><dfn title="label-command">Using the <code title="attr-accesskey">accesskey</code> attribute on a <code>label</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3912:
3913: <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
3914: key</a> and a <a href="forms.html#labeled-control">labeled control</a> and whose
3915: <a href="forms.html#labeled-control">labeled control</a> <a href="#concept-command" title="concept-command">defines a
3916: command</a>, itself <a href="#concept-command" title="concept-command">defines a
3917: command</a>.</p>
3918:
3919: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3920: is "command".</p>
3921:
3922: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3923: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3924: element, if the attribute is present and not empty. Otherwise the
3925: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3926:
3927: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
1.804 mike 3928: is the string given by the element's <code><a href="infrastructure.html#textcontent">textContent</a></code> IDL
1.1 mike 3929: attribute.</p>
3930:
3931: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3932: is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
3933: of the element.</p>
3934:
3935: <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
3936: command.</p>
3937:
3938: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3939: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
3940:
3941: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>,
3942: <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a>, and
3943: <a href="#command-facet-action" title="command-facet-Action">Action</a> facets of the
3944: command are the same as the respective facets of the element's
3945: <a href="forms.html#labeled-control">labeled control</a>.</p>
3946:
3947: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3948: of the command is always false. (The command is never checked.)</p>
3949:
3950:
3951:
1.886 mike 3952: <h5 id="using-the-accesskey-attribute-on-a-legend-element-to-define-a-command"><span class="secno">4.11.5.7 </span><dfn title="legend-command">Using the <code title="attr-accesskey">accesskey</code> attribute on a <code>legend</code> element to define a command</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3953:
1.300 mike 3954: <p>A <code><a href="forms.html#the-legend-element">legend</a></code> element that has an <a href="editing.html#assigned-access-key">assigned access
1.1 mike 3955: key</a> and is a child of a <code><a href="forms.html#the-fieldset-element">fieldset</a></code> element that
1.300 mike 3956: has a descendant that is not a descendant of the <code><a href="forms.html#the-legend-element">legend</a></code>
1.1 mike 3957: element and is neither a <code><a href="forms.html#the-label-element">label</a></code> element nor a
1.300 mike 3958: <code><a href="forms.html#the-legend-element">legend</a></code> element but that <a href="#concept-command" title="concept-command">defines a command</a>, itself <a href="#concept-command" title="concept-command">defines a command</a>.</p>
1.1 mike 3959:
3960: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
3961: is "command".</p>
3962:
3963: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
3964: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
3965: element, if the attribute is present and not empty. Otherwise the
3966: command is an <a href="#anonymous-command">anonymous command</a>.</p>
3967:
3968: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
1.804 mike 3969: is the string given by the element's <code><a href="infrastructure.html#textcontent">textContent</a></code> IDL
1.1 mike 3970: attribute.</p>
3971:
3972: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
3973: is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
3974: of the element.</p>
3975:
3976: <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
3977: command.</p>
3978:
3979: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
3980: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
3981:
3982: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>,
3983: <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled State</a>, and
3984: <a href="#command-facet-action" title="command-facet-Action">Action</a> facets of the
3985: command are the same as the respective facets of the first element
3986: in <a href="infrastructure.html#tree-order">tree order</a> that is a descendant of the parent of the
1.300 mike 3987: <code><a href="forms.html#the-legend-element">legend</a></code> element that <a href="#concept-command" title="concept-command">defines a command</a> but is not a
3988: descendant of the <code><a href="forms.html#the-legend-element">legend</a></code> element and is neither a
3989: <code><a href="forms.html#the-label-element">label</a></code> nor a <code><a href="forms.html#the-legend-element">legend</a></code> element.</p>
1.1 mike 3990:
3991: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
3992: of the command is always false. (The command is never checked.)</p>
3993:
3994:
3995:
1.886 mike 3996: <h5 id="using-the-accesskey-attribute-to-define-a-command-on-other-elements"><span class="secno">4.11.5.8 </span><dfn title="accesskey-command">Using the <code title="attr-accesskey">accesskey</code> attribute to define a command on other elements</dfn></h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 3997:
1.28 mike 3998: <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>
3999:
4000: <p>If one of the other sections that define elements that <a href="#concept-command" title="concept-command">define commands</a> define that this
4001: element <a href="#concept-command" title="concept-command">defines a command</a>, then
4002: that section applies to this element, and this section does
4003: not. Otherwise, this section applies to that element.</p>
1.1 mike 4004:
4005: <p>The <a href="#command-facet-type" title="command-facet-Type">Type</a> of the command
4006: is "command".</p>
4007:
4008: <p>The <a href="#command-facet-id" title="command-facet-ID">ID</a> of the command is
4009: the value of the <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute of the
4010: element, if the attribute is present and not empty. Otherwise the
4011: command is an <a href="#anonymous-command">anonymous command</a>.</p>
4012:
4013: <p>The <a href="#command-facet-label" title="command-facet-Label">Label</a> of the command
4014: depends on the element. If the element is a <a href="forms.html#labeled-control">labeled
1.804 mike 4015: control</a>, the <code><a href="infrastructure.html#textcontent">textContent</a></code> of the first
1.1 mike 4016: <code><a href="forms.html#the-label-element">label</a></code> element in <a href="infrastructure.html#tree-order">tree order</a> whose
4017: <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
4018: string given by <code><var title="">element</var>.labels[0].textContent</code>). Otherwise, the
4019: <a href="#command-facet-label" title="command-facet-Label">Label</a> is the
1.804 mike 4020: <code><a href="infrastructure.html#textcontent">textContent</a></code> of the element itself.</p>
1.1 mike 4021:
4022: <p>The <a href="#command-facet-hint" title="command-facet-Hint">Hint</a> of the command
4023: is the value of the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute
4024: 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>
4025:
4026: <p>There is no <a href="#command-facet-icon" title="command-facet-Icon">Icon</a> for the
4027: command.</p>
4028:
4029: <p>The <a href="#command-facet-accesskey" title="command-facet-AccessKey">AccessKey</a> of the
4030: command is the element's <a href="editing.html#assigned-access-key">assigned access key</a>.</p>
4031:
4032: <p>The <a href="#command-facet-hiddenstate" title="command-facet-HiddenState">Hidden State</a>
4033: 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
4034: otherwise.</p>
4035:
4036: <p>The <a href="#command-facet-disabledstate" title="command-facet-DisabledState">Disabled
4037: State</a> facet of the command is always false. (The command is
4038: always enabled.)</p>
4039:
4040: <p>The <a href="#command-facet-checkedstate" title="command-facet-CheckedState">Checked State</a>
4041: of the command is always false. (The command is never checked.)</p>
4042:
4043: <p>The <a href="#command-facet-action" title="command-facet-Action">Action</a> of the
1.230 mike 4044: command is to run the following steps:</p>
4045:
4046: <ol><li>If the element is <a href="editing.html#focusable">focusable</a>, run the
4047: <a href="editing.html#focusing-steps">focusing steps</a> for the element.</li>
4048:
4049: <li>If the element has a defined <a href="embedded-content-0.html#activation-behavior">activation behavior</a>,
4050: <a href="embedded-content-0.html#run-synthetic-click-activation-steps">run synthetic click activation steps</a> on the
4051: element.</li>
4052:
4053: <li>Otherwise, if the element does not have a defined
1.788 mike 4054: <a href="embedded-content-0.html#activation-behavior">activation behavior</a>, <a href="webappapis.html#fire-a-click-event">fire a <code title="event-click">click</code> event</a> at the element.</li>
1.1 mike 4055:
1.886 mike 4056: </ol></div><h3 id="links"><span class="secno">4.12 </span>Links</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><h4 id="hyperlink-elements"><span class="secno">4.12.1 </span>Hyperlink elements</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code><a href="text-level-semantics.html#the-a-element">a</a></code>, <code><a href="the-canvas-element.html#the-area-element">area</a></code>, and <code><a href="semantics.html#the-link-element">link</a></code>
1.748 mike 4057: elements can, in certain situations described in the definitions of
4058: those elements, represent <dfn id="hyperlink" title="hyperlink">hyperlinks</dfn>.</p><p>The <dfn id="attr-hyperlink-href" title="attr-hyperlink-href"><code>href</code></dfn>
1.870 mike 4059: attribute on <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements must have
4060: a value that is a <a href="infrastructure.html#valid-url">valid URL</a>. This <a href="infrastructure.html#url">URL</a> is
4061: the <i>destination resource</i> of the hyperlink.</p><p class="note">The <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
4062: attribute on <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements is not
4063: required; when those elements do not have <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attributes they do not
4064: represent hyperlinks.</p><p class="note">The <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code>
4065: attribute on the <code><a href="semantics.html#the-link-element">link</a></code> element <em>is</em> required (and
4066: has to be a <a href="infrastructure.html#valid-non-empty-url">valid <em>non-empty</em> URL</a>), but whether
4067: a <code><a href="semantics.html#the-link-element">link</a></code> element represents a hyperlink or not depends on
4068: the value of the <code title="attr-link-rel"><a href="semantics.html#attr-link-rel">rel</a></code> attribute of
4069: that element.</p><p>The <dfn id="attr-hyperlink-target" title="attr-hyperlink-target"><code>target</code></dfn>
1.748 mike 4070: attribute, if present, must be a <a href="browsers.html#valid-browsing-context-name-or-keyword">valid browsing context name
4071: or keyword</a>. It gives the name of the <a href="browsers.html#browsing-context">browsing
4072: context</a> that will be used. <span class="impl">User agents use
1.869 mike 4073: this name when <a href="#following-hyperlinks">following hyperlinks</a>.</span></p><p>For <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that represent
1.748 mike 4074: hyperlinks, the relationship between the document containing the
4075: hyperlink and the destination resource indicated by the hyperlink is
4076: given by the value of the element's <dfn id="attr-hyperlink-rel" title="attr-hyperlink-rel"><code>rel</code></dfn> attribute, which
4077: must be a <a href="infrastructure.html#set-of-space-separated-tokens">set of space-separated tokens</a>. The <a href="#linkTypes">allowed values and their meanings</a> are defined
4078: below. The <code title="attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute has
4079: no default value. If the attribute is omitted or if none of the
4080: values in the attribute are recognized by the user agent, then the
4081: document has no particular relationship with the destination
4082: resource other than there being a hyperlink between the two.</p><p>The <dfn id="attr-hyperlink-media" title="attr-hyperlink-media"><code>media</code></dfn>
4083: attribute describes for which media the target document was
4084: designed. It is purely advisory. The value must be a <a href="infrastructure.html#valid-media-query">valid
4085: media query</a>. The default, if the <code title="attr-hyperlink-media"><a href="#attr-hyperlink-media">media</a></code> attribute is omitted, is
4086: "<code title="">all</code>".</p><p>The <dfn id="attr-hyperlink-hreflang" title="attr-hyperlink-hreflang"><code>hreflang</code></dfn>
4087: attribute on hyperlink elements, if present, gives the language of
4088: the linked resource. It is purely advisory. The value must be a
4089: valid BCP 47 language code. <a href="references.html#refsBCP47">[BCP47]</a>
4090: <span class="impl">User agents must not consider this attribute
4091: authoritative — upon fetching the resource, user agents must
4092: use only language information associated with the resource to
4093: determine its language, not metadata included in the link to the
4094: resource.</span></p><p>The <dfn id="attr-hyperlink-type" title="attr-hyperlink-type"><code>type</code></dfn>
4095: attribute, if present, gives the <a href="infrastructure.html#mime-type">MIME type</a> of the
4096: linked resource. It is purely advisory. The value must be a
4097: <a href="infrastructure.html#valid-mime-type">valid MIME type</a>. <span class="impl">User agents must
4098: not consider the <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code>
4099: attribute authoritative — upon fetching the resource, user
4100: agents must not use metadata included in the link to the resource to
4101: determine its type.</span></p><div class="impl">
4102:
1.886 mike 4103: <h4 id="following-hyperlinks"><span class="secno">4.12.2 </span><dfn>Following hyperlinks</dfn></h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.748 mike 4104:
4105: <p>When a user <em>follows a hyperlink</em>, the user agent must
4106: <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolve</a> the <a href="infrastructure.html#url">URL</a>
4107: given by the <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute
4108: of that hyperlink, relative to the hyperlink element, and if that is
4109: successful, must <a href="history.html#navigate">navigate</a> a <a href="browsers.html#browsing-context">browsing
4110: context</a> to the resulting <a href="infrastructure.html#absolute-url">absolute URL</a>. In the
4111: case of server-side image maps, the URL of the hyperlink must
4112: further have its <var><a href="text-level-semantics.html#hyperlink-suffix">hyperlink suffix</a></var> appended to it.</p>
4113:
4114: <p>If <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolving</a> the
4115: <a href="infrastructure.html#url">URL</a> fails, the user agent may report the error to the
4116: user in a user-agent-specific manner, may navigate to an error page
4117: to report the error, or may ignore the error and do nothing.</p>
4118:
4119: <p>If the user indicated a specific <a href="browsers.html#browsing-context">browsing context</a>
4120: when following the hyperlink, or if the user agent is configured to
4121: follow hyperlinks by navigating a particular browsing context, then
4122: that must be the <a href="browsers.html#browsing-context">browsing context</a> that is
4123: navigated.</p>
4124:
4125: <p>Otherwise, if the hyperlink element is an <code><a href="text-level-semantics.html#the-a-element">a</a></code> or
4126: <code><a href="the-canvas-element.html#the-area-element">area</a></code> element that has a <code title="attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute, then the
4127: <a href="browsers.html#browsing-context">browsing context</a> that is navigated must be chosen by
4128: applying <a href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name">the rules for choosing a browsing context given a
4129: browsing context name</a>, using the value of the <code title="attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute as the
4130: browsing context name. If these rules result in the creation of a
4131: new <a href="browsers.html#browsing-context">browsing context</a>, it must be navigated with
4132: <a href="history.html#replacement-enabled">replacement enabled</a>.</p>
4133:
4134: <p>Otherwise, if the hyperlink element is a <a href="#rel-sidebar-hyperlink" title="rel-sidebar-hyperlink">sidebar hyperlink</a> and the user
4135: agent implements a feature that can be considered a secondary
4136: browsing context, such a secondary browsing context may be selected
4137: as the browsing context to be navigated.</p>
4138:
4139: <p>Otherwise, if the hyperlink element is an <code><a href="text-level-semantics.html#the-a-element">a</a></code> or
4140: <code><a href="the-canvas-element.html#the-area-element">area</a></code> element with no <code title="attr-hyperlink-target"><a href="#attr-hyperlink-target">target</a></code> attribute, but one of
4141: the child nodes of <a href="dom.html#the-head-element">the <code>head</code> element</a> is a
4142: <code><a href="semantics.html#the-base-element">base</a></code> element with a <code title="attr-base-target"><a href="semantics.html#attr-base-target">target</a></code> attribute, then the browsing
4143: context that is navigated must be chosen by applying <a href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name">the rules
4144: for choosing a browsing context given a browsing context name</a>,
4145: using the value of the <code title="attr-base-target"><a href="semantics.html#attr-base-target">target</a></code>
4146: attribute of the first such <code><a href="semantics.html#the-base-element">base</a></code> element as the
4147: browsing context name. If these rules result in the creation of a
4148: new <a href="browsers.html#browsing-context">browsing context</a>, it must be navigated with
4149: <a href="history.html#replacement-enabled">replacement enabled</a>.</p>
4150:
4151: <p>Otherwise, the browsing context that must be navigated is the
4152: same browsing context as the one which the hyperlink element itself
4153: is in.</p>
4154:
4155: <p>The navigation must be done with the <a href="browsers.html#browsing-context">browsing
1.804 mike 4156: context</a> that contains the <code><a href="infrastructure.html#document">Document</a></code> object with
1.748 mike 4157: which the hyperlink's element in question is associated as the
4158: <a href="history.html#source-browsing-context">source browsing context</a>.</p>
4159:
1.886 mike 4160: </div><h4 id="linkTypes"><span class="secno">4.12.3 </span>Link types</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The following table summarizes the link types that are defined by
1.748 mike 4161: this specification. This table is non-normative; the actual
4162: definitions for the link types are given in the next few
4163: sections.</p><p>In this section, the term <i>referenced document</i> refers to
4164: the resource identified by the element representing the link, and
4165: the term <i>current document</i> refers to the resource within
4166: which the element representing the link finds itself.</p><div class="impl">
4167:
4168: <p>To determine which link types apply to a <code><a href="semantics.html#the-link-element">link</a></code>,
4169: <code><a href="text-level-semantics.html#the-a-element">a</a></code>, or <code><a href="the-canvas-element.html#the-area-element">area</a></code> element, the element's <code title="">rel</code> attribute must be <a href="infrastructure.html#split-a-string-on-spaces" title="split a string on
4170: spaces">split on spaces</a>. The resulting tokens are the link
4171: types that apply to that element.</p>
4172:
4173: </div><p>Except where otherwise specified, a keyword must not be specified
4174: more than once per <code title="attr-rel-hyperlink">rel</code>
4175: attribute.</p><p>The link types that contain no U+003A COLON characters (:),
4176: including all those defined in this specification, are <a href="infrastructure.html#ascii-case-insensitive">ASCII
4177: case-insensitive</a> values<span class="impl">, and must be
4178: compared as such</span>.</p><p class="example">Thus, <code title="">rel="next"</code> is the
4179: same as <code title="">rel="NEXT"</code>.</p><table><thead><tr><th rowspan="2">Link type</th>
4180: <th colspan="2">Effect on...</th>
4181: <th rowspan="2">Brief description</th>
4182: </tr><tr><th><code><a href="semantics.html#the-link-element">link</a></code></th>
4183: <th><code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code></th>
4184: </tr></thead><tbody><tr><td><code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code></td> <!-- second most used <link rel> value -->
4185: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4186: <td><a href="#hyperlink">Hyperlink</a></td>
4187: <td>Gives alternate representations of the current document.</td>
4188: </tr><tr><td><code title="rel-archives"><a href="#link-type-archives">archives</a></code></td>
4189: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4190: <td><a href="#hyperlink">Hyperlink</a></td>
4191: <td>Provides a link to a collection of records, documents, or other materials of historical interest.</td>
4192: </tr><tr><td><code title="rel-author"><a href="#link-type-author">author</a></code></td>
4193: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4194: <td><a href="#hyperlink">Hyperlink</a></td>
4195: <td>Gives a link to the current document's author.</td>
4196: </tr><tr><td><code title="rel-bookmark"><a href="#link-type-bookmark">bookmark</a></code></td> <!-- fourth most used <a rel> value -->
4197: <td><em>not allowed</em></td>
4198: <td><a href="#hyperlink">Hyperlink</a></td>
4199: <td>Gives the permalink for the nearest ancestor section.</td>
4200: </tr><!-- (commented out on the assumption that rel=contact is really XFN)
4201: <tr>
4202: <td><code title="rel-contact">contact</code></td> <!- 8th most used <a rel> value ->
4203: <td><span title="hyperlink link">Hyperlink</span></td>
4204: <td><span>Hyperlink</span></td>
4205: <td>Gives a link to contact information for the current document.</td>
4206: </tr>
4207: --><tr><td><code title="rel-external"><a href="#link-type-external">external</a></code></td> <!-- fifth and sixth most used <a rel> value (sixth is "external nofollow") -->
4208: <td><em>not allowed</em></td>
4209: <td><a href="#hyperlink">Hyperlink</a></td>
4210: <td>Indicates that the referenced document is not part of the same site as the current document.</td>
4211: </tr><tr><td><code title="rel-first"><a href="#link-type-first">first</a></code></td>
4212: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4213: <td><a href="#hyperlink">Hyperlink</a></td>
4214: <td>Indicates that the current document is a part of a series, and that the first document in the series is the referenced document.</td>
4215: </tr><tr><td><code title="rel-help"><a href="#link-type-help">help</a></code></td>
4216: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4217: <td><a href="#hyperlink">Hyperlink</a></td>
4218: <td>Provides a link to context-sensitive help.</td>
4219: </tr><tr><td><code title="rel-icon"><a href="#rel-icon">icon</a></code></td> <!-- link rel="shortcut icon" and its ilk are the fourth, sixth, and ninth most used values -->
4220: <td><a href="semantics.html#external-resource-link" title="external resource link">External Resource</a></td>
4221: <td><em>not allowed</em></td>
4222: <td>Imports an icon to represent the current document.</td>
4223: </tr><tr><td><code title="rel-index"><a href="#link-type-index">index</a></code></td> <!-- used more than "top" and "contents" on <link> (though on <a>, "contents" wins) -->
4224: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4225: <td><a href="#hyperlink">Hyperlink</a></td>
4226: <td>Gives a link to the document that provides a table of contents or index listing the current document.</td>
4227: </tr><tr><td><code title="rel-last"><a href="#link-type-last">last</a></code></td>
4228: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4229: <td><a href="#hyperlink">Hyperlink</a></td>
4230: <td>Indicates that the current document is a part of a series, and that the last document in the series is the referenced document.</td>
4231: </tr><tr><td><code title="rel-license"><a href="#link-type-license">license</a></code></td> <!-- seventh most used <a rel> value -->
4232: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4233: <td><a href="#hyperlink">Hyperlink</a></td>
4234: <td>Indicates that the main content of the current document is covered by the copyright license described by the referenced document.</td>
4235: </tr><tr><td><code title="rel-next"><a href="#link-type-next">next</a></code></td>
4236: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4237: <td><a href="#hyperlink">Hyperlink</a></td>
4238: <td>Indicates that the current document is a part of a series, and that the next document in the series is the referenced document.</td>
4239: </tr><tr><td><code title="rel-nofollow"><a href="#link-type-nofollow">nofollow</a></code></td> <!-- most used <a rel> value (and sixth most used is "external nofollow") -->
4240: <td><em>not allowed</em></td>
4241: <td><a href="#hyperlink">Hyperlink</a></td>
4242: <td>Indicates that the current document's original author or publisher does not endorse the referenced document.</td>
4243: </tr><tr><td><code title="rel-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code></td>
4244: <td><em>not allowed</em></td>
4245: <td><a href="#hyperlink">Hyperlink</a></td>
4246: <td>Requires that the user agent not send an HTTP <code title="http-referer">Referer</code> (sic) header if the user follows the hyperlink.</td>
4247: </tr><tr><td><code title="rel-pingback"><a href="#link-type-pingback">pingback</a></code></td>
4248: <td><a href="semantics.html#external-resource-link" title="external resource link">External Resource</a></td>
4249: <td><em>not allowed</em></td>
4250: <td>Gives the address of the pingback server that handles pingbacks to the current document.</td>
4251: </tr><tr><td><code title="rel-prefetch"><a href="#link-type-prefetch">prefetch</a></code></td>
4252: <td><a href="semantics.html#external-resource-link" title="external resource link">External Resource</a></td>
4253: <td><em>not allowed</em></td>
4254: <td>Specifies that the target resource should be preemptively cached.</td>
4255: </tr><tr><td><code title="rel-prev"><a href="#link-type-prev">prev</a></code></td> <!-- prev is used more than previous -->
4256: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4257: <td><a href="#hyperlink">Hyperlink</a></td>
4258: <td>Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document.</td>
4259: </tr><tr><td><code title="rel-search"><a href="#link-type-search">search</a></code></td> <!-- used quite a bit -->
4260: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4261: <td><a href="#hyperlink">Hyperlink</a></td>
4262: <td>Gives a link to a resource that can be used to search through the current document and its related pages.</td>
4263: </tr><tr><td><code title="rel-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code></td> <!-- most commonly used <link rel> value, variants came in 7th, 8th, 12th, 17th... -->
4264: <td><a href="semantics.html#external-resource-link" title="external resource link">External Resource</a></td>
4265: <td><em>not allowed</em></td>
4266: <td>Imports a stylesheet.</td>
4267: </tr><tr><td><code title="rel-sidebar"><a href="#link-type-sidebar">sidebar</a></code></td> <!-- used quite a bit -->
4268: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4269: <td><a href="#hyperlink">Hyperlink</a></td>
4270: <td>Specifies that the referenced document, if retrieved, is intended to be shown in the browser's sidebar (if it has one).</td>
4271: </tr><tr><td><code title="rel-tag"><a href="#link-type-tag">tag</a></code></td> <!-- second and third most used <a rel> value (third is technically "category tag"). -->
4272: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4273: <td><a href="#hyperlink">Hyperlink</a></td>
4274: <td>Gives a tag (identified by the given address) that applies to the current document.</td>
4275: </tr><tr><td><code title="rel-up"><a href="#link-type-up">up</a></code></td>
4276: <td><a href="semantics.html#hyperlink-link" title="hyperlink link">Hyperlink</a></td>
4277: <td><a href="#hyperlink">Hyperlink</a></td>
4278: <td>Provides a link to a document giving the context for the current document.</td>
4279: </tr></tbody></table><div class="impl">
4280:
4281: <p>Some of the types described below list synonyms for these
4282: values. These <!--<span class="impl">-->are to be handled as
4283: specified by user agents, but<!--</span>--> must not be used in
4284: documents.</p>
4285:
4286: </div><!-- v2 ideas:
4287: * rel="script"
4288: * rel="related" // see also
4289: * http://microformats.org/wiki/rel-enclosure
1.886 mike 4290: --><h5 id="link-type-alternate"><span class="secno">4.12.3.1 </span>Link type "<dfn title="rel-alternate"><code>alternate</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword may be
1.748 mike 4291: used with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
1.891 mike 4292: elements.</p><p>The meaning of this keyword depends on the values of the other
4293: attributes.</p><dl class="switch"><dt>If the element is a <code><a href="semantics.html#the-link-element">link</a></code> element and the <code title="attr-link-rel"><a href="semantics.html#attr-link-rel">rel</a></code> attribute also contains the
4294: keyword <code title="rel-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code></dt>
1.748 mike 4295:
1.891 mike 4296: <dd>
4297:
4298: <p>The <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword
4299: modifies the meaning of the <code title="rel-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code> keyword in the way
4300: described for that keyword. The <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword does not create a
4301: link of its own.</p>
4302:
4303: </dd>
1.748 mike 4304:
4305:
1.891 mike 4306: <dt>The <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword is
4307: used with the <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code>
4308: attribute set to the value <code title="">application/rss+xml</code> or the value <code title="">application/atom+xml</code></dt>
4309:
4310: <dd>
1.748 mike 4311:
1.891 mike 4312: <p>The link is a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>
4313: referencing a syndication feed (though not necessarily syndicating
4314: exactly the same content as the current page).</p>
1.748 mike 4315:
1.891 mike 4316: <div class="impl">
1.748 mike 4317:
1.891 mike 4318: <p>The first <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, or <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4319: element in the document (in tree order) with the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword used with the <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> attribute set to the value
4320: <code title="">application/rss+xml</code> or the value <code title="">application/atom+xml</code> must be treated as the default
4321: syndication feed for the purposes of feed autodiscovery.</p>
1.748 mike 4322:
1.891 mike 4323: <div class="example">
4324: <p>The following <code><a href="semantics.html#the-link-element">link</a></code> element gives the syndication
4325: feed for the current page:</p>
4326: <pre><link rel="alternate" type="application/atom+xml" href="data.xml"></pre>
4327: <p>The following extract offers various different syndication
4328: feeds:</p>
4329: <pre><p>You can access the planets database using Atom feeds:</p>
1.748 mike 4330: <ul>
4331: <li><a href="recently-visited-planets.xml" rel="alternate" type="application/atom+xml">Recently Visited Planets</a></li>
4332: <li><a href="known-bad-planets.xml" rel="alternate" type="application/atom+xml">Known Bad Planets</a></li>
4333: <li><a href="unexplored-planets.xml" rel="alternate" type="application/atom+xml">Unexplored Planets</a></li>
4334: </ul></pre>
1.891 mike 4335: </div>
4336:
4337: </div>
4338:
4339: </dd>
4340:
4341:
4342: <dt>Otherwise</dt>
4343:
4344: <dd>
4345:
4346: <p>The link is a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>
4347: referencing an alternate representation of the current
4348: document.</p>
4349:
4350: <p>The nature of the referenced document is given by the <code title="attr-hyperlink-media"><a href="#attr-hyperlink-media">media</a></code>, <code title="attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code>, and <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> attributes.</p>
4351:
4352: <p>If the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword is
4353: used with the <code title="attr-hyperlink-media"><a href="#attr-hyperlink-media">media</a></code>
4354: attribute, it indicates that the referenced document is intended for
4355: use with the media specified.</p>
4356:
4357: <p>If the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword is
4358: used with the <code title="attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code>
4359: attribute, and that attribute's value differs from the <a href="infrastructure.html#root-element">root
4360: element</a>'s <a href="dom.html#language">language</a>, it indicates that the
4361: referenced document is a translation.</p>
4362:
4363: <p>If the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword is
4364: used with the <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code>
4365: attribute, it indicates that the referenced document is a
4366: reformulation of the current document in the specified format.</p>
4367:
4368: <p>The <code title="attr-hyperlink-media"><a href="#attr-hyperlink-media">media</a></code>, <code title="attr-hyperlink-hreflang"><a href="#attr-hyperlink-hreflang">hreflang</a></code>, and <code title="attr-hyperlink-type"><a href="#attr-hyperlink-type">type</a></code> attributes can be combined
4369: when specified with the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code>
4370: keyword.</p>
4371:
4372: <div class="example">
4373:
4374: <p>For example, the following link is a French translation that
4375: uses the PDF format:</p>
1.748 mike 4376:
1.891 mike 4377: <pre><link rel=alternate type=application/pdf hreflang=fr href=manual-fr></pre>
1.748 mike 4378:
1.891 mike 4379: </div>
1.748 mike 4380:
1.891 mike 4381: <p>This relationship is transitive — that is, if a document
4382: links to two other documents with the link type "<code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code>", then, in addition to
4383: implying that those documents are alternative representations of
4384: the first document, it is also implying that those two documents
4385: are alternative representations of each other.</p>
1.748 mike 4386:
1.891 mike 4387: </dd>
1.748 mike 4388:
1.891 mike 4389: </dl><h5 id="link-type-archives"><span class="secno">4.12.3.2 </span>Link type "<dfn title="rel-archives"><code>archives</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-archives"><a href="#link-type-archives">archives</a></code> keyword may be
1.748 mike 4390: used with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4391: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-archives"><a href="#link-type-archives">archives</a></code> keyword indicates
4392: that the referenced document describes a collection of records,
4393: documents, or other materials of historical interest.</p><p class="example">A blog's index page could link to an index of the
4394: blog's past posts with <code title="">rel="archives"</code>.</p><div class="impl">
4395:
4396: <p><strong>Synonyms</strong>: For historical reasons, user agents
4397: must also treat the keyword "<code title="">archive</code>" like the
4398: <code title="rel-archives"><a href="#link-type-archives">archives</a></code> keyword.</p>
4399:
1.886 mike 4400: </div><h5 id="link-type-author"><span class="secno">4.12.3.3 </span>Link type "<dfn title="rel-author"><code>author</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-author"><a href="#link-type-author">author</a></code> keyword may be
1.748 mike 4401: used with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4402: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>For <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements, the <code title="rel-author"><a href="#link-type-author">author</a></code> keyword indicates that the
4403: referenced document provides further information about the author of
4404: the nearest <code><a href="semantics.html#the-article-element">article</a></code> element ancestor of the element
4405: defining the hyperlink, if there is one, or of the page as a whole,
4406: otherwise.</p><p>For <code><a href="semantics.html#the-link-element">link</a></code> elements, the <code title="rel-author"><a href="#link-type-author">author</a></code> keyword indicates that the
4407: referenced document provides further information about the author
4408: for the page as a whole.</p><p class="note">The "referenced document" can be, and often is, a
4409: <code title="">mailto:</code> URL giving the e-mail address of the
4410: author. <a href="references.html#refsMAILTO">[MAILTO]</a></p><div class="impl">
4411:
4412: <p><strong>Synonyms</strong>: For historical reasons, user agents
4413: must also treat <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and
4414: <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that have a <code title="">rev</code>
4415: attribute with the value "<code>made</code>" as having the <code title="rel-author"><a href="#link-type-author">author</a></code> keyword specified as a link
4416: relationship.</p>
4417:
1.886 mike 4418: </div><h5 id="link-type-bookmark"><span class="secno">4.12.3.4 </span>Link type "<dfn title="rel-bookmark"><code>bookmark</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-bookmark"><a href="#link-type-bookmark">bookmark</a></code> keyword may be
1.748 mike 4419: used with <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</p><p>The <code title="rel-bookmark"><a href="#link-type-bookmark">bookmark</a></code> keyword gives a
4420: permalink for the nearest ancestor <code><a href="semantics.html#the-article-element">article</a></code> element of
4421: the linking element in question, or of <a href="semantics.html#associatedSection">the section the linking element is most
4422: closely associated with</a>, if there are no ancestor
4423: <code><a href="semantics.html#the-article-element">article</a></code> elements.</p><div class="example">
4424: <p>The following snippet has three permalinks. A user agent could
4425: determine which permalink applies to which part of the spec by
4426: looking at where the permalinks are given.</p>
4427: <pre> ...
4428: <body>
4429: <h1>Example of permalinks</h1>
4430: <div id="a">
4431: <h2>First example</h2>
4432: <p><a href="a.html" rel="bookmark">This</a> permalink applies to
4433: only the content from the first H2 to the second H2. The DIV isn't
4434: exactly that section, but it roughly corresponds to it.</p>
4435: </div>
4436: <h2>Second example</h2>
4437: <article id="b">
4438: <p><a href="b.html" rel="bookmark">This</a> permalink applies to
4439: the outer ARTICLE element (which could be, e.g., a blog post).</p>
4440: <article id="c">
4441: <p><a href="c.html" rel="bookmark">This</a> permalink applies to
4442: the inner ARTICLE element (which could be, e.g., a blog comment).</p>
4443: </article>
4444: </article>
4445: </body>
4446: ...</pre>
4447: </div><!-- (commented out on the assumption that rel=contact is really XFN)
4448: <h5>Link type "<dfn title="rel-contact"><code>contact</code></dfn>"</h5>
4449:
4450: <p>The <code title="rel-contact">contact</code> keyword may be used
4451: with <code>link</code>, <code>a</code>, and <code>area</code>
4452: elements. For <code>link</code> elements, it creates a <span
4453: title="hyperlink link">hyperlink</span>.</p>
4454:
4455: <p>For <code>a</code> and <code>area</code> elements, the <code
4456: title="rel-contact">contact</code> keyword indicates that the
4457: referenced document provides further contact information for the
4458: author of the nearest <code>article</code> element ancestor of the
4459: element defining the hyperlink, if there is one, or of the page as a
4460: whole, otherwise.</p>
4461:
4462: <div class="impl">
4463:
4464: <p>User agents must treat any hyperlink in an <code>address</code>
4465: element as having the <code title="rel-contact">contact</code> link
4466: type specified.</p>
4467:
4468: </div>
4469:
4470: <p>For <code>link</code> elements, the <code
4471: title="rel-contact">contact</code> keyword indicates that the
4472: referenced document provides further contact information for the
4473: page as a whole.</p>
1.886 mike 4474: --><h5 id="link-type-external"><span class="secno">4.12.3.5 </span>Link type "<dfn title="rel-external"><code>external</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-external"><a href="#link-type-external">external</a></code> keyword may be
1.748 mike 4475: used with <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</p><p>The <code title="rel-external"><a href="#link-type-external">external</a></code> keyword indicates
4476: that the link is leading to a document that is not part of the site
1.886 mike 4477: that the current document forms a part of.</p><h5 id="link-type-help"><span class="secno">4.12.3.6 </span>Link type "<dfn title="rel-help"><code>help</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-help"><a href="#link-type-help">help</a></code> keyword may be used with
1.748 mike 4478: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4479: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>For <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements, the <code title="rel-help"><a href="#link-type-help">help</a></code> keyword indicates that the referenced
4480: document provides further help information for the parent of the
4481: element defining the hyperlink, and its children.</p><div class="example">
4482:
4483: <p>In the following example, the form control has associated
4484: context-sensitive help. The user agent could use this information,
4485: for example, displaying the referenced document if the user presses
4486: the "Help" or "F1" key.</p>
4487:
4488: <pre> <p><label> Topic: <input name=topic> <a href="help/topic.html" rel="help">(Help)</a></label></p></pre>
4489:
4490: </div><p>For <code><a href="semantics.html#the-link-element">link</a></code> elements, the <code title="rel-help"><a href="#link-type-help">help</a></code> keyword indicates that the referenced
1.886 mike 4491: document provides help for the page as a whole.</p><h5 id="rel-icon"><span class="secno">4.12.3.7 </span>Link type "<dfn title="rel-icon"><code>icon</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-icon"><a href="#rel-icon">icon</a></code> keyword may be used with
1.748 mike 4492: <code><a href="semantics.html#the-link-element">link</a></code> elements, for which it creates an <a href="semantics.html#external-resource-link" title="external resource link">external resource link</a>.</p><div class="impl">
4493:
4494: <p>The specified resource is an icon representing the page or site,
4495: and should be used by the user agent when representing the page in
4496: the user interface.</p>
4497:
4498: </div><p>Icons could be auditory icons, visual icons, or other kinds of
4499: icons. <span class="impl">If multiple icons are provided, the user
4500: agent must select the most appropriate icon according to the <code title="attr-link-type"><a href="semantics.html#attr-link-type">type</a></code>, <code title="attr-link-media"><a href="semantics.html#attr-link-media">media</a></code>, and <code title="attr-link-sizes"><a href="#attr-link-sizes">sizes</a></code> attributes. If there are
4501: multiple equally appropriate icons, user agents must use the last
4502: one declared in <a href="infrastructure.html#tree-order">tree order</a>. If the user agent tries to
4503: use an icon but that icon is determined, upon closer examination, to
4504: in fact be inappropriate (e.g. because it uses an unsupported
4505: format), then the user agent must try the next-most-appropriate icon
4506: as determined by the attributes.</span></p><div class="impl">
4507:
4508: <p>There is no default type for resources given by the <code title="rel-icon"><a href="#rel-icon">icon</a></code> keyword. However, for the purposes of
4509: <a href="semantics.html#concept-link-type-sniffing">determining the type of the
4510: resource</a>, user agents must expect the resource to be an image.</p>
4511:
4512: </div><p>The <dfn id="attr-link-sizes" title="attr-link-sizes"><code>sizes</code></dfn>
4513: attribute gives the sizes of icons for visual media.</p><p>If specified, the attribute must have a value that is an
4514: <a href="infrastructure.html#unordered-set-of-unique-space-separated-tokens">unordered set of unique space-separated tokens</a>. The
4515: values must all be either <code title="attr-link-sizes-any"><a href="#attr-link-sizes-any">any</a></code> or a value that consists of
4516: two <a href="infrastructure.html#valid-non-negative-integer" title="valid non-negative integer">valid non-negative
4517: integers</a> that do not have a leading U+0030 DIGIT ZERO (0)
4518: character and that are separated by a single U+0078 LATIN SMALL
4519: LETTER X character (x).</p><p>The keywords represent icon sizes.</p><div class="impl">
4520:
4521: <p>To parse and process the attribute's value, the user agent must
4522: first <a href="infrastructure.html#split-a-string-on-spaces" title="split a string on spaces">split the attribute's
4523: value on spaces</a>, and must then parse each resulting keyword
4524: to determine what it represents.</p>
4525:
4526: </div><p>The <dfn id="attr-link-sizes-any" title="attr-link-sizes-any"><code>any</code></dfn> keyword
4527: represents that the resource contains a scalable icon, e.g. as
4528: provided by an SVG image.</p><div class="impl">
4529:
4530: <p>Other keywords must be further parsed as follows to determine
4531: what they represent:</p>
4532:
4533: <ul><li><p>If the keyword doesn't contain exactly one U+0078 LATIN
4534: SMALL LETTER X character (x), then this keyword doesn't represent
4535: anything. Abort these steps for that keyword.</p></li>
4536:
4537: <li><p>Let <var title="">width string</var> be the string before
4538: the "<code title="">x</code>".</p></li>
4539:
4540: <li><p>Let <var title="">height string</var> be the string after the
4541: "<code title="">x</code>".</p></li>
4542:
4543: <li><p>If either <var title="">width string</var> or <var title="">height string</var> start with a U+0030 DIGIT ZERO (0)
4544: character or contain any characters other than characters in the
4545: range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9), then this
4546: keyword doesn't represent anything. Abort these steps for that
4547: keyword.</p></li>
4548:
4549: <li><p>Apply the <a href="infrastructure.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative
4550: integers</a> to <var title="">width string</var> to obtain <var title="">width</var>.</p></li>
4551:
4552: <li><p>Apply the <a href="infrastructure.html#rules-for-parsing-non-negative-integers">rules for parsing non-negative
4553: integers</a> to <var title="">height string</var> to obtain <var title="">height</var>.</p></li>
4554:
4555: <li><p>The keyword represents that the resource contains a bitmap
4556: icon with a width of <var title="">width</var> device pixels and a
4557: height of <var title="">height</var> device pixels.</p></li>
4558:
4559: </ul></div><p>The keywords specified on the <code title="attr-link-sizes"><a href="#attr-link-sizes">sizes</a></code> attribute must not represent
4560: icon sizes that are not actually available in the linked
4561: resource.</p><div class="impl">
4562:
4563: <p>If the attribute is not specified, then the user agent must
4564: assume that the given icon is appropriate, but less appropriate than
4565: an icon of a known and appropriate size.</p>
4566:
4567: </div><div class="example">
4568:
4569: <p>The following snippet shows the top part of an application with
4570: several icons.</p>
4571:
4572: <pre><!DOCTYPE HTML>
4573: <html>
4574: <head>
4575: <title>lsForums — Inbox</title>
4576: <link rel=icon href=favicon.png sizes="16x16" type="image/png">
4577: <link rel=icon href=windows.ico sizes="32x32 48x48" type="image/vnd.microsoft.icon">
4578: <link rel=icon href=mac.icns sizes="128x128 512x512 8192x8192 32768x32768">
4579: <link rel=icon href=iphone.png sizes="59x60" type="image/png">
4580: <link rel=icon href=gnome.svg sizes="any" type="image/svg+xml">
4581: <link rel=stylesheet href=lsforums.css>
4582: <script src=lsforums.js></script>
4583: <meta name=application-name content="lsForums">
4584: </head>
4585: <body>
4586: ...</pre>
4587:
1.886 mike 4588: </div><h5 id="link-type-license"><span class="secno">4.12.3.8 </span>Link type "<dfn title="rel-license"><code>license</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-license"><a href="#link-type-license">license</a></code> keyword may be used
1.748 mike 4589: with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4590: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-license"><a href="#link-type-license">license</a></code> keyword indicates
4591: that the referenced document provides the copyright license terms
4592: under which the main content of the current document is
4593: provided.</p><p>This specification does not specify how to distinguish between
4594: the main content of a document and content that is not deemed to be
4595: part of that main content. The distinction should be made clear to
4596: the user.</p><div class="example">
4597:
4598: <p>Consider a photo sharing site. A page on that site might
4599: describe and show a photograph, and the page might be marked up as
4600: follows:</p>
4601:
4602: <pre><!DOCTYPE HTML>
4603: <html>
4604: <head>
4605: <title>Exampl Pictures: Kissat</title>
4606: <link rel="stylesheet" href="/style/default">
4607: </head>
4608: <body>
4609: <h1>Kissat</h1>
4610: <nav>
4611: <a href="../">Return to photo index</a>
4612: </nav>
4613: <figure>
4614: <img src="/pix/39627052_fd8dcd98b5.jpg">
4615: <figcaption>Kissat</figcaption>
4616: </figure>
4617: <p>One of them has six toes!</p>
4618: <p><small><a rel="license" href="http://www.opensource.org/licenses/mit-license.php">MIT Licensed</a></small></p>
4619: <footer>
4620: <a href="/">Home</a> | <a href="../">Photo index</a>
4621: <p><small>© copyright 2009 Exampl Pictures. All Rights Reserved.</small></p>
4622: </footer>
4623: </body>
4624: </html></pre>
4625:
4626: <p>In this case the <code title="rel-license"><a href="#link-type-license">license</a></code>
4627: applies to just the photo (the main content of the document), not
4628: the whole document. In particular not the design of the page
4629: itself, which is covered by the copyright given at the bottom of
4630: the document. This could be made clearer in the styling
4631: (e.g. making the license link prominently positioned near the
4632: photograph, while having the page copyright in light small text at
4633: the foot of the page.</p>
4634:
4635: </div><div class="impl">
4636:
4637: <p><strong>Synonyms</strong>: For historical reasons, user agents
4638: must also treat the keyword "<code title="">copyright</code>" like
4639: the <code title="rel-license"><a href="#link-type-license">license</a></code> keyword.</p>
4640:
1.886 mike 4641: </div><h5 id="link-type-nofollow"><span class="secno">4.12.3.9 </span>Link type "<dfn title="rel-nofollow"><code>nofollow</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-nofollow"><a href="#link-type-nofollow">nofollow</a></code> keyword may be
1.748 mike 4642: used with <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</p><p>The <code title="rel-nofollow"><a href="#link-type-nofollow">nofollow</a></code> keyword indicates
4643: that the link is not endorsed by the original author or publisher of
4644: the page, or that the link to the referenced document was included
4645: primarily because of a commercial relationship between people
1.886 mike 4646: affiliated with the two pages.</p><h5 id="link-type-noreferrer"><span class="secno">4.12.3.10 </span>Link type "<dfn title="rel-noreferrer"><code>noreferrer</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> keyword may be
1.748 mike 4647: used with <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</p><p>It indicates that no referrer information is to be leaked when
4648: following the link.</p><div class="impl">
4649:
4650: <p>If a user agent follows a link defined by an <code><a href="text-level-semantics.html#the-a-element">a</a></code> or
4651: <code><a href="the-canvas-element.html#the-area-element">area</a></code> element that has the <code title="rel-noreferrer"><a href="#link-type-noreferrer">noreferrer</a></code> keyword, the user agent
4652: must not include a <code title="http-referer">Referer</code> (sic)
4653: HTTP header (<a href="infrastructure.html#concept-http-equivalent-headers" title="concept-http-equivalent-headers">or
4654: equivalent</a> for other protocols) in the request.</p>
4655:
4656: <p>This keyword also <a href="browsers.html#noopener">causes the <code title="dom-opener">opener</code> attribute to remain null</a> if the
4657: hyperlink creates a new <a href="browsers.html#browsing-context">browsing context</a>.</p>
4658:
4659: </div><!-- v2: Would be nice to apply this to other elements too,
1.886 mike 4660: e.g. letting <img> or CSS or <video> hide the referrer --><h5 id="link-type-pingback"><span class="secno">4.12.3.11 </span>Link type "<dfn title="rel-pingback"><code>pingback</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-pingback"><a href="#link-type-pingback">pingback</a></code> keyword may be
1.748 mike 4661: used with <code><a href="semantics.html#the-link-element">link</a></code> elements, for which it creates an <a href="semantics.html#external-resource-link" title="external resource link">external resource link</a>.</p><p>For the semantics of the <code title="rel-pingback"><a href="#link-type-pingback">pingback</a></code> keyword, see the Pingback 1.0
1.886 mike 4662: specification. <a href="references.html#refsPINGBACK">[PINGBACK]</a></p><h5 id="link-type-prefetch"><span class="secno">4.12.3.12 </span>Link type "<dfn title="rel-prefetch"><code>prefetch</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-prefetch"><a href="#link-type-prefetch">prefetch</a></code> keyword may be
1.748 mike 4663: used with <code><a href="semantics.html#the-link-element">link</a></code> elements, for which it creates an <a href="semantics.html#external-resource-link" title="external resource link">external resource link</a>.</p><p>The <code title="rel-prefetch"><a href="#link-type-prefetch">prefetch</a></code> keyword indicates
4664: that preemptively fetching and caching the specified resource is
4665: likely to be beneficial, as it is highly likely that the user will
1.886 mike 4666: require this resource.</p><p>There is no default type for resources given by the <code title="rel-prefetch"><a href="#link-type-prefetch">prefetch</a></code> keyword.</p><h5 id="link-type-search"><span class="secno">4.12.3.13 </span>Link type "<dfn title="rel-search"><code>search</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-search"><a href="#link-type-search">search</a></code> keyword may be used
1.748 mike 4667: with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4668: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-search"><a href="#link-type-search">search</a></code> keyword indicates that
4669: the referenced document provides an interface specifically for
4670: searching the document and its related resources.</p><p class="note">OpenSearch description documents can be used with
4671: <code><a href="semantics.html#the-link-element">link</a></code> elements and the <code title="rel-search"><a href="#link-type-search">search</a></code> link type to enable user agents to
1.886 mike 4672: autodiscover search interfaces. <a href="references.html#refsOPENSEARCH">[OPENSEARCH]</a></p><h5 id="link-type-stylesheet"><span class="secno">4.12.3.14 </span>Link type "<dfn title="rel-stylesheet"><code>stylesheet</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code> keyword may be
1.748 mike 4673: used with <code><a href="semantics.html#the-link-element">link</a></code> elements, for which it creates an <a href="semantics.html#external-resource-link" title="external resource link">external resource link</a> that
4674: contributes to the <a href="semantics.html#styling">styling processing model</a>.</p><p>The specified resource is a resource that describes how to
4675: present the document. Exactly how the resource is to be processed
4676: depends on the actual type of the resource.</p><p>If the <code title="rel-alternate"><a href="#link-type-alternate">alternate</a></code> keyword is
4677: also specified on the <code><a href="semantics.html#the-link-element">link</a></code> element, then <dfn id="the-link-is-an-alternative-stylesheet">the link
4678: is an alternative stylesheet</dfn>; in this case, the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute must be specified on the
4679: <code><a href="semantics.html#the-link-element">link</a></code> element, with a non-empty value.</p><p>The default type for resources given by the <code title="rel-stylesheet"><a href="#link-type-stylesheet">stylesheet</a></code> keyword is <code title="">text/css</code>.</p><div class="impl">
4680:
4681: <p><strong>Quirk</strong>: If the document has been set to
4682: <a href="dom.html#quirks-mode">quirks mode</a> and the <a href="infrastructure.html#content-type" title="Content-Type">Content-Type metadata</a> of the external
4683: resource is not a supported style sheet type, the user agent must
4684: instead assume it to be <code title="">text/css</code>.</p>
4685:
1.886 mike 4686: </div><h5 id="link-type-sidebar"><span class="secno">4.12.3.15 </span>Link type "<dfn title="rel-sidebar"><code>sidebar</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-sidebar"><a href="#link-type-sidebar">sidebar</a></code> keyword may be used
1.748 mike 4687: with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4688: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-sidebar"><a href="#link-type-sidebar">sidebar</a></code> keyword indicates
4689: that the referenced document, if retrieved, is intended to be shown
4690: in a <a href="browsers.html#secondary-browsing-context">secondary browsing context</a> (if possible), instead
1.886 mike 4691: of in the current <a href="browsers.html#browsing-context">browsing context</a>.</p><p>A <a href="#hyperlink" title="hyperlink">hyperlink element</a> with the <code title="rel-sidebar"><a href="#link-type-sidebar">sidebar</a></code> keyword specified is a <dfn id="rel-sidebar-hyperlink" title="rel-sidebar-hyperlink">sidebar hyperlink</dfn>.</p><h5 id="link-type-tag"><span class="secno">4.12.3.16 </span>Link type "<dfn title="rel-tag"><code>tag</code></dfn>"</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-tag"><a href="#link-type-tag">tag</a></code> keyword may be used
1.748 mike 4692: with <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4693: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-tag"><a href="#link-type-tag">tag</a></code> keyword indicates that the
4694: <em>tag</em> that the referenced document represents applies to the
4695: current document.</p><p class="note">Since it indicates that the tag <em>applies to the
4696: current document</em>, it would be inappropriate to use this keyword
4697: in the markup of a <a href="#tag-cloud">tag cloud</a>, which lists
1.886 mike 4698: the popular tag across a set of pages.</p><h5 id="hierarchical-link-types"><span class="secno">4.12.3.17 </span>Hierarchical link types</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>Some documents form part of a hierarchical structure of
1.748 mike 4699: documents.</p><p>A hierarchical structure of documents is one where each document
4700: can have various subdocuments. The document of which a document is a
4701: subdocument is said to be the document's <em>parent</em>. A document
1.886 mike 4702: with no parent forms the top of the hierarchy.</p><p>A document may be part of multiple hierarchies.</p><h6 id="link-type-index"><span class="secno">4.12.3.17.1 </span>Link type "<dfn title="rel-index"><code>index</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-index"><a href="#link-type-index">index</a></code> keyword may be used with
1.748 mike 4703: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4704: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-index"><a href="#link-type-index">index</a></code> keyword indicates that
4705: the document is part of a hierarchical structure, and that the link
4706: is leading to the document that is the top of the hierarchy. It
4707: conveys more information when used with the <code title="rel-up"><a href="#link-type-up">up</a></code> keyword (q.v.).</p><div class="impl">
4708:
4709: <p><strong>Synonyms</strong>: For historical reasons, user agents
4710: must also treat the keywords "<code title="">top</code>", "<code title="">contents</code>", and "<code title="">toc</code>" like the
4711: <code title="rel-index"><a href="#link-type-index">index</a></code> keyword.</p>
4712:
1.886 mike 4713: </div><h6 id="link-type-up"><span class="secno">4.12.3.17.2 </span>Link type "<dfn title="rel-up"><code>up</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-up"><a href="#link-type-up">up</a></code> keyword may be used with
1.748 mike 4714: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4715: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-up"><a href="#link-type-up">up</a></code> keyword indicates that the
4716: document is part of a hierarchical structure, and that the link is
4717: leading to a document that is an ancestor of the current
4718: document.</p><p>The <code title="rel-up"><a href="#link-type-up">up</a></code> keyword may be repeated within
4719: a <code title="attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code> attribute to indicate
4720: the hierarchical distance from the current document to the
4721: referenced document. If it occurs only once, then the link is
4722: leading to the current document's parent; each additional occurrence
4723: of the keyword represents one further level. If the <code title="rel-index"><a href="#link-type-index">index</a></code> keyword is also present, then the
4724: number of <code title="rel-up"><a href="#link-type-up">up</a></code> keywords is the depth of
4725: the current page relative to the top of the hierarchy. Only one link
4726: is created for the set of one or more <code title="rel-up"><a href="#link-type-up">up</a></code>
4727: keywords and, if present, the <code title="rel-index"><a href="#link-type-index">index</a></code>
4728: keyword.</p><p>If the page is part of multiple hierarchies, then they should be
4729: described in different <a href="embedded-content-0.html#paragraph" title="paragraph">paragraphs</a>. <span class="impl">User agents
4730: must scope any interpretation of the <code title="rel-up"><a href="#link-type-up">up</a></code>
4731: and <code title="rel-index"><a href="#link-type-index">index</a></code> keywords together
4732: indicating the depth of the hierarchy to the <a href="embedded-content-0.html#paragraph">paragraph</a>
4733: in which the link finds itself, if any, or to the document
4734: otherwise.</span></p><div class="impl">
4735:
4736: <p>When two links have both the <code title="rel-up"><a href="#link-type-up">up</a></code> and
4737: <code title="rel-index"><a href="#link-type-index">index</a></code> keywords specified together in
4738: the same scope and contradict each other by having a different
4739: number of <code title="rel-up"><a href="#link-type-up">up</a></code> keywords, the link with the
4740: greater number of <code title="rel-up"><a href="#link-type-up">up</a></code> keywords must be
4741: taken as giving the depth of the document.</p>
4742:
4743: </div><div class="example">
4744:
4745: <p>This can be used to mark up a navigation style sometimes known
4746: as bread crumbs. In the following example, the current page can be
4747: reached via two paths.</p>
4748:
4749: <pre><nav>
4750: <p>
4751: <a href="/" rel="index up up up">Main</a> >
4752: <a href="/products/" rel="up up">Products</a> >
4753: <a href="/products/dishwashers/" rel="up">Dishwashers</a> >
4754: <a>Second hand</a>
4755: </p>
4756: <p>
4757: <a href="/" rel="index up up">Main</a> >
4758: <a href="/second-hand/" rel="up">Second hand</a> >
4759: <a>Dishwashers</a>
4760: </p>
4761: </nav></pre>
4762:
4763: </div><p class="note">The <code title="dom-a-relList"><a href="text-level-semantics.html#dom-a-rellist">relList</a></code> IDL
4764: attribute (e.g. on the <code><a href="text-level-semantics.html#the-a-element">a</a></code> element) does not currently
4765: represent multiple <code title="rel-up"><a href="#link-type-up">up</a></code> keywords (the
1.886 mike 4766: interface hides duplicates).</p><h5 id="sequential-link-types"><span class="secno">4.12.3.18 </span>Sequential link types</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>Some documents form part of a sequence of documents.</p><p>A sequence of documents is one where each document can have a
1.748 mike 4767: <em>previous sibling</em> and a <em>next sibling</em>. A document
4768: with no previous sibling is the start of its sequence, a document
1.886 mike 4769: with no next sibling is the end of its sequence.</p><p>A document may be part of multiple sequences.</p><h6 id="link-type-first"><span class="secno">4.12.3.18.1 </span>Link type "<dfn title="rel-first"><code>first</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-first"><a href="#link-type-first">first</a></code> keyword may be used with
1.748 mike 4770: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4771: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-first"><a href="#link-type-first">first</a></code> keyword indicates that
4772: the document is part of a sequence, and that the link is leading to
4773: the document that is the first logical document in the sequence.</p><div class="impl">
4774:
4775: <p><strong>Synonyms</strong>: For historical reasons, user agents
4776: must also treat the keywords "<code title="">begin</code>" and
4777: "<code title="">start</code>" like the <code title="rel-first"><a href="#link-type-first">first</a></code> keyword.</p>
4778:
1.886 mike 4779: </div><h6 id="link-type-last"><span class="secno">4.12.3.18.2 </span>Link type "<dfn title="rel-last"><code>last</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-last"><a href="#link-type-last">last</a></code> keyword may be used with
1.748 mike 4780: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4781: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-last"><a href="#link-type-last">last</a></code> keyword indicates that the
4782: document is part of a sequence, and that the link is leading to the
4783: document that is the last logical document in the sequence.</p><div class="impl">
4784:
4785: <p><strong>Synonyms</strong>: For historical reasons, user agents
4786: must also treat the keyword "<code title="">end</code>" like the
4787: <code title="rel-last"><a href="#link-type-last">last</a></code> keyword.</p>
4788:
1.886 mike 4789: </div><h6 id="link-type-next"><span class="secno">4.12.3.18.3 </span>Link type "<dfn title="rel-next"><code>next</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-next"><a href="#link-type-next">next</a></code> keyword may be used with
1.748 mike 4790: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4791: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-next"><a href="#link-type-next">next</a></code> keyword indicates that the
4792: document is part of a sequence, and that the link is leading to the
1.886 mike 4793: document that is the next logical document in the sequence.</p><h6 id="link-type-prev"><span class="secno">4.12.3.18.4 </span>Link type "<dfn title="rel-prev"><code>prev</code></dfn>"</h6><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>The <code title="rel-prev"><a href="#link-type-prev">prev</a></code> keyword may be used with
1.748 mike 4794: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code>
4795: elements. For <code><a href="semantics.html#the-link-element">link</a></code> elements, it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink</a>.</p><p>The <code title="rel-prev"><a href="#link-type-prev">prev</a></code> keyword indicates that the
4796: document is part of a sequence, and that the link is leading to the
4797: document that is the previous logical document in the sequence.</p><div class="impl">
4798:
4799: <p><strong>Synonyms</strong>: For historical reasons, user agents
4800: must also treat the keyword "<code title="">previous</code>" like
4801: the <code title="rel-prev"><a href="#link-type-prev">prev</a></code> keyword.</p>
4802:
1.886 mike 4803: </div><h5 id="other-link-types"><span class="secno">4.12.3.19 </span>Other link types</h5><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p><dfn id="concept-rel-extensions" title="concept-rel-extensions">Extensions to the predefined
1.748 mike 4804: set of link types</dfn> may be registered in the <a href="http://wiki.whatwg.org/wiki/RelExtensions">WHATWG Wiki
4805: RelExtensions page</a>. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a></p><p>Anyone is free to edit the WHATWG Wiki RelExtensions page at any
4806: time to add a type. Extension types must be specified with the
4807: following information:</p><dl><dt>Keyword</dt>
4808:
4809: <dd>
4810:
4811: <p>The actual value being defined. The value should not be
4812: confusingly similar to any other defined value (e.g. differing
4813: only in case).</p>
4814:
4815: <p>If the value contains a U+003A COLON character (:), it must
4816: also be an <a href="infrastructure.html#absolute-url">absolute URL</a>.</p>
4817:
4818: </dd>
4819:
4820:
4821: <dt>Effect on... <code><a href="semantics.html#the-link-element">link</a></code></dt>
4822:
4823: <dd>
4824:
4825: <p>One of the following:</p>
4826:
4827: <dl><dt>not allowed</dt>
4828:
4829: <dd>The keyword is not allowed to be specified on
4830: <code><a href="semantics.html#the-link-element">link</a></code> elements.</dd>
4831:
4832: <dt>Hyperlink</dt>
4833:
4834: <dd>The keyword may be specified on a <code><a href="semantics.html#the-link-element">link</a></code> element;
4835: it creates a <a href="semantics.html#hyperlink-link" title="hyperlink link">hyperlink
4836: link</a>.</dd>
4837:
4838: <dt>External Resource</dt>
4839:
4840: <dd>The keyword may be specified on a <code><a href="semantics.html#the-link-element">link</a></code> element;
4841: it creates a <a href="semantics.html#external-resource-link" title="external resource link">external
4842: resource link</a>.</dd>
4843:
4844: </dl></dd>
4845:
4846:
4847: <dt>Effect on... <code><a href="text-level-semantics.html#the-a-element">a</a></code> and <code><a href="the-canvas-element.html#the-area-element">area</a></code></dt>
4848:
4849: <dd>
4850:
4851: <p>One of the following:</p>
4852:
4853: <dl><dt>not allowed</dt>
4854:
4855: <dd>The keyword is not allowed to be specified on <code><a href="text-level-semantics.html#the-a-element">a</a></code>
4856: and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</dd>
4857:
4858: <dt>Hyperlink</dt>
4859:
4860: <dd>The keyword may be specified on <code><a href="text-level-semantics.html#the-a-element">a</a></code> and
4861: <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements.</dd>
4862:
4863: </dl></dd>
4864:
4865:
4866: <dt>Brief description</dt>
4867:
4868: <dd><p>A short non-normative description of what the keyword's
4869: meaning is.</p></dd>
4870:
4871:
4872: <dt>Specification</dt>
4873:
4874: <dd><p>A link to a more detailed description of the keyword's
4875: semantics and requirements. It could be another page on the Wiki,
4876: or a link to an external page.</p></dd>
4877:
4878:
4879: <dt>Synonyms</dt>
4880:
4881: <dd><p>A list of other keyword values that have exactly the same
4882: processing requirements. Authors should not use the values defined
4883: to be synonyms, they are only intended to allow user agents to
4884: support legacy content. Anyone may remove synonyms that are not
4885: used in practice; only names that need to be processed as synonyms
4886: for compatibility with legacy content are to be registered in this
4887: way.</p></dd>
4888:
4889:
4890: <dt>Status</dt>
4891:
4892: <dd>
4893:
4894: <p>One of the following:</p>
4895:
4896: <dl><dt>Proposed</dt>
4897:
4898: <dd>The keyword has not received wide peer review and
4899: approval. Someone has proposed it and is, or soon will be, using
4900: it.</dd>
4901:
4902: <dt>Ratified</dt>
4903:
4904: <dd>The keyword has received wide peer review and approval. It
4905: has a specification that unambiguously defines how to handle
4906: pages that use the keyword, including when they use it in
4907: incorrect ways.</dd>
4908:
4909: <dt>Discontinued</dt>
4910:
4911: <dd>The keyword has received wide peer review and it has been
4912: found wanting. Existing pages are using this keyword, but new
4913: pages should avoid it. The "brief description" and
4914: "specification" entries will give details of what authors should
4915: use instead, if anything.</dd>
4916:
4917: </dl><p>If a keyword is found to be redundant with existing values, it
4918: should be removed and listed as a synonym for the existing
4919: value.</p>
4920:
4921: <p>If a keyword is registered in the "proposed" state for a
4922: period of a month or more without being used or specified, then it
4923: may be removed from the registry.</p>
4924:
4925: <p>If a keyword is added with the "proposed" status and found to
4926: be redundant with existing values, it should be removed and listed
4927: as a synonym for the existing value. If a keyword is added with
4928: the "proposed" status and found to be harmful, then it should be
4929: changed to "discontinued" status.</p>
4930:
4931: <p>Anyone can change the status at any time, but should only do so
4932: in accordance with the definitions above.</p>
4933:
4934: </dd>
4935:
4936: </dl><div class="impl">
4937:
4938: <p>Conformance checkers must use the information given on the WHATWG
4939: Wiki RelExtensions page to establish if a value is allowed or not:
4940: values defined in this specification or marked as "proposed" or
4941: "ratified" must be accepted when used on the elements for which they
4942: apply as described in the "Effect on..." field, whereas values
4943: marked as "discontinued" or not listed in either this specification
4944: or on the aforementioned page must be rejected as invalid.
4945: Conformance checkers may cache this information (e.g. for
4946: performance reasons or to avoid the use of unreliable network
4947: connectivity).</p>
4948:
4949: <p>When an author uses a new type not defined by either this
4950: specification or the Wiki page, conformance checkers should offer to
4951: add the value to the Wiki, with the details described above, with
4952: the "proposed" status.</p>
4953:
4954: </div><p>Types defined as extensions in the <a href="http://wiki.whatwg.org/wiki/RelExtensions">WHATWG Wiki
4955: RelExtensions page</a> with the status "proposed" or "ratified" may
4956: be used with the <code title="">rel</code> attribute on
4957: <code><a href="semantics.html#the-link-element">link</a></code>, <code><a href="text-level-semantics.html#the-a-element">a</a></code>, and <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements in
1.886 mike 4958: accordance to the "Effect on..." field. <a href="references.html#refsWHATWGWIKI">[WHATWGWIKI]</a></p><h3 id="common-idioms-without-dedicated-elements"><span class="secno">4.13 </span>Common idioms without dedicated elements</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments. </i><span><a href="http://www.w3.org/html/wg/tracker/issues/89">ISSUE-89</a> (idioms) blocks progress to Last Call</span></p><h4 id="tag-clouds"><span class="secno">4.13.1 </span>Tag clouds</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p id="tag-cloud">This specification does not define any markup
1.299 mike 4959: specifically for marking up lists of keywords that apply to a group
4960: of pages (also known as <i>tag clouds</i>). In general, authors are
4961: encouraged to either mark up such lists using <code><a href="semantics.html#the-ul-element">ul</a></code>
4962: elements with explicit inline counts that are then hidden and turned
4963: into a presentational effect using a style sheet, or to use SVG.</p><div class="example">
4964:
4965: <p>Here, three tags are included in a short tag cloud:</p>
4966:
4967: <pre><style>
4968: @media screen, print, handheld, tv {
4969: /* should be ignored by non-visual browsers */
4970: .tag-cloud > li > span { display: none; }
4971: .tag-cloud > li { display: inline; }
4972: .tag-cloud-1 { font-size: 0.7em; }
4973: .tag-cloud-2 { font-size: 0.9em; }
4974: .tag-cloud-3 { font-size: 1.1em; }
4975: .tag-cloud-4 { font-size: 1.3em; }
4976: .tag-cloud-5 { font-size: 1.5em; }
4977: }
4978: </style>
4979: ...
4980: <ul class="tag-cloud">
4981: <li class="tag-cloud-4"><a title="28 instances" href="/t/apple">apple</a> <span>(popular)</span>
4982: <li class="tag-cloud-2"><a title="6 instances" href="/t/kiwi">kiwi</a> <span>(rare)</span>
4983: <li class="tag-cloud-5"><a title="41 instances" href="/t/pear">pear</a> <span>(very popular)</span>
4984: </ul></pre>
4985:
4986: <p>The actual frequency of each tag is given using the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute. A CSS style sheet is
4987: provided to convert the markup into a cloud of differently-sized
4988: words, but for user agents that do not support CSS or are not
4989: visual, the markup contains annotations like "(popular)" or
4990: "(rare)" to categorize the various tags by frequency, thus enabling
4991: all users to benefit from the information.</p>
4992:
4993: <p>The <code><a href="semantics.html#the-ul-element">ul</a></code> element is used (rather than
1.749 mike 4994: <code><a href="semantics.html#the-ol-element">ol</a></code>) because the order is not particularly important:
1.299 mike 4995: while the list is in fact ordered alphabetically, it would convey
4996: the same information if ordered by, say, the length of the tag.</p>
4997:
1.748 mike 4998: <p>The <code title="rel-tag"><a href="#link-type-tag">tag</a></code> <code title="attr-hyperlink-rel"><a href="#attr-hyperlink-rel">rel</a></code>-keyword is <em>not</em> used
1.299 mike 4999: on these <code><a href="text-level-semantics.html#the-a-element">a</a></code> elements because they do not represent tags
5000: that apply to the page itself; they are just part of an index
5001: listing the tags themselves.</p>
5002:
1.886 mike 5003: </div><h4 id="conversations"><span class="secno">4.13.2 </span>Conversations</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><!-- http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-September/022576.html --><p>This specification does not define a specific element for marking
1.299 mike 5004: up conversations, meeting minutes, chat transcripts, dialogues in
5005: screenplays, instant message logs, and other situations where
5006: different players take turns in discourse.</p><p>Instead, authors are encouraged to mark up conversations using
1.303 mike 5007: <code><a href="semantics.html#the-p-element">p</a></code> elements and punctuation. Authors who need to mark
5008: the speaker for styling purposes are encouraged to use
5009: <code><a href="text-level-semantics.html#the-span-element">span</a></code> or <code><a href="text-level-semantics.html#the-b-element">b</a></code>. Paragraphs with their text
5010: wrapped in the <code><a href="text-level-semantics.html#the-i-element">i</a></code> element can be used for marking up
5011: stage directions.</p><div class="example">
1.299 mike 5012:
5013: <p>This example demonstrates this using an extract from Abbot and
5014: Costello's famous sketch, <cite>Who's on first</cite>:</p>
5015:
1.303 mike 5016: <pre><p> Costello: Look, you gotta first baseman?
5017: <p> Abbott: Certainly.
5018: <p> Costello: Who's playing first?
5019: <p> Abbott: That's right.
5020: <p> Costello becomes exasperated.
5021: <p> Costello: When you pay off the first baseman every month, who gets the money?
5022: <p> Abbott: Every dollar of it.</pre>
1.299 mike 5023:
5024: </div><div class="example">
5025:
5026: <p>The following extract shows how an IM conversation log could be
5027: marked up.</p>
5028:
5029: <pre><p> <time>14:22</time> <b>egof</b> I'm not that nerdy, I've only seen 30% of the star trek episodes
5030: <p> <time>14:23</time> <b>kaj</b> if you know what percentage of the star trek episodes you have seen, you are inarguably nerdy
5031: <p> <time>14:23</time> <b>egof</b> it's unarguably
1.303 mike 5032: <p> <time>14:23</time> <i>* kaj blinks</i>
1.299 mike 5033: <p> <time>14:24</time> <b>kaj</b> you are not helping your case</pre>
5034: <!-- with thanks to http://bash.org/?854262 -->
5035:
1.886 mike 5036: </div><h4 id="footnotes"><span class="secno">4.13.3 </span>Footnotes</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p><p>HTML does not have a dedicated mechanism for marking up
1.299 mike 5037: footnotes. Here are the recommended alternatives.</p><hr><p>For short inline annotations, the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute should be used.</p><div class="example">
5038:
1.419 mike 5039: <p>In this example, two parts of a dialogue are annotated with
5040: footnote-like content using the <code title="attr-title"><a href="dom.html#the-title-attribute">title</a></code> attribute.</p>
1.299 mike 5041:
5042: <pre><p> <b>Customer</b>: Hello! I wish to register a complaint. Hello. Miss?
1.419 mike 5043: <p> <b>Shopkeeper</b>: <strong><span title="Colloquial pronunciation of 'What do you'"</strong>
1.299 mike 5044: >Watcha</span> mean, miss?
5045: <p> <b>Customer</b>: Uh, I'm sorry, I have a cold. I wish to make a complaint.
1.419 mike 5046: <p> <b>Shopkeeper</b>: Sorry, <span <strong>title="This is, of course, a lie."</strong>>we're
1.299 mike 5047: closing for lunch</span>.</pre>
5048:
5049: </div><hr><p>For longer annotations, the <code><a href="text-level-semantics.html#the-a-element">a</a></code> element should be
5050: used, pointing to an element later in the document. The convention
5051: is that the contents of the link be a number in square brackets.</p><div class="example">
5052:
5053: <p>In this example, a footnote in the dialogue links to a paragraph
5054: below the dialogue. The paragraph then reciprocally links back to the
5055: dialogue, allowing the user to return to the location of the
5056: footnote.</p>
5057:
1.303 mike 5058: <pre><p> Announcer: Number 16: The <i>hand</i>.
5059: <p> Interviewer: Good evening. I have with me in the studio tonight
5060: Mr Norman St John Polevaulter, who for the past few years has been
5061: contradicting people. Mr Polevaulter, why <em>do</em> you
5062: contradict people?
5063: <p> Norman: I don't. <sup><a href="#fn1" id="r1">[1]</a></sup>
5064: <p> Interviewer: You told me you did!
1.299 mike 5065: <em>...</em>
5066: <section>
5067: <p id="fn1"><a href="#r1">[1]</a> This is, naturally, a lie,
5068: but paradoxically if it were true he could not say so without
5069: contradicting the interviewer and thus making it false.</p>
5070: </section></pre>
5071:
5072: </div><hr><p>For side notes, longer annotations that apply to entire sections
5073: of the text rather than just specific words or sentences, the
5074: <code><a href="semantics.html#the-aside-element">aside</a></code> element should be used.</p><div class="example">
5075:
5076: <p>In this example, a sidebar is given after a dialogue, giving it
5077: some context.</p>
5078:
1.303 mike 5079: <pre><p> <span class="speaker">Customer</span>: I will not buy this record, it is scratched.
5080: <p> <span class="speaker">Shopkeeper</span>: I'm sorry?
5081: <p> <span class="speaker">Customer</span>: I will not buy this record, it is scratched.
5082: <p> <span class="speaker">Shopkeeper</span>: No no no, this's'a tobacconist's.
1.299 mike 5083: <aside>
5084: <p>In 1970, the British Empire lay in ruins, and foreign
5085: nationalists frequented the streets — many of them Hungarians
5086: (not the streets — the foreign nationals). Sadly, Alexander
5087: Yalt has been publishing incompetently-written phrase books.
5088: </aside></pre>
5089:
5090: </div><hr><p>For figures or tables, footnotes can be included in the relevant
1.756 mike 5091: <code><a href="semantics.html#the-figcaption-element">figcaption</a></code> or <code><a href="tabular-data.html#the-caption-element">caption</a></code> element, or in
1.729 mike 5092: surrounding prose.</p><div class="example">
1.299 mike 5093:
5094: <p>In this example, a <!-- round --> table has cells with footnotes
1.756 mike 5095: that are given in prose. A <code><a href="semantics.html#the-figure-element">figure</a></code> element is used to
1.299 mike 5096: give a single legend to the combination of the table and its
5097: footnotes.</p>
5098:
5099: <pre><figure>
1.729 mike 5100: <figcaption>Table 1. Alternative activities for knights.</figcaption>
5101: <table>
5102: <tr>
5103: <th> Activity
5104: <th> Location
5105: <th> Cost
5106: <tr>
5107: <td> Dance
5108: <td> Wherever possible
5109: <td> £0<sup><a href="#fn1">1</a></sup>
5110: <tr>
5111: <td> Routines, chorus scenes<sup><a href="#fn2">2</a></sup>
5112: <td> Undisclosed
5113: <td> Undisclosed
5114: <tr>
5115: <td> Dining<sup><a href="#fn3">3</a></sup>
5116: <td> Camelot
5117: <td> Cost of ham, jam, and spam<sup><a href="#fn4">4</a></sup>
5118: </table>
5119: <p id="fn1">1. Assumed.</p>
5120: <p id="fn2">2. Footwork impeccable.</p>
5121: <p id="fn3">3. Quality described as "well".</p>
5122: <p id="fn4">4. A lot.</p>
1.299 mike 5123: </figure></pre>
5124:
1.117 mike 5125: </div><div class="impl">
1.1 mike 5126:
1.886 mike 5127: <h3 id="matching-html-elements-using-selectors"><span class="secno">4.14 </span>Matching HTML elements using selectors</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.1 mike 5128:
1.886 mike 5129: <h4 id="selectors"><span class="secno">4.14.1 </span>Case-sensitivity</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.718 mike 5130:
5131: <p>Attribute and element <em>names</em> of <a href="infrastructure.html#html-elements">HTML
5132: elements</a> in <a href="dom.html#html-documents">HTML documents</a> must be treated as
5133: <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a>.</p>
5134:
5135: <p>Classes from the <code title="attr-class"><a href="dom.html#classes">class</a></code> attribute
5136: of <a href="infrastructure.html#html-elements">HTML elements</a> in documents that are in <a href="dom.html#quirks-mode">quirks
5137: mode</a> must be treated as <a href="infrastructure.html#ascii-case-insensitive">ASCII
5138: case-insensitive</a>.</p>
5139:
5140: <p>Attribute selectors on an <a href="infrastructure.html#html-elements" title="HTML elements">HTML
5141: element</a> in an <a href="dom.html#html-documents" title="HTML documents">HTML
5142: document</a> must treat the <em>values</em> of attributes with
5143: the following names as <a href="infrastructure.html#ascii-case-insensitive">ASCII case-insensitive</a>:</p>
5144:
5145: <!-- based on Mozilla's list, which was itself based on HTML4 -->
5146: <!-- WebKit's was identical at the time of writing except as noted below -->
5147: <ul class="brief"><li><code title="">accept</code>
5148: </li><li><code title="">accept-charset</code>
5149: </li><li><code title="">align</code>
5150: </li><li><code title="">alink</code>
5151: </li><li><code title="">axis</code>
5152: </li><li><code title="">bgcolor</code>
5153: </li><li><code title="">charset</code>
5154: </li><li><code title="">checked</code>
5155: </li><li><code title="">clear</code>
5156: </li><li><code title="">codetype</code>
5157: </li><li><code title="">color</code>
5158: </li><li><code title="">compact</code>
5159: </li><li><code title="">declare</code>
5160: </li><li><code title="">defer</code>
5161: </li><li><code title="">dir</code>
5162: </li><li><code title="">direction</code> <!-- not in webkit -->
5163: </li><li><code title="">disabled</code>
5164: </li><li><code title="">enctype</code>
5165: </li><li><code title="">face</code>
5166: </li><li><code title="">frame</code>
5167: </li><li><code title="">hreflang</code>
5168: </li><li><code title="">http-equiv</code>
5169: </li><li><code title="">lang</code>
5170: </li><li><code title="">language</code>
5171: </li><li><code title="">link</code>
5172: </li><li><code title="">media</code>
5173: </li><li><code title="">method</code>
5174: </li><li><code title="">multiple</code>
5175: </li><li><code title="">nohref</code>
5176: </li><li><code title="">noresize</code>
5177: </li><li><code title="">noshade</code>
5178: </li><li><code title="">nowrap</code>
5179: </li><li><code title="">readonly</code>
5180: </li><li><code title="">rel</code>
5181: </li><li><code title="">rev</code>
5182: </li><li><code title="">rules</code>
5183: </li><li><code title="">scope</code>
5184: </li><li><code title="">scrolling</code>
5185: </li><li><code title="">selected</code>
5186: </li><li><code title="">shape</code>
5187: </li><li><code title="">target</code>
5188: </li><li><code title="">text</code>
5189: </li><li><code title="">type</code>
5190: </li><li><code title="">valign</code>
5191: </li><li><code title="">valuetype</code>
5192: </li><li><code title="">vlink</code>
5193: </li></ul><p>All other attribute values on <a href="infrastructure.html#html-elements">HTML elements</a> must be
5194: treated as <a href="infrastructure.html#case-sensitive">case-sensitive</a>.</p>
5195:
5196:
1.748 mike 5197: <h4 id="pseudo-classes"><span class="secno">4.14.2 </span>Pseudo-classes</h4>
1.718 mike 5198:
1.1 mike 5199: <p>There are a number of dynamic selectors that can be used with
5200: HTML. This section defines when these selectors match HTML
5201: elements.</p>
5202:
5203: <dl><dt><dfn id="selector-link" title="selector-link"><code>:link</code></dfn></dt>
5204: <dt><dfn id="selector-visited" title="selector-visited"><code>:visited</code></dfn></dt>
5205:
5206: <dd>
5207:
1.748 mike 5208: <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="#attr-hyperlink-href">href</a></code> attribute, all
5209: <code><a href="the-canvas-element.html#the-area-element">area</a></code> elements that have an <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute, and all
1.1 mike 5210: <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
5211: <code title="selector-link"><a href="#selector-link">:link</a></code> and <code title="selector-visited"><a href="#selector-visited">:visited</a></code>.</p>
5212:
5213: </dd>
5214:
5215:
5216: <dt><dfn id="selector-active" title="selector-active"><code>:active</code></dfn></dt>
5217:
5218: <dd>
5219:
5220: <p>The <code title="selector-active"><a href="#selector-active">:active</a></code> pseudo-class
5221: must match the following elements between the time the user begins
1.95 mike 5222: to activate the element and the time the user stops activating
1.1 mike 5223: the element:</p>
5224:
1.748 mike 5225: <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="#attr-hyperlink-href">href</a></code> attribute</li>
1.1 mike 5226:
1.748 mike 5227: <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="#attr-hyperlink-href">href</a></code> attribute</li>
1.1 mike 5228:
5229: <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>
5230:
5231: <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>
5232:
5233: <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>
5234:
5235: <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>
5236:
5237: <li>any other element, if it is <a href="editing.html#specially-focusable">specially
5238: focusable</a></li>
5239:
5240: </ul><p class="example">For example, if the user is using a keyboard to
5241: push a <code><a href="forms.html#the-button-element">button</a></code> element by pressing the space bar, the
5242: element would match this pseudo-class in between the time that the
5243: element received the <code title="event-keydown">keydown</code>
5244: event and the time the element received the <code title="event-keyup">keyup</code> event.</p>
5245:
5246: </dd>
5247:
5248:
5249: <dt><dfn id="selector-enabled" title="selector-enabled"><code>:enabled</code></dfn></dt>
5250:
5251: <dd>
5252:
5253: <p>The <code title="selector-enabled"><a href="#selector-enabled">:enabled</a></code> pseudo-class
5254: must match the following elements:</p>
5255:
1.748 mike 5256: <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="#attr-hyperlink-href">href</a></code> attribute</li>
1.1 mike 5257:
1.748 mike 5258: <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="#attr-hyperlink-href">href</a></code> attribute</li>
1.1 mike 5259:
5260: <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>
5261:
5262: <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>
5263:
5264: <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
5265: <a href="forms.html#hidden-state" title="attr-input-type-hidden">Hidden</a> state and that
5266: are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
5267:
5268: <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>
5269:
5270: <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>
5271:
5272: <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>
5273:
5274: <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>
5275:
5276: <li><code><a href="semantics.html#the-li-element">li</a></code> elements that are children of
5277: <code><a href="#menus">menu</a></code> elements, and that have a child element that
5278: defines a <a href="#concept-command" title="concept-command">command</a>, if the
5279: first such element's <a href="#command-facet-disabledstate" title="command-facet-disabledstate">Disabled State</a> facet
5280: is false (not disabled)</li>
5281:
5282: </ul></dd>
5283:
5284:
5285: <dt><dfn id="selector-disabled" title="selector-disabled"><code>:disabled</code></dfn></dt>
5286:
5287: <dd>
5288:
5289: <p>The <code title="selector-disabled"><a href="#selector-disabled">:disabled</a></code>
5290: pseudo-class must match the following elements:</p>
5291:
1.131 mike 5292: <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 5293:
5294: <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
5295: <a href="forms.html#hidden-state" title="attr-input-type-hidden">Hidden</a> state and that
5296: are <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
5297:
5298: <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>
5299:
5300: <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>
5301:
5302: <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>
5303:
5304: <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>
5305:
5306: <li><code><a href="semantics.html#the-li-element">li</a></code> elements that are children of
5307: <code><a href="#menus">menu</a></code> elements, and that have a child element that
5308: defines a <a href="#concept-command" title="concept-command">command</a>, if the
5309: first such element's <a href="#command-facet-disabledstate" title="command-facet-disabledstate">Disabled State</a> facet
5310: is true (disabled)</li>
5311:
5312: </ul></dd>
5313:
5314:
5315: <dt><dfn id="selector-checked" title="selector-checked"><code>:checked</code></dfn></dt>
5316:
5317: <dd>
5318:
5319: <p>The <code title="selector-checked"><a href="#selector-checked">:checked</a></code> pseudo-class
5320: must match the following elements:</p>
5321:
5322: <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
5323: <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> state is
5324: true</li>
5325:
5326: <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
5327: <a href="forms.html#concept-fe-checked" title="concept-fe-checked">checkedness</a> state is
5328: true</li>
5329:
5330: <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
5331: and that have a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code>
5332: attribute</li>
5333:
5334: <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
5335: have a <code title="attr-command-checked"><a href="#attr-command-checked">checked</a></code>
5336: attribute</li>
5337:
5338: </ul></dd>
5339:
5340:
5341: <dt><dfn id="selector-indeterminate" title="selector-indeterminate"><code>:indeterminate</code></dfn></dt>
5342:
5343: <dd>
5344:
5345: <p>The <code title="selector-indeterminate"><a href="#selector-indeterminate">:indeterminate</a></code>
5346: pseudo-class must match <code><a href="forms.html#the-input-element">input</a></code> elements whose <code title="attr-input-type"><a href="forms.html#attr-input-type">type</a></code> attribute is in the <a href="forms.html#checkbox-state" title="attr-input-type-checkbox">Checkbox</a> state and whose
1.186 mike 5347: <code title="dom-input-indeterminate"><a href="forms.html#dom-input-indeterminate">indeterminate</a></code> IDL
1.1 mike 5348: attribute is set to true.</p>
5349:
5350: </dd>
5351:
5352:
5353: <dt><dfn id="selector-default" title="selector-default"><code>:default</code></dfn></dt>
5354:
5355: <dd>
5356:
5357: <p>The <code title="selector-default"><a href="#selector-default">:default</a></code> pseudo-class
5358: must match the following elements:</p>
5359:
5360: <ul><li><code><a href="forms.html#the-button-element">button</a></code> elements that are their form's
5361: <a href="forms.html#default-button">default button</a></li>
5362:
5363: <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
5364: are their form's <a href="forms.html#default-button">default button</a></li>
5365: <!--
5366: <li><code>command</code> elements that have a <code
5367: title="attr-command-default">default</code> attribute</li>
5368: -->
5369: </ul></dd>
5370:
5371:
5372: <dt><dfn id="selector-valid" title="selector-valid"><code>:valid</code></dfn></dt>
5373:
5374: <dd>
5375:
5376: <p>The <code title="selector-valid"><a href="#selector-valid">:valid</a></code> pseudo-class
5377: must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for
5378: constraint validation">candidates for constraint validation</a>
5379: and that <a href="forms.html#concept-fv-valid" title="concept-fv-valid">satisfy their
5380: constraints</a>.</p>
5381:
5382: </dd>
5383:
5384:
5385: <dt><dfn id="selector-invalid" title="selector-invalid"><code>:invalid</code></dfn></dt>
5386:
5387: <dd>
5388:
5389: <p>The <code title="selector-invalid"><a href="#selector-invalid">:invalid</a></code> pseudo-class
5390: must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for
5391: constraint validation">candidates for constraint validation</a>
5392: but that do not <a href="forms.html#concept-fv-valid" title="concept-fv-valid">satisfy their
5393: constraints</a>.</p>
5394:
5395: </dd>
5396:
5397:
5398: <dt><dfn id="selector-in-range" title="selector-in-range"><code>:in-range</code></dfn></dt>
5399:
5400: <dd>
5401:
5402: <p>The <code title="selector-in-range"><a href="#selector-in-range">:in-range</a></code>
5403: pseudo-class must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for constraint validation">candidates for
5404: constraint validation</a> and that are neither <a href="forms.html#suffering-from-an-underflow">suffering
5405: from an underflow</a> nor <a href="forms.html#suffering-from-an-overflow">suffering from an
5406: overflow</a>.</p>
5407:
5408: </dd>
5409:
5410:
5411: <dt><dfn id="selector-out-of-range" title="selector-out-of-range"><code>:out-of-range</code></dfn></dt>
5412:
5413: <dd>
5414:
5415: <p>The <code title="selector-out-of-range"><a href="#selector-out-of-range">:out-of-range</a></code>
5416: pseudo-class must match all elements that are <a href="forms.html#candidate-for-constraint-validation" title="candidate for constraint validation">candidates for
5417: constraint validation</a> and that are <a href="forms.html#suffering-from-an-underflow">suffering from an
5418: underflow</a> or <a href="forms.html#suffering-from-an-overflow">suffering from an overflow</a>.</p>
5419:
5420: </dd>
5421:
5422:
5423: <dt><dfn id="selector-required" title="selector-required"><code>:required</code></dfn></dt>
5424:
5425: <dd>
5426:
5427: <p>The <code title="selector-required"><a href="#selector-required">:required</a></code>
5428: pseudo-class must match the following elements:</p>
5429:
5430: <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>
5431:
5432: <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>
5433: attribute</li>
5434:
5435: </ul></dd>
5436:
5437:
5438: <dt><dfn id="selector-optional" title="selector-optional"><code>:optional</code></dfn></dt>
5439:
5440: <dd>
5441:
5442: <p>The <code title="selector-optional"><a href="#selector-optional">:optional</a></code>
5443: pseudo-class must match the following elements:</p>
5444:
5445: <ul><li><code><a href="forms.html#the-button-element">button</a></code> elements</li>
5446:
5447: <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>
5448:
5449: <li><code><a href="forms.html#the-select-element">select</a></code> elements</li>
5450:
5451: <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>
5452: attribute</li>
5453:
5454: </ul></dd>
5455:
5456:
5457: <dt><dfn id="selector-read-only" title="selector-read-only"><code>:read-only</code></dfn></dt>
5458: <dt><dfn id="selector-read-write" title="selector-read-write"><code>:read-write</code></dfn></dt>
5459:
5460: <dd>
5461:
5462: <p>The <code title="selector-read-write"><a href="#selector-read-write">:read-write</a></code>
5463: pseudo-class must match the following elements:</p>
5464:
5465: <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,
5466: but that are not <i title="concept-input-immutable"><a href="forms.html#concept-input-immutable">immutable</a></i>
5467: (i.e. that do not have the <code title="attr-input-readonly"><a href="forms.html#attr-input-readonly">readonly</a></code> attribute specified
5468: and that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a>)</li>
5469:
5470: <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
5471: that are not <a href="forms.html#concept-fe-disabled" title="concept-fe-disabled">disabled</a></li>
5472:
5473: <li>any element that is <a href="editing.html#editable">editable</a></li>
5474:
5475: </ul><p>The <code title="selector-read-only"><a href="#selector-read-only">:read-only</a></code>
5476: pseudo-class must match all other <a href="infrastructure.html#html-elements">HTML elements</a>.</p>
5477:
5478: </dd>
5479:
5480: </dl><p class="note">Another section of this specification defines the
5481: <i><a href="history.html#target-element">target element</a></i> used with the <code title="selector-target">:target</code> pseudo-class.</p>
5482:
5483: <p class="note">This specification does not define when an element
5484: 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
5485: those are all defined in sufficient detail in a language-agnostic
1.98 mike 5486: fashion in the Selectors specification. <a href="references.html#refsSELECTORS">[SELECTORS]</a></p>
1.1 mike 5487:
1.718 mike 5488: </div><div class="impl">
5489:
1.886 mike 5490: <h3 id="converting-html-to-other-formats"><span class="secno">4.15 </span>Converting HTML to other formats</h3><p class="XXX annotation"><b>Status: </b><i>Last call for comments</i></p>
1.718 mike 5491:
5492:
1.720 mike 5493:
5494:
1.886 mike 5495: <h4 id="atom"><span class="secno">4.15.1 </span>Atom</h4><p class="XXX annotation"><b>Status: </b><i>Last call for comments. </i><span><a href="http://www.w3.org/html/wg/tracker/issues/86">ISSUE-86</a> (atom-id-stability) blocks progress to Last Call</span></p>
1.718 mike 5496:
1.804 mike 5497: <p>Given a <code><a href="infrastructure.html#document">Document</a></code> <var title="">source</var>, a user
1.718 mike 5498: agent may run the following algorithm to <dfn id="extracting-atom" title="extracting
5499: Atom">extract an Atom feed</dfn>. This is not the only algorithm
5500: that can be used for this purpose; for instance, a user agent might
5501: instead use the hAtom algorithm. <a href="references.html#refsHATOM">[HATOM]</a></p>
5502:
1.804 mike 5503: <ol><li><p>If the <code><a href="infrastructure.html#document">Document</a></code> <var title="">source</var> does
1.718 mike 5504: not contain any <code><a href="semantics.html#the-article-element">article</a></code> elements, then return nothing
5505: and abort these steps. This algorithm can only be used with
5506: documents that contain distinct articles.</p>
5507:
5508: </li><li><p>Let <var title="">R</var> be an empty <a href="dom.html#xml-documents" title="XML
1.804 mike 5509: documents">XML</a> <code><a href="infrastructure.html#document">Document</a></code> object whose <a href="dom.html#the-document-s-address" title="the document's address">address</a> is user-agent
1.718 mike 5510: defined.</p></li>
5511:
5512: <li><p>Append a <code title="">feed</code> element in the
5513: <a href="#atom-namespace">Atom namespace</a> to <var title="">R</var>.</p></li>
5514:
5515: <li>
5516:
5517: <p>For each <code><a href="semantics.html#meta">meta</a></code> element with a <code title="attr-meta-name"><a href="semantics.html#attr-meta-name">name</a></code> attribute and a <code title="attr-meta-content"><a href="semantics.html#attr-meta-content">content</a></code> attribute and whose <code title="attr-meta-name"><a href="semantics.html#attr-meta-name">name</a></code> attribute's value is <code title="meta-author"><a href="semantics.html#meta-author">author</a></code>, run the following substeps:</p>
5518:
5519: <ol><li><p>Append an <code title="">author</code> element in the
5520: <a href="#atom-namespace">Atom namespace</a> to the root element of <var title="">R</var>.</p></li>
5521:
5522: <li><p>Append a <code title="">name</code> element in the
5523: <a href="#atom-namespace">Atom namespace</a> to the element created in the
5524: previous step.</p>
5525:
5526: </li><li><p>Append a text node whose data is the value of the
5527: <code><a href="semantics.html#meta">meta</a></code> element's <code title="attr-meta-content"><a href="semantics.html#attr-meta-content">content</a></code> attribute to the element
5528: created in the previous step.</p></li>
5529:
5530: </ol><!-- could use vCards instead, and get <atom:email> and <atom:uri>
5531: elements out of this instead of just <atom:name> --></li>
5532:
5533: <li>
5534:
5535: <p>If there is a <code><a href="semantics.html#the-link-element">link</a></code> element whose <code title="attr-link-rel"><a href="semantics.html#attr-link-rel">rel</a></code> attribute's value includes the
1.748 mike 5536: keyword <code title="rel-icon"><a href="#rel-icon">icon</a></code>, and that element also
1.718 mike 5537: has an <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code> attribute whose
5538: value successfully <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolves</a>
5539: relative to the <code><a href="semantics.html#the-link-element">link</a></code> element, then append an <code title="">icon</code> element in the <a href="#atom-namespace">Atom namespace</a> to
5540: the root element of <var title="">R</var> whose contents is a text
5541: node with its data set to the <a href="infrastructure.html#absolute-url">absolute URL</a> resulting
5542: from <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolving</a> the value of the
5543: <code title="attr-link-href"><a href="semantics.html#attr-link-href">href</a></code> attribute.</p>
5544:
5545: <!-- could check ratio, could check type... -->
5546:
5547: </li>
5548:
5549: <li>
5550:
5551: <p>Append an <code title="">id</code> element in the <a href="#atom-namespace">Atom
5552: namespace</a> to the root element of <var title="">R</var>
5553: whose contents is a text node with its data set to <a href="dom.html#the-document-s-current-address">the
5554: document's current address</a>.</p>
5555:
5556: </li>
5557:
5558: <li>
5559:
5560: <p>Optionally: Let <var title="">x</var> be a <code title="">link</code> element in the <a href="#atom-namespace">Atom
5561: namespace</a>. Add a <code title="">rel</code> attribute whose
5562: value is the string "<code title="">self</code>" to <var title="">x</var>. Append a text node with its data set to the
5563: (user-agent-defined) <a href="dom.html#the-document-s-address" title="the document's
5564: address">address</a> of <var title="">R</var> to <var title="">x</var>. Append <var title="">x</var> to the root element
5565: of <var title="">R</var>.</p>
5566:
5567: <p class="note">This step would be skipped when the document <var title="">R</var> has no convenient <a href="dom.html#the-document-s-address" title="the document's
5568: address">address</a>. The presence of the <code title="">rel="self"</code> link is a "should"-level requirement in
5569: the Atom specification.</p>
5570:
5571: </li>
5572:
5573: <li>
5574:
5575: <p>Let <var title="">x</var> be a <code title="">link</code>
5576: element in the <a href="#atom-namespace">Atom namespace</a>. Add a <code title="">rel</code> attribute whose value is the string "<code title="">alternate</code>" to <var title="">x</var>. If the
5577: document being converted is an <a href="dom.html#html-documents" title="HTML documents">HTML
5578: document</a>, add a <code title="">type</code> attribute whose
5579: value is the string "<code><a href="iana.html#text-html">text/html</a></code>" to <var title="">x</var>. Otherwise, the document being converted is an
5580: <a href="dom.html#xml-documents" title="XML documents">XML document</a>; add a <code title="">type</code> attribute whose value is the string
5581: "<code><a href="iana.html#application-xhtml-xml">application/xhtml+xml</a></code>" to <var title="">x</var>. Append a text node with its data set to
5582: <a href="dom.html#the-document-s-current-address">the document's current address</a> to <var title="">x</var>. Append <var title="">x</var> to the root element
5583: of <var title="">R</var>.</p>
5584:
5585: </li>
5586:
5587: <li><p>Let <var title="">subheading text</var> be the empty
5588: string.</p></li>
5589:
5590: <li><p>Let <var title="">heading</var> be the first element of
5591: <a href="dom.html#heading-content">heading content</a> whose nearest ancestor of
5592: <a href="dom.html#sectioning-content">sectioning content</a> is <a href="dom.html#the-body-element">the body
5593: element</a>, if any, or null if there is none.</p></li>
5594:
5595: <li>
5596:
5597: <p>Take the appropriate action from the following list, as
5598: determined by the type of the <var title="">heading</var>
5599: element:</p>
5600:
5601: <dl><dt>If <var title="">heading</var> is null</dt>
5602:
5603: <dd>
5604:
5605: <p>Let <var title="">heading text</var> be the
1.804 mike 5606: <code><a href="infrastructure.html#textcontent">textContent</a></code> of <a href="dom.html#the-title-element">the <code>title</code>
1.718 mike 5607: element</a>, if there is one, or the empty string
5608: otherwise.</p>
5609:
5610: </dd>
5611:
5612: <dt>If <var title="">heading</var> is a <code><a href="semantics.html#the-hgroup-element">hgroup</a></code> element</dt>
5613:
5614: <dd>
5615:
5616: <p>If <var title="">heading</var> contains no child
5617: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> elements, let <var title="">heading text</var> be the empty string.</p>
5618:
5619: <p>Otherwise, let <var title="">headings list</var> be a list of
5620: all the <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> element children
5621: of <var title="">heading</var>, sorted first by descending
5622: <a href="semantics.html#rank">rank</a> and then in <a href="infrastructure.html#tree-order">tree order</a> (so
5623: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>s first, then <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>s, etc, with each
1.804 mike 5624: group in the order they appear in the document). Then, let <var title="">heading text</var> be the <code><a href="infrastructure.html#textcontent">textContent</a></code> of
1.718 mike 5625: the first entry in <var title="">headings list</var>, and if
5626: there are multiple entries, let <var title="">subheading
1.804 mike 5627: text</var> be the <code><a href="infrastructure.html#textcontent">textContent</a></code> of the second entry
1.718 mike 5628: in <var title="">headings list</var>.</p>
5629:
5630: </dd>
5631:
5632: <dt>If <var title="">heading</var> is an <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> element</dt>
5633:
5634: <dd>
5635:
5636: <p>Let <var title="">heading text</var> be the
1.804 mike 5637: <code><a href="infrastructure.html#textcontent">textContent</a></code> of <var title="">heading</var>.</p>
1.718 mike 5638:
5639: </dd>
5640:
5641: </dl></li>
5642:
5643: <li>
5644:
5645: <p>Append a <code title="">title</code> element in the <a href="#atom-namespace">Atom
5646: namespace</a> to the root element of <var title="">R</var>
5647: whose contents is a text node with its data set to <var title="">heading text</var>.</p>
5648:
5649: </li>
5650:
5651: <li>
5652:
5653: <p>If <var title="">subheading text</var> is not the empty string,
5654: append a <code title="">subtitle</code> element in the <a href="#atom-namespace">Atom
5655: namespace</a> to the root element of <var title="">R</var>
5656: whose contents is a text node with its data set to <var title="">subheading text</var>.</p>
5657:
5658: </li>
5659:
5660: <li><p>Let <var title="">global update date</var> have no
5661: value.</p></li>
5662:
5663: <li>
5664:
5665: <p>For each <code><a href="semantics.html#the-article-element">article</a></code> element <var title="">article</var> that does not have an ancestor
5666: <code><a href="semantics.html#the-article-element">article</a></code> element, run the following steps:</p>
5667:
5668: <ol><li><p>Let <var title="">E</var> be an <code title="">entry</code> element in the <a href="#atom-namespace">Atom namespace</a>,
5669: and append <var title="">E</var> to the root element of <var title="">R</var>.</p></li>
5670:
5671: <li><p>Let <var title="">heading</var> be the first element of
5672: <a href="dom.html#heading-content">heading content</a> whose nearest ancestor of
5673: <a href="dom.html#sectioning-content">sectioning content</a> is <var title="">article</var>,
5674: if any, or null if there is none.</p></li>
5675:
5676: <li>
5677:
5678: <p>Take the appropriate action from the following list, as
5679: determined by the type of the <var title="">heading</var>
5680: element:</p>
5681:
5682: <dl><dt>If <var title="">heading</var> is null</dt>
5683:
5684: <dd>
5685:
5686: <p>Let <var title="">heading text</var> be the empty
5687: string.</p>
5688:
5689: </dd>
5690:
5691: <dt>If <var title="">heading</var> is a <code><a href="semantics.html#the-hgroup-element">hgroup</a></code> element</dt>
5692:
5693: <dd>
5694:
5695: <p>If <var title="">heading</var> contains no child
5696: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> elements, let <var title="">heading text</var> be the empty string.</p>
5697:
5698: <p>Otherwise, let <var title="">headings list</var> be a list
5699: of all the <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> element
5700: children of <var title="">heading</var>, sorted first by
5701: descending <a href="semantics.html#rank">rank</a> and then in <a href="infrastructure.html#tree-order">tree
5702: order</a> (so <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>s first, then
5703: <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h2</a></code>s, etc, with each group in the order they
5704: appear in the document). Then, let <var title="">heading
1.804 mike 5705: text</var> be the <code><a href="infrastructure.html#textcontent">textContent</a></code> of the first entry
1.718 mike 5706: in <var title="">headings list</var>.</p>
5707:
5708: </dd>
5709:
5710: <dt>If <var title="">heading</var> is an <code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h1</a></code>–<code><a href="semantics.html#the-h1-h2-h3-h4-h5-and-h6-elements">h6</a></code> element</dt>
5711:
5712: <dd>
5713:
5714: <p>Let <var title="">heading text</var> be the
1.804 mike 5715: <code><a href="infrastructure.html#textcontent">textContent</a></code> of <var title="">heading</var>.</p>
1.718 mike 5716:
5717: </dd>
5718:
5719: </dl></li>
5720:
5721: <li>
5722:
5723: <p>Append a <code title="">title</code> element in the
5724: <a href="#atom-namespace">Atom namespace</a> to <var title="">E</var> whose
5725: contents is a text node with its data set to <var title="">heading text</var>.</p>
5726:
5727: </li>
5728:
5729: <!-- <atom:author> is required either at the feed level (above)
5730: or the entry level (here) but we don't provide it -->
5731:
5732: <li>
5733:
5734: <p>Clone <var title="">article</var> and its descendants into an
1.788 mike 5735: environment that has <a href="webappapis.html#concept-bc-noscript" title="concept-bc-noscript">scripting
1.718 mike 5736: disabled</a>, has no <a href="infrastructure.html#plugin" title="plugin">plugins</a>, and
5737: fails any attempt to <a href="infrastructure.html#fetch" title="fetch">fetch</a> any
5738: resources. Let <var title="">cloned article</var> be the
5739: resulting clone <code><a href="semantics.html#the-article-element">article</a></code> element.</p>
5740:
5741: </li>
5742:
5743: <li>
5744:
5745: <p>Remove from the subtree rooted at <var title="">cloned
5746: article</var> any <code><a href="semantics.html#the-article-element">article</a></code> elements other than the
5747: <var title="">cloned article</var> itself, any
5748: <code><a href="semantics.html#the-header-element">header</a></code>, <code><a href="semantics.html#the-footer-element">footer</a></code>, or <code><a href="semantics.html#the-nav-element">nav</a></code>
5749: elements whose nearest ancestor of <a href="dom.html#sectioning-content">sectioning
5750: content</a> is the <var title="">cloned article</var>, and
5751: the first element of <a href="dom.html#heading-content">heading content</a> whose nearest
5752: ancestor of <a href="dom.html#sectioning-content">sectioning content</a> is the <var title="">cloned article</var>, if any.</p>
5753:
5754: </li>
5755:
5756: <li>
5757:
5758: <p>If <var title="">cloned article</var> contains any
5759: <code><a href="text-level-semantics.html#the-ins-element">ins</a></code> or <code><a href="text-level-semantics.html#the-del-element">del</a></code> elements with <code title="attr-mod-datetime"><a href="text-level-semantics.html#attr-mod-datetime">datetime</a></code> attributes whose
5760: values <a href="infrastructure.html#parse-a-global-date-and-time-string" title="parse a global date and time string">parse
5761: as global date and time strings</a> without errors, then let
5762: <var title="">update date</var> be the value of the <code title="attr-mod-datetime"><a href="text-level-semantics.html#attr-mod-datetime">datetime</a></code> attribute that parses
5763: to the newest <a href="infrastructure.html#concept-datetime" title="concept-datetime">global date and
5764: time</a>.</p>
5765:
5766: <p>Otherwise, let <var title="">update date</var> have no
5767: value.</p>
5768:
5769: <p class="note">This value is used below; it is calculated here
5770: because in certain cases the next step mutates the <var title="">cloned article</var>.</p>
5771:
5772: </li>
5773:
5774: <li>
5775:
5776: <p>If the document being converted is an <a href="dom.html#html-documents" title="HTML
5777: documents">HTML document</a>, then: Let <var title="">x</var>
5778: be a <code title="">content</code> element in the <a href="#atom-namespace">Atom
5779: namespace</a>. Add a <code title="">type</code> attribute
5780: whose value is the string "<code title="">html</code>" to <var title="">x</var>. Append a text node with its data set to the
5781: result of running the <a href="syntax.html#html-fragment-serialization-algorithm">HTML fragment serialization
5782: algorithm</a> on <var title="">cloned article</var> to <var title="">x</var>. Append <var title="">x</var> to <var title="">E</var>.</p>
5783:
5784: <p>Otherwise, the document being converted is an <a href="dom.html#xml-documents" title="XML documents">XML document</a>: Let <var title="">x</var> be a <code title="">content</code> element in
5785: the <a href="#atom-namespace">Atom namespace</a>. Add a <code title="">type</code> attribute whose value is the string "<code title="">xml</code>" to <var title="">x</var>. Append a
5786: <code><a href="semantics.html#the-div-element">div</a></code> element to <var title="">x</var>. Move all the
5787: child nodes of the <var title="">cloned article</var> node to
5788: that <code><a href="semantics.html#the-div-element">div</a></code> element, preserving their relative
5789: order. Append <var title="">x</var> to <var title="">E</var>.</p>
5790:
5791: </li>
5792:
5793: <li>
5794:
5795: <p>Establish the value of <var title="">id</var> and <var title="">has-alternate</var> from the first of the following to
5796: apply:</p>
5797:
5798: <dl><dt>If the <var title="">article</var> node has a descendant
1.748 mike 5799: <code><a href="text-level-semantics.html#the-a-element">a</a></code> or <code><a href="the-canvas-element.html#the-area-element">area</a></code> element with an <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code> attribute that
1.718 mike 5800: successfully <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolves</a>
5801: relative to that descendant and a <code title="attr-a-rel">rel</code> attribute whose value includes
1.748 mike 5802: the <code title="rel-bookmark"><a href="#link-type-bookmark">bookmark</a></code> keyword</dt>
1.718 mike 5803:
5804: <dd>Let <var title="">id</var> be the <a href="infrastructure.html#absolute-url">absolute URL</a>
5805: resulting from <a href="infrastructure.html#resolve-a-url" title="resolve a url">resolving</a> the
1.748 mike 5806: value of the <code title="attr-hyperlink-href"><a href="#attr-hyperlink-href">href</a></code>
1.718 mike 5807: attribute of the first such <code><a href="text-level-semantics.html#the-a-element">a</a></code> or <code><a href="the-canvas-element.html#the-area-element">area</a></code>
5808: element, relative to the element. Let <var title="">has-alternate</var> be true.</dd>
5809:
5810: <dt>If the <var title="">article</var> node has an <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute</dt>
5811:
5812: <dd>Let <var title="">id</var> be <a href="dom.html#the-document-s-current-address">the document's current
5813: address</a>, with the fragment identifier (if any) removed,
5814: and with a new fragment identifier specified, consisting of the
5815: value of the <var title="">article</var> element's <code title="attr-id"><a href="dom.html#the-id-attribute">id</a></code> attribute. Let <var title="">has-alternate</var> be false.</dd>
5816:
5817: <dt>Otherwise</dt>
5818:
5819: <dd>Let <var title="">id</var> be a user-agent-defined
5820: undereferenceable yet globally unique <a href="infrastructure.html#valid-url" title="valid
5821: URL">valid</a> <a href="infrastructure.html#absolute-url">absolute URL</a>. The same
5822: <a href="infrastructure.html#absolute-url">absolute URL</a> should be generated for each run of
5823: this algorithm when given the same input. Let <var title="">has-alternate</var> be false.</dd>
5824:
5825: </dl></li>
5826:
5827: <li>
5828:
5829: <p>Append an <code title="">id</code> element in the <a href="#atom-namespace">Atom
5830: namespace</a> to <var title="">E</var> whose contents is a
5831: text node with its data set to <var title="">id</var>.</p>
5832:
5833: </li>
5834:
5835: <li>
5836:
5837: <p>If <var title="">has-alternate</var> is true: Let <var title="">x</var> be a <code title="">link</code> element in the
5838: <a href="#atom-namespace">Atom namespace</a>. Add a <code title="">rel</code>
5839: attribute whose value is the string "<code title="">alternate</code>" to <var title="">x</var>. Append a
5840: text node with its data set to <var title="">id</var> to <var title="">x</var>. Append <var title="">x</var> to <var title="">E</var>.</p>
5841:
5842: </li>
5843:
5844: <li>
5845:
5846: <p>If <var title="">article</var> has a <code><a href="text-level-semantics.html#the-time-element">time</a></code>
5847: element descendant that has a <code title="attr-time-pubdate"><a href="text-level-semantics.html#attr-time-pubdate">pubdate</a></code> attribute and whose
5848: nearest ancestor <code><a href="semantics.html#the-article-element">article</a></code> element is <var title="">article</var>, and the first such element's <a href="text-level-semantics.html#concept-time-date" title="concept-time-date">date</a> is not unknown, then run
5849: the following substeps, with <var title="">e</var> being the
5850: first such element:</p>
5851:
5852: <ol><li><p>Let <var title="">datetime</var> be a <a href="infrastructure.html#concept-datetime" title="concept-datetime">global date and time</a> whose date
5853: component is the <a href="text-level-semantics.html#concept-time-date" title="concept-time-date">date</a> of
5854: <var title="">e</var>.</p></li>
5855:
5856: <li><p>If <var title="">e</var>'s <a href="text-level-semantics.html#concept-time-time" title="concept-time-time">time</a> and <a href="text-level-semantics.html#concept-time-timezone" title="concept-time-timezone">time-zone offset</a> are not
5857: unknown, then let <var title="">datetime</var>'s time and
5858: time-zone offset components be the <a href="text-level-semantics.html#concept-time-time" title="concept-time-time">time</a> and <a href="text-level-semantics.html#concept-time-timezone" title="concept-time-timezone">time-zone offset</a> of <var title="">e</var>. Otherwise, let them be midnight and no offset
5859: respectively ("<code title="">00:00Z</code>").</p></li>
5860:
5861: <li><p>Let <var title="">publication date</var> be the
5862: <a href="infrastructure.html#best-representation-of-the-global-date-and-time-string">best representation of the global date and time
5863: string</a> <var title="">datetime</var>.</p></li>
5864:
5865: </ol><p>Otherwise, let <var title="">publication date</var> have no
5866: value.</p>
5867:
5868: </li>
5869:
5870: <li>
5871:
5872: <p>If <var title="">update date</var> has no value but <var title="">publication date</var> does, then let <var title="">update date</var> have the value of <var title="">publication date</var>.</p>
5873:
5874: <p>Otherwise, if <var title="">publication date</var> has no
5875: value but <var title="">update date</var> does, then let <var title="">publication date</var> have the value of <var title="">update date</var>.</p>
5876:
5877: </li>
5878:
5879: <li>
5880:
5881: <p>If <var title="">update date</var> has a value, and <var title="">global update date</var> has no value or is less recent
5882: than <var title="">update date</var>, then let <var title="">global update date</var> have the value of <var title="">update date</var>.</p>
5883:
5884: </li>
5885:
5886: <li>
5887:
5888: <p>If <var title="">publication date</var> and <var title="">update date</var> both still have no value, then let
5889: them both value a value that is a <a href="infrastructure.html#valid-global-date-and-time-string">valid global date and
5890: time string</a> representing the <a href="infrastructure.html#concept-datetime" title="concept-datetime">global date and time</a> of the
5891: moment that this algorithm was invoked.</p>
5892:
5893: </li>
5894:
5895: <li>
5896:
5897: <p>Append an <code title="">published</code> element in the
5898: <a href="#atom-namespace">Atom namespace</a> to <var title="">E</var> whose
5899: contents is a text node with its data set to <var title="">publication date</var>.</p>
5900:
5901: </li>
5902:
5903: <li>
5904:
5905: <p>Append an <code title="">updated</code> element in the
5906: <a href="#atom-namespace">Atom namespace</a> to <var title="">E</var> whose
5907: contents is a text node with its data set to <var title="">update date</var>.</p>
5908:
5909: </li>
5910:
5911: </ol></li>
5912:
5913: <li>
5914:
5915: <p>If <var title="">global update date</var> has no value, then
5916: let it have a value that is a <a href="infrastructure.html#valid-global-date-and-time-string">valid global date and time
5917: string</a> representing the <a href="infrastructure.html#concept-datetime" title="concept-datetime">global date and time</a> of the date
1.804 mike 5918: and time of the <code><a href="infrastructure.html#document">Document</a></code>'s source file's last
1.718 mike 5919: modification, if it is known, or else of the moment that this
5920: algorithm was invoked.</p>
5921:
5922: </li>
5923:
5924: <li>
5925:
5926: <p>Insert an <code title="">updated</code> element in the
5927: <a href="#atom-namespace">Atom namespace</a> into the root element of <var title="">R</var> before the first <code title="">entry</code> in
5928: the <a href="#atom-namespace">Atom namespace</a> whose contents is a text node with
5929: its data set to <var title="">global update date</var>.</p>
5930:
5931: </li>
5932:
5933: <li><p>Return the Atom document <var title="">R</var>.</p></li>
5934:
5935: </ol><p class="note">The above algorithm does not guarantee that the
5936: output will be a conforming Atom feed. In particular, if
5937: insufficient information is provided in the document (e.g. if the
5938: document does not have any <code title=""><meta name="author"
5939: content="..."></code> elements), then the output will not be
5940: conforming.</p>
5941:
5942: <p>The <dfn id="atom-namespace">Atom namespace</dfn> is: <code>http://www.w3.org/2005/Atom</code></p>
5943:
5944:
5945:
1.117 mike 5946: </div></body></html>
Webmaster