| 1 |
wakaba |
1.1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
| 2 |
|
|
|
| 3 |
|
|
<html lang=en-US-x-Hixie> |
| 4 |
|
|
<head> |
| 5 |
|
|
<title>XML Binding Language 2.0</title> |
| 6 |
|
|
<link href="http://www.mozilla.org/favicon.ico" rel=icon> |
| 7 |
|
|
|
| 8 |
|
|
<style type="text/css"> |
| 9 |
|
|
|
| 10 |
|
|
html { margin: 0; padding: 0; color: black; background: white; } |
| 11 |
|
|
body { margin: 0; padding: 0; background: top left repeat-y url(http://www.mozilla.org/favicon.ico); } |
| 12 |
|
|
|
| 13 |
|
|
:link { color: #00C; background: transparent } |
| 14 |
|
|
:visited { color: #609; background: transparent } |
| 15 |
|
|
:link:active, :visited:active { color: #C00; background: transparent } |
| 16 |
|
|
:link:hover, :visited:hover { background: #ffa; } |
| 17 |
|
|
code :link, code :visited { color: inherit; } |
| 18 |
|
|
|
| 19 |
|
|
h1, h2, h3, h4, h5, h6 { text-align: left } |
| 20 |
|
|
h1, h2, h3 { color: #3c790a; background: transparent; } |
| 21 |
|
|
h1 { font: 900 170% sans-serif } |
| 22 |
|
|
h2 { font: 800 140% sans-serif } |
| 23 |
|
|
h3 { font: 700 120% sans-serif } |
| 24 |
|
|
h4 { font: bold 100% sans-serif } |
| 25 |
|
|
h5 { font: italic 100% sans-serif } |
| 26 |
|
|
h6 { font: small-caps 100% sans-serif } |
| 27 |
|
|
|
| 28 |
|
|
/* overall semantic structure presentation */ |
| 29 |
|
|
body { padding: 0 1em 2em 8.5em; line-height: 1.35; } |
| 30 |
|
|
pre { margin-left: 2em; /* overflow: auto; */ } |
| 31 |
|
|
h1 + h2 { margin-top: 0; } |
| 32 |
|
|
h2 { margin: 3em 0 1em 0; } |
| 33 |
|
|
h2 + h3 { margin-top: 0; } |
| 34 |
|
|
h3 { margin: 2em 0 1em 0; } |
| 35 |
|
|
h4 { margin: 1.5em 0 0.75em 0; } |
| 36 |
|
|
h5, h6 { margin: 1.5em 0 1em; } |
| 37 |
|
|
p { margin: 1em 0; } |
| 38 |
|
|
dl, dd { margin-top: 0; margin-bottom: 0; } |
| 39 |
|
|
dt { margin-top: 0.75em; margin-bottom: 0.25em; clear: left; } |
| 40 |
|
|
dd dt { margin-top: 0.25em; margin-bottom: 0; } |
| 41 |
|
|
dd p { margin-top: 0; } |
| 42 |
|
|
p + * > li, dd li { margin: 1em 0; } |
| 43 |
|
|
dt, dfn { font-weight: bold; font-style: normal; } |
| 44 |
|
|
pre, code { color: black; background: transparent; font-size: inherit; font-family: monospace; } |
| 45 |
|
|
pre strong { color: fuchsia; background: transparent; font: inherit; font-weight: bold; } |
| 46 |
|
|
pre em { color: teal; background: transparent; font-weight: bolder; font-style: normal; } |
| 47 |
|
|
@media screen { code { color: orangered; } } |
| 48 |
|
|
var sub { vertical-align: bottom; font-size: smaller; position: relative; top: 0.1em; } |
| 49 |
|
|
table { border-collapse: collapse; border-style: hidden hidden none hidden; } |
| 50 |
|
|
table thead { border-bottom: solid; } |
| 51 |
|
|
table tbody th:first-child { border-left: solid; } |
| 52 |
|
|
table td, table th { border-left: solid; border-right: solid; border-bottom: solid thin; vertical-align: top; padding: 0.2em; } |
| 53 |
|
|
blockquote { margin: 0 0 0 2em; border: 0; padding: 0; font-style: italic; } |
| 54 |
|
|
ins { background: green; color: white; /* color: green; border: solid thin lime; padding: 0.3em; line-height: 1.6em; */ text-decoration: none; } |
| 55 |
|
|
del { background: maroon; color: white; /* color: maroon; border: solid thin red; padding: 0.3em; line-height: 1.6em; */ text-decoration: line-through; } |
| 56 |
|
|
body ins, body del { display: block; } |
| 57 |
|
|
body * ins, body * del { display: inline; } |
| 58 |
|
|
|
| 59 |
|
|
/* classes */ |
| 60 |
|
|
|
| 61 |
|
|
ul.toc dfn, h1 dfn, h2 dfn, h3 dfn, h4 dfn, h5 dfn, h6 dfn { font: inherit; } |
| 62 |
|
|
ul.toc li ul { margin-bottom: 0.75em; } |
| 63 |
|
|
ul.toc li ul li ul { margin-bottom: 0.25em; } |
| 64 |
|
|
img.extra { float: right; } |
| 65 |
|
|
hr.bookmark { border: dashed 2em black; background: yellow; } |
| 66 |
|
|
pre.idl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em; } |
| 67 |
|
|
pre.idl :link, pre.idl :visited { color: inherit; background: transparent; } |
| 68 |
|
|
code.property-name { background: #FFFFCC; color: black; } |
| 69 |
|
|
code.method-name { background: #CCCCFF; color: black; } |
| 70 |
|
|
code.parameter-name { background: #FFCCFF; color: black; } |
| 71 |
|
|
code.constant-name { background: #CCFFCC; color: black; } |
| 72 |
|
|
|
| 73 |
|
|
div.head { margin: 0 0 1em; padding: 1em 0 0 0; } |
| 74 |
|
|
div.head p { margin: 1em 0; } |
| 75 |
|
|
div.head h1 { margin: 0; } |
| 76 |
|
|
div.head .logo { float: right; margin: 0 1em; } |
| 77 |
|
|
div.head .logo img { border: none } /* remove border from top image */ |
| 78 |
|
|
div.head dl { margin: 1em 0; } |
| 79 |
|
|
div.head p.copyright { font-size: smaller; } |
| 80 |
|
|
|
| 81 |
|
|
.issue { color: #E50000; background: white; opacity: 0.9; } |
| 82 |
|
|
.big-issue { color: #E50000; background: white; border: solid red; padding: 0.5em; margin: 1em 0; } |
| 83 |
|
|
.big-issue > :first-child { margin-top: 0; } |
| 84 |
|
|
p .big-issue { line-height: 3em; } |
| 85 |
|
|
.note { color: green; background: transparent; } |
| 86 |
|
|
.warning { color: red; background: transparent; } |
| 87 |
|
|
.note, .warning { font-weight: bolder; font-style: italic; padding: 0.5em 2em; } |
| 88 |
|
|
.warning:before { font-style: normal; } |
| 89 |
|
|
.critical { margin: 1em; border: double thick red; padding: 1em; background: #FFFFCC; } |
| 90 |
|
|
.critical > :first-child { margin-top: 0; } |
| 91 |
|
|
.example { display: block; color: #222222; background: #FCFCFC; border-left: double; margin: 1em 0 1em 1em; padding-left: 1em; } |
| 92 |
|
|
|
| 93 |
|
|
body, th, td { font-family: sans-serif; } |
| 94 |
|
|
pre, code { font-family: monospace; } |
| 95 |
|
|
.note { font-family: sans-serif; } |
| 96 |
|
|
p.note:before { content: 'Note: '; } |
| 97 |
|
|
p.warning:before { content: '\26A0 Warning! '; } |
| 98 |
|
|
ul.toc { list-style: none; } |
| 99 |
|
|
|
| 100 |
|
|
.issue { |
| 101 |
|
|
position: absolute; |
| 102 |
|
|
top: auto; |
| 103 |
|
|
left: 0; |
| 104 |
|
|
margin: -1.5em 0.2em 0.2em 0.2em; |
| 105 |
|
|
border: solid thin; |
| 106 |
|
|
padding: 0.35em; |
| 107 |
|
|
width: 12em; |
| 108 |
|
|
text-align: left; |
| 109 |
|
|
font-size: 0.6em; |
| 110 |
|
|
} |
| 111 |
|
|
|
| 112 |
|
|
.issue:hover { |
| 113 |
|
|
z-index: 1; |
| 114 |
|
|
} |
| 115 |
|
|
|
| 116 |
|
|
.issue:before { |
| 117 |
|
|
content: '\25B6'; |
| 118 |
|
|
display: block; |
| 119 |
|
|
text-align: right; |
| 120 |
|
|
position: absolute; |
| 121 |
|
|
left: 100%; |
| 122 |
|
|
top: 0; |
| 123 |
|
|
} |
| 124 |
|
|
|
| 125 |
|
|
@media aural { |
| 126 |
|
|
h1, h2, h3 { stress: 20; richness: 90 } |
| 127 |
|
|
.hide { speak: none } |
| 128 |
|
|
p.copyright { volume: x-soft; speech-rate: x-fast } |
| 129 |
|
|
dt { pause-before: 20% } |
| 130 |
|
|
code, pre { speak-punctuation: code } |
| 131 |
|
|
} |
| 132 |
|
|
|
| 133 |
|
|
.hide, #footer { display: none } |
| 134 |
|
|
</style> |
| 135 |
|
|
|
| 136 |
|
|
<body> |
| 137 |
|
|
<div class=head> |
| 138 |
|
|
<h1 id=xbl-2.0>XBL 2.0</h1> |
| 139 |
|
|
|
| 140 |
|
|
<h2 class="no-num no-toc" id=work-in> Work in Progress — Last Update |
| 141 |
|
|
15 March 2007</h2> |
| 142 |
|
|
|
| 143 |
|
|
<p>XBL 2.0 is part of Mozilla's <a |
| 144 |
|
|
href="http://www.mozilla.org/projects/xbl/">XBL Project</a>. For a list |
| 145 |
|
|
of other Mozilla projects, see the <a |
| 146 |
|
|
href="http://www.mozilla.org/projects/">project page</a>.</p> |
| 147 |
|
|
|
| 148 |
|
|
<p>Please send comments to the <a |
| 149 |
|
|
href="mailto:dev-tech-xbl@mozilla.org">dev-tech-xbl@mozilla.org</a> |
| 150 |
|
|
mailing list (<a |
| 151 |
|
|
href="http://lists.mozilla.org/listinfo/dev-tech-xbl">subscribe</a>, <a |
| 152 |
|
|
href="http://groups.google.com/group/mozilla.dev.tech.xbl">archives</a>).</p> |
| 153 |
|
|
|
| 154 |
|
|
<p>This document is stored in CVS. <a |
| 155 |
|
|
href="http://bonsai-www.mozilla.org/cvslog.cgi?file=mozilla-org/html/projects/xbl/xbl2.html&root=/www/">View |
| 156 |
|
|
document history</a>. <a |
| 157 |
|
|
href="https://doctor.mozilla.org/doctor.cgi?action=edit&file=http%3A%2F%2Fwww.mozilla.org%2Fprojects%2Fxbl%2Fxbl2.html">Edit</a>.</p> |
| 158 |
|
|
|
| 159 |
|
|
<p class=copyright>Portions of this content are © 1998–2006 by |
| 160 |
|
|
individual mozilla.org contributors; content available under a Creative |
| 161 |
|
|
Commons license. (<a |
| 162 |
|
|
href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>)</p> |
| 163 |
|
|
</div> |
| 164 |
|
|
|
| 165 |
|
|
<hr> |
| 166 |
|
|
|
| 167 |
|
|
<div> |
| 168 |
|
|
<h2 class="no-num no-toc" id=abstract><span class=ja-translation lang=ja>概要</span></h2> |
| 169 |
|
|
|
| 170 |
|
|
<p>The XML Binding Language (XBL) describes the ability to associate |
| 171 |
|
|
elements in one document with script, event handlers, CSS, and more |
| 172 |
|
|
complex content models in another document. This can be used to re-order |
| 173 |
|
|
and wrap content so that, for instance, simple HTML or XHTML markup can |
| 174 |
|
|
have complex CSS styles applied without requiring that the markup be |
| 175 |
|
|
polluted with multiple semantically neutral <code title="">div</code> |
| 176 |
|
|
elements.</p> |
| 177 |
|
|
|
| 178 |
|
|
<p>It can also be used to implement new DOM interfaces, and, in |
| 179 |
|
|
conjunction with other specifications, enables arbitrary tag sets to be |
| 180 |
|
|
implemented as widgets. For example, XBL could in theory be used to |
| 181 |
|
|
implement XForms.</p> |
| 182 |
|
|
|
| 183 |
|
|
<h2 class="no-num no-toc" id=status><span class=ja-translation lang=ja>この文書の状態</span></h2> |
| 184 |
|
|
|
| 185 |
|
|
<p>This specification is a (non-backwards-compatible) revision of |
| 186 |
|
|
Mozilla's XBL 1.0 language, originally developed at Netscape in 2000, and |
| 187 |
|
|
originally implemented in the Gecko rendering engine. <a |
| 188 |
|
|
href="#refsXBL10">[XBL10]</a></p> |
| 189 |
|
|
|
| 190 |
|
|
<p>This specification was developed by the Mozilla Foundation and its |
| 191 |
|
|
contributors, in conjunction with individuals from Opera Software ASA, |
| 192 |
|
|
Google, Inc, and Apple Computer, Inc, to address problems found in the |
| 193 |
|
|
original language and to allow for implementations in a broader range of |
| 194 |
|
|
Web browsers.</p> |
| 195 |
|
|
|
| 196 |
|
|
<p>This document is also based, in part, on work done in the W3C's |
| 197 |
|
|
Bindings Task Force. However, no text from that collaboration, other than |
| 198 |
|
|
that written by the aforementioned contributors, remains in this |
| 199 |
|
|
specification. Inspiration was similarly taken from other efforts, such |
| 200 |
|
|
as HTML Components. <a href="#refsHTC">[HTC]</a></p> |
| 201 |
|
|
|
| 202 |
|
|
<p>Although they have had related histories, this specification is |
| 203 |
|
|
separate from the W3C's "sXBL" drafts, and is not compatible with them. |
| 204 |
|
|
(The two efforts use different namespaces, for one.)</p> |
| 205 |
|
|
|
| 206 |
|
|
<p>This is the working copy of XBL 2.0. If you wish to make comments |
| 207 |
|
|
regarding this document, please send them to <a |
| 208 |
|
|
href="mailto:dev-tech-xbl@mozilla.org">dev-tech-xbl@mozilla.org</a>. All |
| 209 |
|
|
feedback is welcome.</p> |
| 210 |
|
|
|
| 211 |
|
|
<h2 class="no-num no-toc" id=table><span class=ja-translation lang=ja>目次 |
| 212 |
|
|
</span></h2> |
| 213 |
|
|
<!--begin-toc--> |
| 214 |
|
|
<ul class=toc> |
| 215 |
|
|
<li><a href="#introduction"><span class=secno>1. </span>Introduction</a> |
| 216 |
|
|
<ul class=toc> |
| 217 |
|
|
<li><a href="#relationship"><span class=secno>1.1. </span>Relationship |
| 218 |
|
|
to XBL1</a> |
| 219 |
|
|
|
| 220 |
|
|
<li><a href="#relationship0"><span class=secno>1.2. </span>Relationship |
| 221 |
|
|
to XSLT</a> |
| 222 |
|
|
|
| 223 |
|
|
<li><a href="#terminology"><span class=secno>1.3. </span>Terminology |
| 224 |
|
|
and Conventions</a> |
| 225 |
|
|
|
| 226 |
|
|
<li><a href="#conformance"><span class=secno>1.4. |
| 227 |
|
|
</span>Conformance</a> |
| 228 |
|
|
<ul class=toc> |
| 229 |
|
|
<li><a href="#error"><span class=secno>1.4.1. </span>Error |
| 230 |
|
|
Handling</a> |
| 231 |
|
|
|
| 232 |
|
|
<li><a href="#attributes"><span class=secno>1.4.2. </span><dfn |
| 233 |
|
|
id=attributes17 title=selector>Attributes Containing |
| 234 |
|
|
Selectors</dfn></a> |
| 235 |
|
|
|
| 236 |
|
|
<li><a href="#attributes0"><span class=secno>1.4.3. </span><dfn |
| 237 |
|
|
id=attributes18 title=space-separated>Attributes Containing |
| 238 |
|
|
Space-Separated Values</dfn></a> |
| 239 |
|
|
|
| 240 |
|
|
<li><a href="#attributes1"><span class=secno>1.4.4. </span><dfn |
| 241 |
|
|
id=attributes19 title="valid MIME type">Attributes Containing MIME |
| 242 |
|
|
Types</dfn></a> |
| 243 |
|
|
|
| 244 |
|
|
<li><a href="#attributes2"><span class=secno>1.4.5. </span><dfn |
| 245 |
|
|
id=attributes20 title=URI>Attributes Containing URIs</dfn></a> |
| 246 |
|
|
|
| 247 |
|
|
<li><a href="#attributes3"><span class=secno>1.4.6. </span>Attributes |
| 248 |
|
|
Containing Keywords</a> |
| 249 |
|
|
|
| 250 |
|
|
<li><a href="#extension"><span class=secno>1.4.7. </span>Extension |
| 251 |
|
|
Mechanisms</a> |
| 252 |
|
|
|
| 253 |
|
|
<li><a href="#feature"><span class=secno>1.4.8. </span>Feature |
| 254 |
|
|
Strings for the DOM and SVG</a> |
| 255 |
|
|
</ul> |
| 256 |
|
|
|
| 257 |
|
|
<li><a href="#security"><span class=secno>1.5. </span>Security |
| 258 |
|
|
Concerns</a> |
| 259 |
|
|
</ul> |
| 260 |
|
|
|
| 261 |
|
|
<li><a href="#xbl-elements"><span class=secno>2. </span>XBL Elements</a> |
| 262 |
|
|
<ul class=toc> |
| 263 |
|
|
<li><a href="#the-xbl"><span class=secno>2.1. </span>The <dfn |
| 264 |
|
|
id=xbl><code>xbl</code></dfn> Element</a> |
| 265 |
|
|
|
| 266 |
|
|
<li><a href="#the-binding"><span class=secno>2.2. </span>The <dfn |
| 267 |
|
|
id=binding7><code>binding</code></dfn> Element</a> |
| 268 |
|
|
|
| 269 |
|
|
<li><a href="#the-implementation"><span class=secno>2.3. </span>The |
| 270 |
|
|
<dfn id=implementation><code>implementation</code></dfn> Element</a> |
| 271 |
|
|
|
| 272 |
|
|
<li><a href="#the-template"><span class=secno>2.4. </span>The <dfn |
| 273 |
|
|
id=template><code>template</code></dfn> Element</a> |
| 274 |
|
|
|
| 275 |
|
|
<li><a href="#the-content"><span class=secno>2.5. </span>The <dfn |
| 276 |
|
|
id=content><code>content</code></dfn> Element</a> |
| 277 |
|
|
|
| 278 |
|
|
<li><a href="#the-inherited"><span class=secno>2.6. </span>The <dfn |
| 279 |
|
|
id=inherited><code>inherited</code></dfn> Element</a> |
| 280 |
|
|
|
| 281 |
|
|
<li><a href="#the-xblattr"><span class=secno>2.7. </span>The <dfn |
| 282 |
|
|
id=xblattr title=attr-attr><code>xbl:attr</code></dfn> Attribute</a> |
| 283 |
|
|
|
| 284 |
|
|
<li><a href="#the-xblpseudo"><span class=secno>2.8. </span>The <dfn |
| 285 |
|
|
id=xblpseudo title=attr-pseudo><code>xbl:pseudo</code></dfn> |
| 286 |
|
|
Attribute</a> |
| 287 |
|
|
|
| 288 |
|
|
<li><a href="#the-div"><span class=secno>2.9. </span>The <dfn |
| 289 |
|
|
id=div><code>div</code></dfn> Element</a> |
| 290 |
|
|
|
| 291 |
|
|
<li><a href="#the-handlers"><span class=secno>2.10. </span>The <dfn |
| 292 |
|
|
id=handlers><code>handlers</code></dfn> Element</a> |
| 293 |
|
|
|
| 294 |
|
|
<li><a href="#the-handler"><span class=secno>2.11. </span>The <dfn |
| 295 |
|
|
id=handler><code>handler</code></dfn> Element</a> |
| 296 |
|
|
|
| 297 |
|
|
<li><a href="#the-resources"><span class=secno>2.12. </span>The <dfn |
| 298 |
|
|
id=resources0><code>resources</code></dfn> Element</a> |
| 299 |
|
|
|
| 300 |
|
|
<li><a href="#the-style"><span class=secno>2.13. </span>The <dfn |
| 301 |
|
|
id=style0><code>style</code></dfn> Element</a> |
| 302 |
|
|
|
| 303 |
|
|
<li><a href="#the-prefetch"><span class=secno>2.14. </span>The <dfn |
| 304 |
|
|
id=prefetch><code>prefetch</code></dfn> Element</a> |
| 305 |
|
|
|
| 306 |
|
|
<li><a href="#the-script"><span class=secno>2.15. </span>The <dfn |
| 307 |
|
|
id=script0><code>script</code></dfn> Element</a> |
| 308 |
|
|
|
| 309 |
|
|
<li><a href="#the-id"><span class=secno>2.16. </span>The <dfn id=id |
| 310 |
|
|
title=attr-id><code>id</code></dfn> Attribute of XBL Elements</a> |
| 311 |
|
|
</ul> |
| 312 |
|
|
|
| 313 |
|
|
<li><a href="#binding"><span class=secno>3. </span><dfn |
| 314 |
|
|
id=binding8>Binding Attachment and Detachment</dfn></a> |
| 315 |
|
|
<ul class=toc> |
| 316 |
|
|
<li><a href="#the-bindings-are-ready"><span class=secno>3.1. |
| 317 |
|
|
</span><dfn id=the-bindings-are-ready0>The Bindings-Are-Ready |
| 318 |
|
|
State</dfn></a> |
| 319 |
|
|
|
| 320 |
|
|
<li><a href="#attachment"><span class=secno>3.2. </span><dfn |
| 321 |
|
|
id=attachment3 title="attachment using binding">Attachment using <code |
| 322 |
|
|
title=binding><binding element=""></code></dfn></a> |
| 323 |
|
|
<ul class=toc> |
| 324 |
|
|
<li><a href="#importing"><span class=secno>3.2.1. </span><dfn |
| 325 |
|
|
id=importing0 title=import>Importing Binding Documents</dfn></a> |
| 326 |
|
|
</ul> |
| 327 |
|
|
|
| 328 |
|
|
<li><a href="#attachment0"><span class=secno>3.3. </span>Attachment |
| 329 |
|
|
using CSS</a> |
| 330 |
|
|
<ul class=toc> |
| 331 |
|
|
<li><a href="#the-binding0"><span class=secno>3.3.1. </span>The |
| 332 |
|
|
'<code title="binding property">binding</code>' Property</a> |
| 333 |
|
|
|
| 334 |
|
|
<li><a href="#processing"><span class=secno>3.3.2. </span>Processing |
| 335 |
|
|
Model</a> |
| 336 |
|
|
|
| 337 |
|
|
<li><a href="#examples"><span class=secno>3.3.3. </span>Examples</a> |
| 338 |
|
|
</ul> |
| 339 |
|
|
|
| 340 |
|
|
<li><a href="#attachment1"><span class=secno>3.4. </span>Attachment |
| 341 |
|
|
using the DOM</a> |
| 342 |
|
|
|
| 343 |
|
|
<li><a href="#binding0"><span class=secno>3.5. </span><dfn |
| 344 |
|
|
id=binding9>Binding Attachment Model</dfn></a> |
| 345 |
|
|
|
| 346 |
|
|
<li><a href="#handling"><span class=secno>3.6. </span><dfn |
| 347 |
|
|
id=handling1>Handling Insertion and Removal from the |
| 348 |
|
|
Document</dfn></a> |
| 349 |
|
|
|
| 350 |
|
|
<li><a href="#binding1"><span class=secno>3.7. </span><dfn |
| 351 |
|
|
id=binding10>Binding Inheritance</dfn></a> |
| 352 |
|
|
<ul class=toc> |
| 353 |
|
|
<li><a href="#explicit"><span class=secno>3.7.1. </span><dfn |
| 354 |
|
|
id=explicit0>Explicit Inheritance</dfn></a> |
| 355 |
|
|
|
| 356 |
|
|
<li><a href="#implicit"><span class=secno>3.7.2. </span><dfn |
| 357 |
|
|
id=implicit0>Implicit Inheritance</dfn></a> |
| 358 |
|
|
|
| 359 |
|
|
<li><a href="#mixing"><span class=secno>3.7.3. </span>Mixing Implicit |
| 360 |
|
|
and Explicit Inheritance</a> |
| 361 |
|
|
</ul> |
| 362 |
|
|
|
| 363 |
|
|
<li><a href="#views"><span class=secno>3.8. </span>Views and |
| 364 |
|
|
Attachment</a> |
| 365 |
|
|
|
| 366 |
|
|
<li><a href="#attachment2"><span class=secno>3.9. </span>Attachment |
| 367 |
|
|
During Document Load</a> |
| 368 |
|
|
|
| 369 |
|
|
<li><a href="#binding2"><span class=secno>3.10. </span><dfn |
| 370 |
|
|
id=binding11>Binding Detachment Model</dfn></a> |
| 371 |
|
|
</ul> |
| 372 |
|
|
|
| 373 |
|
|
<li><a href="#shadow"><span class=secno>4. </span><dfn id=shadow3>Shadow |
| 374 |
|
|
Content</dfn></a> |
| 375 |
|
|
<ul class=toc> |
| 376 |
|
|
<li><a href="#rules"><span class=secno>4.1. </span><dfn id=rules1>Rules |
| 377 |
|
|
for Shadow Content Generation</dfn></a> |
| 378 |
|
|
|
| 379 |
|
|
<li><a href="#rules0"><span class=secno>4.2. </span><dfn |
| 380 |
|
|
id=rules2>Rules for Shadow Content Destruction</dfn></a> |
| 381 |
|
|
|
| 382 |
|
|
<li><a href="#attribute"><span class=secno>4.3. </span><dfn |
| 383 |
|
|
id=attribute0>Attribute Forwarding</dfn></a> |
| 384 |
|
|
<ul class=toc> |
| 385 |
|
|
<li><a href="#forwarding"><span class=secno>4.3.1. </span>Forwarding |
| 386 |
|
|
to and from text nodes</a> |
| 387 |
|
|
|
| 388 |
|
|
<li><a href="#forwarding0"><span class=secno>4.3.2. </span>Forwarding |
| 389 |
|
|
language metadata</a> |
| 390 |
|
|
|
| 391 |
|
|
<li><a href="#error0"><span class=secno>4.3.3. </span>Error |
| 392 |
|
|
handling</a> |
| 393 |
|
|
|
| 394 |
|
|
<li><a href="#type-specifiers"><span class=secno>4.3.4. </span>Type |
| 395 |
|
|
specifiers</a> |
| 396 |
|
|
|
| 397 |
|
|
<li><a href="#dynamic"><span class=secno>4.3.5. </span>Dynamic |
| 398 |
|
|
changes</a> |
| 399 |
|
|
|
| 400 |
|
|
<li><a href="#how-attribute"><span class=secno>4.3.6. </span>How |
| 401 |
|
|
Attribute Forwarding Affects the Shadow Tree</a> |
| 402 |
|
|
</ul> |
| 403 |
|
|
|
| 404 |
|
|
<li><a href="#processing0"><span class=secno>4.4. </span><dfn |
| 405 |
|
|
id=processing1>Processing <code>content</code> Elements</dfn></a> |
| 406 |
|
|
<ul class=toc> |
| 407 |
|
|
<li><a href="#how-nodes"><span class=secno>4.4.1. </span>How Nodes |
| 408 |
|
|
are Distributed</a> |
| 409 |
|
|
|
| 410 |
|
|
<li><a href="#when-nodes"><span class=secno>4.4.2. </span>When Nodes |
| 411 |
|
|
Are Redistributed</a> |
| 412 |
|
|
</ul> |
| 413 |
|
|
|
| 414 |
|
|
<li><a href="#the-final"><span class=secno>4.5. </span>The <dfn |
| 415 |
|
|
id=final>Final Flattened Tree</dfn></a> |
| 416 |
|
|
<ul class=toc> |
| 417 |
|
|
<li><a href="#terminology0"><span class=secno>4.5.1. |
| 418 |
|
|
</span>Terminology</a> |
| 419 |
|
|
</ul> |
| 420 |
|
|
|
| 421 |
|
|
<li><a href="#handling0"><span class=secno>4.6. </span><dfn |
| 422 |
|
|
id=handling2>Handling DOM Changes</dfn></a> |
| 423 |
|
|
|
| 424 |
|
|
<li><a href="#shadow0"><span class=secno>4.7. </span>Shadow Content and |
| 425 |
|
|
CSS</a> |
| 426 |
|
|
<ul class=toc> |
| 427 |
|
|
<li><a href="#selectors"><span class=secno>4.7.1. </span><dfn |
| 428 |
|
|
id=selectors0>Selectors and Shadow Scopes</dfn></a> |
| 429 |
|
|
|
| 430 |
|
|
<li><a href="#css-property"><span class=secno>4.7.2. </span><dfn |
| 431 |
|
|
id=css-property0>CSS Property Inheritance and Rendering</dfn></a> |
| 432 |
|
|
|
| 433 |
|
|
<li><a href="#the-bound-element"><span class=secno>4.7.3. </span>The |
| 434 |
|
|
<code>:bound-element</code> Pseudo-Class</a> |
| 435 |
|
|
|
| 436 |
|
|
<li><a href="#matching"><span class=secno>4.7.4. </span><dfn |
| 437 |
|
|
id=matching0>Matching Pseudo-Elements</dfn></a> |
| 438 |
|
|
</ul> |
| 439 |
|
|
|
| 440 |
|
|
<li><a href="#shadow1"><span class=secno>4.8. </span>Shadow Content and |
| 441 |
|
|
<code>xml:base</code></a> |
| 442 |
|
|
|
| 443 |
|
|
<li><a href="#shadow2"><span class=secno>4.9. </span><dfn id=shadow4 |
| 444 |
|
|
title="Semantics of non-XBL elements in XBL contexts">Shadow Content |
| 445 |
|
|
and Other Things</dfn></a> |
| 446 |
|
|
<ul class=toc> |
| 447 |
|
|
<li><a href="#general"><span class=secno>4.9.1. </span>General |
| 448 |
|
|
Rules</a> |
| 449 |
|
|
|
| 450 |
|
|
<li><a href="#style"><span class=secno>4.9.2. </span><dfn |
| 451 |
|
|
id=style1>Style Blocks</dfn></a> |
| 452 |
|
|
|
| 453 |
|
|
<li><a href="#script"><span class=secno>4.9.3. </span><dfn |
| 454 |
|
|
id=script1>Script Blocks</dfn></a> |
| 455 |
|
|
|
| 456 |
|
|
<li><a href="#event"><span class=secno>4.9.4. </span><dfn |
| 457 |
|
|
id=event4>Event Handler Blocks</dfn></a> |
| 458 |
|
|
|
| 459 |
|
|
<li><a href="#html-forms"><span class=secno>4.9.5. </span>HTML |
| 460 |
|
|
Forms</a> |
| 461 |
|
|
|
| 462 |
|
|
<li><a href="#svg"><span class=secno>4.9.6. </span>SVG</a> |
| 463 |
|
|
</ul> |
| 464 |
|
|
|
| 465 |
|
|
<li><a href="#binding3"><span class=secno>4.10. </span><dfn |
| 466 |
|
|
id=binding12>Binding Style Sheets</dfn></a> |
| 467 |
|
|
<ul class=toc> |
| 468 |
|
|
<li><a href="#styleSummary"><span class=secno>4.10.1. </span>Summary |
| 469 |
|
|
of styling rules</a> |
| 470 |
|
|
</ul> |
| 471 |
|
|
</ul> |
| 472 |
|
|
|
| 473 |
|
|
<li><a href="#binding4"><span class=secno>5. </span><dfn |
| 474 |
|
|
id=binding13>Binding Implementations</dfn></a> |
| 475 |
|
|
<ul class=toc> |
| 476 |
|
|
<li><a href="#the-xblimplementation"><span class=secno>5.1. </span>The |
| 477 |
|
|
<code>XBLImplementation</code> Interface</a> |
| 478 |
|
|
|
| 479 |
|
|
<li><a href="#the-xblimplementationlist"><span class=secno>5.2. |
| 480 |
|
|
</span>The <code>XBLImplementationList</code> Interface</a> |
| 481 |
|
|
|
| 482 |
|
|
<li><a href="#accessing"><span class=secno>5.3. </span>Accessing |
| 483 |
|
|
Binding Implementations</a> |
| 484 |
|
|
|
| 485 |
|
|
<li><a href="#ecmascript"><span class=secno>5.4. </span><dfn |
| 486 |
|
|
id=ecmascript0>ECMAScript Bindings</dfn></a> |
| 487 |
|
|
<ul class=toc> |
| 488 |
|
|
<li><a href="#compiling"><span class=secno>5.4.1. </span><dfn |
| 489 |
|
|
id=compiling0>Compiling ECMAScript Bindings</dfn></a> |
| 490 |
|
|
|
| 491 |
|
|
<li><a href="#invoking"><span class=secno>5.4.2. </span>Invoking |
| 492 |
|
|
Methods on an ECMAScript Implementation Object</a> |
| 493 |
|
|
</ul> |
| 494 |
|
|
</ul> |
| 495 |
|
|
|
| 496 |
|
|
<li><a href="#event0"><span class=secno>6. </span><dfn id=event5>Event |
| 497 |
|
|
Handlers</dfn></a> |
| 498 |
|
|
<ul class=toc> |
| 499 |
|
|
<li><a href="#event1"><span class=secno>6.1. </span><dfn |
| 500 |
|
|
id=event6>Event Forwarding</dfn></a> |
| 501 |
|
|
|
| 502 |
|
|
<li><a href="#registering"><span class=secno>6.2. </span><dfn |
| 503 |
|
|
id=registering0>Registering Event Handlers with the |
| 504 |
|
|
<code>handler</code> Element</dfn></a> |
| 505 |
|
|
|
| 506 |
|
|
<li><a href="#mouse"><span class=secno>6.3. </span><dfn id=mouse0>Mouse |
| 507 |
|
|
Event Handler Filters</dfn></a> |
| 508 |
|
|
|
| 509 |
|
|
<li><a href="#key-event"><span class=secno>6.4. </span><dfn |
| 510 |
|
|
id=key-event0>Key Event Handler Filters</dfn></a> |
| 511 |
|
|
|
| 512 |
|
|
<li><a href="#text-input"><span class=secno>6.5. </span><dfn |
| 513 |
|
|
id=text-input0>Text Input Event Handler Filters</dfn></a> |
| 514 |
|
|
|
| 515 |
|
|
<li><a href="#mutation"><span class=secno>6.6. </span><dfn |
| 516 |
|
|
id=mutation0>Mutation Event Handler Filters</dfn></a> |
| 517 |
|
|
|
| 518 |
|
|
<li><a href="#modifiers"><span class=secno>6.7. </span><dfn |
| 519 |
|
|
id=modifiers0>Modifiers</dfn></a> |
| 520 |
|
|
|
| 521 |
|
|
<li><a href="#event2"><span class=secno>6.8. </span><dfn |
| 522 |
|
|
id=event7>Event Flow and Targeting Across Shadow Scopes</dfn></a> |
| 523 |
|
|
|
| 524 |
|
|
<li><a href="#the-default"><span class=secno>6.9. </span><dfn |
| 525 |
|
|
id=the-default0 title="default phase">The Default Phase</dfn></a> |
| 526 |
|
|
|
| 527 |
|
|
<li><a href="#the-focus"><span class=secno>6.10. </span>The |
| 528 |
|
|
<code>focus</code>, <code>DOMFocusIn</code>, <code>blur</code>, and |
| 529 |
|
|
<code>DOMFocusOut</code> Events</a> |
| 530 |
|
|
|
| 531 |
|
|
<li><a href="#the-mouseover"><span class=secno>6.11. </span>The |
| 532 |
|
|
<code>mouseover</code> and <code>mouseout</code> Events</a> |
| 533 |
|
|
|
| 534 |
|
|
<li><a href="#event3"><span class=secno>6.12. </span><dfn |
| 535 |
|
|
id=event8>Event Handlers Implemented in ECMAScript</dfn></a> |
| 536 |
|
|
</ul> |
| 537 |
|
|
|
| 538 |
|
|
<li><a href="#dom-interfaces"><span class=secno>7. </span><dfn |
| 539 |
|
|
id=dom-interfaces0>DOM Interfaces</dfn></a> |
| 540 |
|
|
<ul class=toc> |
| 541 |
|
|
<li><a href="#the-documentxbl"><span class=secno>7.1. </span>The |
| 542 |
|
|
<code>DocumentXBL</code> Interface</a> |
| 543 |
|
|
|
| 544 |
|
|
<li><a href="#the-elementxbl"><span class=secno>7.2. </span>The |
| 545 |
|
|
<code>ElementXBL</code> Interface</a> |
| 546 |
|
|
<ul class=toc> |
| 547 |
|
|
<li><a href="#scoping"><span class=secno>7.2.1. </span>Scoping and |
| 548 |
|
|
Access Using the DOM</a> |
| 549 |
|
|
</ul> |
| 550 |
|
|
|
| 551 |
|
|
<li><a href="#the-xblcontentelement"><span class=secno>7.3. </span>The |
| 552 |
|
|
<code>XBLContentElement</code> Interface</a> |
| 553 |
|
|
|
| 554 |
|
|
<li><a href="#the-xbltemplateelement"><span class=secno>7.4. </span>The |
| 555 |
|
|
<code>XBLTemplateElement</code> Interface</a> |
| 556 |
|
|
|
| 557 |
|
|
<li><a href="#the-eventxbl"><span class=secno>7.5. </span>The |
| 558 |
|
|
<code>EventXBL</code> Interface</a> |
| 559 |
|
|
</ul> |
| 560 |
|
|
|
| 561 |
|
|
<li><a href="#resources"><span class=secno>8. </span>Resources</a> |
| 562 |
|
|
<ul class=toc> |
| 563 |
|
|
<li><a href="#loading"><span class=secno>8.1. </span><dfn |
| 564 |
|
|
id=loading2>Loading External Resources</dfn></a> |
| 565 |
|
|
<ul class=toc> |
| 566 |
|
|
<li><a href="#binding5"><span class=secno>8.1.1. </span>Binding |
| 567 |
|
|
Documents</a> |
| 568 |
|
|
|
| 569 |
|
|
<li><a href="#external"><span class=secno>8.1.2. </span>External |
| 570 |
|
|
Resources</a> |
| 571 |
|
|
</ul> |
| 572 |
|
|
|
| 573 |
|
|
<li><a href="#loading0"><span class=secno>8.2. </span><dfn |
| 574 |
|
|
id=loading3>Loading and Running Scripts</dfn></a> |
| 575 |
|
|
<ul class=toc> |
| 576 |
|
|
<li><a href="#xforms"><span class=secno>8.2.1. </span>XForms |
| 577 |
|
|
Actions</a> |
| 578 |
|
|
|
| 579 |
|
|
<li><a href="#scripting"><span class=secno>8.2.2. </span>Scripting |
| 580 |
|
|
Model</a> |
| 581 |
|
|
</ul> |
| 582 |
|
|
|
| 583 |
|
|
<li><a href="#loading1"><span class=secno>8.3. </span><dfn |
| 584 |
|
|
id=loading4>Loading Style Sheets</dfn></a> |
| 585 |
|
|
|
| 586 |
|
|
<li><a href="#interpretation"><span class=secno>8.4. </span><dfn |
| 587 |
|
|
id=interpretation0>Interpretation of URIs to XBL bindings</dfn></a> |
| 588 |
|
|
</ul> |
| 589 |
|
|
|
| 590 |
|
|
<li><a href="#summaries"><span class=secno>9. </span>Summaries of |
| 591 |
|
|
Elements, Attributes, and Events</a> |
| 592 |
|
|
<ul class=toc> |
| 593 |
|
|
<li><a href="#elements"><span class=secno>9.1. </span>Elements and |
| 594 |
|
|
Attributes</a> |
| 595 |
|
|
|
| 596 |
|
|
<li><a href="#events"><span class=secno>9.2. </span>Events</a> |
| 597 |
|
|
|
| 598 |
|
|
<li><a href="#implementations"><span class=secno>9.3. |
| 599 |
|
|
</span>Implementations</a> |
| 600 |
|
|
</ul> |
| 601 |
|
|
|
| 602 |
|
|
<li class=no-num><a href="#acknowledgments">Acknowledgments</a> |
| 603 |
|
|
|
| 604 |
|
|
<li class=no-num><a href="#references">References</a> |
| 605 |
|
|
</ul> |
| 606 |
|
|
<!--end-toc--> |
| 607 |
|
|
<hr> |
| 608 |
|
|
|
| 609 |
|
|
<h2 id=introduction><span class=ja-translation lang=ja><span class=secno>1. </span>はじめに</span></h2> |
| 610 |
|
|
|
| 611 |
|
|
<p>This specification defines the XML Binding Language and some supporting |
| 612 |
|
|
DOM interfaces and CSS features. XBL is a mechanism for overriding the |
| 613 |
|
|
standard presentation and interactive behavior of particular elements by |
| 614 |
|
|
attaching those elements to appropriate definitions, called <a |
| 615 |
|
|
href="#binding16" title=binding>bindings</a>. Bindings can be attached to |
| 616 |
|
|
elements using either CSS, the DOM, or by declaring, in XBL, that |
| 617 |
|
|
elements matching a specific selector are implemented by a particular |
| 618 |
|
|
binding. The element that the binding is attached to, called the <a |
| 619 |
|
|
href="#bound">bound element</a>, acquires the new behavior and |
| 620 |
|
|
presentation specified by the binding.</p> |
| 621 |
|
|
|
| 622 |
|
|
<p>Bindings can contain <a href="#handlers0" title=handlers>event |
| 623 |
|
|
handlers</a> that watch for events on the bound element, an <a |
| 624 |
|
|
href="#implementation0">implementation</a> of new methods and properties |
| 625 |
|
|
that become accessible from the bound element, <a href="#shadow5">shadow |
| 626 |
|
|
content</a> that is inserted underneath the bound element, and associated |
| 627 |
|
|
<a href="#resources1">resources</a> such as scoped style sheets and |
| 628 |
|
|
precached images, sounds, or videos.</p> |
| 629 |
|
|
|
| 630 |
|
|
<p><span title="Except if script invoked by XBL explicitly changes the |
| 631 |
|
|
original DOM.">XBL cannot be used to give a document new |
| 632 |
|
|
semantics.</span> The meaning of a document is not changed by any |
| 633 |
|
|
bindings that are associated with it, only its presentation and |
| 634 |
|
|
interactive behavior.</p> |
| 635 |
|
|
|
| 636 |
|
|
<div class=example id=intro-example> |
| 637 |
|
|
<p>To help readers understand how certain features can be used, this |
| 638 |
|
|
specification includes some examples.</p> |
| 639 |
|
|
|
| 640 |
|
|
<p>In these examples, a long ellipsis ("...") is used to indicate elided |
| 641 |
|
|
content that would be present in a full example but has been removed for |
| 642 |
|
|
clarity.</p> |
| 643 |
|
|
|
| 644 |
|
|
<p>Here we see a simple binding being used to reorder content in an HTML |
| 645 |
|
|
page, so that the element with <code>class="nav"</code> is positioned |
| 646 |
|
|
before the element with <code>class="main"</code>. CSS associated with |
| 647 |
|
|
the binding is then used to position the two elements.</p> |
| 648 |
|
|
|
| 649 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 650 |
|
|
<binding id="nav-then-main"> |
| 651 |
|
|
<template> |
| 652 |
|
|
<div id="wrapper"> |
| 653 |
|
|
<div id="col2"><content includes=".nav"/></div> |
| 654 |
|
|
<div id="col1"><content includes=".main"/></div> |
| 655 |
|
|
</div> |
| 656 |
|
|
</template> |
| 657 |
|
|
<resources> |
| 658 |
|
|
<style> |
| 659 |
|
|
#wrapper { display: table-row; } |
| 660 |
|
|
#col1, #col2 { display: table-cell; } |
| 661 |
|
|
</style> |
| 662 |
|
|
</resources> |
| 663 |
|
|
</binding> |
| 664 |
|
|
</xbl></pre> |
| 665 |
|
|
|
| 666 |
|
|
<p>The HTML page associated with such a binding might look like:</p> |
| 667 |
|
|
|
| 668 |
|
|
<pre><!DOCTYPE HTML> |
| 669 |
|
|
<html> |
| 670 |
|
|
<head> |
| 671 |
|
|
<title>Demo</title> |
| 672 |
|
|
<link rel="stylesheet" href="example.css"> |
| 673 |
|
|
</head> |
| 674 |
|
|
<body> |
| 675 |
|
|
<div class="main"> |
| 676 |
|
|
<h1>Demo</h1> |
| 677 |
|
|
... |
| 678 |
|
|
</div> |
| 679 |
|
|
<div class="nav"> |
| 680 |
|
|
<p><a href="http://example.com/">Home</a></p> |
| 681 |
|
|
... |
| 682 |
|
|
</div> |
| 683 |
|
|
</body> |
| 684 |
|
|
</html></pre> |
| 685 |
|
|
|
| 686 |
|
|
<p>The CSS stylesheet referred to from that document would include |
| 687 |
|
|
various stylistic rules, and would in particular contain a link to the |
| 688 |
|
|
XBL file, making it apply to the <code>body</code> element so as to |
| 689 |
|
|
reorder the two child elements:</p> |
| 690 |
|
|
|
| 691 |
|
|
<pre>/* Colors and Fonts */ |
| 692 |
|
|
h1 { font: 2em sans-serif; color: green; background: white; } |
| 693 |
|
|
... |
| 694 |
|
|
|
| 695 |
|
|
/* Reorder content */ |
| 696 |
|
|
body { binding: url(example.xml#nav-then-main); }</pre> |
| 697 |
|
|
|
| 698 |
|
|
<p>The result of all the above is equivalent to the result one would get |
| 699 |
|
|
if one simply placed the <code title="">div</code> element with |
| 700 |
|
|
<code>class="nav"</code> before the <code title="">div</code> element |
| 701 |
|
|
with <code>class="main"</code>. However, the effect is achieved without |
| 702 |
|
|
needing any changes to the markup. This allows the same markup to be |
| 703 |
|
|
given different presentations dynamically. It also allows changes to be |
| 704 |
|
|
applied across entire sites by merely changing global stylesheet and |
| 705 |
|
|
binding files, much as CSS can be used to change the layout and |
| 706 |
|
|
presentation of a site even without XBL.</p> |
| 707 |
|
|
</div> |
| 708 |
|
|
|
| 709 |
|
|
<div class=example id=simple-shadow-example> |
| 710 |
|
|
<p>Here is another example, this time of an inaccessible implementation |
| 711 |
|
|
of the proposed HTML5 <code title="">details</code> disclosure element: |
| 712 |
|
|
it opens and closes when clicked, and reflects its current state in the |
| 713 |
|
|
element's "<code>open</code>" attribute.</p> |
| 714 |
|
|
|
| 715 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 716 |
|
|
<binding element="details"> |
| 717 |
|
|
<template> |
| 718 |
|
|
<div> |
| 719 |
|
|
<div><content includes="legend:first-child">Details...</content></div> |
| 720 |
|
|
<div state="hidden" id="container"><content/></div> |
| 721 |
|
|
</div> |
| 722 |
|
|
</template> |
| 723 |
|
|
<handlers> |
| 724 |
|
|
<handler event="click" phase="default-action"> |
| 725 |
|
|
this.open = !this.open; |
| 726 |
|
|
</handler> |
| 727 |
|
|
<handler event="DOMAttrModified" attr-name="open" attr-change="addition" phase="target"> |
| 728 |
|
|
this.shadowTree.getElementById('container').setAttribute('state', 'visible'); |
| 729 |
|
|
</handler> |
| 730 |
|
|
<handler event="DOMAttrModified" attr-name="open" attr-change="removal" phase="target"> |
| 731 |
|
|
this.shadowTree.getElementById('container').setAttribute('state', 'hidden'); |
| 732 |
|
|
</handler> |
| 733 |
|
|
</handlers> |
| 734 |
|
|
<implementation> |
| 735 |
|
|
({ |
| 736 |
|
|
get open() { return this.boundElement.hasAttribute('open'); }, |
| 737 |
|
|
set open(val) { |
| 738 |
|
|
if (val) |
| 739 |
|
|
this.boundElement.setAttribute('open', 'open'); |
| 740 |
|
|
else |
| 741 |
|
|
this.boundElement.removeAttribute('open'); |
| 742 |
|
|
return this.open; |
| 743 |
|
|
}, |
| 744 |
|
|
}) |
| 745 |
|
|
</implementation> |
| 746 |
|
|
<resources> |
| 747 |
|
|
<style> |
| 748 |
|
|
#container[state=hidden] { display: none; } |
| 749 |
|
|
</style> |
| 750 |
|
|
</resources> |
| 751 |
|
|
</binding> |
| 752 |
|
|
</xbl></pre> |
| 753 |
|
|
</div> |
| 754 |
|
|
|
| 755 |
|
|
<p class=note>Since the examples are all untested (there are no XBL2 |
| 756 |
|
|
implementations at the time of writing), it is quite possible that they |
| 757 |
|
|
have errors. Please report any errors you think you see, so that we can |
| 758 |
|
|
correct the examples.</p> |
| 759 |
|
|
|
| 760 |
|
|
<h3 id=relationship><span class=ja-translation lang=ja><span class=secno>1.1. </span>XBL1 との関係</span></h3> |
| 761 |
|
|
|
| 762 |
|
|
<p>This specification is not backwards compatible with XBL1.</p> |
| 763 |
|
|
|
| 764 |
|
|
<p>There are numerous changes. However, of particular importance to |
| 765 |
|
|
readers familiar with XBL1, there have been some changes to the element |
| 766 |
|
|
names. In particular, the XBL1 element <code title="">content</code> is |
| 767 |
|
|
now called <code><a href="#template0">template</a></code>, and the XBL1 |
| 768 |
|
|
element <code title="">children</code> is now called <code><a |
| 769 |
|
|
href="#content0">content</a></code>.</p> |
| 770 |
|
|
|
| 771 |
|
|
<h3 id=relationship0><span class=ja-translation lang=ja><span class=secno>1.2. </span>XSLT との関係</span></h3> |
| 772 |
|
|
|
| 773 |
|
|
<p>This specification has a similar scope to XSLT. The main differences |
| 774 |
|
|
are:</p> |
| 775 |
|
|
|
| 776 |
|
|
<ul> |
| 777 |
|
|
<li> |
| 778 |
|
|
<p>XSLT operates on a static DOM, permanently replacing that DOM for |
| 779 |
|
|
rendering. XBL, on the other hand, transparently transforms the DOM for |
| 780 |
|
|
rendering while leaving the underlying structure intact, and |
| 781 |
|
|
dynamically reflects changes to the underlying DOM in the transformed |
| 782 |
|
|
rendering. |
| 783 |
|
|
|
| 784 |
|
|
<li> |
| 785 |
|
|
<p>XSLT allows any arbitrary transformation to be performed. XBL shadow |
| 786 |
|
|
trees, on the other hand, only support reordering of the bound |
| 787 |
|
|
element's child nodes and interleaving of those explicit children with |
| 788 |
|
|
shadow content. Arbitrary transformations are not possible in XBL while |
| 789 |
|
|
retaining the transparent nature of XBL's shadow tree processing. |
| 790 |
|
|
</ul> |
| 791 |
|
|
|
| 792 |
|
|
<p>In addition, XBL can be used for component creation, which is not |
| 793 |
|
|
covered by XSLT.</p> |
| 794 |
|
|
|
| 795 |
|
|
<h3 id=terminology><span class=secno>1.3. </span>Terminology and |
| 796 |
|
|
Conventions</h3> |
| 797 |
|
|
|
| 798 |
|
|
<p>An <dfn id=xbl-user title="XBL user agents">XBL user agent</dfn> is an |
| 799 |
|
|
implementation that attempts to support this specification.</p> |
| 800 |
|
|
|
| 801 |
|
|
<p>A <dfn id=binding14 title="">binding</dfn> is the definition of |
| 802 |
|
|
behavior that can be applied to an element so as to augment its |
| 803 |
|
|
presentation.</p> |
| 804 |
|
|
|
| 805 |
|
|
<p>The namespace of all the <dfn id=xbl-elements0>XBL elements</dfn> and |
| 806 |
|
|
<dfn id=xbl-global>XBL global attributes</dfn> must be: <code |
| 807 |
|
|
class=uri>http://www.w3.org/ns/xbl</code> |
| 808 |
|
|
|
| 809 |
|
|
<p>An <dfn id=xbl-document>XBL document</dfn> is an XML document that has |
| 810 |
|
|
the <code><a href="#xbl0">xbl</a></code> element at its root.</p> |
| 811 |
|
|
|
| 812 |
|
|
<p>A <dfn id=non-xbl>non-XBL document</dfn> is an XML document whose root |
| 813 |
|
|
element is from a namespace other than XBL (e.g. XHTML). A non-XBL |
| 814 |
|
|
document can include XBL, if the other languages involved allow it.</p> |
| 815 |
|
|
|
| 816 |
|
|
<p>An <dfn id=xbl-subtree title="XBL subtrees">XBL subtree</dfn> is a |
| 817 |
|
|
subtree in an XML document, the subtree having as its root |
| 818 |
|
|
<!-- XXX better word |
| 819 |
|
|
than root? --> node an <code><a |
| 820 |
|
|
href="#xbl0">xbl</a></code> element in the XBL namespace, which is used |
| 821 |
|
|
to define bindings. XBL subtrees can stand alone in <a |
| 822 |
|
|
href="#xbl-document" title="XBL document">XBL documents</a>, or can be |
| 823 |
|
|
included in <a href="#non-xbl" title="non-XBL document">non-XBL |
| 824 |
|
|
documents</a>.</p> |
| 825 |
|
|
|
| 826 |
|
|
<p>The term <dfn id=binding15>binding document</dfn> is used to mean |
| 827 |
|
|
either an <a href="#xbl-document">XBL document</a> or a <a |
| 828 |
|
|
href="#non-xbl">non-XBL document</a> containing one or more <span |
| 829 |
|
|
title="XBL subtree">XBL subtrees</span>.</p> |
| 830 |
|
|
|
| 831 |
|
|
<div class=example id=date-example> |
| 832 |
|
|
<p>In the following XHTML example, the XBL subtree is the portion of the |
| 833 |
|
|
markup that is emphasized. It is in a non-XBL document, since the root |
| 834 |
|
|
element is an XHTML element.</p> |
| 835 |
|
|
|
| 836 |
|
|
<pre><html xmlns="http://www.w3.org/1999/xhtml"> |
| 837 |
|
|
<head> |
| 838 |
|
|
<title>Demo</title> |
| 839 |
|
|
<strong><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 840 |
|
|
<script><![CDATA[ |
| 841 |
|
|
function fmt(n) { |
| 842 |
|
|
if (n < 10) |
| 843 |
|
|
return "0" + n; |
| 844 |
|
|
else |
| 845 |
|
|
return n; |
| 846 |
|
|
} |
| 847 |
|
|
]]></script> |
| 848 |
|
|
<binding element=".date"> |
| 849 |
|
|
<implementation> |
| 850 |
|
|
({ |
| 851 |
|
|
xblBindingAttached: function() { |
| 852 |
|
|
var tm = /(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d) UTC$/.exec(this.boundElement.textContent); |
| 853 |
|
|
var date = new Date(); |
| 854 |
|
|
date.setUTCFullYear(parseInt(tm[1], 10)); |
| 855 |
|
|
date.setUTCMonth(parseInt(tm[2], 10) - 1); |
| 856 |
|
|
date.setUTCDate(parseInt(tm[3], 10)); |
| 857 |
|
|
date.setUTCHours(parseInt(tm[4], 10)); |
| 858 |
|
|
date.setUTCMinutes(parseInt(tm[5], 10)); |
| 859 |
|
|
date.setUTCSeconds(0); |
| 860 |
|
|
this.boundElement.textContent = date.getFullYear() + "-" + |
| 861 |
|
|
fmt(date.getMonth() + 1) + "-" + |
| 862 |
|
|
fmt(date.getDate()) + " " + |
| 863 |
|
|
fmt(date.getHours()) + ":" + |
| 864 |
|
|
fmt(date.getMinutes()) + " LT"; |
| 865 |
|
|
this.boundElement.title = "Adjusted to local time zone" |
| 866 |
|
|
}, |
| 867 |
|
|
}) |
| 868 |
|
|
</implementation> |
| 869 |
|
|
</binding> |
| 870 |
|
|
</xbl></strong> |
| 871 |
|
|
</head> |
| 872 |
|
|
<body> |
| 873 |
|
|
<h1>Demo</h1> |
| 874 |
|
|
<p class="date">2006-08-10 18:40 UTC</p> |
| 875 |
|
|
<p>...</p> |
| 876 |
|
|
</body> |
| 877 |
|
|
</html></pre> |
| 878 |
|
|
|
| 879 |
|
|
<p>(As an aside, the binding defined in this example causes elements with |
| 880 |
|
|
<code>class="date"</code> to have their content parsed into a UTC date |
| 881 |
|
|
and converted into a local time. The binding mutates the original DOM to |
| 882 |
|
|
do this, and it doesn't reflect any dynamic changes made to the |
| 883 |
|
|
element's content; there are better, albeit slightly more involved, ways |
| 884 |
|
|
of achieving the same effect that don't have these problems.)</p> |
| 885 |
|
|
</div> |
| 886 |
|
|
|
| 887 |
|
|
<p>A <dfn id=bound>bound element</dfn> is an XML or HTML element to which |
| 888 |
|
|
a binding has been applied.</p> |
| 889 |
|
|
|
| 890 |
|
|
<p class=example>In the <a href="#date-example">example above</a>, the |
| 891 |
|
|
first <code>p</code> element is the <em><a href="#bound">bound |
| 892 |
|
|
element</a></em>.</p> |
| 893 |
|
|
|
| 894 |
|
|
<p>A <dfn id=bound0>bound document</dfn> is an XML or HTML document |
| 895 |
|
|
containing one or more <a href="#bound" title="bound element">bound |
| 896 |
|
|
elements</a>.</p> |
| 897 |
|
|
|
| 898 |
|
|
<p class=example>In the <a href="#date-example">example at the top of this |
| 899 |
|
|
section</a>, the document is both the <em><a href="#binding15">binding |
| 900 |
|
|
document</a></em> (because it contains the definition of the binding), |
| 901 |
|
|
and the <em><a href="#bound0">bound document</a></em> (because it |
| 902 |
|
|
contains the affected <em><a href="#bound">bound element</a></em>). In |
| 903 |
|
|
the <a href="#intro-example">example in the introduction section</a>, the |
| 904 |
|
|
HTML file is the <em><a href="#bound0">bound document</a></em>, and the |
| 905 |
|
|
XBL file is the <em><a href="#binding15">binding document</a></em>.</p> |
| 906 |
|
|
|
| 907 |
|
|
<p>In this specification, the term <dfn id=in-error>in error</dfn>, |
| 908 |
|
|
typically used of an element or attribute, means that the element, |
| 909 |
|
|
attribute, or other construct is not conformant according to the rules of |
| 910 |
|
|
this specification. Rules for exactly how the construct must be treated |
| 911 |
|
|
when it is in error are always given when the term is used. Typically |
| 912 |
|
|
this will involve <dfn id=ignoring title=ignore>ignoring</dfn> the |
| 913 |
|
|
erroneous nodes, meaning the UA must, <em>for the purposes of XBL |
| 914 |
|
|
processing</em>, act as if those nodes were absent. UAs must not, |
| 915 |
|
|
however, remove such nodes from the DOM in order to ignore them, nor |
| 916 |
|
|
should it change what DOM interfaces those nodes implement. The nodes |
| 917 |
|
|
retain all their non-XBL semantics.</p> |
| 918 |
|
|
|
| 919 |
|
|
<p>UAs should report all errors to users, although they may do this in an |
| 920 |
|
|
unobtrusive way, for example in an error console.</p> |
| 921 |
|
|
|
| 922 |
|
|
<p>In addition to the error handling rules given in this specification, |
| 923 |
|
|
UAs may abort all processing when encountering an error.</p> |
| 924 |
|
|
|
| 925 |
|
|
<p class=note>Aborting is only likely to be a viable error handling |
| 926 |
|
|
mechanism in controlled environments, e.g. in conformance checkers. Web |
| 927 |
|
|
browsers are expected to use the error recovery mechanisms described in |
| 928 |
|
|
this specification, not abort.</p> |
| 929 |
|
|
|
| 930 |
|
|
<p>A <dfn id=correct title=correct>correct</dfn> element, attribute, |
| 931 |
|
|
value, or binding is one which is not <a href="#in-error">in error</a>.</p> |
| 932 |
|
|
|
| 933 |
|
|
<div class=example id=correct-vs-error-example> |
| 934 |
|
|
<p>The following sample XBL document is <a href="#in-error">in error</a> |
| 935 |
|
|
because the <code><a href="#script2">script</a></code> element in XBL is |
| 936 |
|
|
only allowed as a child of the <code><a href="#xbl0">xbl</a></code> |
| 937 |
|
|
element:</p> |
| 938 |
|
|
|
| 939 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 940 |
|
|
<binding id="demo"> |
| 941 |
|
|
<strong><script> |
| 942 |
|
|
// This example is <em><a href="#in-error">in error</a></em>. |
| 943 |
|
|
// You are not allowed to put a <code><a href="#script2">script</a></code> element inside |
| 944 |
|
|
// a <code><a href="#binding16">binding</a></code> element, only inside an <code><a href="#xbl0">xbl</a></code> element. |
| 945 |
|
|
// This is because scripts evaluate in the scope of the |
| 946 |
|
|
// entire XBL document, and are therefore not associated |
| 947 |
|
|
// with a particular binding. |
| 948 |
|
|
function life() { |
| 949 |
|
|
return 42; |
| 950 |
|
|
} |
| 951 |
|
|
</script></strong> |
| 952 |
|
|
</binding> |
| 953 |
|
|
</xbl></pre> |
| 954 |
|
|
|
| 955 |
|
|
<p>The correct way of doing this would be:</p> |
| 956 |
|
|
|
| 957 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 958 |
|
|
<script> |
| 959 |
|
|
// This example is <a href="#correct">correct</a>. |
| 960 |
|
|
function life() { |
| 961 |
|
|
return 42; |
| 962 |
|
|
} |
| 963 |
|
|
</script> |
| 964 |
|
|
<binding id="demo"> |
| 965 |
|
|
<!-- Now you can see that this binding actually does nothing. --> |
| 966 |
|
|
</binding> |
| 967 |
|
|
</xbl></pre> |
| 968 |
|
|
</div> |
| 969 |
|
|
|
| 970 |
|
|
<p>The term "<dfn id=semantics>semantics</dfn>" is used to refer to the |
| 971 |
|
|
<em>intrinsic meaning</em> or processing model of elements, attributes, |
| 972 |
|
|
events, and DOM interface members. Semantics are defined by |
| 973 |
|
|
specifications; for example, this specification defines the semantics of |
| 974 |
|
|
XBL elements.</p> |
| 975 |
|
|
|
| 976 |
|
|
<p>XBL elements are frequently referred to by just their local name in |
| 977 |
|
|
this specification. In real documents, they must be associated with the |
| 978 |
|
|
XBL namespace as per the rules given in the Namespaces in XML |
| 979 |
|
|
specification <a href="#refsXMLNS">[XMLNS]</a>.</p> |
| 980 |
|
|
|
| 981 |
|
|
<p>For convenience, elements and attributes from specific namespaces are |
| 982 |
|
|
sometimes referred to simply in the form <code>prefix:localname</code>, |
| 983 |
|
|
without explicitly stating which namespace the prefix is bound to. When |
| 984 |
|
|
this occurs, readers should assume the following prefix declarations are |
| 985 |
|
|
in scope:</p> |
| 986 |
|
|
|
| 987 |
|
|
<pre><!--xmlns="http://www.w3.org/ns/xbl" |
| 988 |
|
|
-->xmlns:xbl="http://www.w3.org/ns/xbl" |
| 989 |
|
|
xmlns:xforms="http://www.w3.org/2002/xforms" |
| 990 |
|
|
xmlns:xlink="http://www.w3.org/1999/xlink" |
| 991 |
|
|
xmlns:html="http://www.w3.org/1999/xhtml"</pre> |
| 992 |
|
|
|
| 993 |
|
|
<p>When this specification refers to <em>elements in a namespace</em>, it |
| 994 |
|
|
does not exclude elements in <em>no</em> namespace; the null namespace is |
| 995 |
|
|
considered a namespace like any other for the purposes of XBL processing.</p> |
| 996 |
|
|
|
| 997 |
|
|
<p>All element names, attribute names, and attribute values in XBL are |
| 998 |
|
|
case sensitive, with the exception of attribute values defined by other |
| 999 |
|
|
specifications (those have the sensitivity defined by those other |
| 1000 |
|
|
specifications).</p> |
| 1001 |
|
|
|
| 1002 |
|
|
<p>An <dfn id=xml-mime>XML MIME type</dfn> is <code>text/xml</code>, |
| 1003 |
|
|
<code>application/xml</code>, or any MIME type ending with the string |
| 1004 |
|
|
<code>+xml</code> (ignoring any MIME parameters).</p> |
| 1005 |
|
|
|
| 1006 |
|
|
<p>The terms "<dfn id=author>author style sheets</dfn>", "<dfn |
| 1007 |
|
|
id=user-style>user style sheets</dfn>", "<dfn id=user-agent>user agent |
| 1008 |
|
|
style sheets</dfn>", and "<dfn id=pseudo-element>pseudo-element</dfn>" |
| 1009 |
|
|
are used as defined by the CSS specifications. <a |
| 1010 |
|
|
href="#refsCSS21">[CSS21]</a></p> |
| 1011 |
|
|
|
| 1012 |
|
|
<p>The term "<dfn id=qname>QName</dfn>" is used as defined by the |
| 1013 |
|
|
Namespaces in XML specification. <a href="#refsXMLNS">[XMLNS]</a></p> |
| 1014 |
|
|
|
| 1015 |
|
|
<p>The term "<dfn id=view>view</dfn>" is used as defined by the DOM2 Views |
| 1016 |
|
|
specification. <a href="#refsDOM2VIEWS">[DOM2VIEWS]</a></p> |
| 1017 |
|
|
|
| 1018 |
|
|
<h3 id=conformance><span class=secno>1.4. </span>Conformance</h3> |
| 1019 |
|
|
|
| 1020 |
|
|
<p>As well as sections marked as non-normative, all diagrams, examples, |
| 1021 |
|
|
and notes in this specification are non-normative. Everything else in |
| 1022 |
|
|
this specification is normative.</p> |
| 1023 |
|
|
|
| 1024 |
|
|
<p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", |
| 1025 |
|
|
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the |
| 1026 |
|
|
normative parts of this document are to be interpreted as described in |
| 1027 |
|
|
RFC2119. For readability, these words do not appear in all uppercase |
| 1028 |
|
|
letters in this specification. <a href="#refsRFC2119">[RFC2119]</a></p> |
| 1029 |
|
|
|
| 1030 |
|
|
<p>There are two classes of products that can claim conformance to this |
| 1031 |
|
|
implementation: <a href="#xbl-subtree">XBL subtrees</a>, and <a |
| 1032 |
|
|
href="#xbl-user">XBL user agents</a>.</p> |
| 1033 |
|
|
|
| 1034 |
|
|
<p><a href="#xbl-subtree">XBL subtrees</a> must satisfy the constraints |
| 1035 |
|
|
described in this specification in order to be considered conformant.</p> |
| 1036 |
|
|
|
| 1037 |
|
|
<p>Products that generate XBL subtrees cannot claim conformance to this |
| 1038 |
|
|
specification, though they can claim to only produce XBL subtrees that |
| 1039 |
|
|
themselves are conformant to this specification.</p> |
| 1040 |
|
|
|
| 1041 |
|
|
<p><a href="#xbl-user">XBL user agents</a> must behave as described by |
| 1042 |
|
|
this specification in order to be considered conformant, even when faced |
| 1043 |
|
|
with non-conformant XBL subtrees.</p> |
| 1044 |
|
|
|
| 1045 |
|
|
<p>User agents may optimize any algorithm given in this specification, so |
| 1046 |
|
|
long as the end result is indistinguishable from the result that would be |
| 1047 |
|
|
obtained by the specification's algorithms. (The algorithms in this |
| 1048 |
|
|
specification are generally written with more concern for clarity than |
| 1049 |
|
|
over efficiency.)</p> |
| 1050 |
|
|
|
| 1051 |
|
|
<p id=dom-basis>This specification is defined in terms of the DOM. The |
| 1052 |
|
|
language in this specification assumes that the user agent expands all |
| 1053 |
|
|
entity references, and therefore does not include entity reference nodes |
| 1054 |
|
|
in the DOM. If user agents do include entity reference nodes in the DOM, |
| 1055 |
|
|
then user agents must handle them as if they were replaced by their DOM |
| 1056 |
|
|
replacement values when implementing this specification.</p> |
| 1057 |
|
|
|
| 1058 |
|
|
<p class=example>For example, if a requirement talks about an element's |
| 1059 |
|
|
child text nodes, then any text nodes that are children of an entity |
| 1060 |
|
|
reference that is a child of that element would be used as well.</p> |
| 1061 |
|
|
|
| 1062 |
|
|
<h4 id=error><span class=secno>1.4.1. </span>Error Handling</h4> |
| 1063 |
|
|
|
| 1064 |
|
|
<p>This specification describes the rules for processing of XBL elements |
| 1065 |
|
|
and related features, whether they are used in a conformant manner or |
| 1066 |
|
|
not. Conformant implementations, therefore, will interoperably handle any |
| 1067 |
|
|
content, whether valid or not.</p> |
| 1068 |
|
|
|
| 1069 |
|
|
<h4 id=attributes><span class=secno>1.4.2. </span><dfn id=attributes21 |
| 1070 |
|
|
title=selector>Attributes Containing Selectors</dfn></h4> |
| 1071 |
|
|
|
| 1072 |
|
|
<p>The <code title=attr-binding-element><a |
| 1073 |
|
|
href="#element">element</a></code> attribute of the <code><a |
| 1074 |
|
|
href="#binding16">binding</a></code> element and the <code |
| 1075 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 1076 |
|
|
attribute of the <code><a href="#content0">content</a></code> element, if |
| 1077 |
|
|
specified, must have their values parsed according to the rules in the |
| 1078 |
|
|
Selectors specification. <a href="#refsSELECTORS">[SELECTORS]</a></p> |
| 1079 |
|
|
|
| 1080 |
|
|
<p class=note>This specification does not specify what level of Selectors |
| 1081 |
|
|
support is required.</p> |
| 1082 |
|
|
|
| 1083 |
|
|
<p>Namespace prefixes can be used with selectors. In XBL attributes that |
| 1084 |
|
|
take selectors, the namespace prefixes that may be used are the prefixes |
| 1085 |
|
|
that are in scope using the <code>xmlns:*</code> syntax. User agents must |
| 1086 |
|
|
use the XML namespace prefixes in scope on the attribute's element when |
| 1087 |
|
|
parsing selectors with namespace prefixes. The default namespace in |
| 1088 |
|
|
selectors in XBL attributes is always unbound. <a |
| 1089 |
|
|
href="#refsXMLNS">[XMLNS]</a></p> |
| 1090 |
|
|
|
| 1091 |
|
|
<p class=note>The "xml" prefix is defined to always be declared (and bound |
| 1092 |
|
|
to the <code>http://www.w3.org/XML/1998/namespace</code> namespace), as |
| 1093 |
|
|
is the "xmlns" prefix (which is bound to |
| 1094 |
|
|
<code>http://www.w3.org/2000/xmlns/</code>).</p> |
| 1095 |
|
|
|
| 1096 |
|
|
<p>Selectors are case-insensitive, but namespace prefixes are |
| 1097 |
|
|
case-sensitive. Thus, there could be multiple namespace prefixes declared |
| 1098 |
|
|
that match a particular namespace prefix as used in a selector. User |
| 1099 |
|
|
agents must act as if all namespace prefixes in scope were lexically |
| 1100 |
|
|
sorted by Unicode codepoint, with the first namespace prefix of each |
| 1101 |
|
|
group of namespace prefixes differing only by case (using case folding as |
| 1102 |
|
|
defined by Unicode) being the one assumed to be in scope for the purposes |
| 1103 |
|
|
of selector matching. <a href="#refsUNICODE">[UNICODE]</a></p> |
| 1104 |
|
|
|
| 1105 |
|
|
<div class=example id=selectors-example> |
| 1106 |
|
|
<p>The following excerpt from an XBL document defines a binding that is |
| 1107 |
|
|
bound to elements declaring links (e.g. the <code title="">a</code> |
| 1108 |
|
|
element in HTML).</p> |
| 1109 |
|
|
|
| 1110 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1111 |
|
|
<binding element=":link, :visited"> |
| 1112 |
|
|
... |
| 1113 |
|
|
</binding> |
| 1114 |
|
|
</xbl></pre> |
| 1115 |
|
|
|
| 1116 |
|
|
<p>The following excerpt defines a binding bound to any element in the |
| 1117 |
|
|
<code>http://example.com/</code> namespace that is the child of an |
| 1118 |
|
|
element in the <code>http://www.example.net/</code> namespace with the |
| 1119 |
|
|
name <code>parent</code>. (Note that the <code>></code> character |
| 1120 |
|
|
does not have to be escaped.)</p> |
| 1121 |
|
|
|
| 1122 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 1123 |
|
|
xmlns:eg1="http://www.example.net/" |
| 1124 |
|
|
xmlns:eg2="http://example.com/"> |
| 1125 |
|
|
<binding element="eg1|parent > eg2|*"> |
| 1126 |
|
|
... |
| 1127 |
|
|
</binding> |
| 1128 |
|
|
</xbl></pre> |
| 1129 |
|
|
|
| 1130 |
|
|
<p>Finally this third example defines a binding that matches elements |
| 1131 |
|
|
with the name <code>blockquote</code>, regardless of what namespace they |
| 1132 |
|
|
are in. If it is known that the binding document is only ever going to |
| 1133 |
|
|
be used from documents that use one namespace, for example if the |
| 1134 |
|
|
bindings are always to be imported into HTML documents, then it is |
| 1135 |
|
|
easier to just specify the local name (as in this example) and ignore |
| 1136 |
|
|
the namespaces.</p> |
| 1137 |
|
|
|
| 1138 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1139 |
|
|
<binding element="blockquote"> |
| 1140 |
|
|
... |
| 1141 |
|
|
</binding> |
| 1142 |
|
|
</xbl></pre> |
| 1143 |
|
|
</div> |
| 1144 |
|
|
|
| 1145 |
|
|
<h4 id=attributes0><span class=secno>1.4.3. </span><dfn id=attributes22 |
| 1146 |
|
|
title=space-separated>Attributes Containing Space-Separated Values</dfn></h4> |
| 1147 |
|
|
|
| 1148 |
|
|
<p>Some attributes are defined as taking space-separated values. The list |
| 1149 |
|
|
of values for such attributes must be obtained by taking the attribute's |
| 1150 |
|
|
value, replacing any sequences of U+0009, U+000A, U+000D, and U+0020 |
| 1151 |
|
|
characters (in any order) with a single U+0020 SPACE character, dropping |
| 1152 |
|
|
any leading or trailing U+0020 SPACE character, and then chopping the |
| 1153 |
|
|
resulting string at each occurrence of a U+0020 character, dropping that |
| 1154 |
|
|
character in the process.</p> |
| 1155 |
|
|
|
| 1156 |
|
|
<p>A space-separated attribute whose value is the empty string, or which |
| 1157 |
|
|
consists of only U+0009, U+000A, U+000D, and U+0020 characters, has no |
| 1158 |
|
|
values.</p> |
| 1159 |
|
|
|
| 1160 |
|
|
<div class=example id=space-separated-example> |
| 1161 |
|
|
<p>In the attribute <code>button="1 2"</code>, the values are "1" and |
| 1162 |
|
|
"2".</p> |
| 1163 |
|
|
|
| 1164 |
|
|
<p>In the attribute |
| 1165 |
|
|
<code>class=" key - note - rocks"</code>, |
| 1166 |
|
|
there are five keywords: "key", "note", "rocks", and two occurrences of |
| 1167 |
|
|
the single-character keyword "-".</p> |
| 1168 |
|
|
</div> |
| 1169 |
|
|
|
| 1170 |
|
|
<h4 id=attributes1><span class=secno>1.4.4. </span><dfn id=attributes23 |
| 1171 |
|
|
title="valid MIME type">Attributes Containing MIME Types</dfn></h4> |
| 1172 |
|
|
|
| 1173 |
|
|
<p>Some attributes are defined as containing MIME types. A valid MIME type |
| 1174 |
|
|
is one that matches the production for <code |
| 1175 |
|
|
title="">valid-MIME-type</code> in the following EBNF:</p> |
| 1176 |
|
|
|
| 1177 |
|
|
<pre>valid-MIME-type := type "/" subtype *(";" parameter)</pre> |
| 1178 |
|
|
|
| 1179 |
|
|
<p>...where the <code title="">type</code>, <code title="">subtype</code>, |
| 1180 |
|
|
and <code title="">parameter</code> tokens are those defined in RFC 2045. |
| 1181 |
|
|
<a href="#refsRFC2045">[RFC2045]</a></p> |
| 1182 |
|
|
|
| 1183 |
|
|
<h4 id=attributes2><span class=secno>1.4.5. </span><dfn id=attributes24 |
| 1184 |
|
|
title=URI>Attributes Containing URIs</dfn></h4> |
| 1185 |
|
|
|
| 1186 |
|
|
<p>Some attributes, pseudo-attributes, and method arguments are defined as |
| 1187 |
|
|
specifying URIs. Such attributes must have values that match the <code |
| 1188 |
|
|
title="">URI</code> token of RFC 3986 or the <code title="">IRI</code> |
| 1189 |
|
|
token of RFC 3987. If they do not, they are <a href="#in-error">in |
| 1190 |
|
|
error</a> (though the processing of erroneous URIs varies depending on |
| 1191 |
|
|
the context). <a href="#refsRFC3986">[RFC3986]</a> <a |
| 1192 |
|
|
href="#refsRFC3987">[RFC3987]</a></p> |
| 1193 |
|
|
|
| 1194 |
|
|
<h4 id=attributes3><span class=secno>1.4.6. </span>Attributes Containing |
| 1195 |
|
|
Keywords</h4> |
| 1196 |
|
|
|
| 1197 |
|
|
<p>Certain attributes are defined as requiring certain values, e.g. <code |
| 1198 |
|
|
title="">true</code> or <code title="">false</code>. For such attributes, |
| 1199 |
|
|
the values must be specified exactly, in the case given in this |
| 1200 |
|
|
specification, and with no leading or trailing whitespace. |
| 1201 |
|
|
Implementations must only perform literal comparisons, and must not use |
| 1202 |
|
|
case-insensitive comparisons nor trim attribute values before comparison.</p> |
| 1203 |
|
|
|
| 1204 |
|
|
<h4 id=extension><span class=secno>1.4.7. </span>Extension Mechanisms</h4> |
| 1205 |
|
|
|
| 1206 |
|
|
<p>XBL2 does not have an extension mechanism; implementations that |
| 1207 |
|
|
recognize elements in the XBL namespace that aren't part of this |
| 1208 |
|
|
specification, or who recognise attributes that have no namespace, that |
| 1209 |
|
|
are on elements in the XBL namespace, and that aren't part of this |
| 1210 |
|
|
specification, are non-conforming. If UAs support features in other |
| 1211 |
|
|
namespaces that affect the XBL processing model in a way that contradicts |
| 1212 |
|
|
this specification, then they are not conforming either.</p> |
| 1213 |
|
|
|
| 1214 |
|
|
<h4 id=feature><span class=secno>1.4.8. </span>Feature Strings for the DOM |
| 1215 |
|
|
and SVG</h4> |
| 1216 |
|
|
|
| 1217 |
|
|
<p>XBL2 user agents must recognize the string "XBL" as being a DOM feature |
| 1218 |
|
|
corresponding to support of XBL2 and its corresponding DOM APIs. Support |
| 1219 |
|
|
for this specification must be treated as support for versions "1.0" and |
| 1220 |
|
|
"2.0" of the "XBL" feature in terms of versions for the <code |
| 1221 |
|
|
title="">hasFeature()</code> DOM Core method.</p> |
| 1222 |
|
|
|
| 1223 |
|
|
<p>XBL2 user agents that also implement SVG must recognize the following |
| 1224 |
|
|
string as being a language extension URI for the purposes of SVG <code |
| 1225 |
|
|
title="">requiredExtensions</code> evaluation: |
| 1226 |
|
|
<code>http://www.w3.org/ns/xbl#v2</code></p> |
| 1227 |
|
|
|
| 1228 |
|
|
<h3 id=security><span class=secno>1.5. </span>Security Concerns</h3> |
| 1229 |
|
|
|
| 1230 |
|
|
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span></p> |
| 1231 |
|
|
|
| 1232 |
|
|
<p>XBL raises a number of security concerns.</p> |
| 1233 |
|
|
|
| 1234 |
|
|
<p><strong>Data theft</strong>: A naïve implementation of XBL would |
| 1235 |
|
|
allow any document to bind to bindings defined in any other document, and |
| 1236 |
|
|
(since referencing a binding allows full access to that binding |
| 1237 |
|
|
document's DOM) thereby allow access to any remote file, including those |
| 1238 |
|
|
on intranet sites or on authenticated extranet sites.</p> |
| 1239 |
|
|
|
| 1240 |
|
|
<p>XBL itself does not do anything to prevent this. However, it is |
| 1241 |
|
|
strongly suggested that an access control mechanism (such as that |
| 1242 |
|
|
described in <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a>) be used to |
| 1243 |
|
|
prevent such cross-domain accesses unless the remote site has allowed |
| 1244 |
|
|
accesses.</p> |
| 1245 |
|
|
|
| 1246 |
|
|
<p><strong>Privilege escalation</strong>: In conjunction with data theft, |
| 1247 |
|
|
there is the concern that a page could bind to a binding document on a |
| 1248 |
|
|
remote site, and then use the privileges of that site to obtain further |
| 1249 |
|
|
information. XBL prevents this by requiring that the bindings all run in |
| 1250 |
|
|
the security context of the <em><a href="#bound0">bound |
| 1251 |
|
|
document</a></em>, so that accessing a remote binding document does not |
| 1252 |
|
|
provide the bound document with any extra privileges on the remote |
| 1253 |
|
|
domain.</p> |
| 1254 |
|
|
|
| 1255 |
|
|
<p><strong>Cookie theft</strong>: Related to privilege escalation is the |
| 1256 |
|
|
risk that once an access-controlled binding document hosted on a remote |
| 1257 |
|
|
site has been loaded, authentication information stored in cookies for |
| 1258 |
|
|
that domain would become accessible to the bound document. XBL prevents |
| 1259 |
|
|
this by requiring that the <code>cookie</code> attribute on the |
| 1260 |
|
|
<code>DocumentWindow</code> interface be set to null.</p> |
| 1261 |
|
|
|
| 1262 |
|
|
<p><strong>Secure bindings</strong>: Using XBL for bindings that need |
| 1263 |
|
|
access to the local filesystem, e.g. for implementing File Upload form |
| 1264 |
|
|
controls, is not yet handled by this specification. However, a future |
| 1265 |
|
|
version will provide a secure way to define an XBL binding that can be |
| 1266 |
|
|
used to implement privileged mechanisms that can then be used by other |
| 1267 |
|
|
bindings to provide such controls.</p> |
| 1268 |
|
|
|
| 1269 |
|
|
<h2 id=xbl-elements><span class=secno>2. </span>XBL Elements</h2> |
| 1270 |
|
|
|
| 1271 |
|
|
<p>The start of any XBL subtree is an <code><a href="#xbl0">xbl</a></code> |
| 1272 |
|
|
element, which is described below.</p> |
| 1273 |
|
|
|
| 1274 |
|
|
<p>When an XBL element is found inside an element other than those listed |
| 1275 |
|
|
under the "Expected contexts" list in the definitions below, it is <a |
| 1276 |
|
|
href="#in-error">in error</a>. When an XBL element has a child node that |
| 1277 |
|
|
does not satisfy the "Expected children" list in its definition (for |
| 1278 |
|
|
instance because it is the wrong node type, wrong element type, or |
| 1279 |
|
|
because too many elements of its type preceded it), the <em>child</em> is |
| 1280 |
|
|
<a href="#in-error">in error</a>. In both cases, being <a |
| 1281 |
|
|
href="#in-error">in error</a> means that the UA must, for the purposes of |
| 1282 |
|
|
XBL evaluation, treat the XBL subtree as it would if the erroneous node |
| 1283 |
|
|
and all its descendants were not present in the DOM.</p> |
| 1284 |
|
|
|
| 1285 |
|
|
<p>However, non-XBL elements retain their semantics, even when considered |
| 1286 |
|
|
to be <a href="#in-error">in error</a> for the purposes of XBL.</p> |
| 1287 |
|
|
|
| 1288 |
|
|
<p>Regardless of the requirements of the last few paragraphs and of the |
| 1289 |
|
|
"expected children" lines, comment nodes, and text and CDATA nodes |
| 1290 |
|
|
containing only whitespace characters, may always be given as children of |
| 1291 |
|
|
XBL elements.</p> |
| 1292 |
|
|
|
| 1293 |
|
|
<p>For cases where attributes on XBL elements do not conform to this |
| 1294 |
|
|
specification or (for namespaced attributes) to another specification, |
| 1295 |
|
|
and for cases where attributes in the XBL namespace are found on elements |
| 1296 |
|
|
other than those listed as their "Expected element" in the definitions |
| 1297 |
|
|
below, the error handling is similar: the attributes must be considered |
| 1298 |
|
|
to be <a href="#in-error">in error</a> and the UA must <a |
| 1299 |
|
|
href="#ignoring">ignore</a> them, meaning that the presence of these |
| 1300 |
|
|
non-conforming attributes in no way affects the XBL processing.</p> |
| 1301 |
|
|
|
| 1302 |
|
|
<p>Further error handling rules for more specific cases are given where |
| 1303 |
|
|
appropriate.</p> |
| 1304 |
|
|
|
| 1305 |
|
|
<p>XBL user agents that support CSS should act as if they had the |
| 1306 |
|
|
following rules in their UA style sheet:</p> |
| 1307 |
|
|
|
| 1308 |
|
|
<pre>@namespace xbl url(http://www.w3.org/ns/xbl); |
| 1309 |
|
|
xbl|* { display: none; } |
| 1310 |
|
|
xbl|div { display: block; } |
| 1311 |
|
|
</pre> |
| 1312 |
|
|
|
| 1313 |
|
|
<p>XBL user agents that do not support CSS should not render the XBL |
| 1314 |
|
|
elements other than the <code><a href="#div0">div</a></code> element, |
| 1315 |
|
|
which they should render as a paragraph-like element.</p> |
| 1316 |
|
|
|
| 1317 |
|
|
<p class=note>The following sections describe the <em>content model</em> |
| 1318 |
|
|
of XBL elements, but not their actual processing model. The processing |
| 1319 |
|
|
model for XBL is described in later sections.</p> |
| 1320 |
|
|
|
| 1321 |
|
|
<h3 id=the-xbl><span class=secno>2.1. </span>The <dfn |
| 1322 |
|
|
id=xbl0><code>xbl</code></dfn> Element</h3> |
| 1323 |
|
|
|
| 1324 |
|
|
<dl> |
| 1325 |
|
|
<dt>Expected contexts: |
| 1326 |
|
|
|
| 1327 |
|
|
<dd>In an <a href="#xbl-document">XBL document</a>, none (this is the |
| 1328 |
|
|
root element). |
| 1329 |
|
|
|
| 1330 |
|
|
<dd>In a <a href="#non-xbl">non-XBL document</a>, any non-XBL element |
| 1331 |
|
|
whose specification allows the <code><a href="#xbl0">xbl</a></code> |
| 1332 |
|
|
element as a child. |
| 1333 |
|
|
|
| 1334 |
|
|
<dt>Expected children (in any order): |
| 1335 |
|
|
|
| 1336 |
|
|
<dd><code><a href="#binding16">binding</a></code>: zero or more. |
| 1337 |
|
|
|
| 1338 |
|
|
<dd><code><a href="#script2">script</a></code>: zero or more. |
| 1339 |
|
|
|
| 1340 |
|
|
<dd>Any non-XBL element. |
| 1341 |
|
|
</dl> |
| 1342 |
|
|
|
| 1343 |
|
|
<p class=note>The <code><a href="#xbl0">xbl</a></code> element is the root |
| 1344 |
|
|
element of all XBL subtrees.</p> |
| 1345 |
|
|
|
| 1346 |
|
|
<h4 class="no-toc no-num" id=attributes4>Attributes</h4> |
| 1347 |
|
|
|
| 1348 |
|
|
<dl> |
| 1349 |
|
|
<dt><dfn id=id0 title=attr-xbl-id>id</dfn> |
| 1350 |
|
|
|
| 1351 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 1352 |
|
|
|
| 1353 |
|
|
<dt><dfn id=script-type title=attr-xbl-script-type>script-type</dfn> |
| 1354 |
|
|
|
| 1355 |
|
|
<dd>The <code title=attr-xbl-script-type><a |
| 1356 |
|
|
href="#script-type">script-type</a></code> attribute specifies the MIME |
| 1357 |
|
|
type of the scripting language used by all bindings and XBL script |
| 1358 |
|
|
blocks in the XBL subtree. The value must be a <a |
| 1359 |
|
|
href="#attributes23">valid MIME type</a>. If the attribute is not |
| 1360 |
|
|
specified, the default language is ECMAScript<!-- XXX MIME type? |
| 1361 |
|
|
-->. |
| 1362 |
|
|
<a href="#refsECMA262">[ECMA262]</a> |
| 1363 |
|
|
|
| 1364 |
|
|
<dt><dfn id=style-type title=attr-xbl-style-type>style-type</dfn> |
| 1365 |
|
|
|
| 1366 |
|
|
<dd>The <code title=attr-xbl-style-type><a |
| 1367 |
|
|
href="#style-type">style-type</a></code> attribute specifies the MIME |
| 1368 |
|
|
type of the styling language used by all bindings and XBL style blocks |
| 1369 |
|
|
in the XBL subtree. The value must be a <a href="#attributes23">valid |
| 1370 |
|
|
MIME type</a>. If the attribute is not specified, the default language |
| 1371 |
|
|
is CSS (<code class=mimetype>text/css</code>). |
| 1372 |
|
|
</dl> |
| 1373 |
|
|
|
| 1374 |
|
|
<p>UAs must consider any <code><a href="#xbl0">xbl</a></code> elements |
| 1375 |
|
|
that have another <code><a href="#xbl0">xbl</a></code> element as an |
| 1376 |
|
|
ancestor as being <a href="#in-error">in error</a> and must then <a |
| 1377 |
|
|
href="#ignoring">ignore</a> them, meaning those elements must never be |
| 1378 |
|
|
considered to declare any bindings.</p> |
| 1379 |
|
|
|
| 1380 |
|
|
<p class=example>For example, conforming UAs will never bind elements to |
| 1381 |
|
|
bindings defined by <code><a href="#binding16">binding</a></code> |
| 1382 |
|
|
elements that have two <code><a href="#xbl0">xbl</a></code> ancestors.</p> |
| 1383 |
|
|
|
| 1384 |
|
|
<p>Similarly, XBL elements (other than the <code><a |
| 1385 |
|
|
href="#xbl0">xbl</a></code> element itself) that do not have a <a |
| 1386 |
|
|
href="#correct">correct</a> <code><a href="#xbl0">xbl</a></code> element |
| 1387 |
|
|
as an ancestor are <a href="#in-error">in error</a> too, and UAs must <a |
| 1388 |
|
|
href="#ignoring">ignore</a> them.</p> |
| 1389 |
|
|
|
| 1390 |
|
|
<p class=example>For example, conformant UAs will never bind elements to |
| 1391 |
|
|
bindings defined by <code><a href="#binding16">binding</a></code> |
| 1392 |
|
|
elements that have no <code><a href="#xbl0">xbl</a></code> ancestors at |
| 1393 |
|
|
all.</p> |
| 1394 |
|
|
|
| 1395 |
|
|
<p>The same does not apply to the <code title=attr-xbl-style-type><a |
| 1396 |
|
|
href="#style-type">style-type</a></code> and <code |
| 1397 |
|
|
title=attr-xbl-script-type><a href="#script-type">script-type</a></code> |
| 1398 |
|
|
attributes. If the UA does not support the specified styling language (or |
| 1399 |
|
|
has styling disabled), it must still apply bindings as appropriate; only |
| 1400 |
|
|
<code><a href="#style2">style</a></code> blocks must be ignored. |
| 1401 |
|
|
Similarly, if the UA does not support the specified scripting language |
| 1402 |
|
|
(or has scripting disabled), it must still apply bindings as appropriate; |
| 1403 |
|
|
only <code><a href="#script2">script</a></code>, <code><a |
| 1404 |
|
|
href="#handler0">handler</a></code> and <code><a |
| 1405 |
|
|
href="#implementation0">implementation</a></code> sections must be |
| 1406 |
|
|
ignored.</p> |
| 1407 |
|
|
|
| 1408 |
|
|
<p class=note>The empty string is not a special value for these |
| 1409 |
|
|
attributes. Setting the <code title=attr-xbl-style-type><a |
| 1410 |
|
|
href="#style-type">style-type</a></code> attribute to the empty string, |
| 1411 |
|
|
e.g., will result in all <code><a href="#style2">style</a></code> blocks |
| 1412 |
|
|
being ignored, since the empty string is not a valid MIME type that the |
| 1413 |
|
|
UA supports.</p> |
| 1414 |
|
|
|
| 1415 |
|
|
<div class=example id=xbl-element-example> |
| 1416 |
|
|
<p>The following document defines two bindings, one using Perl as the |
| 1417 |
|
|
scripting language and the other using JavaScript. The second one |
| 1418 |
|
|
extends the first one. (This example assumes that |
| 1419 |
|
|
<code>text/x-perl</code> refers to Perl. Note that this specification |
| 1420 |
|
|
doesn't actually define how Perl-based bindings are to be supported by |
| 1421 |
|
|
the UA; the code below assumes that an <code><a |
| 1422 |
|
|
href="#implementation0">implementation</a></code> element takes an |
| 1423 |
|
|
anonymous Perl package and blesses a hash to that package for each |
| 1424 |
|
|
binding, but this is nothing but conjecture.)</p> |
| 1425 |
|
|
|
| 1426 |
|
|
<pre><root> |
| 1427 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" |
| 1428 |
|
|
script-type="text/x-perl"> |
| 1429 |
|
|
<binding id="validityImplementor"> |
| 1430 |
|
|
<implementation> |
| 1431 |
|
|
use strict; |
| 1432 |
|
|
use vars qw(@ISA); |
| 1433 |
|
|
@ISA = qw(XBLImplementation); |
| 1434 |
|
|
sub validate { |
| 1435 |
|
|
my $self = shift; |
| 1436 |
|
|
my $data = $self->{boundElement}->getAttribute('value'); |
| 1437 |
|
|
my $pattern = $self->{boundElement}->getAttribute('pattern'); |
| 1438 |
|
|
return $data =~ m/^(?:$pattern)$/s; |
| 1439 |
|
|
} |
| 1440 |
|
|
</implementation> |
| 1441 |
|
|
</binding> |
| 1442 |
|
|
</xbl> |
| 1443 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1444 |
|
|
<binding id="validityClassifier" extends="#validityImplementor"> |
| 1445 |
|
|
<handlers> |
| 1446 |
|
|
<handler event="change"> |
| 1447 |
|
|
if (this.baseBinding.validate()) |
| 1448 |
|
|
this.boundElement.className = 'valid'; |
| 1449 |
|
|
else |
| 1450 |
|
|
this.boundElement.className = 'invalid'; |
| 1451 |
|
|
</handler> |
| 1452 |
|
|
</handlers> |
| 1453 |
|
|
</binding> |
| 1454 |
|
|
</xbl> |
| 1455 |
|
|
</root></pre> |
| 1456 |
|
|
|
| 1457 |
|
|
<p>(What these bindings do is somewhat boring. The first does nothing |
| 1458 |
|
|
except expose a "validate()" method that returns true if the contents of |
| 1459 |
|
|
the element's <code title="">value</code> attribute matches the regular |
| 1460 |
|
|
expression in the element's <code title="">pattern</code> attribute. The |
| 1461 |
|
|
second makes the binding call this method every time the <code |
| 1462 |
|
|
title="">change</code> event bubbles through the element, and changes |
| 1463 |
|
|
the element's <code title="">class</code> attribute based on the return |
| 1464 |
|
|
value.)</p> |
| 1465 |
|
|
</div> |
| 1466 |
|
|
|
| 1467 |
|
|
<h3 id=the-binding><span class=secno>2.2. </span>The <dfn |
| 1468 |
|
|
id=binding16><code>binding</code></dfn> Element</h3> |
| 1469 |
|
|
|
| 1470 |
|
|
<dl> |
| 1471 |
|
|
<dt>Expected context: |
| 1472 |
|
|
|
| 1473 |
|
|
<dd><code><a href="#xbl0">xbl</a></code> |
| 1474 |
|
|
|
| 1475 |
|
|
<dt>Expected children (in any order): |
| 1476 |
|
|
|
| 1477 |
|
|
<dd><code><a href="#implementation0">implementation</a></code>: zero or |
| 1478 |
|
|
one. |
| 1479 |
|
|
|
| 1480 |
|
|
<dd><code><a href="#template0">template</a></code>: zero or one. |
| 1481 |
|
|
|
| 1482 |
|
|
<dd><code><a href="#handlers0">handlers</a></code>: zero or one. |
| 1483 |
|
|
|
| 1484 |
|
|
<dd><code><a href="#resources1">resources</a></code>: zero or one. |
| 1485 |
|
|
|
| 1486 |
|
|
<dd>Any non-XBL element |
| 1487 |
|
|
</dl> |
| 1488 |
|
|
|
| 1489 |
|
|
<div class=note> |
| 1490 |
|
|
<p>The <code><a href="#binding16">binding</a></code> element describes a |
| 1491 |
|
|
single XBL binding that adds presentation and interactive behavior to |
| 1492 |
|
|
XML or HTML elements. Each binding has these optional components:</p> |
| 1493 |
|
|
|
| 1494 |
|
|
<p><em title=implementation><a href="#implementation0">Methods, |
| 1495 |
|
|
Properties, and Fields</a></em>: A binding can specify additional |
| 1496 |
|
|
methods that can be invoked on the element. It can also specify |
| 1497 |
|
|
additional properties and fields that can be retrieved or set on the |
| 1498 |
|
|
element. In this way the functionality of the bound element becomes |
| 1499 |
|
|
extensible. (See: <a href="#binding23">binding implementations</a>.)</p> |
| 1500 |
|
|
|
| 1501 |
|
|
<p><em><a href="#template0">Template</a></em>: The optional <code><a |
| 1502 |
|
|
href="#template0">template</a></code> defines the initial <em><a |
| 1503 |
|
|
href="#shadow5">shadow content</a></em> for the bound element.</p> |
| 1504 |
|
|
|
| 1505 |
|
|
<p><em title=handlers><a href="#handlers0">Behavior</a></em>: A binding |
| 1506 |
|
|
can define event listeners for various types of events. Some examples |
| 1507 |
|
|
are: UI events (e.g., key and mouse events) on the bound element or on |
| 1508 |
|
|
elements within the shadow content, and mutation events on the bound |
| 1509 |
|
|
element and its descendants. (See: <a href="#event11">event |
| 1510 |
|
|
handlers</a>.)</p> |
| 1511 |
|
|
|
| 1512 |
|
|
<p><em><a href="#resources1">Resources</a></em>: A binding can list style |
| 1513 |
|
|
sheets that are scoped to the bound element, and images, sounds, videos, |
| 1514 |
|
|
or other files that a user agent can pre-cache in order to improve |
| 1515 |
|
|
performance. (See: <a href="#binding22">binding style sheets</a>, |
| 1516 |
|
|
<span>prefetching resources</span>.)</p> |
| 1517 |
|
|
|
| 1518 |
|
|
<p>Bindings can act as an attachment mechanism, specifying a namespace |
| 1519 |
|
|
and local name of elements to associate with the given binding when the |
| 1520 |
|
|
binding is <span title=importing>imported</span>, using the <code |
| 1521 |
|
|
title=attr-binding-element><a href="#element">element</a></code> |
| 1522 |
|
|
attribute.</p> |
| 1523 |
|
|
</div> |
| 1524 |
|
|
|
| 1525 |
|
|
<p>In addition to the above, the <code><a |
| 1526 |
|
|
href="#binding16">binding</a></code> element's child nodes may include |
| 1527 |
|
|
any element outside the XBL namespace. These are handled as they would be |
| 1528 |
|
|
in any other context, and are <a href="#ignoring" |
| 1529 |
|
|
title=ignore>ignored</a> by the XBL processing model.</p> |
| 1530 |
|
|
|
| 1531 |
|
|
<h4 class="no-toc no-num" id=attributes5>Attributes</h4> |
| 1532 |
|
|
|
| 1533 |
|
|
<dl> |
| 1534 |
|
|
<dt><dfn id=id1 title=attr-binding-id>id</dfn> |
| 1535 |
|
|
|
| 1536 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 1537 |
|
|
|
| 1538 |
|
|
<dt><dfn id=extends title=attr-binding-extends>extends</dfn> |
| 1539 |
|
|
|
| 1540 |
|
|
<dd>The <code title=attr-binding-extends><a |
| 1541 |
|
|
href="#extends">extends</a></code> attribute is used to specify the <a |
| 1542 |
|
|
href="#attributes24">URI</a> of a binding that this binding inherits |
| 1543 |
|
|
from. (See: <a href="#interpretation1">interpretation of URIs to XBL |
| 1544 |
|
|
bindings</a>.) If the URI is <a href="#in-error">in error</a> or does |
| 1545 |
|
|
not refer to another binding, the UA must <a href="#ignoring">ignore</a> |
| 1546 |
|
|
it, meaning that this binding does not explicitly inherit from another |
| 1547 |
|
|
binding. (See: <a href="#explicit2">explicit inheritance</a>.) Only one |
| 1548 |
|
|
URI can be specified. |
| 1549 |
|
|
|
| 1550 |
|
|
<dt><dfn id=element title=attr-binding-element>element</dfn> |
| 1551 |
|
|
|
| 1552 |
|
|
<dd> |
| 1553 |
|
|
<p>This attribute, if specified, must contain a <a |
| 1554 |
|
|
href="#attributes21">selector</a>. All elements in the binding |
| 1555 |
|
|
document, and in any documents that <span title=importing>import</span> |
| 1556 |
|
|
the binding document, that <a href="#selectors1" title="selectors and |
| 1557 |
|
|
shadow scopes">match the given selector</a>, must be bound to the |
| 1558 |
|
|
binding defined by this <code><a href="#binding16">binding</a></code> |
| 1559 |
|
|
element. (The element's own shadow tree, if any, must not be taken into |
| 1560 |
|
|
account when determining if it matches a selector for the purposes of |
| 1561 |
|
|
this attribute.)</p> |
| 1562 |
|
|
|
| 1563 |
|
|
<p>If an <code title=attr-binding-element><a |
| 1564 |
|
|
href="#element">element</a></code> attribute contains an invalid |
| 1565 |
|
|
selector, it is <a href="#in-error">in error</a> and must be <a |
| 1566 |
|
|
href="#ignoring" title=ignore>ignored</a>, meaning that while the |
| 1567 |
|
|
binding is still parsed and may be referenced using other attachment |
| 1568 |
|
|
mechanisms, the binding is not attached to any element by its <code |
| 1569 |
|
|
title=attr-binding-element><a href="#element">element</a></code> |
| 1570 |
|
|
attribute, as if the attribute had simply been omitted.</p> |
| 1571 |
|
|
</dd> |
| 1572 |
|
|
<!-- |
| 1573 |
|
|
|
| 1574 |
|
|
"secure" - for secure bindings. These have no generated content, |
| 1575 |
|
|
no event handlers. Only an implementation. They execute in a |
| 1576 |
|
|
different scope. |
| 1577 |
|
|
|
| 1578 |
|
|
--> |
| 1579 |
|
|
</dl> |
| 1580 |
|
|
|
| 1581 |
|
|
<div class=note> |
| 1582 |
|
|
<p>The <code><a href="#binding16">binding</a></code> element defines a |
| 1583 |
|
|
presentation and behavior binding. It does not define an element's |
| 1584 |
|
|
semantics. If an element has no semantics when processed alone, then it |
| 1585 |
|
|
has no semantics when processed with XBL.</p> |
| 1586 |
|
|
|
| 1587 |
|
|
<p>Sending markup that does not have well-defined semantics over the |
| 1588 |
|
|
network is bad practice. XBL is intended to be used to augment the user |
| 1589 |
|
|
experience, for instance by providing better quality widgets or |
| 1590 |
|
|
enhancing aesthetics. If the document being sent is <em>unusable</em> |
| 1591 |
|
|
without XBL, then XBL is being abused.</p> |
| 1592 |
|
|
</div> |
| 1593 |
|
|
|
| 1594 |
|
|
<div class=example id=binding-element-example> |
| 1595 |
|
|
<p>This binding extends a binding defined in an external file. The |
| 1596 |
|
|
binding in the other file defines a <code title="">value</code> |
| 1597 |
|
|
property, and fires events when that property is changed. <em>This</em> |
| 1598 |
|
|
binding just implements a check box that all <code>checkbox</code> |
| 1599 |
|
|
elements in the <code>http://ui.example.com/</code> namespace will be |
| 1600 |
|
|
bound to.</p> |
| 1601 |
|
|
|
| 1602 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 1603 |
|
|
xmlns:ui="http://ui.example.com/"> |
| 1604 |
|
|
<binding element="ui|checkbox" id="checkbox" |
| 1605 |
|
|
extends="http://www.example.org/resources/ui-core.xml#valuedControl"> |
| 1606 |
|
|
<template> |
| 1607 |
|
|
<div id="wrapper"> |
| 1608 |
|
|
<div id="control"/> |
| 1609 |
|
|
<div id="label"><content/></div> |
| 1610 |
|
|
</div> |
| 1611 |
|
|
</template> |
| 1612 |
|
|
<resources> |
| 1613 |
|
|
<style> |
| 1614 |
|
|
#wrapper > div { display: inline-block; } |
| 1615 |
|
|
</style> |
| 1616 |
|
|
</resources> |
| 1617 |
|
|
<handlers> |
| 1618 |
|
|
<handler event="click" phase="default-action"> |
| 1619 |
|
|
if (this.baseBinding.value == 'on') |
| 1620 |
|
|
this.baseBinding.value = 'off'; |
| 1621 |
|
|
else |
| 1622 |
|
|
this.baseBinding.value = 'on'; |
| 1623 |
|
|
</handler> |
| 1624 |
|
|
<handler event="change" phase="target"> |
| 1625 |
|
|
if (this.baseBinding.value == 'on') |
| 1626 |
|
|
this.shadowTree.getElementById('control').textContent = '☑'; |
| 1627 |
|
|
else |
| 1628 |
|
|
this.shadowTree.getElementById('control').textContent = '☐'; |
| 1629 |
|
|
</handler> |
| 1630 |
|
|
</handlers> |
| 1631 |
|
|
</binding> |
| 1632 |
|
|
</xbl></pre> |
| 1633 |
|
|
</div> |
| 1634 |
|
|
|
| 1635 |
|
|
<h3 id=the-implementation><span class=secno>2.3. </span>The <dfn |
| 1636 |
|
|
id=implementation0><code>implementation</code></dfn> Element</h3> |
| 1637 |
|
|
|
| 1638 |
|
|
<dl> |
| 1639 |
|
|
<dt>Expected context: |
| 1640 |
|
|
|
| 1641 |
|
|
<dd><code><a href="#binding16">binding</a></code> |
| 1642 |
|
|
|
| 1643 |
|
|
<dt>Expected children: |
| 1644 |
|
|
|
| 1645 |
|
|
<dd>If the element has no <code title=attr-implementation-src><a |
| 1646 |
|
|
href="#src">src</a></code> attribute: depends on the scripting language. |
| 1647 |
|
|
|
| 1648 |
|
|
<dd>If the element does have a <code title=attr-implementation-src><a |
| 1649 |
|
|
href="#src">src</a></code> attribute: none. |
| 1650 |
|
|
</dl> |
| 1651 |
|
|
|
| 1652 |
|
|
<p class=note>The <code><a |
| 1653 |
|
|
href="#implementation0">implementation</a></code> element describes a set |
| 1654 |
|
|
of methods, properties, and fields that are attached to the bound |
| 1655 |
|
|
element. Once the binding is attached, these methods, properties, and |
| 1656 |
|
|
fields can be invoked directly from the bound element.</p> |
| 1657 |
|
|
|
| 1658 |
|
|
<p>The <code><a href="#implementation0">implementation</a></code> element, |
| 1659 |
|
|
if present, must either contain code in the language specified by the XBL |
| 1660 |
|
|
subtree's <code title=attr-xbl-script-type><a |
| 1661 |
|
|
href="#script-type">script-type</a></code> attribute, or have a <code |
| 1662 |
|
|
title=attr-implementation-src><a href="#src">src</a></code> attribute |
| 1663 |
|
|
that points to a resource containing code in the language specified by |
| 1664 |
|
|
the <code title=attr-xbl-script-type><a |
| 1665 |
|
|
href="#script-type">script-type</a></code> attribute. The syntax and |
| 1666 |
|
|
semantics of this code depend on the specific language. This |
| 1667 |
|
|
specification defines the semantics for <span title="ECMAScript binding |
| 1668 |
|
|
for XBL">ECMAScript implementations</span>. (See: <a |
| 1669 |
|
|
href="#binding23">binding implementations</a>.)</p> |
| 1670 |
|
|
|
| 1671 |
|
|
<h4 class="no-toc no-num" id=attributes6>Attributes</h4> |
| 1672 |
|
|
|
| 1673 |
|
|
<dl> |
| 1674 |
|
|
<dt><dfn id=id2 title=attr-implementation-id>id</dfn> |
| 1675 |
|
|
|
| 1676 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 1677 |
|
|
|
| 1678 |
|
|
<dt><dfn id=src title=attr-implementation-src>src</dfn> |
| 1679 |
|
|
|
| 1680 |
|
|
<dd>The <code title=attr-implementation-src><a href="#src">src</a></code> |
| 1681 |
|
|
attribute specifies the <a href="#attributes24">URI</a> to a resource of |
| 1682 |
|
|
the type given by the XBL subtree's <code title=attr-xbl-script-type><a |
| 1683 |
|
|
href="#script-type">script-type</a></code> attribute. If the attribute |
| 1684 |
|
|
is specified, the contents of the element must be ignored (even if the |
| 1685 |
|
|
resource could not be fetched or was of the wrong type). (See: <a |
| 1686 |
|
|
href="#binding23">binding implementations</a>.) |
| 1687 |
|
|
</dl> |
| 1688 |
|
|
|
| 1689 |
|
|
<p>If an <code><a href="#implementation0">implementation</a></code> |
| 1690 |
|
|
element is marked (via the <code title=attr-xbl-script-type><a |
| 1691 |
|
|
href="#script-type">script-type</a></code> attribute of the <code><a |
| 1692 |
|
|
href="#xbl0">xbl</a></code> element) as being in a language that the UA |
| 1693 |
|
|
does not support, then the UA must <a href="#ignoring">ignore</a> it. |
| 1694 |
|
|
Similarly, if the <code><a |
| 1695 |
|
|
href="#implementation0">implementation</a></code> element points (using |
| 1696 |
|
|
the <code title=attr-implementation-src><a href="#src">src</a></code> |
| 1697 |
|
|
attribute) to a resource that is either unavailable, or not of the type |
| 1698 |
|
|
specified by the <code title=attr-xbl-script-type><a |
| 1699 |
|
|
href="#script-type">script-type</a></code> attribute of the <code><a |
| 1700 |
|
|
href="#xbl0">xbl</a></code> element (or implied by its absence), then it |
| 1701 |
|
|
is <a href="#in-error">in error</a> and the UA must <a |
| 1702 |
|
|
href="#ignoring">ignore</a> it. In both cases, "ignoring it" means it |
| 1703 |
|
|
must not be used as an implementation definition for any binding.</p> |
| 1704 |
|
|
|
| 1705 |
|
|
<p>How UAs must handle nodes inside <code><a |
| 1706 |
|
|
href="#implementation0">implementation</a></code> elements depends on the |
| 1707 |
|
|
language used. (See: <a href="#loading6">loading and running scripts</a>, |
| 1708 |
|
|
<a href="#binding23">binding implementations</a>.)</p> |
| 1709 |
|
|
|
| 1710 |
|
|
<p><code><a href="#implementation0">implementation</a></code> blocks are |
| 1711 |
|
|
evaluated once, on first use. Changes to an <code><a |
| 1712 |
|
|
href="#implementation0">implementation</a></code> element or its contents |
| 1713 |
|
|
have no effect once the element has been evaluated. (See: <a |
| 1714 |
|
|
href="#binding23">binding implementations</a>.)</p> |
| 1715 |
|
|
<!-- |
| 1716 |
|
|
<p>User agents may support an additional attribute with a name of |
| 1717 |
|
|
the form <code><var>vendor</var>-binary</code> |
| 1718 |
|
|
(e.g. <code>moz-binary=""</code> or <code>khtml-binary=""</code>) |
| 1719 |
|
|
that contains information on native code implementations of the |
| 1720 |
|
|
binding, if necessary. Content using such an attribute is |
| 1721 |
|
|
non-conforming. (This feature is expected to be used in |
| 1722 |
|
|
vendor-specific environments, not on the Web, and guidance for the |
| 1723 |
|
|
name is provided only as an aid in preventing conflicts with future |
| 1724 |
|
|
versions of this specification.)</p> |
| 1725 |
|
|
--> |
| 1726 |
|
|
|
| 1727 |
|
|
<div class=example id=implementation-element-example> |
| 1728 |
|
|
<p>The following example shows a binding that defines a new method, two |
| 1729 |
|
|
new properties (one with a custom getter and setter, one without), an |
| 1730 |
|
|
internal field (used to back the property), and some hooks to initialize |
| 1731 |
|
|
the binding and to handle the bound element being inserted and removed |
| 1732 |
|
|
from the document. The binding applies to any element with the class |
| 1733 |
|
|
"demo" (in the files into which it is imported, that is).</p> |
| 1734 |
|
|
|
| 1735 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1736 |
|
|
<binding element=".demo"> |
| 1737 |
|
|
<implementation> |
| 1738 |
|
|
({ |
| 1739 |
|
|
add: function (op1, op2) { |
| 1740 |
|
|
return op1+op2; |
| 1741 |
|
|
}, |
| 1742 |
|
|
get memory() { |
| 1743 |
|
|
return this._memory.toString(); |
| 1744 |
|
|
}, |
| 1745 |
|
|
set memory(value) { |
| 1746 |
|
|
this._memory = parseInt(value, 10); |
| 1747 |
|
|
}, |
| 1748 |
|
|
xblBindingAttached: function() { |
| 1749 |
|
|
this._memory = 0; // internal property to back "memory" external property |
| 1750 |
|
|
this.external.state = 'initialized'; // external property |
| 1751 |
|
|
}, |
| 1752 |
|
|
xblEnteredDocument: function() { |
| 1753 |
|
|
this.external.state = 'in document'; |
| 1754 |
|
|
}, |
| 1755 |
|
|
xblLeftDocument: function() { |
| 1756 |
|
|
this.external.state = 'out of document'; |
| 1757 |
|
|
}, |
| 1758 |
|
|
}) |
| 1759 |
|
|
</implementation> |
| 1760 |
|
|
</binding> |
| 1761 |
|
|
</xbl></pre> |
| 1762 |
|
|
|
| 1763 |
|
|
<p class=note>The <code>get field() {}</code> and |
| 1764 |
|
|
<code>set field(syntax) {}</code> features are <a |
| 1765 |
|
|
href="http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Creating_New_Objects:Defining_Getters_and_Setters">part |
| 1766 |
|
|
of JavaScript 1.5</a> and will probably be in ECMAScript 4. The examples |
| 1767 |
|
|
in this specification assume an implementation that supports ECMAScript |
| 1768 |
|
|
4, but any language could be supported in real implementations.</p> |
| 1769 |
|
|
|
| 1770 |
|
|
<p>The following example shows how to refer to an external file for the |
| 1771 |
|
|
implementation of a binding. In this example, the handlers simply defer |
| 1772 |
|
|
to methods defined in that implementation, so that all the code is in |
| 1773 |
|
|
that file.</p> |
| 1774 |
|
|
|
| 1775 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1776 |
|
|
<binding id="demo"> |
| 1777 |
|
|
<implementation src="demo.js"/> |
| 1778 |
|
|
<handlers> |
| 1779 |
|
|
<handler event="click"> this.clicked(event); </handler> |
| 1780 |
|
|
<handler event="focus"> this.focused(event); </handler> |
| 1781 |
|
|
<handler event="blur"> this.blurred(event); </handler> |
| 1782 |
|
|
</handlers> |
| 1783 |
|
|
</binding> |
| 1784 |
|
|
</xbl></pre> |
| 1785 |
|
|
|
| 1786 |
|
|
<p>The <code>demo.js</code> file for this might look like this, to ensure |
| 1787 |
|
|
that the methods defined are in fact internal methods, not exposed on |
| 1788 |
|
|
the <a href="#external0">external object</a>:</p> |
| 1789 |
|
|
|
| 1790 |
|
|
<pre>({ |
| 1791 |
|
|
xblBindingAttached: function () { |
| 1792 |
|
|
this.clicked = function (event) { ... }; |
| 1793 |
|
|
this.focused = function (event) { ... }; |
| 1794 |
|
|
this.blurred = function (event) { ... }; |
| 1795 |
|
|
}, |
| 1796 |
|
|
// ... other methods and fields ... |
| 1797 |
|
|
})</pre> |
| 1798 |
|
|
</div> |
| 1799 |
|
|
|
| 1800 |
|
|
<h3 id=the-template><span class=secno>2.4. </span>The <dfn |
| 1801 |
|
|
id=template0><code>template</code></dfn> Element</h3> |
| 1802 |
|
|
|
| 1803 |
|
|
<dl> |
| 1804 |
|
|
<dt>Expected context: |
| 1805 |
|
|
|
| 1806 |
|
|
<dd><code><a href="#binding16">binding</a></code> |
| 1807 |
|
|
|
| 1808 |
|
|
<dt>Expected children: |
| 1809 |
|
|
|
| 1810 |
|
|
<dd>Anything. Of particular interest, the <code><a |
| 1811 |
|
|
href="#content0">content</a></code> and <code><a |
| 1812 |
|
|
href="#inherited0">inherited</a></code> elements may occur as |
| 1813 |
|
|
descendants, and non-XBL descendant elements may host <code |
| 1814 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> and <code |
| 1815 |
|
|
title=attr-pseudo><a href="#xblpseudo0">xbl:pseudo</a></code> |
| 1816 |
|
|
attributes. |
| 1817 |
|
|
</dl> |
| 1818 |
|
|
|
| 1819 |
|
|
<p class=note>The <code><a href="#template0">template</a></code> element |
| 1820 |
|
|
contains child nodes that can be in any namespace. When a binding is |
| 1821 |
|
|
attached, the <code><a href="#template0">template</a></code> element's |
| 1822 |
|
|
child nodes are cloned and attached to the bound document under the bound |
| 1823 |
|
|
element. Dynamic changes to the descendants of <code><a |
| 1824 |
|
|
href="#template0">template</a></code> elements are reflected in bindings. |
| 1825 |
|
|
(See: <a href="#shadow5">shadow content</a>.)</p> |
| 1826 |
|
|
|
| 1827 |
|
|
<h4 class="no-toc no-num" id=attributes7>Attributes</h4> |
| 1828 |
|
|
|
| 1829 |
|
|
<dl> |
| 1830 |
|
|
<dt><dfn id=id3 title=attr-template-id>id</dfn> |
| 1831 |
|
|
|
| 1832 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 1833 |
|
|
|
| 1834 |
|
|
<dt><dfn id=apply-author-sheets |
| 1835 |
|
|
title=attr-template-apply-author-sheets>apply-author-sheets</dfn> |
| 1836 |
|
|
|
| 1837 |
|
|
<dd>The <code title=attr-template-apply-author-sheets><a |
| 1838 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> attribute |
| 1839 |
|
|
indicates whether or not rules in <a href="#author">author style |
| 1840 |
|
|
sheets</a> associated with the bound element's document apply to the |
| 1841 |
|
|
shadow content generated by the binding. Its value must be either |
| 1842 |
|
|
<code>true</code> (indicating that they do) or <code>false</code> |
| 1843 |
|
|
(indicating that they do not). The default behavior, which is used when |
| 1844 |
|
|
the attribute is omitted or has a value other than the two allowed |
| 1845 |
|
|
values, is to not apply the bound document's <a href="#author">author |
| 1846 |
|
|
style sheets</a> (same as <code>false</code>). (See: <a |
| 1847 |
|
|
href="#binding22">binding style sheets</a>.) |
| 1848 |
|
|
|
| 1849 |
|
|
<dt><dfn id=allow-selectors-through |
| 1850 |
|
|
title=attr-template-allow-selectors-through>allow-selectors-through</dfn> |
| 1851 |
|
|
|
| 1852 |
|
|
<dd>The <code title=attr-template-allow-selectors-through><a |
| 1853 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code> |
| 1854 |
|
|
attribute indicates whether or not rules in CSS can <a |
| 1855 |
|
|
href="#selectors1" title="selectors and shadow scopes">cross scopes</a>. |
| 1856 |
|
|
Its value must be either <code>true</code> (indicating that they can) or |
| 1857 |
|
|
<code>false</code> (indicating that they cannot). The default behavior, |
| 1858 |
|
|
which is used when the attribute is omitted or has a value other than |
| 1859 |
|
|
the two allowed values, is to not let selectors cross scopes (same as |
| 1860 |
|
|
<code>false</code>). (See: <a href="#selectors1">selectors and shadow |
| 1861 |
|
|
scopes</a>.) |
| 1862 |
|
|
</dl> |
| 1863 |
|
|
|
| 1864 |
|
|
<p class=note>The semantics of non-XBL elements inside this element are |
| 1865 |
|
|
untouched, which can lead to unintuitive results. (See: <a |
| 1866 |
|
|
href="#shadow10">semantics of non-XBL elements in XBL contexts</a>.)</p> |
| 1867 |
|
|
|
| 1868 |
|
|
<div class=example id=template-element-example> |
| 1869 |
|
|
<p>The following binding defines a shadow tree that wraps the contents of |
| 1870 |
|
|
the bound element in four blocks. It uses the <code |
| 1871 |
|
|
title=attr-template-apply-author-sheets><a |
| 1872 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> attribute to |
| 1873 |
|
|
allow the bound document to style the nodes directly, and uses the <code |
| 1874 |
|
|
title=attr-template-allow-selectors-through><a |
| 1875 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code> |
| 1876 |
|
|
attribute to allow the bound document to pretend (for the purposes of |
| 1877 |
|
|
selector matching) that the shadow tree actually is descended from the |
| 1878 |
|
|
bound element.</p> |
| 1879 |
|
|
|
| 1880 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 1881 |
|
|
<binding id="wrapBy4"> |
| 1882 |
|
|
<template apply-author-sheets="true" allow-selectors-through="true"> |
| 1883 |
|
|
<div class="wrap1"> |
| 1884 |
|
|
<div class="wrap2"> |
| 1885 |
|
|
<div class="wrap3"> |
| 1886 |
|
|
<div class="wrap4"> |
| 1887 |
|
|
<content/> |
| 1888 |
|
|
</div> |
| 1889 |
|
|
</div> |
| 1890 |
|
|
</div> |
| 1891 |
|
|
</div> |
| 1892 |
|
|
</template> |
| 1893 |
|
|
</binding> |
| 1894 |
|
|
</xbl></pre> |
| 1895 |
|
|
|
| 1896 |
|
|
<p>Using this binding could take the following document:</p> |
| 1897 |
|
|
|
| 1898 |
|
|
<pre><html xmlns="http://www.w3.org/1999/xhtml"> |
| 1899 |
|
|
<head> |
| 1900 |
|
|
<title>Pretty Title</title> |
| 1901 |
|
|
<style> |
| 1902 |
|
|
h1 span { display: block; } |
| 1903 |
|
|
h1 { border: solid red; } |
| 1904 |
|
|
h1 .wrap1 { border: solid orange; } |
| 1905 |
|
|
h1 .wrap2 { border: solid yellow; } |
| 1906 |
|
|
h1 .wrap3 { border: solid green; } |
| 1907 |
|
|
h1 .wrap4 { border: solid blue; } |
| 1908 |
|
|
</style> |
| 1909 |
|
|
</head> |
| 1910 |
|
|
<body> |
| 1911 |
|
|
<h1> |
| 1912 |
|
|
<span class="wrap1"> |
| 1913 |
|
|
<span class="wrap2"> |
| 1914 |
|
|
<span class="wrap3"> |
| 1915 |
|
|
<span class="wrap4"> |
| 1916 |
|
|
Pretty Title |
| 1917 |
|
|
</span> |
| 1918 |
|
|
</span> |
| 1919 |
|
|
</span> |
| 1920 |
|
|
</span> |
| 1921 |
|
|
</h1> |
| 1922 |
|
|
... |
| 1923 |
|
|
</body> |
| 1924 |
|
|
</html></pre> |
| 1925 |
|
|
|
| 1926 |
|
|
<p>...and shrink it to this:</p> |
| 1927 |
|
|
|
| 1928 |
|
|
<pre><html xmlns="http://www.w3.org/1999/xhtml"> |
| 1929 |
|
|
<head> |
| 1930 |
|
|
<title>Pretty Title</title> |
| 1931 |
|
|
<style> |
| 1932 |
|
|
h1 { binding: url(cool.xml#wrapBy4); } |
| 1933 |
|
|
h1 { border: solid red; } |
| 1934 |
|
|
h1 .wrap1 { border: solid orange; } |
| 1935 |
|
|
h1 .wrap2 { border: solid yellow; } |
| 1936 |
|
|
h1 .wrap3 { border: solid green; } |
| 1937 |
|
|
h1 .wrap4 { border: solid blue; } |
| 1938 |
|
|
</style> |
| 1939 |
|
|
</head> |
| 1940 |
|
|
<body> |
| 1941 |
|
|
<h1>Pretty Title</h1> |
| 1942 |
|
|
... |
| 1943 |
|
|
</body> |
| 1944 |
|
|
</html></pre> |
| 1945 |
|
|
|
| 1946 |
|
|
<p>...which removes the semantic-free elements used as presentation hooks |
| 1947 |
|
|
from the content markup layer, and places them in the presentation layer |
| 1948 |
|
|
where they belong.</p> |
| 1949 |
|
|
</div> |
| 1950 |
|
|
|
| 1951 |
|
|
<h3 id=the-content><span class=secno>2.5. </span>The <dfn |
| 1952 |
|
|
id=content0><code>content</code></dfn> Element</h3> |
| 1953 |
|
|
|
| 1954 |
|
|
<dl> |
| 1955 |
|
|
<dt>Expected context: |
| 1956 |
|
|
|
| 1957 |
|
|
<dd>Any, but there must be a <a href="#correct">correct</a> <code><a |
| 1958 |
|
|
href="#template0">template</a></code> element somewhere in the ancestor |
| 1959 |
|
|
chain, and there must not be any <code><a |
| 1960 |
|
|
href="#content0">content</a></code> elements anywhere in the ancestor |
| 1961 |
|
|
chain. |
| 1962 |
|
|
|
| 1963 |
|
|
<dt>Expected children: |
| 1964 |
|
|
|
| 1965 |
|
|
<dd>Anything. |
| 1966 |
|
|
</dl> |
| 1967 |
|
|
|
| 1968 |
|
|
<div class=note> |
| 1969 |
|
|
<p>The <code><a href="#content0">content</a></code> element is used |
| 1970 |
|
|
inside <a href="#shadow5">shadow content</a> to specify where <a |
| 1971 |
|
|
href="#explicit3">explicit children</a> that might already exist |
| 1972 |
|
|
underneath the bound element are inserted into the <a |
| 1973 |
|
|
href="#shadow7">shadow tree</a>. As far as the presentation model is |
| 1974 |
|
|
concerned, any shadow content the binding places between the bound |
| 1975 |
|
|
element and the <code><a href="#content0">content</a></code> elements is |
| 1976 |
|
|
interleaved between the bound element and its <a |
| 1977 |
|
|
href="#explicit3">explicit children</a> without affecting the document |
| 1978 |
|
|
model.</p> |
| 1979 |
|
|
|
| 1980 |
|
|
<p>If the <code title=attr-content-includes><a |
| 1981 |
|
|
href="#includes">includes</a></code> attribute has children of the bound |
| 1982 |
|
|
element assigned to it, then those children are inserted into the <a |
| 1983 |
|
|
href="#final0">final flattened tree</a> in place of the <code><a |
| 1984 |
|
|
href="#content0">content</a></code> element. Otherwise, the child |
| 1985 |
|
|
elements of the <code><a href="#content0">content</a></code> element are |
| 1986 |
|
|
inserted into the <a href="#final0">final flattened tree</a> in place of |
| 1987 |
|
|
the <code><a href="#content0">content</a></code> element instead. (See: |
| 1988 |
|
|
<a href="#processing2">processing <code title="">content</code> |
| 1989 |
|
|
elements</a>.)</p> |
| 1990 |
|
|
</div> |
| 1991 |
|
|
|
| 1992 |
|
|
<h4 class="no-toc no-num" id=attributes8>Attributes</h4> |
| 1993 |
|
|
|
| 1994 |
|
|
<dl> |
| 1995 |
|
|
<dt><dfn id=id4 title=attr-content-id>id</dfn> |
| 1996 |
|
|
|
| 1997 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 1998 |
|
|
|
| 1999 |
|
|
<dt><dfn id=includes title=attr-content-includes>includes</dfn> |
| 2000 |
|
|
|
| 2001 |
|
|
<dd>The <code title=attr-content-includes><a |
| 2002 |
|
|
href="#includes">includes</a></code> attribute can be used to indicate |
| 2003 |
|
|
that only certain content should be placed at the <code><a |
| 2004 |
|
|
href="#content0">content</a></code> element. Its value must be a valid |
| 2005 |
|
|
<a href="#attributes21">selector</a>. (See: <a |
| 2006 |
|
|
href="#processing2">processing <code title="">content</code> |
| 2007 |
|
|
elements</a>.) |
| 2008 |
|
|
|
| 2009 |
|
|
<dt><dfn id=apply-binding-sheets |
| 2010 |
|
|
title=attr-content-apply-binding-sheets>apply-binding-sheets</dfn> |
| 2011 |
|
|
|
| 2012 |
|
|
<dd>The <code title=attr-content-apply-binding-sheets><a |
| 2013 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code> attribute |
| 2014 |
|
|
indicates whether or not scoped style sheets loaded for an XBL binding |
| 2015 |
|
|
are applied to a bound element's <a href="#explicit3">explicit |
| 2016 |
|
|
children</a> (in addition to the bound element itself) that are inserted |
| 2017 |
|
|
below this <code><a href="#content0">content</a></code> element when it |
| 2018 |
|
|
is processed. Its value must be either <code>true</code> (indicating |
| 2019 |
|
|
that they are) or <code>false</code> (indicating that they are not). The |
| 2020 |
|
|
default behavior, which is used when the attribute is omitted or has a |
| 2021 |
|
|
value other than the two allowed values, is that they are not applied |
| 2022 |
|
|
(same as <code>false</code>). (See: <a href="#binding22">binding style |
| 2023 |
|
|
sheets</a>.) |
| 2024 |
|
|
|
| 2025 |
|
|
<dt><dfn id=locked title=attr-content-locked>locked</dfn> |
| 2026 |
|
|
|
| 2027 |
|
|
<dd>The <code title=attr-content-locked><a |
| 2028 |
|
|
href="#locked">locked</a></code> attribute indicates whether or not new |
| 2029 |
|
|
children may be inserted below this <code><a |
| 2030 |
|
|
href="#content0">content</a></code> element when it is processed. Its |
| 2031 |
|
|
value must be either <code>true</code> (indicating that they may not) or |
| 2032 |
|
|
<code>false</code> (indicating that they may). The default behavior, |
| 2033 |
|
|
which is used when the attribute is omitted or has a value other than |
| 2034 |
|
|
the two allowed values, is that they may be inserted (same as |
| 2035 |
|
|
<code>false</code>). Elements already assigned to a <code><a |
| 2036 |
|
|
href="#content0">content</a></code> element whose <code |
| 2037 |
|
|
title=attr-content-locked><a href="#locked">locked</a></code> attribute |
| 2038 |
|
|
is dynamically changed are not removed from that element. (See: <a |
| 2039 |
|
|
href="#processing2">processing <code title="">content</code> |
| 2040 |
|
|
elements</a>.) |
| 2041 |
|
|
</dl> |
| 2042 |
|
|
|
| 2043 |
|
|
<div class=example id=content-element-example> |
| 2044 |
|
|
<p>This sample extract from a binding document shows how to use the <code |
| 2045 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 2046 |
|
|
attribute to distribute children to different parts of a shadow content |
| 2047 |
|
|
template.</p> |
| 2048 |
|
|
|
| 2049 |
|
|
<pre><xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl" |
| 2050 |
|
|
xmlns:data="http://example.com/data-language"> |
| 2051 |
|
|
<xbl:binding element="data|grid"> |
| 2052 |
|
|
<xbl:template> |
| 2053 |
|
|
<xbl:div class="caption" xbl:attr="xbl:text=title"/> |
| 2054 |
|
|
<xbl:div class="outer-table"> |
| 2055 |
|
|
<xbl:div class="columns"> |
| 2056 |
|
|
<xbl:content includes="data|column"> |
| 2057 |
|
|
<!-- default to have just one column if none are declared --> |
| 2058 |
|
|
<data:column/> |
| 2059 |
|
|
</xbl:content> |
| 2060 |
|
|
</xbl:div> |
| 2061 |
|
|
<xbl:div class="rows"> |
| 2062 |
|
|
<xbl:content includes="data|heading"/> |
| 2063 |
|
|
<xbl:div class="body"> |
| 2064 |
|
|
<xbl:content includes="data|row:not([hidden])"/> |
| 2065 |
|
|
</xbl:div> |
| 2066 |
|
|
</xbl:div> |
| 2067 |
|
|
</xbl:div> |
| 2068 |
|
|
</xbl:template> |
| 2069 |
|
|
... |
| 2070 |
|
|
</xbl:binding> |
| 2071 |
|
|
... |
| 2072 |
|
|
</xbl:xbl></pre> |
| 2073 |
|
|
|
| 2074 |
|
|
<p>The above template would be used with markup such as the following:</p> |
| 2075 |
|
|
|
| 2076 |
|
|
<pre><data xmlns="http://example.com/data-language"> |
| 2077 |
|
|
... |
| 2078 |
|
|
<grid title="The Lesser of Two Evils"> |
| 2079 |
|
|
<column id="product" sort="alphabetic primary"/> |
| 2080 |
|
|
<column id="catchphrase" sort="alphabetic secondary"/> |
| 2081 |
|
|
<heading> |
| 2082 |
|
|
<item>Product</item> |
| 2083 |
|
|
<item>Catchphrase</item> |
| 2084 |
|
|
</heading> |
| 2085 |
|
|
<row> |
| 2086 |
|
|
<item>Arachno Spores</item> |
| 2087 |
|
|
<item>The fatal spore with the funny name</item> |
| 2088 |
|
|
</row> |
| 2089 |
|
|
<row> |
| 2090 |
|
|
<item>Pastorama</item> |
| 2091 |
|
|
<item>Located on the former site of Brooklyn</item> |
| 2092 |
|
|
</row> |
| 2093 |
|
|
</grid> |
| 2094 |
|
|
... |
| 2095 |
|
|
</data></pre> |
| 2096 |
|
|
|
| 2097 |
|
|
<p>The following illustrates how the above markup would get |
| 2098 |
|
|
redistributed.</p> |
| 2099 |
|
|
|
| 2100 |
|
|
<p><img alt="The two column elements would get put under the div with |
| 2101 |
|
|
class columns; the heading element and its descendants would end up at |
| 2102 |
|
|
the start of the div with class rows, and the two row elements would end |
| 2103 |
|
|
up under the div with class rows." |
| 2104 |
|
|
src="images/content-element-example-explanation.png"></p> |
| 2105 |
|
|
</div> |
| 2106 |
|
|
|
| 2107 |
|
|
<div class=example id=content-element-example-2> |
| 2108 |
|
|
<p>In this example, the binding uses the <code |
| 2109 |
|
|
title=attr-content-apply-binding-sheets><a |
| 2110 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code> attribute |
| 2111 |
|
|
to let its stylesheet affect the <a href="#explicit3">explicit |
| 2112 |
|
|
children</a> of the bound element.</p> |
| 2113 |
|
|
|
| 2114 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 2115 |
|
|
xmlns:ui="http://example.org/ui-language/"> |
| 2116 |
|
|
<binding element="ui|listbox"> |
| 2117 |
|
|
<template allow-selectors-through="true"> |
| 2118 |
|
|
<div id="listbox-focus"> |
| 2119 |
|
|
<content includes="ui|listitem" apply-binding-sheets="true"/> |
| 2120 |
|
|
</div> |
| 2121 |
|
|
</template> |
| 2122 |
|
|
<resources> |
| 2123 |
|
|
<style> |
| 2124 |
|
|
@namespace xbl url(http://www.w3.org/ns/xbl); |
| 2125 |
|
|
@namespace uil url(http://example.org/ui-language/); |
| 2126 |
|
|
uil|listbox { display: block; background: white; color: black; } |
| 2127 |
|
|
uil|listbox > xbl|div#listbox-focus { border: ridge silver; } |
| 2128 |
|
|
uil|listbox:focus > xbl|div#listbox-focus { border: inset silver; } |
| 2129 |
|
|
uil|listitem { display: block; background: white; color: black; } |
| 2130 |
|
|
uil|listitem[selected] { display: block; background: navy; color: white;} |
| 2131 |
|
|
</style> |
| 2132 |
|
|
</resources> |
| 2133 |
|
|
... |
| 2134 |
|
|
</binding></xbl></pre> |
| 2135 |
|
|
</div> |
| 2136 |
|
|
|
| 2137 |
|
|
<div class=example id=content-element-example-locked> |
| 2138 |
|
|
<p>In the following example, the <code title=attr-content-locked><a |
| 2139 |
|
|
href="#locked">locked</a></code> attribute is used to keep the children |
| 2140 |
|
|
of the bound element in the location that the user has selected. By |
| 2141 |
|
|
default, the <code title="">listitem</code> elements would be placed in |
| 2142 |
|
|
the first <code><a href="#content0">content</a></code> element, but |
| 2143 |
|
|
because it is locked, they will instead go into the second one.</p> |
| 2144 |
|
|
|
| 2145 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 2146 |
|
|
xmlns:ui="http://example.org/ui-language/"> |
| 2147 |
|
|
<binding element="ui|duallist"> |
| 2148 |
|
|
<template> |
| 2149 |
|
|
<div> |
| 2150 |
|
|
<ui:listbox id="left" title="Selected Items"> |
| 2151 |
|
|
<content includes="ui|listitem" locked="true" id="leftList"/> |
| 2152 |
|
|
</ui:listbox> |
| 2153 |
|
|
</div> |
| 2154 |
|
|
<div id="buttons"> |
| 2155 |
|
|
<ui:button id="move-right"> Move Right </ui:button> |
| 2156 |
|
|
<ui:button id="move-left"> Move Left </ui:button> |
| 2157 |
|
|
</div> |
| 2158 |
|
|
<div> |
| 2159 |
|
|
<ui:listbox id="right" title="Available Items"> |
| 2160 |
|
|
<content includes="ui|listitem" id="rightList"/> |
| 2161 |
|
|
</ui:listbox> |
| 2162 |
|
|
</div> |
| 2163 |
|
|
</template> |
| 2164 |
|
|
<implementation> |
| 2165 |
|
|
({ |
| 2166 |
|
|
xblBindingAttached: function() { |
| 2167 |
|
|
this.shadowTree.getElementById('move-right').addEventListener( |
| 2168 |
|
|
'click', this.moveRight, false |
| 2169 |
|
|
); |
| 2170 |
|
|
this.shadowTree.getElementById('move-left').addEventListener( |
| 2171 |
|
|
'click', this.moveLeft, false |
| 2172 |
|
|
); |
| 2173 |
|
|
}, |
| 2174 |
|
|
moveRight: function(event) { |
| 2175 |
|
|
this.shadowTree.getElementById('rightList').setInsertionPoint( |
| 2176 |
|
|
this.shadowTree.getElementById('left').selectedElement |
| 2177 |
|
|
); |
| 2178 |
|
|
}, |
| 2179 |
|
|
moveLeft: function(event) { |
| 2180 |
|
|
this.shadowTree.getElementById('leftList').setInsertionPoint( |
| 2181 |
|
|
this.shadowTree.getElementById('right').selectedElement |
| 2182 |
|
|
); |
| 2183 |
|
|
}, |
| 2184 |
|
|
}) |
| 2185 |
|
|
</implementation> |
| 2186 |
|
|
</binding> |
| 2187 |
|
|
</xbl></pre> |
| 2188 |
|
|
</div> |
| 2189 |
|
|
|
| 2190 |
|
|
<h3 id=the-inherited><span class=secno>2.6. </span>The <dfn |
| 2191 |
|
|
id=inherited0><code>inherited</code></dfn> Element</h3> |
| 2192 |
|
|
|
| 2193 |
|
|
<dl> |
| 2194 |
|
|
<dt>Expected context: |
| 2195 |
|
|
|
| 2196 |
|
|
<dd>Any, but there must be a <a href="#correct">correct</a> <code><a |
| 2197 |
|
|
href="#template0">template</a></code> element somewhere in the ancestor |
| 2198 |
|
|
chain. |
| 2199 |
|
|
|
| 2200 |
|
|
<dt>Expected children: |
| 2201 |
|
|
|
| 2202 |
|
|
<dd>Anything. |
| 2203 |
|
|
</dl> |
| 2204 |
|
|
|
| 2205 |
|
|
<p class=note>The <code><a href="#inherited0">inherited</a></code> element |
| 2206 |
|
|
represents where the next inherited shadow tree is to be inserted. If the |
| 2207 |
|
|
binding is the base binding (and thus has no inherited bindings) or if |
| 2208 |
|
|
none of the bindings it inherits from have shadow trees, or if this is |
| 2209 |
|
|
not the first <code><a href="#inherited0">inherited</a></code> element in |
| 2210 |
|
|
the binding's shadow tree, then the contents of the <code><a |
| 2211 |
|
|
href="#inherited0">inherited</a></code> element (if any) will be used |
| 2212 |
|
|
instead. (See: <a href="#final0" title="final flattened tree">the final |
| 2213 |
|
|
flattened tree</a>.)</p> |
| 2214 |
|
|
|
| 2215 |
|
|
<h4 class="no-toc no-num" id=attributes9>Attributes</h4> |
| 2216 |
|
|
|
| 2217 |
|
|
<dl> |
| 2218 |
|
|
<dt><dfn id=id5 title=attr-element-id>id</dfn> |
| 2219 |
|
|
|
| 2220 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2221 |
|
|
</dl> |
| 2222 |
|
|
|
| 2223 |
|
|
<p class=note>While it is legal to nest <code><a |
| 2224 |
|
|
href="#inherited0">inherited</a></code> elements, it is pointless, since |
| 2225 |
|
|
if one <code><a href="#inherited0">inherited</a></code> element used its |
| 2226 |
|
|
fallback content, any subsequent such elements will too.</p> |
| 2227 |
|
|
|
| 2228 |
|
|
<div class=example id=inherited-element-example> |
| 2229 |
|
|
<p>The following binding wraps the bound element's children in a set of |
| 2230 |
|
|
<code><a href="#div0">div</a></code>s for extra styling. By using the |
| 2231 |
|
|
<code><a href="#inherited0">inherited</a></code> element, it has been |
| 2232 |
|
|
designed such that it must be used in conjunction with other bindings: |
| 2233 |
|
|
it will (if applied after the others) wrap the shadow trees of those |
| 2234 |
|
|
templates. Contrast this with <a href="#template-element-example">the |
| 2235 |
|
|
example in the <code>template</code> section</a>, which would not |
| 2236 |
|
|
interact with other bindings. However, if this binding is not applied in |
| 2237 |
|
|
conjunction with a binding that has a <code><a |
| 2238 |
|
|
href="#content0">content</a></code> element giving a place for the |
| 2239 |
|
|
element's explicit children, then those children will not be in the |
| 2240 |
|
|
final flattened tree.</p> |
| 2241 |
|
|
|
| 2242 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 2243 |
|
|
<binding id="wrapBy4"> |
| 2244 |
|
|
<template apply-author-sheets="true" allow-selectors-through="true"> |
| 2245 |
|
|
<div class="wrap1"> |
| 2246 |
|
|
<div class="wrap2"> |
| 2247 |
|
|
<div class="wrap3"> |
| 2248 |
|
|
<div class="wrap4"> |
| 2249 |
|
|
<inherited/> |
| 2250 |
|
|
</div> |
| 2251 |
|
|
</div> |
| 2252 |
|
|
</div> |
| 2253 |
|
|
</div> |
| 2254 |
|
|
</template> |
| 2255 |
|
|
</binding> |
| 2256 |
|
|
</xbl></pre> |
| 2257 |
|
|
</div> |
| 2258 |
|
|
|
| 2259 |
|
|
<h3 id=the-xblattr><span class=secno>2.7. </span>The <dfn id=xblattr0 |
| 2260 |
|
|
title=attr-attr><code>xbl:attr</code></dfn> Attribute</h3> |
| 2261 |
|
|
|
| 2262 |
|
|
<dl> |
| 2263 |
|
|
<dt>Expected element: |
| 2264 |
|
|
|
| 2265 |
|
|
<dd>Any, but there must be a <a href="#correct">correct</a> <code><a |
| 2266 |
|
|
href="#template0">template</a></code> element somewhere in the ancestor |
| 2267 |
|
|
chain. |
| 2268 |
|
|
</dl> |
| 2269 |
|
|
|
| 2270 |
|
|
<p class=note>The <code title=attr-attr><a |
| 2271 |
|
|
href="#xblattr0">xbl:attr</a></code> attribute is a global attribute in |
| 2272 |
|
|
the XBL namespace that specifies which attributes on the bound element |
| 2273 |
|
|
should be forwarded to the element on which the attribute is found when |
| 2274 |
|
|
the shadow content template is cloned. It is a <a |
| 2275 |
|
|
href="#attributes22">space-separated</a> list of <a href="#qname" |
| 2276 |
|
|
title=QName>QNames</a> or <a href="#qname">QName</a> pairs separated by |
| 2277 |
|
|
equal signs, each possibly suffixed by a hash character ("#") and a type |
| 2278 |
|
|
designation. (See: <a href="#attribute1">attribute forwarding</a>.)</p> |
| 2279 |
|
|
|
| 2280 |
|
|
<p>The value of the <code title=attr-attr><a |
| 2281 |
|
|
href="#xblattr0">xbl:attr</a></code> attribute must be a <a |
| 2282 |
|
|
href="#attributes22">space-separated</a> value of items that match the |
| 2283 |
|
|
pattern given in the <a href="#attribute1">attribute forwarding</a> |
| 2284 |
|
|
section.</p> |
| 2285 |
|
|
|
| 2286 |
|
|
<div class=example id=inherits-attribute-example> |
| 2287 |
|
|
<p>One of the major uses of the <code title=attr-attr><a |
| 2288 |
|
|
href="#xblattr0">xbl:attr</a></code> attribute is to implement one |
| 2289 |
|
|
element in terms of another element which already has special behavior |
| 2290 |
|
|
in user agents. This example shows how a <code>ui:text</code> element |
| 2291 |
|
|
can be implemented in terms of an <code>html:input</code> element, with |
| 2292 |
|
|
certain attributes being forwarded to that element directly.</p> |
| 2293 |
|
|
|
| 2294 |
|
|
<pre><xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl" |
| 2295 |
|
|
xmlns:ui="http://example.com/ui-language/" |
| 2296 |
|
|
xmlns:html="http://www.w3.org/1999/xhtml"> |
| 2297 |
|
|
<xbl:binding element="ui|text"> |
| 2298 |
|
|
<xbl:template> |
| 2299 |
|
|
<html:label> |
| 2300 |
|
|
<html:span xbl:attr="xbl:text=label"/> |
| 2301 |
|
|
<html:input xbl:attr="value=default disabled readonly" id="input"/> |
| 2302 |
|
|
</html:label> |
| 2303 |
|
|
</xbl:template> |
| 2304 |
|
|
<xbl:implementation> |
| 2305 |
|
|
({ |
| 2306 |
|
|
get value () { return this.shadowTree.getElementById('input').value; }, |
| 2307 |
|
|
set value (val) { this.shadowTree.getElementById('input').value = val; }, |
| 2308 |
|
|
}) |
| 2309 |
|
|
</xbl:implementation> |
| 2310 |
|
|
</xbl:binding> |
| 2311 |
|
|
</xbl:xbl></pre> |
| 2312 |
|
|
</div> |
| 2313 |
|
|
|
| 2314 |
|
|
<h3 id=the-xblpseudo><span class=secno>2.8. </span>The <dfn id=xblpseudo0 |
| 2315 |
|
|
title=attr-pseudo><code>xbl:pseudo</code></dfn> Attribute</h3> |
| 2316 |
|
|
|
| 2317 |
|
|
<dl> |
| 2318 |
|
|
<dt>Expected element: |
| 2319 |
|
|
|
| 2320 |
|
|
<dd>Any, but there must be a <a href="#correct">correct</a> <code><a |
| 2321 |
|
|
href="#template0">template</a></code> element somewhere in the ancestor |
| 2322 |
|
|
chain. |
| 2323 |
|
|
</dl> |
| 2324 |
|
|
|
| 2325 |
|
|
<p class=note>The <code title=attr-pseudo><a |
| 2326 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attribute is a global attribute |
| 2327 |
|
|
in the XBL namespace that specifies the <a |
| 2328 |
|
|
href="#pseudo-element">pseudo-element</a> that, when used on the bound |
| 2329 |
|
|
element, must be mapped to the element on which the attribute is found.</p> |
| 2330 |
|
|
|
| 2331 |
|
|
<p>The value of the <code title=attr-pseudo><a |
| 2332 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attribute must be a valid <a |
| 2333 |
|
|
href="#pseudo-element">pseudo-element</a> name, in lowercase, without the |
| 2334 |
|
|
leading "::". The valid pseudo-elements are defined by the CSS |
| 2335 |
|
|
specifications, and are "value", "choices", "label", "repeat-item", and |
| 2336 |
|
|
"icon". Future versions of CSS might introduce new values. (See: <a |
| 2337 |
|
|
href="#matching1">matching pseudo-elements</a>.)</p> |
| 2338 |
|
|
|
| 2339 |
|
|
<div class=example id=pseudo-attribute-example> |
| 2340 |
|
|
<p>The <code title=attr-pseudo><a |
| 2341 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attribute is useful as a way to |
| 2342 |
|
|
let <a href="#author" title="author style sheets">author styles</a> |
| 2343 |
|
|
affect the insides of a shadow tree without exposing the exact |
| 2344 |
|
|
construction of the tree. Here, the binding represents a composite |
| 2345 |
|
|
widget with an icon, a label, a text field, and some buttons. |
| 2346 |
|
|
Pseudo-elements are used for each part allowing the author to style each |
| 2347 |
|
|
part separately.</p> |
| 2348 |
|
|
|
| 2349 |
|
|
<pre><xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl" |
| 2350 |
|
|
xmlns:html="http://www.w3.org/1999/xhtml"> |
| 2351 |
|
|
<xbl:binding id="input-dialog"> |
| 2352 |
|
|
<xbl:template> |
| 2353 |
|
|
<xbl:div class="root"> |
| 2354 |
|
|
<xbl:div class="icon-block"> |
| 2355 |
|
|
<html:img xbl:pseudo="icon" xbl:attr="src=icon alt=alt"/> |
| 2356 |
|
|
</xbl:div> |
| 2357 |
|
|
<xbl:div xbl:pseudo="label" xbl:attr="xbl:text=label"/> |
| 2358 |
|
|
<xbl:div class="field-block"> |
| 2359 |
|
|
<html:input xbl:pseudo="value" xbl:attr="value" id="field"/> |
| 2360 |
|
|
</xbl:div> |
| 2361 |
|
|
<xbl:div class="buttons-block"> |
| 2362 |
|
|
<html:button xbl:pseudo="choices" id="ok"> OK </html:button> |
| 2363 |
|
|
<html:button xbl:pseudo="choices" id="cancel"> Cancel </html:button> |
| 2364 |
|
|
</xbl:div> |
| 2365 |
|
|
</xbl:div> |
| 2366 |
|
|
</xbl:template> |
| 2367 |
|
|
... |
| 2368 |
|
|
</xbl:binding> |
| 2369 |
|
|
</xbl:xbl></pre> |
| 2370 |
|
|
|
| 2371 |
|
|
<p>An author-level stylesheet for a document using the binding might look |
| 2372 |
|
|
like:</p> |
| 2373 |
|
|
|
| 2374 |
|
|
<pre>textDialog { binding: url(dialogs.xml#input-dialog); } |
| 2375 |
|
|
textDialog::value { background: white; color: black; } |
| 2376 |
|
|
textDialog::choices { border: outset; }</pre> |
| 2377 |
|
|
</div> |
| 2378 |
|
|
|
| 2379 |
|
|
<h3 id=the-div><span class=secno>2.9. </span>The <dfn |
| 2380 |
|
|
id=div0><code>div</code></dfn> Element</h3> |
| 2381 |
|
|
|
| 2382 |
|
|
<dl> |
| 2383 |
|
|
<dt>Expected contexts: |
| 2384 |
|
|
|
| 2385 |
|
|
<dd><code><a href="#template0">template</a></code> |
| 2386 |
|
|
|
| 2387 |
|
|
<dd><code><a href="#content0">content</a></code> |
| 2388 |
|
|
|
| 2389 |
|
|
<dd><code><a href="#inherited0">inherited</a></code> |
| 2390 |
|
|
|
| 2391 |
|
|
<dd><code><a href="#div0">div</a></code> |
| 2392 |
|
|
|
| 2393 |
|
|
<dt>Expected children: |
| 2394 |
|
|
|
| 2395 |
|
|
<dd>Anything. Of particular interest, the <code><a |
| 2396 |
|
|
href="#content0">content</a></code> and <code><a |
| 2397 |
|
|
href="#inherited0">inherited</a></code> elements may occur as |
| 2398 |
|
|
descendants, and non-XBL descendant elements may host <code |
| 2399 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> and <code |
| 2400 |
|
|
title=attr-pseudo><a href="#xblpseudo0">xbl:pseudo</a></code> |
| 2401 |
|
|
attributes. |
| 2402 |
|
|
</dl> |
| 2403 |
|
|
|
| 2404 |
|
|
<p class=note>The <code><a href="#div0">div</a></code> element has no |
| 2405 |
|
|
intrinsic meaning. It is intended to be used as a styling hook for |
| 2406 |
|
|
presentational bindings.</p> |
| 2407 |
|
|
|
| 2408 |
|
|
<h4 class="no-toc no-num" id=attributes10>Attributes</h4> |
| 2409 |
|
|
|
| 2410 |
|
|
<dl> |
| 2411 |
|
|
<dt><dfn id=id6 title=attr-div-id>id</dfn> |
| 2412 |
|
|
|
| 2413 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2414 |
|
|
|
| 2415 |
|
|
<dt><dfn id=class title=attr-div-class>class</dfn> |
| 2416 |
|
|
|
| 2417 |
|
|
<dd>A <a href="#attributes22">space-separated</a> list of keywords |
| 2418 |
|
|
relevant to the element that could be useful as stylistic hooks. This is |
| 2419 |
|
|
a "class" attribute (which means, for example, that the CSS "." |
| 2420 |
|
|
shorthand can be used to match <code><a href="#div0">div</a></code> |
| 2421 |
|
|
elements based on their <code>class</code> attribute). <span |
| 2422 |
|
|
class=note>The <code title=attr-div-class><a |
| 2423 |
|
|
href="#class">class</a></code> attribute doesn't apply to other XBL |
| 2424 |
|
|
elements, only to <code><a href="#div0">div</a></code>.</span> |
| 2425 |
|
|
|
| 2426 |
|
|
<dt><dfn id=state title=attr-div-state>state</dfn> |
| 2427 |
|
|
|
| 2428 |
|
|
<dd>A free-form attribute with no predefined meaning that can be used as |
| 2429 |
|
|
a stylistic hook, to store state, or for other purposes as desired by |
| 2430 |
|
|
the binding author. |
| 2431 |
|
|
|
| 2432 |
|
|
<dt><dfn id=title title=attr-div-title>title</dfn> |
| 2433 |
|
|
|
| 2434 |
|
|
<dd>Text representing advisory information that the user agent should |
| 2435 |
|
|
show to the user upon request (e.g., on a graphical browser, the |
| 2436 |
|
|
contents of this attribute could be shown as a tooltip when the user |
| 2437 |
|
|
indicates the element with a mouse pointer). <span class=note>The <code |
| 2438 |
|
|
title=attr-div-title><a href="#title">title</a></code> attribute doesn't |
| 2439 |
|
|
apply to other XBL elements, only to <code><a |
| 2440 |
|
|
href="#div0">div</a></code>.</span> |
| 2441 |
|
|
</dl> |
| 2442 |
|
|
|
| 2443 |
|
|
<p>The <code><a href="#div0">div</a></code> element in XBL is <em>not</em> |
| 2444 |
|
|
the same element type as the <code><a href="#div0">div</a></code> element |
| 2445 |
|
|
in HTML, but it is intended to be used in similar ways (and shares the |
| 2446 |
|
|
name for that reason).</p> |
| 2447 |
|
|
|
| 2448 |
|
|
<div class=example id=div-element-example> |
| 2449 |
|
|
<p>Many of the examples in this specification use the <code><a |
| 2450 |
|
|
href="#div0">div</a></code> element.</p> |
| 2451 |
|
|
|
| 2452 |
|
|
<p>The following example uses the <code title=attr-div-state><a |
| 2453 |
|
|
href="#state">state</a></code> attribute so that the CSS style sheet can |
| 2454 |
|
|
render the shadow tree differently based on whether the switch that the |
| 2455 |
|
|
binding represents is turned on or off.</p> |
| 2456 |
|
|
|
| 2457 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 2458 |
|
|
<binding id="switch"> |
| 2459 |
|
|
<template> |
| 2460 |
|
|
<div class="wrapper"> |
| 2461 |
|
|
<div id="main" state="off"/> |
| 2462 |
|
|
</div> |
| 2463 |
|
|
</template> |
| 2464 |
|
|
<handlers> |
| 2465 |
|
|
<handler event="click"> |
| 2466 |
|
|
this.shadowTree.getElementById('main').setAttribute('state', |
| 2467 |
|
|
this.shadowTree.getElementById('main').getAttribute('state') == 'on' ? |
| 2468 |
|
|
'off' : 'on'); |
| 2469 |
|
|
</handler> |
| 2470 |
|
|
</handlers> |
| 2471 |
|
|
<resources> |
| 2472 |
|
|
<style> |
| 2473 |
|
|
#main[state=off] { ... } |
| 2474 |
|
|
#main[state=on] { ... } |
| 2475 |
|
|
</style> |
| 2476 |
|
|
</resources> |
| 2477 |
|
|
</binding> |
| 2478 |
|
|
</xbl></pre> |
| 2479 |
|
|
</div> |
| 2480 |
|
|
|
| 2481 |
|
|
<h3 id=the-handlers><span class=secno>2.10. </span>The <dfn |
| 2482 |
|
|
id=handlers0><code>handlers</code></dfn> Element</h3> |
| 2483 |
|
|
|
| 2484 |
|
|
<dl> |
| 2485 |
|
|
<dt>Expected context: |
| 2486 |
|
|
|
| 2487 |
|
|
<dd><code><a href="#binding16">binding</a></code> |
| 2488 |
|
|
|
| 2489 |
|
|
<dt>Expected children: |
| 2490 |
|
|
|
| 2491 |
|
|
<dd><code><a href="#handler0">handler</a></code>: zero or more. |
| 2492 |
|
|
</dl> |
| 2493 |
|
|
|
| 2494 |
|
|
<div class=note> |
| 2495 |
|
|
<p>The <code><a href="#handlers0">handlers</a></code> element's event |
| 2496 |
|
|
handlers can be called for events that flow through the bound element. |
| 2497 |
|
|
During capture, target, bubbling, and <a href="#the-default1" |
| 2498 |
|
|
title="default phase">default</a> phases, when a given event is received |
| 2499 |
|
|
by a bound element, if a corresponding event listener has been attached |
| 2500 |
|
|
to the <code><a href="#handlers0">handlers</a></code> element, then the |
| 2501 |
|
|
event will be <a href="#event12" title="event forwarding">forwarded</a> |
| 2502 |
|
|
to that event listener. (See: <a href="#event12">event forwarding</a>, |
| 2503 |
|
|
<a href="#binding17">binding attachment and detachment</a>.)</p> |
| 2504 |
|
|
|
| 2505 |
|
|
<p>Typically, event handlers are defined using <code><a |
| 2506 |
|
|
href="#handler0">handler</a></code> elements.</p> |
| 2507 |
|
|
</div> |
| 2508 |
|
|
|
| 2509 |
|
|
<h4 class="no-toc no-num" id=attributes11>Attributes</h4> |
| 2510 |
|
|
|
| 2511 |
|
|
<dl> |
| 2512 |
|
|
<dt><dfn id=id7 title=attr-handlers-id>id</dfn> |
| 2513 |
|
|
|
| 2514 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2515 |
|
|
</dl> |
| 2516 |
|
|
|
| 2517 |
|
|
<div class=example id=handlers-element-example> |
| 2518 |
|
|
<p>The following example shows how <code><a |
| 2519 |
|
|
href="#handlers0">handlers</a></code> can be used with any event |
| 2520 |
|
|
listener mechanism.</p> |
| 2521 |
|
|
|
| 2522 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 2523 |
|
|
<binding id="test"> |
| 2524 |
|
|
<handlers id="test-handlers"/> |
| 2525 |
|
|
... |
| 2526 |
|
|
</binding> |
| 2527 |
|
|
<script> |
| 2528 |
|
|
document.getElementById('test-handlers').addEventListener('click', function (event) { |
| 2529 |
|
|
// this will get called for every click event that bubbles through |
| 2530 |
|
|
// any element that is bound to the "test" binding above. |
| 2531 |
|
|
... |
| 2532 |
|
|
}, false); |
| 2533 |
|
|
</script> |
| 2534 |
|
|
</xbl></pre> |
| 2535 |
|
|
</div> |
| 2536 |
|
|
|
| 2537 |
|
|
<h3 id=the-handler><span class=secno>2.11. </span>The <dfn |
| 2538 |
|
|
id=handler0><code>handler</code></dfn> Element</h3> |
| 2539 |
|
|
|
| 2540 |
|
|
<dl> |
| 2541 |
|
|
<dt>Expected context: |
| 2542 |
|
|
|
| 2543 |
|
|
<dd><code><a href="#handlers0">handlers</a></code> |
| 2544 |
|
|
|
| 2545 |
|
|
<dt>Expected children: |
| 2546 |
|
|
|
| 2547 |
|
|
<dd>Depends on the scripting language. |
| 2548 |
|
|
</dl> |
| 2549 |
|
|
|
| 2550 |
|
|
<p class=note>The <code><a href="#handler0">handler</a></code> element |
| 2551 |
|
|
describes a single event handler. This handler is attached to its parent |
| 2552 |
|
|
<code><a href="#handlers0">handlers</a></code> element, which is used as |
| 2553 |
|
|
an event forwarding target when handling events on the bound element. |
| 2554 |
|
|
(See: <a href="#event11">event handlers</a>.) It wraps a script that is |
| 2555 |
|
|
executed when the event handler is matched.</p> |
| 2556 |
|
|
|
| 2557 |
|
|
<h4 class="no-toc no-num" id=attributes12>Attributes</h4> |
| 2558 |
|
|
|
| 2559 |
|
|
<dl> |
| 2560 |
|
|
<dt><dfn id=id8 title=attr-handler-id>id</dfn> |
| 2561 |
|
|
|
| 2562 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2563 |
|
|
|
| 2564 |
|
|
<dt><dfn id=event9 title=attr-handler-event>event</dfn> |
| 2565 |
|
|
|
| 2566 |
|
|
<dd>The <code title=attr-handler-event><a href="#event9">event</a></code> |
| 2567 |
|
|
attribute describes the specific event that this handler is listening |
| 2568 |
|
|
for. (See: <a href="#registering1">registering event handlers with the |
| 2569 |
|
|
<code>handler</code> element</a>.) |
| 2570 |
|
|
|
| 2571 |
|
|
<dt><dfn id=phase title=attr-handler-phase>phase</dfn> |
| 2572 |
|
|
|
| 2573 |
|
|
<dd>This attribute specifies the phase of the event flow that this |
| 2574 |
|
|
handler should monitor. When specified, the value must be one of |
| 2575 |
|
|
<code>capture</code>, <code>target</code>, <code>bubble</code>, or |
| 2576 |
|
|
<code>default-action</code>. If <code>capture</code> is specified, then |
| 2577 |
|
|
the event handler must only be fired during the capturing phase of event |
| 2578 |
|
|
propagation. If <code>target</code> is specified, then the event handler |
| 2579 |
|
|
must only be fired during the target phase. If |
| 2580 |
|
|
<code>default-action</code> is specified, then the event handler must |
| 2581 |
|
|
only be fired during the <a href="#the-default1">default phase</a> (if |
| 2582 |
|
|
it occurs). Otherwise, the handler must only be fired during the |
| 2583 |
|
|
bubbling phase. (See: <a href="#registering1">registering event handlers |
| 2584 |
|
|
with the <code>handler</code> element</a>.) |
| 2585 |
|
|
|
| 2586 |
|
|
<dt><dfn id=trusted title=attr-handler-trusted>trusted</dfn> |
| 2587 |
|
|
|
| 2588 |
|
|
<dd>This attribute specifies whether the handler should be limited to <a |
| 2589 |
|
|
href="#trusted0" title=event-trusted>trusted events</a>. When specified, |
| 2590 |
|
|
it must have the value <code>true</code> or the value |
| 2591 |
|
|
<code>false</code>. If <code>true</code> is specified, then the event |
| 2592 |
|
|
handler must only be fired if the event's <code title=event-trusted><a |
| 2593 |
|
|
href="#trusted0">trusted</a></code> attribute is true. Otherwise, the |
| 2594 |
|
|
value of the <code title=event-trusted><a |
| 2595 |
|
|
href="#trusted0">trusted</a></code> flag does not affect the event |
| 2596 |
|
|
handler. (See: <a href="#registering1">registering event handlers with |
| 2597 |
|
|
the <code>handler</code> element</a>.) |
| 2598 |
|
|
|
| 2599 |
|
|
<dt><dfn id=propagate title=attr-handler-propagate>propagate</dfn> |
| 2600 |
|
|
|
| 2601 |
|
|
<dd>The <code title=attr-handler-propagate><a |
| 2602 |
|
|
href="#propagate">propagate</a></code> attribute specifies whether after |
| 2603 |
|
|
processing all listeners at the current node, the event is allowed to |
| 2604 |
|
|
continue on its path (either in the capture or the bubble phase). When |
| 2605 |
|
|
specified, it must have the value <code title="">stop</code> or the |
| 2606 |
|
|
value <code title="">continue</code>. If the value is <code |
| 2607 |
|
|
title="">stop</code>, then propagation will be stopped, otherwise it |
| 2608 |
|
|
won't. It has no effect if the <code title=attr-handler-phase><a |
| 2609 |
|
|
href="#phase">phase</a></code> attribute has the value |
| 2610 |
|
|
<code>default-action</code>. (See: <a href="#registering1">registering |
| 2611 |
|
|
event handlers with the <code>handler</code> element</a>.) |
| 2612 |
|
|
|
| 2613 |
|
|
<dt><dfn id=default-action |
| 2614 |
|
|
title=attr-handler-default-action>default-action</dfn> |
| 2615 |
|
|
|
| 2616 |
|
|
<dd>The <code title=attr-handler-default-action><a |
| 2617 |
|
|
href="#default-action">default-action</a></code> attribute specifies |
| 2618 |
|
|
whether after processing of all listeners for the event, the default |
| 2619 |
|
|
action for the event (if any) should be performed or not. (See: <a |
| 2620 |
|
|
href="#registering1">registering event handlers with the |
| 2621 |
|
|
<code>handler</code> element</a>.)</dd> |
| 2622 |
|
|
<!--XXX provide <handler method="foo"/> as a shortcut for <handler>foo(event)</handler> --> |
| 2623 |
|
|
<!-- lexical constraints for filters are defined in filter sections --> |
| 2624 |
|
|
|
| 2625 |
|
|
<dt><dfn id=button title=attr-handler-button>button</dfn> |
| 2626 |
|
|
|
| 2627 |
|
|
<dd>The <code title=attr-handler-button><a |
| 2628 |
|
|
href="#button">button</a></code> attribute imposes a <em>filter</em> on |
| 2629 |
|
|
the handler. It is used with mouse handlers to specify a particular |
| 2630 |
|
|
button. (See: <a href="#mouse1">mouse event handler filters</a>.) |
| 2631 |
|
|
|
| 2632 |
|
|
<dt><dfn id=click-count title=attr-handler-click-count>click-count</dfn> |
| 2633 |
|
|
|
| 2634 |
|
|
<dd>The <code title=attr-handler-click-count><a |
| 2635 |
|
|
href="#click-count">click-count</a></code> attribute imposes a |
| 2636 |
|
|
<em>filter</em> on the handler. It is used with mouse handlers to |
| 2637 |
|
|
specify how many clicks must have occurred. (See: <a |
| 2638 |
|
|
href="#mouse1">mouse event handler filters</a>.) |
| 2639 |
|
|
|
| 2640 |
|
|
<dt><dfn id=modifiers1 title=attr-handler-modifiers>modifiers</dfn> |
| 2641 |
|
|
|
| 2642 |
|
|
<dd>The <code title=attr-handler-modifiers><a |
| 2643 |
|
|
href="#modifiers1">modifiers</a></code> attribute imposes a filter on |
| 2644 |
|
|
key and mouse handlers. It is used with mouse and key handlers to |
| 2645 |
|
|
specify particular modifier keys. (See: <a href="#mouse1">mouse event |
| 2646 |
|
|
handler filters</a>, <a href="#key-event1">key event handler |
| 2647 |
|
|
filters</a>, <a href="#modifiers2">modifiers</a>.) |
| 2648 |
|
|
|
| 2649 |
|
|
<dt><dfn id=key title=attr-handler-key>key</dfn> |
| 2650 |
|
|
|
| 2651 |
|
|
<dd>The <code title=attr-handler-key><a href="#key">key</a></code> |
| 2652 |
|
|
attribute imposes a filter on key handlers. It is used with key handlers |
| 2653 |
|
|
to specify which keys to listen for. (See: <a href="#key-event1">key |
| 2654 |
|
|
event handler filters</a>.) |
| 2655 |
|
|
|
| 2656 |
|
|
<dt><dfn id=key-location |
| 2657 |
|
|
title=attr-handler-key-location>key-location</dfn> |
| 2658 |
|
|
|
| 2659 |
|
|
<dd>The <code title=attr-handler-key-location><a |
| 2660 |
|
|
href="#key-location">key-location</a></code> attribute imposes a filter |
| 2661 |
|
|
on key handlers. It is used with key handlers to specify which keys to |
| 2662 |
|
|
listen for. (See: <a href="#key-event1">key event handler filters</a>.) |
| 2663 |
|
|
|
| 2664 |
|
|
<dt><dfn id=text title=attr-handler-text>text</dfn> |
| 2665 |
|
|
|
| 2666 |
|
|
<dd>The <code title=attr-handler-text><a href="#text">text</a></code> |
| 2667 |
|
|
attribute imposes a filter on text input handlers. It is used with text |
| 2668 |
|
|
input handlers to specify which characters to listen for. (See: <a |
| 2669 |
|
|
href="#text-input1">text input event handler filters</a>.) |
| 2670 |
|
|
|
| 2671 |
|
|
<dt><dfn id=prev-value title=attr-handler-prev-value>prev-value</dfn> |
| 2672 |
|
|
|
| 2673 |
|
|
<dd>The <code title=attr-handler-prev-value><a |
| 2674 |
|
|
href="#prev-value">prev-value</a></code> attribute imposes a filter on |
| 2675 |
|
|
mutation handlers. It is used with mutation handlers to specify what |
| 2676 |
|
|
<code>prev-value</code> to listen for. (See: <a |
| 2677 |
|
|
href="#mutation1">mutation event handler filters</a>.) |
| 2678 |
|
|
|
| 2679 |
|
|
<dt><dfn id=new-value title=attr-handler-new-value>new-value</dfn> |
| 2680 |
|
|
|
| 2681 |
|
|
<dd>The <code title=attr-handler-new-value><a |
| 2682 |
|
|
href="#new-value">new-value</a></code> attribute imposes a filter on |
| 2683 |
|
|
mutation handlers. It is used with mutation handlers to specify what |
| 2684 |
|
|
<code>new-value</code> to listen for. (See: <a |
| 2685 |
|
|
href="#mutation1">mutation event handler filters</a>) |
| 2686 |
|
|
|
| 2687 |
|
|
<dt><dfn id=attr-name title=attr-handler-attr-name>attr-name</dfn> |
| 2688 |
|
|
|
| 2689 |
|
|
<dd>The <code title=attr-handler-attr-name><a |
| 2690 |
|
|
href="#attr-name">attr-name</a></code> attribute imposes a filter on |
| 2691 |
|
|
mutation handlers. It is used with attribute mutation handlers to |
| 2692 |
|
|
specify which attribute to listen to for changes. (See: <a |
| 2693 |
|
|
href="#mutation1">mutation event handler filters</a>) |
| 2694 |
|
|
|
| 2695 |
|
|
<dt><dfn id=attr-change title=attr-handler-attr-change>attr-change</dfn> |
| 2696 |
|
|
|
| 2697 |
|
|
<dd>The <code title=attr-handler-attr-change><a |
| 2698 |
|
|
href="#attr-change">attr-change</a></code> attribute imposes a filter on |
| 2699 |
|
|
mutation handlers. It is used with attribute mutation handlers to |
| 2700 |
|
|
specify the type of change to listen for. (See: <a |
| 2701 |
|
|
href="#mutation1">mutation event handler filters</a>.) |
| 2702 |
|
|
</dl> |
| 2703 |
|
|
|
| 2704 |
|
|
<p>If a <code><a href="#handler0">handler</a></code> element is marked |
| 2705 |
|
|
(via the <code title=attr-xbl-script-type><a |
| 2706 |
|
|
href="#script-type">script-type</a></code> attribute of the <code><a |
| 2707 |
|
|
href="#xbl0">xbl</a></code> element) as being in a language that the UA |
| 2708 |
|
|
does not support then the UA must <a href="#ignoring">ignore</a> it, |
| 2709 |
|
|
meaning it must not be used for the event handler definitions of any |
| 2710 |
|
|
binding.</p> |
| 2711 |
|
|
|
| 2712 |
|
|
<p>How UAs must handle nodes inside <code><a |
| 2713 |
|
|
href="#handler0">handler</a></code> elements depends on the language |
| 2714 |
|
|
used. (See: <a href="#loading6">loading and running scripts</a>, <a |
| 2715 |
|
|
href="#event11">event handlers</a>.)</p> |
| 2716 |
|
|
|
| 2717 |
|
|
<p><code><a href="#handler0">handler</a></code> blocks are evaluated each |
| 2718 |
|
|
time they are fired. Changes to the <code><a |
| 2719 |
|
|
href="#handler0">handler</a></code> elements therefore take effect the |
| 2720 |
|
|
next time the event is fired.</p> |
| 2721 |
|
|
|
| 2722 |
|
|
<div class=example id=handler-element-example> |
| 2723 |
|
|
<p>The following binding implements a link which, when clicked once with |
| 2724 |
|
|
the primary button and with no key modifiers, or, when focused and sent |
| 2725 |
|
|
a keypress of the Enter key with no modifiers, will cause the link to be |
| 2726 |
|
|
followed.</p> |
| 2727 |
|
|
|
| 2728 |
|
|
<p>It will only do this if the click or the keypress is a real event |
| 2729 |
|
|
triggered by the user; it won't do it for events faked by script. |
| 2730 |
|
|
However, if the event faked by script is a DOMActivate event, then it |
| 2731 |
|
|
will follow the link, because the handler for the DOMActivate event |
| 2732 |
|
|
doesn't check that the event is <a href="#trusted0" |
| 2733 |
|
|
title=event-trusted>trusted</a>. (If it did, it would never fire, |
| 2734 |
|
|
because the event is dispatched by the binding, and therefore is not |
| 2735 |
|
|
trusted.)</p> |
| 2736 |
|
|
|
| 2737 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 2738 |
|
|
<binding id="events"> |
| 2739 |
|
|
<handlers> |
| 2740 |
|
|
<handler event="click" phase="default-action" |
| 2741 |
|
|
button="1" click-count="1" modifiers="none" |
| 2742 |
|
|
trusted="true"> |
| 2743 |
|
|
this.activate(); |
| 2744 |
|
|
</handler> |
| 2745 |
|
|
<handler event="keypress" phase="default-action" |
| 2746 |
|
|
key="Enter" modifiers="none" |
| 2747 |
|
|
trusted="true"> |
| 2748 |
|
|
this.activate(); |
| 2749 |
|
|
</handler> |
| 2750 |
|
|
<handler event="DOMActivate" phase="default-action"> |
| 2751 |
|
|
if (event.target == this.boundElement) |
| 2752 |
|
|
this.boundElement.ownerDocument.location.href = this.href; |
| 2753 |
|
|
</handler> |
| 2754 |
|
|
</handlers> |
| 2755 |
|
|
... |
| 2756 |
|
|
<!-- it is assumed that the implementation for this binding |
| 2757 |
|
|
implements a .activate() method that fires the DOMActivate |
| 2758 |
|
|
event on itself. --> |
| 2759 |
|
|
</binding> |
| 2760 |
|
|
</xbl></pre> |
| 2761 |
|
|
</div> |
| 2762 |
|
|
|
| 2763 |
|
|
<h3 id=the-resources><span class=secno>2.12. </span>The <dfn |
| 2764 |
|
|
id=resources1><code>resources</code></dfn> Element</h3> |
| 2765 |
|
|
|
| 2766 |
|
|
<dl> |
| 2767 |
|
|
<dt>Expected context: |
| 2768 |
|
|
|
| 2769 |
|
|
<dd><code><a href="#binding16">binding</a></code> |
| 2770 |
|
|
|
| 2771 |
|
|
<dt>Expected children (in any order): |
| 2772 |
|
|
|
| 2773 |
|
|
<dd><code><a href="#style2">style</a></code>: zero or more. |
| 2774 |
|
|
|
| 2775 |
|
|
<dd><code><a href="#prefetch0">prefetch</a></code>: zero or more. |
| 2776 |
|
|
</dl> |
| 2777 |
|
|
|
| 2778 |
|
|
<p class=note>The <code><a href="#resources1">resources</a></code> element |
| 2779 |
|
|
contains a list of style sheets to apply when using this binding, as well |
| 2780 |
|
|
as a list of files (images, videos, sound files, etc) to optionally |
| 2781 |
|
|
preload.</p> |
| 2782 |
|
|
|
| 2783 |
|
|
<h4 class="no-toc no-num" id=attributes13>Attributes</h4> |
| 2784 |
|
|
|
| 2785 |
|
|
<dl> |
| 2786 |
|
|
<dt><dfn id=id9 title=attr-resources-id>id</dfn> |
| 2787 |
|
|
|
| 2788 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2789 |
|
|
</dl> |
| 2790 |
|
|
|
| 2791 |
|
|
<h3 id=the-style><span class=secno>2.13. </span>The <dfn |
| 2792 |
|
|
id=style2><code>style</code></dfn> Element</h3> |
| 2793 |
|
|
|
| 2794 |
|
|
<dl> |
| 2795 |
|
|
<dt>Expected context: |
| 2796 |
|
|
|
| 2797 |
|
|
<dd><code><a href="#resources1">resources</a></code> |
| 2798 |
|
|
|
| 2799 |
|
|
<dt>Expected children: |
| 2800 |
|
|
|
| 2801 |
|
|
<dd>If the element has no <code title=attr-style-src><a |
| 2802 |
|
|
href="#src0">src</a></code> attribute: depends on the styling language. |
| 2803 |
|
|
|
| 2804 |
|
|
<dd>If the element does have a <code title=attr-style-src><a |
| 2805 |
|
|
href="#src0">src</a></code> attribute: none. |
| 2806 |
|
|
</dl> |
| 2807 |
|
|
|
| 2808 |
|
|
<div class=note> |
| 2809 |
|
|
<p>The <code><a href="#style2">style</a></code> element is used to |
| 2810 |
|
|
specify a style sheet that is to be applied to the bound element and to |
| 2811 |
|
|
the shadow content generated by the binding, as well as to any <a |
| 2812 |
|
|
href="#explicit3">explicit children</a> (and their descendants) assigned |
| 2813 |
|
|
to <code><a href="#content0">content</a></code> elements in the shadow |
| 2814 |
|
|
content whose <code title=attr-content-apply-binding-sheets><a |
| 2815 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code> attribute |
| 2816 |
|
|
is set.</p> |
| 2817 |
|
|
|
| 2818 |
|
|
<p>The <code><a href="#style2">style</a></code> element in XBL never |
| 2819 |
|
|
applies styles to elements in the bound document other than the bound |
| 2820 |
|
|
element (and <a href="#apply-binding-sheets" |
| 2821 |
|
|
title=attr-content-apply-binding-sheets>possibly its children</a>). It |
| 2822 |
|
|
never affects any ancestors of the bound element, or any nodes in any |
| 2823 |
|
|
other bindings or binding templates.</p> |
| 2824 |
|
|
</div> |
| 2825 |
|
|
|
| 2826 |
|
|
<h4 class="no-toc no-num" id=attributes14>Attributes</h4> |
| 2827 |
|
|
|
| 2828 |
|
|
<dl> |
| 2829 |
|
|
<dt><dfn id=id10 title=attr-style-id>id</dfn> |
| 2830 |
|
|
|
| 2831 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2832 |
|
|
|
| 2833 |
|
|
<dt><dfn id=media title=attr-style-media>media</dfn> |
| 2834 |
|
|
|
| 2835 |
|
|
<dd>The <code title=attr-style-media><a href="#media">media</a></code> |
| 2836 |
|
|
attribute specifies the intended destination medium for style |
| 2837 |
|
|
information. If specified, the value of the attribute must be a valid |
| 2838 |
|
|
Media Query (<code title="">media_query</code> token). How the value of |
| 2839 |
|
|
this attribute is interpreted is defined by Media Queries. If this |
| 2840 |
|
|
attribute is not specified, then there is no restriction on which media |
| 2841 |
|
|
the style sheet should be applied to (same as specifying |
| 2842 |
|
|
<code>media="all"</code>). <a href="#refsMQ">[MQ]</a> |
| 2843 |
|
|
|
| 2844 |
|
|
<dt><dfn id=src0 title=attr-style-src>src</dfn> |
| 2845 |
|
|
|
| 2846 |
|
|
<dd>The <code title=attr-style-src><a href="#src0">src</a></code> |
| 2847 |
|
|
attribute specifies the <a href="#attributes24">URI</a> to a resource of |
| 2848 |
|
|
the type given by the XBL subtree's <code title=attr-xbl-style-type><a |
| 2849 |
|
|
href="#style-type">style-type</a></code> attribute. If the attribute is |
| 2850 |
|
|
specified, the contents of the element must be ignored (even if the |
| 2851 |
|
|
resource could not be fetched or was of the wrong type). (See: <a |
| 2852 |
|
|
href="#binding22">binding style sheets</a>.) |
| 2853 |
|
|
</dl> |
| 2854 |
|
|
|
| 2855 |
|
|
<p>If a <code><a href="#style2">style</a></code> element is marked (via |
| 2856 |
|
|
the <code title=attr-xbl-style-type><a |
| 2857 |
|
|
href="#style-type">style-type</a></code> attribute of the <code><a |
| 2858 |
|
|
href="#xbl0">xbl</a></code> element) as being in a language that the UA |
| 2859 |
|
|
does not support, the UA must <a href="#ignoring">ignore</a> it. |
| 2860 |
|
|
Similarly, if the <code><a href="#style2">style</a></code> element points |
| 2861 |
|
|
(using the <code title=attr-style-src><a href="#src0">src</a></code> |
| 2862 |
|
|
attribute) to a resource that is either unavailable, or not of the type |
| 2863 |
|
|
specified by the <code title=attr-xbl-style-type><a |
| 2864 |
|
|
href="#style-type">style-type</a></code> attribute of the <code><a |
| 2865 |
|
|
href="#xbl0">xbl</a></code> element (or implied by its absence), then it |
| 2866 |
|
|
is <a href="#in-error">in error</a> and the UA must <a |
| 2867 |
|
|
href="#ignoring">ignore</a> it. In both cases, "ignoring it" means it |
| 2868 |
|
|
must not be used to style anything.</p> |
| 2869 |
|
|
|
| 2870 |
|
|
<p>How UAs must handle nodes inside <code><a |
| 2871 |
|
|
href="#style2">style</a></code> elements depends on the language used. |
| 2872 |
|
|
(See: <a href="#binding22">binding style sheets</a>.)</p> |
| 2873 |
|
|
|
| 2874 |
|
|
<p>For a summary of the various ways that content can be styled in the |
| 2875 |
|
|
presence of XBL, see the <a href="#styleSummary">styling summary |
| 2876 |
|
|
section</a>.</p> |
| 2877 |
|
|
|
| 2878 |
|
|
<h3 id=the-prefetch><span class=secno>2.14. </span>The <dfn |
| 2879 |
|
|
id=prefetch0><code>prefetch</code></dfn> Element</h3> |
| 2880 |
|
|
|
| 2881 |
|
|
<dl> |
| 2882 |
|
|
<dt>Expected context: |
| 2883 |
|
|
|
| 2884 |
|
|
<dd><code><a href="#resources1">resources</a></code> |
| 2885 |
|
|
|
| 2886 |
|
|
<dt>Expected children: |
| 2887 |
|
|
|
| 2888 |
|
|
<dd><span class=ja-translation lang=ja>なし。</span></dl> |
| 2889 |
|
|
|
| 2890 |
|
|
<p class=note>The <code><a href="#prefetch0">prefetch</a></code> element |
| 2891 |
|
|
can be used to list resources that may be pre-loaded for performance |
| 2892 |
|
|
reasons.</p> |
| 2893 |
|
|
|
| 2894 |
|
|
<p>Support for this element is optional. UAs may <a |
| 2895 |
|
|
href="#ignoring">ignore</a> it.</p> |
| 2896 |
|
|
|
| 2897 |
|
|
<h4 class="no-toc no-num" id=attributes15>Attributes</h4> |
| 2898 |
|
|
|
| 2899 |
|
|
<dl> |
| 2900 |
|
|
<dt><dfn id=id11 title=attr-prefetch-id>id</dfn> |
| 2901 |
|
|
|
| 2902 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 2903 |
|
|
|
| 2904 |
|
|
<dt><dfn id=src1 title=attr-prefetch-src>src</dfn> |
| 2905 |
|
|
|
| 2906 |
|
|
<dd>A <a href="#attributes24">URI</a> to a resource (such as an image) |
| 2907 |
|
|
that the binding might use later. |
| 2908 |
|
|
</dl> |
| 2909 |
|
|
|
| 2910 |
|
|
<div class=example id=prefetch-element-example> |
| 2911 |
|
|
<p>The following binding uses two images; it sets the source of an HTML |
| 2912 |
|
|
<code>img</code> element programmatically to refer to those images. To |
| 2913 |
|
|
increase the chance that the "green.png" image is available straight |
| 2914 |
|
|
away when it is used, it uses a <code><a |
| 2915 |
|
|
href="#prefetch0">prefetch</a></code> element and specifies that that |
| 2916 |
|
|
image will be needed.</p> |
| 2917 |
|
|
|
| 2918 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 2919 |
|
|
xmlns:html="http://www.w3.org/1999/xhtml"> |
| 2920 |
|
|
<binding id="light"> |
| 2921 |
|
|
<template> |
| 2922 |
|
|
<html:img id="l" src="red.png" alt=""/> |
| 2923 |
|
|
</template> |
| 2924 |
|
|
<resources> |
| 2925 |
|
|
<prefetch src="red.png"/> <!-- this one isn't necessary, since |
| 2926 |
|
|
the UA will fetch this one as soon as it sees the <html:img> element --> |
| 2927 |
|
|
<prefetch src="green.png"/> |
| 2928 |
|
|
</resources> |
| 2929 |
|
|
<implementation> |
| 2930 |
|
|
({ |
| 2931 |
|
|
red: function() { |
| 2932 |
|
|
this.shadowTree.getElementById('l').src = 'red.png'; |
| 2933 |
|
|
}, |
| 2934 |
|
|
green: function() { |
| 2935 |
|
|
this.shadowTree.getElementById('l').src = 'green.png'; |
| 2936 |
|
|
}, |
| 2937 |
|
|
}) |
| 2938 |
|
|
</implementation> |
| 2939 |
|
|
</binding> |
| 2940 |
|
|
</xbl></pre> |
| 2941 |
|
|
|
| 2942 |
|
|
<p>This binding might be used as follows:</p> |
| 2943 |
|
|
|
| 2944 |
|
|
<pre><!DOCTYPE HTML> |
| 2945 |
|
|
<html> |
| 2946 |
|
|
<head> |
| 2947 |
|
|
<title>Light Demo</title> |
| 2948 |
|
|
<style> |
| 2949 |
|
|
#light { binding: url(demo.xml#light); } |
| 2950 |
|
|
</style> |
| 2951 |
|
|
</head> |
| 2952 |
|
|
<body> |
| 2953 |
|
|
<p id="light">Red</p> |
| 2954 |
|
|
<p> |
| 2955 |
|
|
<input type="button" onclick="doRed()" value="red"> |
| 2956 |
|
|
<input type="button" onclick="doGreen()" value="green"> |
| 2957 |
|
|
</p> |
| 2958 |
|
|
<script> |
| 2959 |
|
|
var light = document.getElementById('light'); |
| 2960 |
|
|
function doRed() { |
| 2961 |
|
|
light.textContent = "Red"; |
| 2962 |
|
|
if (light.red) |
| 2963 |
|
|
// binding might not be applied, so only call the method if it is defined |
| 2964 |
|
|
light.red(); |
| 2965 |
|
|
} |
| 2966 |
|
|
function doGreen() { |
| 2967 |
|
|
light.textContent = "Green"; |
| 2968 |
|
|
if (light.green) // same |
| 2969 |
|
|
light.green(); |
| 2970 |
|
|
} |
| 2971 |
|
|
</script> |
| 2972 |
|
|
</body> |
| 2973 |
|
|
</html></pre> |
| 2974 |
|
|
|
| 2975 |
|
|
<p>Ok, so this example is a little far fetched. So are most of the |
| 2976 |
|
|
examples in this spec. They're just examples!</p> |
| 2977 |
|
|
</div> |
| 2978 |
|
|
|
| 2979 |
|
|
<h3 id=the-script><span class=secno>2.15. </span>The <dfn |
| 2980 |
|
|
id=script2><code>script</code></dfn> Element</h3> |
| 2981 |
|
|
|
| 2982 |
|
|
<dl> |
| 2983 |
|
|
<dt>Expected context: |
| 2984 |
|
|
|
| 2985 |
|
|
<dd><code><a href="#xbl0">xbl</a></code> |
| 2986 |
|
|
|
| 2987 |
|
|
<dt>Expected children: |
| 2988 |
|
|
|
| 2989 |
|
|
<dd>If the element has no <code title=attr-script-src><a |
| 2990 |
|
|
href="#src2">src</a></code> attribute: depends on the scripting |
| 2991 |
|
|
language. |
| 2992 |
|
|
|
| 2993 |
|
|
<dd>If the element does have a <code title=attr-script-src><a |
| 2994 |
|
|
href="#src2">src</a></code> attribute: none. |
| 2995 |
|
|
</dl> |
| 2996 |
|
|
|
| 2997 |
|
|
<p class=note>The <code><a href="#script2">script</a></code> element |
| 2998 |
|
|
contains code that is executed when the XBL subtree is loaded. It can |
| 2999 |
|
|
therefore be used to define helper functions used by the bindings.</p> |
| 3000 |
|
|
|
| 3001 |
|
|
<p>The <code><a href="#script2">script</a></code> element, when present, |
| 3002 |
|
|
must either contain code in the language specified by the XBL subtree's |
| 3003 |
|
|
<code title=attr-xbl-script-type><a |
| 3004 |
|
|
href="#script-type">script-type</a></code> attribute, or have a <code |
| 3005 |
|
|
title=attr-script-src><a href="#src2">src</a></code> attribute that |
| 3006 |
|
|
points to a resource containing code in the language specified by the |
| 3007 |
|
|
<code title=attr-xbl-script-type><a |
| 3008 |
|
|
href="#script-type">script-type</a></code> attribute. The syntax and |
| 3009 |
|
|
semantics of this code depend on the specific language. (See: <a |
| 3010 |
|
|
href="#loading6">loading and running scripts</a>.)</p> |
| 3011 |
|
|
|
| 3012 |
|
|
<h4 class="no-toc no-num" id=attributes16>Attributes</h4> |
| 3013 |
|
|
|
| 3014 |
|
|
<dl> |
| 3015 |
|
|
<dt><dfn id=id12 title=attr-script-id>id</dfn> |
| 3016 |
|
|
|
| 3017 |
|
|
<dd>The <a href="#id13" title=attr-id><code>id</code> attribute</a>. |
| 3018 |
|
|
|
| 3019 |
|
|
<dt><dfn id=src2 title=attr-script-src>src</dfn> |
| 3020 |
|
|
|
| 3021 |
|
|
<dd>The <code title=attr-script-src><a href="#src2">src</a></code> |
| 3022 |
|
|
attribute specifies the <a href="#attributes24">URI</a> to a resource of |
| 3023 |
|
|
the type given by the XBL subtree's <code title=attr-xbl-script-type><a |
| 3024 |
|
|
href="#script-type">script-type</a></code> attribute. If the attribute |
| 3025 |
|
|
is specified, the contents of the element must be ignored (even if the |
| 3026 |
|
|
resource could not be fetched or was of the wrong type). (See: <a |
| 3027 |
|
|
href="#loading6">loading and running scripts</a>.) |
| 3028 |
|
|
</dl> |
| 3029 |
|
|
|
| 3030 |
|
|
<p>If an <code><a href="#script2">script</a></code> element is marked (via |
| 3031 |
|
|
the <code title=attr-xbl-script-type><a |
| 3032 |
|
|
href="#script-type">script-type</a></code> attribute of the <code><a |
| 3033 |
|
|
href="#xbl0">xbl</a></code> element) as being in a language that the UA |
| 3034 |
|
|
does not support, the UA must <a href="#ignoring">ignore</a> it. |
| 3035 |
|
|
Similarly, if the <code><a href="#script2">script</a></code> element |
| 3036 |
|
|
points (using the <code title=attr-script-src><a |
| 3037 |
|
|
href="#src2">src</a></code> attribute) to a resource that is either |
| 3038 |
|
|
unavailable, or not of the type specified by the <code |
| 3039 |
|
|
title=attr-xbl-script-type><a href="#script-type">script-type</a></code> |
| 3040 |
|
|
attribute of the <code><a href="#xbl0">xbl</a></code> element (or implied |
| 3041 |
|
|
by its absence), then it is <a href="#in-error">in error</a> and the UA |
| 3042 |
|
|
must <a href="#ignoring">ignore</a> it. In both cases, "ignoring it" |
| 3043 |
|
|
means that the script must not be executed.</p> |
| 3044 |
|
|
|
| 3045 |
|
|
<p>How UAs must handle nodes inside <code><a |
| 3046 |
|
|
href="#script2">script</a></code> elements depends on the language used. |
| 3047 |
|
|
(See: <a href="#loading6">loading and running scripts</a>.)</p> |
| 3048 |
|
|
|
| 3049 |
|
|
<p><code><a href="#script2">script</a></code> blocks must be evaluated |
| 3050 |
|
|
when their end-tag is parsed, or, for dynamically created elements, when |
| 3051 |
|
|
they are first inserted into a document. This is the case whether or not |
| 3052 |
|
|
the elements are <a href="#in-error">in |
| 3053 |
|
|
error</a><!--[uncomment this is people |
| 3054 |
|
|
demand more] (because script processing is not considered to be part |
| 3055 |
|
|
of XBL processing)-->. |
| 3056 |
|
|
Once evaluation has started, a <code><a href="#script2">script</a></code> |
| 3057 |
|
|
block is dead and changes to its contents or attributes have no effect.</p> |
| 3058 |
|
|
|
| 3059 |
|
|
<h3 id=the-id><span class=secno>2.16. </span>The <dfn id=id13 |
| 3060 |
|
|
title=attr-id><code>id</code></dfn> Attribute of XBL Elements</h3> |
| 3061 |
|
|
|
| 3062 |
|
|
<dl> |
| 3063 |
|
|
<dt>Expected element: |
| 3064 |
|
|
|
| 3065 |
|
|
<dd>Any element in the XBL namespace. |
| 3066 |
|
|
</dl> |
| 3067 |
|
|
|
| 3068 |
|
|
<p class=note>The <code title=attr-id><a href="#id13">id</a></code> |
| 3069 |
|
|
attribute assigns an identifier to an element.</p> |
| 3070 |
|
|
|
| 3071 |
|
|
<p>The given identifier must be unique in the <a href="#binding15">binding |
| 3072 |
|
|
document</a>. The <code title=attr-id><a href="#id13">id</a></code> |
| 3073 |
|
|
attribute is of type ID. <a href="#refsXML">[XML]</a>.</p> |
| 3074 |
|
|
|
| 3075 |
|
|
<p>If the attribute's value is the empty string, the attribute must not |
| 3076 |
|
|
set an ID. Otherwise, the attribute's value must be treated as (one of) |
| 3077 |
|
|
the element's ID(s).</p> |
| 3078 |
|
|
|
| 3079 |
|
|
<h2 id=binding><span class=secno>3. </span><dfn id=binding17>Binding |
| 3080 |
|
|
Attachment and Detachment</dfn></h2> |
| 3081 |
|
|
|
| 3082 |
|
|
<p>Bindings can be attached and detached dynamically, using several |
| 3083 |
|
|
mechanisms.</p> |
| 3084 |
|
|
|
| 3085 |
|
|
<p>Bindings must be attached as soon as the following conditions have all |
| 3086 |
|
|
been met:</p> |
| 3087 |
|
|
|
| 3088 |
|
|
<ul> |
| 3089 |
|
|
<li>it is known that the binding applies to the element, |
| 3090 |
|
|
|
| 3091 |
|
|
<li>the DOM <code>Element</code> object for the element has been created, |
| 3092 |
|
|
and |
| 3093 |
|
|
|
| 3094 |
|
|
<li>the binding document defining the binding has loaded. |
| 3095 |
|
|
</ul> |
| 3096 |
|
|
|
| 3097 |
|
|
<p>In particular, binding can happen before the element is inserted into |
| 3098 |
|
|
its document.</p> |
| 3099 |
|
|
|
| 3100 |
|
|
<p>If the binding document was already loaded when the element was |
| 3101 |
|
|
created, or when it became known that the element matched the binding |
| 3102 |
|
|
(e.g. because the binding's <code title=attr-binding-element><a |
| 3103 |
|
|
href="#element">element</a></code> attribute is mutated in a script), |
| 3104 |
|
|
then the binding must be applied such that to any running scripts, |
| 3105 |
|
|
notwithstanding those implementing <code><a |
| 3106 |
|
|
href="#xblbindingattached">xblBindingAttached()</a></code> notification |
| 3107 |
|
|
methods, it appears that the binding was applied immediately. When |
| 3108 |
|
|
mutation events are to fire, they must fire <em>after</em> the binding |
| 3109 |
|
|
being applied.</p> |
| 3110 |
|
|
|
| 3111 |
|
|
<p>If the binding document has yet to be (fully) loaded when it becomes |
| 3112 |
|
|
known that the binding applies, then the user agent must wait until all |
| 3113 |
|
|
running scripts have completed before attaching the binding.</p> |
| 3114 |
|
|
<!-- XXX someone complained last time i used that term |
| 3115 |
|
|
("run to completion"), and suggested better text. In the WA1 spec, I |
| 3116 |
|
|
think. Use that here. [in the thread-safe storage bit, iirc] --> |
| 3117 |
|
|
|
| 3118 |
|
|
<p class=note>If the binding attachment mechanism is the <code |
| 3119 |
|
|
title="binding property"><a href="#binding18">'binding'</a></code> |
| 3120 |
|
|
property, then it does not become known to the user agent that the |
| 3121 |
|
|
binding applies (or does not apply) until the next time style resolution |
| 3122 |
|
|
is performed. This specification does not define when style resolution |
| 3123 |
|
|
happens.</p> |
| 3124 |
|
|
<!-- XXX who does. HTML5? --> |
| 3125 |
|
|
<div class=example> |
| 3126 |
|
|
<p>Assume that <code title="">foo.xml</code> defines a binding that |
| 3127 |
|
|
applies to all "<code title="">foo</code>" elements. The following |
| 3128 |
|
|
script uses <code title=loadBindingDocument><a |
| 3129 |
|
|
href="#loadbindingdocument">loadBindingDocument()</a></code> to ensure |
| 3130 |
|
|
that <code title="">foo.xml</code> is loaded, then creates a <code |
| 3131 |
|
|
title="">foo</code> element and uses it.</p> |
| 3132 |
|
|
|
| 3133 |
|
|
<pre>// load the binding document |
| 3134 |
|
|
document.loadBindingDocument('foo.xml'); // this is synchronous |
| 3135 |
|
|
|
| 3136 |
|
|
// create an element <foo> |
| 3137 |
|
|
var foo = document.createElement('foo'); // binds synchronously too |
| 3138 |
|
|
foo.myCustomMethod(); // calls the binding's implementation</pre> |
| 3139 |
|
|
|
| 3140 |
|
|
<p>Without the call to <code title=loadBindingDocument><a |
| 3141 |
|
|
href="#loadbindingdocument">loadBindingDocument()</a></code>, if the |
| 3142 |
|
|
binding document wasn't loaded yet the element wouldn't be bound |
| 3143 |
|
|
straight away, and the last line would fail.</p> |
| 3144 |
|
|
</div> |
| 3145 |
|
|
|
| 3146 |
|
|
<p>Bindings must be detached as soon as it is known that the binding no |
| 3147 |
|
|
longer applies to the element. In the case of attachment using the '<code |
| 3148 |
|
|
title="binding property"><a href="#binding18">binding</a></code>' |
| 3149 |
|
|
property, this won't be until the next time style resolution is |
| 3150 |
|
|
performed.</p> |
| 3151 |
|
|
|
| 3152 |
|
|
<p>When it becomes known that a binding is to be detached, it must happen |
| 3153 |
|
|
such that to any running scripts it appears that the binding was removed |
| 3154 |
|
|
immediately, except if the script in question is running as part of the |
| 3155 |
|
|
last step of the binding attachment process, in which case the detachment |
| 3156 |
|
|
happens after all the bindings being attached have had their methods |
| 3157 |
|
|
called. (See: <a href="#binding19">binding attachment model</a>.)</p> |
| 3158 |
|
|
<!-- XXX this contradicts what is said elsewhere; could make this |
| 3159 |
|
|
work by saying "except if there is an xblFoo notification method |
| 3160 |
|
|
running" or something --> |
| 3161 |
|
|
|
| 3162 |
|
|
<h3 id=the-bindings-are-ready><span class=secno>3.1. </span><dfn |
| 3163 |
|
|
id=the-bindings-are-ready1>The Bindings-Are-Ready State</dfn></h3> |
| 3164 |
|
|
|
| 3165 |
|
|
<p>XBL implementations must have a <dfn |
| 3166 |
|
|
id=bindings-are-ready>bindings-are-ready</dfn> counter (for each |
| 3167 |
|
|
<code>Document</code>) that keeps track of when there are outstanding |
| 3168 |
|
|
bindings to bind. This counter is set at the times given in the following |
| 3169 |
|
|
sections. (It is not set for all kinds of attachments.)</p> |
| 3170 |
|
|
|
| 3171 |
|
|
<p>If the bound document is being parsed by the user agent, then, as soon |
| 3172 |
|
|
as all the following conditions have been met, the user agent must fire |
| 3173 |
|
|
an <dfn |
| 3174 |
|
|
id=xbl-bindings-are-ready><code>xbl-bindings-are-ready</code></dfn> event |
| 3175 |
|
|
on the document's root element. The conditions are:</p> |
| 3176 |
|
|
|
| 3177 |
|
|
<ul> |
| 3178 |
|
|
<li> the document has finished parsing, |
| 3179 |
|
|
|
| 3180 |
|
|
<li> the <a href="#bindings-are-ready">bindings-are-ready</a> counter is |
| 3181 |
|
|
at zero, |
| 3182 |
|
|
|
| 3183 |
|
|
<li> all bindings that are known to apply to elements have been |
| 3184 |
|
|
completely applied, and |
| 3185 |
|
|
|
| 3186 |
|
|
<li> no scripts are running. |
| 3187 |
|
|
</ul> |
| 3188 |
|
|
|
| 3189 |
|
|
<p>The event must use the <code>Event</code> interface, must bubble, must |
| 3190 |
|
|
not be cancelable, and must not have a default action. <a |
| 3191 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 3192 |
|
|
|
| 3193 |
|
|
<p>Initially, the <a href="#bindings-are-ready">bindings-are-ready</a> |
| 3194 |
|
|
counter must be set to zero.</p> |
| 3195 |
|
|
|
| 3196 |
|
|
<p>The bound document's <code>load</code> event must not fire until after |
| 3197 |
|
|
the <code><a |
| 3198 |
|
|
href="#xbl-bindings-are-ready">xbl-bindings-are-ready</a></code> event |
| 3199 |
|
|
has fired. The <code><a |
| 3200 |
|
|
href="#xbl-bindings-are-ready">xbl-bindings-are-ready</a></code> event |
| 3201 |
|
|
must fire even in the complete absence of any use of XBL in the document.</p> |
| 3202 |
|
|
|
| 3203 |
|
|
<p>The <code><a |
| 3204 |
|
|
href="#xbl-bindings-are-ready">xbl-bindings-are-ready</a></code> event |
| 3205 |
|
|
must only fire once per document load.</p> |
| 3206 |
|
|
|
| 3207 |
|
|
<h3 id=attachment><span class=secno>3.2. </span><dfn id=attachment4 |
| 3208 |
|
|
title="attachment using binding">Attachment using <code |
| 3209 |
|
|
title=binding><binding element=""></code></dfn></h3> |
| 3210 |
|
|
|
| 3211 |
|
|
<p>The simplest binding mechanism is the <code><a |
| 3212 |
|
|
href="#binding16">binding</a></code> element's <code |
| 3213 |
|
|
title=attr-binding-element><a href="#element">element</a></code> |
| 3214 |
|
|
attribute. It declares which bindings should be attached to which |
| 3215 |
|
|
elements. (See: <a href="#attributes21" title=selector>attributes |
| 3216 |
|
|
containing selectors</a>, <a href="#element" |
| 3217 |
|
|
title=attr-binding-element>the <code title="">binding</code> |
| 3218 |
|
|
element</a>.)</p> |
| 3219 |
|
|
|
| 3220 |
|
|
<p>While an element matches the <code title=attr-binding-element><a |
| 3221 |
|
|
href="#element">element</a></code> attribute of one or more of the |
| 3222 |
|
|
<code><a href="#binding16">binding</a></code> elements that is <a |
| 3223 |
|
|
href="#importing1" title=import>imported</a> into, or defined in, the |
| 3224 |
|
|
element's document, the bindings defined by each such <code><a |
| 3225 |
|
|
href="#binding16">binding</a></code> element must be bound to the |
| 3226 |
|
|
element. This applies to all elements that are associated with a |
| 3227 |
|
|
document, even when they have not yet been inserted into the document, or |
| 3228 |
|
|
are not in the <a href="#final0">final flattened tree</a>.</p> |
| 3229 |
|
|
|
| 3230 |
|
|
<h4 id=importing><span class=secno>3.2.1. </span><dfn id=importing1 |
| 3231 |
|
|
title=import>Importing Binding Documents</dfn></h4> |
| 3232 |
|
|
|
| 3233 |
|
|
<p>There are two ways to import binding documents (and thus have their |
| 3234 |
|
|
<code title=binding><a href="#binding16"><binding |
| 3235 |
|
|
element=""></a></code> bindings apply): <a href="#the-ltxblgt" |
| 3236 |
|
|
title=xbl-pi>the <code><?xbl?></code> processing instruction</a>, |
| 3237 |
|
|
and the <code><a |
| 3238 |
|
|
href="#loadbindingdocument">loadBindingDocument()</a></code> method. The |
| 3239 |
|
|
latter is defined in the section on the <code><a |
| 3240 |
|
|
href="#documentxbl">DocumentXBL</a></code> interface.</p> |
| 3241 |
|
|
|
| 3242 |
|
|
<p><dfn id=the-ltxblgt title=xbl-pi>The <code><?xbl?></code> |
| 3243 |
|
|
processing instruction</dfn> specifies a binding document to load. Any |
| 3244 |
|
|
bindings <a href="#attachment4" title="attachment using binding">defined |
| 3245 |
|
|
in that document</a> must be applied to matching elements in the document |
| 3246 |
|
|
with the processing instruction.</p> |
| 3247 |
|
|
|
| 3248 |
|
|
<p><code><?xbl?></code> processing instructions that occur after the |
| 3249 |
|
|
root element's start tag in the markup are <a href="#in-error">in |
| 3250 |
|
|
error</a>. <code><?xbl?></code> PIs that are dynamically inserted |
| 3251 |
|
|
through the DOM after the root element's start tag has been parsed or the |
| 3252 |
|
|
root element has been attached to the document are <a href="#in-error">in |
| 3253 |
|
|
error</a> too.</p> |
| 3254 |
|
|
|
| 3255 |
|
|
<p>A <code><?xbl?></code> processing instruction that is not <a |
| 3256 |
|
|
href="#in-error">in error</a> according to the above must be parsed using |
| 3257 |
|
|
the same syntax as the XML Stylesheet PI. <a |
| 3258 |
|
|
href="#refsXMLSSPI">[XMLSSPI]</a> If there are any parse errors, then the |
| 3259 |
|
|
entire processing instruction is <a href="#in-error">in error</a>.</p> |
| 3260 |
|
|
|
| 3261 |
|
|
<p>Otherwise, if it has an <dfn id=href |
| 3262 |
|
|
title=attr-import-href><code>href</code></dfn> pseudo-attribute then it |
| 3263 |
|
|
specifies the <a href="#attributes24">URI</a> of the binding document to |
| 3264 |
|
|
import. If the URI cannot be resolved, or returns an error, or does not |
| 3265 |
|
|
point to a resource with <span>an XML MIME type</span><!-- XXX |
| 3266 |
|
|
xref -->, |
| 3267 |
|
|
or has any other problem that makes it unusable, then the processing |
| 3268 |
|
|
instruction is <a href="#in-error">in error</a>.</p> |
| 3269 |
|
|
|
| 3270 |
|
|
<p>If a processing instruction is <a href="#in-error">in error</a> (as |
| 3271 |
|
|
described in the previous few paragraphs) then it must be ignored.</p> |
| 3272 |
|
|
|
| 3273 |
|
|
<p>Otherwise, the referenced document must be loaded (unless it has <a |
| 3274 |
|
|
href="#loading5" title="loading external resources">already been |
| 3275 |
|
|
loaded</a>), and any bindings defined by that document must be applied to |
| 3276 |
|
|
matching elements in the document that contained the PI. Once loaded, the |
| 3277 |
|
|
binding document is added to the <code><a |
| 3278 |
|
|
href="#bindingdocuments">bindingDocuments</a></code> list of the document |
| 3279 |
|
|
with the PI.</p> |
| 3280 |
|
|
|
| 3281 |
|
|
<p>Dynamic changes to <code><?xbl?></code> processing instructions |
| 3282 |
|
|
must be ignored from an XBL standpoint.</p> |
| 3283 |
|
|
|
| 3284 |
|
|
<p>An imported binding document is <em>live</em>.</p> |
| 3285 |
|
|
|
| 3286 |
|
|
<p class=example>For example, if new <code><a |
| 3287 |
|
|
href="#binding16">binding</a></code> elements are added to an imported |
| 3288 |
|
|
binding document (via the DOM), then the new bindings are immediately |
| 3289 |
|
|
applied to the document that had the PI importing that binding document.</p> |
| 3290 |
|
|
|
| 3291 |
|
|
<p>XBL bindings are always implicitly imported into the document in which |
| 3292 |
|
|
they are defined.</p> |
| 3293 |
|
|
|
| 3294 |
|
|
<p>Whenever an <code><?xbl?></code> PI causes a binding document to be |
| 3295 |
|
|
loaded, the document's <a |
| 3296 |
|
|
href="#bindings-are-ready">bindings-are-ready</a> counter must be |
| 3297 |
|
|
increased by one. Once the binding document is loaded, the counter must |
| 3298 |
|
|
be decreased by one.</p> |
| 3299 |
|
|
|
| 3300 |
|
|
<div class=example> |
| 3301 |
|
|
<p>An XBL subtree that defines some bindings is automatically imported in |
| 3302 |
|
|
that document, so such mappings are always used. The following example |
| 3303 |
|
|
demonstrates this.</p> |
| 3304 |
|
|
|
| 3305 |
|
|
<pre><strong>example.xml</strong> |
| 3306 |
|
|
|
| 3307 |
|
|
<...> |
| 3308 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" ...> |
| 3309 |
|
|
<binding element="foo"> |
| 3310 |
|
|
... |
| 3311 |
|
|
</binding> |
| 3312 |
|
|
<binding element="bar"> |
| 3313 |
|
|
... |
| 3314 |
|
|
</binding> |
| 3315 |
|
|
</xbl ...> |
| 3316 |
|
|
<foo xmlns=""/> <!-- this will have a binding applied --> |
| 3317 |
|
|
<bar xmlns=""/> <!-- this will have a binding applied --> |
| 3318 |
|
|
</...> |
| 3319 |
|
|
</pre> |
| 3320 |
|
|
|
| 3321 |
|
|
<p>If the binding definitions are in a separate file, then that file |
| 3322 |
|
|
needs to be imported explicitly:</p> |
| 3323 |
|
|
|
| 3324 |
|
|
<pre><strong>widgets.xml</strong> |
| 3325 |
|
|
|
| 3326 |
|
|
<...> |
| 3327 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" ...> |
| 3328 |
|
|
<binding element="foo"> |
| 3329 |
|
|
... |
| 3330 |
|
|
</binding> |
| 3331 |
|
|
<binding element="bar"> |
| 3332 |
|
|
... |
| 3333 |
|
|
</binding> |
| 3334 |
|
|
</xbl ...> |
| 3335 |
|
|
</...> |
| 3336 |
|
|
</pre> |
| 3337 |
|
|
|
| 3338 |
|
|
<pre><strong>example.xml</strong> |
| 3339 |
|
|
|
| 3340 |
|
|
<em><?xbl href="widgets.xml"?></em> |
| 3341 |
|
|
<...> |
| 3342 |
|
|
<foo/> <!-- bound --> |
| 3343 |
|
|
<bar/> <!-- bound --> |
| 3344 |
|
|
</...> |
| 3345 |
|
|
</pre> |
| 3346 |
|
|
|
| 3347 |
|
|
<p>If a file imports some bindings and the file containing those bindings |
| 3348 |
|
|
has its own <code><?xbl?></code> processing instructions, that |
| 3349 |
|
|
second PI only affects nodes in the binding document, not the original |
| 3350 |
|
|
document. For example:</p> |
| 3351 |
|
|
|
| 3352 |
|
|
<pre><strong>foo.xml</strong> |
| 3353 |
|
|
|
| 3354 |
|
|
<...> |
| 3355 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" ...> |
| 3356 |
|
|
<binding element="foo"> |
| 3357 |
|
|
<content> |
| 3358 |
|
|
<bar xmlns=""/> <!-- not bound, not even when in shadow content --> |
| 3359 |
|
|
</content> |
| 3360 |
|
|
</binding> |
| 3361 |
|
|
</xbl> |
| 3362 |
|
|
</...> |
| 3363 |
|
|
</pre> |
| 3364 |
|
|
|
| 3365 |
|
|
<pre><strong>bar.xml</strong> |
| 3366 |
|
|
|
| 3367 |
|
|
<?xbl href="foo.xml"?> |
| 3368 |
|
|
<...> |
| 3369 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" ...> |
| 3370 |
|
|
<binding element="bar"> |
| 3371 |
|
|
<content> |
| 3372 |
|
|
<foo xmlns=""/> <!-- bound: this document imports foo.xml --> |
| 3373 |
|
|
<bar xmlns=""/> <!-- bound: bar binding is defined locally --> |
| 3374 |
|
|
</content> |
| 3375 |
|
|
</binding> |
| 3376 |
|
|
</xbl> |
| 3377 |
|
|
</...> |
| 3378 |
|
|
</pre> |
| 3379 |
|
|
|
| 3380 |
|
|
<pre><strong>example.xml</strong> |
| 3381 |
|
|
|
| 3382 |
|
|
<?xbl href="bar.xml"?> |
| 3383 |
|
|
<...> |
| 3384 |
|
|
<foo/> <!-- not bound: foo.xml not imported here --> |
| 3385 |
|
|
<bar/> <!-- bound --> |
| 3386 |
|
|
</...> |
| 3387 |
|
|
</pre> |
| 3388 |
|
|
</div> |
| 3389 |
|
|
|
| 3390 |
|
|
<h3 id=attachment0><span class=secno>3.3. </span>Attachment using CSS</h3> |
| 3391 |
|
|
|
| 3392 |
|
|
<p>Bindings can be attached to elements through CSS using the '<code |
| 3393 |
|
|
title="binding property"><a href="#binding18">binding</a></code>' |
| 3394 |
|
|
property.</p> |
| 3395 |
|
|
|
| 3396 |
|
|
<div class=example> |
| 3397 |
|
|
<p>In the following example, a binding is referenced that will be |
| 3398 |
|
|
attached to all XHTML checkbox elements.</p> |
| 3399 |
|
|
|
| 3400 |
|
|
<pre> |
| 3401 |
|
|
input[type="checkbox"] { |
| 3402 |
|
|
binding: url("http://www.example.org/xbl/htmlBindings.xml#checkbox"); |
| 3403 |
|
|
} |
| 3404 |
|
|
</pre> |
| 3405 |
|
|
</div> |
| 3406 |
|
|
|
| 3407 |
|
|
<p>Bindings attached through CSS must only remain on the bound element as |
| 3408 |
|
|
long as the element continues to match the style rule. If at any time a |
| 3409 |
|
|
resolution of style on the element determines that a different binding |
| 3410 |
|
|
should be attached, the old binding (and all bindings that it explicitly |
| 3411 |
|
|
extends in its <a href="#explicit1">explicit inheritance chain</a>) must |
| 3412 |
|
|
be detached.</p> |
| 3413 |
|
|
|
| 3414 |
|
|
<p>Whenever an element is removed from a document, any bindings attached |
| 3415 |
|
|
to that element via CSS must be detached.</p> |
| 3416 |
|
|
|
| 3417 |
|
|
<p class=note>Attaching a binding using CSS does not <a |
| 3418 |
|
|
href="#importing1">import</a> the binding document. The <code |
| 3419 |
|
|
title=attr-binding-element><a href="#element">element</a></code> |
| 3420 |
|
|
attributes of <code><a href="#binding16">binding</a></code> elements in |
| 3421 |
|
|
the binding document do not take effect unless the binding document is |
| 3422 |
|
|
imported. (See: <a href="#importing1" title=import>importing binding |
| 3423 |
|
|
documents</a>.)</p> |
| 3424 |
|
|
|
| 3425 |
|
|
<p>Attaching using CSS does not affect the <a |
| 3426 |
|
|
href="#bindings-are-ready">bindings-are-ready</a> counter.</p> |
| 3427 |
|
|
|
| 3428 |
|
|
<h4 id=the-binding0><span class=secno>3.3.1. </span>The '<code |
| 3429 |
|
|
title="binding property"><a href="#binding18">binding</a></code>' |
| 3430 |
|
|
Property</h4> |
| 3431 |
|
|
|
| 3432 |
|
|
<p>A property to attach a binding to a particular element.</p> |
| 3433 |
|
|
|
| 3434 |
|
|
<table class=propdef id=binding6> |
| 3435 |
|
|
<caption> <dfn id=binding18 title="binding |
| 3436 |
|
|
property">'<code>binding</code>'</dfn></caption> |
| 3437 |
|
|
|
| 3438 |
|
|
<tbody> |
| 3439 |
|
|
<tr> |
| 3440 |
|
|
<td><em>Value:</em> |
| 3441 |
|
|
|
| 3442 |
|
|
<td>none | [ <uri> ]* <uri> |
| 3443 |
|
|
<!--XXXPD <predefined binding>--> |
| 3444 |
|
|
|
| 3445 |
|
|
<tr> |
| 3446 |
|
|
<td><em>Initial:</em> |
| 3447 |
|
|
|
| 3448 |
|
|
<td>none |
| 3449 |
|
|
|
| 3450 |
|
|
<tr> |
| 3451 |
|
|
<td><em>Applies To:</em> |
| 3452 |
|
|
|
| 3453 |
|
|
<td>all elements (but not pseudo-elements) |
| 3454 |
|
|
|
| 3455 |
|
|
<tr> |
| 3456 |
|
|
<td><em title="">Inherited:</em> |
| 3457 |
|
|
|
| 3458 |
|
|
<td>no |
| 3459 |
|
|
|
| 3460 |
|
|
<tr> |
| 3461 |
|
|
<td><em>Percentages:</em> |
| 3462 |
|
|
|
| 3463 |
|
|
<td>n/a |
| 3464 |
|
|
|
| 3465 |
|
|
<tr> |
| 3466 |
|
|
<td><em>Media:</em> |
| 3467 |
|
|
|
| 3468 |
|
|
<td>all |
| 3469 |
|
|
|
| 3470 |
|
|
<tr> |
| 3471 |
|
|
<td><em>Computed Value:</em> |
| 3472 |
|
|
|
| 3473 |
|
|
<td>specified value, with URIs resolved to absolute URIs |
| 3474 |
|
|
</table> |
| 3475 |
|
|
|
| 3476 |
|
|
<dl> |
| 3477 |
|
|
<dt>none |
| 3478 |
|
|
|
| 3479 |
|
|
<dd>No bindings are to be attached through CSS. |
| 3480 |
|
|
|
| 3481 |
|
|
<dt><uri> |
| 3482 |
|
|
|
| 3483 |
|
|
<dd>The specified binding is attached. More than one binding can be |
| 3484 |
|
|
specified, resulting in the bindings being attached in the specified |
| 3485 |
|
|
order, with the last binding implicitly inheriting from the previous |
| 3486 |
|
|
one, and so forth, up to the first binding. (See: <a |
| 3487 |
|
|
href="#binding20">binding inheritance</a>.)</dd> |
| 3488 |
|
|
<!--XXXPB |
| 3489 |
|
|
<dt><predefined binding></dt> |
| 3490 |
|
|
<dd>One of the bindings defined in the <a |
| 3491 |
|
|
href="#base-bindings">Predefined Base Bindings</a> section is |
| 3492 |
|
|
attached.</dd> |
| 3493 |
|
|
--> |
| 3494 |
|
|
</dl> |
| 3495 |
|
|
|
| 3496 |
|
|
<h4 id=processing><span class=secno>3.3.2. </span>Processing Model</h4> |
| 3497 |
|
|
|
| 3498 |
|
|
<p>User agents may perform the CSS cascade, inheritance, and computation |
| 3499 |
|
|
stages either across the entire tree, or per element, or per property per |
| 3500 |
|
|
element, and either before applying bindings, or simultaneously, while |
| 3501 |
|
|
applying bindings. In any case, for each element the computed value of |
| 3502 |
|
|
'<code title="binding property"><a href="#binding18">binding</a></code>' |
| 3503 |
|
|
must be found and then used to apply the bindings to the element (when |
| 3504 |
|
|
the element is first styled, and each subsequent time the styles that |
| 3505 |
|
|
match the element change).</p> |
| 3506 |
|
|
|
| 3507 |
|
|
<p>Since each time a binding is applied it can change the computed values |
| 3508 |
|
|
of properties of elements that are descendants of the bound element, this |
| 3509 |
|
|
may require several passes. This may be avoided by computing the value of |
| 3510 |
|
|
the '<code title="binding property"><a |
| 3511 |
|
|
href="#binding18">binding</a></code>' property for the element, and then |
| 3512 |
|
|
applying any bindings, before any of its descendants.</p> |
| 3513 |
|
|
|
| 3514 |
|
|
<h4 id=examples><span class=secno>3.3.3. </span>Examples</h4> |
| 3515 |
|
|
|
| 3516 |
|
|
<div class=example id=triangles-example> |
| 3517 |
|
|
<p>The following XBL document defines two bindings for use in SVG. The |
| 3518 |
|
|
first renders an isosceles triangle in place of bound elements that use |
| 3519 |
|
|
it, the other renders a right-angled triangle in place of bound elements |
| 3520 |
|
|
that use it.</p> |
| 3521 |
|
|
|
| 3522 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl" |
| 3523 |
|
|
xmlns:xbl="http://www.w3.org/ns/xbl"> |
| 3524 |
|
|
<binding id="isosceles"> |
| 3525 |
|
|
<template> |
| 3526 |
|
|
<polygon xbl:attr="transform" points="0 -1, 1 0, -1 0" xmlns="http://www.w3.org/2000/svg"/> |
| 3527 |
|
|
</template> |
| 3528 |
|
|
</binding> |
| 3529 |
|
|
<binding id="rightangle"> |
| 3530 |
|
|
<template> |
| 3531 |
|
|
<polygon xbl:attr="transform" points="0 0, 1 0, 0 -1" xmlns="http://www.w3.org/2000/svg"/> |
| 3532 |
|
|
</template> |
| 3533 |
|
|
</binding> |
| 3534 |
|
|
</xbl></pre> |
| 3535 |
|
|
|
| 3536 |
|
|
<p>Assuming the above file was called <code>triangles.xml</code>, these |
| 3537 |
|
|
bindings could be bound to elements using CSS like so:</p> |
| 3538 |
|
|
|
| 3539 |
|
|
<pre>@namespace triangles url(http://triangles.example.com/); |
| 3540 |
|
|
triangles|isosceles { binding: url(triangles.xml#isosceles); } |
| 3541 |
|
|
triangles|rightangle { binding: url(triangles.xml#rightangle); }</pre> |
| 3542 |
|
|
|
| 3543 |
|
|
<p>If the stylesheet was called <code>triangles.css</code>, an SVG file |
| 3544 |
|
|
using these elements might look like:</p> |
| 3545 |
|
|
|
| 3546 |
|
|
<pre><?xml-stylesheet href="triangles.css"?> |
| 3547 |
|
|
<svg xmlns="http://www.w3.org/2000/svg" |
| 3548 |
|
|
xmlns:t="http://triangles.example.com/"> |
| 3549 |
|
|
<circle cx="10" cy="10" r="5"/> |
| 3550 |
|
|
<rect x="20" y="20" height="5" width="10"/> |
| 3551 |
|
|
<t:isosceles transform="translate(10 20) scale(10)"/> |
| 3552 |
|
|
<t:rightangle transform="translate(20 20) scale(10)"/> |
| 3553 |
|
|
</svg></pre> |
| 3554 |
|
|
|
| 3555 |
|
|
<p>The same example could also be done all in one file like this:</p> |
| 3556 |
|
|
|
| 3557 |
|
|
<pre><svg xmlns="http://www.w3.org/2000/svg" |
| 3558 |
|
|
xmlns:t="http://triangles.example.com/"> |
| 3559 |
|
|
<defs> |
| 3560 |
|
|
<xbl xmlns="http://www.w3.org/ns/xbl" |
| 3561 |
|
|
xmlns:xbl="http://www.w3.org/ns/xbl"> |
| 3562 |
|
|
<binding id="isosceles"> |
| 3563 |
|
|
<template> |
| 3564 |
|
|
<polygon xbl:attr="transform" points="0 -1, 1 0, -1 0" xmlns="http://www.w3.org/2000/svg"/> |
| 3565 |
|
|
</template> |
| 3566 |
|
|
</binding> |
| 3567 |
|
|
<binding id="rightangle"> |
| 3568 |
|
|
<template> |
| 3569 |
|
|
<polygon xbl:attr="transform" points="0 0, 1 0, 0 -1" xmlns="http://www.w3.org/2000/svg"/> |
| 3570 |
|
|
</template> |
| 3571 |
|
|
</binding> |
| 3572 |
|
|
</xbl> |
| 3573 |
|
|
<style type="text/css"> |
| 3574 |
|
|
@namespace triangles url(http://triangles.example.com/); |
| 3575 |
|
|
triangles|isosceles { binding: url(#isosceles); } |
| 3576 |
|
|
triangles|rightangle { binding: url(#rightangle); } |
| 3577 |
|
|
</style> |
| 3578 |
|
|
</defs> |
| 3579 |
|
|
<circle cx="10" cy="10" r="5"/> |
| 3580 |
|
|
<rect x="20" y="20" height="5" width="10"/> |
| 3581 |
|
|
<t:isosceles transform="translate(10 20) scale(10)"/> |
| 3582 |
|
|
<t:rightangle transform="translate(20 20) scale(10)"/> |
| 3583 |
|
|
</svg></pre> |
| 3584 |
|
|
</div> |
| 3585 |
|
|
|
| 3586 |
|
|
<h3 id=attachment1><span class=secno>3.4. </span>Attachment using the DOM</h3> |
| 3587 |
|
|
|
| 3588 |
|
|
<p>Bindings can be attached to elements through the DOM using the <a |
| 3589 |
|
|
href="#dom-interfaces"><code>ElementXBL</code></a> interface. The method |
| 3590 |
|
|
<code><a href="#addbinding">addBinding</a></code> takes a binding URI and |
| 3591 |
|
|
attaches the binding to the element (in all <a href="#view" |
| 3592 |
|
|
title=view>views</a>).</p> |
| 3593 |
|
|
|
| 3594 |
|
|
<pre class="dom |
| 3595 |
|
|
example">var checkbox = document.getElementById("mycheckbox"); |
| 3596 |
|
|
checkbox.addBinding("http://www.example.org/xbl/htmlBindings.xml#checkbox");</pre> |
| 3597 |
|
|
|
| 3598 |
|
|
<p>This attachment is not necessarily synchronous. Scripts that invoke |
| 3599 |
|
|
this method should not assume that the binding is installed immediately |
| 3600 |
|
|
after this method returns. (An <code><a |
| 3601 |
|
|
href="#xbl-bound">xbl-bound</a></code> event is fired when the binding is |
| 3602 |
|
|
installed.)</p> |
| 3603 |
|
|
|
| 3604 |
|
|
<p>When a binding is attached using the DOM, it inherits from the current |
| 3605 |
|
|
<a href="#most-derived">most derived binding</a> that is already attached |
| 3606 |
|
|
to the element, if any. (See: <a href="#binding20">binding |
| 3607 |
|
|
inheritance</a>.)</p> |
| 3608 |
|
|
|
| 3609 |
|
|
<p>Any bindings attached to an element using the <code><a |
| 3610 |
|
|
href="#addbinding">addBinding()</a></code> method will remain on the |
| 3611 |
|
|
element until the element is destroyed or a corresponding <code><a |
| 3612 |
|
|
href="#removebinding">removeBinding()</a></code> call is made.</p> |
| 3613 |
|
|
|
| 3614 |
|
|
<p class=note>Attaching a binding using the <code><a |
| 3615 |
|
|
href="#addbinding">addBinding()</a></code> DOM APIs does not <a |
| 3616 |
|
|
href="#importing1">import</a> the binding document. The <code |
| 3617 |
|
|
title=attr-binding-element><a href="#element">element</a></code> |
| 3618 |
|
|
attributes of <code><a href="#binding16">binding</a></code> elements in |
| 3619 |
|
|
the binding document do not take effect unless the binding document is |
| 3620 |
|
|
imported. (See: <a href="#importing1" title=import>importing binding |
| 3621 |
|
|
documents</a>.)</p> |
| 3622 |
|
|
|
| 3623 |
|
|
<p>Attaching using the <code><a href="#addbinding">addBinding()</a></code> |
| 3624 |
|
|
API does not affect the <a |
| 3625 |
|
|
href="#bindings-are-ready">bindings-are-ready</a> counter.</p> |
| 3626 |
|
|
|
| 3627 |
|
|
<h3 id=binding0><span class=secno>3.5. </span><dfn id=binding19>Binding |
| 3628 |
|
|
Attachment Model</dfn></h3> |
| 3629 |
|
|
|
| 3630 |
|
|
<p>When a new binding is attached, the UA must perform the following steps |
| 3631 |
|
|
in order (or act as if it did). Implementations may choose to suspend |
| 3632 |
|
|
redraw during this process.</p> |
| 3633 |
|
|
|
| 3634 |
|
|
<ol> |
| 3635 |
|
|
<li>If the binding has an <code title=attr-binding-extends><a |
| 3636 |
|
|
href="#extends">extends</a></code> attribute, then the user agent must |
| 3637 |
|
|
immediately consider the binding that the attributes references (if any) |
| 3638 |
|
|
to apply to the bound element as well, and must attach that binding |
| 3639 |
|
|
first, recursively applying these steps to that binding. If this causes |
| 3640 |
|
|
a loop — that is, if a binding directly or indirectly derives from |
| 3641 |
|
|
itself through a chain of one or more <code |
| 3642 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3643 |
|
|
attributes — then the user agent must only apply each binding in |
| 3644 |
|
|
the chain once. (See: <a href="#explicit2">explicit inheritance</a>, <a |
| 3645 |
|
|
href="#interpretation1">interpretation of URIs to XBL bindings</a>.) |
| 3646 |
|
|
|
| 3647 |
|
|
<li>If the binding has a template, the binding's shadow tree must be |
| 3648 |
|
|
generated. This may cause other bindings to be applied synchronously, if |
| 3649 |
|
|
their binding documents are already loaded. (See: <a |
| 3650 |
|
|
href="#rules3">rules for shadow content generation</a>, <a |
| 3651 |
|
|
href="#binding17">binding attachment and detachment</a>.) |
| 3652 |
|
|
|
| 3653 |
|
|
<li>If other bindings are already attached to the bound element, then the |
| 3654 |
|
|
newly added binding will add a new <a href="#explicit1">explicit |
| 3655 |
|
|
inheritance chain</a> to the element's list of bindings (its <a |
| 3656 |
|
|
href="#implicit1">implicit inheritance chain</a>). (See: <a |
| 3657 |
|
|
href="#implicit2">implicit inheritance</a>.) |
| 3658 |
|
|
|
| 3659 |
|
|
<li>If the new binding has an implementation, it must be made available |
| 3660 |
|
|
to scripts. Language-specific constructors for the binding |
| 3661 |
|
|
implementation must run at this point. (See: <a |
| 3662 |
|
|
href="#binding23">binding implementations</a>.) |
| 3663 |
|
|
|
| 3664 |
|
|
<li>Events must start being routed through the binding's <code><a |
| 3665 |
|
|
href="#handlers0">handlers</a></code> element, when there is one. (See: |
| 3666 |
|
|
<a href="#event12">event forwarding</a>.) |
| 3667 |
|
|
|
| 3668 |
|
|
<li>If the new binding changes which shadow trees contribute to the <a |
| 3669 |
|
|
href="#final0">final flattened tree</a> then the <a |
| 3670 |
|
|
href="#explicit3">explicit children</a> must be redistributed. (See: <a |
| 3671 |
|
|
href="#processing2">processing <code title="">content</code> |
| 3672 |
|
|
elements</a>.) |
| 3673 |
|
|
</ol> |
| 3674 |
|
|
|
| 3675 |
|
|
<p>The attachment process for the binding must then wait for the above |
| 3676 |
|
|
steps to have been completed for all bindings that are known to apply to |
| 3677 |
|
|
elements. When all the new bindings have reached this point, then, for |
| 3678 |
|
|
each newly attached binding, the <code><a |
| 3679 |
|
|
href="#xblbindingattached">xblBindingAttached()</a></code> method must be |
| 3680 |
|
|
invoked on the binding's <a href="#implementation0">implementation</a>, |
| 3681 |
|
|
immediately followed, if that bound element <a href="#is-in">is in a |
| 3682 |
|
|
document</a>, by the invocation of the <code><a |
| 3683 |
|
|
href="#xblentereddocument">xblEnteredDocument()</a></code> method. |
| 3684 |
|
|
|
| 3685 |
|
|
<p>The order that bindings on different bound elements have these methods |
| 3686 |
|
|
called must be the relative tree order of all their bound elements, as |
| 3687 |
|
|
returned by the <code>compareDocumentPosition()</code> function. In |
| 3688 |
|
|
certain cases (e.g. bound elements in disconnected fragments), this order |
| 3689 |
|
|
is implementation-specific; however, it must always be consistent with |
| 3690 |
|
|
the return values of that function. <a |
| 3691 |
|
|
href="#refsDOM3CORE">[DOM3CORE]</a></p> |
| 3692 |
|
|
|
| 3693 |
|
|
<p>The order that bindings on the same bound element have these methods |
| 3694 |
|
|
called must be the derivation order, with less derived bindings being |
| 3695 |
|
|
initialized before more derived bindings.</p> |
| 3696 |
|
|
|
| 3697 |
|
|
<p>After all the appropriate methods have been called, an <dfn |
| 3698 |
|
|
id=xbl-bound title=xbl-bound><code>xbl-bound</code></dfn> event that |
| 3699 |
|
|
bubbles, is not cancelable, has no default action, and uses the |
| 3700 |
|
|
<code>Event</code> interface, must be fired on every bound element that |
| 3701 |
|
|
just got bound, in the same order as their <code><a |
| 3702 |
|
|
href="#xblbindingattached">xblBindingAttached()</a></code> methods were |
| 3703 |
|
|
invoked. (See: <a href="#binding20">binding inheritance</a>.) <a |
| 3704 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 3705 |
|
|
|
| 3706 |
|
|
<p>If a binding stops applying to a document while the above steps are |
| 3707 |
|
|
being applied, the binding is not removed until after the steps above |
| 3708 |
|
|
have all been completed. Once they have been completed, any bindings that |
| 3709 |
|
|
no longer apply must be detached. (See: <a href="#binding21">binding |
| 3710 |
|
|
detachment model</a>.)</p> |
| 3711 |
|
|
|
| 3712 |
|
|
<h3 id=handling><span class=secno>3.6. </span><dfn id=handling3>Handling |
| 3713 |
|
|
Insertion and Removal from the Document</dfn></h3> |
| 3714 |
|
|
|
| 3715 |
|
|
<p>A bound element <dfn id=is-in>is in a document</dfn> if it has a |
| 3716 |
|
|
<code>Document</code> node as an ancestor, or it is in a shadow tree and |
| 3717 |
|
|
that shadow tree's bound element is itself <a href="#is-in" title="is in |
| 3718 |
|
|
a document">in a document</a>.</p> |
| 3719 |
|
|
|
| 3720 |
|
|
<p>When a bound element that is not <a href="#is-in" title="is in a |
| 3721 |
|
|
document">in a document</a> is affected in such a way that it |
| 3722 |
|
|
subsequently <a href="#is-in"><em>is</em> in a document</a>, then the |
| 3723 |
|
|
<code><a href="#xblentereddocument">xblEnteredDocument()</a></code> |
| 3724 |
|
|
method must be invoked on the binding's <a |
| 3725 |
|
|
href="#implementation0">implementation</a>.</p> |
| 3726 |
|
|
|
| 3727 |
|
|
<p>Similarly in reverse: when a bound element that <a |
| 3728 |
|
|
href="#is-in"><em>is</em> in a document</a> is affected in such a way |
| 3729 |
|
|
that it subsequently is <em>not</em> <a href="#is-in" title="is in a |
| 3730 |
|
|
document">in a document</a>, then the <code><a |
| 3731 |
|
|
href="#xblleftdocument">xblLeftDocument()</a></code> method must be |
| 3732 |
|
|
invoked on the binding's <a href="#implementation0">implementation</a>.</p> |
| 3733 |
|
|
|
| 3734 |
|
|
<p>These methods must be invoked as soon as the DOM is in a stable state, |
| 3735 |
|
|
after any mutation events have fired, and after all running scripts have |
| 3736 |
|
|
finished executing. If a bound element is removed and then reinserted |
| 3737 |
|
|
into a document (or vice versa) during script execution, or while |
| 3738 |
|
|
mutation events are being fired, the user agent must coalesce all the |
| 3739 |
|
|
notifications into zero or one method calls (i.e. matching pairs of |
| 3740 |
|
|
insertions and removals must not cause bindings to be notified).</p> |
| 3741 |
|
|
<!-- XXX this needs work --> |
| 3742 |
|
|
<h3 id=binding1><span class=secno>3.7. </span><dfn id=binding20>Binding |
| 3743 |
|
|
Inheritance</dfn></h3> |
| 3744 |
|
|
|
| 3745 |
|
|
<p>Bindings can inherit from each other explicitly using the <code |
| 3746 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3747 |
|
|
attribute. They can also inherit from each other <em>implicitly</em> if |
| 3748 |
|
|
multiple bindings are attached to an element.</p> |
| 3749 |
|
|
|
| 3750 |
|
|
<div class="figure example"> |
| 3751 |
|
|
<!-- Note: alt="" is correct for the following image, since the |
| 3752 |
|
|
caption says everything the image says. --> |
| 3753 |
|
|
|
| 3754 |
|
|
<p><img alt="" src="images/attachment.gif"></p> |
| 3755 |
|
|
|
| 3756 |
|
|
<div class=caption> |
| 3757 |
|
|
<p>The implicit inheritance link can be pictured as having several |
| 3758 |
|
|
explicit chains adjacent to each other, with the implicit inheritance |
| 3759 |
|
|
chain going down each explicit inheritance chain sequentially.</p> |
| 3760 |
|
|
|
| 3761 |
|
|
<p>Consider a case where seven bindings are defined, "a", which inherits |
| 3762 |
|
|
from "b" which inherits from "c"; "d", which stands alone; and "e", |
| 3763 |
|
|
which inherits from "f" which inherits from "g". If a bound element E |
| 3764 |
|
|
is bound to "a", "b", "d", and "e" (with "e" bound last), then there |
| 3765 |
|
|
would be nine bindings attached to E. Four of them would be explicitly |
| 3766 |
|
|
bound, and five would be part of explicit inheritance chains from those |
| 3767 |
|
|
four.</p> |
| 3768 |
|
|
|
| 3769 |
|
|
<p>In such an example, you would also get implicit inheritance from "g" |
| 3770 |
|
|
to "d", from "d" to "b", and from one of the instances of "c" to "a".</p> |
| 3771 |
|
|
</div> |
| 3772 |
|
|
</div> |
| 3773 |
|
|
|
| 3774 |
|
|
<p>An <dfn id=explicit1>explicit inheritance chain</dfn> is a chain of |
| 3775 |
|
|
bindings connected using the <code title=attr-binding-extends><a |
| 3776 |
|
|
href="#extends">extends</a></code> attribute.</p> |
| 3777 |
|
|
|
| 3778 |
|
|
<p>An <dfn id=implicit1>implicit inheritance chain</dfn> is a chain of <a |
| 3779 |
|
|
href="#explicit1" title="explicit inheritance chain">explicit inheritance |
| 3780 |
|
|
chains</a>. There can be at most one <em>implicit</em> inheritance chain |
| 3781 |
|
|
per bound element.</p> |
| 3782 |
|
|
|
| 3783 |
|
|
<p>A <dfn id=base-binding>base binding</dfn> is a binding that does not |
| 3784 |
|
|
inherit from any other binding, either explicitly or implicitly. The base |
| 3785 |
|
|
binding of a bound element is at one end of the bound element's implicit |
| 3786 |
|
|
inheritance chain.</p> |
| 3787 |
|
|
|
| 3788 |
|
|
<p>A <dfn id=base-binding0>base binding of the explicit chain</dfn> is any |
| 3789 |
|
|
binding that does not inherit explicitly from another, but may inherit |
| 3790 |
|
|
implicitly from other bindings.</p> |
| 3791 |
|
|
|
| 3792 |
|
|
<p>A <dfn id=most-derived>most derived binding</dfn> is a binding that no |
| 3793 |
|
|
other binding inherits from. The most derived binding of a bound element |
| 3794 |
|
|
is the binding at the other end of the bound element's implicit |
| 3795 |
|
|
inheritance chain from the base binding.</p> |
| 3796 |
|
|
|
| 3797 |
|
|
<p>If <var title="">B<sub title=""><var title="">i</var></sub></var> is |
| 3798 |
|
|
the <var title="">i</var>th binding in a group of <var title="">N</var> |
| 3799 |
|
|
chains, where <var title="">B<sub title="">1</sub></var> is the <a |
| 3800 |
|
|
href="#base-binding">base binding</a> and <var title="">B<sub |
| 3801 |
|
|
title=""><var title="">N</var></sub></var> is the <a |
| 3802 |
|
|
href="#most-derived">most derived binding</a>, then <var title="">B<sub |
| 3803 |
|
|
title=""><var title="">i</var>-1</sub></var> is the <dfn id=next->next |
| 3804 |
|
|
most derived</dfn> binding of <var title="">B<sub title=""><var |
| 3805 |
|
|
title="">i</var></sub></var>.</p> |
| 3806 |
|
|
|
| 3807 |
|
|
<p>In this specification, inheritance is represented as an arrow pointing |
| 3808 |
|
|
to the binding that is being inherited. Thus, in the chain A→B, the |
| 3809 |
|
|
A binding is the most derived binding, and the B binding is the next most |
| 3810 |
|
|
derived binding, in this case also the base binding.</p> |
| 3811 |
|
|
|
| 3812 |
|
|
<p class=example>In the example above, the <em><a |
| 3813 |
|
|
href="#base-binding">base binding</a></em> is the first "c", the four <em |
| 3814 |
|
|
title="base binding of the explicit chain"><a href="#base-binding0">base |
| 3815 |
|
|
bindings of the explicit chains</a></em> are "c", "c", "d", and "g", and |
| 3816 |
|
|
the <em><a href="#most-derived">most derived binding</a></em> is "e".</p> |
| 3817 |
|
|
|
| 3818 |
|
|
<p class=note>The results of inheritance are described in the sections on |
| 3819 |
|
|
<a href="#binding23">binding implementations</a> and <a |
| 3820 |
|
|
href="#shadow5">shadow content</a>.</p> |
| 3821 |
|
|
|
| 3822 |
|
|
<h4 id=explicit><span class=secno>3.7.1. </span><dfn id=explicit2>Explicit |
| 3823 |
|
|
Inheritance</dfn></h4> |
| 3824 |
|
|
|
| 3825 |
|
|
<p>The <code><a href="#binding16">binding</a></code> element's <code |
| 3826 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3827 |
|
|
attribute gives an explicit inheritance chain for a binding, ensuring |
| 3828 |
|
|
that whenever the binding is bound to an element, the named binding also |
| 3829 |
|
|
gets bound. (See: <a href="#binding19">binding attachment model</a>, <a |
| 3830 |
|
|
href="#binding21">binding detachment model</a>.)</p> |
| 3831 |
|
|
|
| 3832 |
|
|
<p>The <code title=attr-binding-extends><a |
| 3833 |
|
|
href="#extends">extends</a></code> attribute thus creates an <a |
| 3834 |
|
|
href="#explicit1">explicit inheritance chain</a>.</p> |
| 3835 |
|
|
|
| 3836 |
|
|
<p>If a <code><a href="#binding16">binding</a></code> element's <code |
| 3837 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3838 |
|
|
attribute is changed, then, for each time the binding is bound to an |
| 3839 |
|
|
element, the user agent must follow these steps:</p> |
| 3840 |
|
|
|
| 3841 |
|
|
<ol> |
| 3842 |
|
|
<li> |
| 3843 |
|
|
<p>Let <var title="">binding</var> be the instance of the binding that |
| 3844 |
|
|
is attached to the bound element.</p> |
| 3845 |
|
|
|
| 3846 |
|
|
<li> |
| 3847 |
|
|
<p>If <var title="">binding</var> is not <em>directly</em> attached to |
| 3848 |
|
|
the bound element, but is instead attached to the bound element because |
| 3849 |
|
|
another binding is inheriting from it using the <code |
| 3850 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3851 |
|
|
attribute, then let <var title="">binding</var> be <em>that</em> |
| 3852 |
|
|
binding instead, and repeat this step.</p> |
| 3853 |
|
|
|
| 3854 |
|
|
<p>Otherwise, <var title="">binding</var> was attached to the bound |
| 3855 |
|
|
element directly, and is not being inherited by another binding using |
| 3856 |
|
|
the <code title=attr-binding-extends><a |
| 3857 |
|
|
href="#extends">extends</a></code> attribute.</p> |
| 3858 |
|
|
|
| 3859 |
|
|
<li> |
| 3860 |
|
|
<p>Detach <var title="">binding</var>. (See: <a |
| 3861 |
|
|
href="#binding21">binding detachment model</a>.)</p> |
| 3862 |
|
|
|
| 3863 |
|
|
<li> |
| 3864 |
|
|
<p>Attach a new instance of <var title="">binding</var> so that it is in |
| 3865 |
|
|
the same place in the binding chain as the old instance was. (See: <a |
| 3866 |
|
|
href="#binding19">binding attachment model</a>, <a |
| 3867 |
|
|
href="#implicit2">implicit inheritance</a>.)</p> |
| 3868 |
|
|
</ol> |
| 3869 |
|
|
|
| 3870 |
|
|
<p class=note>It is possible to form a loop with the <code |
| 3871 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3872 |
|
|
attribute. For example, a binding A can inherit from B which inherits |
| 3873 |
|
|
from C which inherits from B again. The attachment algorithm is defined |
| 3874 |
|
|
in a way that makes the loop stop as soon as a duplicate binding would be |
| 3875 |
|
|
bound. In this case, the user agent will form a chain starting with A |
| 3876 |
|
|
(the <a href="#most-derived">most derived binding</a>), derived from B, |
| 3877 |
|
|
derived from C, with C as the <a href="#base-binding">base binding</a> |
| 3878 |
|
|
(chain A→B→C). If, given the same definitions, the element was |
| 3879 |
|
|
bound directly to C, then the chain would be C→B.</p> |
| 3880 |
|
|
|
| 3881 |
|
|
<h4 id=implicit><span class=secno>3.7.2. </span><dfn id=implicit2>Implicit |
| 3882 |
|
|
Inheritance</dfn></h4> |
| 3883 |
|
|
|
| 3884 |
|
|
<p>When two bindings are both attached to the same element, the <a |
| 3885 |
|
|
href="#base-binding0" title="base binding of the explicit chain">base |
| 3886 |
|
|
binding</a> at the end of the <a href="#explicit1">explicit inheritance |
| 3887 |
|
|
chain</a> of the second binding implicitly inherits from the <a |
| 3888 |
|
|
href="#most-derived">most derived binding</a> of the explicit inheritance |
| 3889 |
|
|
chain of the first.</p> |
| 3890 |
|
|
|
| 3891 |
|
|
<p>If one of the <a href="#explicit1" title="explicit inheritance |
| 3892 |
|
|
chain">explicit inheritance chains</a> is removed, then the remaining |
| 3893 |
|
|
binding chains are reconnected so that the <a href="#base-binding0">base |
| 3894 |
|
|
binding of the explicit chain</a> after the break now inherits from the |
| 3895 |
|
|
<a href="#most-derived">most derived binding</a> before the break.</p> |
| 3896 |
|
|
|
| 3897 |
|
|
<p>The order of bindings is always such that bindings added via the |
| 3898 |
|
|
<code><a href="#binding16">binding</a></code> element are first (in the |
| 3899 |
|
|
order the bindings are specified in the file, with the files, if there |
| 3900 |
|
|
are more than one, ordered in the same order that they are referred to, |
| 3901 |
|
|
traversed pre-order, depth-first), the bindings attached via CSS are |
| 3902 |
|
|
second (in the order specified on the '<code title="binding property"><a |
| 3903 |
|
|
href="#binding18">binding</a></code>' property), and the bindings added |
| 3904 |
|
|
via <code><a href="#addbinding">addBinding</a></code> are third (in the |
| 3905 |
|
|
order they were attached, most recently attached being the <a |
| 3906 |
|
|
href="#most-derived">most derived binding</a>).</p> |
| 3907 |
|
|
|
| 3908 |
|
|
<div class=example> |
| 3909 |
|
|
<p>For example, take a binding <em>d<sub>1</sub></em>, which specifies a |
| 3910 |
|
|
base binding <em>d<sub>2</sub></em> using the <code |
| 3911 |
|
|
title=attr-binding-extends><a href="#extends">extends</a></code> |
| 3912 |
|
|
attribute such that its explicit inheritance chain is:</p> |
| 3913 |
|
|
|
| 3914 |
|
|
<p><em>d<sub>1</sub></em> → <em>d<sub>2</sub></em></p> |
| 3915 |
|
|
|
| 3916 |
|
|
<p>If binding <em>d<sub>1</sub></em> is attached to an element using |
| 3917 |
|
|
<code><a href="#addbinding">addBinding</a></code> that already has a |
| 3918 |
|
|
binding chain of:</p> |
| 3919 |
|
|
|
| 3920 |
|
|
<p><em>s<sub>1</sub></em> → <em>s<sub>2</sub></em> → |
| 3921 |
|
|
<em>s<sub>3</sub></em></p> |
| 3922 |
|
|
|
| 3923 |
|
|
<p>...then the base binding at the end of the inheritance chain, |
| 3924 |
|
|
<em>d<sub>2</sub></em>, is the one that will inherit from the most |
| 3925 |
|
|
derived binding that is already attached to the element, |
| 3926 |
|
|
<em>s<sub>1</sub></em>. The resulting binding chain following the |
| 3927 |
|
|
addition of the binding is therefore:</p> |
| 3928 |
|
|
|
| 3929 |
|
|
<p><em>d<sub>1</sub></em> → <em>d<sub>2</sub></em> → |
| 3930 |
|
|
<em>s<sub>1</sub></em> → <em>s<sub>2</sub></em> → |
| 3931 |
|
|
<em>s<sub>3</sub></em></p> |
| 3932 |
|
|
|
| 3933 |
|
|
<p>The inheritance between <em>d<sub>2</sub></em> and |
| 3934 |
|
|
<em>s<sub>1</sub></em> is <em>implicit</em>, meaning that there is no |
| 3935 |
|
|
connection in the XBL subtrees between the two bindings. The inheritance |
| 3936 |
|
|
link has been forged dynamically through the invocation of the <code><a |
| 3937 |
|
|
href="#addbinding">addBinding</a></code> method.</p> |
| 3938 |
|
|
</div> |
| 3939 |
|
|
|
| 3940 |
|
|
<p>An element can be bound to the same binding multiple times, in which |
| 3941 |
|
|
case a binding can end up inheriting from itself. (This can only happen |
| 3942 |
|
|
via implicit inheritance, though.)</p> |
| 3943 |
|
|
|
| 3944 |
|
|
<h4 id=mixing><span class=secno>3.7.3. </span>Mixing Implicit and Explicit |
| 3945 |
|
|
Inheritance</h4> |
| 3946 |
|
|
|
| 3947 |
|
|
<div class=example id=mixed-inheritance-example> |
| 3948 |
|
|
<p>Consider the following completely useless but short bindings:</p> |
| 3949 |
|
|
|
| 3950 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 3951 |
|
|
<binding id="a"> |
| 3952 |
|
|
<template> l <inherited> l <content> o </content> - </inherited> W </template> |
| 3953 |
|
|
</binding> |
| 3954 |
|
|
<binding id="b" element="[X]" extends="#a"> |
| 3955 |
|
|
<template> e <inherited> error </inherited> o <content> r </content> </template> |
| 3956 |
|
|
</binding> |
| 3957 |
|
|
<binding id="c" element="[Y]"> |
| 3958 |
|
|
<template> H <inherited> error </inherited> l <content> error </content> ! </template> |
| 3959 |
|
|
</binding> |
| 3960 |
|
|
</xbl></pre> |
| 3961 |
|
|
|
| 3962 |
|
|
<p>When imported by the following equally silly but simple document:</p> |
| 3963 |
|
|
|
| 3964 |
|
|
<pre><?xbl href="test.xml"?> |
| 3965 |
|
|
<root X="" Y=""> d </root></pre> |
| 3966 |
|
|
|
| 3967 |
|
|
<p>The resulting flattened tree would spell |
| 3968 |
|
|
"H e l l o - W o r l d !".</p> |
| 3969 |
|
|
|
| 3970 |
|
|
<p> |
| 3971 |
|
|
|
| 3972 |
|
|
<p>The binding "c" that attaches because of the Y attribute implicitly |
| 3973 |
|
|
inherits from the binding "b" that is bound because of the X attribute, |
| 3974 |
|
|
and that latter binding explicitly inherits from the "a" binding. Since |
| 3975 |
|
|
the "Y" binding has a <code><a href="#content0">content</a></code> |
| 3976 |
|
|
element, the "d" explicit child node of the bound element ends up |
| 3977 |
|
|
assigned to the <code><a href="#content0">content</a></code> element in |
| 3978 |
|
|
the "Y" binding.</p> |
| 3979 |
|
|
|
| 3980 |
|
|
<p>The following table shows the source of each character:</p> |
| 3981 |
|
|
|
| 3982 |
|
|
<table> |
| 3983 |
|
|
<tbody> |
| 3984 |
|
|
<tr> |
| 3985 |
|
|
<th> Output: |
| 3986 |
|
|
|
| 3987 |
|
|
<td> H |
| 3988 |
|
|
|
| 3989 |
|
|
<td> e |
| 3990 |
|
|
|
| 3991 |
|
|
<td> l |
| 3992 |
|
|
|
| 3993 |
|
|
<td> l |
| 3994 |
|
|
|
| 3995 |
|
|
<td> o |
| 3996 |
|
|
|
| 3997 |
|
|
<td> - |
| 3998 |
|
|
|
| 3999 |
|
|
<td> W |
| 4000 |
|
|
|
| 4001 |
|
|
<td> o |
| 4002 |
|
|
|
| 4003 |
|
|
<td> r |
| 4004 |
|
|
|
| 4005 |
|
|
<td> l |
| 4006 |
|
|
|
| 4007 |
|
|
<td> d |
| 4008 |
|
|
|
| 4009 |
|
|
<td> ! |
| 4010 |
|
|
|
| 4011 |
|
|
<tr> |
| 4012 |
|
|
<th> Source: |
| 4013 |
|
|
|
| 4014 |
|
|
<td> c |
| 4015 |
|
|
|
| 4016 |
|
|
<td> b |
| 4017 |
|
|
|
| 4018 |
|
|
<td> a |
| 4019 |
|
|
|
| 4020 |
|
|
<td> a |
| 4021 |
|
|
|
| 4022 |
|
|
<td> a |
| 4023 |
|
|
|
| 4024 |
|
|
<td> a |
| 4025 |
|
|
|
| 4026 |
|
|
<td> a |
| 4027 |
|
|
|
| 4028 |
|
|
<td> b |
| 4029 |
|
|
|
| 4030 |
|
|
<td> b |
| 4031 |
|
|
|
| 4032 |
|
|
<td> c |
| 4033 |
|
|
|
| 4034 |
|
|
<td> R |
| 4035 |
|
|
|
| 4036 |
|
|
<td> c |
| 4037 |
|
|
</table> |
| 4038 |
|
|
|
| 4039 |
|
|
<p>...where R represents the bound document.</p> |
| 4040 |
|
|
|
| 4041 |
|
|
<p>The inheritance chain of the bindings attached to the <code |
| 4042 |
|
|
title="">root</code> element in this example is:</p> |
| 4043 |
|
|
|
| 4044 |
|
|
<pre>c → b → a</pre> |
| 4045 |
|
|
|
| 4046 |
|
|
<p>...where the first arrow is an implicit inheritance, and the second is |
| 4047 |
|
|
an explicit inheritance.</p> |
| 4048 |
|
|
</div> |
| 4049 |
|
|
|
| 4050 |
|
|
<h3 id=views><span class=secno>3.8. </span>Views and Attachment</h3> |
| 4051 |
|
|
|
| 4052 |
|
|
<p>Only one set of bindings is attached to the document, and they must |
| 4053 |
|
|
affect all views in a <a href="#view" title=view>multi-view UA</a>. |
| 4054 |
|
|
Bindings attached via style sheets must be attached based on the style |
| 4055 |
|
|
sheets that apply to the default view.</p> |
| 4056 |
|
|
|
| 4057 |
|
|
<h3 id=attachment2><span class=secno>3.9. </span>Attachment During |
| 4058 |
|
|
Document Load</h3> |
| 4059 |
|
|
|
| 4060 |
|
|
<p>Binding loads are asynchronous. That is to say, when a binding is added |
| 4061 |
|
|
(either via style sheet, script, or some other method), and the relevant |
| 4062 |
|
|
<a href="#binding15">binding document</a> is not yet loaded, the load |
| 4063 |
|
|
must be started in the background and the binding only attached once the |
| 4064 |
|
|
binding document is available. An author can ensure that all bindings are |
| 4065 |
|
|
synchronously attached by calling <code><a |
| 4066 |
|
|
href="#loadbindingdocument">loadBindingDocument</a></code> to pre-fetch |
| 4067 |
|
|
any binding documents that are required.</p> |
| 4068 |
|
|
|
| 4069 |
|
|
<p>The bound document must wait until all XBL dependencies have loaded |
| 4070 |
|
|
before firing its <code title=event-load>load</code> event.</p> |
| 4071 |
|
|
|
| 4072 |
|
|
<h3 id=binding2><span class=secno>3.10. </span><dfn id=binding21>Binding |
| 4073 |
|
|
Detachment Model</dfn></h3> |
| 4074 |
|
|
|
| 4075 |
|
|
<p>When a binding is detached, the <code><a |
| 4076 |
|
|
href="#xblleftdocument">xblLeftDocument()</a></code> method must be |
| 4077 |
|
|
invoked on the binding's <a href="#implementation0">implementation</a>. |
| 4078 |
|
|
Then, the shadow tree must be removed, the implementation must be removed |
| 4079 |
|
|
from the bound element's list of binding implementations, and any |
| 4080 |
|
|
forwarding of events to the binding must be stopped for this bound |
| 4081 |
|
|
element.</p> |
| 4082 |
|
|
|
| 4083 |
|
|
<p>If the binding had an <code title=attr-binding-extends><a |
| 4084 |
|
|
href="#extends">extends</a></code> attribute when it was bound to the |
| 4085 |
|
|
element (it may have changed since then, in which case the binding is |
| 4086 |
|
|
being detached precisely for that reason), then the user agent must then |
| 4087 |
|
|
detach the binding that was attached because of that attribute (if any). |
| 4088 |
|
|
(See: <a href="#explicit2">explicit inheritance</a>, <a |
| 4089 |
|
|
href="#interpretation1">interpretation of URIs to XBL bindings</a>.) |
| 4090 |
|
|
|
| 4091 |
|
|
<p>If the binding had a shadow tree, the explicit children must then be |
| 4092 |
|
|
redistributed. (See: <a href="#processing2">processing <code |
| 4093 |
|
|
title="">content</code> elements</a>.)</p> |
| 4094 |
|
|
<!-- XXX need to define how this works when multiple bindings stop |
| 4095 |
|
|
applying at once, and if they re-apply while being removed --> |
| 4096 |
|
|
|
| 4097 |
|
|
<h2 id=shadow><span class=secno>4. </span><dfn id=shadow5>Shadow |
| 4098 |
|
|
Content</dfn></h2> |
| 4099 |
|
|
|
| 4100 |
|
|
<p>The subtree specified by the <code><a |
| 4101 |
|
|
href="#template0">template</a></code> element is referred to as the <dfn |
| 4102 |
|
|
id=shadow6>shadow content template</dfn>. This template describes a |
| 4103 |
|
|
content tree that will be generated under the bound element during |
| 4104 |
|
|
binding attachment. An element declared in a bound document using a |
| 4105 |
|
|
single element can then be constructed out of multiple child elements, |
| 4106 |
|
|
and this implementation is hidden from the bound document.</p> |
| 4107 |
|
|
|
| 4108 |
|
|
<p>A <dfn id=shadow7>shadow tree</dfn> is a tree of nodes created by |
| 4109 |
|
|
cloning a binding's <a href="#shadow6">shadow content template</a>. A |
| 4110 |
|
|
bound element can have zero, one, or more shadow trees. If a bound |
| 4111 |
|
|
element has any, they are combined by the user agent, along with the |
| 4112 |
|
|
element's <a href="#explicit3">explicit children</a>, to form the <a |
| 4113 |
|
|
href="#final0">final flattened tree</a>. Shadow trees are hidden from |
| 4114 |
|
|
normal DOM processing (hence the name "shadow"); they are not accessible |
| 4115 |
|
|
via Core DOM navigation facilities such as <code>firstChild</code> or |
| 4116 |
|
|
<code>nextSibling</code>. (See: <a href="#shadow5">shadow content</a>.)</p> |
| 4117 |
|
|
|
| 4118 |
|
|
<p>The term <dfn id=shadow8 title="">shadow content</dfn> refers to the |
| 4119 |
|
|
various nodes in the shadow tree(s) of a bound element. Shadow content is |
| 4120 |
|
|
created by cloning <a href="#shadow6" title="shadow content |
| 4121 |
|
|
template">shadow content templates</a> during binding attachment. |
| 4122 |
|
|
|
| 4123 |
|
|
<div class=example> |
| 4124 |
|
|
<p>For example, the HTML file upload control appears in most browsers as |
| 4125 |
|
|
a composite widget consisting of a text field and a button. A sample XBL |
| 4126 |
|
|
binding for the file widget might look as follows:</p> |
| 4127 |
|
|
|
| 4128 |
|
|
<pre><binding id="fileupload"> |
| 4129 |
|
|
<template> |
| 4130 |
|
|
<html:input type="text"/> |
| 4131 |
|
|
<html:input type="button"/> |
| 4132 |
|
|
</template> |
| 4133 |
|
|
</binding></pre> |
| 4134 |
|
|
|
| 4135 |
|
|
<p>Because this content is not visible to its parent element, it is said |
| 4136 |
|
|
to be <em><a href="#shadow5">shadow content</a></em>.</p> |
| 4137 |
|
|
</div> |
| 4138 |
|
|
|
| 4139 |
|
|
<p class=note>The file control is actually a special case. Due to security |
| 4140 |
|
|
considerations, untrusted bindings will typically not be able to extend |
| 4141 |
|
|
the file upload control in UAs intended for use with untrusted content.</p> |
| 4142 |
|
|
|
| 4143 |
|
|
<p>Whenever bindings are attached to an element, shadow content will |
| 4144 |
|
|
potentially be <a href="#rules3" title="Rules for Shadow Content |
| 4145 |
|
|
Generation">generated</a>. Similarly, when a binding is removed from an |
| 4146 |
|
|
element, its shadow content, if any, is <a href="#rules4" title="Rules |
| 4147 |
|
|
for Shadow Content Destruction">destroyed</a>.</p> |
| 4148 |
|
|
|
| 4149 |
|
|
<p>A shadow tree must be generated if a <code><a |
| 4150 |
|
|
href="#template0">template</a></code> element is added to a <code><a |
| 4151 |
|
|
href="#binding16">binding</a></code> element that had no <code><a |
| 4152 |
|
|
href="#template0">template</a></code> element. If the <code><a |
| 4153 |
|
|
href="#template0">template</a></code> element is removed, then the shadow |
| 4154 |
|
|
tree must be destroyed.</p> |
| 4155 |
|
|
|
| 4156 |
|
|
<p>The <code><a href="#template0">template</a></code> element used to |
| 4157 |
|
|
generate a binding is always the first such element in a <code><a |
| 4158 |
|
|
href="#binding16">binding</a></code> element. If the <code><a |
| 4159 |
|
|
href="#binding16">binding</a></code> element is mutated in a way which |
| 4160 |
|
|
changes which <code><a href="#template0">template</a></code> element is |
| 4161 |
|
|
the first, then the corresponding shadow tree must be <a |
| 4162 |
|
|
href="#regenerating">regenerated</a>.</p> |
| 4163 |
|
|
|
| 4164 |
|
|
<p>Similarly, when a <code><a href="#template0">template</a></code> |
| 4165 |
|
|
element or any of its descendants is mutated in any way, any bindings |
| 4166 |
|
|
whose shadow tree was constructed from that element must be <a |
| 4167 |
|
|
href="#regenerating">regenerated</a>.</p> |
| 4168 |
|
|
|
| 4169 |
|
|
<p><dfn id=regenerating title=regenerated>Regenerating a shadow tree</dfn> |
| 4170 |
|
|
consists of first <a href="#rules4" title="Rules for Shadow Content |
| 4171 |
|
|
Destruction">destroying</a> the existing shadow tree and then <a |
| 4172 |
|
|
href="#rules3" title="Rules for Shadow Content Generation">generating</a> |
| 4173 |
|
|
a new one.</p> |
| 4174 |
|
|
|
| 4175 |
|
|
<h3 id=rules><span class=secno>4.1. </span><dfn id=rules3>Rules for Shadow |
| 4176 |
|
|
Content Generation</dfn></h3> |
| 4177 |
|
|
|
| 4178 |
|
|
<p>When a shadow tree is generated, user agents must act as follows:</p> |
| 4179 |
|
|
|
| 4180 |
|
|
<p>If the binding element has no <code><a |
| 4181 |
|
|
href="#template0">template</a></code> element, then no shadow content |
| 4182 |
|
|
will be generated for this binding.</p> |
| 4183 |
|
|
|
| 4184 |
|
|
<p>Otherwise, its first <code><a href="#template0">template</a></code> |
| 4185 |
|
|
element must be deeply cloned.</p> |
| 4186 |
|
|
|
| 4187 |
|
|
<p>The <code>xml:base</code> data of the cloned <code><a |
| 4188 |
|
|
href="#template0">template</a></code> element must be set so that the |
| 4189 |
|
|
<code>baseURI</code> of nodes in the resulting shadow tree is the same as |
| 4190 |
|
|
their pre-cloning counterparts. All shadow nodes' |
| 4191 |
|
|
<code>ownerDocument</code> pointers are left pointing at their binding |
| 4192 |
|
|
documents' <code>Document</code> node(s).</p> |
| 4193 |
|
|
|
| 4194 |
|
|
<p>No mutation events must be fired during the above steps.</p> |
| 4195 |
|
|
|
| 4196 |
|
|
<p>Any bindings that apply to elements in the shadow tree must be applied.</p> |
| 4197 |
|
|
|
| 4198 |
|
|
<p>For bindings with ECMAScript implementations: the <code><a |
| 4199 |
|
|
href="#shadowtree">shadowTree</a></code> member of the <a |
| 4200 |
|
|
href="#internal">internal object</a> must be set to be a reference to the |
| 4201 |
|
|
<code><a href="#template0">template</a></code> element clone (the root of |
| 4202 |
|
|
the shadow tree).</p> |
| 4203 |
|
|
|
| 4204 |
|
|
<p>The shadow tree is then <dfn id=applied>applied</dfn> to the bound |
| 4205 |
|
|
element: the binding's shadow tree is placed in the appropriate place in |
| 4206 |
|
|
the final flattened tree, <a href="#explicit3">explicit children</a> are |
| 4207 |
|
|
(re)distributed to the appropriate <code><a |
| 4208 |
|
|
href="#content0">content</a></code> elements, and the CSS cascade and |
| 4209 |
|
|
inheritance is be computed along the new tree. (See: <a |
| 4210 |
|
|
href="#processing2">processing <code title="">content</code> |
| 4211 |
|
|
elements</a>.)</p> |
| 4212 |
|
|
|
| 4213 |
|
|
<p>After this point, further bindings may need to be applied, or certain |
| 4214 |
|
|
bindings may need to be removed (because of CSS inheritance or because |
| 4215 |
|
|
the selectors that decide which elements match which bindings can be |
| 4216 |
|
|
affected by the shadow tree being associated with the bound element).</p> |
| 4217 |
|
|
|
| 4218 |
|
|
<p>Everything described in this section must be completed atomically |
| 4219 |
|
|
— that is, the UA must not execute author scripts during this |
| 4220 |
|
|
process.</p> |
| 4221 |
|
|
|
| 4222 |
|
|
<p class=note>Some implementations might optimize this algorithm, such as |
| 4223 |
|
|
using "lazy evaluation" approaches and thereby postpone the cascade and |
| 4224 |
|
|
inheritance operations.</p> |
| 4225 |
|
|
|
| 4226 |
|
|
<h3 id=rules0><span class=secno>4.2. </span><dfn id=rules4>Rules for |
| 4227 |
|
|
Shadow Content Destruction</dfn></h3> |
| 4228 |
|
|
|
| 4229 |
|
|
<p>The destruction of a shadow tree consists of recreating the <a |
| 4230 |
|
|
href="#final0">final flattened tree</a> without the influence of that |
| 4231 |
|
|
binding's shadow tree by redistributing the <a href="#explicit3">explicit |
| 4232 |
|
|
children</a> to the remaining shadow trees' <code><a |
| 4233 |
|
|
href="#content0">content</a></code> elements (or, if there are none, |
| 4234 |
|
|
putting the nodes back directly under the bound element).</p> |
| 4235 |
|
|
|
| 4236 |
|
|
<p>For bindings with ECMAScript implementations: the <code><a |
| 4237 |
|
|
href="#shadowtree">shadowTree</a></code> member of the <a |
| 4238 |
|
|
href="#internal">internal object</a> must be set to null.</p> |
| 4239 |
|
|
|
| 4240 |
|
|
<h3 id=attribute><span class=secno>4.3. </span><dfn |
| 4241 |
|
|
id=attribute1>Attribute Forwarding</dfn></h3> |
| 4242 |
|
|
|
| 4243 |
|
|
<p>Attributes on shadow content elements can be tied to attributes on the |
| 4244 |
|
|
bound element; then, whenever the attribute is set or removed on the |
| 4245 |
|
|
bound element, the corresponding attribute on the shadow content is also |
| 4246 |
|
|
set or removed. On any shadow content element, an <code |
| 4247 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute can be |
| 4248 |
|
|
used to specify a <a href="#attributes22">space-separated</a> list of |
| 4249 |
|
|
attributes that should be inherited. Attributes with namespaces can be |
| 4250 |
|
|
defined using a namespace prefix and the attribute name separate by a |
| 4251 |
|
|
colon.</p> |
| 4252 |
|
|
|
| 4253 |
|
|
<div class=example> |
| 4254 |
|
|
<p>For example, returning to the HTML file upload control example above, |
| 4255 |
|
|
the shadow text field can be set up to automatically inherit the |
| 4256 |
|
|
<code>value</code> attribute from the bound element.</p> |
| 4257 |
|
|
|
| 4258 |
|
|
<pre><xbl:binding id="fileUploadControl"> |
| 4259 |
|
|
<xbl:template> |
| 4260 |
|
|
<html:input type="text" xbl:attr="value"/> |
| 4261 |
|
|
<html:input type="button" value="Browse..."/> |
| 4262 |
|
|
</xbl:template> |
| 4263 |
|
|
</xbl:binding></pre> |
| 4264 |
|
|
</div> |
| 4265 |
|
|
|
| 4266 |
|
|
<p>Each entry in the <code title=attr-attr><a |
| 4267 |
|
|
href="#xblattr0">xbl:attr</a></code> list can either simply list an |
| 4268 |
|
|
attribute (a <a href="#qname">QName</a>, such as <code>value</code> in |
| 4269 |
|
|
the example above), or it can specify an <code>=</code>-separated pair of |
| 4270 |
|
|
<a href="#qname" title=QName>QNames</a> consisting of the attribute on |
| 4271 |
|
|
the shadow content that should be tied to the attribute on the bound |
| 4272 |
|
|
element. When two names are specified, the attribute to be added on the |
| 4273 |
|
|
shadow content node is listed first, and the attribute of the bound |
| 4274 |
|
|
element is second.</p> |
| 4275 |
|
|
|
| 4276 |
|
|
<p>Each entry may also be suffixed by a single hash mark (#) followed by a |
| 4277 |
|
|
<a href="#type-">type designation</a>.</p> |
| 4278 |
|
|
|
| 4279 |
|
|
<p>The <code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> |
| 4280 |
|
|
attribute's value must be parsed as follows. First, it must be split on |
| 4281 |
|
|
spaces (treated as a <a href="#attributes22">space-separated</a> value). |
| 4282 |
|
|
Next, each resulting item must be matched against the following pattern |
| 4283 |
|
|
(given here in pseudo-BNF, where square brackets indicate optional |
| 4284 |
|
|
terms):</p> |
| 4285 |
|
|
|
| 4286 |
|
|
<pre>xbl inherits item := [<var>s1</var> ':'] <var>s2</var> ['=' [<var>s3</var> ':'] <var>s4</var>] ['#' <var>s5</var>]</pre> |
| 4287 |
|
|
|
| 4288 |
|
|
<p>...where <var>s1</var>..<var>s5</var> are strings of characters not |
| 4289 |
|
|
containing any of ":". "=", or "#".</p> |
| 4290 |
|
|
|
| 4291 |
|
|
<p>If any item does not match this pattern, then the item is <a |
| 4292 |
|
|
href="#in-error">in error</a> and must be ignored. Other items in the |
| 4293 |
|
|
list, if any, are not affected by this.</p> |
| 4294 |
|
|
|
| 4295 |
|
|
<p>The values <var>s1</var>:<var>s2</var> and <var>s3</var>:<var>s4</var> |
| 4296 |
|
|
(if present) must be resolved to fully qualified names using the |
| 4297 |
|
|
attribute <a href="#qname">QName</a> resolving semantics and the |
| 4298 |
|
|
namespaces prefix declarations in scope on the element on which the <code |
| 4299 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute is |
| 4300 |
|
|
found, at the time that the attribute is parsed. Any value in the list |
| 4301 |
|
|
that does not resolve to a fully qualified name is <a href="#in-error">in |
| 4302 |
|
|
error</a> and must be ignored. <a href="#refsXMLNS">[XMLNS]</a></p> |
| 4303 |
|
|
|
| 4304 |
|
|
<p>Changes to namespace prefix definitions in the shadow tree that affect |
| 4305 |
|
|
<a href="#qname" title=QName>QNames</a> used in <code title=attr-attr><a |
| 4306 |
|
|
href="#xblattr0">xbl:attr</a></code> attributes take effect the next time |
| 4307 |
|
|
the attribute is parsed (which must be the next time the attribute is |
| 4308 |
|
|
changed, but may be earlier).</p> |
| 4309 |
|
|
|
| 4310 |
|
|
<h4 id=forwarding><span class=secno>4.3.1. </span>Forwarding to and from |
| 4311 |
|
|
text nodes</h4> |
| 4312 |
|
|
|
| 4313 |
|
|
<p>The special value <dfn id=xbltext><code>xbl:text</code></dfn> can be |
| 4314 |
|
|
used in an <code title="">=</code>-separated pair, where the prefix is |
| 4315 |
|
|
associated with the XBL namespace. (The value is not a literal; it |
| 4316 |
|
|
represents the fictional "text" attribute in the XBL namespace.)</p> |
| 4317 |
|
|
|
| 4318 |
|
|
<p>When specified on the left-hand side of the pair it indicates that the |
| 4319 |
|
|
value of the attribute on the right-hand side are to be represented as |
| 4320 |
|
|
text nodes underneath the shadow element in the <a href="#final0">final |
| 4321 |
|
|
flattened tree</a>. If the element has any child nodes in the DOM (any |
| 4322 |
|
|
nodes, including comment nodes, whitespace text nodes, or even empty |
| 4323 |
|
|
CDATA nodes) then the pair is <a href="#in-error">in error</a> and UAs |
| 4324 |
|
|
must ignore it, meaning the attribute value is not forwarded. Otherwise, |
| 4325 |
|
|
a text node must be created, and that text node will be placed under the |
| 4326 |
|
|
element in the final flattened tree.</p> |
| 4327 |
|
|
|
| 4328 |
|
|
<p>Text nodes created in this way are orphans; their |
| 4329 |
|
|
<code>parentNode</code>, <code>nextSibling</code>, |
| 4330 |
|
|
<code>previousSibling</code>, <code>childNodes</code>, |
| 4331 |
|
|
<code>firstChild</code>, and <code>lastChild</code> attributes are all |
| 4332 |
|
|
null or empty. Their <code>ownerDocument</code> attribute is set to the |
| 4333 |
|
|
same as the shadow content node that generated them. (The only way one of |
| 4334 |
|
|
these text nodes can be accessed is if the element is itself bound: the |
| 4335 |
|
|
text node might then appear in a <code><a |
| 4336 |
|
|
href="#content0">content</a></code> element's <code><a |
| 4337 |
|
|
href="#xblchildnodes">xblChildNodes</a></code> list.)</p> |
| 4338 |
|
|
|
| 4339 |
|
|
<p>When used on the right-hand side, it indicates that any text nodes |
| 4340 |
|
|
(including CDATA nodes and whitespace text nodes) that are <a |
| 4341 |
|
|
href="#explicit3">explicit children</a> of the bound element must have |
| 4342 |
|
|
their data concatenated and the resulting value stored as the attribute |
| 4343 |
|
|
on the left-hand side.</p> |
| 4344 |
|
|
<!--XXX use textContent instead? innerText? |
| 4345 |
|
|
The HTML5 special version? --> |
| 4346 |
|
|
|
| 4347 |
|
|
<p>The <code><a href="#xbltext">xbl:text</a></code> value cannot occur by |
| 4348 |
|
|
itself in the list. If it occurs by itself, it is <a href="#in-error">in |
| 4349 |
|
|
error</a> and UAs must <a href="#ignoring">ignore</a> that value in the |
| 4350 |
|
|
<a href="#attributes22">space-separated</a> list that is the <code |
| 4351 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute.</p> |
| 4352 |
|
|
|
| 4353 |
|
|
<h4 id=forwarding0><span class=secno>4.3.2. </span>Forwarding language |
| 4354 |
|
|
metadata</h4> |
| 4355 |
|
|
|
| 4356 |
|
|
<p>The special value <dfn id=xbllang><code>xbl:lang</code></dfn> can also |
| 4357 |
|
|
be used in an <code title="">=</code>-separated pair. (Again, this is |
| 4358 |
|
|
just the fictional "lang" attribute in the XBL namespace, not the literal |
| 4359 |
|
|
string "xbl:lang", so the "xbl" prefix, or whatever prefix is used, must |
| 4360 |
|
|
be declared as the XBL namespace.)</p> |
| 4361 |
|
|
|
| 4362 |
|
|
<p>When used on the right-hand side, it indicates that the value to be |
| 4363 |
|
|
copied is the natural language of the bound element, typically given by |
| 4364 |
|
|
the attribute <code>xml:lang</code> of that element or an ancestor, or by |
| 4365 |
|
|
HTTP headers, or similar. If no language is defined, then the value to be |
| 4366 |
|
|
copied must be the empty string.</p> |
| 4367 |
|
|
|
| 4368 |
|
|
<p>The <code><a href="#xbllang">xbl:lang</a></code> value cannot occur by |
| 4369 |
|
|
itself or on the left-hand side. If it does, it is <a href="#in-error">in |
| 4370 |
|
|
error</a> and UAs must <a href="#ignoring">ignore</a> that value in the |
| 4371 |
|
|
element's <code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> |
| 4372 |
|
|
attribute.</p> |
| 4373 |
|
|
|
| 4374 |
|
|
<h4 id=error0><span class=secno>4.3.3. </span>Error handling</h4> |
| 4375 |
|
|
|
| 4376 |
|
|
<p>Any other values in the XBL namespace in the list are <a |
| 4377 |
|
|
href="#in-error">in error</a> and must be <a href="#ignoring" |
| 4378 |
|
|
title=ignore>ignored</a>. (In particular, trying to change or set the |
| 4379 |
|
|
value of <code title=attr-pseudo><a |
| 4380 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> or, worse, <code |
| 4381 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code>, must not result |
| 4382 |
|
|
in any changes to any attributes.)</p> |
| 4383 |
|
|
|
| 4384 |
|
|
<p>If an attribute is listed multiple times on the left hand side (or on |
| 4385 |
|
|
its own), then the last designation wins (as if the attributes were each |
| 4386 |
|
|
forwarded in turn, an earlier forwarding being overwritten by a later |
| 4387 |
|
|
one).</p> |
| 4388 |
|
|
|
| 4389 |
|
|
<h4 id=type-specifiers><span class=secno>4.3.4. </span>Type specifiers</h4> |
| 4390 |
|
|
|
| 4391 |
|
|
<p>If the attribute or attribute pair is followed by a <dfn id=type->type |
| 4392 |
|
|
designation</dfn>, in the form of a hash mark character ("#") and by a |
| 4393 |
|
|
type name, then the value must be processed as described for its type |
| 4394 |
|
|
below before being forwarded.</p> |
| 4395 |
|
|
|
| 4396 |
|
|
<dl> |
| 4397 |
|
|
<dt>If the type is <dfn id=url title=type-url><code>url</code></dfn> |
| 4398 |
|
|
|
| 4399 |
|
|
<dd>The value must be resolved to an absolute URI using the base URI of |
| 4400 |
|
|
the source element before being forwarded. |
| 4401 |
|
|
|
| 4402 |
|
|
<dt>If the type is <dfn id=text0 title=type-text><code>text</code></dfn> |
| 4403 |
|
|
(default) |
| 4404 |
|
|
|
| 4405 |
|
|
<dd>The value is forwarded unchanged. |
| 4406 |
|
|
|
| 4407 |
|
|
<dt>If the type is any other value |
| 4408 |
|
|
|
| 4409 |
|
|
<dd>The attribute must not be forwarded. The value is <a |
| 4410 |
|
|
href="#in-error">in error</a> and UAs must <a |
| 4411 |
|
|
href="#ignoring">ignore</a> that value in the element's <code |
| 4412 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute. |
| 4413 |
|
|
</dl> |
| 4414 |
|
|
|
| 4415 |
|
|
<div class=example> |
| 4416 |
|
|
<p>In the following shadow template, the "src" attribute on the bound |
| 4417 |
|
|
element is forwarded to the "src" attribute on the <code>image</code> |
| 4418 |
|
|
element in the shadow tree, and the link will work even if the original |
| 4419 |
|
|
attribute had a relative URI and the base URIs of the various nodes are |
| 4420 |
|
|
different:</p> |
| 4421 |
|
|
|
| 4422 |
|
|
<pre> |
| 4423 |
|
|
<xbl:template> |
| 4424 |
|
|
<xul:image xbl:attr="src#url title alt=xbl:text xml:lang=xbl:lang"/> |
| 4425 |
|
|
</xbl:template> |
| 4426 |
|
|
</pre> |
| 4427 |
|
|
|
| 4428 |
|
|
<p>This example also shows how to turn the value of an attribute on the |
| 4429 |
|
|
bound element, in this case the "alt" attribute, into child nodes of the |
| 4430 |
|
|
element in the shadow tree, using <code><a |
| 4431 |
|
|
href="#xbltext">xbl:text</a></code>. For accessibility reasons, the |
| 4432 |
|
|
language of the element is also explicitly forwarded.</p> |
| 4433 |
|
|
</div> |
| 4434 |
|
|
<!-- XXX we need a way to translate x="foo" y="foo" to |
| 4435 |
|
|
transform="translate(x,y)" and similar --> |
| 4436 |
|
|
<!-- XXX we need a way to handle onfoo attributes on the bound |
| 4437 |
|
|
element --> |
| 4438 |
|
|
|
| 4439 |
|
|
<h4 id=dynamic><span class=secno>4.3.5. </span>Dynamic changes</h4> |
| 4440 |
|
|
|
| 4441 |
|
|
<p>The <code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> |
| 4442 |
|
|
attribute must be parsed when the binding is first applied and whenever |
| 4443 |
|
|
the attribute's value changes. It must be applied (causing the relevant |
| 4444 |
|
|
attributes and text nodes to be updated) when the shadow tree is |
| 4445 |
|
|
generated, when the attribute is changed, and whenever any of the bound |
| 4446 |
|
|
element's attributes or text nodes referred to by the <code |
| 4447 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute change.</p> |
| 4448 |
|
|
|
| 4449 |
|
|
<h4 id=how-attribute><span class=secno>4.3.6. </span>How Attribute |
| 4450 |
|
|
Forwarding Affects the Shadow Tree</h4> |
| 4451 |
|
|
|
| 4452 |
|
|
<p>The element to which the attributes are forwarded (that is, the element |
| 4453 |
|
|
with the <code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> |
| 4454 |
|
|
attribute specified) has its attributes mutated. Whenever attribute |
| 4455 |
|
|
forwarding happens: existing attributes to which values are being |
| 4456 |
|
|
forwarded must have their values changed, attributes that are being |
| 4457 |
|
|
forwarded that do not yet exist on the shadow tree element must be added |
| 4458 |
|
|
to the shadow tree element, attributes to which values would be forwarded |
| 4459 |
|
|
but whose source attributes are not present on the bound element must be |
| 4460 |
|
|
removed from the shadow tree element.</p> |
| 4461 |
|
|
|
| 4462 |
|
|
<p>The shadow tree element's attributes can be changed dynamically, and |
| 4463 |
|
|
this doesn't affect the attribute forwarding, until dynamic changes cause |
| 4464 |
|
|
attribute forwarding to be performed again. When attribute forwarding is |
| 4465 |
|
|
performed, all attributes are forwarded, even those that haven't changed |
| 4466 |
|
|
on the bound element, thus blowing away any dynamic changes to the shadow |
| 4467 |
|
|
tree element's attributes that are referenced by the <code |
| 4468 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute.</p> |
| 4469 |
|
|
|
| 4470 |
|
|
<h3 id=processing0><span class=secno>4.4. </span><dfn |
| 4471 |
|
|
id=processing2>Processing <code>content</code> Elements</dfn></h3> |
| 4472 |
|
|
|
| 4473 |
|
|
<p>A node is said to match a <code><a href="#content0">content</a></code> |
| 4474 |
|
|
element when the <code><a href="#content0">content</a></code> element has |
| 4475 |
|
|
no <code title=attr-content-includes><a |
| 4476 |
|
|
href="#includes">includes</a></code> attribute, or when the element in |
| 4477 |
|
|
question matches the selector given by that <code |
| 4478 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 4479 |
|
|
attribute.</p> |
| 4480 |
|
|
|
| 4481 |
|
|
<p>If an element stops matching a <code><a |
| 4482 |
|
|
href="#content0">content</a></code> element that it is assigned to, then |
| 4483 |
|
|
the bound element's explicit chlidren must be redistributed.</p> |
| 4484 |
|
|
|
| 4485 |
|
|
<h4 id=how-nodes><span class=secno>4.4.1. </span>How Nodes are Distributed</h4> |
| 4486 |
|
|
|
| 4487 |
|
|
<p><img alt="" class=extra src="images/xbl_image_1.gif">XBL bindings can |
| 4488 |
|
|
interleave shadow content between bound elements and their <a |
| 4489 |
|
|
href="#explicit3">explicit children</a>. They do so using XBL's <code><a |
| 4490 |
|
|
href="#content0">content</a></code> element. Any number of <code><a |
| 4491 |
|
|
href="#content0">content</a></code> nodes may be used in a binding's |
| 4492 |
|
|
shadow content template.</p> |
| 4493 |
|
|
|
| 4494 |
|
|
<p>In addition, the shadow trees of inherited bindings get inserted into |
| 4495 |
|
|
the first <code><a href="#inherited0">inherited</a></code> element in the |
| 4496 |
|
|
binding.</p> |
| 4497 |
|
|
|
| 4498 |
|
|
<p>The <dfn id=explicit3>explicit children</dfn> of an element are the |
| 4499 |
|
|
nodes that are listed in the element's <code>childNodes</code> array, |
| 4500 |
|
|
with the exception that any <code><a href="#content0">content</a></code> |
| 4501 |
|
|
elements in that array are instead replaced by whatever nodes they |
| 4502 |
|
|
currently have assigned to them, or, if no nodes are assigned to that |
| 4503 |
|
|
<code><a href="#content0">content</a></code> element, by the child nodes |
| 4504 |
|
|
of that <code><a href="#content0">content</a></code> element. If an |
| 4505 |
|
|
element's <code>childNodes</code> list is empty but the element has an |
| 4506 |
|
|
<code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute |
| 4507 |
|
|
that uses the <code><a href="#xbltext">xbl:text</a></code> value on the |
| 4508 |
|
|
left hand side in a way that is not <a href="#in-error">in error</a> then |
| 4509 |
|
|
its "explicit children" is the text node generated during <a |
| 4510 |
|
|
href="#attribute1">attribute forwarding</a>.</p> |
| 4511 |
|
|
|
| 4512 |
|
|
<div class=example> |
| 4513 |
|
|
<p>Consider the following simple document:</p> |
| 4514 |
|
|
|
| 4515 |
|
|
<pre><X><A/></X></pre> |
| 4516 |
|
|
|
| 4517 |
|
|
<p>Now, if the element X in that document is bound to a binding with the |
| 4518 |
|
|
following shadow tree template:</p> |
| 4519 |
|
|
|
| 4520 |
|
|
<pre><template> |
| 4521 |
|
|
<my:T> |
| 4522 |
|
|
<my:P/> |
| 4523 |
|
|
<content/> |
| 4524 |
|
|
<my:Q/> |
| 4525 |
|
|
</my:T> |
| 4526 |
|
|
</template></pre> |
| 4527 |
|
|
|
| 4528 |
|
|
<p>The explicit children of the <code>T</code> element, ignoring |
| 4529 |
|
|
whitespace nodes, are, in order, <code>P</code>, <code>A</code>, and |
| 4530 |
|
|
<code>Q</code>. This is because the children of <code>T</code> are |
| 4531 |
|
|
<code>P</code>, a <code><a href="#content0">content</a></code> element, |
| 4532 |
|
|
and <code>Q</code>, and the <code><a href="#content0">content</a></code> |
| 4533 |
|
|
element has just one node associated with it, namely the <code>A</code> |
| 4534 |
|
|
element.</p> |
| 4535 |
|
|
</div> |
| 4536 |
|
|
|
| 4537 |
|
|
<p>When the <a href="#explicit3">explicit children</a> are distributed and |
| 4538 |
|
|
assigned to the <code><a href="#content0">content</a></code> elements in |
| 4539 |
|
|
the bound element's shadow trees, the <code |
| 4540 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 4541 |
|
|
attribute determines which <code><a href="#content0">content</a></code> |
| 4542 |
|
|
element a given child is to be placed under.</p> |
| 4543 |
|
|
|
| 4544 |
|
|
<p>If no <code title=attr-content-includes><a |
| 4545 |
|
|
href="#includes">includes</a></code> attribute is specified, a <code><a |
| 4546 |
|
|
href="#content0">content</a></code> element is considered generic and |
| 4547 |
|
|
will match on all content, including text nodes, CDATA nodes, comments, |
| 4548 |
|
|
and so on.</p> |
| 4549 |
|
|
|
| 4550 |
|
|
<p>If the <code title=attr-content-includes><a |
| 4551 |
|
|
href="#includes">includes</a></code> attribute is specified, it must be |
| 4552 |
|
|
interpreted as a <a href="#attributes21">selector</a>, and only elements |
| 4553 |
|
|
that <a href="#selectors1" title="selectors and shadow scopes">match the |
| 4554 |
|
|
selector</a> apply to that <code><a href="#content0">content</a></code> |
| 4555 |
|
|
element. If the selector is invalid, the <code><a |
| 4556 |
|
|
href="#content0">content</a></code> element is <a href="#in-error">in |
| 4557 |
|
|
error</a> and does not match any nodes. Matching of the elements to the |
| 4558 |
|
|
selector is done without taking into account the shadow tree in which the |
| 4559 |
|
|
<code><a href="#content0">content</a></code> element itself is found. <a |
| 4560 |
|
|
href="#refsSELECTORS">[SELECTORS]</a></p> |
| 4561 |
|
|
|
| 4562 |
|
|
<p>Each node that is to be distributed (each <a href="#explicit3" |
| 4563 |
|
|
title="explicit children">explicit child node</a>) must be assigned to a |
| 4564 |
|
|
<code><a href="#content0">content</a></code> element as follows:</p> |
| 4565 |
|
|
|
| 4566 |
|
|
<ol> |
| 4567 |
|
|
<li>If the node is already assigned to a <code><a |
| 4568 |
|
|
href="#content0">content</a></code> element for this binding, and the |
| 4569 |
|
|
<code><a href="#content0">content</a></code> element is <a |
| 4570 |
|
|
href="#locked" title=attr-content-locked>locked</a>, then that is the |
| 4571 |
|
|
<code><a href="#content0">content</a></code> element to which the node |
| 4572 |
|
|
must be assigned, stop here. |
| 4573 |
|
|
|
| 4574 |
|
|
<li>Otherwise: if the node is already assigned to a <code><a |
| 4575 |
|
|
href="#content0">content</a></code> element for this binding, unassign |
| 4576 |
|
|
it. |
| 4577 |
|
|
|
| 4578 |
|
|
<li>Let <var>T</var> be the shadow tree of the <span>most derived</span> |
| 4579 |
|
|
binding with a shadow tree for the bound element. |
| 4580 |
|
|
|
| 4581 |
|
|
<li>If <var>T</var> contains a <a href="#correct">correct</a> <code><a |
| 4582 |
|
|
href="#content0">content</a></code> element that is not <a |
| 4583 |
|
|
href="#locked" title=attr-content-locked>locked</a> and to which the |
| 4584 |
|
|
node in question applies, then the first such element in a depth-first, |
| 4585 |
|
|
pre-order traversal of the shadow tree <var>T</var> is the <code><a |
| 4586 |
|
|
href="#content0">content</a></code> element to which the node must be |
| 4587 |
|
|
assigned, stop here. |
| 4588 |
|
|
|
| 4589 |
|
|
<li>Otherwise, if this binding has no <a href="#correct">correct</a> |
| 4590 |
|
|
<code><a href="#inherited0">inherited</a></code> element in its shadow |
| 4591 |
|
|
tree, then the node is not assigned to a <code><a |
| 4592 |
|
|
href="#content0">content</a></code> element, and does not appear in the |
| 4593 |
|
|
<a href="#final0">final flattened tree</a>; stop here. |
| 4594 |
|
|
|
| 4595 |
|
|
<li>Otherwise, if the binding has a <a href="#correct">correct</a> |
| 4596 |
|
|
<code><a href="#inherited0">inherited</a></code> element in its shadow |
| 4597 |
|
|
tree but it is the least derived binding with a shadow tree, then the |
| 4598 |
|
|
node is not assigned to a <code><a href="#content0">content</a></code> |
| 4599 |
|
|
element, and does not appear in the <a href="#final0">final flattened |
| 4600 |
|
|
tree</a>; stop here. |
| 4601 |
|
|
|
| 4602 |
|
|
<li>Otherwise, let <var>T</var> be the shadow tree of the <a |
| 4603 |
|
|
href="#next-">next most derived</a> binding with a shadow tree and |
| 4604 |
|
|
return to step 4. |
| 4605 |
|
|
</ol> |
| 4606 |
|
|
|
| 4607 |
|
|
<p>The <a href="#explicit3">explicit children</a> must be processed in |
| 4608 |
|
|
order, so if two nodes are assigned to a <code><a |
| 4609 |
|
|
href="#content0">content</a></code> element, their order in the <code><a |
| 4610 |
|
|
href="#xblchildnodes">xblChildNodes</a></code> list is the same as their |
| 4611 |
|
|
relative order in the <a href="#explicit3">explicit children</a> list.</p> |
| 4612 |
|
|
|
| 4613 |
|
|
<div class=example> |
| 4614 |
|
|
<p>Consider the following simple document:</p> |
| 4615 |
|
|
|
| 4616 |
|
|
<pre><X><A/><B/><C/></X></pre> |
| 4617 |
|
|
|
| 4618 |
|
|
<p>Imagine that the element X in that document is bound to a binding with |
| 4619 |
|
|
the following shadow tree template:</p> |
| 4620 |
|
|
|
| 4621 |
|
|
<pre><template> |
| 4622 |
|
|
<my:T> |
| 4623 |
|
|
<my:M/> |
| 4624 |
|
|
<content/> |
| 4625 |
|
|
<my:N/> |
| 4626 |
|
|
</my:T> |
| 4627 |
|
|
</template></pre> |
| 4628 |
|
|
|
| 4629 |
|
|
<p>Imagine further that the element T is itself bound to a binding with |
| 4630 |
|
|
the following template:</p> |
| 4631 |
|
|
|
| 4632 |
|
|
<pre><template> |
| 4633 |
|
|
<my:R> |
| 4634 |
|
|
<content includes="N"/> |
| 4635 |
|
|
<content includes="B"/> |
| 4636 |
|
|
</my:R> |
| 4637 |
|
|
</template></pre> |
| 4638 |
|
|
|
| 4639 |
|
|
<p>The resulting <a href="#final0">final flattened tree</a> would be:</p> |
| 4640 |
|
|
|
| 4641 |
|
|
<pre> X |
| 4642 |
|
|
| |
| 4643 |
|
|
`-- T |
| 4644 |
|
|
| |
| 4645 |
|
|
`-- R |
| 4646 |
|
|
| |
| 4647 |
|
|
+-- N |
| 4648 |
|
|
| |
| 4649 |
|
|
`-- B</pre> |
| 4650 |
|
|
|
| 4651 |
|
|
<p>In this example, there are two selectors, "N" and "B", both of which |
| 4652 |
|
|
match just elements with the given local name.</p> |
| 4653 |
|
|
</div> |
| 4654 |
|
|
|
| 4655 |
|
|
<h4 id=when-nodes><span class=secno>4.4.2. </span>When Nodes Are |
| 4656 |
|
|
Redistributed</h4> |
| 4657 |
|
|
|
| 4658 |
|
|
<p>The algorithm described in the previous section is applied when:</p> |
| 4659 |
|
|
|
| 4660 |
|
|
<ul> |
| 4661 |
|
|
<li><a href="#rules3" title="Rules for Shadow Content Generation">A |
| 4662 |
|
|
shadow tree is generated</a>. |
| 4663 |
|
|
|
| 4664 |
|
|
<li><a href="#rules4" title="Rules for Shadow Content Destruction">A |
| 4665 |
|
|
shadow tree is destroyed and the bound element still has bindings with |
| 4666 |
|
|
shadow trees</a>. |
| 4667 |
|
|
|
| 4668 |
|
|
<li><a href="#handling4" title="Handling DOM Changes">The bound element |
| 4669 |
|
|
has explicit children added, removed, or moved</a>. |
| 4670 |
|
|
|
| 4671 |
|
|
<li><a href="#handling4" title="Handling DOM Changes">A shadow tree is |
| 4672 |
|
|
modified in a way that affects the relative order of |
| 4673 |
|
|
<code>content</code> elements or their <code |
| 4674 |
|
|
title=attr-content-includes>includes</code> attributes</a>. |
| 4675 |
|
|
|
| 4676 |
|
|
<li><a href="#handling4" title="Handling DOM Changes">An <code |
| 4677 |
|
|
title=attr-content-includes>includes</code> attribute in the shadow tree |
| 4678 |
|
|
is mutated</a>. |
| 4679 |
|
|
|
| 4680 |
|
|
<li><a href="#processing2" title="Processing content Elements">One or |
| 4681 |
|
|
more of the nodes assigned to a <code>content</code> element in a shadow |
| 4682 |
|
|
tree no longer match the element's <code |
| 4683 |
|
|
title=attr-content-includes>includes</code> attribute.</a></li> |
| 4684 |
|
|
<!-- XXXX the shadow tree is regenerated, e.g. template descendants |
| 4685 |
|
|
are modified --> |
| 4686 |
|
|
</ul> |
| 4687 |
|
|
|
| 4688 |
|
|
<div class=example> |
| 4689 |
|
|
<p>Consider the following binding shadow tree:</p> |
| 4690 |
|
|
|
| 4691 |
|
|
<pre><template> |
| 4692 |
|
|
<div>As: <content includes="A, AA"/></div> |
| 4693 |
|
|
<div>Other: <content/></div> |
| 4694 |
|
|
</template></pre> |
| 4695 |
|
|
|
| 4696 |
|
|
<p>If an element is bound to this binding while it has three child |
| 4697 |
|
|
elements A, AA, and B, then the A and AA elements would end up under the |
| 4698 |
|
|
first <code><a href="#content0">content</a></code> element, and the B |
| 4699 |
|
|
element would end up under the second <code><a |
| 4700 |
|
|
href="#content0">content</a></code> element. But if the <code |
| 4701 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 4702 |
|
|
attribute of the first <code><a href="#content0">content</a></code> |
| 4703 |
|
|
element in the shadow tree was then dynamically modified to just have |
| 4704 |
|
|
the value "<code title="">A</code>", then the AA element would be |
| 4705 |
|
|
reassigned to the second <code><a href="#content0">content</a></code> |
| 4706 |
|
|
element.</p> |
| 4707 |
|
|
</div> |
| 4708 |
|
|
|
| 4709 |
|
|
<h3 id=the-final><span class=secno>4.5. </span>The <dfn id=final0>Final |
| 4710 |
|
|
Flattened Tree</dfn></h3> |
| 4711 |
|
|
|
| 4712 |
|
|
<p>The final flattened tree is the view of the document and shadow trees |
| 4713 |
|
|
after XBL has been fully applied. It is only used for two things:</p> |
| 4714 |
|
|
|
| 4715 |
|
|
<dl> |
| 4716 |
|
|
<dt>Rendering |
| 4717 |
|
|
|
| 4718 |
|
|
<dd>Rendering must be performed using the final flattened tree. Nodes |
| 4719 |
|
|
that do not appear in the final flattened tree must not be rendered. |
| 4720 |
|
|
(See: <a href="#css-property1">CSS property inheritance and |
| 4721 |
|
|
rendering</a>.) |
| 4722 |
|
|
|
| 4723 |
|
|
<dt>Event dispatch |
| 4724 |
|
|
|
| 4725 |
|
|
<dd>Events flow along the final flattened tree. (See: <a |
| 4726 |
|
|
href="#event13">event flow and targeting across shadow scopes</a>.) |
| 4727 |
|
|
</dl> |
| 4728 |
|
|
|
| 4729 |
|
|
<p>All other processing continues to use the DOM Core tree. (See: <a |
| 4730 |
|
|
href="#shadow10" title="Semantics of non-XBL elements in XBL |
| 4731 |
|
|
contexts">shadow content and other things</a>.)</p> |
| 4732 |
|
|
|
| 4733 |
|
|
<p>The final flattened tree must be constructed by taking the bound |
| 4734 |
|
|
document's core DOM tree and performing the equivalent of the following |
| 4735 |
|
|
steps on each bound element, until there are no more bound elements in |
| 4736 |
|
|
the tree that have not been processed:</p> |
| 4737 |
|
|
|
| 4738 |
|
|
<ol> |
| 4739 |
|
|
<li>If the bound element has no shadow trees, move on to the next bound |
| 4740 |
|
|
element. |
| 4741 |
|
|
|
| 4742 |
|
|
<li>Otherwise, replace the child nodes of the bound element with the |
| 4743 |
|
|
child nodes of the most derived shadow tree's root <code><a |
| 4744 |
|
|
href="#template0">template</a></code> element. |
| 4745 |
|
|
|
| 4746 |
|
|
<li>For any element in the shadow tree that has an <code |
| 4747 |
|
|
title=attr-attr><a href="#xblattr0">xbl:attr</a></code> attribute that |
| 4748 |
|
|
uses the <code><a href="#xbltext">xbl:text</a></code> value on the left |
| 4749 |
|
|
hand side in a way that is not <a href="#in-error">in error</a>, let the |
| 4750 |
|
|
element's only child node be the attribute-forwarding text node. (If the |
| 4751 |
|
|
element in question has any child nodes, then the <code><a |
| 4752 |
|
|
href="#xbltext">xbl:text</a></code> value will be <a href="#in-error">in |
| 4753 |
|
|
error</a>.) |
| 4754 |
|
|
|
| 4755 |
|
|
<li>Replace any <code><a href="#content0">content</a></code> elements in |
| 4756 |
|
|
the shadow tree with the nodes that were assigned to them in the <a |
| 4757 |
|
|
href="#processing2" title="Processing content Elements">previous |
| 4758 |
|
|
section</a>, unless there are no such nodes, in which case replace them |
| 4759 |
|
|
with their child nodes. |
| 4760 |
|
|
|
| 4761 |
|
|
<li>Replace the second and subsequent <code><a |
| 4762 |
|
|
href="#inherited0">inherited</a></code> elements in the shadow tree with |
| 4763 |
|
|
their child nodes. |
| 4764 |
|
|
|
| 4765 |
|
|
<li>Replace the first <code><a href="#inherited0">inherited</a></code> |
| 4766 |
|
|
element in the shadow tree, if any, with the child nodes of the <a |
| 4767 |
|
|
href="#next-">next most derived</a> binding's shadow tree's root |
| 4768 |
|
|
<code><a href="#template0">template</a></code> element, or, if there is |
| 4769 |
|
|
no less-derived binding with a shadow tree, with the child nodes of the |
| 4770 |
|
|
<code><a href="#inherited0">inherited</a></code> element itself. |
| 4771 |
|
|
|
| 4772 |
|
|
<li>If the previous step added a shadow tree to the flattened tree, then |
| 4773 |
|
|
return to step 3 to deal with that newly added shadow tree. Otherwise, |
| 4774 |
|
|
move on to the next bound element. |
| 4775 |
|
|
</ol> |
| 4776 |
|
|
|
| 4777 |
|
|
<div class=example> |
| 4778 |
|
|
<p>Imagine the following document fragment:</p> |
| 4779 |
|
|
|
| 4780 |
|
|
<pre>... |
| 4781 |
|
|
<A> |
| 4782 |
|
|
<B> |
| 4783 |
|
|
<C/> |
| 4784 |
|
|
<D/> |
| 4785 |
|
|
</B> |
| 4786 |
|
|
</A> |
| 4787 |
|
|
...</pre> |
| 4788 |
|
|
|
| 4789 |
|
|
<p>...is bound to the following XBL:</p> |
| 4790 |
|
|
|
| 4791 |
|
|
<pre><xbl:xbl xmlns:xbl="http://www.w3.org/ns/xbl"> |
| 4792 |
|
|
<xbl:binding element="B"> |
| 4793 |
|
|
<xbl:template> |
| 4794 |
|
|
<P> |
| 4795 |
|
|
<Q> |
| 4796 |
|
|
<xbl:content includes="C"> |
| 4797 |
|
|
<R/> |
| 4798 |
|
|
</xbl:content> |
| 4799 |
|
|
</Q> |
| 4800 |
|
|
<xbl:content includes="D"> |
| 4801 |
|
|
<S/> |
| 4802 |
|
|
</xbl:content> |
| 4803 |
|
|
</P> |
| 4804 |
|
|
</xbl:template> |
| 4805 |
|
|
</xbl:binding> |
| 4806 |
|
|
<xbl:binding element="Q"> |
| 4807 |
|
|
<xbl:template> |
| 4808 |
|
|
<X> |
| 4809 |
|
|
<Y> |
| 4810 |
|
|
<xbl:content> |
| 4811 |
|
|
<Z1/> |
| 4812 |
|
|
</xbl:content> |
| 4813 |
|
|
<xbl:content> |
| 4814 |
|
|
<Z2/> |
| 4815 |
|
|
</xbl:content> |
| 4816 |
|
|
</Y> |
| 4817 |
|
|
</X> |
| 4818 |
|
|
</xbl:template> |
| 4819 |
|
|
</xbl:binding> |
| 4820 |
|
|
</xbl:xbl></pre> |
| 4821 |
|
|
|
| 4822 |
|
|
<p>The resulting DOM would look like the following. To read these |
| 4823 |
|
|
diagrams, use the following key:</p> |
| 4824 |
|
|
|
| 4825 |
|
|
<pre> |
| 4826 |
|
|
| Solid/dashed lines represent normal DOM traversal attribute |
| 4827 |
|
|
---+--- relationships using childNodes, parentNode, nextSibling, |
| 4828 |
|
|
| previousSibling, firstChild, lastChild, etc. |
| 4829 |
|
|
|
| 4830 |
|
|
: |
| 4831 |
|
|
...:... Dotted lines represent the final flattened tree. |
| 4832 |
|
|
:</pre> |
| 4833 |
|
|
|
| 4834 |
|
|
<p>White-space nodes have, for sanity, been left out of these diagrams.</p> |
| 4835 |
|
|
|
| 4836 |
|
|
<p>DOM view:</p> |
| 4837 |
|
|
|
| 4838 |
|
|
<pre> |
| 4839 |
|
|
| |
| 4840 |
|
|
+-- A |
| 4841 |
|
|
| |
| 4842 |
|
|
+-- B |
| 4843 |
|
|
| |
| 4844 |
|
|
+-- C |
| 4845 |
|
|
| |
| 4846 |
|
|
+-- D |
| 4847 |
|
|
</pre> |
| 4848 |
|
|
|
| 4849 |
|
|
<p>The shadow trees of B elements:</p> |
| 4850 |
|
|
|
| 4851 |
|
|
<pre> |
| 4852 |
|
|
template |
| 4853 |
|
|
| |
| 4854 |
|
|
+-- P |
| 4855 |
|
|
| |
| 4856 |
|
|
+-- Q |
| 4857 |
|
|
| | |
| 4858 |
|
|
| +-- content |
| 4859 |
|
|
| | |
| 4860 |
|
|
| +-- R |
| 4861 |
|
|
| |
| 4862 |
|
|
+-- content |
| 4863 |
|
|
| |
| 4864 |
|
|
+-- S |
| 4865 |
|
|
</pre> |
| 4866 |
|
|
|
| 4867 |
|
|
<p>The shadow trees of Q elements:</p> |
| 4868 |
|
|
|
| 4869 |
|
|
<pre> |
| 4870 |
|
|
template |
| 4871 |
|
|
| |
| 4872 |
|
|
+-- X |
| 4873 |
|
|
| |
| 4874 |
|
|
+-- Y |
| 4875 |
|
|
| |
| 4876 |
|
|
+-- content |
| 4877 |
|
|
| | |
| 4878 |
|
|
| +-- Z1 |
| 4879 |
|
|
| |
| 4880 |
|
|
+-- content |
| 4881 |
|
|
| |
| 4882 |
|
|
+-- Z2 |
| 4883 |
|
|
</pre> |
| 4884 |
|
|
|
| 4885 |
|
|
<p>The final flattened tree:</p> |
| 4886 |
|
|
|
| 4887 |
|
|
<pre> |
| 4888 |
|
|
: |
| 4889 |
|
|
:.. A |
| 4890 |
|
|
: |
| 4891 |
|
|
:.. B |
| 4892 |
|
|
: |
| 4893 |
|
|
:.. P |
| 4894 |
|
|
: |
| 4895 |
|
|
:.. Q |
| 4896 |
|
|
: : |
| 4897 |
|
|
: :.. X |
| 4898 |
|
|
: : |
| 4899 |
|
|
: :.. Y |
| 4900 |
|
|
: : |
| 4901 |
|
|
: :.. C |
| 4902 |
|
|
: : |
| 4903 |
|
|
: :.. Z2 |
| 4904 |
|
|
: |
| 4905 |
|
|
:.. D |
| 4906 |
|
|
</pre> |
| 4907 |
|
|
|
| 4908 |
|
|
<p>The final flattened tree overlayed with the core DOM (the "*" and "#" |
| 4909 |
|
|
characters here identify which <code><a |
| 4910 |
|
|
href="#content0">content</a></code> elements the two explicit children |
| 4911 |
|
|
are assigned to):</p> |
| 4912 |
|
|
|
| 4913 |
|
|
<pre id=pretty-diagram> |
| 4914 |
|
|
:|___ |
| 4915 |
|
|
:....A template |
| 4916 |
|
|
:|___ | |
| 4917 |
|
|
:... B | |
| 4918 |
|
|
:| | |
| 4919 |
|
|
:|... P template |
| 4920 |
|
|
| :|____ | |
| 4921 |
|
|
| :|... Q | |
| 4922 |
|
|
| :| :| | |
| 4923 |
|
|
| :| :|.... X |
| 4924 |
|
|
| :| | :\_______ |
| 4925 |
|
|
| :| | :....... Y __ |
| 4926 |
|
|
| :| | : \ |
| 4927 |
|
|
| :| +-- content* : | |
| 4928 |
|
|
| :| | : | |
| 4929 |
|
|
| :| +-- R : +-- content* |
| 4930 |
|
|
| :| : | | |
| 4931 |
|
|
+---:|--------- C* ......: | `-- Z1 |
| 4932 |
|
|
| :| : | |
| 4933 |
|
|
| :| : `-- content |
| 4934 |
|
|
| :| : |___ |
| 4935 |
|
|
| :| :............ Z2 |
| 4936 |
|
|
| :`-- content# |
| 4937 |
|
|
| : | |
| 4938 |
|
|
| : `-- S |
| 4939 |
|
|
|___:____ |
| 4940 |
|
|
:... D# |
| 4941 |
|
|
</pre> |
| 4942 |
|
|
</div> |
| 4943 |
|
|
|
| 4944 |
|
|
<h4 id=terminology0><span class=ja-translation lang=ja><span class=secno>4.5.1. </span>用語</span></h4> |
| 4945 |
|
|
|
| 4946 |
|
|
<p>Shadow content introduces the concept of <dfn id=shadow9>shadow |
| 4947 |
|
|
scope</dfn> to nodes within a document. Because shadow content elements |
| 4948 |
|
|
can also have bindings attached that generate their own shadow content, |
| 4949 |
|
|
this scoping can be taken to an arbitrary level of nesting.</p> |
| 4950 |
|
|
|
| 4951 |
|
|
<p>Shadow content nodes are in <dfn id=binding-level>binding-level shadow |
| 4952 |
|
|
scopes</dfn>. Binding scopes are determined by the bound element to which |
| 4953 |
|
|
the binding responsible for the generation of the shadow nodes is |
| 4954 |
|
|
attached. The bound element itself is in the shadow scope of the content |
| 4955 |
|
|
around it, and its binding's shadow content is in a deeper shadow scope. |
| 4956 |
|
|
Shadow content that contains no elements that are themselves bound is |
| 4957 |
|
|
said to be in the deepest, or innermost, shadow scope.</p> |
| 4958 |
|
|
|
| 4959 |
|
|
<h3 id=handling0><span class=secno>4.6. </span><dfn id=handling4>Handling |
| 4960 |
|
|
DOM Changes</dfn></h3> |
| 4961 |
|
|
|
| 4962 |
|
|
<p>All of the nodes in the shadow tree are live. Whenever an element is |
| 4963 |
|
|
inserted into, removed from, or appended to the DOM, and whenever its |
| 4964 |
|
|
attributes or pseudo-class states are changed, all the children of bound |
| 4965 |
|
|
elements must check that their assigned <code><a |
| 4966 |
|
|
href="#content0">content</a></code> element is still appropriate, |
| 4967 |
|
|
following all the same rules that applied when first placing <a |
| 4968 |
|
|
href="#explicit3">explicit children</a> during shadow content generation. |
| 4969 |
|
|
If one or more nodes stop fitting into any of the <code><a |
| 4970 |
|
|
href="#content0">content</a></code> elements then they no longer appear |
| 4971 |
|
|
in the <a href="#final0">final flattened tree</a>. Similarly, nodes that |
| 4972 |
|
|
previously did not appear in the final flattened tree may start matching |
| 4973 |
|
|
a <code><a href="#content0">content</a></code> element and thus be |
| 4974 |
|
|
inserted into the flattened tree.</p> |
| 4975 |
|
|
|
| 4976 |
|
|
<p>It is possible to manipulate the shadow content contained underneath a |
| 4977 |
|
|
bound element using standard DOM APIs. If shadow content that contains a |
| 4978 |
|
|
<code><a href="#content0">content</a></code> element is removed, then any |
| 4979 |
|
|
<a href="#explicit3">explicit children</a> assigned to that element are |
| 4980 |
|
|
relocated to the first unlocked <code><a |
| 4981 |
|
|
href="#content0">content</a></code> elements that match them. If a |
| 4982 |
|
|
<code><a href="#content0">content</a></code> element's <code |
| 4983 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 4984 |
|
|
attribute is changed, then the <a href="#explicit3">explicit children</a> |
| 4985 |
|
|
of the binding's bound element must be redistributed appropriately.</p> |
| 4986 |
|
|
|
| 4987 |
|
|
<p><code><a href="#content0">content</a></code> elements may be |
| 4988 |
|
|
dynamically locked by manipulating their <code |
| 4989 |
|
|
title=attr-content-locked><a href="#locked">locked</a></code> attribute. |
| 4990 |
|
|
A locked <code><a href="#content0">content</a></code> element cannot |
| 4991 |
|
|
accept new children unless they are explicitly assigned to it using the |
| 4992 |
|
|
<code><a href="#setinsertionpoint">setInsertionPoint()</a></code> method. |
| 4993 |
|
|
However, children already under a locked <code><a |
| 4994 |
|
|
href="#content0">content</a></code> element remain there while the |
| 4995 |
|
|
element's <code title=attr-content-includes><a |
| 4996 |
|
|
href="#includes">includes</a></code> attribute (or lack thereof) matches |
| 4997 |
|
|
them.</p> |
| 4998 |
|
|
|
| 4999 |
|
|
<p>Whenever the subtree of a <code><a |
| 5000 |
|
|
href="#template0">template</a></code> element in a binding document is |
| 5001 |
|
|
dynamically modified, any shadow trees that were constructed by cloning |
| 5002 |
|
|
that element must be <a href="#regenerating">regenerated</a>.</p> |
| 5003 |
|
|
<!-- XXX when does this happen, |
| 5004 |
|
|
exactly, relative to the mutations? --> |
| 5005 |
|
|
<h3 id=shadow0><span class=secno>4.7. </span>Shadow Content and CSS</h3> |
| 5006 |
|
|
|
| 5007 |
|
|
<h4 id=selectors><span class=secno>4.7.1. </span><dfn |
| 5008 |
|
|
id=selectors1>Selectors and Shadow Scopes</dfn></h4> |
| 5009 |
|
|
|
| 5010 |
|
|
<p>Bindings can interleave shadow elements between the bound element and |
| 5011 |
|
|
its <a href="#explicit3">explicit children</a>. (See: <a |
| 5012 |
|
|
href="#processing2">processing <code title="">content</code> |
| 5013 |
|
|
elements</a>.) In this situation, a new tree emerges that is different |
| 5014 |
|
|
from the explicit content node tree. In addition to having a single |
| 5015 |
|
|
explicit parent (the bound element) and a single set of children (the |
| 5016 |
|
|
explicit children in the DOM tree), elements also have a set of shadow |
| 5017 |
|
|
parents and shadow children (introduced by bindings when <code><a |
| 5018 |
|
|
href="#content0">content</a></code> elements were used). This necessarily |
| 5019 |
|
|
affects the CSS model.</p> |
| 5020 |
|
|
|
| 5021 |
|
|
<p><em>Combinators:</em> CSS combinators, in the presence of XBL, must act |
| 5022 |
|
|
as follows. This is intended to match the definitions of CSS in all cases |
| 5023 |
|
|
other than when a selector would involve one or more XBL elements.</p> |
| 5024 |
|
|
|
| 5025 |
|
|
<dl> |
| 5026 |
|
|
<dt>A>B |
| 5027 |
|
|
|
| 5028 |
|
|
<dd> |
| 5029 |
|
|
<p>If "<code>B</code>" is in a shadow tree and |
| 5030 |
|
|
"<code>B.parentNode</code>" is a <code><a |
| 5031 |
|
|
href="#content0">content</a></code> element or an <code><a |
| 5032 |
|
|
href="#inherited0">inherited</a></code> element, let "<code>X</code>" |
| 5033 |
|
|
be "<code>B.parentNode.parentNode</code>", otherwise let |
| 5034 |
|
|
"<code>X</code>" be "<code>B.parentNode</code>".</p> |
| 5035 |
|
|
|
| 5036 |
|
|
<p>Now if "<code>X</code>" is the root of a shadow tree, but the |
| 5037 |
|
|
binding's "<code title=attr-template-allow-selectors-through><a |
| 5038 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code>" is |
| 5039 |
|
|
not <code>true</code>, the selector doesn't match "<code>B</code>". |
| 5040 |
|
|
Otherwise, if "<code>X</code>" is the root of a shadow tree and the |
| 5041 |
|
|
binding's "<code title=attr-template-allow-selectors-through><a |
| 5042 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code>" is |
| 5043 |
|
|
<code>true</code> and the binding is the bound element's most derived |
| 5044 |
|
|
binding with a shadow tree, then let "<code>X</code>" be the bound |
| 5045 |
|
|
element for which the shadow tree was generated. Otherwise, if |
| 5046 |
|
|
"<code>X</code>" is the root of a shadow tree and the binding's "<code |
| 5047 |
|
|
title=attr-template-allow-selectors-through><a |
| 5048 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code>" is |
| 5049 |
|
|
<code>true</code> but the binding is not the bound element's most |
| 5050 |
|
|
derived binding with a shadow tree, then let "<code>X</code>" be the |
| 5051 |
|
|
parent node of the <code><a href="#inherited0">inherited</a></code> |
| 5052 |
|
|
element into which the shadow tree was placed during the construction |
| 5053 |
|
|
of the <a href="#final0">final flattened tree</a>; if this is itself |
| 5054 |
|
|
the root of a shadow tree, then repeat the steps described in this |
| 5055 |
|
|
paragraph using that element as "<code>X</code>".</p> |
| 5056 |
|
|
|
| 5057 |
|
|
<p>Then, the selector matches "<code>B</code>" if the "<code>X</code>" |
| 5058 |
|
|
element is the "<code>A</code>" element.</p> |
| 5059 |
|
|
|
| 5060 |
|
|
<dt>A B |
| 5061 |
|
|
|
| 5062 |
|
|
<dd>Matches "<code>B</code>" if either "<code>A>B</code>" matches |
| 5063 |
|
|
"<code>B</code>", or "<code>C>B</code>" matches "<code>B</code>" and |
| 5064 |
|
|
"<code>A C</code>" matches "<code>C</code>". |
| 5065 |
|
|
|
| 5066 |
|
|
<dt>A+B |
| 5067 |
|
|
|
| 5068 |
|
|
<dd>If "<code>B</code>" is in a shadow tree and |
| 5069 |
|
|
"<code>B.previousSibling</code>" is a <code><a |
| 5070 |
|
|
href="#content0">content</a></code> element or an <code><a |
| 5071 |
|
|
href="#inherited0">inherited</a></code> element, the selector doesn't |
| 5072 |
|
|
match "<code>B</code>", otherwise, it matches if |
| 5073 |
|
|
"<code>B.previousSibling</code>" is "<code>A</code>". |
| 5074 |
|
|
|
| 5075 |
|
|
<dt>A~B |
| 5076 |
|
|
|
| 5077 |
|
|
<dd>Matches "<code>B</code>" if either "<code>A+B</code>" matches |
| 5078 |
|
|
"<code>B</code>", or if "<code>C+B</code>" matches "<code>B</code>" and |
| 5079 |
|
|
"<code>A~C</code>" matches "<code>C</code>". |
| 5080 |
|
|
</dl> |
| 5081 |
|
|
|
| 5082 |
|
|
<div class=example> |
| 5083 |
|
|
<p>The selector <code>p ~ p</code> never matches any elements in the |
| 5084 |
|
|
following example, even if the <code><a |
| 5085 |
|
|
href="#content0">content</a></code> element has a <code>p</code> element |
| 5086 |
|
|
assigned to it:</p> |
| 5087 |
|
|
|
| 5088 |
|
|
<pre><template> |
| 5089 |
|
|
<html:p>...</html:p> |
| 5090 |
|
|
<content includes="p"><html:p>...</html:p></content> |
| 5091 |
|
|
<html:p>...</html:p> |
| 5092 |
|
|
</template> |
| 5093 |
|
|
</pre> |
| 5094 |
|
|
</div> |
| 5095 |
|
|
|
| 5096 |
|
|
<p><em>Pseudo-classes and pseudo-elements:</em> Pseudo-classes and |
| 5097 |
|
|
pseudo-elements are unchanged in the presence of XBL. They operate |
| 5098 |
|
|
exclusively on the core DOM.</p> |
| 5099 |
|
|
|
| 5100 |
|
|
<div class=example> |
| 5101 |
|
|
<p>In particular, note that this means that the selector |
| 5102 |
|
|
<code>:nth-child(odd)</code> would match both the <code>A</code> and |
| 5103 |
|
|
<code>B</code> nodes in the following example:</p> |
| 5104 |
|
|
|
| 5105 |
|
|
<pre><xbl:template> |
| 5106 |
|
|
<A/> |
| 5107 |
|
|
<xbl:content/> |
| 5108 |
|
|
<B/> |
| 5109 |
|
|
</xbl:template></pre> |
| 5110 |
|
|
|
| 5111 |
|
|
<p>...regardless of the number of nodes that are inserted at the point |
| 5112 |
|
|
given by the <code><a href="#content0">content</a></code> element |
| 5113 |
|
|
(whether that be 0, 1, 2, or more nodes).</p> |
| 5114 |
|
|
</div> |
| 5115 |
|
|
|
| 5116 |
|
|
<h4 id=css-property><span class=secno>4.7.2. </span><dfn |
| 5117 |
|
|
id=css-property1>CSS Property Inheritance and Rendering</dfn></h4> |
| 5118 |
|
|
|
| 5119 |
|
|
<p>The <a href="#final0">final flattened tree</a> determines how CSS |
| 5120 |
|
|
properties (e.g., fonts and colors) are inherited. Elements must inherit |
| 5121 |
|
|
from their parent node in the <a href="#final0">final flattened tree</a>, |
| 5122 |
|
|
regardless of what their DOM Core parent node is.</p> |
| 5123 |
|
|
|
| 5124 |
|
|
<p>Similarly, the rendering is performed using the <a href="#final0">final |
| 5125 |
|
|
flattened tree</a>. Nodes that do not appear in the <a |
| 5126 |
|
|
href="#final0">final flattened tree</a> have no computed style (as if |
| 5127 |
|
|
they were orphan nodes) and are not rendered.</p> |
| 5128 |
|
|
|
| 5129 |
|
|
<h4 id=the-bound-element><span class=secno>4.7.3. </span>The <code><a |
| 5130 |
|
|
href="#bound-element">:bound-element</a></code> Pseudo-Class</h4> |
| 5131 |
|
|
|
| 5132 |
|
|
<p>The <dfn id=bound-element><code>:bound-element</code></dfn> |
| 5133 |
|
|
pseudo-class, when used from a binding, must match the bound element of |
| 5134 |
|
|
that binding. If the selector is used somewhere other than in a binding's |
| 5135 |
|
|
style sheet (i.e. with a <code><a href="#style2">style</a></code> element |
| 5136 |
|
|
in XBL) or in a <code><a href="#content0">content</a></code> element's |
| 5137 |
|
|
<code title=attr-content-includes><a href="#includes">includes</a></code> |
| 5138 |
|
|
attribute, then it must match any bound element. <a |
| 5139 |
|
|
href="#refsSELECTORS">[SELECTORS]</a></p> |
| 5140 |
|
|
|
| 5141 |
|
|
<div class=example> |
| 5142 |
|
|
<p>In the following example, the binding uses this pseudo-class to to |
| 5143 |
|
|
draw a border around each of the children of the bound element, but no |
| 5144 |
|
|
other elements:</p> |
| 5145 |
|
|
|
| 5146 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 5147 |
|
|
<binding> |
| 5148 |
|
|
<template><content allow-selectors-through="true"/></template> |
| 5149 |
|
|
<style> |
| 5150 |
|
|
:bound-element > * { border: solid; } |
| 5151 |
|
|
</style> |
| 5152 |
|
|
</binding> |
| 5153 |
|
|
</xbl></pre> |
| 5154 |
|
|
</div> |
| 5155 |
|
|
|
| 5156 |
|
|
<h4 id=matching><span class=secno>4.7.4. </span><dfn id=matching1>Matching |
| 5157 |
|
|
Pseudo-Elements</dfn></h4> |
| 5158 |
|
|
|
| 5159 |
|
|
<p>Shadow nodes may be associated with various pre-defined <a |
| 5160 |
|
|
href="#pseudo-element" title=pseudo-element>pseudo-elements</a> of the |
| 5161 |
|
|
bound element. On any element in the shadow content template, an <code |
| 5162 |
|
|
title=attr-pseudo><a href="#xblpseudo0">xbl:pseudo</a></code> attribute |
| 5163 |
|
|
(in the XBL namespace) can be used to specify the name of the pseudo to |
| 5164 |
|
|
associate with that element.</p> |
| 5165 |
|
|
|
| 5166 |
|
|
<div class=example> |
| 5167 |
|
|
<p>For example, once more returning to the HTML file upload control |
| 5168 |
|
|
example above, the shadow text field can be set up to be considered a |
| 5169 |
|
|
match for the selector <span>input[type=file]::value</span> as follows.</p> |
| 5170 |
|
|
|
| 5171 |
|
|
<pre><xbl:binding id="fileUploadControl"> |
| 5172 |
|
|
<xbl:template> |
| 5173 |
|
|
<html:input type="text" xbl:pseudo="value"/> |
| 5174 |
|
|
<html:input type="button" value="Browse..."/> |
| 5175 |
|
|
</xbl:template> |
| 5176 |
|
|
</xbl:binding></pre> |
| 5177 |
|
|
</div> |
| 5178 |
|
|
|
| 5179 |
|
|
<p>The pseudo must be given without its leading double colon.</p> |
| 5180 |
|
|
|
| 5181 |
|
|
<p>If the pseudo-element name is not recognized, it is <a |
| 5182 |
|
|
href="#in-error">in error</a> and the UA must <a |
| 5183 |
|
|
href="#ignoring">ignore</a> the attribute. User agents must not |
| 5184 |
|
|
automatically recognize any pseudo-element (as this will break |
| 5185 |
|
|
forwards-compatibility).</p> |
| 5186 |
|
|
|
| 5187 |
|
|
<p>If an element has multiple nodes with the same pseudo-element, then |
| 5188 |
|
|
they all match the relevant selector. Matching of nodes based on their |
| 5189 |
|
|
pseudo-element is unaffected by the <code>apply-author-sheets</code> |
| 5190 |
|
|
attribute.</p> |
| 5191 |
|
|
|
| 5192 |
|
|
<p id=pseudo-list>The allowed pseudo-elements are:</p> |
| 5193 |
|
|
|
| 5194 |
|
|
<dl> |
| 5195 |
|
|
<dt>::value |
| 5196 |
|
|
|
| 5197 |
|
|
<dd>Intended to represent the entire rectangular 'interactive area' (or |
| 5198 |
|
|
the nearest equivalent in non-visual environments) of a text-entry form |
| 5199 |
|
|
control, specifically excluding the caption. |
| 5200 |
|
|
|
| 5201 |
|
|
<dt>::choices |
| 5202 |
|
|
|
| 5203 |
|
|
<dd>Intended to represent the entire rectangular 'selection area' (or the |
| 5204 |
|
|
nearest equivalent in non-visual environments) of a list form control, |
| 5205 |
|
|
specifically excluding the caption. |
| 5206 |
|
|
|
| 5207 |
|
|
<dt>::label |
| 5208 |
|
|
|
| 5209 |
|
|
<dd>Intended to represent the non-interactive area (or the nearest |
| 5210 |
|
|
equivalent in non-visual environments) of control, typically the |
| 5211 |
|
|
caption. |
| 5212 |
|
|
|
| 5213 |
|
|
<dt>::repeat-item |
| 5214 |
|
|
|
| 5215 |
|
|
<dd>Within a repeating sequence, for example generated by the repeat |
| 5216 |
|
|
construct in XForms, <!-- or the template stuff in XUL --> each repeated |
| 5217 |
|
|
item could be labeled as matching a pseudo-element ::repeat-item. |
| 5218 |
|
|
|
| 5219 |
|
|
<dt>::icon |
| 5220 |
|
|
|
| 5221 |
|
|
<dd>Intended to represent the icon part of a control, for example the |
| 5222 |
|
|
picture in a toolbar button or the icon next to a menu item.</dd> |
| 5223 |
|
|
<!-- |
| 5224 |
|
|
<dt>::XXX</dt> |
| 5225 |
|
|
|
| 5226 |
|
|
<dd>Intended to represent a specific part (or the nearest equivalent |
| 5227 |
|
|
in non-visual environments) of a XXX control.</dd> |
| 5228 |
|
|
--> |
| 5229 |
|
|
<!-- XXX add more from css3-ui --> |
| 5230 |
|
|
</dl> |
| 5231 |
|
|
|
| 5232 |
|
|
<p>These pseudo-element descriptions are purely advisory, and while |
| 5233 |
|
|
authors are encouraged to use them for their predefined roles, it is |
| 5234 |
|
|
valid to use them for other purposes.</p> |
| 5235 |
|
|
|
| 5236 |
|
|
<div class=example> |
| 5237 |
|
|
<p>The following XBL is part of the definition of a button control.</p> |
| 5238 |
|
|
|
| 5239 |
|
|
<pre> <xbl:binding id="imageButton"> |
| 5240 |
|
|
<xbl:template> |
| 5241 |
|
|
<html:span xbl:pseudo="icon"/> |
| 5242 |
|
|
<html:span xbl:attr="xbl:text=title"/> |
| 5243 |
|
|
</xbl:template> |
| 5244 |
|
|
</xbl:binding></pre> |
| 5245 |
|
|
|
| 5246 |
|
|
<p>This control could then be used like this:</p> |
| 5247 |
|
|
|
| 5248 |
|
|
<pre><button title="Save" class="save-button"/></pre> |
| 5249 |
|
|
|
| 5250 |
|
|
<p>...and styled like this:</p> |
| 5251 |
|
|
|
| 5252 |
|
|
<pre> button { binding: url(buttons.xml#imageButton); } |
| 5253 |
|
|
button.save-button::icon { |
| 5254 |
|
|
content: url(icons/save.png); |
| 5255 |
|
|
} |
| 5256 |
|
|
</pre> |
| 5257 |
|
|
</div> |
| 5258 |
|
|
|
| 5259 |
|
|
<p>In property descriptions, the term "all elements" in the "Applies To:" |
| 5260 |
|
|
line includes these pseudo-elements, as they map directly to real |
| 5261 |
|
|
elements in the binding.</p> |
| 5262 |
|
|
|
| 5263 |
|
|
<p>User agents are required to support the above pseudo-element |
| 5264 |
|
|
identifiers, in so far as they interact with XBL2. User agents may also |
| 5265 |
|
|
support these same pseudo-elements for other purposes, e.g. as described |
| 5266 |
|
|
in the CSS3 UI specification. <a href="#refsCSS3UI">[CSS3UI]</a></p> |
| 5267 |
|
|
|
| 5268 |
|
|
<h3 id=shadow1><span class=secno>4.8. </span>Shadow Content and |
| 5269 |
|
|
<code>xml:base</code></h3> |
| 5270 |
|
|
|
| 5271 |
|
|
<p class=note>This section is intended to re-iterate what the |
| 5272 |
|
|
<code>xml:base</code> specification already states, in case there is any |
| 5273 |
|
|
question about how <code>xml:base</code> processing should work in shadow |
| 5274 |
|
|
trees.</p> |
| 5275 |
|
|
|
| 5276 |
|
|
<p>Relative <code>xml:base</code>s on nodes in shadow trees are resolved |
| 5277 |
|
|
relative to their <code>parentNode</code>, or the |
| 5278 |
|
|
<code>ownerDocument</code> if there is no <code>parentNode</code>.</p> |
| 5279 |
|
|
|
| 5280 |
|
|
<h3 id=shadow2><span class=secno>4.9. </span><dfn id=shadow10 |
| 5281 |
|
|
title="Semantics of non-XBL elements in XBL contexts">Shadow Content and |
| 5282 |
|
|
Other Things</dfn></h3> |
| 5283 |
|
|
<!--XXX Things that need to be defined in future revisions include |
| 5284 |
|
|
<em>binding to</em> html:script, html:select, html:textarea, MathML |
| 5285 |
|
|
nodes, etc (are their semantics based on the shadow tree, the |
| 5286 |
|
|
<span>final flattened tree</span>, or the original tree), as well as |
| 5287 |
|
|
having elements inside the shadow tree such as html:script, |
| 5288 |
|
|
html:style, html:map, form controls (are they part of the outer |
| 5289 |
|
|
form), html:form (does it wrap elements that are assigned to |
| 5290 |
|
|
<code>content</code> elements?), etc. --> |
| 5291 |
|
|
|
| 5292 |
|
|
<p>Since the processing rules of all non-XBL elements found while |
| 5293 |
|
|
processing a binding document are not affected by their being part of an |
| 5294 |
|
|
XBL subtree, there are certain elements that are unlikely to have the |
| 5295 |
|
|
desired effect when included in shadow content templates. Some of these |
| 5296 |
|
|
cases are described below.</p> |
| 5297 |
|
|
|
| 5298 |
|
|
<p class=note>While some of these effects may seem peculiar, it must be |
| 5299 |
|
|
emphasized that they are merely the result of XBL not affecting the |
| 5300 |
|
|
semantics of these elements at all. It would have been possible to define |
| 5301 |
|
|
XBL in such a way that the semantics of various elements from the XHTML, |
| 5302 |
|
|
XML Events, etc, namespaces were modified, but this would have required |
| 5303 |
|
|
XBL knowing about special elements from a large number of namespaces, |
| 5304 |
|
|
causing XBL implementations to have large interdependencies.</p> |
| 5305 |
|
|
|
| 5306 |
|
|
<h4 id=general><span class=secno>4.9.1. </span>General Rules</h4> |
| 5307 |
|
|
|
| 5308 |
|
|
<p>Shadow content is not considered part of a document, so elements that |
| 5309 |
|
|
are defined to trigger when they are "inserted into the document" do not |
| 5310 |
|
|
trigger during binding attachment.</p> |
| 5311 |
|
|
|
| 5312 |
|
|
<p>IDs used in shadow content, as seen on XML Events nodes, in XHTML on |
| 5313 |
|
|
the <code>html:label</code> element's <code>for</code> attribute, and in |
| 5314 |
|
|
many other places, must be resolved in the context of the <a |
| 5315 |
|
|
href="#shadow9">shadow scope</a> and (failing that) the binding document, |
| 5316 |
|
|
not the scope of the document into which the shadow content is inserted.</p> |
| 5317 |
|
|
|
| 5318 |
|
|
<div class=example> |
| 5319 |
|
|
<p>If a shadow template has an <code>html:img</code> element that has its |
| 5320 |
|
|
<code>usemap</code> attribute set:</p> |
| 5321 |
|
|
|
| 5322 |
|
|
<pre><template ...> |
| 5323 |
|
|
<html:img src="..." usemap="#test" alt="..."/> |
| 5324 |
|
|
</template></pre> |
| 5325 |
|
|
|
| 5326 |
|
|
<p>If the binding is applied to an element in a document containing an |
| 5327 |
|
|
<code>html:map</code> element with ID "test", that image map will not be |
| 5328 |
|
|
associated with this image. If the binding document itself contains an |
| 5329 |
|
|
<code>html:map</code> element with ID "test", however, that |
| 5330 |
|
|
<em>would</em> be associated with the element (even if it was, say, in |
| 5331 |
|
|
another binding's template).</p> |
| 5332 |
|
|
|
| 5333 |
|
|
<p>If the template looked like this: |
| 5334 |
|
|
|
| 5335 |
|
|
<pre><template ...> |
| 5336 |
|
|
<html:img src="..." usemap="#test" alt="..."/> |
| 5337 |
|
|
<html:map id="test"> ... </html:map> |
| 5338 |
|
|
</template></pre> |
| 5339 |
|
|
|
| 5340 |
|
|
<p>...then the <code>html:img</code> element would always be attached to |
| 5341 |
|
|
that <code>html:map</code> element, regardless of the existence of other |
| 5342 |
|
|
<code>html:map</code> elements in the binding document.</p> |
| 5343 |
|
|
</div> |
| 5344 |
|
|
|
| 5345 |
|
|
<p>When an element's processing model is defined in terms of the element's |
| 5346 |
|
|
child nodes or descendants, shadow trees do not affect the processing |
| 5347 |
|
|
model (unless this is called out explicitly below). For instance, an HTML |
| 5348 |
|
|
<code>title</code> element's behavior in determining the document title |
| 5349 |
|
|
is unaffected by XBL, even if the <code>title</code> element is bound or |
| 5350 |
|
|
has bound elements in its descendants.</p> |
| 5351 |
|
|
|
| 5352 |
|
|
<p>When the nodes are cloned, their <code>xml:base</code> data remains as |
| 5353 |
|
|
it was in the bindings document (see <span>rules for content |
| 5354 |
|
|
generation</span>). Therefore URIs consisting of just fragment |
| 5355 |
|
|
identifiers (such as those in <code>url()</code> notation in <code |
| 5356 |
|
|
title="">style</code> attributes of, e.g., XHTML nodes) refer to |
| 5357 |
|
|
resources in the bindings document, not content in the bound document or |
| 5358 |
|
|
the shadow tree.</p> |
| 5359 |
|
|
|
| 5360 |
|
|
<p class=note>This would cause trouble with <a |
| 5361 |
|
|
href="#attribute1">attribute forwarding</a>, so the attribute forwarding |
| 5362 |
|
|
syntax allows attributes to be marked as being <a href="#url" |
| 5363 |
|
|
title=type-url>of type "url"</a>.</p> |
| 5364 |
|
|
|
| 5365 |
|
|
<h4 id=style><span class=secno>4.9.2. </span><dfn id=style3>Style |
| 5366 |
|
|
Blocks</dfn></h4> |
| 5367 |
|
|
|
| 5368 |
|
|
<p>The semantics of <code>html:style</code> elements is that they |
| 5369 |
|
|
introduce new styles for their document. Since the document, in the case |
| 5370 |
|
|
of anything in an XBL subtree, is the bindings document (or the <a |
| 5371 |
|
|
href="#non-xbl">non-XBL document</a> in which the XBL subtree is found), |
| 5372 |
|
|
<em>that</em> is the document that must be affected by such a style |
| 5373 |
|
|
sheet.</p> |
| 5374 |
|
|
|
| 5375 |
|
|
<p>Since the style sheets of such resource documents generally have no |
| 5376 |
|
|
effect, placing <code>html:style</code> blocks in XBL binding documents |
| 5377 |
|
|
is usually redundant. Such an element placed in a shadow content template |
| 5378 |
|
|
does not affect the documents into which the shadow content is later |
| 5379 |
|
|
inserted during binding attachment.</p> |
| 5380 |
|
|
|
| 5381 |
|
|
<h4 id=script><span class=secno>4.9.3. </span><dfn id=script3>Script |
| 5382 |
|
|
Blocks</dfn></h4> |
| 5383 |
|
|
|
| 5384 |
|
|
<p>Script elements, such as <code>html:script</code> and its ilk, are |
| 5385 |
|
|
typically evaluated only during parsing, or during parsing and when |
| 5386 |
|
|
inserted into a document. In all cases, however, they are evaluated in |
| 5387 |
|
|
the context of their owner document. Therefore such elements must only be |
| 5388 |
|
|
evaluated during initial parsing, in the context of the XBL subtree's |
| 5389 |
|
|
document, and not during binding attachment.</p> |
| 5390 |
|
|
|
| 5391 |
|
|
<h4 id=event><span class=secno>4.9.4. </span><dfn id=event10>Event Handler |
| 5392 |
|
|
Blocks</dfn></h4> |
| 5393 |
|
|
|
| 5394 |
|
|
<p>XML Events elements in the binding document must result in event |
| 5395 |
|
|
handlers being registered as event listeners on the nodes in the original |
| 5396 |
|
|
bindings document (including possibly the <code title=template><a |
| 5397 |
|
|
href="#template0">template</a></code> node) as described in XML Events. |
| 5398 |
|
|
They may be included in shadow content templates, but when the shadow |
| 5399 |
|
|
content template is cloned, the newly cloned event handlers must cause |
| 5400 |
|
|
new event listeners to be added to their new DOM Core parent nodes. Thus |
| 5401 |
|
|
an event handler that is the child of an <code><a |
| 5402 |
|
|
href="#template0">template</a></code> element in the shadow content |
| 5403 |
|
|
template will never fire once it has been cloned, since the events <a |
| 5404 |
|
|
href="#event13" title="Event Flow and Targeting Across Shadow Scopes">do |
| 5405 |
|
|
not bubble into the <code>template</code> elements</a>. <a |
| 5406 |
|
|
href="#refsXMLEVENTS">[XMLEVENTS]</a></p> |
| 5407 |
|
|
|
| 5408 |
|
|
<p>Event handler blocks that are children of <code><a |
| 5409 |
|
|
href="#handlers0">handlers</a></code> elements (in particular XML Events |
| 5410 |
|
|
handler blocks) cause event listeners to be fired when <a |
| 5411 |
|
|
href="#event12">event forwarding</a> happens, just like with XBL <code><a |
| 5412 |
|
|
href="#handler0">handler</a></code> elements.</p> |
| 5413 |
|
|
|
| 5414 |
|
|
<h4 id=html-forms><span class=secno>4.9.5. </span>HTML Forms</h4> |
| 5415 |
|
|
|
| 5416 |
|
|
<p>Forms and form controls in shadow trees don't interact with form |
| 5417 |
|
|
controls and <code>form</code> elements in the bound document. Each |
| 5418 |
|
|
document and shadow tree creates a new scope for forms and form controls.</p> |
| 5419 |
|
|
|
| 5420 |
|
|
<div class=example> |
| 5421 |
|
|
<p>Here's an extract from an HTML document with a form:</p> |
| 5422 |
|
|
|
| 5423 |
|
|
<pre>... |
| 5424 |
|
|
<form action="register" method="post"> |
| 5425 |
|
|
<h2>Customer Registration</h2> |
| 5426 |
|
|
<p>Please enter your details.</p> |
| 5427 |
|
|
<fieldset> |
| 5428 |
|
|
<legend>Contact Information</legend> |
| 5429 |
|
|
<p>Name: <input name="name" title="Enter your full name (first name first)."></p> |
| 5430 |
|
|
<p>Job Title: <input name="title" title="Enter your job title, e.g. 'Software Engineer'."></p> |
| 5431 |
|
|
<p>E-mail: <input name="email" title="Enter your e-mail address, in the form 'user@example.com'."></p> |
| 5432 |
|
|
</fieldset> |
| 5433 |
|
|
<fieldset> |
| 5434 |
|
|
<legend>Company Information</legend> |
| 5435 |
|
|
<p>Name: <input name="company" title="Enter the name of your employer."></p> |
| 5436 |
|
|
<p>Address: <textarea name="address" title="Enter the full street address of your employer, including postal code."></p> |
| 5437 |
|
|
</fieldset> |
| 5438 |
|
|
<fieldset> |
| 5439 |
|
|
<legend>Additional Information</legend> |
| 5440 |
|
|
<p>Birthday: <input name="dob" title="Enter your birthdate in the form YYYY-MM-DD, e.g. 1975-03-29."></p> |
| 5441 |
|
|
<p>Favorite animal: <input name="animal" title="Enter the word 'Cat'."></p> |
| 5442 |
|
|
</fieldset> |
| 5443 |
|
|
<fieldset> |
| 5444 |
|
|
<legend>Submission</legend> |
| 5445 |
|
|
<p><button title="Only submit the form when you are sure it is complete.">Submit</button></p> |
| 5446 |
|
|
</fieldset> |
| 5447 |
|
|
</form> |
| 5448 |
|
|
...</pre> |
| 5449 |
|
|
|
| 5450 |
|
|
<p>The first binding, shown below as an extract from an XBL document, |
| 5451 |
|
|
could be attached to the <code>form</code> above, through CSS, to |
| 5452 |
|
|
provide a help box that shows the help text associated with the |
| 5453 |
|
|
currently focused control:</p> |
| 5454 |
|
|
|
| 5455 |
|
|
<pre>... |
| 5456 |
|
|
<binding id="form-with-help"> |
| 5457 |
|
|
<template> |
| 5458 |
|
|
<div> |
| 5459 |
|
|
<div class="header">Form:</div> |
| 5460 |
|
|
<div class="form"><content/></div> |
| 5461 |
|
|
</div> |
| 5462 |
|
|
<div> |
| 5463 |
|
|
<div class="header">Help:</div> |
| 5464 |
|
|
<div id="help"/> |
| 5465 |
|
|
</div> |
| 5466 |
|
|
</template> |
| 5467 |
|
|
<resources> |
| 5468 |
|
|
<style> |
| 5469 |
|
|
.header { font-size: larger; } |
| 5470 |
|
|
.form { height: 15em; overflow: scroll; } |
| 5471 |
|
|
</style> |
| 5472 |
|
|
</resources> |
| 5473 |
|
|
<handlers> |
| 5474 |
|
|
<handler event="focus"> |
| 5475 |
|
|
this.shadowTree.getElementById('help').textContent = event.target.getAttribute('title'); |
| 5476 |
|
|
</handler> |
| 5477 |
|
|
</handlers> |
| 5478 |
|
|
</binding> |
| 5479 |
|
|
...</pre> |
| 5480 |
|
|
|
| 5481 |
|
|
<p>The help could be positioned more usefully by a slightly more advanced |
| 5482 |
|
|
binding that positioned the <code><a href="#div0">div</a></code> when |
| 5483 |
|
|
setting the help.</p> |
| 5484 |
|
|
|
| 5485 |
|
|
<p>The last binding isn't particularly interesting. However, the |
| 5486 |
|
|
important thing to note is that if it was extended to include form |
| 5487 |
|
|
controls of its own, as in the following example, the form controls in |
| 5488 |
|
|
the binding would not interact with the form in the markup:</p> |
| 5489 |
|
|
|
| 5490 |
|
|
<pre>... |
| 5491 |
|
|
<binding id="form-with-help"> |
| 5492 |
|
|
<template> |
| 5493 |
|
|
<div class="header"> |
| 5494 |
|
|
<div class="title"><content includes=":bound-element > h2:first-of-type"/></div> |
| 5495 |
|
|
<div class="tagline"><content includes=":bound-element > h2:first-of-type ~ p:first-of-type"/></div> |
| 5496 |
|
|
</div> |
| 5497 |
|
|
<div> |
| 5498 |
|
|
<div class="panel"><content locked="true" id="current"/></div> |
| 5499 |
|
|
</div> |
| 5500 |
|
|
<div> |
| 5501 |
|
|
<div class="buttons"> |
| 5502 |
|
|
<button id="back">Back</button> |
| 5503 |
|
|
<button id="next">Next</button> |
| 5504 |
|
|
</div> |
| 5505 |
|
|
</div> |
| 5506 |
|
|
<div class="hidden"><content includes=":bound-element > fieldset" id="not-current"/></div> |
| 5507 |
|
|
</template> |
| 5508 |
|
|
<implementation> |
| 5509 |
|
|
({ |
| 5510 |
|
|
set current(fieldset) { |
| 5511 |
|
|
if (this._current) |
| 5512 |
|
|
this.shadowTree.getElementById('not-current').setInsertionPoint(this._current); |
| 5513 |
|
|
this._current = fieldset; |
| 5514 |
|
|
if (this._current) |
| 5515 |
|
|
this.shadowTree.getElementById('current').setInsertionPoint(this._current); |
| 5516 |
|
|
}, |
| 5517 |
|
|
back: function() { |
| 5518 |
|
|
if (!this._current) return; |
| 5519 |
|
|
var notCurrent = this.shadowTree.getElementById('not-current'); |
| 5520 |
|
|
notCurrent.setInsertionPoint(this._current); |
| 5521 |
|
|
var last = this._current; |
| 5522 |
|
|
var index = 0; |
| 5523 |
|
|
while (index &lt; notCurrent.xblChildNodes.length && |
| 5524 |
|
|
notCurrent.xblChildNodes[index] != this._current) |
| 5525 |
|
|
last = notCurrent.xblChildNodes[index++]; |
| 5526 |
|
|
this._current = last; |
| 5527 |
|
|
this.shadowTree.getElementById('current').setInsertionPoint(this._current); |
| 5528 |
|
|
} |
| 5529 |
|
|
next: function() { |
| 5530 |
|
|
if (!this._current) return; |
| 5531 |
|
|
var notCurrent = this.shadowTree.getElementById('not-current'); |
| 5532 |
|
|
notCurrent.setInsertionPoint(this._current); |
| 5533 |
|
|
var last = this._current; |
| 5534 |
|
|
var index = notCurrent.xblChildNodes.length-1; |
| 5535 |
|
|
while (index > 0 && notCurrent.xblChildNodes[index] != this._current) |
| 5536 |
|
|
last = notCurrent.xblChildNodes[index++]; |
| 5537 |
|
|
this._current = last; |
| 5538 |
|
|
this.shadowTree.getElementById('current').setInsertionPoint(this._current); |
| 5539 |
|
|
} |
| 5540 |
|
|
get current() { |
| 5541 |
|
|
return this._current; |
| 5542 |
|
|
}, |
| 5543 |
|
|
xblBindingAttached: function() { |
| 5544 |
|
|
this.current = this.getElementById('not-current').xblChildNodes[0]; |
| 5545 |
|
|
this.shadowTree.getElementById('back').addEventListener('click', this.back, false); |
| 5546 |
|
|
this.shadowTree.getElementById('next').addEventListener('click', this.next, false); |
| 5547 |
|
|
}, |
| 5548 |
|
|
}) |
| 5549 |
|
|
</implementation> |
| 5550 |
|
|
<resources> |
| 5551 |
|
|
<style> ... </style> |
| 5552 |
|
|
</resources> |
| 5553 |
|
|
</binding> |
| 5554 |
|
|
...</pre> |
| 5555 |
|
|
|
| 5556 |
|
|
<p>Again, the binding could be made cleaner, e.g. by disabling the "back" |
| 5557 |
|
|
button when on the first page, and by hiding the last fieldset and |
| 5558 |
|
|
instead having a "finish" button, but these improvements are left as |
| 5559 |
|
|
exercises for the reader.</p> |
| 5560 |
|
|
</div> |
| 5561 |
|
|
|
| 5562 |
|
|
<h4 id=svg><span class=secno>4.9.6. </span>SVG</h4> |
| 5563 |
|
|
|
| 5564 |
|
|
<p><em>Painting:</em> When painting groups, for child elements that have |
| 5565 |
|
|
shadow trees, instead of painting the child element itself, the group |
| 5566 |
|
|
must paint the child nodes of the element's shadow tree's root <code><a |
| 5567 |
|
|
href="#template0">template</a></code> element.</p> |
| 5568 |
|
|
|
| 5569 |
|
|
<p><em>Text:</em> When rendering text, for descendant elements that have |
| 5570 |
|
|
shadow trees, instead of using the element or its children directly, the |
| 5571 |
|
|
user agent must use the child nodes of the element's shadow tree's root |
| 5572 |
|
|
<code><a href="#template0">template</a></code> element. (All other |
| 5573 |
|
|
processing, e.g. handling of combining characters, must then be done as |
| 5574 |
|
|
defined for SVG.)</p> |
| 5575 |
|
|
|
| 5576 |
|
|
<p><em>ID references and URIs:</em> When a URI identifies an element with |
| 5577 |
|
|
a shadow tree, the SVG processor must use the first element node in the |
| 5578 |
|
|
element's shadow tree's root <code><a |
| 5579 |
|
|
href="#template0">template</a></code> element's <code>childNodes</code> |
| 5580 |
|
|
list instead of the element itself. If there are no elements, then the |
| 5581 |
|
|
SVG document is in error. The SVG specification defines how to handle |
| 5582 |
|
|
documents that are in error.</p> |
| 5583 |
|
|
<!-- NOT links to "in error", since this is |
| 5584 |
|
|
SVG-in-error, not XBL-in-error. --> |
| 5585 |
|
|
|
| 5586 |
|
|
<p>When a URI reference with a fragment identifier in a shadow tree |
| 5587 |
|
|
references the binding document, then, if an elemnt in the shadow tree is |
| 5588 |
|
|
identified by the fragment identifier, that is the element that must be |
| 5589 |
|
|
used; otherwise, the fragment identifier must be matched against the |
| 5590 |
|
|
actual binding document instead.</p> |
| 5591 |
|
|
|
| 5592 |
|
|
<p><em>Animation elements:</em> When an animation element would be |
| 5593 |
|
|
implicitly associated with its parent element (e.g. when it has no <code |
| 5594 |
|
|
title="">xlink:href</code> attribute), but that parent element is a |
| 5595 |
|
|
<code><a href="#template0">template</a></code> element that is the root |
| 5596 |
|
|
of a shadow tree, then the animation element must instead be associated |
| 5597 |
|
|
with the element found using the following algorithm:</p> |
| 5598 |
|
|
|
| 5599 |
|
|
<ol> |
| 5600 |
|
|
<li>Let <var title="">element</var> be the animation element. |
| 5601 |
|
|
|
| 5602 |
|
|
<li>If <var title="">element</var> has no parent element, then the |
| 5603 |
|
|
animation element is not associated with any element. Stop these steps. |
| 5604 |
|
|
|
| 5605 |
|
|
<li>Let <var title="">parent</var> be the parent element of <var |
| 5606 |
|
|
title="">element</var>. |
| 5607 |
|
|
|
| 5608 |
|
|
<li>If <var title="">parent</var> is a <code><a |
| 5609 |
|
|
href="#template0">template</a></code> element that is the root of a |
| 5610 |
|
|
shadow tree, then let <var title="">element</var> be the bound element |
| 5611 |
|
|
for that shadow tree, and return to the second step. |
| 5612 |
|
|
|
| 5613 |
|
|
<li>Otherwise, <var title="">parent</var> is the element to which the |
| 5614 |
|
|
animation element is assigned. |
| 5615 |
|
|
</ol> |
| 5616 |
|
|
|
| 5617 |
|
|
<p>Animation elements must be processed even when in shadow trees.</p> |
| 5618 |
|
|
|
| 5619 |
|
|
<div class=example> |
| 5620 |
|
|
<p>In the following example, the UA would render the string "Hello Cruel |
| 5621 |
|
|
World", while animating the colour of the entire string over six |
| 5622 |
|
|
seconds.</p> |
| 5623 |
|
|
|
| 5624 |
|
|
<pre><svg xmlns="http://www.w3.org/2000/svg"> |
| 5625 |
|
|
<defs> |
| 5626 |
|
|
<b:xbl xmlns:b="http://www.w3.org/ns/xbl"> |
| 5627 |
|
|
<b:binding <a href="#element" title=attr-binding-element>element="|world"</a>> |
| 5628 |
|
|
<b:template> |
| 5629 |
|
|
<tspan <a href="#xblattr0" title=attr-attr>b:attr</a>="<a href="#xbltext" title=xbl:text>b:text=data</a>"/> World |
| 5630 |
|
|
<animateColor attributeName="fill" from="rgb(0,0,255)" to="rgb(128,0,0)" begin="0s" dur="6s" fill="freeze" /> |
| 5631 |
|
|
</b:template> |
| 5632 |
|
|
</b:binding> |
| 5633 |
|
|
</b:xbl> |
| 5634 |
|
|
</defs> |
| 5635 |
|
|
<text y="50" font-size="12"> |
| 5636 |
|
|
Hello <world xmlns="" data="Cruel"/> |
| 5637 |
|
|
</text> |
| 5638 |
|
|
</svg></pre> |
| 5639 |
|
|
</div> |
| 5640 |
|
|
|
| 5641 |
|
|
<h3 id=binding3><span class=secno>4.10. </span><dfn id=binding22>Binding |
| 5642 |
|
|
Style Sheets</dfn></h3> |
| 5643 |
|
|
|
| 5644 |
|
|
<p>Shadow content nodes and bound elements are styled using style sheets |
| 5645 |
|
|
from a number of sources, depending on the values of certain attributes. |
| 5646 |
|
|
When multiple bindings are applied to the same bound element, the sheets |
| 5647 |
|
|
from each binding all contribute to the final set of style sheets to |
| 5648 |
|
|
apply, the style sheets of the <a href="#most-derived">most derived |
| 5649 |
|
|
binding</a> being walked first. For each binding, the style sheets that |
| 5650 |
|
|
apply are as follows, in the order given:</p> |
| 5651 |
|
|
|
| 5652 |
|
|
<p><em>Scoped style sheets:</em> A binding file can load style sheets |
| 5653 |
|
|
using the <code><a href="#style2">style</a></code> element. (See: <a |
| 5654 |
|
|
href="#loading7">loading style sheets</a>.) These style sheets must be |
| 5655 |
|
|
applied to the bound element and to all shadow content attached to the |
| 5656 |
|
|
bound element.</p> |
| 5657 |
|
|
|
| 5658 |
|
|
<p>If the binding was attached using CSS, the scoped style sheets have the |
| 5659 |
|
|
same CSS origin as the sheet with the rule responsible for the binding. |
| 5660 |
|
|
Style sheets used by bindings that are attached using the DOM or using |
| 5661 |
|
|
<code title=import><a href="#importing1"><?xbl?></a></code> are |
| 5662 |
|
|
treated as author-level sheets.</p> |
| 5663 |
|
|
|
| 5664 |
|
|
<p>When bindings from multiple levels are applied to the same bound |
| 5665 |
|
|
element, the style sheets that apply must cascade according to their own |
| 5666 |
|
|
levels.</p> |
| 5667 |
|
|
|
| 5668 |
|
|
<p class=example>An element E is attached to binding U from the user agent |
| 5669 |
|
|
style sheet, and binding A from the DOM, which places A in the author |
| 5670 |
|
|
level. When the style sheets that apply to E are sorted, U must be |
| 5671 |
|
|
applied at the UA level and A at the author level.</p> |
| 5672 |
|
|
|
| 5673 |
|
|
<p><em><a href="#author">Author style sheets</a></em>: While the <code |
| 5674 |
|
|
title=attr-template-apply-author-sheets><a |
| 5675 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> attribute on |
| 5676 |
|
|
the <code><a href="#template0">template</a></code> element found at the |
| 5677 |
|
|
root of the element's shadow tree is set to <code>true</code>, the rules |
| 5678 |
|
|
specified in any <a href="#author">author style sheets</a> at <a |
| 5679 |
|
|
href="#shadow9" title="shadow scope">outer shadow scopes</a> (including |
| 5680 |
|
|
those promoted to outer scopes using <code |
| 5681 |
|
|
title=attr-content-apply-binding-sheets><a |
| 5682 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code>, as defined |
| 5683 |
|
|
below) must be applied to the shadow content. Otherwise, only those |
| 5684 |
|
|
matched through <a href="#pseudo-list">predefined pseudo-elements</a> are |
| 5685 |
|
|
used, and other author-level sheets in higher shadow scopes must not be |
| 5686 |
|
|
applied to the shadow content. (The bound element is always styled using |
| 5687 |
|
|
the sheets of higher shadow scopes.)</p> |
| 5688 |
|
|
|
| 5689 |
|
|
<p>By default, style sheets specified in bindings (as described above) are |
| 5690 |
|
|
applied only to shadow content generated by bindings attached to the |
| 5691 |
|
|
bound element and to the bound element itself. A second attribute, <code |
| 5692 |
|
|
title=attr-content-apply-binding-sheets><a |
| 5693 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code>, can be used |
| 5694 |
|
|
to indicate that all descendants of the bound element, both shadow and |
| 5695 |
|
|
explicit, can be styled by the sheets in the binding's document. This can |
| 5696 |
|
|
be controlled on a per-insertion-point basis. While this attribute is set |
| 5697 |
|
|
to <code>true</code> on a <code><a href="#content0">content</a></code> |
| 5698 |
|
|
node in the shadow tree DOM, any nodes that are assigned to that element, |
| 5699 |
|
|
and any descendants of those nodes, must have the scoped style sheets of |
| 5700 |
|
|
the binding (those that apply to the shadow content as described above) |
| 5701 |
|
|
applied to them too, as if they had been promoted to the higher scope.</p> |
| 5702 |
|
|
|
| 5703 |
|
|
<p>Sheets within each origin are always walked from the innermost shadow |
| 5704 |
|
|
scope to the outermost shadow scope (with rules in the outermost shadow |
| 5705 |
|
|
scope therefore overriding rules of equal specificity in the innermost |
| 5706 |
|
|
shadow scope). With this ordering a binding that defines a widget can |
| 5707 |
|
|
define a default look for the widget that can then be easily overridden |
| 5708 |
|
|
by a client of the widget. For multiple bindings attached to the same |
| 5709 |
|
|
element, the sheets are walked from the <a href="#base-binding">base |
| 5710 |
|
|
binding</a> to the <a href="#most-derived">most derived binding</a>.</p> |
| 5711 |
|
|
|
| 5712 |
|
|
<p><em><a href="#user-agent">User agent style sheets</a> and <a |
| 5713 |
|
|
href="#user-style">user style sheets</a></em>: These are always applied |
| 5714 |
|
|
to all shadow scopes.</p> |
| 5715 |
|
|
|
| 5716 |
|
|
<p>Since styles from both author style sheets and binding style sheets are |
| 5717 |
|
|
applied to the bound element, it is possible for an infinite loop to form |
| 5718 |
|
|
where an author sets the '<code title="binding property"><a |
| 5719 |
|
|
href="#binding18">binding</a></code>' property to a particular binding |
| 5720 |
|
|
that then explicitly sets the '<code title="binding property"><a |
| 5721 |
|
|
href="#binding18">binding</a></code>' property to 'none' (or another |
| 5722 |
|
|
binding). This specification does not take any precautions to avoid this, |
| 5723 |
|
|
any more than it takes precautions to avoid loops caused by binding |
| 5724 |
|
|
constructors explicitly calling <code><a |
| 5725 |
|
|
href="#removebinding">removeBinding()</a></code> to remove the binding |
| 5726 |
|
|
itself and binding detachment event handlers reattaching the bindings. |
| 5727 |
|
|
Similar potential loops exist also in underlying technologies, for |
| 5728 |
|
|
example <code>:hover</code> rules that cause elements to no longer be |
| 5729 |
|
|
hovered, or focus event handlers that move focus to an element and blur |
| 5730 |
|
|
event handlers that move focus back to the element.</p> |
| 5731 |
|
|
|
| 5732 |
|
|
<p>In so far as XBL is concerned, authors must avoid constructing such |
| 5733 |
|
|
loops, and implementers must ensure that such loops do not prevent users |
| 5734 |
|
|
from interacting with the user agent.</p> |
| 5735 |
|
|
|
| 5736 |
|
|
<h4 id=styleSummary><span class=secno>4.10.1. </span>Summary of styling |
| 5737 |
|
|
rules</h4> |
| 5738 |
|
|
|
| 5739 |
|
|
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span></p> |
| 5740 |
|
|
|
| 5741 |
|
|
<p>The <code><style></code> is applied only to the bound element and |
| 5742 |
|
|
the shadow content that was generated by the binding. The |
| 5743 |
|
|
<code><style></code> is also applied to explicit children (and |
| 5744 |
|
|
their descendants) assigned to <code><content></code> elements |
| 5745 |
|
|
whose <code title=attr-content-apply-binding-sheets><a |
| 5746 |
|
|
href="#apply-binding-sheets">apply-binding-sheets</a></code> is set to |
| 5747 |
|
|
<code>true</code>.</p> |
| 5748 |
|
|
|
| 5749 |
|
|
<p>Continuing from the above, author sheets (styles from the bound |
| 5750 |
|
|
document) are applied to the shadow content only if <code |
| 5751 |
|
|
title=attr-template-apply-author-sheets><a |
| 5752 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> is set to true |
| 5753 |
|
|
for the <code><template></code>.</p> |
| 5754 |
|
|
|
| 5755 |
|
|
<p>Last, but not least, one can use author sheets to change the style of |
| 5756 |
|
|
elements in the shadow content that use the <code title=attr-pseudo><a |
| 5757 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attribute, as long as it matches |
| 5758 |
|
|
them with pseudo-elements (irrespective of the <code |
| 5759 |
|
|
title=attr-template-apply-author-sheets><a |
| 5760 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> setting).</p> |
| 5761 |
|
|
|
| 5762 |
|
|
<h2 id=binding4><span class=secno>5. </span><dfn id=binding23>Binding |
| 5763 |
|
|
Implementations</dfn></h2> |
| 5764 |
|
|
|
| 5765 |
|
|
<p>Bindings can define methods and properties on a bound element using the |
| 5766 |
|
|
<code><a href="#implementation0">implementation</a></code> element. A |
| 5767 |
|
|
binding implementation provides a new set of methods and properties that |
| 5768 |
|
|
can be invoked from the bound element.</p> |
| 5769 |
|
|
|
| 5770 |
|
|
<p>How the binding implementation is defined depends on the scripting |
| 5771 |
|
|
language used; the details for ECMAScript are defined below.</p> |
| 5772 |
|
|
|
| 5773 |
|
|
<p>In general, however, each binding has an object that implements the |
| 5774 |
|
|
<code><a href="#xblimplementation">XBLImplementation</a></code> |
| 5775 |
|
|
interface, along with any other interfaces that the implementation might |
| 5776 |
|
|
implement. This is the <em>implementation object</em> for that instance |
| 5777 |
|
|
of the binding. All elements implement the <code><a |
| 5778 |
|
|
href="#elementxbl">ElementXBL</a></code> interface, whose <code><a |
| 5779 |
|
|
href="#xblimplementations">xblImplementations</a></code> member returns |
| 5780 |
|
|
an object implementing <code><a |
| 5781 |
|
|
href="#xblimplementationlist">XBLImplementationList</a></code>. This |
| 5782 |
|
|
object lists all the implementation objects for that bound element. (If |
| 5783 |
|
|
the element is not a bound element, the list is empty.)</p> |
| 5784 |
|
|
|
| 5785 |
|
|
<h3 id=the-xblimplementation><span class=secno>5.1. </span>The <code><a |
| 5786 |
|
|
href="#xblimplementation">XBLImplementation</a></code> Interface</h3> |
| 5787 |
|
|
|
| 5788 |
|
|
<p>All implementation objects support the <code><a |
| 5789 |
|
|
href="#xblimplementation">XBLImplementation</a></code> interface (in |
| 5790 |
|
|
addition to any other interfaces specific to the binding). By |
| 5791 |
|
|
implementing the methods defined in this interface, bindings can be |
| 5792 |
|
|
notified of the binding's state with respect to its environment.</p> |
| 5793 |
|
|
|
| 5794 |
|
|
<pre |
| 5795 |
|
|
class=idl>interface <dfn id=xblimplementation>XBLImplementation</dfn> { |
| 5796 |
|
|
void <a href="#xblbindingattached">xblBindingAttached</a>(); |
| 5797 |
|
|
void <a href="#xblentereddocument">xblEnteredDocument</a>(); |
| 5798 |
|
|
void <a href="#xblleftdocument">xblLeftDocument</a>(); |
| 5799 |
|
|
};</pre> |
| 5800 |
|
|
|
| 5801 |
|
|
<p>The <dfn id=xblbindingattached><code>xblBindingAttached()</code></dfn> |
| 5802 |
|
|
method is called by the user agent after the binding has been attached. |
| 5803 |
|
|
(See: <a href="#binding19">binding attachment model</a>.)</p> |
| 5804 |
|
|
|
| 5805 |
|
|
<p>The <dfn id=xblentereddocument><code>xblEnteredDocument()</code></dfn> |
| 5806 |
|
|
method is called by the user agent in two cases:</p> |
| 5807 |
|
|
|
| 5808 |
|
|
<ul> |
| 5809 |
|
|
<li> When the bound element, or one of its ancestors, or one of the |
| 5810 |
|
|
elements in a higher shadow scope, is inserted into the document. |
| 5811 |
|
|
|
| 5812 |
|
|
<li> When the binding is originally attached, if the bound element is |
| 5813 |
|
|
already in the document. |
| 5814 |
|
|
</ul> |
| 5815 |
|
|
|
| 5816 |
|
|
<p>Thus, it can be used to perform initialization steps that depend upon |
| 5817 |
|
|
being in a document. (See: <a href="#binding19">binding attachment |
| 5818 |
|
|
model</a>, <a href="#handling3">handling insertion and removal from the |
| 5819 |
|
|
document</a>.)</p> |
| 5820 |
|
|
|
| 5821 |
|
|
<p>The <dfn id=xblleftdocument><code>xblLeftDocument()</code></dfn> method |
| 5822 |
|
|
is called by the user agent when the bound element, or one of its |
| 5823 |
|
|
ancestors, or one of the elements in a higher shadow scope, is removed |
| 5824 |
|
|
from the document. (See: <a href="#handling3">handling insertion and |
| 5825 |
|
|
removal from the document</a>.)</p> |
| 5826 |
|
|
|
| 5827 |
|
|
<p>If the <code><a href="#implementation0">implementation</a></code> does |
| 5828 |
|
|
not define one of these methods, then when that method is invoked, |
| 5829 |
|
|
nothing must happen (as if all bindings had default implementations of |
| 5830 |
|
|
those methods that were no-ops).</p> |
| 5831 |
|
|
<!-- XXX need a way to persist certain values --> |
| 5832 |
|
|
<p>Authors should not start their own methods with the three letters |
| 5833 |
|
|
"xbl". Future versions of this specification might add new callbacks to |
| 5834 |
|
|
this interface, and if they do, those methods will start with the prefix |
| 5835 |
|
|
"xbl".</p> |
| 5836 |
|
|
<!-- XXX more callbacks: |
| 5837 |
|
|
http://lxr.mozilla.org/seamonkey/source/content/xtf/public/nsIXTFStyledElementWrapper.idl |
| 5838 |
|
|
xblSelected to indicate that the selection now spans the element (glazou) |
| 5839 |
|
|
--> |
| 5840 |
|
|
|
| 5841 |
|
|
<div class=example> |
| 5842 |
|
|
<p>This binding implements a clock. However, to save resources, the clock |
| 5843 |
|
|
is only active when it is actually included in a document.</p> |
| 5844 |
|
|
|
| 5845 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 5846 |
|
|
<binding id="clock"> |
| 5847 |
|
|
<implementation> |
| 5848 |
|
|
({ |
| 5849 |
|
|
xblEnteredDocument: function () { |
| 5850 |
|
|
this.timer = setInterval(update, 1000); |
| 5851 |
|
|
}, |
| 5852 |
|
|
xblLeftDocument: function () { |
| 5853 |
|
|
clearInterval(this.timer); |
| 5854 |
|
|
}, |
| 5855 |
|
|
update: function () { |
| 5856 |
|
|
this.shadowTree.getElementById('clock-value').textContent = new Date(); |
| 5857 |
|
|
}, |
| 5858 |
|
|
}) |
| 5859 |
|
|
</implementation> |
| 5860 |
|
|
<template><div id="clock-value"></div></template> |
| 5861 |
|
|
</binding> |
| 5862 |
|
|
</xbl></pre> |
| 5863 |
|
|
</div> |
| 5864 |
|
|
|
| 5865 |
|
|
<h3 id=the-xblimplementationlist><span class=secno>5.2. </span>The |
| 5866 |
|
|
<code><a href="#xblimplementationlist">XBLImplementationList</a></code> |
| 5867 |
|
|
Interface</h3> |
| 5868 |
|
|
|
| 5869 |
|
|
<p>The <dfn id=xblimplementations><code>xblImplementations</code></dfn> |
| 5870 |
|
|
attribute on all elements must return an instance of an <code><a |
| 5871 |
|
|
href="#xblimplementationlist">XBLImplementationList</a></code> object |
| 5872 |
|
|
(the same object for the lifetime of the element), which is a live list |
| 5873 |
|
|
of the implementation objects provided by the bindings for that bound |
| 5874 |
|
|
element at any particular point in time.</p> |
| 5875 |
|
|
|
| 5876 |
|
|
<pre |
| 5877 |
|
|
class=idl>interface <dfn id=xblimplementationlist>XBLImplementationList</dfn> { |
| 5878 |
|
|
<a href="#xblimplementation">XBLImplementation</a> <a href="#itemn" title=XBLImplementationList-item>item</a>(in unsigned long index); |
| 5879 |
|
|
readonly attribute unsigned long <a href="#length" title=XBLImplementationList-length>length</a>; |
| 5880 |
|
|
};</pre> |
| 5881 |
|
|
|
| 5882 |
|
|
<p>The <dfn id=length |
| 5883 |
|
|
title=XBLImplementationList-length><code>length</code></dfn> attribute |
| 5884 |
|
|
must return the number of implementation objects associated with the |
| 5885 |
|
|
bound element, or zero if the element is not a bound element or has none |
| 5886 |
|
|
of its bindings have implementations.</p> |
| 5887 |
|
|
|
| 5888 |
|
|
<p>The <dfn id=itemn |
| 5889 |
|
|
title=XBLImplementationList-item><code>item(<var>n</var>)</code></dfn> |
| 5890 |
|
|
method must return the <var>n</var>th implementation object associated |
| 5891 |
|
|
with the bound element. If the index is not a number between zero and |
| 5892 |
|
|
<code title=XBLImplementationList-length><a |
| 5893 |
|
|
href="#length">length</a></code>-1 (inclusive), then the method must |
| 5894 |
|
|
raise an <code>INDEX_SIZE_ERR</code> DOM exception. <a |
| 5895 |
|
|
href="#refsDOM3CORE">[DOM3CORE]</a></p> |
| 5896 |
|
|
|
| 5897 |
|
|
<p>The list must be ordered such that the <a href="#most-derived">most |
| 5898 |
|
|
derived binding</a> is last, and the <a href="#base-binding">base |
| 5899 |
|
|
binding</a> has index zero.</p> |
| 5900 |
|
|
|
| 5901 |
|
|
<p>In ECMAScript implementations, objects that implement the <code><a |
| 5902 |
|
|
href="#xblimplementationlist">XBLImplementationList</a></code> interface |
| 5903 |
|
|
must also have a [[Get]] method that, when invoked with a property name |
| 5904 |
|
|
that is a number, acts like the <code title=XBLImplementationList-item><a |
| 5905 |
|
|
href="#itemn">item()</a></code> method would when invoked with that |
| 5906 |
|
|
argument.</p> |
| 5907 |
|
|
|
| 5908 |
|
|
<h3 id=accessing><span class=secno>5.3. </span>Accessing Binding |
| 5909 |
|
|
Implementations</h3> |
| 5910 |
|
|
|
| 5911 |
|
|
<p>Script can access binding implementations directly using the <code><a |
| 5912 |
|
|
href="#xblimplementations">xblImplementations</a></code> member. In |
| 5913 |
|
|
addition, in languages that support dynamic dispatch (such as |
| 5914 |
|
|
ECMAScript), any attempts to access members of <code><a |
| 5915 |
|
|
href="#elementxbl">ElementXBL</a></code> objects that do not correspond |
| 5916 |
|
|
to methods or properties on the object itself but do correspond to |
| 5917 |
|
|
members of one of the objects in the <code><a |
| 5918 |
|
|
href="#xblimplementations">xblImplementations</a></code> list must be |
| 5919 |
|
|
forwarded to the last object in the <code><a |
| 5920 |
|
|
href="#xblimplementations">xblImplementations</a></code> list that is so |
| 5921 |
|
|
matched.</p> |
| 5922 |
|
|
<!-- XXX example needed, including one that shows this with an |
| 5923 |
|
|
lvalue --> |
| 5924 |
|
|
|
| 5925 |
|
|
<h3 id=ecmascript><span class=secno>5.4. </span><dfn |
| 5926 |
|
|
id=ecmascript1>ECMAScript Bindings</dfn></h3> |
| 5927 |
|
|
|
| 5928 |
|
|
<p>When a binding is attached, the user agent must follow the following |
| 5929 |
|
|
steps to make the binding implementation available to scripts:</p> |
| 5930 |
|
|
|
| 5931 |
|
|
<ol> |
| 5932 |
|
|
<li> |
| 5933 |
|
|
<p>If this is the first time the binding defined by that <code><a |
| 5934 |
|
|
href="#binding16">binding</a></code> element is used since that binding |
| 5935 |
|
|
document was loaded, and if that element contains an <code><a |
| 5936 |
|
|
href="#implementation0">implementation</a></code> element, then:</p> |
| 5937 |
|
|
|
| 5938 |
|
|
<ol> |
| 5939 |
|
|
<li>The first <code><a |
| 5940 |
|
|
href="#implementation0">implementation</a></code> element child of the |
| 5941 |
|
|
<code><a href="#binding16">binding</a></code> element must have its |
| 5942 |
|
|
code <a href="#compiling1" title="Compiling ECMAScript |
| 5943 |
|
|
Bindings">compiled and run</a> (see below). |
| 5944 |
|
|
|
| 5945 |
|
|
<li>The return value of that script, if it is an object, must be |
| 5946 |
|
|
forever associated with that <code><a |
| 5947 |
|
|
href="#binding16">binding</a></code> element as that binding's |
| 5948 |
|
|
<em>implementation prototype object</em>. |
| 5949 |
|
|
</ol> |
| 5950 |
|
|
|
| 5951 |
|
|
<p>Otherwise, if the <code><a href="#binding16">binding</a></code> |
| 5952 |
|
|
element doesn't contain an <code><a |
| 5953 |
|
|
href="#implementation0">implementation</a></code> element, or if it |
| 5954 |
|
|
does but it does not evaluate to an object, then an empty object must |
| 5955 |
|
|
be created (by invoking the <code>Object</code> constructor in the |
| 5956 |
|
|
global scope of the binding document), and the <code><a |
| 5957 |
|
|
href="#binding16">binding</a></code> element's implementation prototype |
| 5958 |
|
|
object must be forever set to that object.</p> |
| 5959 |
|
|
|
| 5960 |
|
|
<p class=note>Any further changes to <code><a |
| 5961 |
|
|
href="#implementation0">implementation</a></code> elements will have no |
| 5962 |
|
|
effect on the implementation prototype object of this particular |
| 5963 |
|
|
binding.</p> |
| 5964 |
|
|
|
| 5965 |
|
|
<li> |
| 5966 |
|
|
<p>Next, the UA must create two new ECMAScript objects by invoking the |
| 5967 |
|
|
<code>Object</code> constructor in the global scope of the binding |
| 5968 |
|
|
document. These objects are the <dfn id=internal>internal object</dfn> |
| 5969 |
|
|
and the <dfn id=external0>external object</dfn>.</p> |
| 5970 |
|
|
|
| 5971 |
|
|
<li> |
| 5972 |
|
|
<p>The [[Prototype]] property of the internal object must be set to the |
| 5973 |
|
|
external object, and the [[Prototype]] property of the external object |
| 5974 |
|
|
must be set to the binding's implementation prototype object.</p> |
| 5975 |
|
|
|
| 5976 |
|
|
<li> |
| 5977 |
|
|
<p>The internal object must then have the following fields defined:</p> |
| 5978 |
|
|
|
| 5979 |
|
|
<dl> |
| 5980 |
|
|
<dt><dfn id=external1><code>external</code></dfn> |
| 5981 |
|
|
|
| 5982 |
|
|
<dd>This field's value must be set to a reference to the external |
| 5983 |
|
|
object. |
| 5984 |
|
|
|
| 5985 |
|
|
<dt><dfn id=boundelement><code>boundElement</code></dfn> |
| 5986 |
|
|
|
| 5987 |
|
|
<dd>This field's value must be set to a reference of the node object |
| 5988 |
|
|
that is the bound element. |
| 5989 |
|
|
|
| 5990 |
|
|
<dt><dfn id=shadowtree><code>shadowTree</code></dfn> |
| 5991 |
|
|
|
| 5992 |
|
|
<dd>This field's value must be initially set to null. Its value is |
| 5993 |
|
|
changed during <a href="#rules3" title="Rules for Shadow Content |
| 5994 |
|
|
Generation">shadow content generation</a> and <a href="#rules4" |
| 5995 |
|
|
title="Rules for Shadow Content Destruction">destruction</a>. |
| 5996 |
|
|
|
| 5997 |
|
|
<dt><dfn id=basebinding><code>baseBinding</code></dfn> |
| 5998 |
|
|
|
| 5999 |
|
|
<dd>If the binding's <code title=attr-binding-extends><a |
| 6000 |
|
|
href="#extends">extends</a></code> attribute caused another binding to |
| 6001 |
|
|
be attached to the bound element, then the <code><a |
| 6002 |
|
|
href="#basebinding">baseBinding</a></code> field's value must be set |
| 6003 |
|
|
to a reference of that binding's implementation object, if it has one |
| 6004 |
|
|
(if that is an ECMAScript implementation as well, then that is that |
| 6005 |
|
|
binding's external object). Otherwise, it must be set to the value |
| 6006 |
|
|
null. |
| 6007 |
|
|
</dl> |
| 6008 |
|
|
</ol> |
| 6009 |
|
|
|
| 6010 |
|
|
<p>Conceptually, the internal and external objects together make the |
| 6011 |
|
|
implementation object, but as far as the <code><a |
| 6012 |
|
|
href="#xblimplementations">xblImplementations</a></code> property's list |
| 6013 |
|
|
is concerned, the external object is the one that is returned as the |
| 6014 |
|
|
implementation object.</p> |
| 6015 |
|
|
|
| 6016 |
|
|
<h4 id=compiling><span class=secno>5.4.1. </span><dfn |
| 6017 |
|
|
id=compiling1>Compiling ECMAScript Bindings</dfn></h4> |
| 6018 |
|
|
|
| 6019 |
|
|
<p>When the user agent has to compile and run an XBL binding ECMAScript |
| 6020 |
|
|
implementation, it must first obtain the script itself in the manner |
| 6021 |
|
|
described in the section on <a href="#loading6">loading and running |
| 6022 |
|
|
scripts</a>, and must then compile and execute the script using the |
| 6023 |
|
|
binding document's global scope.</p> |
| 6024 |
|
|
|
| 6025 |
|
|
<p>If the script evaluates to an object, then that is the |
| 6026 |
|
|
<em>implementation prototype object</em>. Otherwise, there isn't one.</p> |
| 6027 |
|
|
|
| 6028 |
|
|
<h4 id=invoking><span class=secno>5.4.2. </span>Invoking Methods on an |
| 6029 |
|
|
ECMAScript Implementation Object</h4> |
| 6030 |
|
|
|
| 6031 |
|
|
<p>When function code of an implementation object implemented in |
| 6032 |
|
|
ECMAScript is called, the user agent must set the <code>this</code> value |
| 6033 |
|
|
to the <a href="#internal">internal object</a> associated with the <a |
| 6034 |
|
|
href="#external0">external object</a> on which the function was invoked.</p> |
| 6035 |
|
|
|
| 6036 |
|
|
<h2 id=event0><span class=secno>6. </span><dfn id=event11>Event |
| 6037 |
|
|
Handlers</dfn></h2> |
| 6038 |
|
|
|
| 6039 |
|
|
<h3 id=event1><span class=secno>6.1. </span><dfn id=event12>Event |
| 6040 |
|
|
Forwarding</dfn></h3> |
| 6041 |
|
|
|
| 6042 |
|
|
<p>Whenever an event passes through a bound element, whether during the |
| 6043 |
|
|
capture, target, bubble, or <a href="#the-default1" title="default |
| 6044 |
|
|
phase">default</a> phases, the user agent must also invoke any |
| 6045 |
|
|
appropriate event listeners attached to the binding's first <code><a |
| 6046 |
|
|
href="#handlers0">handlers</a></code> element.</p> |
| 6047 |
|
|
|
| 6048 |
|
|
<p>When events are forwarded in this manner, the event handlers attached |
| 6049 |
|
|
to the <code><a href="#handlers0">handlers</a></code> element must fire |
| 6050 |
|
|
after any event handlers on the bound element itself in the capture |
| 6051 |
|
|
phase, after the event has been retargeted to shadow nodes, if |
| 6052 |
|
|
appropriate; and before any event handlers on the bound element itself in |
| 6053 |
|
|
the target and bubble phases, before the event has been retargeted to the |
| 6054 |
|
|
bound element, if appropriate. (See: <a href="#event13">event flow and |
| 6055 |
|
|
targeting across shadow scopes</a>.)</p> |
| 6056 |
|
|
|
| 6057 |
|
|
<p>Event handlers must fire first on the <a href="#most-derived">most |
| 6058 |
|
|
derived binding</a> and then on its inherited binding, continuing all the |
| 6059 |
|
|
way up the chains to the <a href="#base-binding">base binding</a>. A |
| 6060 |
|
|
derived handler then has a way of preventing the event from flowing to |
| 6061 |
|
|
the handlers of the bindings it inherits from, by using the |
| 6062 |
|
|
<code>stopImmediatePropagation()</code> method.</p> |
| 6063 |
|
|
|
| 6064 |
|
|
<p>Event handlers may be attached to the <code><a |
| 6065 |
|
|
href="#handlers0">handlers</a></code> element using any method, including |
| 6066 |
|
|
DOM3 Events' <code>addEventListener()</code> method and the <code><a |
| 6067 |
|
|
href="#handler0">handler</a></code> XBL element. All event handlers |
| 6068 |
|
|
registered on the first <code><a href="#handlers0">handlers</a></code> |
| 6069 |
|
|
element of the binding are considered, not just those attached using the |
| 6070 |
|
|
<code><a href="#handler0">handler</a></code> element.</p> |
| 6071 |
|
|
|
| 6072 |
|
|
<div class=example> |
| 6073 |
|
|
<p>In the following example, the bound element is the |
| 6074 |
|
|
<code>hotspot</code> element. When either it is clicked or the element |
| 6075 |
|
|
inside it is clicked, an alert is generated containing the text "Hello |
| 6076 |
|
|
World".</p> |
| 6077 |
|
|
|
| 6078 |
|
|
<p>The bound document is:</p> |
| 6079 |
|
|
|
| 6080 |
|
|
<pre><hotspot message="Hello World"> |
| 6081 |
|
|
<instruction> Activate this text. </instruction> |
| 6082 |
|
|
</hotspot></pre> |
| 6083 |
|
|
|
| 6084 |
|
|
<p>The binding is:</p> |
| 6085 |
|
|
|
| 6086 |
|
|
<pre><binding> |
| 6087 |
|
|
<handlers> |
| 6088 |
|
|
<handler event="click"> |
| 6089 |
|
|
alert(event.currentTarget.getAttribute('message')); |
| 6090 |
|
|
</handler> |
| 6091 |
|
|
</handlers> |
| 6092 |
|
|
</binding></pre> |
| 6093 |
|
|
|
| 6094 |
|
|
<p>Note that the event object passed to the <code><a |
| 6095 |
|
|
href="#handlers0">handlers</a></code>'s handlers is the same as would |
| 6096 |
|
|
have been passed to event handlers registered directly on the bound |
| 6097 |
|
|
element. This is why <code>currentTarget</code> in this example points |
| 6098 |
|
|
to the bound element.</p> |
| 6099 |
|
|
</div> |
| 6100 |
|
|
|
| 6101 |
|
|
<h3 id=registering><span class=secno>6.2. </span><dfn |
| 6102 |
|
|
id=registering1>Registering Event Handlers with the <code>handler</code> |
| 6103 |
|
|
Element</dfn></h3> |
| 6104 |
|
|
|
| 6105 |
|
|
<p>Whenever the <code>event</code> or <code>phase</code> attributes of an |
| 6106 |
|
|
XBL <code><a href="#handler0">handler</a></code> element change, or |
| 6107 |
|
|
whenever a <code><a href="#handler0">handler</a></code> element's parent |
| 6108 |
|
|
changes, an event listener must be registered on the element's parent |
| 6109 |
|
|
element, if it has one; and if an event listener had previously been |
| 6110 |
|
|
registered for that <code><a href="#handler0">handler</a></code> element, |
| 6111 |
|
|
it must be removed.</p> |
| 6112 |
|
|
|
| 6113 |
|
|
<p>In terms of the DOM3 Events <code>addEventListenerNS()</code> method, |
| 6114 |
|
|
the arguments used when registering the new event listener must be set as |
| 6115 |
|
|
follows:</p> |
| 6116 |
|
|
|
| 6117 |
|
|
<dl> |
| 6118 |
|
|
<dt><code>namespaceURI</code> |
| 6119 |
|
|
|
| 6120 |
|
|
<dd>Always <code>null</code> in this version of XBL. |
| 6121 |
|
|
|
| 6122 |
|
|
<dt><code>type</code> |
| 6123 |
|
|
|
| 6124 |
|
|
<dd>The literal value of the <code title=attr-handler-event><a |
| 6125 |
|
|
href="#event9">event</a></code> attribute, or the empty string if the |
| 6126 |
|
|
attribute is missing. |
| 6127 |
|
|
|
| 6128 |
|
|
<dt><code>listener</code> |
| 6129 |
|
|
|
| 6130 |
|
|
<dd>An object implementing the <code>EventListener</code> interface that |
| 6131 |
|
|
invokes the <code><a href="#handler0">handler</a></code> element as |
| 6132 |
|
|
described below. |
| 6133 |
|
|
|
| 6134 |
|
|
<dt><code>useCapture</code> |
| 6135 |
|
|
|
| 6136 |
|
|
<dd>True if the <code title=attr-handler-phase><a |
| 6137 |
|
|
href="#phase">phase</a></code> attribute is present and has the literal |
| 6138 |
|
|
value <code>capture</code>, otherwise false. |
| 6139 |
|
|
|
| 6140 |
|
|
<dt><code>evtGroup</code> |
| 6141 |
|
|
|
| 6142 |
|
|
<dd>Always <code>null</code> in this version of XBL. (Event listeners |
| 6143 |
|
|
registered with <code><a href="#handler0">handler</a></code> elements |
| 6144 |
|
|
are registered in the default event group.) |
| 6145 |
|
|
</dl> |
| 6146 |
|
|
|
| 6147 |
|
|
<p>Thus, the <code title=attr-handler-event><a |
| 6148 |
|
|
href="#event9">event</a></code> attribute specifies the event type, and |
| 6149 |
|
|
the <code title=attr-handler-phase><a href="#phase">phase</a></code> |
| 6150 |
|
|
attribute the listener type. If the <code title=attr-handler-event><a |
| 6151 |
|
|
href="#event9">event</a></code> attribute is missing or its value is the |
| 6152 |
|
|
empty string, it is <a href="#in-error">in error</a>. If the <code |
| 6153 |
|
|
title=attr-handler-phase><a href="#phase">phase</a></code> attribute is |
| 6154 |
|
|
present but has a value other than the literal strings |
| 6155 |
|
|
<code>capture</code>, <code>target</code>, <code>bubble</code>, or |
| 6156 |
|
|
<code>default-action</code>, it is <a href="#in-error">in error</a>. |
| 6157 |
|
|
(However, their being <a href="#in-error">in error</a> does not affect |
| 6158 |
|
|
the processing model described above.)</p> |
| 6159 |
|
|
|
| 6160 |
|
|
<p>When a <code><a href="#handler0">handler</a></code> element is invoked |
| 6161 |
|
|
by the object passed to the <code>addEventListenerNS()</code> method, the |
| 6162 |
|
|
user agent must check that the event in question was forwarded to a |
| 6163 |
|
|
<code><a href="#handlers0">handlers</a></code> element from a bound |
| 6164 |
|
|
element, and that that <code><a href="#handlers0">handlers</a></code> |
| 6165 |
|
|
element is the parent node of the <code><a |
| 6166 |
|
|
href="#handler0">handler</a></code> element.</p> |
| 6167 |
|
|
|
| 6168 |
|
|
<p>If that isn't the case, then the invocation must do nothing.</p> |
| 6169 |
|
|
|
| 6170 |
|
|
<p>Otherwise, if that condition <em>is</em> met, then the UA must check |
| 6171 |
|
|
any relevant filters specified on the <code><a |
| 6172 |
|
|
href="#handler0">handler</a></code> element. If any of them fail to match |
| 6173 |
|
|
the event, then the invocation must not do anything else. (The filter |
| 6174 |
|
|
attributes are defined in the next few sections.)</p> |
| 6175 |
|
|
|
| 6176 |
|
|
<p>Otherwise, if all the filters match, then the user agent must execute |
| 6177 |
|
|
the contents of the <code><a href="#handler0">handler</a></code> element, |
| 6178 |
|
|
treating it as being in the language specified by the <code |
| 6179 |
|
|
title=attr-xbl-script-type><a href="#script-type">script-type</a></code> |
| 6180 |
|
|
attribute. (See: <a href="#loading6">loading and running scripts</a>, <a |
| 6181 |
|
|
href="#event14">event handlers implemented in ECMAScript</a>.) The script |
| 6182 |
|
|
must be run in the context of the binding document (and not, e.g., in the |
| 6183 |
|
|
bound document's context).</p> |
| 6184 |
|
|
|
| 6185 |
|
|
<p>The <code title=attr-handler-propagate><a |
| 6186 |
|
|
href="#propagate">propagate</a></code> attribute specifies whether, after |
| 6187 |
|
|
processing all listeners at the current node, the event is allowed to |
| 6188 |
|
|
continue on its path (either in the capture or the bubble phase). The |
| 6189 |
|
|
possible values are <code>stop</code> and <code>continue</code> (the |
| 6190 |
|
|
default). If <code>stop</code> is specified, then after the event handler |
| 6191 |
|
|
has been fired, the event's <code>stopPropagation()</code> method must be |
| 6192 |
|
|
called.</p> |
| 6193 |
|
|
|
| 6194 |
|
|
<p>The <code title=attr-handler-default-action><a |
| 6195 |
|
|
href="#default-action">default-action</a></code> attribute specifies |
| 6196 |
|
|
whether, after processing of all listeners for the event, the default |
| 6197 |
|
|
action for the event (if any) should be performed or not. For instance, |
| 6198 |
|
|
in XHTML the default action for a mouse click on an <code>html:a</code> |
| 6199 |
|
|
element or one of its descendants is to traverse the link. The possible |
| 6200 |
|
|
values are <code>cancel</code> and <code>perform</code> (the default). If |
| 6201 |
|
|
<code>cancel</code> is specified, then after the event handler has been |
| 6202 |
|
|
fired, the event's <code>preventDefault()</code> method must be called.</p> |
| 6203 |
|
|
|
| 6204 |
|
|
<p>The <code title=attr-handler-trusted><a |
| 6205 |
|
|
href="#trusted">trusted</a></code> attribute is a filter that, if set to |
| 6206 |
|
|
the value <code>true</code>, matches only events whose <code |
| 6207 |
|
|
title=event-trusted><a href="#trusted0">trusted</a></code> attribute is |
| 6208 |
|
|
true. Otherwise, if it has another value or if it is not specified, any |
| 6209 |
|
|
event matches this filter. This filter can be used regardless of the type |
| 6210 |
|
|
of the event.</p> |
| 6211 |
|
|
|
| 6212 |
|
|
<p>The <code title=attr-handler-phase><a href="#phase">phase</a></code> |
| 6213 |
|
|
attribute is a filter that matches only events that are in the phase it |
| 6214 |
|
|
specifies. If the attribute has the value <code>capture</code>, it must |
| 6215 |
|
|
only match events whose <code>eventPhase</code> attribute has the value |
| 6216 |
|
|
<code>CAPTURING_PHASE</code> (1). If the attribute has the value |
| 6217 |
|
|
<code>target</code>, it must only match events whose |
| 6218 |
|
|
<code>eventPhase</code> attribute has the value <code>AT_TARGET</code> |
| 6219 |
|
|
(2). If the attribute has the value <code>default-action</code>, it must |
| 6220 |
|
|
only match events whose <code>eventPhase</code> attribute has the value |
| 6221 |
|
|
0x78626C44 <!-- |
| 6222 |
|
|
"xblD" in ASCII --> (2019716164). This is the value |
| 6223 |
|
|
used in the <a href="#the-default1">default phase</a>. If it is specified |
| 6224 |
|
|
and has another value, it must only match events whose |
| 6225 |
|
|
<code>eventPhase</code> attribute has the value <code>BUBBLE_PHASE</code> |
| 6226 |
|
|
(3). If it is not specified, it must only match events whose |
| 6227 |
|
|
<code>eventPhase</code> attribute has the value <code>AT_TARGET</code> |
| 6228 |
|
|
(2) or <code>BUBBLE_PHASE</code> (3). (If it isn't specified, then it |
| 6229 |
|
|
isn't registered as a capture event listener, so the handler would never |
| 6230 |
|
|
see the value <code>CAPTURING_PHASE</code> (1).) This filter can be used |
| 6231 |
|
|
regardless of the type of the event.</p> |
| 6232 |
|
|
|
| 6233 |
|
|
<p>In addition to the <code title=attr-handler-trusted><a |
| 6234 |
|
|
href="#trusted">trusted</a></code> and <code title=attr-handler-phase><a |
| 6235 |
|
|
href="#phase">phase</a></code> filters, event-specific filters may be |
| 6236 |
|
|
used, as described in the following sections. Only filters appropriate to |
| 6237 |
|
|
the given event type may be used; all other filter attributes, if |
| 6238 |
|
|
specified, are <a href="#in-error">in error</a> and UAs must <a |
| 6239 |
|
|
href="#ignoring">ignore</a> them.</p> |
| 6240 |
|
|
|
| 6241 |
|
|
<h3 id=mouse><span class=secno>6.3. </span><dfn id=mouse1>Mouse Event |
| 6242 |
|
|
Handler Filters</dfn></h3> |
| 6243 |
|
|
|
| 6244 |
|
|
<p>For events that use or derive from the <code>MouseEvent</code> |
| 6245 |
|
|
interface, three event-specific filter attributes may be used. <a |
| 6246 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 6247 |
|
|
|
| 6248 |
|
|
<p>The filters are:</p> |
| 6249 |
|
|
|
| 6250 |
|
|
<dl> |
| 6251 |
|
|
<dt><code title=attr-handler-button><a href="#button">button</a></code> |
| 6252 |
|
|
|
| 6253 |
|
|
<dd>A list of values, at least one of which has to match the |
| 6254 |
|
|
<code>button</code> attribute on the event object for the XBL event |
| 6255 |
|
|
handler to fire. If the attribute is not specified, then any value of |
| 6256 |
|
|
the <code>button</code> attribute on the event object must be considered |
| 6257 |
|
|
a match. If the value is specified, it must be a <a |
| 6258 |
|
|
href="#attributes22">space-separated</a> list of values, each of which |
| 6259 |
|
|
must be one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 |
| 6260 |
|
|
DIGIT NINE (9). Each string must be interpreted as a base ten integer |
| 6261 |
|
|
and then compared to the value of the <code>button</code> attribute on |
| 6262 |
|
|
the event object. If none of the values match the <code>button</code> |
| 6263 |
|
|
attribute, then the event handler must not be executed. |
| 6264 |
|
|
|
| 6265 |
|
|
<dt><code title=attr-handler-click-count><a |
| 6266 |
|
|
href="#click-count">click-count</a></code> |
| 6267 |
|
|
|
| 6268 |
|
|
<dd>A list of values, at least one of which has to match the |
| 6269 |
|
|
<code>detail</code> attribute on the event object for the XBL event |
| 6270 |
|
|
handler to fire. If the attribute is not specified, then any value of |
| 6271 |
|
|
the <code>detail</code> attribute on the event object must be considered |
| 6272 |
|
|
a match. If the value is specified, it must be a <a |
| 6273 |
|
|
href="#attributes22">space-separated</a> list of values, each of which |
| 6274 |
|
|
must be one or more digits in the range U+0030 DIGIT ZERO (0) to U+0039 |
| 6275 |
|
|
DIGIT NINE (9). Each string must be interpreted as a base ten integer |
| 6276 |
|
|
and then compared to the value of the <code>detail</code> attribute on |
| 6277 |
|
|
the event object. If none of the values match the <code>detail</code> |
| 6278 |
|
|
attribute, then the event handler must not be executed. Note that this |
| 6279 |
|
|
is checked for <em>any</em> event that uses the <code>MouseEvent</code> |
| 6280 |
|
|
interface, not just those for which <code>detail</code> is defined. |
| 6281 |
|
|
Authors should take care to not specify this attribute with, for |
| 6282 |
|
|
example, <code>mouseover</code> events, since in that context |
| 6283 |
|
|
<code>detail</code> is undefined. |
| 6284 |
|
|
|
| 6285 |
|
|
<dt><code title=attr-handler-modifiers><a |
| 6286 |
|
|
href="#modifiers1">modifiers</a></code> |
| 6287 |
|
|
|
| 6288 |
|
|
<dd>See <a href="#modifiers2">modifiers</a>. |
| 6289 |
|
|
</dl> |
| 6290 |
|
|
|
| 6291 |
|
|
<h3 id=key-event><span class=secno>6.4. </span><dfn id=key-event1>Key |
| 6292 |
|
|
Event Handler Filters</dfn></h3> |
| 6293 |
|
|
|
| 6294 |
|
|
<p>For events that use or derive from the <code>KeyboardEvent</code> |
| 6295 |
|
|
interface, three event-specific filter attributes may be used. <a |
| 6296 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 6297 |
|
|
|
| 6298 |
|
|
<p>The filters are:</p> |
| 6299 |
|
|
|
| 6300 |
|
|
<dl> |
| 6301 |
|
|
<dt><code title=attr-handler-key><a href="#key">key</a></code> |
| 6302 |
|
|
|
| 6303 |
|
|
<dd>The key identifier. If specified, the value must be an exact literal |
| 6304 |
|
|
match of the <code>keyIdentifier</code> attribute of the event object. |
| 6305 |
|
|
For example, <code>Enter</code>. If this filter is specified but the |
| 6306 |
|
|
<code title=attr-handler-modifiers><a |
| 6307 |
|
|
href="#modifiers1">modifiers</a></code> attribute is not, the user agent |
| 6308 |
|
|
must act as if the <code title=attr-handler-modifiers><a |
| 6309 |
|
|
href="#modifiers1">modifiers</a></code> attribute had been set with the |
| 6310 |
|
|
value "<code>none</code>". If specified, the value of this attribute |
| 6311 |
|
|
must be a valid value of the <code>keyIdentifier</code> attribute. |
| 6312 |
|
|
|
| 6313 |
|
|
<dt><code title=attr-handler-key-location><a |
| 6314 |
|
|
href="#key-location">key-location</a></code> |
| 6315 |
|
|
|
| 6316 |
|
|
<dd>If specified, this attribute's value must be a <a |
| 6317 |
|
|
href="#attributes22">space-separated</a> list of values from the four |
| 6318 |
|
|
literal (case-sensitive) keywords <code>standard</code>, |
| 6319 |
|
|
<code>left</code>, <code>right</code>, and <code>numpad</code> (with no |
| 6320 |
|
|
duplicates), which map to the DOM values 0x00, 0x01, 0x02, or 0x03 |
| 6321 |
|
|
respectively. If specified, the event object's <code>keyLocation</code> |
| 6322 |
|
|
attribute must have a value equal to the numeric value of one of the |
| 6323 |
|
|
specified keywords. Unknown and duplicate values are <a |
| 6324 |
|
|
href="#in-error">in error</a> and UAs must <a |
| 6325 |
|
|
href="#ignoring">ignore</a> them (although without dropping any <a |
| 6326 |
|
|
href="#correct">correct</a> values). |
| 6327 |
|
|
|
| 6328 |
|
|
<dt><code title=attr-handler-modifiers><a |
| 6329 |
|
|
href="#modifiers1">modifiers</a></code> |
| 6330 |
|
|
|
| 6331 |
|
|
<dd>See <a href="#modifiers2">modifiers</a>. |
| 6332 |
|
|
</dl> |
| 6333 |
|
|
|
| 6334 |
|
|
<h3 id=text-input><span class=secno>6.5. </span><dfn id=text-input1>Text |
| 6335 |
|
|
Input Event Handler Filters</dfn></h3> |
| 6336 |
|
|
|
| 6337 |
|
|
<p>For events that use or derive from the <code>TextEvent</code> |
| 6338 |
|
|
interface, one event-specific filter attribute may be used. <a |
| 6339 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 6340 |
|
|
|
| 6341 |
|
|
<p>The filter is:</p> |
| 6342 |
|
|
|
| 6343 |
|
|
<dl> |
| 6344 |
|
|
<dt><code title=attr-handler-text><a href="#text">text</a></code> |
| 6345 |
|
|
|
| 6346 |
|
|
<dd>The text data to match. If specified, the value must be an exact |
| 6347 |
|
|
literal match of the <code>data</code> attribute of the event object. |
| 6348 |
|
|
The value of the attribute may be any string. |
| 6349 |
|
|
</dl> |
| 6350 |
|
|
|
| 6351 |
|
|
<h3 id=mutation><span class=secno>6.6. </span><dfn id=mutation1>Mutation |
| 6352 |
|
|
Event Handler Filters</dfn></h3> |
| 6353 |
|
|
|
| 6354 |
|
|
<p>For events that use or derive from the <code>MutationEvent</code> |
| 6355 |
|
|
interface, four event-specific filter attributes may be used. <a |
| 6356 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 6357 |
|
|
|
| 6358 |
|
|
<p>The filters are:</p> |
| 6359 |
|
|
|
| 6360 |
|
|
<dl> |
| 6361 |
|
|
<dt><code title=attr-handler-prev-value><a |
| 6362 |
|
|
href="#prev-value">prev-value</a></code> |
| 6363 |
|
|
|
| 6364 |
|
|
<dd>If specified, the value must be an exact literal match of the |
| 6365 |
|
|
<code>prevValue</code> attribute of the event object. The value of the |
| 6366 |
|
|
attribute may be any string. |
| 6367 |
|
|
|
| 6368 |
|
|
<dt><code title=attr-handler-new-value><a |
| 6369 |
|
|
href="#new-value">new-value</a></code> |
| 6370 |
|
|
|
| 6371 |
|
|
<dd>If specified, the value must be an exact literal match of the |
| 6372 |
|
|
<code>newValue</code> attribute of the event object. The value of the |
| 6373 |
|
|
attribute may be any string. |
| 6374 |
|
|
|
| 6375 |
|
|
<dt><code title=attr-handler-attr-name><a |
| 6376 |
|
|
href="#attr-name">attr-name</a></code> |
| 6377 |
|
|
|
| 6378 |
|
|
<dd>If specified, the value must be an exact literal match of the |
| 6379 |
|
|
<code>attrName</code> attribute of the event object. The value of the |
| 6380 |
|
|
attribute may be any string. |
| 6381 |
|
|
|
| 6382 |
|
|
<dt><code title=attr-handler-attr-change><a |
| 6383 |
|
|
href="#attr-change">attr-change</a></code> |
| 6384 |
|
|
|
| 6385 |
|
|
<dd>If specified, this attribute's value must be a <a |
| 6386 |
|
|
href="#attributes22">space-separated</a> list of values from the three |
| 6387 |
|
|
literal (case-sensitive) keywords <code>modification</code>, |
| 6388 |
|
|
<code>addition</code>, <code>removal</code> (with no duplicates), which |
| 6389 |
|
|
map to the DOM values 0x00, 0x01, or 0x02 respectively. If specified, |
| 6390 |
|
|
the event object's <code>attrChange</code> attribute must have a value |
| 6391 |
|
|
equal to the numeric value of one of the specified keywords. Unknown and |
| 6392 |
|
|
duplicate values are <a href="#in-error">in error</a> and the UA must <a |
| 6393 |
|
|
href="#ignoring">ignore</a> them, although without causing <a |
| 6394 |
|
|
href="#correct">correct</a> values to be dropped. |
| 6395 |
|
|
</dl> |
| 6396 |
|
|
|
| 6397 |
|
|
<p>There are currently no attributes specifically designed to be used with |
| 6398 |
|
|
events that use the <code>MutationEventName</code> interface.</p> |
| 6399 |
|
|
|
| 6400 |
|
|
<h3 id=modifiers><span class=secno>6.7. </span><dfn |
| 6401 |
|
|
id=modifiers2>Modifiers</dfn></h3> |
| 6402 |
|
|
|
| 6403 |
|
|
<p>The <code title=attr-handler-modifiers><a |
| 6404 |
|
|
href="#modifiers1">modifiers</a></code> attribute specifies a filter |
| 6405 |
|
|
dependent on which keyboard accelerator keys ("modifiers") are set.</p> |
| 6406 |
|
|
|
| 6407 |
|
|
<p>The attribute is a <a href="#attributes22">space-separated</a> list of |
| 6408 |
|
|
values.</p> |
| 6409 |
|
|
|
| 6410 |
|
|
<p>To process this filter, the user agent must first invoke the |
| 6411 |
|
|
<code>getModifierState()</code> method of the event for all the modifiers |
| 6412 |
|
|
the UA supports, noting the return value for each modifier. The user |
| 6413 |
|
|
agent must then walk through all the values in the <code |
| 6414 |
|
|
title=attr-handler-modifiers><a href="#modifiers1">modifiers</a></code> |
| 6415 |
|
|
attribute, as described in the list below. The filter matches if all the |
| 6416 |
|
|
modifiers that returned true are accounted for, and none of the values |
| 6417 |
|
|
made the filter fail.</p> |
| 6418 |
|
|
|
| 6419 |
|
|
<p class=note>The <code>getModifierState()</code> method, and the |
| 6420 |
|
|
modifiers that go with it, are defined in DOM3 Events. <a |
| 6421 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 6422 |
|
|
|
| 6423 |
|
|
<p>By default, only the <code>CapsLock</code>, <code>NumLock</code>, and |
| 6424 |
|
|
<code>Scroll</code> modifiers are accounted for. Values on the attribute |
| 6425 |
|
|
cause other modifiers to be accounted for.</p> |
| 6426 |
|
|
|
| 6427 |
|
|
<p>Before comparing the modifiers to the attribute values, the user agent |
| 6428 |
|
|
must convert all the modifiers to lowercase.</p> |
| 6429 |
|
|
|
| 6430 |
|
|
<p>User agents must recognize the <code>accel</code> keyword as a synonym |
| 6431 |
|
|
for the modifier that is the primary accelerator key on the platform (on |
| 6432 |
|
|
Windows, this would typically be <code>control</code>, on Mac it would |
| 6433 |
|
|
typically be <code>meta</code>).</p> |
| 6434 |
|
|
|
| 6435 |
|
|
<p>User agents must also recognize the <code>access</code> keyword as a |
| 6436 |
|
|
synonym for the primary shortcut mnemonic key on the platform (on |
| 6437 |
|
|
Windows, this would typically be <code>alt</code>).</p> |
| 6438 |
|
|
|
| 6439 |
|
|
<p>The attribute values must be handled as follows:</p> |
| 6440 |
|
|
|
| 6441 |
|
|
<dl> |
| 6442 |
|
|
<dt><code>any</code> |
| 6443 |
|
|
|
| 6444 |
|
|
<dd>If the keyword <code>any</code> is specified, then all the modifiers |
| 6445 |
|
|
are accounted for. |
| 6446 |
|
|
|
| 6447 |
|
|
<dt><code>none</code> |
| 6448 |
|
|
|
| 6449 |
|
|
<dd>The keyword <code>none</code> makes the filter fail if any modifiers |
| 6450 |
|
|
returned true, except for the <code>CapsLock</code>, |
| 6451 |
|
|
<code>NumLock</code>, and <code>Scroll</code> modifiers, which are |
| 6452 |
|
|
ignored for the purposes of this keyword. |
| 6453 |
|
|
|
| 6454 |
|
|
<dt><code>+<var>modifier</var></code> |
| 6455 |
|
|
|
| 6456 |
|
|
<dd>The <var>modifier</var> modifier is accounted for. If the given |
| 6457 |
|
|
modifier does not correspond to the lowercase version of one of the |
| 6458 |
|
|
modifiers supported by the UA, or if the <code>getModifierState()</code> |
| 6459 |
|
|
method did not actually return true for the corresponding modifier, then |
| 6460 |
|
|
it makes the filter fail. |
| 6461 |
|
|
|
| 6462 |
|
|
<dt><code>-<var>modifier</var></code> |
| 6463 |
|
|
|
| 6464 |
|
|
<dd>If the <code>getModifierState()</code> method returned true for the |
| 6465 |
|
|
modifier corresponding to <var>modifier</var>, then it makes the filter |
| 6466 |
|
|
fail. |
| 6467 |
|
|
|
| 6468 |
|
|
<dt><code><var>modifier</var>?</code> |
| 6469 |
|
|
|
| 6470 |
|
|
<dd>The <var>modifier</var> modifier is accounted for. If the |
| 6471 |
|
|
<code>getModifierState()</code> method did not actually return true for |
| 6472 |
|
|
the modifier corresponding to <var>modifier</var>, the value is ignored. |
| 6473 |
|
|
|
| 6474 |
|
|
<dt>Anything else ("<code><var>modifier</var></code>") |
| 6475 |
|
|
|
| 6476 |
|
|
<dd>Treated the same as <code>+<var>modifier</var></code>. |
| 6477 |
|
|
</dl> |
| 6478 |
|
|
|
| 6479 |
|
|
<p>A modifier can be listed multiple times, though this is not |
| 6480 |
|
|
particularly useful.</p> |
| 6481 |
|
|
|
| 6482 |
|
|
<div class=example> |
| 6483 |
|
|
<p>Here are some examples of what this means:</p> |
| 6484 |
|
|
|
| 6485 |
|
|
<dl> |
| 6486 |
|
|
<dt><code title="">modifiers</code> not specified |
| 6487 |
|
|
|
| 6488 |
|
|
<dd>The modifiers are ignored, unless the <code |
| 6489 |
|
|
title=attr-handler-key><a href="#key">key</a></code> attribute is |
| 6490 |
|
|
specified, in which case the event handler is only invoked if no |
| 6491 |
|
|
modifiers are pressed. |
| 6492 |
|
|
|
| 6493 |
|
|
<dt><code title="">modifiers=""</code> |
| 6494 |
|
|
|
| 6495 |
|
|
<dt><code title="">modifiers="none"</code> |
| 6496 |
|
|
|
| 6497 |
|
|
<dd>The event handler is only invoked if no modifiers are pressed. |
| 6498 |
|
|
|
| 6499 |
|
|
<dt><code title="">modifiers="any"</code> |
| 6500 |
|
|
|
| 6501 |
|
|
<dd>The modifiers are ignored. |
| 6502 |
|
|
|
| 6503 |
|
|
<dt><code title="">modifiers="alt control"</code> |
| 6504 |
|
|
|
| 6505 |
|
|
<dd>The filter matches if both alt and control were pressed, and no |
| 6506 |
|
|
others. |
| 6507 |
|
|
|
| 6508 |
|
|
<dt><code title="">modifiers="alt control?"</code> |
| 6509 |
|
|
|
| 6510 |
|
|
<dd>The filter matches if alt was pressed, and no others, except maybe |
| 6511 |
|
|
control. |
| 6512 |
|
|
|
| 6513 |
|
|
<dt><code title="">modifiers="any -control"</code> |
| 6514 |
|
|
|
| 6515 |
|
|
<dd>The filter matches if the control key was not pressed, regardless of |
| 6516 |
|
|
the state of other modifiers. |
| 6517 |
|
|
|
| 6518 |
|
|
<dt><code title="">modifiers="Alt"</code> |
| 6519 |
|
|
|
| 6520 |
|
|
<dd>Never matches, since the user agent must compare the given values to |
| 6521 |
|
|
<em>lowercase</em> modifier names. |
| 6522 |
|
|
|
| 6523 |
|
|
<dt><code title="">modifiers="accel -capslock"</code> |
| 6524 |
|
|
|
| 6525 |
|
|
<dd>Matches when the platform's accelerator key is pressed, but only if |
| 6526 |
|
|
the caps lock key is not active. |
| 6527 |
|
|
|
| 6528 |
|
|
<dt><code title="">modifiers="alt alt alt"</code> |
| 6529 |
|
|
|
| 6530 |
|
|
<dd>Same as just listing the alt modifier once: the filter matches if |
| 6531 |
|
|
only the alt modifier is pressed. |
| 6532 |
|
|
|
| 6533 |
|
|
<dt><code title="">modifiers="+alt -accel"</code> |
| 6534 |
|
|
|
| 6535 |
|
|
<dd>Matches when the platform's accelerator key is pressed, but the alt |
| 6536 |
|
|
modifier is not pressed. If the platform's accelerator key is in fact |
| 6537 |
|
|
the alt key, this filter can never match. |
| 6538 |
|
|
</dl> |
| 6539 |
|
|
</div> |
| 6540 |
|
|
|
| 6541 |
|
|
<h3 id=event2><span class=secno>6.8. </span><dfn id=event13>Event Flow and |
| 6542 |
|
|
Targeting Across Shadow Scopes</dfn></h3> |
| 6543 |
|
|
|
| 6544 |
|
|
<p>DOM events can fire on shadow targets just as they can on explicit |
| 6545 |
|
|
targets. Events must flow through the <a href="#final0">final flattened |
| 6546 |
|
|
tree</a>. As long as the event flows within the same shadow tree <a |
| 6547 |
|
|
href="#shadow9" title="shadow scope">scope</a>, it is no different from |
| 6548 |
|
|
the behavior outlined in the DOM Events specification.</p> |
| 6549 |
|
|
|
| 6550 |
|
|
<p>Whenever events originating from a shadow tree flow from a shadow |
| 6551 |
|
|
element in that shadow tree to the bound element, one of two actions |
| 6552 |
|
|
occurs. Either the event is retargeted so that the bound element becomes |
| 6553 |
|
|
the target, or the event is stopped and flow proceeds to the next phase. |
| 6554 |
|
|
Whenever an event is retargeted, the event is cloned, with the clone's |
| 6555 |
|
|
<code>target</code> field set to the bound element.</p> |
| 6556 |
|
|
|
| 6557 |
|
|
<p>The action taken (retarget vs. stop) is specific to the event type. In |
| 6558 |
|
|
general, UI events must be retargeted and mutation events must be |
| 6559 |
|
|
stopped. Exceptions to the rule are noted below. The goal of this |
| 6560 |
|
|
retargeting or stopping is to stop outer shadow scopes from being exposed |
| 6561 |
|
|
to nodes from inner shadow scopes, and to stop outer shadow scopes from |
| 6562 |
|
|
getting apparently meaningless events that only make sense in the context |
| 6563 |
|
|
of inner shadow scopes.</p> |
| 6564 |
|
|
|
| 6565 |
|
|
<p>During the capture phase, the rules are exactly reversed. The first |
| 6566 |
|
|
node to see the event is the node after which bubbling stops. The target |
| 6567 |
|
|
node, when the event is passing through a node at a higher shadow scope |
| 6568 |
|
|
than the event target, is always the bound element in whose shadow |
| 6569 |
|
|
content the event target lies.</p> |
| 6570 |
|
|
|
| 6571 |
|
|
<p>When an event is retargetted at a bound element, the bound element's |
| 6572 |
|
|
event handlers must see the event only in the target phase. The capture |
| 6573 |
|
|
phase listeners must not be triggered for the bound element.</p> |
| 6574 |
|
|
|
| 6575 |
|
|
<p>The timing of event retargeting is such that when the event is |
| 6576 |
|
|
forwarded to the <code><a href="#handlers0">handlers</a></code> element, |
| 6577 |
|
|
the binding's handlers see the relevant shadow tree node as the target, |
| 6578 |
|
|
rather than the bound element as the target. (See: <a |
| 6579 |
|
|
href="#event12">event forwarding</a>.)</p> |
| 6580 |
|
|
|
| 6581 |
|
|
<p>Events bubble into deeper scopes; for example, an event fired on a |
| 6582 |
|
|
bound element's <a href="#explicit3" title="explicit children">explicit |
| 6583 |
|
|
child</a> bubbles into the element containing the <code><a |
| 6584 |
|
|
href="#content0">content</a></code> element the element was assigned to. |
| 6585 |
|
|
This does not cause any event retargeting to take place, either when |
| 6586 |
|
|
entering the deeper scope or when leaving it, since such an event does |
| 6587 |
|
|
not actually originate in that shadow tree.</p> |
| 6588 |
|
|
|
| 6589 |
|
|
<p>Any method invocations on any clones of the event object must also be |
| 6590 |
|
|
forwarded to the original event and all the clones, so that attempts to |
| 6591 |
|
|
stop propagation and cancel the default action affect the event |
| 6592 |
|
|
regardless of how many scopes it has crossed.</p> |
| 6593 |
|
|
|
| 6594 |
|
|
<div class=example> |
| 6595 |
|
|
<p>Bound document:</p> |
| 6596 |
|
|
|
| 6597 |
|
|
<pre><root xmlns=""> |
| 6598 |
|
|
<bound/> |
| 6599 |
|
|
</root></pre> |
| 6600 |
|
|
|
| 6601 |
|
|
<p>Binding template applied to the <code>bound</code> element:</p> |
| 6602 |
|
|
|
| 6603 |
|
|
<pre> ... |
| 6604 |
|
|
<xbl:template> |
| 6605 |
|
|
<shadow xmlns=""> |
| 6606 |
|
|
<target/> |
| 6607 |
|
|
</shadow> |
| 6608 |
|
|
</xbl:template> |
| 6609 |
|
|
...</pre> |
| 6610 |
|
|
|
| 6611 |
|
|
<p>If someone clicks the "target" element, the click event is dispatched |
| 6612 |
|
|
as follows:</p> |
| 6613 |
|
|
|
| 6614 |
|
|
<ol> |
| 6615 |
|
|
<li>The capture listeners on <code>root</code>. Capture phase, target is |
| 6616 |
|
|
<code>bound</code>. |
| 6617 |
|
|
|
| 6618 |
|
|
<li>The capture listeners on the binding's <code><a |
| 6619 |
|
|
href="#handlers0">handlers</a></code>. Capture phase, target is |
| 6620 |
|
|
<code>target</code>. |
| 6621 |
|
|
|
| 6622 |
|
|
<li>The capture listeners on <code>shadow</code>. Capture phase, target |
| 6623 |
|
|
is <code>target</code>. |
| 6624 |
|
|
|
| 6625 |
|
|
<li>The bubbling listeners on <code>target</code>. Target phase, target |
| 6626 |
|
|
is <code>target</code>. |
| 6627 |
|
|
|
| 6628 |
|
|
<li>The bubbling listeners on <code>shadow</code>. Bubbling phase, |
| 6629 |
|
|
target is <code>target</code>. |
| 6630 |
|
|
|
| 6631 |
|
|
<li>The bubbling listeners on the binding's <code><a |
| 6632 |
|
|
href="#handlers0">handlers</a></code>. Bubbling phase, target is |
| 6633 |
|
|
<code>target</code>. |
| 6634 |
|
|
|
| 6635 |
|
|
<li>The bubbling listeners on <code>bound</code>. Target phase, target |
| 6636 |
|
|
is <code>bound</code>. |
| 6637 |
|
|
|
| 6638 |
|
|
<li>The bubbling listeners on <code>root</code>. Bubbling phase, target |
| 6639 |
|
|
is <code>bound</code>. |
| 6640 |
|
|
|
| 6641 |
|
|
<li>The default action listeners on the binding's <code><a |
| 6642 |
|
|
href="#handlers0">handlers</a></code>. Default phase, target is |
| 6643 |
|
|
<code>target</code>. |
| 6644 |
|
|
|
| 6645 |
|
|
<li>The UA's default action listeners for <code>target</code>. Default |
| 6646 |
|
|
phase, target is <code>target</code>. |
| 6647 |
|
|
</ol> |
| 6648 |
|
|
</div> |
| 6649 |
|
|
|
| 6650 |
|
|
<h3 id=the-default><span class=secno>6.9. </span><dfn id=the-default1 |
| 6651 |
|
|
title="default phase">The Default Phase</dfn></h3> |
| 6652 |
|
|
|
| 6653 |
|
|
<p>If an event bubbles through or is targeted at one or more bound |
| 6654 |
|
|
elements, and the event is not canceled (after the capture, target, and |
| 6655 |
|
|
bubble phases have all completed, its <code>defaultPrevented</code> |
| 6656 |
|
|
attribute is still false), then the event's <code>eventPhase</code> |
| 6657 |
|
|
attribute must be set to the value 0x78626C44 <!-- "xblD" in ASCII --> |
| 6658 |
|
|
(2019716164), and then the event must be <a href="#event12" title="event |
| 6659 |
|
|
forwarding">forwarded</a> to the relevant <code><a |
| 6660 |
|
|
href="#handlers0">handlers</a></code> elements of all the bound elements |
| 6661 |
|
|
the event bubbled through or was targeted at in those bubble and target |
| 6662 |
|
|
phases, in reverse tree order (starting from the target node and walking |
| 6663 |
|
|
the tree towards the <code>Document</code> node), with |
| 6664 |
|
|
<code>currentTarget</code> set to the relevant bound element each time. |
| 6665 |
|
|
If the event is canceled (that is, if the <code>defaultPrevented</code> |
| 6666 |
|
|
attribute becomes true) while being forwarded to one of these bound |
| 6667 |
|
|
elements, subsequent bound elements must not receive the event.</p> |
| 6668 |
|
|
|
| 6669 |
|
|
<p>If the event has a UA default action, it must only perform it if the |
| 6670 |
|
|
<code>defaultPrevented</code> attribute is still false after it has been |
| 6671 |
|
|
so forwarded.</p> |
| 6672 |
|
|
|
| 6673 |
|
|
<p>The <code>stopPropagation()</code> and |
| 6674 |
|
|
<code>stopImmediatePropagation()</code> methods must have no effect |
| 6675 |
|
|
during this "default" phase.</p> |
| 6676 |
|
|
|
| 6677 |
|
|
<h3 id=the-focus><span class=secno>6.10. </span>The <code>focus</code>, |
| 6678 |
|
|
<code>DOMFocusIn</code>, <code>blur</code>, and <code>DOMFocusOut</code> |
| 6679 |
|
|
Events</h3> |
| 6680 |
|
|
|
| 6681 |
|
|
<p>If shadow content underneath a focusable bound element loses focus and |
| 6682 |
|
|
shadow content also underneath the bound element takes focus, then both |
| 6683 |
|
|
focus change events must be stopped. As far as the bound element is |
| 6684 |
|
|
concerned, it retains focus throughout the two events. (Other |
| 6685 |
|
|
specifications may go into more detail as to how to determine if an |
| 6686 |
|
|
element can be focused.)</p> |
| 6687 |
|
|
|
| 6688 |
|
|
<p>If the focus moves from the bound element's shadow content to a node |
| 6689 |
|
|
completely outside the bound element, or vice versa, then the respective |
| 6690 |
|
|
events must be retargetted instead.</p> |
| 6691 |
|
|
|
| 6692 |
|
|
<p>The <span>'nav-index'</span> property defined in the CSS UI module <a |
| 6693 |
|
|
href="#refsCSS3UI">[CSS3UI]</a> can be used to specify the tab order for |
| 6694 |
|
|
focusable elements. This property can be specified on shadow content. |
| 6695 |
|
|
Each shadow scope has a unique tab order. The <span>'nav-index'</span> |
| 6696 |
|
|
values used in one shadow scope are ignored by other shadow scopes. The |
| 6697 |
|
|
tab order is resolved in the shadow tree first to produce a list of |
| 6698 |
|
|
elements in the tab order. This list is substituted in place of the bound |
| 6699 |
|
|
element in the bound element's tree tab order.</p> |
| 6700 |
|
|
|
| 6701 |
|
|
<div class=example> |
| 6702 |
|
|
<p>As an example, consider the HTML file upload control. It is a |
| 6703 |
|
|
focusable element that in turn is made up of two focusable shadow |
| 6704 |
|
|
elements: a text field and a button. Tab indices can be specified on the |
| 6705 |
|
|
text field and the button to indicate the order in which the components |
| 6706 |
|
|
of the file control should be accessed when tabbing.</p> |
| 6707 |
|
|
|
| 6708 |
|
|
<p>When the user tabs such that the file control should become focused, |
| 6709 |
|
|
the user agent determines if any shadow content should also become |
| 6710 |
|
|
focused, using the tab order specified by the shadow content elements. |
| 6711 |
|
|
It then generates a focus event on the text field inside the file |
| 6712 |
|
|
control. As this event flows across shadow scopes, it is retargeted to |
| 6713 |
|
|
be a focus event on the file control itself.</p> |
| 6714 |
|
|
|
| 6715 |
|
|
<p>Focus events should also be stopped if the bound element is already |
| 6716 |
|
|
focused. For example, if the user has already focused the text field |
| 6717 |
|
|
within an HTML file upload control, then the file upload control is now |
| 6718 |
|
|
also focused. If the user then focuses the button inside the file upload |
| 6719 |
|
|
control, the focus event generated for the button is stopped before it |
| 6720 |
|
|
reaches the file control, since the file control is already focused.</p> |
| 6721 |
|
|
</div> |
| 6722 |
|
|
|
| 6723 |
|
|
<p>Because content in multiple shadow scopes can be focused, the CSS |
| 6724 |
|
|
<code>:focus</code> pseudo-element is hierarchical in the presence of |
| 6725 |
|
|
XBL, with up to one element in each shadow scope matching the |
| 6726 |
|
|
pseudo-class. Style rules can be written with the assumption that they |
| 6727 |
|
|
will match (in the above example) both the file control and the element |
| 6728 |
|
|
focused inside the file control. In other words, an arbitrary chain of |
| 6729 |
|
|
elements can be in the <code>:focus</code> state at the same time.</p> |
| 6730 |
|
|
|
| 6731 |
|
|
<p class=note>Further specifications may describe in more detail the |
| 6732 |
|
|
interaction of arbitrary chains of elements that can be in the |
| 6733 |
|
|
<code>:focus</code> state at the same time.</p> |
| 6734 |
|
|
|
| 6735 |
|
|
<h3 id=the-mouseover><span class=secno>6.11. </span>The |
| 6736 |
|
|
<code>mouseover</code> and <code>mouseout</code> Events</h3> |
| 6737 |
|
|
|
| 6738 |
|
|
<p>Mouseover and mouseout events must be retargeted if the pointing device |
| 6739 |
|
|
genuinely moves onto (enters) or is moved away (exits) the bound element |
| 6740 |
|
|
(in addition to entering or exiting some shadow content). If, however, |
| 6741 |
|
|
the user has simply moved the pointing device from one element in the |
| 6742 |
|
|
shadow tree to another element in the same shadow tree, without entering |
| 6743 |
|
|
or exiting the bound element itself, then the event must be stopped.</p> |
| 6744 |
|
|
|
| 6745 |
|
|
<div class=example> |
| 6746 |
|
|
<p>For example, if the user enters the HTML file upload control from the |
| 6747 |
|
|
left, a mouseover event is generated for the shadow text field. Because |
| 6748 |
|
|
this event also constitutes a mouseover of the file control itself, the |
| 6749 |
|
|
event is retargeted when it flows across shadow scopes. If the user then |
| 6750 |
|
|
moves the mouse from the text field to the button, a mouseout is |
| 6751 |
|
|
generated for the text field, followed by a mouseover of the button.</p> |
| 6752 |
|
|
|
| 6753 |
|
|
<p>Since neither of these events constitutes a mouseover or mouseout of |
| 6754 |
|
|
the file control itself, the events are not allowed to flow to the file |
| 6755 |
|
|
control. If the user continues moving to the right and leaves the |
| 6756 |
|
|
button, then the mouseout generated will be retargeted, since the file |
| 6757 |
|
|
control will also have been exited.</p> |
| 6758 |
|
|
</div> |
| 6759 |
|
|
|
| 6760 |
|
|
<h3 id=event3><span class=secno>6.12. </span><dfn id=event14>Event |
| 6761 |
|
|
Handlers Implemented in ECMAScript</dfn></h3> |
| 6762 |
|
|
|
| 6763 |
|
|
<p>When a script of a <code><a href="#handler0">handler</a></code> element |
| 6764 |
|
|
implemented in ECMAScript is executed the user agent must set the |
| 6765 |
|
|
<code>this</code> value to the <a href="#internal">internal object</a> |
| 6766 |
|
|
part of the implementation object of the binding with which the <code><a |
| 6767 |
|
|
href="#handler0">handler</a></code> element is associated. The script |
| 6768 |
|
|
must be executed as a function body with one argument, called |
| 6769 |
|
|
<code>event</code>, which is a reference to the <code>Event</code> object |
| 6770 |
|
|
representing the event. The script must be compiled and executed each |
| 6771 |
|
|
time it is accessed, so that any dynamic changes to the event handler |
| 6772 |
|
|
code in the binding document take effect.</p> |
| 6773 |
|
|
|
| 6774 |
|
|
<h2 id=dom-interfaces><span class=secno>7. </span><dfn |
| 6775 |
|
|
id=dom-interfaces1>DOM Interfaces</dfn></h2> |
| 6776 |
|
|
|
| 6777 |
|
|
<p>XBL introduces a few XBL-specific interfaces.</p> |
| 6778 |
|
|
|
| 6779 |
|
|
<h3 id=the-documentxbl><span class=secno>7.1. </span>The <code><a |
| 6780 |
|
|
href="#documentxbl">DocumentXBL</a></code> Interface</h3> |
| 6781 |
|
|
|
| 6782 |
|
|
<p>The <code><a href="#documentxbl">DocumentXBL</a></code> interface |
| 6783 |
|
|
contains methods for loading and obtaining binding documents. The |
| 6784 |
|
|
interface is implemented by DOM documents that support having their |
| 6785 |
|
|
elements bound by XBL.</p> |
| 6786 |
|
|
|
| 6787 |
|
|
<dl> |
| 6788 |
|
|
<dt>IDL Definition |
| 6789 |
|
|
|
| 6790 |
|
|
<dd> |
| 6791 |
|
|
<pre class=idl>interface <dfn id=documentxbl>DocumentXBL</dfn> { |
| 6792 |
|
|
readonly attribute NamedNodeMap <a href="#bindingdocuments">bindingDocuments</a>; |
| 6793 |
|
|
Document <a href="#loadbindingdocument">loadBindingDocument</a>(in DOMString documentURI); |
| 6794 |
|
|
};</pre> |
| 6795 |
|
|
|
| 6796 |
|
|
<dt>Attributes |
| 6797 |
|
|
|
| 6798 |
|
|
<dd> |
| 6799 |
|
|
<dl> |
| 6800 |
|
|
<dt><dfn id=bindingdocuments><code |
| 6801 |
|
|
class=attribute-name>bindingDocuments</code></dfn> of type <code |
| 6802 |
|
|
class=dom>NamedNodeMap</code>, readonly |
| 6803 |
|
|
|
| 6804 |
|
|
<dd>The <code><a href="#bindingdocuments">bindingDocuments</a></code> |
| 6805 |
|
|
attribute must return a <code>NamedNodeMap</code> of all the binding |
| 6806 |
|
|
documents loaded by the document. Documents are referenced using their |
| 6807 |
|
|
URIs as the node names, with null namespaces. The |
| 6808 |
|
|
<code>NamedNodeMap</code> must be live, and must raise |
| 6809 |
|
|
<code>NO_MODIFICATION_ALLOWED_ERR</code> on any attempts at |
| 6810 |
|
|
modification or deletion. |
| 6811 |
|
|
</dl> |
| 6812 |
|
|
|
| 6813 |
|
|
<dt>Methods |
| 6814 |
|
|
|
| 6815 |
|
|
<dd> |
| 6816 |
|
|
<dl> |
| 6817 |
|
|
<dt><dfn id=loadbindingdocument><code |
| 6818 |
|
|
class=method-name>loadBindingDocument</code></dfn> |
| 6819 |
|
|
|
| 6820 |
|
|
<dd> |
| 6821 |
|
|
<p>The <code><a |
| 6822 |
|
|
href="#loadbindingdocument">loadBindingDocument</a></code> method |
| 6823 |
|
|
must synchronously load the specified binding document (unless it has |
| 6824 |
|
|
<a href="#loading5" title="loading external resources">already been |
| 6825 |
|
|
loaded</a>), as well as any binding documents that are required by |
| 6826 |
|
|
that binding document due to <a href="#extends" |
| 6827 |
|
|
title=attr-binding-extends>explicit inheritance</a>, and any bindings |
| 6828 |
|
|
defined by that document must be applied to matching elements in the |
| 6829 |
|
|
document that corresponds to this <code><a |
| 6830 |
|
|
href="#documentxbl">DocumentXBL</a></code> object. The method must |
| 6831 |
|
|
then return the binding document's <code>Document</code> object. |
| 6832 |
|
|
(See: <a href="#binding17">binding attachment and detachment</a>.) If |
| 6833 |
|
|
the load succeeded, it is also added to the <code><a |
| 6834 |
|
|
href="#bindingdocuments">bindingDocuments</a></code> attribute. If |
| 6835 |
|
|
the load fails, this method must return null.</p> |
| 6836 |
|
|
|
| 6837 |
|
|
<dl> |
| 6838 |
|
|
<dt>Parameters |
| 6839 |
|
|
|
| 6840 |
|
|
<dd> |
| 6841 |
|
|
<dl> |
| 6842 |
|
|
<dt><code class=parameter-name>documentURI</code> of type <code |
| 6843 |
|
|
class=dom>DOMString</code> |
| 6844 |
|
|
|
| 6845 |
|
|
<dd>The <a href="#attributes24">URI</a> of a binding document. |
| 6846 |
|
|
</dl> |
| 6847 |
|
|
|
| 6848 |
|
|
<dt>Return Value |
| 6849 |
|
|
|
| 6850 |
|
|
<dd> |
| 6851 |
|
|
<dl> |
| 6852 |
|
|
<dt><code>Document</code> |
| 6853 |
|
|
|
| 6854 |
|
|
<dd>The return value of <code><a |
| 6855 |
|
|
href="#loadbindingdocument">loadBindingDocument()</a></code> is |
| 6856 |
|
|
the <code>Document</code> object of the binding document that was |
| 6857 |
|
|
loaded, or <code>null</code> if the load failed. |
| 6858 |
|
|
</dl> |
| 6859 |
|
|
|
| 6860 |
|
|
<dt>No Exceptions |
| 6861 |
|
|
</dl> |
| 6862 |
|
|
</dl> |
| 6863 |
|
|
</dl> |
| 6864 |
|
|
|
| 6865 |
|
|
<h3 id=the-elementxbl><span class=secno>7.2. </span>The <code><a |
| 6866 |
|
|
href="#elementxbl">ElementXBL</a></code> Interface</h3> |
| 6867 |
|
|
|
| 6868 |
wakaba |
1.2 |
<p><span class=ja-translation lang=ja><code><a href="#elementxbl">ElementXBL</a></code> interface contains methods for adding or removing bindings from an element. The interface is implemented by all <code>Element</code> nodes (regardless of whether they are currently involved with any XBL processing) and may be obtained using binding-specific casting methods on an <code>Element</code> 界面。 |
| 6869 |
|
|
</span></p> |
| 6870 |
wakaba |
1.1 |
|
| 6871 |
|
|
<dl> |
| 6872 |
|
|
<dt>IDL Definition |
| 6873 |
|
|
|
| 6874 |
|
|
<dd> |
| 6875 |
|
|
<pre class=idl>interface <dfn id=elementxbl>ElementXBL</dfn> { |
| 6876 |
|
|
readonly attribute XBLImplementationList <a href="#xblimplementations">xblImplementations</a>; |
| 6877 |
|
|
void <a href="#addbinding">addBinding</a>(in DOMString bindingURI); |
| 6878 |
|
|
void <a href="#removebinding">removeBinding</a>(in DOMString bindingURI); |
| 6879 |
|
|
boolean <a href="#hasbinding">hasBinding</a>(in DOMString bindingURI); |
| 6880 |
|
|
};</pre> |
| 6881 |
|
|
|
| 6882 |
|
|
<dt>Attributes |
| 6883 |
|
|
|
| 6884 |
|
|
<dd> |
| 6885 |
|
|
<dl> |
| 6886 |
|
|
<dt><code><a href="#xblimplementations">xblImplementations</a></code> |
| 6887 |
|
|
of type <code><a |
| 6888 |
|
|
href="#xblimplementationlist">XBLImplementationList</a></code>, |
| 6889 |
|
|
readonly |
| 6890 |
|
|
|
| 6891 |
|
|
<dd>See <a href="#binding23">binding implementations</a>. |
| 6892 |
|
|
</dl> |
| 6893 |
|
|
|
| 6894 |
|
|
<dt>Methods |
| 6895 |
|
|
|
| 6896 |
|
|
<dd> |
| 6897 |
|
|
<dl> |
| 6898 |
|
|
<dt><dfn id=addbinding><code class=method-name>addBinding</code></dfn> |
| 6899 |
|
|
|
| 6900 |
|
|
<dd> The <code><a href="#addbinding">addBinding</a></code> method must |
| 6901 |
|
|
attach the specified binding (and any bindings that the binding |
| 6902 |
|
|
inherits from) to the element. This call is not necessarily |
| 6903 |
|
|
synchronous. The binding may not be attached yet when the call |
| 6904 |
|
|
completes. |
| 6905 |
|
|
<dl> |
| 6906 |
|
|
<dt>Parameters |
| 6907 |
|
|
|
| 6908 |
|
|
<dd> |
| 6909 |
|
|
<dl> |
| 6910 |
|
|
<dt><code class=parameter-name>bindingURI</code> of type |
| 6911 |
|
|
<code>DOMString</code> |
| 6912 |
|
|
|
| 6913 |
|
|
<dd>A <a href="#attributes24">URI</a> that specifies the location |
| 6914 |
|
|
of a specific binding to attach. |
| 6915 |
|
|
</dl> |
| 6916 |
|
|
|
| 6917 |
|
|
<dt>No Return Value |
| 6918 |
|
|
|
| 6919 |
|
|
<dt>Exceptions |
| 6920 |
|
|
|
| 6921 |
|
|
<dd> |
| 6922 |
|
|
<dl> |
| 6923 |
|
|
<dt><code>HIERARCHY_REQUEST_ERR</code> |
| 6924 |
|
|
|
| 6925 |
|
|
<dd>This exception must be raised if the node is not an element. |
| 6926 |
|
|
</dl> |
| 6927 |
|
|
</dl> |
| 6928 |
|
|
|
| 6929 |
|
|
<dt><dfn id=removebinding><code |
| 6930 |
|
|
class=method-name>removeBinding</code></dfn> |
| 6931 |
|
|
|
| 6932 |
|
|
<dd> The <code><a href="#removebinding">removeBinding</a></code> method |
| 6933 |
|
|
must detach the specified binding (and any bindings that the binding |
| 6934 |
|
|
inherits from explicitly using the <code>extends</code> attribute) |
| 6935 |
|
|
from the element. This method can only detach bindings that were |
| 6936 |
|
|
attached using <code><a href="#addbinding">addBinding</a></code>. If |
| 6937 |
|
|
the binding in question is not attached to this element (or was |
| 6938 |
|
|
attached through another attachment mechanism) then the method must do |
| 6939 |
|
|
nothing. |
| 6940 |
|
|
<dl> |
| 6941 |
|
|
<dt>Parameters |
| 6942 |
|
|
|
| 6943 |
|
|
<dd> |
| 6944 |
|
|
<dl> |
| 6945 |
|
|
<dt><code class=parameter-name>bindingURI</code> of type |
| 6946 |
|
|
<code>DOMString</code> |
| 6947 |
|
|
|
| 6948 |
|
|
<dd>A <a href="#attributes24">URI</a> that specifies the location |
| 6949 |
|
|
of a specific binding to detach. |
| 6950 |
|
|
</dl> |
| 6951 |
|
|
|
| 6952 |
|
|
<dt>No Return Value |
| 6953 |
|
|
|
| 6954 |
|
|
<dt>No Exceptions |
| 6955 |
|
|
</dl> |
| 6956 |
|
|
|
| 6957 |
|
|
<dt><dfn id=hasbinding><code class=method-name>hasBinding</code></dfn> |
| 6958 |
|
|
|
| 6959 |
|
|
<dd> |
| 6960 |
|
|
<p>The <code><a href="#hasbinding">hasBinding</a></code> method must |
| 6961 |
|
|
check the bindings applied to the element and compares each binding's |
| 6962 |
|
|
URI with the parameter passed. If any of the bindings matches the |
| 6963 |
|
|
specified URI, then the method must return true, otherwise it must |
| 6964 |
|
|
return false. This can be used to check if an element has been bound |
| 6965 |
|
|
to a particular binding in in order to ensure that the expected |
| 6966 |
|
|
methods and attributes are available.</p> |
| 6967 |
|
|
|
| 6968 |
|
|
<p>Any bindings attached to the element (including, e.g., those |
| 6969 |
|
|
attached using CSS) are examined by this method.</p> |
| 6970 |
|
|
|
| 6971 |
|
|
<p class=example>For example widgets may walk up their ancestors |
| 6972 |
|
|
looking for an element that has been bound to a form-container |
| 6973 |
|
|
binding in order to locate their scope (so that radio buttons may |
| 6974 |
|
|
properly be mutually exclusive, or so that a submit button can |
| 6975 |
|
|
properly submit a form).</p> |
| 6976 |
|
|
|
| 6977 |
|
|
<dl> |
| 6978 |
|
|
<dt>Parameters |
| 6979 |
|
|
|
| 6980 |
|
|
<dd> |
| 6981 |
|
|
<dl> |
| 6982 |
|
|
<dt><code class=parameter-name>bindingURI</code> of type |
| 6983 |
|
|
<code>DOMString</code> |
| 6984 |
|
|
|
| 6985 |
|
|
<dd>A <a href="#attributes24">URI</a> that specifies the location |
| 6986 |
|
|
of a specific binding for which to look. |
| 6987 |
|
|
</dl> |
| 6988 |
|
|
|
| 6989 |
|
|
<dt>Returns |
| 6990 |
|
|
|
| 6991 |
|
|
<dd> |
| 6992 |
|
|
<dl> |
| 6993 |
|
|
<dt><code>boolean</code> |
| 6994 |
|
|
|
| 6995 |
|
|
<dd><code>true</code> if any of the bindings match the parameter, |
| 6996 |
|
|
<code>false</code> otherwise. |
| 6997 |
|
|
</dl> |
| 6998 |
|
|
|
| 6999 |
|
|
<dt>No Exceptions |
| 7000 |
|
|
</dl> |
| 7001 |
|
|
</dl> |
| 7002 |
|
|
</dl> |
| 7003 |
|
|
|
| 7004 |
|
|
<h4 id=scoping><span class=secno>7.2.1. </span>Scoping and Access Using |
| 7005 |
|
|
the DOM</h4> |
| 7006 |
|
|
|
| 7007 |
|
|
<p>In effect the shadow content exists in its own insulated pocket within |
| 7008 |
|
|
the document, its <a href="#shadow9">shadow scope</a>. Bound elements |
| 7009 |
|
|
have no knowledge of their shadow children in terms of DOM Core <a |
| 7010 |
|
|
href="#refsDOM3CORE">[DOM3CORE]</a>. The shadow content is not accessible |
| 7011 |
|
|
via the <code>childNodes</code> list for the bound element, nor is it |
| 7012 |
|
|
accessible using <code>firstChild</code>/<code>nextSibling</code> to |
| 7013 |
|
|
iterate over the children of the bound element.</p> |
| 7014 |
|
|
|
| 7015 |
|
|
<p>DOM methods that can be invoked on elements (e.g., |
| 7016 |
|
|
<code>getElementsByTagName()</code>) will only see nodes that are in the |
| 7017 |
|
|
same shadow scope. Methods invoked on the document (e.g., <code |
| 7018 |
|
|
title="">getElementById</code>) only see nodes that are not in shadow |
| 7019 |
|
|
trees.</p> |
| 7020 |
|
|
|
| 7021 |
|
|
<p>On shadow content nodes, <code>ownerDocument</code> always points to |
| 7022 |
|
|
the document from which the nodes were cloned.</p> |
| 7023 |
|
|
|
| 7024 |
|
|
<p>Elements in different shadow scopes may have clashing IDs. IDs need |
| 7025 |
|
|
only be unique within each shadow scope.</p> |
| 7026 |
|
|
|
| 7027 |
|
|
<p>Elements that are the root of a shadow tree (the cloned <code><a |
| 7028 |
|
|
href="#template0">template</a></code> elements) cannot be inserted into a |
| 7029 |
|
|
document. Any attempt to do so must raise a |
| 7030 |
|
|
<code>HIERARCHY_REQUEST_ERR</code>. <!-- (This is because if you |
| 7031 |
|
|
did, you would end up having two ways to reach the nodes in the |
| 7032 |
|
|
<span>final flattened tree</span>, which would be mighty confusing |
| 7033 |
|
|
for things like getComputedStyle() --></p> |
| 7034 |
|
|
|
| 7035 |
|
|
<p>Manipulating the DOM of a shadow tree (<code><a |
| 7036 |
|
|
href="#content0">content</a></code> elements being moved about or even |
| 7037 |
|
|
removed altogether, <code title=attr-attr><a |
| 7038 |
|
|
href="#xblattr0">xbl:attr</a></code> attributes being attached and |
| 7039 |
|
|
modified, etc) must immediately cause the <a href="#final0">final |
| 7040 |
|
|
flattened tree</a> to be updated.</p> |
| 7041 |
|
|
|
| 7042 |
|
|
<p>Changes to namespace prefix definitions in the shadow tree that affect |
| 7043 |
|
|
<a href="#qname" title=QName>QNames</a> used in <code title=attr-attr><a |
| 7044 |
|
|
href="#xblattr0">xbl:attr</a></code> attributes may have their effects |
| 7045 |
|
|
applied immediately but this is not required.</p> |
| 7046 |
|
|
|
| 7047 |
|
|
<p>Because each bound element gets its own copy of the cloned template, |
| 7048 |
|
|
changes to a bound element's shadow content only affect that bound |
| 7049 |
|
|
element. Other bindings are unaffected.</p> |
| 7050 |
|
|
|
| 7051 |
|
|
<p>If an element is added to the DOM dynamically, its shadow scope is that |
| 7052 |
|
|
of its parent element. Adding an element as a child of a bound element |
| 7053 |
|
|
causes that element to be assigned to an appropriate <code><a |
| 7054 |
|
|
href="#content0">content</a></code> element (if there is one — if |
| 7055 |
|
|
there is not, the element does not appear anywhere in the <a |
| 7056 |
|
|
href="#final0">final flattened tree</a>).</p> |
| 7057 |
|
|
|
| 7058 |
|
|
<h3 id=the-xblcontentelement><span class=secno>7.3. </span>The <code><a |
| 7059 |
|
|
href="#xblcontentelement">XBLContentElement</a></code> Interface</h3> |
| 7060 |
|
|
|
| 7061 |
|
|
<p>The <code><a href="#xblcontentelement">XBLContentElement</a></code> |
| 7062 |
|
|
interface is implemented by <code><a href="#content0">content</a></code> |
| 7063 |
|
|
elements in the XBL namespace (regardless of whether they are <a |
| 7064 |
|
|
href="#in-error">in error</a> or not).</p> |
| 7065 |
|
|
|
| 7066 |
|
|
<dl> |
| 7067 |
|
|
<dt>IDL Definition |
| 7068 |
|
|
|
| 7069 |
|
|
<dd> |
| 7070 |
|
|
<pre |
| 7071 |
|
|
class=idl>interface <dfn id=xblcontentelement>XBLContentElement</dfn> : Element { |
| 7072 |
|
|
readonly attribute <span>NodeList</span> <a href="#xblchildnodes">xblChildNodes</a>; |
| 7073 |
|
|
void <a href="#setinsertionpoint">setInsertionPoint</a>(in Node child); |
| 7074 |
|
|
};</pre> |
| 7075 |
|
|
|
| 7076 |
|
|
<dt>Attributes |
| 7077 |
|
|
|
| 7078 |
|
|
<dd> |
| 7079 |
|
|
<dl> |
| 7080 |
|
|
<dt><dfn id=xblchildnodes><code>xblChildNodes</code></dfn> of type |
| 7081 |
|
|
<code>NodeList</code>, readonly |
| 7082 |
|
|
|
| 7083 |
|
|
<dd> |
| 7084 |
|
|
<p>The <code><a href="#xblchildnodes">xblChildNodes</a></code> |
| 7085 |
|
|
attribute must return a <code>NodeList</code> containing a live list |
| 7086 |
|
|
of all the nodes that are currently assigned to the <code><a |
| 7087 |
|
|
href="#content0">content</a></code> element.</p> |
| 7088 |
|
|
|
| 7089 |
|
|
<p class=note>A node can be assigned to multiple <code><a |
| 7090 |
|
|
href="#content0">content</a></code> elements simultaneously, in the |
| 7091 |
|
|
case of bound elements inside shadow trees.</p> |
| 7092 |
|
|
|
| 7093 |
|
|
<p>Exception: if the <code><a href="#content0">content</a></code> |
| 7094 |
|
|
element is not in a <a href="#shadow7">shadow tree</a>, then this |
| 7095 |
|
|
attribute must return null.</p> |
| 7096 |
|
|
</dl> |
| 7097 |
|
|
|
| 7098 |
|
|
<dt>Methods |
| 7099 |
|
|
|
| 7100 |
|
|
<dd> |
| 7101 |
|
|
<dl> |
| 7102 |
|
|
<dt><dfn id=setinsertionpoint><code>setInsertionPoint</code></dfn> |
| 7103 |
|
|
|
| 7104 |
|
|
<dd> |
| 7105 |
|
|
<p>The <code><a href="#setinsertionpoint">setInsertionPoint</a></code> |
| 7106 |
|
|
method perform the following steps.</p> |
| 7107 |
|
|
|
| 7108 |
|
|
<ol> |
| 7109 |
|
|
<li>Let <var title="">e</var> be the bound element for which the user |
| 7110 |
|
|
agent generated the shadow tree in which the given <code><a |
| 7111 |
|
|
href="#content0">content</a></code> element finds itself. If there |
| 7112 |
|
|
is no such bound element (e.g. the <code><a |
| 7113 |
|
|
href="#content0">content</a></code> element has been removed from |
| 7114 |
|
|
its shadow tree), then the method must raise an |
| 7115 |
|
|
<code>INVALID_STATE_ERR</code> exception. |
| 7116 |
|
|
|
| 7117 |
|
|
<li>Let <var title="">child</var> be the node that was given as an |
| 7118 |
|
|
argument to the method. |
| 7119 |
|
|
|
| 7120 |
|
|
<li>The user agent must then check that the parent of <var |
| 7121 |
|
|
title="">child</var> is in fact <var title="">e</var>. If it is not, |
| 7122 |
|
|
then the method must raise an <code>HIERARCHY_REQUEST_ERR</code> |
| 7123 |
|
|
exception. |
| 7124 |
|
|
|
| 7125 |
|
|
<li>The user agent must then check that either the <code><a |
| 7126 |
|
|
href="#content0">content</a></code> element has no <code |
| 7127 |
|
|
title=attr-content-includes><a href="#includes">includes</a></code> |
| 7128 |
|
|
attribute, or that <var title="">child</var> matches the selector |
| 7129 |
|
|
given in the <code><a href="#content0">content</a></code> element's |
| 7130 |
|
|
<code title=attr-content-includes><a |
| 7131 |
|
|
href="#includes">includes</a></code> attribute. If the attribute is |
| 7132 |
|
|
present but the element does not match the selector it specifies (or |
| 7133 |
|
|
if the selector is not syntactically correct), then the method must |
| 7134 |
|
|
raise an <code>TYPE_MISMATCH_ERR</code> exception.</li> |
| 7135 |
|
|
<!-- XXX |
| 7136 |
|
|
that one is stretching it --> |
| 7137 |
|
|
|
| 7138 |
|
|
<li>Finally, the user agent must assign <var title="">child</var> to |
| 7139 |
|
|
the <code><a href="#content0">content</a></code> element, instead of |
| 7140 |
|
|
whatever previous <code><a href="#content0">content</a></code> |
| 7141 |
|
|
element it was assigned to, if any. |
| 7142 |
|
|
</ol> |
| 7143 |
|
|
|
| 7144 |
|
|
<p>If a node is assigned, using the <code><a |
| 7145 |
|
|
href="#setinsertionpoint">setInsertionPoint</a></code> method, to a |
| 7146 |
|
|
<code><a href="#content0">content</a></code> element that is not |
| 7147 |
|
|
locked, then the element will only remain there until such time as |
| 7148 |
|
|
the user agent redistributes the bound element's explicit children.</p> |
| 7149 |
|
|
|
| 7150 |
|
|
<p>See <a href="#processing2">processing <code>content</code> |
| 7151 |
|
|
elements</a>.</p> |
| 7152 |
|
|
|
| 7153 |
|
|
<p class=note>The order of nodes assigned to a <code><a |
| 7154 |
|
|
href="#content0">content</a></code> element is always be the same as |
| 7155 |
|
|
the relative order of those nodes in the original core DOM.</p> |
| 7156 |
|
|
|
| 7157 |
|
|
<dl> |
| 7158 |
|
|
<dt>Parameters |
| 7159 |
|
|
|
| 7160 |
|
|
<dd> |
| 7161 |
|
|
<dl> |
| 7162 |
|
|
<dt><code class=parameter-name>child</code> of type |
| 7163 |
|
|
<code>Node</code> |
| 7164 |
|
|
|
| 7165 |
|
|
<dd>The child of the bound element to assign to this <code><a |
| 7166 |
|
|
href="#content0">content</a></code> element. |
| 7167 |
|
|
</dl> |
| 7168 |
|
|
|
| 7169 |
|
|
<dt>No Return Value |
| 7170 |
|
|
|
| 7171 |
|
|
<dt>No Exceptions |
| 7172 |
|
|
</dl> |
| 7173 |
|
|
|
| 7174 |
|
|
<div class=example> |
| 7175 |
|
|
<p>The following example implements a tabbed interface as a binding. |
| 7176 |
|
|
It creates a list of buttons to enable the user to access each of |
| 7177 |
|
|
the sections that the tab box contains, and then uses <code><a |
| 7178 |
|
|
href="#setinsertionpoint">setInsertionPoint()</a></code> to make the |
| 7179 |
|
|
selected tab panel appear.</p> |
| 7180 |
|
|
|
| 7181 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 7182 |
|
|
<binding> |
| 7183 |
|
|
<template> |
| 7184 |
|
|
<div id="tabs"/> |
| 7185 |
|
|
<div class="panel"><content id="current" locked="true"/></div> |
| 7186 |
|
|
<div class="hidden"><content id="not-current"/></div> |
| 7187 |
|
|
</template> |
| 7188 |
|
|
<implementation> |
| 7189 |
|
|
({ |
| 7190 |
|
|
set current(section) { |
| 7191 |
|
|
if (this._current) |
| 7192 |
|
|
this.shadowTree.getElementById('not-current').setInsertionPoint(this._current); |
| 7193 |
|
|
this._current = section; |
| 7194 |
|
|
if (this._current) |
| 7195 |
|
|
this.shadowTree.getElementById('current').setInsertionPoint(this._current); |
| 7196 |
|
|
}, |
| 7197 |
|
|
get current() { |
| 7198 |
|
|
return this._current; |
| 7199 |
|
|
}, |
| 7200 |
|
|
xblBindingAttached: function() { |
| 7201 |
|
|
this.updateTabs(); |
| 7202 |
|
|
this.current = this.boundElement.getElementsByTagName('section')[0]; |
| 7203 |
|
|
}, |
| 7204 |
|
|
clearTabs: function() { |
| 7205 |
|
|
with (this.shadowTree.getElementById('tabs')) |
| 7206 |
|
|
while (hasChildNodes()) |
| 7207 |
|
|
removeChild(firstChild); |
| 7208 |
|
|
}, |
| 7209 |
|
|
addTabFor: function(section) { |
| 7210 |
|
|
var tab = document.createElementNS('http://www.w3.org/ns/xbl', 'div'); |
| 7211 |
|
|
tab.appendChild(document.createTextNode(section.getAttribute('title'));); |
| 7212 |
|
|
tab.addEventListener('click', function (_this) { return function (event) { |
| 7213 |
|
|
var tabs = this.shadowTree.getElementByID('tabs').getElementsByTagName('div'); |
| 7214 |
|
|
for (var i = 0; i &lt; tabs.length; ++i) |
| 7215 |
|
|
tabs[i].setAttribute('class', ''); |
| 7216 |
|
|
_this.current = section; |
| 7217 |
|
|
event.target.setAttribute('class', 'selected'); |
| 7218 |
|
|
event.preventDefault(); |
| 7219 |
|
|
} }(this), false); |
| 7220 |
|
|
this.shadowTree.getElementById('tabs').appendChild(tab); |
| 7221 |
|
|
}, |
| 7222 |
|
|
updateTabs: function() { |
| 7223 |
|
|
this.clearTabs(); |
| 7224 |
|
|
var sections = this.boundElement.getElementsByTagName('section'); |
| 7225 |
|
|
for (var i = 0; i &lt; sections.length; ++i) |
| 7226 |
|
|
this.addTabFor(sections[i]); |
| 7227 |
|
|
}, |
| 7228 |
|
|
}) |
| 7229 |
|
|
</implementation> |
| 7230 |
|
|
<resources> |
| 7231 |
|
|
<style> |
| 7232 |
|
|
#tabs > div { /* style for tabs */ } |
| 7233 |
|
|
#tabs > div.selected { /* style for selected tab */ } |
| 7234 |
|
|
.panel { /* style for panel */ } |
| 7235 |
|
|
.hidden { display: none; } |
| 7236 |
|
|
</style> |
| 7237 |
|
|
</resources> |
| 7238 |
|
|
</binding> |
| 7239 |
|
|
</xbl></pre> |
| 7240 |
|
|
|
| 7241 |
|
|
<p>This binding could be applied to any element that has |
| 7242 |
|
|
<code>section</code> elements as children, each <code>section</code> |
| 7243 |
|
|
element having its title given in its <code>title</code> attribute.</p> |
| 7244 |
|
|
|
| 7245 |
|
|
<p>The binding implemented above doesn't dynamically update when the |
| 7246 |
|
|
DOM is changed, a full implementation would probably want to listen |
| 7247 |
|
|
to mutation events to catch attribute changes and insertions and |
| 7248 |
|
|
removals of the panels.</p> |
| 7249 |
|
|
</div> |
| 7250 |
|
|
</dl> |
| 7251 |
|
|
</dl> |
| 7252 |
|
|
|
| 7253 |
|
|
<h3 id=the-xbltemplateelement><span class=secno>7.4. </span>The <code><a |
| 7254 |
|
|
href="#xbltemplateelement">XBLTemplateElement</a></code> Interface</h3> |
| 7255 |
|
|
|
| 7256 |
|
|
<p>The <code><a href="#xbltemplateelement">XBLTemplateElement</a></code> |
| 7257 |
|
|
interface is implemented by <code><a |
| 7258 |
|
|
href="#template0">template</a></code> elements that are in the XBL |
| 7259 |
|
|
namespace (regardless of whether they are <a href="#in-error">in |
| 7260 |
|
|
error</a> or not).</p> |
| 7261 |
|
|
|
| 7262 |
|
|
<dl> |
| 7263 |
|
|
<dt>IDL Definition |
| 7264 |
|
|
|
| 7265 |
|
|
<dd> |
| 7266 |
|
|
<pre class=idl> |
| 7267 |
|
|
interface <dfn id=xbltemplateelement>XBLTemplateElement</dfn> : Element { |
| 7268 |
|
|
Element <a href="#getelementbyid">getElementById</a>(in DOMString elementId); |
| 7269 |
|
|
}; |
| 7270 |
|
|
</pre> |
| 7271 |
|
|
|
| 7272 |
|
|
<dt>Attributes |
| 7273 |
|
|
|
| 7274 |
|
|
<dd>No Attributes |
| 7275 |
|
|
|
| 7276 |
|
|
<dt>Methods |
| 7277 |
|
|
|
| 7278 |
|
|
<dd> |
| 7279 |
|
|
<dl> |
| 7280 |
|
|
<dt><dfn class=method-name |
| 7281 |
|
|
id=getelementbyid><code>getElementById</code></dfn> |
| 7282 |
|
|
|
| 7283 |
|
|
<dd> |
| 7284 |
|
|
<p class=note>This method is modeled after the method of the same name |
| 7285 |
|
|
defined by <a href="#refsDOM3CORE">[DOM3CORE]</a> on the |
| 7286 |
|
|
<code>Document</code> interface.</p> |
| 7287 |
|
|
|
| 7288 |
|
|
<p>This method must return an <code>Element</code> that has an ID |
| 7289 |
|
|
attribute with the given value, and that is a descendant of the |
| 7290 |
|
|
<code><a href="#template0">template</a></code> element on which it is |
| 7291 |
|
|
invoked. If more than one such element exists, which one is returned |
| 7292 |
|
|
is undefined. If no such element exists, this returns |
| 7293 |
|
|
<code>null</code>.</p> |
| 7294 |
|
|
|
| 7295 |
|
|
<p class=note>Attributes with the name "ID" or "id" are not of type ID |
| 7296 |
|
|
unless so defined. For example, attributes with the name "id" on |
| 7297 |
|
|
elements that are from the XHTML, MathML and XBL namespaces are |
| 7298 |
|
|
defined to be of type ID by their respective specifications.</p> |
| 7299 |
|
|
|
| 7300 |
|
|
<dl> |
| 7301 |
|
|
<dt>Parameters |
| 7302 |
|
|
|
| 7303 |
|
|
<dd> |
| 7304 |
|
|
<dl> |
| 7305 |
|
|
<dt><code class=parameter-name>elementId</code> of type |
| 7306 |
|
|
<code>DOMString</code> |
| 7307 |
|
|
|
| 7308 |
|
|
<dd>The unique <code>id</code> value for an element. |
| 7309 |
|
|
</dl> |
| 7310 |
|
|
|
| 7311 |
|
|
<dt>Returns |
| 7312 |
|
|
|
| 7313 |
|
|
<dd> |
| 7314 |
|
|
<dl> |
| 7315 |
|
|
<dt><code>Element</code> |
| 7316 |
|
|
|
| 7317 |
|
|
<dd> The matching element or null if there is none. |
| 7318 |
|
|
</dl> |
| 7319 |
|
|
|
| 7320 |
|
|
<dt>No Exceptions |
| 7321 |
|
|
</dl> |
| 7322 |
|
|
</dl> |
| 7323 |
|
|
</dl> |
| 7324 |
|
|
|
| 7325 |
|
|
<h3 id=the-eventxbl><span class=secno>7.5. </span>The <code><a |
| 7326 |
|
|
href="#eventxbl">EventXBL</a></code> Interface</h3> |
| 7327 |
|
|
|
| 7328 |
|
|
<p>Objects that implement the <code>Event</code> interface must also |
| 7329 |
|
|
implement the <code><a href="#eventxbl">EventXBL</a></code> interface. <a |
| 7330 |
|
|
href="#refsDOM3EVENTS">[DOM3EVENTS]</a></p> |
| 7331 |
|
|
|
| 7332 |
|
|
<dl> |
| 7333 |
|
|
<dt>IDL Definition |
| 7334 |
|
|
|
| 7335 |
|
|
<dd> |
| 7336 |
|
|
<pre class=idl>interface <dfn id=eventxbl>EventXBL</dfn> { |
| 7337 |
|
|
readonly attribute boolean <a href="#trusted0" title=event-trusted>trusted</a>; |
| 7338 |
|
|
};</pre> |
| 7339 |
|
|
</dl> |
| 7340 |
|
|
|
| 7341 |
|
|
<p>The <dfn id=trusted0 title=event-trusted><code>trusted</code></dfn> |
| 7342 |
|
|
attribute must return true if the user agent dispatched the event (e.g. |
| 7343 |
|
|
in response to user action), and false otherwise (e.g. if an author |
| 7344 |
|
|
script dispatched a synthetic event). Events fired by the user agent in |
| 7345 |
|
|
response to untrusted events must themselves be untrusted.</p> |
| 7346 |
|
|
<!--XXX |
| 7347 |
|
|
<h2>Widget Bindings</h2> |
| 7348 |
|
|
|
| 7349 |
|
|
<p class="big-issue">(to be completed)</p> |
| 7350 |
|
|
|
| 7351 |
|
|
<p>A <dfn>widget binding</dfn> is a binding that extends either |
| 7352 |
|
|
the <span class= "css">widget</span> base binding or any of the |
| 7353 |
|
|
other <dfn>predefined base bindings</dfn> for widgets listed |
| 7354 |
|
|
below.</p> |
| 7355 |
|
|
|
| 7356 |
|
|
<h3 id="base-bindings">Predefined Base Bindings</h3> |
| 7357 |
|
|
|
| 7358 |
|
|
<p>The following bindings have predefined meaning.</p> |
| 7359 |
|
|
|
| 7360 |
|
|
<dl> |
| 7361 |
|
|
|
| 7362 |
|
|
<dt>widget</dt> |
| 7363 |
|
|
|
| 7364 |
|
|
<dd>Implements the <code>value</code> property.</dd> |
| 7365 |
|
|
|
| 7366 |
|
|
<dt>native-checkbox</dt> |
| 7367 |
|
|
|
| 7368 |
|
|
<dd>...</dd> |
| 7369 |
|
|
|
| 7370 |
|
|
<dt>simple-checkbox</dt> |
| 7371 |
|
|
|
| 7372 |
|
|
<dd>...</dd> |
| 7373 |
|
|
|
| 7374 |
|
|
<dt>widget-scope</dt> |
| 7375 |
|
|
|
| 7376 |
|
|
<dd>Implements the <code>submit</code> and <code>reset</code> |
| 7377 |
|
|
methods.</dd> |
| 7378 |
|
|
|
| 7379 |
|
|
</dl> |
| 7380 |
|
|
--> |
| 7381 |
|
|
|
| 7382 |
|
|
<h2 id=resources><span class=secno>8. </span>Resources</h2> |
| 7383 |
|
|
|
| 7384 |
|
|
<h3 id=loading><span class=secno>8.1. </span><dfn id=loading5>Loading |
| 7385 |
|
|
External Resources</dfn></h3> |
| 7386 |
|
|
|
| 7387 |
|
|
<h4 id=binding5><span class=secno>8.1.1. </span>Binding Documents</h4> |
| 7388 |
|
|
|
| 7389 |
|
|
<p>Several features in XBL allow binding documents to be loaded.</p> |
| 7390 |
|
|
|
| 7391 |
|
|
<p>When the specification says that a binding document must be loaded |
| 7392 |
|
|
<em>unless it has already been loaded</em>, then references to the same |
| 7393 |
|
|
binding document (even if they are somewhat indirect, for example via |
| 7394 |
|
|
HTTP redirects) must result in the same <code>Document</code> instance |
| 7395 |
|
|
being reused, or shared.</p> |
| 7396 |
|
|
|
| 7397 |
|
|
<p>To determine if two binding documents are the same, their final base |
| 7398 |
|
|
URIs (after all redirects) are compared.</p> |
| 7399 |
|
|
|
| 7400 |
|
|
<div class=example> |
| 7401 |
|
|
<p>A <a href="#binding15">binding document</a> A contains a <code><a |
| 7402 |
|
|
href="#binding16">binding</a></code> element that refers to a second |
| 7403 |
|
|
binding document X. A new DOM <code>Document</code> instance is created |
| 7404 |
|
|
to represent that instance and the relevant bindings are used.</p> |
| 7405 |
|
|
|
| 7406 |
|
|
<p>Now assume RX is a resource that redirects to resource X using the |
| 7407 |
|
|
HTTP 301 redirection mechanism. A second <code><a |
| 7408 |
|
|
href="#binding16">binding</a></code> element in the binding document A |
| 7409 |
|
|
refers to resource RX. When that resource is being loaded, the redirect |
| 7410 |
|
|
to X would be discovered, and therefore instead of creating a new |
| 7411 |
|
|
<code>Document</code>, the existing one is reused.</p> |
| 7412 |
|
|
</div> |
| 7413 |
|
|
|
| 7414 |
|
|
<p>Such sharing of binding documents must be limited to binding documents |
| 7415 |
|
|
loaded by a document, its binding documents, its scripts, and its style |
| 7416 |
|
|
sheets. Nested documents and images do not share binding documents with |
| 7417 |
|
|
each other or with their container document.</p> |
| 7418 |
|
|
|
| 7419 |
|
|
<div class=example> |
| 7420 |
|
|
<p>For example, if a document uses a binding document, and its style |
| 7421 |
|
|
sheets use that binding document, the same binding document instance |
| 7422 |
|
|
will be used for both cases. However, if that document contains an |
| 7423 |
|
|
<code>iframe</code> whose document uses the same binding document, a new |
| 7424 |
|
|
instance will be used: the binding document instance from the outer |
| 7425 |
|
|
document is not reused.</p> |
| 7426 |
|
|
</div> |
| 7427 |
|
|
|
| 7428 |
|
|
<p>Binding documents that are currently loading count as binding documents |
| 7429 |
|
|
that are already loaded for the purposes of this reuse mechanism.</p> |
| 7430 |
|
|
|
| 7431 |
|
|
<h4 id=external><span class=secno>8.1.2. </span>External Resources</h4> |
| 7432 |
|
|
|
| 7433 |
|
|
<p>When the specification simply says that the external resource must be |
| 7434 |
|
|
loaded, without giving any caveats regarding multiple accesses of the |
| 7435 |
|
|
same resource, then each reference must instantiate a new unique copy of |
| 7436 |
|
|
the document.</p> |
| 7437 |
|
|
|
| 7438 |
|
|
<p class=example>For example, two <code><a href="#style2">style</a></code> |
| 7439 |
|
|
elements whose <code>src</code> attributes point to the same style sheet |
| 7440 |
|
|
must create two different <code>Stylesheet</code> instances, such that |
| 7441 |
|
|
mutating one does not affect the other.</p> |
| 7442 |
|
|
|
| 7443 |
|
|
<p>Several XBL attributes are defined to contain URIs. All URIs may be |
| 7444 |
|
|
relative. For relative URIs, the rules given in <a |
| 7445 |
|
|
href="#refsXMLBASE">[XMLBASE]</a> must be used to resolve the value to an |
| 7446 |
|
|
absolute URI.</p> |
| 7447 |
|
|
|
| 7448 |
|
|
<h3 id=loading0><span class=secno>8.2. </span><dfn id=loading6>Loading and |
| 7449 |
|
|
Running Scripts</dfn></h3> |
| 7450 |
|
|
|
| 7451 |
|
|
<p>Scripts in XBL may be found in <code><a |
| 7452 |
|
|
href="#script2">script</a></code>, <code><a |
| 7453 |
|
|
href="#implementation0">implementation</a></code>, and <code><a |
| 7454 |
|
|
href="#handler0">handler</a></code> elements, or in resources that those |
| 7455 |
|
|
elements point to.</p> |
| 7456 |
|
|
|
| 7457 |
|
|
<p>In the case of <code title=attr-script-src><a |
| 7458 |
|
|
href="#src2">script</a></code> and <code title=attr-implementation-src><a |
| 7459 |
|
|
href="#src">implementation</a></code> elements, if a <code |
| 7460 |
|
|
title="">src</code> attribute is present then the contents of the element |
| 7461 |
|
|
must be <span title="">ignored</span> (even if fetching the specified URI |
| 7462 |
|
|
fails).</p> |
| 7463 |
|
|
|
| 7464 |
|
|
<p>The rules for parsing the scripts are the same for all three elements, |
| 7465 |
|
|
but depend on the scripting language specified by the author.</p> |
| 7466 |
|
|
|
| 7467 |
|
|
<p>For non-XML languages, if the content is inline, UAs must concatenate |
| 7468 |
|
|
all the textual contents of text and CDATA child nodes, and must <a |
| 7469 |
|
|
href="#ignoring">ignore</a> any other, non-text nodes (such as elements |
| 7470 |
|
|
and comments) along with all their children. All descendant elements must |
| 7471 |
|
|
be processed, though, according to their semantics, before the XBL script |
| 7472 |
|
|
block itself is executed.</p> |
| 7473 |
|
|
|
| 7474 |
|
|
<div class=example> |
| 7475 |
|
|
<p>For example, in an XHTML-aware and ECMAScript-capable user agent, the |
| 7476 |
|
|
following ridiculous code would cause the alerts to appear in the order |
| 7477 |
|
|
One, Two, Three, and would set the <code title="">test</code> property |
| 7478 |
|
|
in the binding document's global script scope to the string |
| 7479 |
|
|
"undefinedABC":</p> |
| 7480 |
|
|
|
| 7481 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 7482 |
|
|
<!-- WARNING: THIS EXAMPLE IS NON-CONFORMING --> |
| 7483 |
|
|
<script> |
| 7484 |
|
|
alert('Two'); |
| 7485 |
|
|
test += "B"; |
| 7486 |
|
|
<script xmlns="http://www.w3.org/1999/xhtml"> |
| 7487 |
|
|
alert('One'); |
| 7488 |
|
|
test += "A"; |
| 7489 |
|
|
</script> |
| 7490 |
|
|
alert('Three'); |
| 7491 |
|
|
test += "C"; |
| 7492 |
|
|
</script> |
| 7493 |
|
|
</xbl></pre> |
| 7494 |
|
|
|
| 7495 |
|
|
<p>Authors must not ever consider doing this. The above is invalid.</p> |
| 7496 |
|
|
</div> |
| 7497 |
|
|
|
| 7498 |
|
|
<p>For XML-based scripting languages, handling of unknown elements and |
| 7499 |
|
|
other unexpected nodes must be defined by that language.</p> |
| 7500 |
|
|
|
| 7501 |
|
|
<p>If the content is not inline, then when the element is evaluated, the |
| 7502 |
|
|
resource specified by the <code title="">src</code> attribute must be |
| 7503 |
|
|
fetched. For <code><a href="#script2">script</a></code> elements, while |
| 7504 |
|
|
an external script is being fetched, any pending <a href="#binding19" |
| 7505 |
|
|
title="Binding Attachment Model">binding attachments</a> from the same |
| 7506 |
|
|
binding document must block, as must the evaluation of any further |
| 7507 |
|
|
<code><a href="#script2">script</a></code> blocks. For <code><a |
| 7508 |
|
|
href="#implementation0">implementation</a></code> elements, while the |
| 7509 |
|
|
external script is being fetched, the <a href="#binding19" title="Binding |
| 7510 |
|
|
Attachment Model">attachment</a> of that binding must block. If the |
| 7511 |
|
|
file's Content-Type (or equivalent for non-HTTP protocols), if any, is |
| 7512 |
|
|
not of the type <a href="#script-type" |
| 7513 |
|
|
title=attr-xbl-script-type>specified</a> on the <code><a |
| 7514 |
|
|
href="#xbl0">xbl</a></code> element, then the script must be ignored. |
| 7515 |
|
|
Otherwise, the contents of that file must be used directly, as specified |
| 7516 |
|
|
by the relevant language specification.</p> |
| 7517 |
|
|
|
| 7518 |
|
|
<h4 id=xforms><span class=secno>8.2.1. </span>XForms Actions</h4> |
| 7519 |
|
|
|
| 7520 |
|
|
<p><em>This section is only normative for implementations that support |
| 7521 |
|
|
XForms.</em></p> |
| 7522 |
|
|
|
| 7523 |
|
|
<p>It is theoretically possible to use XForms Actions as the scripting |
| 7524 |
|
|
language in XBL <a href="#refsXFORMS">[XFORMS]</a>. The MIME type that |
| 7525 |
|
|
indicates this scripting language is tentatively defined to be <code |
| 7526 |
|
|
class=mimetype>application/x-xforms-actions+xml</code>. XBL elements have |
| 7527 |
|
|
the following semantics when used with XForms Actions:</p> |
| 7528 |
|
|
|
| 7529 |
|
|
<dl> |
| 7530 |
|
|
<dt><code><a href="#script2">script</a></code> elements |
| 7531 |
|
|
|
| 7532 |
|
|
<dd>These are exactly equivalent to <code>xforms:action</code> elements |
| 7533 |
|
|
that trigger immediately upon being added to the document. |
| 7534 |
|
|
|
| 7535 |
|
|
<dt><code><a href="#handler0">handler</a></code> elements |
| 7536 |
|
|
|
| 7537 |
|
|
<dd>These are exactly equivalent to <code>xforms:action</code> elements |
| 7538 |
|
|
that trigger when the appropriate event on the bound element is |
| 7539 |
|
|
detected. |
| 7540 |
|
|
|
| 7541 |
|
|
<dt><code><a href="#implementation0">implementation</a></code> elements |
| 7542 |
|
|
|
| 7543 |
|
|
<dd>Since XForms Actions cannot declare new interfaces, <code><a |
| 7544 |
|
|
href="#implementation0">implementation</a></code> elements when the |
| 7545 |
|
|
script language is set to <code |
| 7546 |
|
|
class=mimetype>application/x-xforms-actions+xml</code> are <a |
| 7547 |
|
|
href="#in-error">in error</a> and the UA must <a |
| 7548 |
|
|
href="#ignoring">ignore</a> them, by treating <code><a |
| 7549 |
|
|
href="#implementation0">implementation</a></code> elements like |
| 7550 |
|
|
<code>xforms:action</code> elements that are not bound to any event. |
| 7551 |
|
|
</dl> |
| 7552 |
|
|
|
| 7553 |
|
|
<h4 id=scripting><span class=secno>8.2.2. </span>Scripting Model</h4> |
| 7554 |
|
|
|
| 7555 |
|
|
<p>Each document that runs script (including bound documents and binding |
| 7556 |
|
|
documents) has a <code>DocumentWindow</code> object, a |
| 7557 |
|
|
<code>Window</code> object, a global script scope, and a security |
| 7558 |
|
|
context. In ECMAScript, the global script scope and the |
| 7559 |
|
|
<code>Window</code> object are one and the same.</p> |
| 7560 |
|
|
|
| 7561 |
|
|
<p class=note>This above paragraph is a vague description of the Web's |
| 7562 |
|
|
de-facto scripting model. This specification depends on that model, but |
| 7563 |
|
|
it hasn't yet been specified in detail. This specification will be |
| 7564 |
|
|
updated when a suitable description is available.</p> |
| 7565 |
|
|
|
| 7566 |
|
|
<p>Script must always be executed in the context of the global script |
| 7567 |
|
|
scope of the document specified by the script's element's |
| 7568 |
|
|
<code>ownerDocument</code> DOM attribute. This implies that scripts from |
| 7569 |
|
|
different bindings in the same binding document bound to different |
| 7570 |
|
|
elements in the same bound document share the same scripting scope. If |
| 7571 |
|
|
the bindings were defined in the document itself, then the scope is the |
| 7572 |
|
|
same scope as for that document.</p> |
| 7573 |
|
|
|
| 7574 |
|
|
<p>A binding document must inherit the security context of the document to |
| 7575 |
|
|
which it is bound, not the security context of the domain from which it |
| 7576 |
|
|
was fetched<!--, unless the binding is marked |
| 7577 |
|
|
as <em>secure</em>. Secure bindings must use separate security |
| 7578 |
|
|
contexts appropriate for those given bindings-->.</p> |
| 7579 |
|
|
|
| 7580 |
|
|
<p>Scripting and security contexts are (or will be) described in the HTML5 |
| 7581 |
|
|
specification. <a href="#refsHTML5">[HTML5]</a></p> |
| 7582 |
|
|
|
| 7583 |
|
|
<p>In binding documents, the <code>location</code> and |
| 7584 |
|
|
<code>history</code> properties of the <code>Window</code> object, and |
| 7585 |
|
|
the <code>location</code> and <code>cookie</code> properties of the |
| 7586 |
|
|
<code>DocumentWindow</code> object, must return null, and any methods |
| 7587 |
|
|
that are defined in terms of the browsing context's session history must |
| 7588 |
|
|
do nothing. <a href="#refsHTML5">[HTML5]</a></p> |
| 7589 |
|
|
|
| 7590 |
|
|
<p>User agents should implement a security mechanism such as the proposed |
| 7591 |
|
|
<code><?access-control?></code> PI to prevent unauthorized |
| 7592 |
|
|
cross-domain access. <a href="#refsACCESSCONTROL">[ACCESSCONTROL]</a></p> |
| 7593 |
|
|
|
| 7594 |
|
|
<h3 id=loading1><span class=secno>8.3. </span><dfn id=loading7>Loading |
| 7595 |
|
|
Style Sheets</dfn></h3> |
| 7596 |
|
|
|
| 7597 |
|
|
<p>XBL <code><a href="#style2">style</a></code> elements describe the |
| 7598 |
|
|
style sheets that apply to bindings.</p> |
| 7599 |
|
|
|
| 7600 |
|
|
<p>If a <code><a href="#style2">style</a></code> element's <code |
| 7601 |
|
|
title=attr-style-src><a href="#src0">src</a></code> attribute is present, |
| 7602 |
|
|
the contents of the element must be <a href="#ignoring" |
| 7603 |
|
|
title=ignore>ignored</a> (even if fetching the specified URI failed). |
| 7604 |
|
|
Otherwise, it is the element's contents that give the style sheet.</p> |
| 7605 |
|
|
|
| 7606 |
|
|
<p>Wherever the style is found, the rules for parsing it are the same, but |
| 7607 |
|
|
depend on the language specified by the author.</p> |
| 7608 |
|
|
|
| 7609 |
|
|
<p>For non-XML styling languages, if the content is inline, UAs must |
| 7610 |
|
|
concatenate all the textual contents of text and CDATA child nodes, and |
| 7611 |
|
|
the UA must <a href="#ignoring">ignore</a> any other, non-text nodes |
| 7612 |
|
|
(such as elements and comments) along with all their children. All |
| 7613 |
|
|
descendant elements must be processed, though, according to their |
| 7614 |
|
|
semantics, before the XBL style block itself is parsed. A style element |
| 7615 |
|
|
labeled as containing a style sheet in a non-XML language yet containing |
| 7616 |
|
|
element nodes is <a href="#in-error">in error</a>.</p> |
| 7617 |
|
|
|
| 7618 |
|
|
<div class=example> |
| 7619 |
|
|
<p>For example, in an XHTML-aware and ECMAScript-capable user agent, the |
| 7620 |
|
|
rather dubious code below would result in a binding that enclosed the |
| 7621 |
|
|
bound element's children in a green box, not a red one:</p> |
| 7622 |
|
|
|
| 7623 |
|
|
<pre><xbl xmlns="http://www.w3.org/ns/xbl"> |
| 7624 |
|
|
<binding> |
| 7625 |
|
|
<template> |
| 7626 |
|
|
<div> |
| 7627 |
|
|
<content/> |
| 7628 |
|
|
</div> |
| 7629 |
|
|
</template> |
| 7630 |
|
|
<resources> |
| 7631 |
|
|
<style id="test"> |
| 7632 |
|
|
div { background: red; } |
| 7633 |
|
|
<script xmlns="http://www.w3.org/1999/xhtml"> |
| 7634 |
|
|
document.getElementById('test').firstChild.data = "div { background: green; }"; |
| 7635 |
|
|
</script> |
| 7636 |
|
|
<p xmlns="http://www.w3.org/1999/xhtml"> |
| 7637 |
|
|
div { border: red solid; } |
| 7638 |
|
|
This will either be ignored by the XBL user agent, or will cause |
| 7639 |
|
|
it to abort all processing altogether, as this text node is not a |
| 7640 |
|
|
child of the style element. |
| 7641 |
|
|
</p> |
| 7642 |
|
|
</style> |
| 7643 |
|
|
</resources> |
| 7644 |
|
|
</binding> |
| 7645 |
|
|
</xbl></pre> |
| 7646 |
|
|
</div> |
| 7647 |
|
|
|
| 7648 |
|
|
<p>For XML-based styling languages, handling of unknown elements and other |
| 7649 |
|
|
unexpected nodes must be defined by that language.</p> |
| 7650 |
|
|
|
| 7651 |
|
|
<p>If the content was in another resource, and the Content-Type (or |
| 7652 |
|
|
equivalent for non-HTTP protocols), if any, was of the type specified on |
| 7653 |
|
|
the <code><a href="#xbl0">xbl</a></code> element (or implied by its |
| 7654 |
|
|
absence), then the contents of that file must be used directly, as |
| 7655 |
|
|
specified by the relevant language specification. Otherwise, the <code><a |
| 7656 |
|
|
href="#style2">style</a></code> element doesn't provide any styling. The |
| 7657 |
|
|
<code title=attr-style-src><a href="#src0">src</a></code> attribute must |
| 7658 |
|
|
only be examined once all of the element's children have been processed |
| 7659 |
|
|
(if any).</p> |
| 7660 |
|
|
|
| 7661 |
|
|
<h3 id=interpretation><span class=secno>8.4. </span><dfn |
| 7662 |
|
|
id=interpretation1>Interpretation of URIs to XBL bindings</dfn></h3> |
| 7663 |
|
|
|
| 7664 |
|
|
<p>XBL attachment mechanisms use a URI to specify which binding to attach |
| 7665 |
|
|
to the designated element.</p> |
| 7666 |
|
|
|
| 7667 |
|
|
<div class=example> |
| 7668 |
|
|
<p>For example:</p> |
| 7669 |
|
|
|
| 7670 |
|
|
<pre>my|foo { |
| 7671 |
|
|
binding: url("<strong>http://www.example.org/bindings.xml#fooBinding</strong>"); |
| 7672 |
|
|
}</pre> |
| 7673 |
|
|
</div> |
| 7674 |
|
|
|
| 7675 |
|
|
<p>This section defines how these URIs, which are used in the argument to |
| 7676 |
|
|
the <code><a href="#addbinding">addBinding()</a></code> method, and in |
| 7677 |
|
|
the value of the '<code title="binding property"><a |
| 7678 |
|
|
href="#binding18">binding</a></code>' property, are to be interpreted.</p> |
| 7679 |
|
|
|
| 7680 |
|
|
<p>The URI specifies a particular <a href="#binding15">binding |
| 7681 |
|
|
document</a> (an <a href="#xbl-document">XBL document</a> or <a |
| 7682 |
|
|
href="#non-xbl">non-XBL document</a> containing one or more XBL |
| 7683 |
|
|
subtrees). The user agent must fetch this resource (unless it has <a |
| 7684 |
|
|
href="#loading5" title="loading external resources">already been |
| 7685 |
|
|
loaded</a>).</p> |
| 7686 |
|
|
|
| 7687 |
|
|
<p>If the URI contains a fragment identifier, then it must be processed as |
| 7688 |
|
|
described in the relevant MIME type definition. The element targeted by |
| 7689 |
|
|
the fragment identifier must be a <code><a |
| 7690 |
|
|
href="#binding16">binding</a></code> element within an XBL subtree in the |
| 7691 |
|
|
specified document, and that element must be a direct child of an |
| 7692 |
|
|
<code><a href="#xbl0">xbl</a></code> element that does not itself have an |
| 7693 |
|
|
<code><a href="#xbl0">xbl</a></code> element as an ancestor; if these |
| 7694 |
|
|
conditions are not met then the URI is <a href="#in-error">in error</a>.</p> |
| 7695 |
|
|
|
| 7696 |
|
|
<p class=example>For example, if the binding document is sent as |
| 7697 |
|
|
<code>application/xhtml+xml</code>, and the fragment identifier matches a |
| 7698 |
|
|
<code><a href="#binding16">binding</a></code> element's <code |
| 7699 |
|
|
title=attr-id><a href="#id13">id</a></code> attribute, then that is the |
| 7700 |
|
|
binding that is attached.</p> |
| 7701 |
|
|
|
| 7702 |
|
|
<p>If there is no fragment identifier and the URI points to an XBL |
| 7703 |
|
|
document (not a <a href="#non-xbl">non-XBL document</a>) then the first |
| 7704 |
|
|
<code><a href="#binding16">binding</a></code> element in the binding |
| 7705 |
|
|
document that is a child of the root <code><a href="#xbl0">xbl</a></code> |
| 7706 |
|
|
element is selected. Otherwise, the URI does not point to a <a |
| 7707 |
|
|
href="#correct">correct</a> binding and is <a href="#in-error">in |
| 7708 |
|
|
error</a>.</p> |
| 7709 |
|
|
|
| 7710 |
|
|
<p>When an attachment mechanism uses a URI that is <a href="#in-error">in |
| 7711 |
|
|
error</a> (as per the last two paragraphs), then the user agent must act |
| 7712 |
|
|
as if the attachment mechanism had not specified that binding.</p> |
| 7713 |
|
|
|
| 7714 |
|
|
<p>Otherwise, the specified binding is attached to the element, as |
| 7715 |
|
|
described for the relevant attachment mechanism.</p> |
| 7716 |
|
|
|
| 7717 |
|
|
<h2 id=summaries><span class=secno>9. </span>Summaries of Elements, |
| 7718 |
|
|
Attributes, and Events</h2> |
| 7719 |
|
|
|
| 7720 |
|
|
<h3 id=elements><span class=secno>9.1. </span>Elements and Attributes</h3> |
| 7721 |
|
|
|
| 7722 |
|
|
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span></p> |
| 7723 |
|
|
|
| 7724 |
|
|
<table> |
| 7725 |
|
|
<thead> |
| 7726 |
|
|
<tr> |
| 7727 |
|
|
<th>Element |
| 7728 |
|
|
|
| 7729 |
|
|
<th>Attributes |
| 7730 |
|
|
|
| 7731 |
|
|
<th>Content Model |
| 7732 |
|
|
|
| 7733 |
|
|
<tbody> |
| 7734 |
|
|
<tr> |
| 7735 |
|
|
<td><code><a href="#xbl0">xbl</a></code> |
| 7736 |
|
|
|
| 7737 |
|
|
<td> |
| 7738 |
|
|
<ul> |
| 7739 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7740 |
|
|
|
| 7741 |
|
|
<li><code title=attr-xbl-script-type><a |
| 7742 |
|
|
href="#script-type">script-type</a></code> |
| 7743 |
|
|
|
| 7744 |
|
|
<li><code title=attr-xbl-style-type><a |
| 7745 |
|
|
href="#style-type">style-type</a></code> |
| 7746 |
|
|
</ul> |
| 7747 |
|
|
|
| 7748 |
|
|
<td> |
| 7749 |
|
|
<ul> |
| 7750 |
|
|
<li><code><a href="#binding16">binding</a></code> |
| 7751 |
|
|
|
| 7752 |
|
|
<li><code><a href="#script2">script</a></code> |
| 7753 |
|
|
|
| 7754 |
|
|
<li>Non-XBL elements |
| 7755 |
|
|
</ul> |
| 7756 |
|
|
|
| 7757 |
|
|
<tr> |
| 7758 |
|
|
<td><code><a href="#binding16">binding</a></code> |
| 7759 |
|
|
|
| 7760 |
|
|
<td> |
| 7761 |
|
|
<ul> |
| 7762 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7763 |
|
|
|
| 7764 |
|
|
<li><code title=attr-binding-extends><a |
| 7765 |
|
|
href="#extends">extends</a></code> |
| 7766 |
|
|
|
| 7767 |
|
|
<li><code title=attr-binding-element><a |
| 7768 |
|
|
href="#element">element</a></code> |
| 7769 |
|
|
</ul> |
| 7770 |
|
|
|
| 7771 |
|
|
<td> |
| 7772 |
|
|
<ul> |
| 7773 |
|
|
<li><code><a href="#implementation0">implementation</a></code> |
| 7774 |
|
|
|
| 7775 |
|
|
<li><code><a href="#template0">template</a></code> |
| 7776 |
|
|
|
| 7777 |
|
|
<li><code><a href="#handlers0">handlers</a></code> |
| 7778 |
|
|
|
| 7779 |
|
|
<li><code><a href="#resources1">resources</a></code> |
| 7780 |
|
|
|
| 7781 |
|
|
<li>Non-XBL elements |
| 7782 |
|
|
</ul> |
| 7783 |
|
|
|
| 7784 |
|
|
<tr> |
| 7785 |
|
|
<td><code><a href="#implementation0">implementation</a></code> |
| 7786 |
|
|
|
| 7787 |
|
|
<td> |
| 7788 |
|
|
<ul> |
| 7789 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7790 |
|
|
|
| 7791 |
|
|
<li><code title=attr-implementation-src><a href="#src">src</a></code> |
| 7792 |
|
|
|
| 7793 |
|
|
</ul> |
| 7794 |
|
|
|
| 7795 |
|
|
<td> |
| 7796 |
|
|
<ul> |
| 7797 |
|
|
<li>Script |
| 7798 |
|
|
</ul> |
| 7799 |
|
|
|
| 7800 |
|
|
<tr> |
| 7801 |
|
|
<td><code><a href="#template0">template</a></code> |
| 7802 |
|
|
|
| 7803 |
|
|
<td> |
| 7804 |
|
|
<ul> |
| 7805 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7806 |
|
|
|
| 7807 |
|
|
<li><code title=attr-template-apply-author-sheets><a |
| 7808 |
|
|
href="#apply-author-sheets">apply-author-sheets</a></code> |
| 7809 |
|
|
|
| 7810 |
|
|
<li><code title=attr-template-allow-selectors-through><a |
| 7811 |
|
|
href="#allow-selectors-through">allow-selectors-through</a></code> |
| 7812 |
|
|
</ul> |
| 7813 |
|
|
|
| 7814 |
|
|
<td> |
| 7815 |
|
|
<ul> |
| 7816 |
|
|
<li><code><a href="#div0">div</a></code> |
| 7817 |
|
|
|
| 7818 |
|
|
<li><code><a href="#content0">content</a></code> |
| 7819 |
|
|
|
| 7820 |
|
|
<li><code><a href="#inherited0">inherited</a></code> |
| 7821 |
|
|
|
| 7822 |
|
|
<li>Non-XBL elements, optionally with <code title=attr-attr><a |
| 7823 |
|
|
href="#xblattr0">xbl:attr</a></code> and <code title=attr-pseudo><a |
| 7824 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attributes |
| 7825 |
|
|
</ul> |
| 7826 |
|
|
|
| 7827 |
|
|
<tr> |
| 7828 |
|
|
<td><code><a href="#content0">content</a></code> |
| 7829 |
|
|
|
| 7830 |
|
|
<td> |
| 7831 |
|
|
<ul> |
| 7832 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7833 |
|
|
|
| 7834 |
|
|
<li><code title=attr-content-includes><a |
| 7835 |
|
|
href="#includes">includes</a></code> |
| 7836 |
|
|
|
| 7837 |
|
|
<li><code title=attr-content-apply-binding-sheets><a |
| 7838 |
|
|
href="#apply-binding-sheets">apply-author-sheets</a></code> |
| 7839 |
|
|
|
| 7840 |
|
|
<li><code title=attr-content-locked><a |
| 7841 |
|
|
href="#locked">locked</a></code> |
| 7842 |
|
|
</ul> |
| 7843 |
|
|
|
| 7844 |
|
|
<td> |
| 7845 |
|
|
<ul> |
| 7846 |
|
|
<li><code><a href="#div0">div</a></code> |
| 7847 |
|
|
|
| 7848 |
|
|
<li><code><a href="#inherited0">inherited</a></code> |
| 7849 |
|
|
|
| 7850 |
|
|
<li>Non-XBL elements, optionally with <code title=attr-attr><a |
| 7851 |
|
|
href="#xblattr0">xbl:attr</a></code> and <code title=attr-pseudo><a |
| 7852 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attributes |
| 7853 |
|
|
</ul> |
| 7854 |
|
|
|
| 7855 |
|
|
<tr> |
| 7856 |
|
|
<td><code><a href="#inherited0">inherited</a></code> |
| 7857 |
|
|
|
| 7858 |
|
|
<td> |
| 7859 |
|
|
<ul> |
| 7860 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7861 |
|
|
</ul> |
| 7862 |
|
|
|
| 7863 |
|
|
<td> |
| 7864 |
|
|
<ul> |
| 7865 |
|
|
<li><code><a href="#div0">div</a></code> |
| 7866 |
|
|
|
| 7867 |
|
|
<li><code><a href="#content0">content</a></code> |
| 7868 |
|
|
|
| 7869 |
|
|
<li>Non-XBL elements, optionally with <code title=attr-attr><a |
| 7870 |
|
|
href="#xblattr0">xbl:attr</a></code> and <code title=attr-pseudo><a |
| 7871 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attributes |
| 7872 |
|
|
</ul> |
| 7873 |
|
|
|
| 7874 |
|
|
<tr> |
| 7875 |
|
|
<td><code><a href="#div0">div</a></code> |
| 7876 |
|
|
|
| 7877 |
|
|
<td> |
| 7878 |
|
|
<ul> |
| 7879 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7880 |
|
|
|
| 7881 |
|
|
<li><code title=attr-div-class><a href="#class">class</a></code> |
| 7882 |
|
|
|
| 7883 |
|
|
<li><code title=attr-div-state><a href="#state">state</a></code> |
| 7884 |
|
|
|
| 7885 |
|
|
<li><code title=attr-div-title><a href="#title">title</a></code> |
| 7886 |
|
|
|
| 7887 |
|
|
<li><code title=attr-attr><a href="#xblattr0">xbl:attr</a></code> |
| 7888 |
|
|
|
| 7889 |
|
|
<li><code title=attr-pseudo><a |
| 7890 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> |
| 7891 |
|
|
</ul> |
| 7892 |
|
|
|
| 7893 |
|
|
<td> |
| 7894 |
|
|
<ul> |
| 7895 |
|
|
<li><code><a href="#div0">div</a></code> |
| 7896 |
|
|
|
| 7897 |
|
|
<li><code><a href="#content0">content</a></code> |
| 7898 |
|
|
|
| 7899 |
|
|
<li><code><a href="#inherited0">inherited</a></code> |
| 7900 |
|
|
|
| 7901 |
|
|
<li>Non-XBL elements, optionally with <code title=attr-attr><a |
| 7902 |
|
|
href="#xblattr0">xbl:attr</a></code> and <code title=attr-pseudo><a |
| 7903 |
|
|
href="#xblpseudo0">xbl:pseudo</a></code> attributes |
| 7904 |
|
|
</ul> |
| 7905 |
|
|
|
| 7906 |
|
|
<tr> |
| 7907 |
|
|
<td><code><a href="#handlers0">handlers</a></code> |
| 7908 |
|
|
|
| 7909 |
|
|
<td> |
| 7910 |
|
|
<ul> |
| 7911 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7912 |
|
|
</ul> |
| 7913 |
|
|
|
| 7914 |
|
|
<td> |
| 7915 |
|
|
<ul> |
| 7916 |
|
|
<li><code><a href="#handler0">handler</a></code> |
| 7917 |
|
|
</ul> |
| 7918 |
|
|
|
| 7919 |
|
|
<tr> |
| 7920 |
|
|
<td><code><a href="#handler0">handler</a></code> |
| 7921 |
|
|
|
| 7922 |
|
|
<td> |
| 7923 |
|
|
<ul> |
| 7924 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7925 |
|
|
|
| 7926 |
|
|
<li><code title=attr-handler-event><a href="#event9">event</a></code> |
| 7927 |
|
|
|
| 7928 |
|
|
|
| 7929 |
|
|
<li><code title=attr-handler-phase><a href="#phase">phase</a></code> |
| 7930 |
|
|
|
| 7931 |
|
|
<li><code title=attr-handler-trusted><a |
| 7932 |
|
|
href="#trusted">trusted</a></code> |
| 7933 |
|
|
|
| 7934 |
|
|
<li><code title=attr-handler-propagate><a |
| 7935 |
|
|
href="#propagate">propagate</a></code> |
| 7936 |
|
|
|
| 7937 |
|
|
<li><code title=attr-handler-default-action><a |
| 7938 |
|
|
href="#default-action">default-action</a></code> |
| 7939 |
|
|
|
| 7940 |
|
|
<li><code title=attr-handler-button><a |
| 7941 |
|
|
href="#button">button</a></code> |
| 7942 |
|
|
|
| 7943 |
|
|
<li><code title=attr-handler-click-count><a |
| 7944 |
|
|
href="#click-count">click-count</a></code> |
| 7945 |
|
|
|
| 7946 |
|
|
<li><code title=attr-handler-modifiers><a |
| 7947 |
|
|
href="#modifiers1">modifiers</a></code> |
| 7948 |
|
|
|
| 7949 |
|
|
<li><code title=attr-handler-key><a href="#key">key</a></code> |
| 7950 |
|
|
|
| 7951 |
|
|
<li><code title=attr-handler-key-location><a |
| 7952 |
|
|
href="#key-location">key-location</a></code> |
| 7953 |
|
|
|
| 7954 |
|
|
<li><code title=attr-handler-text><a href="#text">text</a></code> |
| 7955 |
|
|
|
| 7956 |
|
|
<li><code title=attr-handler-prev-value><a |
| 7957 |
|
|
href="#prev-value">prev-value</a></code> |
| 7958 |
|
|
|
| 7959 |
|
|
<li><code title=attr-handler-new-value><a |
| 7960 |
|
|
href="#new-value">new-value</a></code> |
| 7961 |
|
|
|
| 7962 |
|
|
<li><code title=attr-handler-attr-name><a |
| 7963 |
|
|
href="#attr-name">attr-name</a></code> |
| 7964 |
|
|
|
| 7965 |
|
|
<li><code title=attr-handler-attr-change><a |
| 7966 |
|
|
href="#attr-change">attr-change</a></code> |
| 7967 |
|
|
</ul> |
| 7968 |
|
|
|
| 7969 |
|
|
<td> |
| 7970 |
|
|
<ul> |
| 7971 |
|
|
<li>Script |
| 7972 |
|
|
</ul> |
| 7973 |
|
|
|
| 7974 |
|
|
<tr> |
| 7975 |
|
|
<td><code><a href="#resources1">resources</a></code> |
| 7976 |
|
|
|
| 7977 |
|
|
<td> |
| 7978 |
|
|
<ul> |
| 7979 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7980 |
|
|
</ul> |
| 7981 |
|
|
|
| 7982 |
|
|
<td> |
| 7983 |
|
|
<ul> |
| 7984 |
|
|
<li><code><a href="#style2">style</a></code> |
| 7985 |
|
|
|
| 7986 |
|
|
<li><code><a href="#prefetch0">prefetch</a></code> |
| 7987 |
|
|
</ul> |
| 7988 |
|
|
|
| 7989 |
|
|
<tr> |
| 7990 |
|
|
<td><code><a href="#style2">style</a></code> |
| 7991 |
|
|
|
| 7992 |
|
|
<td> |
| 7993 |
|
|
<ul> |
| 7994 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 7995 |
|
|
|
| 7996 |
|
|
<li><code title=attr-style-media><a href="#media">media</a></code> |
| 7997 |
|
|
|
| 7998 |
|
|
<li><code title=attr-style-src><a href="#src0">src</a></code> |
| 7999 |
|
|
</ul> |
| 8000 |
|
|
|
| 8001 |
|
|
<td> |
| 8002 |
|
|
<ul> |
| 8003 |
|
|
<li>Style |
| 8004 |
|
|
</ul> |
| 8005 |
|
|
|
| 8006 |
|
|
<tr> |
| 8007 |
|
|
<td><code><a href="#prefetch0">prefetch</a></code> |
| 8008 |
|
|
|
| 8009 |
|
|
<td> |
| 8010 |
|
|
<ul> |
| 8011 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 8012 |
|
|
|
| 8013 |
|
|
<li><code title=attr-prefetch-src><a href="#src1">src</a></code> |
| 8014 |
|
|
</ul> |
| 8015 |
|
|
|
| 8016 |
|
|
<td> |
| 8017 |
|
|
|
| 8018 |
|
|
<tr> |
| 8019 |
|
|
<td><code><a href="#script2">script</a></code> |
| 8020 |
|
|
|
| 8021 |
|
|
<td> |
| 8022 |
|
|
<ul> |
| 8023 |
|
|
<li><code title=attr-id><a href="#id13">id</a></code> |
| 8024 |
|
|
|
| 8025 |
|
|
<li><code title=attr-script-src><a href="#src2">src</a></code> |
| 8026 |
|
|
</ul> |
| 8027 |
|
|
|
| 8028 |
|
|
<td> |
| 8029 |
|
|
<ul> |
| 8030 |
|
|
<li>Script |
| 8031 |
|
|
</ul> |
| 8032 |
|
|
</table> |
| 8033 |
|
|
|
| 8034 |
|
|
<h3 id=events><span class=secno>9.2. </span>Events</h3> |
| 8035 |
|
|
|
| 8036 |
|
|
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span></p> |
| 8037 |
|
|
|
| 8038 |
|
|
<table> |
| 8039 |
|
|
<thead> |
| 8040 |
|
|
<tr> |
| 8041 |
|
|
<th>Event Name |
| 8042 |
|
|
|
| 8043 |
|
|
<th>Interface |
| 8044 |
|
|
|
| 8045 |
|
|
<th>Target when fired by UA |
| 8046 |
|
|
|
| 8047 |
|
|
<th>Bubbles? |
| 8048 |
|
|
|
| 8049 |
|
|
<th>Cancelable? |
| 8050 |
|
|
|
| 8051 |
|
|
<th>Default Action |
| 8052 |
|
|
|
| 8053 |
|
|
<tbody> |
| 8054 |
|
|
<tr> |
| 8055 |
|
|
<td><code title=xbl-bound><a href="#xbl-bound">xbl-bound</a></code> |
| 8056 |
|
|
|
| 8057 |
|
|
<td><code>Event</code> |
| 8058 |
|
|
|
| 8059 |
|
|
<td>Bound element |
| 8060 |
|
|
|
| 8061 |
|
|
<td>✓ Bubbles |
| 8062 |
|
|
|
| 8063 |
|
|
<td>— |
| 8064 |
|
|
|
| 8065 |
|
|
<td>None |
| 8066 |
|
|
|
| 8067 |
|
|
<tr> |
| 8068 |
|
|
<td><code title=xbl-bindings-are-ready><a |
| 8069 |
|
|
href="#xbl-bindings-are-ready">xbl-bindings-are-ready</a></code> |
| 8070 |
|
|
|
| 8071 |
|
|
<td><code>Event</code> |
| 8072 |
|
|
|
| 8073 |
|
|
<td>Bound document's root element |
| 8074 |
|
|
|
| 8075 |
|
|
<td>✓ Bubbles |
| 8076 |
|
|
|
| 8077 |
|
|
<td>— |
| 8078 |
|
|
|
| 8079 |
|
|
<td>None |
| 8080 |
|
|
</table> |
| 8081 |
|
|
|
| 8082 |
|
|
<h3 id=implementations><span class=secno>9.3. </span>Implementations</h3> |
| 8083 |
|
|
|
| 8084 |
|
|
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span></p> |
| 8085 |
|
|
|
| 8086 |
|
|
<p>The properties of the <a href="#internal">internal object</a> are:</p> |
| 8087 |
|
|
|
| 8088 |
|
|
<ul class=brief> |
| 8089 |
|
|
<li><code><a href="#external1">external</a></code> |
| 8090 |
|
|
|
| 8091 |
|
|
<li><code><a href="#boundelement">boundElement</a></code> |
| 8092 |
|
|
|
| 8093 |
|
|
<li><code><a href="#shadowtree">shadowTree</a></code> |
| 8094 |
|
|
|
| 8095 |
|
|
<li><code><a href="#basebinding">baseBinding</a></code> |
| 8096 |
|
|
</ul> |
| 8097 |
|
|
|
| 8098 |
|
|
<p>The methods that binding implementations can support are:</p> |
| 8099 |
|
|
|
| 8100 |
|
|
<ul class=brief> |
| 8101 |
|
|
<li><code><a href="#xblbindingattached">xblBindingAttached()</a></code> |
| 8102 |
|
|
|
| 8103 |
|
|
<li><code><a href="#xblentereddocument">xblEnteredDocument()</a></code> |
| 8104 |
|
|
|
| 8105 |
|
|
<li><code><a href="#xblleftdocument">xblLeftDocument()</a></code> |
| 8106 |
|
|
</ul> |
| 8107 |
|
|
|
| 8108 |
|
|
<h2 class=no-num id=acknowledgments>Acknowledgments</h2> |
| 8109 |
|
|
|
| 8110 |
|
|
<p>David Hyatt developed XBL 1.0 and provided guidance for the development |
| 8111 |
|
|
of XBL 2.0.</p> |
| 8112 |
|
|
|
| 8113 |
|
|
<p>The editor would like to thank Alex Danilo, Alex Vincent, Anne van |
| 8114 |
|
|
Kesteren, Axel Hecht, Antoine Quint, Benjamin Smedberg, Bjoern Hoehrmann, |
| 8115 |
|
|
Boris Zbarsky, Brendan Eich, Cameron McCormack, Chris Lilley, Christophe |
| 8116 |
|
|
Jolif, Cyril Concolato, Darryl Fuller, David Håsäther, Dean |
| 8117 |
|
|
Jackson, Jon Ferraiolo, Jonas Sicking, Karl Dubost, L. David Baron, |
| 8118 |
|
|
Lachlan Hunt, Liam Quin, Marcos Caceres, Mark Baker, Micah Dubinko, Mihai |
| 8119 |
|
|
Sucan, Mikko Pohja, Mohamed Zergaoui, Norman Walsh, Peter Sorotokin, |
| 8120 |
|
|
Robin Berjon, Ruud Steltenpool, Sean Hogan, Simon Pieters, Steve K. |
| 8121 |
|
|
Speicher, Steve Zilles, Tim Rowley, and Tom Pike for their contributions |
| 8122 |
|
|
to this specification.</p> |
| 8123 |
|
|
|
| 8124 |
|
|
<h2 class=no-num id=references><span class=ja-translation lang=ja>参考文献</span></h2> |
| 8125 |
|
|
|
| 8126 |
|
|
<p>All references are normative unless prefixed by the mark |
| 8127 |
|
|
"(Informative)".</p> |
| 8128 |
|
|
|
| 8129 |
|
|
<dl> |
| 8130 |
|
|
<dt id=refsACCESSCONTROL>[ACCESSCONTROL] |
| 8131 |
|
|
|
| 8132 |
|
|
<dd>(Informative) <cite><a |
| 8133 |
|
|
href="http://www.w3.org/TR/2005/NOTE-access-control-20050613/">Authorizing |
| 8134 |
|
|
Read Access to XML Content Using the <?access-control?> Processing |
| 8135 |
|
|
Instruction 1.0</a></cite>, M. Oshry, B. Porter, R. Auburn. W3C, June |
| 8136 |
|
|
2005. The latest version of this specification is available at <a |
| 8137 |
|
|
href="http://www.w3.org/TR/access-control/">http://www.w3.org/TR/access-control/</a> |
| 8138 |
|
|
|
| 8139 |
|
|
<dt id=refsCSS21>[CSS21] |
| 8140 |
|
|
|
| 8141 |
|
|
<dd><cite><a href="http://www.w3.org/TR/2004/CR-CSS21-20040225/">CSS 2.1 |
| 8142 |
|
|
Specification</a></cite>, B. Bos, T. Çelik, I. Hickson, H. Lie. |
| 8143 |
|
|
W3C, September 2003. The latest version of the CSS 2.1 specification is |
| 8144 |
|
|
available at <a |
| 8145 |
|
|
href="http://www.w3.org/TR/CSS21/">http://www.w3.org/TR/CSS21/</a> |
| 8146 |
|
|
|
| 8147 |
|
|
<dt id=refsCSS3UI>[CSS3UI] |
| 8148 |
|
|
|
| 8149 |
|
|
<dd><cite><a href="http://www.w3.org/TR/2004/CR-css3-ui-20040511/">CSS3 |
| 8150 |
|
|
Basic User Interface Module</a></cite>, T. Çelik. W3C, May 2004. |
| 8151 |
|
|
The latest version of the CSS3 UI module is available at <a |
| 8152 |
|
|
href="http://www.w3.org/TR/css3-ui/">http://www.w3.org/TR/css3-ui/</a> |
| 8153 |
|
|
|
| 8154 |
|
|
<dt id=refsDOM2VIEWS>[DOM2VIEWS] |
| 8155 |
|
|
|
| 8156 |
|
|
<dd><cite><a |
| 8157 |
|
|
href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113/">Document |
| 8158 |
|
|
Object Model (DOM) Level 2 Views Specification</a></cite>, A. Le Hors, |
| 8159 |
|
|
L. Cable. W3C, November 2000. The latest version of the DOM Level 2 |
| 8160 |
|
|
Views specification is available at <a |
| 8161 |
|
|
href="http://www.w3.org/TR/DOM-Level-2-Views/">http://www.w3.org/TR/DOM-Level-2-Views/</a> |
| 8162 |
|
|
|
| 8163 |
|
|
<dt id=refsDOM3CORE>[DOM3CORE] |
| 8164 |
|
|
|
| 8165 |
|
|
<dd><cite><a |
| 8166 |
|
|
href="http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/">Document |
| 8167 |
|
|
Object Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. |
| 8168 |
|
|
Le Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne. |
| 8169 |
|
|
W3C, November 2003. The latest version of the DOM Level 3 Core |
| 8170 |
|
|
specification is available at <a |
| 8171 |
|
|
href="http://www.w3.org/TR/DOM-Level-3-Core/">http://www.w3.org/TR/DOM-Level-3-Core/</a> |
| 8172 |
|
|
|
| 8173 |
|
|
<dt id=refsDOM3EVENTS>[DOM3EVENTS] |
| 8174 |
|
|
|
| 8175 |
|
|
<dd><cite><a |
| 8176 |
|
|
href="http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/">Document |
| 8177 |
|
|
Object Model (DOM) Level 3 Events Specification</a></cite>, P. Le |
| 8178 |
|
|
Hégaret, T. Pixley. W3C, November 2003. (Note: Despite its |
| 8179 |
|
|
non-normative status on the W3C Recommendation track, this specification |
| 8180 |
|
|
should be considered normative for the purposes of conformance.) The |
| 8181 |
|
|
latest version of the DOM Level 3 Events specification is available at |
| 8182 |
|
|
<a |
| 8183 |
|
|
href="http://www.w3.org/TR/DOM-Level-3-Events/">http://www.w3.org/TR/DOM-Level-3-Events/</a> |
| 8184 |
|
|
|
| 8185 |
|
|
<dt id=refsECMA262>[ECMA262] |
| 8186 |
|
|
|
| 8187 |
|
|
<dd><cite><a |
| 8188 |
|
|
href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript |
| 8189 |
|
|
Language Specification</a></cite>, Third Edition. ECMA, December 1999. |
| 8190 |
|
|
This version of the ECMAScript Language is available at |
| 8191 |
|
|
http://www.ecma-international.org/publications/standards/Ecma-262.htm |
| 8192 |
|
|
|
| 8193 |
|
|
<dd>(Informative) <cite><a |
| 8194 |
|
|
href="http://developer.mozilla.org/es4/spec/spec.html">ECMAScript |
| 8195 |
|
|
Language Specification</a></cite>, Fourth Edition (Incomplete Draft |
| 8196 |
|
|
Proposal). ECMA, January 2006. This version of the ECMAScript Language |
| 8197 |
|
|
is available at http://developer.mozilla.org/es4/spec/spec.html |
| 8198 |
|
|
|
| 8199 |
|
|
<dt id=refsHTC>[HTC] |
| 8200 |
|
|
|
| 8201 |
|
|
<dd>(Informative) <cite><a |
| 8202 |
|
|
href="http://www.w3.org/TR/1998/NOTE-HTMLComponents-19981023">HTML |
| 8203 |
|
|
Components</a></cite>, C. Wilson. Microsoft, September 1998. The HTML |
| 8204 |
|
|
Components submission is available at |
| 8205 |
|
|
http://www.w3.org/TR/1998/NOTE-HTMLComponents-19981023 |
| 8206 |
|
|
|
| 8207 |
|
|
<dt id=refsHTML5>[HTML5] |
| 8208 |
|
|
|
| 8209 |
|
|
<dd>(Informative) <cite><a |
| 8210 |
|
|
href="http://whatwg.org/specs/web-apps/current-work/">Web Applications |
| 8211 |
|
|
1.0</a></cite>, I. Hickson. WHATWG, work in progress. The latest version |
| 8212 |
|
|
of the HTML5 proposal is at |
| 8213 |
|
|
http://whatwg.org/specs/web-apps/current-work/ |
| 8214 |
|
|
|
| 8215 |
|
|
<dt id=refsMQ>[MQ] |
| 8216 |
|
|
|
| 8217 |
|
|
<dd><cite><a |
| 8218 |
|
|
href="http://www.w3.org/TR/2002/CR-css3-mediaqueries-20020708/">Media |
| 8219 |
|
|
Queries</a></cite>, H. Lie, T. Çelik, D Glazman. W3C, July 2002. |
| 8220 |
|
|
The latest version of Media Queries is available at <a |
| 8221 |
|
|
href="http://www.w3.org/TR/css3-mediaqueries/">http://www.w3.org/TR/css3-mediaqueries/</a> |
| 8222 |
|
|
|
| 8223 |
|
|
<dt id=refsRFC2045>[RFC2045] |
| 8224 |
|
|
|
| 8225 |
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2045">Multipurpose Internet |
| 8226 |
|
|
Mail Extensions (MIME) Part One: Format of Internet Message |
| 8227 |
|
|
Bodies</a></cite>, N. Freed, N. Borenstein. IETF, November 1996. RFC |
| 8228 |
|
|
2045 is available at http://www.ietf.org/rfc/rfc2045 |
| 8229 |
|
|
|
| 8230 |
|
|
<dt id=refsRFC2119>[RFC2119] |
| 8231 |
|
|
|
| 8232 |
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc2119.txt">Key words for use |
| 8233 |
|
|
in RFCs to Indicate Requirement Levels</a></cite>, S. Bradner. IETF, |
| 8234 |
|
|
March 1997. RFC 2119 is available at http://www.ietf.org/rfc/rfc2119.txt |
| 8235 |
|
|
|
| 8236 |
|
|
<dt id=refsRFC3986>[RFC3986] |
| 8237 |
|
|
|
| 8238 |
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc3986">Uniform Resource |
| 8239 |
|
|
Identifier (URI): Generic Syntax</a></cite>, T. Berners-Lee, R. |
| 8240 |
|
|
Fielding, L. Masinter. IETF, January 2005. RFC 3986 is available at |
| 8241 |
|
|
http://www.ietf.org/rfc/rfc3986 |
| 8242 |
|
|
|
| 8243 |
|
|
<dt id=refsRFC3987>[RFC3987] |
| 8244 |
|
|
|
| 8245 |
|
|
<dd><cite><a href="http://www.ietf.org/rfc/rfc3987">Internationalized |
| 8246 |
|
|
Resource Identifiers (IRIs)</a></cite>, M. Dürst, M. Suignard. |
| 8247 |
|
|
IETF, January 2005. RFC 3987 is available at |
| 8248 |
|
|
http://www.ietf.org/rfc/rfc3987 |
| 8249 |
|
|
|
| 8250 |
|
|
<dt id=refsSELECTORS>[SELECTORS] |
| 8251 |
|
|
|
| 8252 |
|
|
<dd><cite><a |
| 8253 |
|
|
href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/">Selectors</a></cite>, |
| 8254 |
|
|
D. Glazman, T. Çelik, I. Hickson. W3C, November 2001. The latest |
| 8255 |
|
|
version of the Selectors specification is available at <a |
| 8256 |
|
|
href="http://www.w3.org/TR/css3-selectors/">http://www.w3.org/TR/css3-selectors/</a> |
| 8257 |
|
|
|
| 8258 |
|
|
<dt id=refsUNICODE>[UNICODE] |
| 8259 |
|
|
|
| 8260 |
|
|
<dd><cite><a href="http://www.unicode.org/versions/Unicode5.0.0/">The |
| 8261 |
|
|
Unicode Standard, Version 5.0.0</a></cite>, The Unicode Consortium. |
| 8262 |
|
|
Boston, MA, Addison-Wesley, November 2006. ISBN |
| 8263 |
|
|
0-321-48091-0<!--, as amended by <a href="http://www.unicode.org/versions/Unicode5.0.1/">Unicode 5.0.1</a> and <a href="http://www.unicode.org/versions/Unicode5.1.0/">Unicode 5.1.0</a>-->. |
| 8264 |
|
|
The latest version of the Unicode specification is available at <a |
| 8265 |
|
|
href="http://www.unicode.org/versions/">http://www.unicode.org/versions/</a> |
| 8266 |
|
|
|
| 8267 |
|
|
<dt id=refsXBL10>[XBL10] |
| 8268 |
|
|
|
| 8269 |
|
|
<dd>(Informative) <cite><a |
| 8270 |
|
|
href="http://www.w3.org/TR/2001/NOTE-xbl-20010223/">XML Binding |
| 8271 |
|
|
Language</a></cite>, D. Hyatt. Mozilla, February 2001. The XBL |
| 8272 |
|
|
submission is available at http://www.w3.org/TR/2001/NOTE-xbl-20010223/ |
| 8273 |
|
|
|
| 8274 |
|
|
<dd>(Informative) <cite><a |
| 8275 |
|
|
href="http://www.mozilla.org/projects/xbl/xbl.html">XML Binding |
| 8276 |
|
|
Language</a></cite>, D. Hyatt. Mozilla, November 2000 (and subsequently |
| 8277 |
|
|
edited by other contributors). The XBL 1.0 specification is available at |
| 8278 |
|
|
http://www.mozilla.org/projects/xbl/xbl.html |
| 8279 |
|
|
|
| 8280 |
|
|
<dt id=refsXFORMS>[XFORMS] |
| 8281 |
|
|
|
| 8282 |
|
|
<dd>(Informative) <cite><a |
| 8283 |
|
|
href="http://www.w3.org/TR/2003/REC-xforms-20031014/">XForms |
| 8284 |
|
|
1.0</a></cite>, M. Dubinko, L. Klotz, R. Merrick, T. Raman. W3C, October |
| 8285 |
|
|
2003. The latest version of the XForms specification is available at <a |
| 8286 |
|
|
href="http://www.w3.org/TR/xforms/">http://www.w3.org/TR/xforms/</a> |
| 8287 |
|
|
|
| 8288 |
|
|
<dt id=refsXML>[XML] |
| 8289 |
|
|
|
| 8290 |
|
|
<dd><cite><a |
| 8291 |
|
|
href="http://www.w3.org/TR/2006/REC-xml-20060816/">Extensible Markup |
| 8292 |
|
|
Language (XML) 1.0 (Fourth Edition)</a></cite>, T. Bray, J. Paoli, C. |
| 8293 |
|
|
Sperberg-McQueen, E. Maler, F. Yergeau. W3C, September 2006. The latest |
| 8294 |
|
|
version of the XML specification is available at <a |
| 8295 |
|
|
href="http://www.w3.org/TR/REC-xml/">http://www.w3.org/TR/REC-xml/</a> |
| 8296 |
|
|
|
| 8297 |
|
|
<dt id=refsXMLBASE>[XMLBASE] |
| 8298 |
|
|
|
| 8299 |
|
|
<dd><cite><a href="http://www.w3.org/TR/2001/REC-xmlbase-20010627/">XML |
| 8300 |
|
|
Base</a></cite>, J. Marsh. W3C, June 2001. The latest version of the XML |
| 8301 |
|
|
Base specification is available at <a |
| 8302 |
|
|
href="http://www.w3.org/TR/xmlbase/">http://www.w3.org/TR/xmlbase/</a> |
| 8303 |
|
|
|
| 8304 |
|
|
<dt id=refsXMLEVENTS>[XMLEVENTS] |
| 8305 |
|
|
|
| 8306 |
|
|
<dd><cite><a |
| 8307 |
|
|
href="http://www.w3.org/TR/2003/REC-xml-events-20031014/">XML |
| 8308 |
|
|
Events</a></cite>, S. McCarron, S. Pemberton, T. Raman. W3C, October |
| 8309 |
|
|
2003. The latest version of the XML Events specification is available at |
| 8310 |
|
|
<a |
| 8311 |
|
|
href="http://www.w3.org/TR/xml-events/">http://www.w3.org/TR/xml-events/</a> |
| 8312 |
|
|
|
| 8313 |
|
|
<dt id=refsXMLNS>[XMLNS] |
| 8314 |
|
|
|
| 8315 |
|
|
<dd><cite><a |
| 8316 |
|
|
href="http://www.w3.org/TR/2006/REC-xml-names-20060816/">Namespaces in |
| 8317 |
|
|
XML (Second Edition)</a></cite>, T. Bray, D. Hollander, A. Layman, R. |
| 8318 |
|
|
Tobin. W3C, August 2006. The latest version of the Namespaces in XML |
| 8319 |
|
|
specification is available at <a |
| 8320 |
|
|
href="http://www.w3.org/TR/REC-xml-names/">http://www.w3.org/TR/REC-xml-names/</a> |
| 8321 |
|
|
|
| 8322 |
|
|
<dt id=refsXMLSSPI>[XMLSSPI] |
| 8323 |
|
|
|
| 8324 |
|
|
<dd><cite><a |
| 8325 |
|
|
href="http://www.w3.org/1999/06/REC-xml-stylesheet-19990629/">Associating |
| 8326 |
|
|
Style Sheets with XML documents</a></cite>, J. Clark. W3C, June 1999. |
| 8327 |
|
|
The latest version of the Associating Style Sheets with XML documents |
| 8328 |
|
|
specification is available at <a |
| 8329 |
|
|
href="http://www.w3.org/TR/xml-stylesheet/">http://www.w3.org/TR/xml-stylesheet/</a> |
| 8330 |
|
|
</dl> |
| 8331 |
|
|
</div> |
| 8332 |
|
|
</html> |
| 8333 |
|
|
<!--XXX WANTED: |
| 8334 |
|
|
|
| 8335 |
|
|
some way of initializing internal fields as pointing to the DOM Nodes |
| 8336 |
|
|
of anon content, so that the constructor doesn't have to walk content, |
| 8337 |
|
|
e.g. to set mInputElement in a <textbox> binding containing an <input |
| 8338 |
|
|
type="text">. |
| 8339 |
|
|
|
| 8340 |
|
|
maximum number of nodes per <content>, with overflow to other |
| 8341 |
|
|
<content>s |
| 8342 |
|
|
|
| 8343 |
|
|
|
| 8344 |
|
|
Nickolay Ponomarev: |
| 8345 |
|
|
A way to say that the element supports onfoo="" handlers. |
| 8346 |
|
|
A way to easily fire custom events. |
| 8347 |
|
|
|
| 8348 |
|
|
--> |