cssom/Overview.src.html

Sun, 18 Aug 2013 23:23:45 +0200

author
Simon Pieters <simonp@opera.com>
date
Sun, 18 Aug 2013 23:23:45 +0200
changeset 8870
1a4eaf3f7f1d
parent 8826
aa74bff40af5
child 8901
048b4760e33e
permissions
-rw-r--r--

[cssom] Make setProperty without priority argument not unset important. Also affects the camel-cased attributes. <http://www.w3.org/mid/DUB119-W4278E92C9DD13C3E85C782E6590@phx.gbl>

simonp@8226 1 <!doctype html>
simonp@8226 2 <html lang="en-US">
simonp@8226 3 <head>
simonp@8226 4 <meta charset=utf-8>
simonp@8226 5 <title>CSS Object Model (CSSOM)</title>
simonp@8435 6 <link rel=stylesheet href=../default.css>
simonp@8226 7 <link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
simonp@8226 8 </head>
simonp@8226 9 <body class="draft">
simonp@8226 10
simonp@8244 11 <div class="head">
simonp@8244 12 <!--logo-->
simonp@8244 13
simonp@8244 14
simonp@8244 15 <h1>CSS Object Model (CSSOM)</h1>
simonp@8244 16
simonp@8244 17
simonp@8244 18 <h2 class="no-num no-toc" id="w3c-doctype">[LONGSTATUS] [DATE: 3 August 2002]</h2>
simonp@8244 19
simonp@8244 20 <dl>
simonp@8244 21
simonp@8244 22 <dt>This Version:</dt>
simonp@8244 23 <dd class=dontpublish><a href="http://dev.w3.org/csswg/cssom/">http://dev.w3.org/csswg/cssom/</a></dd>
simonp@8244 24 <dd class=publish><a href="[VERSION]">[VERSION]</a></dd>
simonp@8244 25
simonp@8244 26 <dt class=dontpublish>Participate:</dt>
simonp@8304 27 <dd class=dontpublish><a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
simonp@8304 28 (<a href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)</dd>
simonp@8304 29 <dd class=dontpublish><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=CSS&amp;component=CSSOM">File a bug</a>
simonp@8304 30 (<a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=CSSOM&amp;product=CSS&amp;resolution=---">open bugs</a>)
simonp@8304 31 <script async="" src="https://w3c-test.org/resources.whatwg.org/file-bug.js"></script></dd>
simonp@8244 32 <dd class=dontpublish><a href="irc://irc.w3.org:6665/css">IRC: #css on W3C</a></dd>
simonp@8244 33
simonp@8244 34 <dt class=publish>Latest Version:</dt>
simonp@8244 35 <dd class=publish><a href="[LATEST]">[LATEST]</a></dd>
simonp@8244 36
simonp@8244 37 <dt class=publish>Latest Editor's draft:</dt>
simonp@8244 38 <dd class=publish><a href="http://dev.w3.org/csswg/cssom/">http://dev.w3.org/csswg/cssom/</a></dd>
simonp@8244 39
simonp@8244 40 <dt class=dontpublish>Previous Version:</dt>
simonp@8244 41 <dd class=dontpublish><a href="http://www.w3.org/TR/2011/WD-cssom-20110712/">http://www.w3.org/TR/2011/WD-cssom-20110712/</a></dd>
simonp@8244 42 <dd class=dontpublish><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/</a></dd>
simonp@8244 43
simonp@8244 44 <dt>Editors:</dt>
simonp@8539 45 <dd>Simon Pieters
simonp@8244 46 (<a href="http://www.opera.com/">Opera Software ASA</a>)
simonp@8244 47 &lt;<a href="mailto:simponp@opera.com">simonp@opera.com</a>&gt;</dd>
simonp@8244 48 <dd><a href="http://www.w3.org/wiki/User:Gadams">Glenn Adams</a>
simonp@8244 49 (<a href="http://www.cox.com/">Cox Communications, Inc.</a>)
simonp@8244 50 &lt;<a href="mailto:glenn.adams@cox.com">glenn.adams@cox.com</a>&gt;</dd>
simonp@8244 51
simonp@8244 52 <dt>Previous Editor:</dt>
simonp@8244 53 <dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
simonp@8244 54 (<a href="http://www.opera.com/">Opera Software ASA</a>)
simonp@8551 55 &lt;<a href="mailto:annevk@annevk.nl">annevk@annevk.nl</a>&gt;</dd>
simonp@8244 56 </dl>
simonp@8244 57
simonp@8244 58 <!--copyright-->
simonp@8244 59
simonp@8244 60 </div>
simonp@8244 61
simonp@8244 62 <hr class="top">
simonp@8244 63
simonp@8244 64
simonp@8244 65 <h2 class="no-num no-toc">Abstract</h2>
simonp@8244 66
simonp@8244 67 <p>CSSOM defines APIs (including generic parsing and serialization rules)
simonp@8244 68 for Media Queries, Selectors, and of course CSS itself.</p>
simonp@8244 69
simonp@8244 70
simonp@8244 71 <h2 class="no-num no-toc" id="sotd">Status of This Document</h2>
simonp@8244 72
simonp@8244 73 <p>This is a public copy of the editors' draft. It is provided for discussion only and may change at any moment.
simonp@8244 74 Its publication here does not imply endorsement of its contents by W3C or by the CSS Working Group. Don't cite
simonp@8244 75 this document other than as work in progress.</p>
simonp@8244 76
simonp@8244 77 <p class="note">Implementers should note well that this specification is an ongoing effort to sort out
simonp@8371 78 what has been widely implemented and deployed from <span data-anolis-ref class=informative>DOM2STYLE</span> as well as common extensions thereto, some details
simonp@8244 79 of which are currently interoperable and others which are not currently interoperable. As this specification moves
simonp@8244 80 forward, it is hoped that these differences will be resolved and an unambiguous and adequate consensus-based
simonp@8244 81 specification will emerge.</p>
simonp@8244 82
simonp@8244 83 <p><em>This section describes the status of this document at the time of
simonp@8244 84 its publication. Other documents may supersede this document. A list of
simonp@8244 85 current W3C publications and the latest revision of this technical report
simonp@8244 86 can be found in the
simonp@8244 87 <a href="http://www.w3.org/TR/">W3C technical reports index at http://www.w3.org/TR/.</a></em>
simonp@8244 88
simonp@8244 89 <p class="dontpublish">This is the [DATE: 3 August 2002] [LONGSTATUS] of CSSOM. Please send comments to
simonp@8244 90 <a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
simonp@8244 91 (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
simonp@8244 92 with <samp>[cssom]</samp> at the start of the subject line.
simonp@8244 93
simonp@8244 94 <p class="publish">This is the [DATE] First Public Working Draft of CSSOM, produced by the
simonp@8244 95 <a href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part
simonp@8244 96 of the <a href="http://www.w3.org/Style/">Style Activity</a>).
simonp@8244 97 <!--XXX remove "First Public" after initial publication -->
simonp@8244 98
simonp@8244 99 <p>This document was produced by a group operating under the
simonp@8244 100 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>.
simonp@8244 101 W3C maintains a
simonp@8244 102 <a href="http://www.w3.org/2004/01/pp-impl/32061/status" rel=disclosure>public list of any patent disclosures</a>
simonp@8244 103 made in connection with the deliverables of the group; that page also
simonp@8244 104 includes instructions for disclosing a patent. An individual who has
simonp@8244 105 actual knowledge of a patent which the individual believes contains
simonp@8244 106 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a>
simonp@8244 107 must disclose the information in accordance with
simonp@8244 108 <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</p>
simonp@8244 109
simonp@8244 110
simonp@8244 111 <h2 class="no-num no-toc" id="toc">Table of Contents</h2>
simonp@8244 112
simonp@8244 113 <!--toc-->
simonp@8244 114
simonp@8244 115
simonp@8244 116 <h2>Introduction</h2>
simonp@8244 117
simonp@8244 118 <p>This document formally specifies the core features of the CSS Object Model (CSSOM). Other documents in the CSSOM family of specifications
simonp@8244 119 as well as other CSS related specifications define extensions to these core features.</p>
simonp@8244 120
simonp@8244 121 <p>The core features of the CSSOM are oriented towards providing basic capabilities to author-defined scripts to permit access to
simonp@8244 122 and manipulation of style related state information and processes.</p>
simonp@8244 123
simonp@8244 124 <p>The features defined below are fundamentally based on prior specifications of the W3C DOM Working Group, primarily
simonp@8371 125 <span data-anolis-ref class=informative>DOM2STYLE</span>. The purposes of the present document are (1) to improve on that prior work by providing
simonp@8244 126 more technical specificity (so as to improve testability and interoperability), (2) to deprecate or remove certain less-widely implemented
simonp@8244 127 features no longer considered to be essential in this context, and (3) to newly specify certain extensions that have been
simonp@8244 128 or expected to be widely implemented.</p>
simonp@8244 129
simonp@8371 130 <p>A full list of the changes to API signatures can be found in <a href="#changes-from-dom-2-style"><cite>Changes from DOM-2 Style</cite></a>.</p>
simonp@8244 131
simonp@8244 132
simonp@8244 133 <h2>Conformance</h2>
simonp@8244 134
simonp@8244 135 <p>All diagrams, examples, and notes in this specification are
simonp@8244 136 non-normative, as are all sections explicitly marked non-normative.
simonp@8244 137 Everything else in this specification is normative.
simonp@8244 138
simonp@8244 139 <p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
simonp@8244 140 NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
simonp@8244 141 "OPTIONAL" in the normative parts of this document are to be
simonp@8244 142 interpreted as described in RFC2119. For readability, these words do
simonp@8244 143 not appear in all uppercase letters in this specification.
simonp@8244 144 <span data-anolis-ref>RFC2119</span>
simonp@8244 145
simonp@8244 146 <p>Requirements phrased in the imperative as part of algorithms
simonp@8244 147 (such as "strip any leading space characters" or "return false and
simonp@8244 148 terminate these steps") are to be interpreted with the meaning of the
simonp@8244 149 key word ("must", "should", "may", etc) used in introducing the
simonp@8244 150 algorithm.
simonp@8244 151
simonp@8244 152 <p>Conformance requirements phrased as algorithms or specific steps
simonp@8244 153 may be implemented in any manner, so long as the end result is
simonp@8244 154 equivalent. (In particular, the algorithms defined in this
simonp@8244 155 specification are intended to be easy to follow, and not intended to
simonp@8244 156 be performant.)
simonp@8244 157
simonp@8244 158 <p id="hardwareLimitations">User agents may impose
simonp@8244 159 implementation-specific limits on otherwise unconstrained inputs,
simonp@8244 160 e.g. to prevent denial of service attacks, to guard against running
simonp@8553 161 out of memory, or to work around platform-specific limitations. <!--fingerprint-->
simonp@8244 162
simonp@8304 163 <p>When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that
simonp@8304 164 e.g. the author can't change the behavior by overriding attributes or methods with custom properties or functions in ECMAScript.
simonp@8244 165
simonp@8244 166 <p>Unless otherwise stated, string comparisons are done in a
simonp@8244 167 <span data-anolis-spec=dom>case-sensitive</span> manner.
simonp@8244 168
simonp@8244 169
simonp@8244 170 <h2>Terminology</h2>
simonp@8244 171
simonp@8244 172 <p>This specification employs certain terminology from the following documents:
simonp@8244 173 <cite>DOM</cite>,
simonp@8244 174 <cite>HTML</cite>,
simonp@8433 175 <cite>CSS Syntax</cite>,
simonp@8244 176 <cite>URL</cite>,
simonp@8372 177 <cite>Fetch</cite>,
simonp@8244 178 <cite>Associating Style Sheets with XML documents</cite>
simonp@8244 179 and
simonp@8244 180 <cite>XML</cite>.
simonp@8244 181 <span data-anolis-ref>DOM</span>
simonp@8244 182 <span data-anolis-ref>HTML</span>
simonp@8433 183 <span data-anolis-ref>CSSSYNTAX</span>
simonp@8244 184 <span data-anolis-ref>URL</span>
simonp@8372 185 <span data-anolis-ref>FETCH</span>
simonp@8244 186 <span data-anolis-ref>XMLSS</span>
simonp@8244 187 <span data-anolis-ref>XML</span>
simonp@8244 188
simonp@8244 189 <p>When this specification talks about object
simonp@8406 190 <code title><var>A</var></code> where <code title><var>A</var></code> is actually an interface, it generally means an object implementing interface
simonp@8406 191 <code title><var>A</var></code>.</p>
simonp@8244 192
simonp@8811 193 <p>The terms <dfn>whitespace</dfn> and <dfn>ignored</dfn> are defined in CSS. <span data-anolis-ref>CSS</span>
simonp@8811 194
simonp@8811 195 <p>The terms <dfn>cascaded value</dfn>, <dfn>computed value</dfn> and <dfn>used value</dfn> are defined in CSS Cascade and Inheritance.
simonp@8811 196 <span data-anolis-ref>CSSCASCADE</span>
simonp@8327 197
simonp@8327 198 <p>The terms <dfn>simple selector</dfn>, <dfn>sequence of simple selectors</dfn>, <dfn>universal selector</dfn> and <dfn>group of selectors</dfn> are defined in
simonp@8327 199 Selectors. <span data-anolis-ref>SELECTORS</span>
simonp@8327 200
simonp@8327 201 <p>The terms <dfn>namespace prefix</dfn> and <dfn>default namespace</dfn> are defined in CSS Namespaces Module. <span data-anolis-ref>CSSNAMESPACES</span>
simonp@8327 202
simonp@8327 203 <p>The term <dfn>list of CSS page selectors</dfn> refers to the comma-separated list of page selectors, as defined in CSS Paged Media Module.
simonp@8327 204 <span data-anolis-ref>CSSPAGE</span>
simonp@8244 205
simonp@8304 206 <p>The terms <dfn>set</dfn> and <dfn>clear</dfn> to refer to the true and
simonp@8304 207 false values of binary flags or variables, respectively. These terms are also used as verbs in which case they refer to
simonp@8304 208 mutating some value to make it true or false, respectively.</p>
simonp@8244 209
simonp@8327 210 <p>The term <dfn>supported styling language</dfn> refers to CSS.
simonp@8327 211
simonp@8327 212 <p class=note>If another styling language becomes supported in user agents, this specification is expected to be updated as necessary.
simonp@8244 213
simonp@8592 214 <p>The term <dfn>supported CSS property</dfn> refers to a CSS property that the user agent implements, and that is defined to be a case-insensitive property in
simonp@8592 215 the CSS specification. A <span>supported CSS property</span> must be in its lowercase form for the purpose of comparisons this specification.
simonp@8592 216
simonp@8592 217 <p class=note>CSS properties that are case-sensitive such as CSS Variables are author-defined and are represented with dedicated interfaces, and do not
simonp@8592 218 participate in the base CSSOM API. <span data-anolis-ref class=informative>CSSVARIABLES</span>
simonp@8592 219
simonp@8329 220 <p>The terms <dfn>::before pseudo-element</dfn> and <dfn>::after pseudo-element</dfn> refer to the :before and :after pseudo-elements in CSS, except in this
simonp@8329 221 specification the pseudo-elements are assumed to exist for all elements even if no box is generated for them. <span data-anolis-ref>CSS</span>
simonp@8329 222
simonp@8244 223 <h3>Common Serializing Idioms</h3>
simonp@8244 224
simonp@8244 225 <p>To <dfn>escape a character</dfn> means to create a string of
simonp@8304 226 "<code title>\</code>" (U+005C), followed by the character.</p>
simonp@8244 227
simonp@8244 228 <p>To <dfn>escape a character as code point</dfn> means to create a
simonp@8304 229 string of "<code title>\</code>" (U+005C), followed by the Unicode code point as
simonp@8244 230 the smallest possible number of hexadecimal digits in the range 0-9 a-f
simonp@8244 231 (U+0030 to U+0039 and U+0061 to U+0066) to represent the code point in
simonp@8244 232 base 16, followed by a single SPACE (U+0020).</p>
simonp@8244 233
simonp@8244 234 <p>To <dfn>serialize an identifier</dfn> means to create a string represented
simonp@8244 235 by the concatenation of, for each character of the identifier:</p>
simonp@8244 236
simonp@8244 237 <ul>
simonp@8244 238 <li>If the character is NULL (U+0000), then <span data-anolis-spec=dom title=concept-throw>throw</span> an
simonp@8244 239 <code data-anolis-spec=dom>InvalidCharacterError</code> exception and terminate these steps.</li>
simonp@8244 240 <li>If the character is in the range [\1-\1f] (U+0001 to U+001F) or
simonp@8244 241 [\7f-\9f] (U+007F to U+009F), then the character
simonp@8244 242 <span title="escape a character as code point">escaped as code point</span>.</li>
simonp@8244 243 <li>If the character is the first character and is in the range [0-9]
simonp@8244 244 (U+0030 to U+0039), then the character
simonp@8244 245 <span title="escape a character as code point">escaped as code point</span>.</li>
simonp@8244 246 <li>If the character is the second character and is in the range [0-9]
simonp@8304 247 (U+0030 to U+0039) and the first character is a "<code title>-</code>"
simonp@8244 248 (U+002D), then the character
simonp@8244 249 <span title="escape a character as code point">escaped as code point</span>.</li>
simonp@8304 250 <li>If the character is the second character and is "<code title>-</code>"
simonp@8304 251 (U+002D) and the first character is "<code title>-</code>" as well, then the
simonp@8244 252 <span title="escape a character">escaped</span> character.</li>
simonp@8244 253 <li>If the character is not handled by one of the above rules and is
simonp@8304 254 greater than or equal to U+0080, is "<code title>-</code>" (U+002D) or
simonp@8304 255 "<code title>_</code>" (U+005F), or is in one of the ranges [0-9] (U+0030 to
simonp@8244 256 U+0039), [A-Z] (U+0041 to U+005A), or [a-z] (U+0061 to U+007A), then the character
simonp@8244 257 itself.</li>
simonp@8244 258 <li>Otherwise, the <span title="escape a character">escaped</span>
simonp@8244 259 character.</li>
simonp@8244 260 </ul>
simonp@8244 261
simonp@8244 262 <p>To <dfn>serialize a string</dfn> means to create a string represented
simonp@8346 263 by '"' (U+0022), followed by the result of applying the rules
simonp@8244 264 below to each character of the given string, followed by
simonp@8346 265 '"' (U+0022):</p>
simonp@8244 266
simonp@8244 267 <ul>
simonp@8244 268 <li>If the character is NULL (U+0000), then <span data-anolis-spec=dom title=concept-throw>throw</span> an
simonp@8244 269 <code data-anolis-spec=dom>InvalidCharacterError</code> exception and terminate these steps.</li>
simonp@8244 270 <li>If the character is in the range [\1-\1f] (U+0001 to U+001F) or [\7f-\9f] (U+007F to
simonp@8244 271 U+009F), the character <span title="escape a character as code point">escaped as code point</span>.</li>
simonp@8346 272 <li>If the character is '"' (U+0022) or "<code title>\</code>"
simonp@8244 273 (U+005C), the <span title="escape a character">escaped</span> character.</li>
simonp@8244 274 <li>Otherwise, the character itself.</li>
simonp@8244 275 </ul>
simonp@8244 276
simonp@8304 277 <p class="note">"<code title>'</code>" (U+0027) is not escaped because strings
simonp@8346 278 are always serialized with '"' (U+0022).</p>
simonp@8244 279
simonp@8244 280 <p>To <dfn>serialize a URL</dfn> means to create a string represented by
simonp@8304 281 "<code title>url(</code>", followed by the
simonp@8244 282 <span title="serialize a string">string escaped</span> value of the given
simonp@8304 283 string, followed by "<code title>)</code>".</p>
simonp@8244 284
simonp@8244 285 <p>To <dfn>serialize a comma-separated list</dfn> concatenate all items of
simonp@8304 286 the list in list order while separating them by "<code title>, </code>", i.e.,
simonp@8244 287 COMMA (U+002C) followed by a single SPACE (U+0020).</p>
simonp@8244 288
simonp@8244 289 <p>To <dfn>serialize a whitespace-separated list</dfn> concatenate all
simonp@8304 290 items of the list in list order while separating them by "<code title> </code>", i.e.,
simonp@8244 291 a single SPACE (U+0020).</p>
simonp@8244 292
simonp@8244 293 <p class="note">When serializing a list according to the above rules,
simonp@8244 294 extraneous whitespace is not inserted prior to the first item or subsequent to
simonp@8244 295 the last item. Unless otherwise specified, an empty list is serialized as the
simonp@8244 296 empty string.</p>
simonp@8244 297
simonp@8244 298
simonp@8244 299 <h2>Media Queries</h2>
simonp@8244 300
simonp@8244 301 <p>Media queries are defined by the Media Queries specification. This
simonp@8244 302 section defines various concepts around media queries, including their API
simonp@8244 303 and serialization form.</p>
simonp@8244 304
simonp@8244 305 <!-- XXX ref -->
simonp@8244 306
simonp@8244 307
simonp@8244 308 <h3>Parsing Media Queries</h3>
simonp@8244 309
simonp@8244 310 <p>To
simonp@8244 311 <dfn>parse a media query list</dfn> for a
simonp@8406 312 given string <var>s</var> into a media query list is defined in
simonp@8244 313 the Media Queries specification. Return the list of one or more media
simonp@8244 314 queries that the algorithm defined there gives.</p> <!-- XXX ref -->
simonp@8244 315
simonp@8244 316 <p class="note">A media query that ends up being "ignored" will turn
simonp@8304 317 into "<code title>not all</code>".</p>
simonp@8244 318
simonp@8244 319 <p>To
simonp@8244 320 <dfn>parse a media query</dfn> for a given string
simonp@8406 321 <var>s</var> means to follow the
simonp@8289 322 <span>parse a media query list</span> steps and return null if more
simonp@8244 323 than one media query is returned or a media query if a
simonp@8244 324 single media query is returned.</p>
simonp@8244 325
simonp@8244 326 <p class="note">Again, a media query that ends up being "ignored" will
simonp@8304 327 turn into "<code title>not all</code>".</p>
simonp@8244 328
simonp@8244 329
simonp@8244 330 <h3>Serializing Media Queries</h3>
simonp@8244 331
simonp@8244 332 <p>To
simonp@8244 333 <dfn>serialize a media query list</dfn>
simonp@8244 334 run these steps:</p>
simonp@8244 335
simonp@8244 336 <ol>
simonp@8244 337 <li><p>If the media query list is empty return the empty string and
simonp@8244 338 terminate these steps.</p></li>
simonp@8244 339
simonp@8581 340 <li><p><span title="serialize a media query">Serialize</span> each media query in the list of media queries, in the same order as they appear in the list of
simonp@8581 341 media queries, and then <span title="serialize a comma-separated list">serialize</span> the list.</p></li>
simonp@8244 342 </ol>
simonp@8244 343
simonp@8244 344 <p>To
simonp@8244 345 <dfn>serialize a media query</dfn> let
simonp@8406 346 <var>s</var> be the empty string, run the steps below, and
simonp@8406 347 finally return <var>s</var>:</p>
simonp@8244 348
simonp@8244 349 <ol>
simonp@8304 350 <li><p>If the media query is negated append "<code title>not</code>", followed
simonp@8406 351 by a single SPACE (U+0020), to <var>s</var>.</p></li>
simonp@8406 352
simonp@8406 353 <li><p>Let <var>type</var> be the media type of the media query,
simonp@8244 354 <span title="serialize an identifier">escaped</span> and
simonp@8244 355 <span data-anolis-spec=dom>converted to ASCII lowercase</span>.</p></li>
simonp@8244 356
simonp@8244 357 <li><p>If the media query does not contain media features append
simonp@8406 358 <var>type</var>, to <var>s</var>,
simonp@8406 359 then return <var>s</var> and terminate this algorithm.</p></li>
simonp@8406 360
simonp@8406 361 <li><p>If <var>type</var> is not "<code title>all</code>" or if the
simonp@8406 362 media query is negated append <var>type</var>, followed by a
simonp@8304 363 single SPACE (U+0020), followed by "<code title>and</code>", followed by a single SPACE
simonp@8406 364 (U+0020), to <var>s</var>.</p></li>
simonp@8244 365
simonp@8244 366 <li><p>Sort the media features in lexicographical order.</p></li>
simonp@8244 367
simonp@8244 368 <li>
simonp@8244 369 <p>Then, for each media feature:</p>
simonp@8226 370
simonp@8226 371 <ol>
simonp@8304 372 <li><p>Append a "<code title>(</code>" (U+0028), followed by the media feature
simonp@8244 373 name, <span data-anolis-spec=dom>converted to ASCII lowercase</span>,
simonp@8406 374 to <var>s</var>.</p></li>
simonp@8244 375
simonp@8304 376 <li><p>If a value is given append a "<code title>:</code>" (U+003A), followed
simonp@8244 377 by a single SPACE (U+0020), followed by the
simonp@8244 378 <span title="serialize a media feature value">serialized media feature value</span>,
simonp@8406 379 to <var>s</var>.</p></li>
simonp@8244 380
simonp@8304 381 <li><p>Append a "<code title>)</code>" (U+0029) to
simonp@8406 382 <var>s</var>.</p></li>
simonp@8244 383
simonp@8244 384 <li><p>If this is not the last media feature append a single SPACE (U+0020),
simonp@8304 385 followed by "<code title>and</code>", followed by a single SPACE (U+0020), to
simonp@8406 386 <var>s</var>.</p></li>
simonp@8226 387 </ol>
simonp@8244 388 </li>
simonp@8244 389 </ol>
simonp@8244 390
simonp@8244 391 <div class="example">
simonp@8244 392 <p>Here are some examples of input (first column) and output (second
simonp@8244 393 column):</p>
simonp@8244 394
simonp@8559 395 <table class="complex data">
simonp@8244 396 <thead>
simonp@8244 397 <tr><th>Input<th>Output
simonp@8244 398 <tbody>
simonp@8226 399 <tr>
simonp@8244 400 <td><pre>not screen and (min-WIDTH:5px) AND (max-width:40px)</pre>
simonp@8244 401 <td><pre>not screen and (max-width: 40px) and (min-width: 5px)</pre>
simonp@8226 402 <tr>
simonp@8244 403 <td><pre>all and (color) and (color)</pre>
simonp@8244 404 <td><pre>(color)</pre>
simonp@8244 405 </table>
simonp@8244 406 </div>
simonp@8244 407
simonp@8244 408
simonp@8244 409
simonp@8244 410 <h4>Serializing Media Feature Values</h4>
simonp@8244 411
simonp@8435 412 <p class="issue">This should probably be done in terms of mapping it to
simonp@8244 413 serializing CSS values as media features are defined in terms of CSS
simonp@8244 414 values after all.</p>
simonp@8244 415
simonp@8244 416 <p>To <dfn>serialize a media feature value</dfn>
simonp@8406 417 named <var>v</var> locate <var>v</var> in the first
simonp@8244 418 column of the table below and use the serialization format described in
simonp@8244 419 the second column:</p>
simonp@8244 420
simonp@8559 421 <table class="complex data">
simonp@8559 422 <thead>
simonp@8559 423 <tr>
simonp@8559 424 <th>Media Feature
simonp@8559 425 <th>Serialization
simonp@8559 426 <tbody>
simonp@8559 427 <tr>
simonp@8559 428 <td>'width'
simonp@8559 429 <td>...
simonp@8559 430 <tr>
simonp@8559 431 <td>'height'
simonp@8559 432 <td>...
simonp@8559 433 <tr>
simonp@8559 434 <td>'device-width'
simonp@8559 435 <td>...
simonp@8559 436 <tr>
simonp@8559 437 <td>'device-height'
simonp@8559 438 <td>...
simonp@8559 439 <tr>
simonp@8559 440 <td>'orientation'
simonp@8559 441 <td>
simonp@8559 442 <p>If the value is 'portrait': "<code title>portrait</code>".</p>
simonp@8559 443 <p>If the value is 'landscape': "<code title>landscape</code>".</p>
simonp@8559 444 <tr>
simonp@8559 445 <td>'aspect-ratio'
simonp@8559 446 <td>...
simonp@8559 447 <tr>
simonp@8559 448 <td>'device-aspect-ratio'
simonp@8559 449 <td>...
simonp@8559 450 <tr>
simonp@8559 451 <td>'color'
simonp@8559 452 <td>...
simonp@8559 453 <tr>
simonp@8559 454 <td>'color-index'
simonp@8559 455 <td>...
simonp@8559 456 <tr>
simonp@8559 457 <td>'monochrome'
simonp@8559 458 <td>...
simonp@8559 459 <tr>
simonp@8559 460 <td>'resolution'
simonp@8559 461 <td>...
simonp@8559 462 <tr>
simonp@8559 463 <td>'scan'
simonp@8559 464 <td>
simonp@8559 465 <p>If the value is 'progressive': "<code title>progressive</code>".</p>
simonp@8559 466 <p>If the value is 'interlace': "<code title>interlace</code>".</p>
simonp@8559 467 <tr>
simonp@8559 468 <td>'grid'
simonp@8559 469 <td>...
simonp@8244 470 </table>
simonp@8244 471
simonp@8244 472 <p>Other specifications can extend this table and vendor-prefixed media
simonp@8244 473 features can have custom serialization formats as well.</p>
simonp@8244 474
simonp@8244 475
simonp@8244 476 <h3>Comparing Media Queries</h3>
simonp@8244 477
simonp@8244 478 <p>To
simonp@8244 479 <dfn>compare media queries</dfn>
simonp@8406 480 <var>m1</var> and <var>m2</var> means to
simonp@8244 481 <span title="serialize a media query">serialize</span> them both and
simonp@8244 482 return true if they are a
simonp@8244 483 <span data-anolis-spec=dom>case-sensitive</span> match and false if they
simonp@8244 484 are not.</p>
simonp@8244 485
simonp@8244 486
simonp@8244 487 <h3>The <code title>MediaList</code> Interface</h3>
simonp@8226 488
simonp@8226 489 <!--
simonp@8226 490 //
simonp@8226 491 // All members defined since DOM-2 Style. The only differences are:
simonp@8226 492 //
simonp@8226 493 // 1. addition of stringifier qualifier on mediaText
simonp@8226 494 // 2. addition of getter qualifier on item
simonp@8226 495 // 3. removal of raises(DOMException) from {append,delete}Medium
simonp@8226 496 //
simonp@8226 497 -->
simonp@8226 498
simonp@8226 499 <p>An object that implements the <code>MediaList</code> interface has an associated <dfn>collection of media queries</dfn>.</p>
simonp@8226 500
simonp@8549 501 <pre class=idl>interface <dfn>MediaList</dfn> {
simonp@8407 502 [TreatNullAs=EmptyString] stringifier attribute DOMString <span title=dom-MediaList-mediaText>mediaText</span>;
simonp@8226 503 readonly attribute unsigned long <span title=dom-MediaList-length>length</span>;
simonp@8226 504 getter DOMString <span title=dom-MediaList-item>item</span>(unsigned long index);
simonp@8226 505 void <span title=dom-MediaList-appendMedium>appendMedium</span>(DOMString medium);
simonp@8226 506 void <span title=dom-MediaList-deleteMedium>deleteMedium</span>(DOMString medium);
simonp@8226 507 };</pre>
simonp@8226 508
simonp@8265 509 <p>The object's <span data-anolis-spec=webidl>supported property indices</span> are the numbers in the range zero to one less than the number of media queries
simonp@8265 510 in the <span>collection of media queries</span> represented by the collection. If there are no such media queries, then there are no
simonp@8265 511 <span data-anolis-spec=webidl>supported property indices</span>.
simonp@8265 512
simonp@8406 513 <p>To <dfn>create a <code>MediaList</code> object</dfn> with a string <var>text</var>, run the following steps:
simonp@8226 514 <ol>
simonp@8226 515 <li><p>Create a new <code>MediaList</code> object.</p></li>
simonp@8406 516 <li><p>Set its <code title='dom-MediaList-mediaText'>mediaText</code> attribute to <var>text</var>.</p></li>
simonp@8226 517 <li><p>Return the newly created <code>MediaList</code> object.</p></li>
simonp@8226 518 </ol>
simonp@8226 519
simonp@8304 520 <p>The <dfn title=dom-MediaList-mediaText><code>mediaText</code></dfn> attribute, on getting, must return a
simonp@8304 521 <span title='serialize a media query list'>serialization</span> of the <span>collection of media queries</span>.</p>
simonp@8226 522 <p>Setting the <code title=dom-MediaList-mediaText>mediaText</code> attribute must run these steps:
simonp@8226 523 <ol>
simonp@8226 524 <li><p>Empty the <span>collection of media queries</span>.</p></li>
simonp@8226 525 <li><p>If the given value is the empty string terminate these steps.</p></li>
simonp@8226 526 <li><p>Append all the media queries as a result of <span title='parse a media query list'>parsing</span> the given
simonp@8226 527 value to the <span>collection of media queries</span>.</p></li>
simonp@8226 528 </ol>
simonp@8226 529
simonp@8406 530 <p>The <dfn title=dom-MediaList-item><code>item(<var>index</var>)</code></dfn> method must return the media query in the <span>collection of media
simonp@8406 531 queries</span> given by <var>index</var>, or null, if <var>index</var> is greater than or equal to the number of media queries in the
simonp@8226 532 <span>collection of media queries</span>.</p>
simonp@8226 533
simonp@8304 534 <p>The <dfn title=dom-MediaList-length><code>length</code></dfn> attribute must return the number of media queries in the <span>collection of media
simonp@8304 535 queries</span>.</p>
simonp@8226 536
simonp@8406 537 <p>The <dfn title=dom-MediaList-appendMedium><code>appendMedium(<var>medium</var>)</code></dfn> method must run these steps:</p>
simonp@8226 538 <ol>
simonp@8406 539 <li><p>Let <var>m</var> be the result of <span title='parse a media query'>parsing</span> the given value.</p></li>
simonp@8406 540 <li><p>If <var>m</var> is null terminate these steps.</p></li>
simonp@8406 541 <li><p>If <span title='compare media queries'>comparing</span> <var>m</var> with any of the media queries in the
simonp@8226 542 <span>collection of media queries</span> returns true terminate these steps.</p></li>
simonp@8406 543 <li><p>Append <var>m</var> to the <span>collection of media queries</span>.</p></li>
simonp@8226 544 </ol>
simonp@8226 545
simonp@8406 546 <p>The <dfn title=dom-MediaList-deleteMedium><code>deleteMedium(<var>medium</var>)</code></dfn> method must run these steps:</p>
simonp@8226 547 <ol>
simonp@8406 548 <li><p>Let <var>m</var> be the result of <span title='parse a media query'>parsing</span> the given value.</p></li>
simonp@8406 549 <li><p>If <var>m</var> is null terminate these steps.</p></li>
simonp@8226 550 <li><p>Remove any media query from the <span>collection of media queries</span> for which
simonp@8406 551 <span title='compare media queries'>comparing</span> the media query with <var>m</var> returns true.</p></li>
simonp@8226 552 </ol>
simonp@8226 553
simonp@8244 554 <h2>Selectors</h2>
simonp@8244 555
simonp@8244 556 <p>Selectors are defined in the Selectors specification. This section
simonp@8244 557 mainly defines how to serialize them.</p> <!-- XXX ref -->
simonp@8244 558
simonp@8244 559 <!-- XXX ref universal selector etc? some are in <span> some not -->
simonp@8244 560
simonp@8244 561
simonp@8244 562 <h3>Parsing Selectors</h3>
simonp@8244 563
simonp@8244 564 <p>To
simonp@8244 565 <dfn>parse a group of selectors</dfn>
simonp@8304 566 means to parse the value using the <code title>selectors_group</code>
simonp@8244 567 production defined in the Selectors specification and return either a
simonp@8289 568 group of selectors if parsing did not fail or null if parsing did
simonp@8244 569 fail.</p> <!-- XXX ref -->
simonp@8244 570
simonp@8244 571
simonp@8244 572 <h3>Serializing Selectors</h3>
simonp@8244 573 <!-- http://dump.testsuite.org/2009/cssom/serializing-selectors.htm -->
simonp@8244 574
simonp@8244 575 <p>To
simonp@8244 576 <dfn>serialize a group of selectors</dfn>
simonp@8244 577 <span title="serialize a selector">serialize</span> each selector in the
simonp@8244 578 group of selectors and then
simonp@8244 579 <span title="serialize a comma-separated list">serialize</span> the
simonp@8244 580 group.</p>
simonp@8244 581
simonp@8244 582 <p>To <dfn>serialize a selector</dfn> let
simonp@8406 583 <var>s</var> be the empty string, run the steps below for each
simonp@8244 584 part of the chain of the selector, and finally return
simonp@8406 585 <var>s</var>:</p>
simonp@8244 586
simonp@8244 587 <ol>
simonp@8244 588 <li><p>If there is only one <span>simple selector</span> in the
simonp@8244 589 <span>sequence of simple selectors</span> which is a
simonp@8244 590 <span>universal selector</span>, append the result of
simonp@8244 591 <span title="serialize a simple selector">serializing</span> the
simonp@8406 592 <span>universal selector</span> to <var>s</var>.</p></li>
simonp@8244 593
simonp@8244 594 <li><p>Otherwise, for each <span>simple selector</span> in the
simonp@8244 595 <span>sequence of simple selectors</span> that is not a
simonp@8438 596 universal selector of which the
simonp@8244 597 <span>namespace prefix</span> maps to a namespace that is not the
simonp@8244 598 <span>default namespace</span>
simonp@8244 599 <span title="serialize a simple selector">serialize</span> the
simonp@8244 600 <span>simple selector</span> and append the result to
simonp@8406 601 <var>s</var>.</p></li>
simonp@8244 602
simonp@8244 603 <li><p>If this is not the last part of the chain of the selector append a
simonp@8244 604 single SPACE (U+0020), followed by the combinator
simonp@8304 605 "<code title>></code>",
simonp@8304 606 "<code title>+</code>", or
simonp@8304 607 "<code title>~</code>"
simonp@8244 608 as appropriate, followed by another single SPACE (U+0020) if the combinator was
simonp@8406 609 not whitespace, to <var>s</var>.</p></li>
simonp@8244 610
simonp@8244 611 <li><p>If this is the last part of the chain of the selector and there is
simonp@8304 612 a pseudo-element, append "<code title>::</code>" followed by the name of the
simonp@8438 613 pseudo-element, to <var>s</var>.</p></li>
simonp@8244 614 </ol>
simonp@8244 615
simonp@8244 616
simonp@8244 617 <p>To
simonp@8244 618 <dfn>serialize a simple selector</dfn>
simonp@8406 619 let <var>s</var> be the empty string, run the steps below, and
simonp@8406 620 finally return <var>s</var>:</p>
simonp@8244 621
simonp@8244 622 <dl class="switch">
simonp@8244 623 <dt>type selector</dt>
simonp@8244 624 <dt>universal selector</dt>
simonp@8244 625 <dd>
simonp@8226 626 <ol>
simonp@8244 627 <li><p>If the <span>namespace prefix</span> maps to a namespace that is
simonp@8244 628 not the <span>default namespace</span> and is not the
simonp@8244 629 null namespace (not in a namespace) append the
simonp@8244 630 <span title="serialize an identifier">escaped</span>
simonp@8304 631 <span>namespace prefix</span>, followed by a "<code title>|</code>" (U+007C)
simonp@8406 632 to <var>s</var>.</p></li>
simonp@8244 633
simonp@8244 634 <li><p>If the <span>namespace prefix</span> maps to a namespace that is
simonp@8244 635 the null namespace (not in a namespace) append
simonp@8406 636 "<code title>|</code>" (U+007C) to <var>s</var>.</p></li>
simonp@8244 637 <!-- This includes |* -->
simonp@8244 638
simonp@8244 639 <li><p>If this is a type selector append the
simonp@8244 640 <span title="serialize an identifier">escaped</span> element name to
simonp@8406 641 <var>s</var>.</p></li>
simonp@8226 642
simonp@8304 643 <li><p>If this is a universal selector append "<code title>*</code>" (U+002A)
simonp@8406 644 to <var>s</var>.</p></li>
simonp@8226 645 </ol>
simonp@8244 646 </dd>
simonp@8244 647
simonp@8244 648 <dt>attribute selector</dt>
simonp@8244 649 <dd>
simonp@8244 650 <ol>
simonp@8304 651 <li><p>Append "<code title>[</code>" (U+005B) to
simonp@8406 652 <var>s</var>.</p></li>
simonp@8244 653
simonp@8244 654 <li><p>If the <span>namespace prefix</span> maps to a namespace that is
simonp@8244 655 not the null namespace (not in a namespace) append the
simonp@8244 656 <span title="serialize an identifier">escaped</span>
simonp@8304 657 <span>namespace prefix</span>, followed by a "<code title>|</code>" (U+007C)
simonp@8406 658 to <var>s</var>.</p></li>
simonp@8244 659
simonp@8244 660 <li><p>Append the <span title="serialize an identifier">escaped</span>
simonp@8406 661 attribute name to <var>s</var>.</p></li>
simonp@8244 662
simonp@8244 663 <li><p>If there is an attribute value specified, append
simonp@8304 664 "<code title>=</code>",
simonp@8304 665 "<code title>~=</code>",
simonp@8304 666 "<code title>|=</code>",
simonp@8304 667 "<code title>^=</code>",
simonp@8304 668 "<code title>$=</code>", or
simonp@8304 669 "<code title>*=</code>"
simonp@8244 670 as appropriate (depending on the type of attribute selector), followed
simonp@8244 671 by the <span title="serialize a string">string escaped</span>
simonp@8406 672 attribute value, to <var>s</var>.</p></li>
simonp@8244 673
simonp@8304 674 <li><p>Append "<code title>]</code>" (U+005D) to
simonp@8438 675 <var>s</var>.</p></li>
simonp@8244 676 </ol>
simonp@8244 677 </dd>
simonp@8244 678
simonp@8244 679 <dt>class selector</dt>
simonp@8304 680 <dd><p>Append a "<code title>.</code>" (U+002E), followed by the
simonp@8244 681 <span title="serialize an identifier">escaped</span> class name to
simonp@8406 682 <var>s</var>.</p></dd>
simonp@8244 683
simonp@8244 684 <dt>ID selector</dt>
simonp@8304 685 <dd><p>Append a "<code title>#</code>" (U+0023), followed by the
simonp@8244 686 <span title="serialize an identifier">escaped</span> ID to
simonp@8406 687 <var>s</var>.</p></dd>
simonp@8244 688
simonp@8244 689 <dt>pseudo-class</dt>
simonp@8244 690 <dd>
simonp@8244 691 <p>If the pseudo-class does not accept arguments append
simonp@8304 692 "<code title>:</code>" (U+003A), followed by the name of the pseudo-class, to
simonp@8406 693 <var>s</var>.</p>
simonp@8244 694
simonp@8304 695 <p>Otherwise, append "<code title>:</code>" (U+003A), followed by the name of
simonp@8304 696 the pseudo-class, followed by "<code title>(</code>" (U+0028), followed by the
simonp@8244 697 value of the pseudo-class argument determined as per below, followed by
simonp@8406 698 "<code title>)</code>" (U+0029), to <var>s</var>.</p>
simonp@8226 699
simonp@8226 700 <dl class="switch">
simonp@8304 701 <dt><code title>:lang()</code></dt>
simonp@8244 702 <dd><p>The <span title="serialize an identifier">escaped</span>
simonp@8244 703 value.</p></dd>
simonp@8244 704
simonp@8304 705 <dt><code title>:nth-child()</code></dt>
simonp@8304 706 <dt><code title>:nth-last-child()</code></dt>
simonp@8304 707 <dt><code title>:nth-of-type()</code></dt>
simonp@8304 708 <dt><code title>:nth-last-of-type()</code></dt>
simonp@8437 709 <dd><p>The result of serializing the value using the rules for <span data-anolis-spec=csssyntax>serializing &lt;an+b></span>.
simonp@8437 710
simonp@8304 711 <dt><code title>:not()</code></dt>
simonp@8244 712 <dd><p>The result of serializing the value using the rules for
simonp@8244 713 <span title="serialize a group of selectors">serializing a group of selectors</span>.</p></dd>
simonp@8226 714 </dl>
simonp@8244 715 </dd>
simonp@8244 716 </dl>
simonp@8244 717
simonp@8244 718
simonp@8244 719 <h2>CSS</h2>
simonp@8244 720
simonp@8244 721
simonp@8244 722 <h3>CSS Style Sheets</h3>
simonp@8244 723
simonp@8244 724 <p>A <dfn>CSS style sheet</dfn> is an abstract concept that
simonp@8244 725 represents a style sheet as defined by the CSS specification. In the CSSOM a
simonp@8244 726 <span>CSS style sheet</span> is represented as a <code>CSSStyleSheet</code> object. A
simonp@8244 727 <span>CSS style sheet</span> has a number of associated state items:</p>
simonp@8244 728
simonp@8244 729 <dl>
simonp@8305 730 <dt><dfn title=concept-css-style-sheet-type>type</dfn></dt>
simonp@8304 731 <dd><p>The literal string "<code title>text/css</code>".</p></dd>
simonp@8244 732
simonp@8305 733 <dt><dfn title=concept-css-style-sheet-location>location</dfn></dt>
simonp@8373 734 <dd><p>Specified when created. The <span data-anolis-spec=url title=concept-absolute-url>absolute URL</span> of the first request of the
simonp@8303 735 <span>CSS style sheet</span> or null if the <span>CSS style sheet</span> was
simonp@8373 736 embedded. Does not change during the lifetime of the <span>CSS style sheet</span>.</p></dd>
simonp@8244 737
simonp@8441 738 <dt><dfn title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</dfn></dt>
simonp@8373 739 <dd><p>Specified when created. The <span>CSS style sheet</span> that is the parent of the
simonp@8303 740 <span>CSS style sheet</span> or null if there is no associated parent.</p></dd>
simonp@8244 741
simonp@8305 742 <dt><dfn title=concept-css-style-sheet-owner-node>owner node</dfn></dt>
simonp@8373 743 <dd><p>Specified when created. The DOM node associated with the <span>CSS style sheet</span> or
simonp@8289 744 null if there is no associated DOM node.</p></dd>
simonp@8244 745
simonp@8305 746 <dt><dfn title=concept-css-style-sheet-owner-css-rule>owner CSS rule</dfn></dt>
simonp@8441 747 <dd><p>Specified when created. The <span>CSS rule</span> in the <span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span>
simonp@8303 748 that caused the inclusion of the <span>CSS style sheet</span> or null if
simonp@8244 749 there is no associated rule.</p></dd>
simonp@8244 750
simonp@8305 751 <dt><dfn title=concept-css-style-sheet-media>media</dfn></dt>
simonp@8244 752 <dd>
simonp@8373 753 <p>Specified when created. The <code>MediaList</code> object associated with the
simonp@8303 754 <span>CSS style sheet</span>.</p>
simonp@8244 755
simonp@8373 756 <p>If this property is specified to a string, the <span title=concept-css-style-sheet-media>media</span> must be set to the return value of invoking
simonp@8373 757 <span>create a <code>MediaList</code> object</span> steps for that string.</p>
simonp@8560 758
simonp@8560 759 <p>If this property is specified to an attribute of the <span title=concept-css-style-sheet-owner-node>owner node</span>, the
simonp@8560 760 <span title=concept-css-style-sheet-media>media</span> must be set to the return value of invoking <span>create a <code>MediaList</code> object</span> steps
simonp@8560 761 for the value of that attribute. Whenever the attribute is set, changed or removed, the <span title=concept-css-style-sheet-media>media</span>'s
simonp@8560 762 <code title=dom-MediaList-mediaText>mediaText</code> attribute must be set to the new value of the attribute, or to null if the attribute is absent.
simonp@8560 763
simonp@8560 764 <p class=note>Changing the <span title=concept-css-style-sheet-media>media</span>'s <code title=dom-MediaList-mediaText>mediaText</code> attribute does not
simonp@8560 765 change the corresponding attribute on the <span title=concept-css-style-sheet-owner-node>owner node</span>.
simonp@8244 766 </dd>
simonp@8244 767
simonp@8305 768 <dt><dfn title=concept-css-style-sheet-title>title</dfn></dt>
simonp@8244 769 <dd>
simonp@8373 770 <p>Specified when created. The title of the <span>CSS style sheet</span>, which can be the empty string.</p>
simonp@8244 771
simonp@8244 772 <div class="example">
simonp@8305 773 <p>In the following, the <span title=concept-css-style-sheet-title>title</span> is non-empty
simonp@8244 774 for the first style sheet, but is empty for the second and third style sheets.</p>
simonp@8244 775 <pre>&lt;style title="papaya whip">
simonp@8226 776 body { background: #ffefd5; }
simonp@8226 777 &lt;/style></pre>
simonp@8226 778 <pre>&lt;style title="">
simonp@8226 779 body { background: orange; }
simonp@8226 780 &lt;/style></pre>
simonp@8226 781 <pre>&lt;style>
simonp@8226 782 body { background: brown; }
simonp@8226 783 &lt;/style></pre>
simonp@8244 784 </div>
simonp@8560 785
simonp@8560 786 <p>If this property is specified to an attribute of the <span title=concept-css-style-sheet-owner-node>owner node</span>, the
simonp@8560 787 <span title=concept-css-style-sheet-title>title</span> must be set to the value of that attribute. Whenever the attribute is set, changed or removed, the
simonp@8560 788 <span title=concept-css-style-sheet-title>title</span> must be set to the new value of the attribute, or to the empty string if the attribute is absent.
simonp@8560 789
simonp@8244 790 </dd>
simonp@8244 791
simonp@8305 792 <dt><dfn title=concept-css-style-sheet-alternate-flag>alternate flag</dfn></dt>
simonp@8244 793 <dd>
simonp@8373 794 <p>Specified when created. Either set or clear. Clear by default.</p>
simonp@8244 795
simonp@8244 796 <div class="example">
simonp@8304 797 <p>The following <span title="CSS style sheet">CSS style sheets</span> have
simonp@8305 798 their <span title=concept-css-style-sheet-alternate-flag>alternate flag</span> set:</p>
simonp@8244 799
simonp@8244 800 <pre>&lt;?xml-stylesheet alternate="yes" title="x" href="data:text/css,&hellip;"?></pre>
simonp@8244 801
simonp@8244 802 <pre>&lt;link rel="alternate stylesheet" title="x" href="data:text/css,&hellip;"></pre>
simonp@8244 803 </div>
simonp@8244 804 </dd>
simonp@8244 805
simonp@8305 806 <dt><dfn title=concept-css-style-sheet-disabled-flag>disabled flag</dfn></dt>
simonp@8244 807 <dd>
simonp@8244 808 <p>Either set or clear. Clear by default.</p>
simonp@8244 809
simonp@8244 810 <p class="note">Even when clear it does not necessarily mean that the
simonp@8303 811 <span>CSS style sheet</span> is actually used for rendering.</p>
simonp@8244 812 </dd>
simonp@8244 813
simonp@8244 814
simonp@8305 815 <dt><dfn title=concept-css-style-sheet-css-rules>CSS rules</dfn></dt>
simonp@8244 816 <dd><p>The <span title="CSS rule">CSS rules</span> associated with the
simonp@8303 817 <span>CSS style sheet</span>.</p></dd>
simonp@8372 818
simonp@8372 819 <dt><dfn title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</dfn>
simonp@8373 820 <dd><p>Specified when created. Either set or clear. If it is set, the API allows reading and modifying of the <span title=concept-css-style-sheet-css-rules>CSS
simonp@8373 821 rules</span>.
simonp@8244 822 </dl>
simonp@8244 823
simonp@8244 824
simonp@8244 825 <h4>The <code title>StyleSheet</code> Interface</h4>
simonp@8226 826
simonp@8226 827 <!--
simonp@8226 828 //
simonp@8226 829 // All members defined since DOM-2 Style. Only difference
simonp@8226 830 // is addition of [PutForwards=mediaText], which is presently
simonp@8226 831 // not defined in CSSOM draft.
simonp@8226 832 //
simonp@8226 833 -->
simonp@8226 834
simonp@8226 835 <p>The <code>StyleSheet</code> interface represents an abstract, base style sheet.</p>
simonp@8226 836
simonp@8226 837 <pre class=idl>interface <dfn>StyleSheet</dfn> {
simonp@8226 838 readonly attribute DOMString <span title=dom-StyleSheet-type>type</span>;
simonp@8226 839 readonly attribute DOMString? <span title=dom-StyleSheet-href>href</span>;
simonp@8304 840 readonly attribute (<span data-anolis-spec=dom>Element</span> or <span data-anolis-spec=dom>ProcessingInstruction</span>)? <!--
simonp@8304 841 --><span title=dom-StyleSheet-ownerNode>ownerNode</span>;
simonp@8226 842 readonly attribute <span>StyleSheet</span>? <span title=dom-StyleSheet-parentStyleSheet>parentStyleSheet</span>;
simonp@8226 843 readonly attribute DOMString? <span title=dom-StyleSheet-title>title</span>;
simonp@8820 844 [SameObject, PutForwards=<span title=dom-MediaList-mediaText>mediaText</span>] readonly attribute <span>MediaList</span> <!--
simonp@8820 845 --><span title=dom-StyleSheet-media>media</span>;
simonp@8226 846 attribute boolean <span title=dom-StyleSheet-disabled>disabled</span>;
simonp@8226 847 };</pre>
simonp@8226 848
simonp@8305 849 <p>The <dfn title=dom-StyleSheet-type><code>type</code></dfn> attribute must return the <span title=concept-css-style-sheet-type>type</span>.</p>
simonp@8305 850
simonp@8374 851 <p>The <dfn title=dom-StyleSheet-href><code>href</code></dfn> attribute must return the <span title=concept-css-style-sheet-location>location</span>.</p>
simonp@8289 852
simonp@8305 853 <p>The <dfn title=dom-StyleSheet-ownerNode><code>ownerNode</code></dfn> attribute must return the <span title=concept-css-style-sheet-owner-node>owner
simonp@8374 854 node</span>.</p>
simonp@8305 855
simonp@8305 856 <p>The <dfn title=dom-StyleSheet-parentStyleSheet><code>parentStyleSheet</code></dfn> attribute must return the
simonp@8441 857 <span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span>.</p>
simonp@8305 858
simonp@8305 859 <p>The <dfn title=dom-StyleSheet-title><code>title</code></dfn> attribute must return the <span title=concept-css-style-sheet-title>title</span> or null if
simonp@8373 860 <span title=concept-css-style-sheet-title>title</span> is the empty string.</p>
simonp@8226 861
simonp@8305 862 <p>The <dfn title=dom-StyleSheet-media><code>media</code></dfn> attribute must return the <span title=concept-css-style-sheet-media>media</span>.</p>
simonp@8226 863
simonp@8305 864 <p>The <dfn title=dom-StyleSheet-disabled><code>disabled</code></dfn> attribute, on getting, must return true if the
simonp@8305 865 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span>
simonp@8305 866 is set, or false otherwise. On setting, the <code title=dom-StyleSheet-disabled>disabled</code> attribute must set the
simonp@8305 867 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> if the new value is true, or unset the
simonp@8305 868 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> otherwise.</p>
simonp@8226 869
simonp@8226 870
simonp@8244 871 <h4>The <code title>CSSStyleSheet</code> Interface</h4>
simonp@8226 872
simonp@8226 873 <!--
simonp@8226 874 //
simonp@8226 875 // All members defined since DOM-2 Style. The only differences are:
simonp@8226 876 //
simonp@8226 877 // 1. removal of raises(DOMException) on {insert,delete}Rule operations.
simonp@8226 878 //
simonp@8226 879 -->
simonp@8226 880
simonp@8436 881 <p>The <code>CSSStyleSheet</code> interface represents a <span>CSS style sheet</span>.</p>
simonp@8226 882 <pre class=idl>interface <dfn>CSSStyleSheet</dfn> : <span>StyleSheet</span> {
simonp@8226 883 readonly attribute <span>CSSRule</span>? <span title=dom-CSSStyleSheet-ownerRule>ownerRule</span>;
simonp@8820 884 [SameObject] readonly attribute <span>CSSRuleList</span> <span title=dom-CSSStyleSheet-cssRules>cssRules</span>;
simonp@8226 885 unsigned long <span title=dom-CSSStyleSheet-insertRule>insertRule</span>(DOMString rule, unsigned long index);
simonp@8226 886 void <span title=dom-CSSStyleSheet-deleteRule>deleteRule</span>(unsigned long index);
simonp@8226 887 };</pre>
simonp@8226 888
simonp@8305 889 <p>The <dfn title=dom-CSSStyleSheet-ownerRule><code>ownerRule</code></dfn> attribute must return the <span title=concept-css-style-sheet-owner-css-rule>owner
simonp@8436 890 CSS rule</span>. If a value other than null is ever returned, then that same value must always be returned on each get access.</p>
simonp@8226 891
simonp@8372 892 <p>The <dfn title=dom-CSSStyleSheet-cssRules><code>cssRules</code></dfn> attribute must follow these steps:
simonp@8372 893
simonp@8372 894 <ol>
simonp@8372 895 <li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is clear,
simonp@8372 896 <span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
simonp@8372 897 <li><p>Return a read-only, live <code>CSSRuleList</code> object representing
simonp@8820 898 the <span title=concept-css-style-sheet-css-rules>CSS rules</span>.</p>
simonp@8372 899 <p class='note'>Even though the returned <code>CSSRuleList</code> object is read-only (from the perspective of
simonp@8372 900 client-authored script), it can nevertheless change over time due to its liveness status. For example, invoking
simonp@8372 901 the <code title=dom-CSSStyleSheet-insertRule>insertRule()</code> or <code title=dom-CSSStyleSheet-deleteRule>deleteRule()</code> methods can result in
simonp@8372 902 mutations reflected in the returned object.</p>
simonp@8372 903 </ol>
simonp@8372 904
simonp@8406 905 <p>The <dfn title=dom-CSSStyleSheet-insertRule><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must run the following steps:
simonp@8372 906
simonp@8372 907 <ol>
simonp@8372 908 <li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is clear,
simonp@8372 909 <span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
simonp@8406 910 <li><p>Return the result of invoking <span>insert a CSS rule</span> <var>rule</var> in the <span title=concept-css-style-sheet-css-rules>CSS rules</span>
simonp@8406 911 at <var>index</var>.
simonp@8372 912 </ol>
simonp@8372 913
simonp@8406 914 <p>The <dfn title=dom-CSSStyleSheet-deleteRule><code>deleteRule(<var>index</var>)</code></dfn> method must run the following steps:
simonp@8372 915
simonp@8372 916 <ol>
simonp@8372 917 <li><p>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is clear,
simonp@8372 918 <span title=concept-throw data-anolis-spec=dom>throw</span> a <code data-anolis-spec=dom>SecurityError</code> exception.
simonp@8406 919 <li><p><span>Remove a CSS rule</span> in the <span title=concept-css-style-sheet-css-rules>CSS rules</span> at <var>index</var>.
simonp@8372 920 </ol>
simonp@8226 921
simonp@8307 922 <h3>CSS Style Sheet Collections</h3>
simonp@8244 923
simonp@8244 924 <p>Below various new concepts are defined that are associated with each
simonp@8244 925 <code data-anolis-spec=dom>Document</code> object.</p>
simonp@8244 926
simonp@8244 927 <p>Each <code data-anolis-spec=dom>Document</code> has an associated list of zero or more
simonp@8304 928 <span title="CSS style sheet">CSS style sheets</span>, named the
simonp@8306 929 <dfn>document CSS style sheets</dfn>. This is
simonp@8244 930 an ordered list that contains all
simonp@8304 931 <span title="CSS style sheet">CSS style sheets</span> associated with the
simonp@8244 932 <code data-anolis-spec=dom>Document</code>, in
simonp@8244 933 <span data-anolis-spec=dom title=concept-tree-order>tree order</span>, with
simonp@8304 934 <span title="CSS style sheet">CSS style sheets</span> created from HTTP
simonp@8406 935 <code title>Link</code> headers first, if any, in header
simonp@8244 936 order.</p>
simonp@8244 937
simonp@8305 938 <p>To <dfn>create a CSS style sheet</dfn>, run these
simonp@8244 939 steps:</p>
simonp@8244 940
simonp@8244 941 <ol>
simonp@8303 942 <li><p>Create a new <span>CSS style sheet</span> object and set its
simonp@8244 943 properties as specified.</p></li>
simonp@8244 944
simonp@8552 945 <li>
simonp@8552 946 <p>Then run the <span>add a CSS style sheet</span> steps for the newly created <span>CSS style sheet</span>.
simonp@8552 947
simonp@8552 948 <p class=warning>If the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> is unset, this can expose information from the user's
simonp@8552 949 intranet.
simonp@8244 950 </ol>
simonp@8244 951
simonp@8306 952 <p>To <dfn>add a CSS style sheet</dfn>, run these
simonp@8244 953 steps:</p>
simonp@8244 954
simonp@8244 955 <ol>
simonp@8303 956 <li><p>Add the <span>CSS style sheet</span> to the list of
simonp@8306 957 <span>document CSS style sheets</span> at the appropriate location. The
simonp@8244 958 remainder of these steps deal with the
simonp@8305 959 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span>.</p></li>
simonp@8305 960
simonp@8305 961 <li><p>If the <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> is set, terminate
simonp@8244 962 these steps.</p></li>
simonp@8244 963
simonp@8373 964 <li><p>If the <span title=concept-css-style-sheet-title>title</span> is not the empty string, the
simonp@8305 965 <span title=concept-css-style-sheet-alternate-flag>alternate flag</span> is clear, and
simonp@8306 966 <span>preferred CSS style sheet set name</span> is the empty string
simonp@8306 967 <span>change the preferred CSS style sheet set name</span> to the
simonp@8305 968 <span title=concept-css-style-sheet-title>title</span>.</p></li>
simonp@8244 969
simonp@8244 970 <li>
simonp@8244 971 <p>If any of the following is true clear the
simonp@8305 972 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> and terminate these steps:
simonp@8244 973
simonp@8244 974 <ul>
simonp@8373 975 <li><p>The <span title=concept-css-style-sheet-title>title</span> is the empty string.</p></li>
simonp@8306 976 <li><p>The <span>last CSS style sheet set name</span> is null and the
simonp@8305 977 <span title=concept-css-style-sheet-title>title</span> is a
simonp@8244 978 <span data-anolis-spec=dom>case-sensitive</span> match
simonp@8306 979 for the <span>preferred CSS style sheet set name</span>.</p></li>
simonp@8305 980 <li><p>The <span title=concept-css-style-sheet-title>title</span> is a
simonp@8244 981 <span data-anolis-spec=dom>case-sensitive</span> match for the
simonp@8306 982 <span>last CSS style sheet set name</span>.</p></li>
simonp@8244 983 </ul>
simonp@8244 984 </li>
simonp@8244 985
simonp@8305 986 <li><p>Set the <span title=concept-css-style-sheet-disabled-flag>disabled flag</span>.</li>
simonp@8244 987 </ol>
simonp@8244 988
simonp@8440 989 <p>To <dfn>remove a CSS style sheet</dfn>, run these steps:</p>
simonp@8440 990
simonp@8440 991 <ol>
simonp@8440 992 <li><p>Remove the <span>CSS style sheet</span> from the list of <span>document CSS style sheets</span>.
simonp@8440 993
simonp@8444 994 <li><p>Set the <span>CSS style sheet</span>'s <span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span>,
simonp@8444 995 <span title=concept-css-style-sheet-owner-node>owner node</span> and <span title=concept-css-style-sheet-owner-css-rule>owner CSS rule</span> to null.
simonp@8440 996
simonp@8440 997 <!-- "associated CSS style sheet" is defined in terms of owner node, so we don't need to set it to null explicitly -->
simonp@8440 998
simonp@8440 999 <!-- XXX does anything need to happen wrt alternate style sheets? what if the last style sheet with the preferred style sheet set name is removed? -->
simonp@8440 1000 </ol>
simonp@8440 1001
simonp@8306 1002 <p>A <dfn>persistent CSS style sheet</dfn> is a
simonp@8306 1003 <span>CSS style sheet</span> from the <span>document CSS style sheets</span>
simonp@8305 1004 whose <span title=concept-css-style-sheet-title>title</span> is the empty string and whose
simonp@8305 1005 <span title=concept-css-style-sheet-alternate-flag>alternate flag</span> is clear.</p>
simonp@8244 1006
simonp@8306 1007 <p>A <dfn>CSS style sheet set</dfn> is an ordered
simonp@8304 1008 collection of one or more <span title="CSS style sheet">CSS style sheets</span>
simonp@8306 1009 from the <span>document CSS style sheets</span> which have an identical
simonp@8305 1010 <span title=concept-css-style-sheet-title>title</span> that is not the empty string.</p>
simonp@8244 1011
simonp@8306 1012 <p>A <dfn>CSS style sheet set name</dfn> is the
simonp@8306 1013 <span title=concept-css-style-sheet-title>title</span> the <span>CSS style sheet set</span> has in
simonp@8244 1014 common.</p>
simonp@8244 1015
simonp@8306 1016 <p>An <dfn>enabled CSS style sheet set</dfn> is a
simonp@8306 1017 <span>CSS style sheet set</span> of which each <span>CSS style sheet</span> has
simonp@8305 1018 its <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> clear.</p>
simonp@8244 1019
simonp@8306 1020 <p>To <dfn>enable a CSS style sheet set</dfn>
simonp@8406 1021 with name <var>name</var>, run these steps:</p>
simonp@8244 1022
simonp@8244 1023 <ol>
simonp@8406 1024 <li><p>If <var>name</var> is the empty string, set the
simonp@8305 1025 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> for each <span>CSS style sheet</span>
simonp@8306 1026 that is in a <span>CSS style sheet set</span> and terminate these steps.</li>
simonp@8305 1027
simonp@8305 1028 <li><p>Clear the <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> for each
simonp@8306 1029 <span>CSS style sheet</span> in a <span>CSS style sheet set</span> whose
simonp@8327 1030 <span>CSS style sheet set name</span> is a
simonp@8244 1031 <span data-anolis-spec=dom>case-sensitive</span> match for
simonp@8406 1032 <var>name</var> and set it for all other
simonp@8304 1033 <span title="CSS style sheet">CSS style sheets</span> in a
simonp@8306 1034 <span>CSS style sheet set</span>.</p></li>
simonp@8244 1035 </ol>
simonp@8244 1036
simonp@8306 1037 <p>To <dfn>select a CSS style sheet set</dfn>
simonp@8406 1038 with name <var>name</var>, run these steps:</p>
simonp@8244 1039
simonp@8244 1040 <ol>
simonp@8306 1041 <li><p><span>enable a CSS style sheet set</span> with name
simonp@8406 1042 <var>name</var>.</p></li>
simonp@8244 1043
simonp@8306 1044 <li><p>Set <span>last CSS style sheet set name</span> to
simonp@8406 1045 <var>name</var>.</p></li>
simonp@8244 1046 </ol>
simonp@8244 1047
simonp@8306 1048 <p>A <dfn>last CSS style sheet set name</dfn>
simonp@8306 1049 is a concept to determine what <span>CSS style sheet set</span> was last
simonp@8306 1050 <span title="select a CSS style sheet set">selected</span>. Initially its
simonp@8289 1051 value is null.</p>
simonp@8244 1052
simonp@8244 1053 <p>A
simonp@8306 1054 <dfn>preferred CSS style sheet set name</dfn>
simonp@8244 1055 is a concept to determine which
simonp@8304 1056 <span title="CSS style sheet">CSS style sheets</span> need to have their
simonp@8305 1057 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> clear. Initially its value
simonp@8244 1058 is the empty string.
simonp@8244 1059
simonp@8244 1060 <p>To
simonp@8306 1061 <dfn>change the preferred CSS style sheet set name</dfn>
simonp@8406 1062 with name <var>name</var>, run these steps:</p>
simonp@8244 1063
simonp@8244 1064 <ol>
simonp@8406 1065 <li><p>Let <var>current</var> be the <span>preferred CSS style sheet set name</span>.</p></li>
simonp@8306 1066
simonp@8306 1067 <li><p>Set <span>preferred CSS style sheet set name</span> to
simonp@8406 1068 <var>name</var>.</p></li>
simonp@8406 1069
simonp@8406 1070 <li><p>If <var>name</var> is not a
simonp@8244 1071 <span data-anolis-spec=dom>case-sensitive</span> match for
simonp@8406 1072 <var>current</var> and
simonp@8306 1073 <span>last CSS style sheet set name</span> is null
simonp@8306 1074 <span>enable a CSS style sheet set</span> with name
simonp@8406 1075 <var>name</var>.</p></li>
simonp@8244 1076 </ol>
simonp@8244 1077
simonp@8244 1078 <!-- XXX ought to define "applied"
simonp@8244 1079
simonp@8244 1080 thoughts:
simonp@8244 1081 depends on disabled flag, alternate flag, media queries, sheesh
simonp@8244 1082 -->
simonp@8244 1083
simonp@8244 1084
simonp@8244 1085 <h4>The HTTP <code title>Default-Style</code> Header</h4>
simonp@8244 1086
simonp@8244 1087 <p>The HTTP <code title="http-default-style">Default-Style</code> header
simonp@8306 1088 can be used to set the <span>preferred CSS style sheet set name</span>
simonp@8306 1089 influencing which <span>CSS style sheet set</span> is (initially) the
simonp@8306 1090 <span>enabled CSS style sheet set</span>.</p>
simonp@8244 1091
simonp@8244 1092 <p>For each HTTP <code title="http-default-style">Default-Style</code>
simonp@8244 1093 header, in header order, the user agent must
simonp@8306 1094 <span>change the preferred CSS style sheet set name</span> with name being the
simonp@8244 1095 value of the header.</p>
simonp@8244 1096
simonp@8244 1097
simonp@8244 1098 <h4>The <code title>StyleSheetList</code> Interface</h4>
simonp@8229 1099
simonp@8304 1100 <p>The <code>StyleSheetList</code> interface represents an ordered collection of <span title="CSS style sheet">CSS style sheets</span>.</p>
simonp@8229 1101
simonp@8229 1102 <pre class=idl>[ArrayClass]
simonp@8229 1103 interface <dfn>StyleSheetList</dfn> {
simonp@8229 1104 getter <span>StyleSheet</span>? <span title=dom-StyleSheetList-item>item</span>(unsigned long index);
simonp@8229 1105 readonly attribute unsigned long <span title=dom-StyleSheetList-length>length</span>;
simonp@8229 1106 };</pre>
simonp@8229 1107
simonp@8304 1108 <p>The object's <span data-anolis-spec=webidl>supported property indices</span> are the numbers in the range zero to one less than the number of
simonp@8304 1109 <span title="CSS style sheet">CSS style sheets</span> represented by the collection. If there are no such <span title="CSS style sheet">CSS style sheets</span>,
simonp@8304 1110 then there are no <span data-anolis-spec=webidl>supported property indices</span>.
simonp@8304 1111
simonp@8406 1112 <p>The <dfn title=dom-StyleSheetList-item><code>item(<var>index</var>)</code></dfn> method must return the <var>index</var>th <span>CSS style
simonp@8406 1113 sheet</span> in the collection. If there is no <var>index</var>th object in the collection, then the method must return null.
simonp@8304 1114
simonp@8304 1115 <p>The <dfn title=dom-StyleSheetList-length><code>length</code></dfn> attribute must return the number of <span title="CSS style sheet">CSS style sheets</span>
simonp@8304 1116 represented by the collection.
simonp@8226 1117
simonp@8244 1118 <h4>Extensions to the <code title>Document</code> Interface</h4>
simonp@8226 1119
simonp@8226 1120 <!--
simonp@8226 1121 //
simonp@8226 1122 // Significant changes since DOM-2 Style:
simonp@8226 1123 //
simonp@8226 1124 // 1. move styleSheets from separate interface (DocumentStyle) to Document
simonp@8226 1125 // 2. addition of selectedStyleSheetSet, lastStyleSheetSet, preferredStyleSheetSet, styleSheetSets, and enableStyleSheetsForSet members
simonp@8226 1126 //
simonp@8226 1127 // N.B. HTML4 Section 14.3 "External Style Sheets" introduces the concept of a "group [of] alternate style sheets ... under a single style [sheet set] name",
simonp@8226 1128 // but does not actually use the term "style sheet set". See http://www.w3.org/TR/html401/present/styles.html#h-14.3 for details.
simonp@8226 1129 //
simonp@8226 1130 // N.B. According to HTML4 Section 14.3, a "persistent style sheet ... must apply in addition to any alternate style sheet".
simonp@8226 1131 //
simonp@8226 1132 // N.B. HTML4 Section 14.3 distinguishes the three categories of style sheets as follows:
simonp@8226 1133 //
simonp@8226 1134 // * persistent - @rel='stylesheet', @title is missing (or empty string?)
simonp@8226 1135 // * preferred - @rel='stylesheet', @title is present (and non-empty?)
simonp@8226 1136 // * alternate - @rel='alternate stylesheet', @title is present (and non-empty?)
simonp@8226 1137 //
simonp@8226 1138 // Also, HTML5 effectively defines:
simonp@8226 1139 //
simonp@8226 1140 // * ignored - @rel='alternate stylesheet', @title is missing (or is empty string?) - in this case, LinkStyle.style must evaluate to null
simonp@8226 1141 //
simonp@8304 1142 // N.B. HTML4 Section 4.3 allows author to specify the default preferred style sheet [set]... [presumably in the case that there are multiple preferred style
simonp@8304 1143 // sheet sets]:
simonp@8226 1144 //
simonp@8226 1145 // * in content - <META http-equiv="Default-Style" content="compact">
simonp@8226 1146 // * in http - e.g., using response header - "Default-Style: compact"
simonp@8304 1147 // * if multiple of the above forms are present, then the LAST one [seen or parsed] takes precedence; HOWEVER, if two or more LINK elements specify preferred
simonp@8304 1148 // style [sheet sets], the FIRST one present in the document takes precedence;
simonp@8226 1149 // * preferred style sheets specified using the above (META or HTTP header equivalent) take precedence over those specified with LINK
simonp@8226 1150 //
simonp@8226 1151 // N.B. CSSOM Draft presently employs the term "Style Sheet Collection"
simonp@8226 1152 //
simonp@8226 1153 // Spec Issues:
simonp@8226 1154 //
simonp@8226 1155 // 1. need to specify which style sheets are included in styleSheets, and in which order:
simonp@8226 1156 //
simonp@8226 1157 // * from Link HTTP header reference
simonp@8226 1158 // * from <?xml-stylesheet ...?>
simonp@8226 1159 // * from LINK element, @rel='stylesheet'|'alternate stylesheet'
simonp@8226 1160 // * from STYLE element
simonp@8226 1161 //
simonp@8226 1162 // 2. for purpose of comparing two titled (named) style sheets, is title (name) compared on case-sensitive or case-insensitive basis
simonp@8226 1163 //
simonp@8226 1164 // 3. CSSOM 6.2 appears to imply that one can create a CSSStyleSheet (or StyleSheet) object and add it to a Document. However, that is not the case; rather
simonp@8304 1165 // it is necessary to create an HTMLLinkElement or HTMLStyleElement element to indirectly create an empty StyleSheet, then this element can be added to the
simonp@8304 1166 // Document.
simonp@8226 1167 //
simonp@8226 1168 -->
simonp@8226 1169
simonp@8226 1170 <pre class=idl>partial interface <span data-anolis-spec=dom>Document</span> {
simonp@8820 1171 [SameObject] readonly attribute <span>StyleSheetList</span> <span title=dom-Document-styleSheets>styleSheets</span>;<!-- DOM-2 - defined on DocumentStyle
simonp@8820 1172 interface -->
simonp@8226 1173 attribute DOMString? <span title=dom-Document-selectedStyleSheetSet>selectedStyleSheetSet</span>;<!-- new -->
simonp@8226 1174 readonly attribute DOMString? <span title=dom-Document-lastStyleSheetSet>lastStyleSheetSet</span>;<!-- new -->
simonp@8226 1175 readonly attribute DOMString? <span title=dom-Document-preferredStyleSheetSet>preferredStyleSheetSet</span>;<!-- new -->
simonp@8226 1176 readonly attribute DOMString[] <span title=dom-Document-styleSheetSets>styleSheetSets</span>;<!-- new -->
simonp@8226 1177 void <span title=dom-Document-enableStyleSheetsForSet>enableStyleSheetsForSet</span>(DOMString? name);<!-- new -->
simonp@8226 1178 };</pre>
simonp@8226 1179
simonp@8229 1180 <p>The <dfn title=dom-Document-styleSheets><code>styleSheets</code></dfn> attribute must return a <code>StyleSheetList</code> collection representing
simonp@8306 1181 the <span>document CSS style sheets</span>.</p>
simonp@8226 1182 <p class='note'>Because of historical IDL limitations the <code title=dom-Document-styleSheets>styleSheets</code> attribute
simonp@8406 1183 used to be on a separate interface, <code title>DocumentStyle</code>.</p>
simonp@8226 1184
simonp@8301 1185 <p>The <dfn title=dom-Document-selectedStyleSheetSet><code>selectedStyleSheetSet</code></dfn> attribute, on getting, must run these steps:</p>
simonp@8226 1186 <ol>
simonp@8306 1187 <li><p>If there is a single <span>enabled CSS style sheet set</span> and no
simonp@8373 1188 other <span>document CSS style sheets</span> with a
simonp@8373 1189 <span title=concept-css-style-sheet-title>title</span> that is not the empty string have the
simonp@8305 1190 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> unset, return the
simonp@8327 1191 <span>CSS style sheet set name</span> of the
simonp@8306 1192 <span>enabled CSS style sheet set</span> and terminate these steps.</li>
simonp@8226 1193
simonp@8304 1194 <li><p>Otherwise, if <span title="CSS style sheet">CSS style sheets</span> from
simonp@8306 1195 different <span title='CSS style sheet set'>CSS style sheet sets</span> have
simonp@8305 1196 their <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> unset, return
simonp@8289 1197 null and terminate these steps.</li>
simonp@8226 1198
simonp@8226 1199 <li>
simonp@8226 1200 <p>Otherwise, return the empty string.</p>
simonp@8226 1201
simonp@8226 1202 <p class='note'>At this point either all
simonp@8373 1203 <span title="CSS style sheet">CSS style sheets</span> with a
simonp@8373 1204 <span title=concept-css-style-sheet-title>title</span> that is not the empty string have the
simonp@8305 1205 <span title=concept-css-style-sheet-disabled-flag>disabled flag</span> set, or there are no such
simonp@8304 1206 <span title="CSS style sheet">CSS style sheets</span>.</p>
simonp@8226 1207 </li>
simonp@8226 1208 </ol>
simonp@8226 1209
simonp@8226 1210 <p>On setting the
simonp@8226 1211 <code title='dom-Document-selectedStyleSheetSet'>selectedStyleSheetSet</code>
simonp@8226 1212 attribute these steps must be run:</p>
simonp@8226 1213
simonp@8226 1214 <ol>
simonp@8289 1215 <li><p>If the value is null terminate this set of steps.</p></li>
simonp@8331 1216 <li><p>Otherwise, <span>select a CSS style sheet set</span> with the name being the
simonp@8226 1217 value passed.</p></li>
simonp@8226 1218 </ol>
simonp@8226 1219
simonp@8226 1220 <p>From the DOM's perspective, all views have the same
simonp@8226 1221 <code title='dom-Document-selectedStyleSheetSet'>selectedStyleSheetSet</code>.
simonp@8226 1222 If a user agent supports multiple views with different selected
simonp@8226 1223 alternative style sheets, then this attribute (and the
simonp@8226 1224 <code>StyleSheet</code> interface's
simonp@8226 1225 <code title='dom-StyleSheet-disabled'>disabled</code> attribute)
simonp@8226 1226 must return and set the value for the default
simonp@8226 1227 view.</p>
simonp@8226 1228
simonp@8306 1229 <p>The <dfn title=dom-Document-lastStyleSheetSet><code>lastStyleSheetSet</code></dfn> attribute must return the <span>last CSS style sheet set name</span>.</p>
simonp@8289 1230 <p class='note'>This attribute is initially null.</p>
simonp@8226 1231
simonp@8327 1232 <p>The <dfn title=dom-Document-preferredStyleSheetSet><code>preferredStyleSheetSet</code></dfn> attribute must return the <span>preferred CSS style sheet set
simonp@8304 1233 name</span>.</p>
simonp@8226 1234 <p class='note'>Unlike <code title='dom-Document-lastStyleSheetSet'>lastStyleSheetSet</code>,
simonp@8226 1235 this attribute is initially the empty string.</p>
simonp@8226 1236
simonp@8226 1237 <p>The <dfn title=dom-Document-styleSheetSets><code>styleSheetSets</code></dfn> attribute must return a read only array of the
simonp@8583 1238 <span title='CSS style sheet set name'>CSS style sheet set names</span> of the <span title='CSS style sheet set'>CSS style sheet sets</span>, in order of the
simonp@8820 1239 <span>document CSS style sheets</span>. The array is live; if the <span>document CSS style sheets</span> change, the array must be updated as appropriate.</p>
simonp@8226 1240
simonp@8406 1241 <p>The <dfn title=dom-Document-enableStyleSheetsForSet><code>enableStyleSheetsForSet(<var>name</var>)</code></dfn> method must, when invoked, run these
simonp@8304 1242 steps:</p>
simonp@8226 1243 <ol>
simonp@8406 1244 <li><p>If <var>name</var> is null terminate these steps.</p></li>
simonp@8406 1245 <li><p><span>enable a CSS style sheet set</span> with name <var>name</var>.</p></li>
simonp@8226 1246 </ol>
simonp@8373 1247 <p class='note'><span title='CSS style sheet'>CSS style sheets</span> with a
simonp@8373 1248 <span title=concept-css-style-sheet-title>title</span> that is the empty string are never affected by this method.
simonp@8226 1249 This method does not change the values of the
simonp@8226 1250 <code title='dom-Document-lastStyleSheetSet'>lastStyleSheetSet</code> or
simonp@8226 1251 <code title='dom-Document-preferredStyleSheetSet'>preferredStyleSheetSet</code> attributes.</p>
simonp@8226 1252
simonp@8226 1253
simonp@8244 1254 <h4>Interaction with the User Interface</h4>
simonp@8244 1255
simonp@8244 1256 <p>The user interface of Web browsers that support style sheets
simonp@8244 1257 should list the style sheet titles given in the
simonp@8244 1258 <code title="dom-Document-styleSheetSets">styleSheetSets</code> list,
simonp@8244 1259 showing the
simonp@8244 1260 <code title="dom-Document-selectedStyleSheetSet">selectedStyleSheetSet</code>
simonp@8244 1261 as the selected style sheet set, leaving none selected if it is
simonp@8289 1262 null or the empty string, and selecting an extra option
simonp@8244 1263 "Basic Page Style" (or similar) if it is the empty string and the
simonp@8244 1264 <code title="dom-Document-preferredStyleSheetSet">preferredStyleSheetSet</code>
simonp@8244 1265 is the empty string as well.</p>
simonp@8244 1266
simonp@8244 1267 <p>Selecting a style sheet from this list should
simonp@8306 1268 use the <span>select a CSS style sheet set</span> set of steps. This
simonp@8244 1269 (by definition) affects the
simonp@8244 1270 <code title="dom-Document-lastStyleSheetSet">lastStyleSheetSet</code>
simonp@8244 1271 attribute.</p>
simonp@8244 1272
simonp@8307 1273 <h5>Persisting the selected CSS style sheet set</h5>
simonp@8307 1274
simonp@8307 1275 <p>If a user agent persist the <span title="select a CSS style sheet set">selected</span> <span>CSS style sheet set</span>, it should use
simonp@8244 1276 the value of the
simonp@8244 1277 <code title="dom-Document-selectedStyleSheetSet">selectedStyleSheetSet</code>
simonp@8289 1278 attribute, or if that is null, the
simonp@8244 1279 <code title="dom-Document-lastStyleSheetSet">lastStyleSheetSet</code>
simonp@8244 1280 attribute, when leaving the page (or at some other time) to determine the
simonp@8307 1281 set name to store. If that is null then the <span>CSS style sheet set</span> should not be
simonp@8244 1282 persisted.</p>
simonp@8244 1283
simonp@8307 1284 <p>When re-setting the <span>CSS style sheet set</span> to the persisted value (which can
simonp@8307 1285 happen at any time, typically at the first time the <span title="CSS style sheet">CSS style sheets</span> are
simonp@8304 1286 needed for styling the document, after the <code title>&lt;head&gt;</code> of
simonp@8244 1287 the document has been parsed, after any scripts that are not dependent on
simonp@8307 1288 computed style have executed), the <span>CSS style sheet set</span>
simonp@8244 1289 should be set by using the
simonp@8306 1290 <span>select a CSS style sheet set</span> set of steps as if the user had
simonp@8307 1291 selected the <span>CSS style sheet set</span> manually.</p>
simonp@8244 1292
simonp@8244 1293 <p class="note">This specification does not give any suggestions on
simonp@8307 1294 how user agents are to decide to persist the <span>CSS style sheet set</span> or whether or
simonp@8307 1295 how to persist the <span title="select a CSS style sheet set">selected</span> <span>CSS style sheet set</span> across pages.</p>
simonp@8244 1296
simonp@8244 1297 <!-- XXX this UI section suggests we may want to introduce a few more
simonp@8244 1298 idioms -->
simonp@8244 1299
simonp@8244 1300
simonp@8244 1301 <h4>Examples</h4>
simonp@8244 1302
simonp@8244 1303 <div class="example">
simonp@8244 1304 <p>Thus, in the following HTML snippet:</p>
simonp@8244 1305
simonp@8244 1306 <pre>&lt;link rel="alternate stylesheet" title="foo" href="a"&gt;
simonp@8226 1307 &lt;link rel="alternate stylesheet" title="bar" href="b"&gt;
simonp@8226 1308 &lt;script&gt;
simonp@8226 1309 document.selectedStyleSheetSet = 'foo';
simonp@8226 1310 document.styleSheets[1].disabled = false;
simonp@8226 1311 &lt;/script&gt;
simonp@8226 1312 &lt;link rel="alternate stylesheet" title="foo" href="c"&gt;
simonp@8226 1313 &lt;link rel="alternate stylesheet" title="bar" href="d"&gt;</pre>
simonp@8226 1314
simonp@8244 1315 <p>...the style sheets that end up enabled are style sheets "a", "b",
simonp@8244 1316 and "c", the
simonp@8244 1317 <code title="dom-Document-selectedStyleSheetSet">selectedStyleSheetSet</code>
simonp@8289 1318 attribute would return null,
simonp@8244 1319 <code title="dom-Document-lastStyleSheetSet">lastStyleSheetSet</code>
simonp@8244 1320 would return "foo", and
simonp@8244 1321 <code title="dom-Document-preferredStyleSheetSet">preferredStyleSheetSet</code>
simonp@8244 1322 would return the empty string.</p>
simonp@8244 1323
simonp@8244 1324 <p>Similarly, in the following HTML snippet:</p>
simonp@8244 1325
simonp@8244 1326 <pre>&lt;link rel="alternate stylesheet" title="foo" href="a"&gt;
simonp@8226 1327 &lt;link rel="alternate stylesheet" title="bar" href="b"&gt;
simonp@8226 1328 &lt;script&gt;
simonp@8226 1329 var before = document.preferredStyleSheetSet;
simonp@8226 1330 document.styleSheets[1].disabled = false;
simonp@8226 1331 &lt;/script&gt;
simonp@8226 1332 &lt;link rel="stylesheet" title="foo" href="c"&gt;
simonp@8226 1333 &lt;link rel="alternate stylesheet" title="bar" href="d"&gt;
simonp@8226 1334 &lt;script&gt;
simonp@8226 1335 var after = document.preferredStyleSheetSet;
simonp@8226 1336 &lt;/script&gt;</pre>
simonp@8226 1337
simonp@8244 1338 <p>...the "before" variable will be equal to the empty string, the
simonp@8244 1339 "after" variable will be equal to "foo", and style sheets "a" and "c"
simonp@8244 1340 will be enabled. This is the case even though the first script block
simonp@8244 1341 sets style sheet "b" to be enabled, because upon parsing the
simonp@8304 1342 following <code title>&lt;link&gt;</code> element, the
simonp@8244 1343 <code title="dom-Document-preferredStyleSheetSet">preferredStyleSheetSet</code>
simonp@8244 1344 is set and the
simonp@8244 1345 <code title="dom-Document-enableStyleSheetsForSet">enableStyleSheetsForSet()</code>
simonp@8244 1346 method is called (since
simonp@8244 1347 <code title="dom-Document-selectedStyleSheetSet">selectedStyleSheetSet</code>
simonp@8244 1348 was never set
simonp@8244 1349 explicitly, leaving
simonp@8244 1350 <code title="dom-Document-lastStyleSheetSet">lastStyleSheetSet</code> at
simonp@8289 1351 null throughout), which changes which style sheets are enabled and which
simonp@8244 1352 are not.</p>
simonp@8244 1353 </div>
simonp@8244 1354
simonp@8244 1355
simonp@8244 1356 <h3>Style Sheet Association</h3>
simonp@8244 1357
simonp@8826 1358 <p>This section defines the interface an
simonp@8305 1359 <span title=concept-css-style-sheet-owner-node>owner node</span> of a <span>CSS style sheet</span> has to
simonp@8244 1360 implement and defines the requirements for
simonp@8244 1361 <span data-anolis-spec=xmlss title="xml-stylesheet processing instruction">xml-stylesheet processing instructions</span>
simonp@8406 1362 and HTTP <code title>Link</code> headers when the link
simonp@8244 1363 relation type is an
simonp@8244 1364 <span data-anolis-spec=dom>ASCII case-insensitive</span> match for
simonp@8304 1365 "<code title>stylesheet</code>" since nobody else was interested in
simonp@8244 1366 defining this.</p>
simonp@8244 1367
simonp@8244 1368 <p class=note>The editor is in good hope that HTML and SVG will define the
simonp@8244 1369 appropriate processing in their respective specifications, in terms of
simonp@8244 1370 this specification, in due course.</p>
simonp@8244 1371
simonp@8244 1372
simonp@8522 1373 <h4>Fetching CSS style sheets</h4>
simonp@8522 1374
simonp@8523 1375 <p>To <dfn>fetch a CSS style sheet</dfn> with parsed URL <var>parsed URL</var>, referrer <var>referrer</var>, document
simonp@8522 1376 <var>document</var>, optionally a set of parameters <var>parameters</var> (used as input to creating a
simonp@8522 1377 <span data-anolis-spec=fetch title=concept-request>request</span>), follow these steps:
simonp@8522 1378
simonp@8522 1379 <ol>
simonp@8522 1380 <li><p>Let <var>origin</var> be <var>document</var>'s <span data-anolis-spec=html>origin</span>.
simonp@8522 1381
simonp@8522 1382 <li><p>Let <var>request</var> be a new <span data-anolis-spec=fetch title=concept-request>request</span>, with the
simonp@8522 1383 <span data-anolis-spec=fetch title=concept-request-url>url</span> <var>parsed URL</var>,
simonp@8522 1384 <span data-anolis-spec=fetch title=concept-request-origin>origin</span> <var>origin</var>,
simonp@8522 1385 <span data-anolis-spec=fetch title=concept-request-referrer>referrer</span> <var>referrer</var>, and if specified the set of parameters <var>parameters</var>.
simonp@8522 1386
simonp@8522 1387 <li><p>Let <var>response</var> be the result of <span data-anolis-spec=fetch title=concept-fetch>fetching</span> <var>request</var>.</p></li>
simonp@8522 1388
simonp@8522 1389 <li><p>Wait until <var>response</var> is available.
simonp@8522 1390
simonp@8522 1391 <li><p>If <var>response</var> is a <span data-anolis-spec=fetch title=concept-network-error>network error</span>, return an error.
simonp@8522 1392
simonp@8522 1393 <li><p>If <var>document</var> is in <span data-anolis-spec=dom title=concept-document-quirks>quirks mode</span>, <var>response</var> is
simonp@8522 1394 <span data-anolis-spec=fetch>CORS-same-origin</span> and the <span data-anolis-spec=html>Content-Type metadata</span> of <var>response</var> is not a
simonp@8522 1395 <span>supported styling language</span> change the <span data-anolis-spec=html>Content-Type metadata</span> of <var>response</var> to
simonp@8522 1396 <code title>text/css</code>.
simonp@8522 1397
simonp@8522 1398 <li><p>If <var>response</var> is not in a <span>supported styling language</span> return an error.</p></li>
simonp@8522 1399
simonp@8522 1400 <li><p>Return <var>response</var>.
simonp@8522 1401 </ol>
simonp@8244 1402
simonp@8244 1403 <h4>The <code title>LinkStyle</code> Interface</h4>
simonp@8226 1404
simonp@8307 1405 <p>The <dfn>associated CSS style sheet</dfn> of a node is the <span>CSS style sheet</span> in the list of
simonp@8306 1406 <span>document CSS style sheets</span> of which the <span title=concept-css-style-sheet-owner-node>owner node</span> implements the <code>LinkStyle</code>
simonp@8305 1407 interface.</p>
simonp@8226 1408
simonp@8226 1409 <pre class=idl>[NoInterfaceObject]
simonp@8226 1410 interface <dfn>LinkStyle</dfn> {
simonp@8226 1411 readonly attribute <span>StyleSheet</span>? <span title=dom-LinkStyle-sheet>sheet</span>;
simonp@8226 1412 };</pre>
simonp@8226 1413
simonp@8307 1414 <p>The <dfn title=dom-LinkStyle-sheet><code>sheet</code></dfn> attribute must return the <span>associated CSS style sheet</span> for the node or null
simonp@8307 1415 if there is no <span>associated CSS style sheet</span>.</p>
simonp@8244 1416
simonp@8244 1417 <div class="example">
simonp@8304 1418 <p>In the following fragment, the first <code title>style</code>
simonp@8304 1419 element has a <code title=dom-LinkStyle-sheet>sheet</code> attribute that returns a
simonp@8244 1420 <code>StyleSheet</code> object representing the style sheet, but for
simonp@8304 1421 the second <code title>style</code> element, the <code title=dom-LinkStyle-sheet>sheet</code> attribute returns null,
simonp@8304 1422 assuming the user agent supports CSS (<code title>text/css</code>), but does
simonp@8304 1423 not support the (hypothetical) ExampleSheets (<code title>text/example-sheets</code>).</p>
simonp@8244 1424
simonp@8244 1425 <pre>&lt;style type="text/css"&gt;
simonp@8226 1426 body { background:lime }
simonp@8226 1427 &lt;/style&gt;</pre>
simonp@8226 1428 <pre>&lt;style type="text/example-sheets"&gt;
simonp@8226 1429 $(body).background := lime
simonp@8226 1430 &lt;/style&gt;</pre>
simonp@8244 1431 </div>
simonp@8244 1432
simonp@8244 1433 <p class="note">Whether or not the node refers to a style sheet is defined
simonp@8244 1434 by the specification that defines the semantics of said node.</p>
simonp@8244 1435
simonp@8244 1436
simonp@8244 1437 <h4>Requirements on specifications</h4>
simonp@8244 1438
simonp@8244 1439 <p>Specifications introducing new ways of associating style sheets through
simonp@8244 1440 the DOM should define which nodes implement the
simonp@8244 1441 <code>LinkStyle</code> interface. When doing so, they
simonp@8303 1442 must also define when a <span>CSS style sheet</span> is
simonp@8305 1443 <span title="create a CSS style sheet">created</span>.</p>
simonp@8244 1444
simonp@8244 1445
simonp@8244 1446
simonp@8244 1447
simonp@8244 1448
simonp@8440 1449 <h4>Requirements on User Agents Implementing the xml-stylesheet processing instruction</h4>
simonp@8440 1450
simonp@8440 1451 <!-- XXX load/error events -->
simonp@8244 1452
simonp@8244 1453 <pre class="idl"><span data-anolis-spec=dom>ProcessingInstruction</span> implements <span>LinkStyle</span>;</pre>
simonp@8244 1454
simonp@8440 1455 <p>The <dfn>prolog</dfn> refers to <span data-anolis-spec=dom title=concept-node>nodes</span> that are children of the
simonp@8440 1456 <span data-anolis-spec=dom title=concept-document>document</span> and are not <span data-anolis-spec=dom title=concept-tree-following>following</span> the
simonp@8440 1457 <code data-anolis-spec=dom>Element</code> child of the <span data-anolis-spec=dom title=concept-document>document</span>, if any.
simonp@8440 1458
simonp@8440 1459 <p>When a <code data-anolis-spec=dom>ProcessingInstruction</code> <span data-anolis-spec=dom title=concept-node>node</span> <var>node</var> is inserted to a
simonp@8440 1460 document, removed from a document, becomes part of the <span>prolog</span>, is no longer part of the <span>prolog</span>, or has its
simonp@8440 1461 <span data-anolis-spec=dom title=concept-cd-data>data</span> changed, these steps must be run:
simonp@8244 1462
simonp@8244 1463 <ol>
simonp@8440 1464 <li><p>If an instance of this algorithm is currently running for <var>node</var>, abort that instance, and stop the associated
simonp@8440 1465 <span data-anolis-spec=fetch title=concept-fetch>fetching</span> if applicable.
simonp@8440 1466
simonp@8440 1467 <li><p>If <var>node</var> has an <span>associated CSS style sheet</span>, <span title="remove a CSS style sheet">remove</span> it.
simonp@8440 1468
simonp@8440 1469 <li><p>If <var>node</var> is not an <span data-anolis-spec=xmlss>xml-stylesheet processing instruction</span>, terminate these steps.
simonp@8440 1470
simonp@8440 1471 <li><p>If <var>node</var> is part of the <span data-anolis-spec=xml>document type declaration</span>, terminate these steps.
simonp@8440 1472
simonp@8440 1473 <li><p>If <var>node</var> does not have an <code title>href</code> <span data-anolis-spec=xmlss>pseudo-attribute</span>, terminate these steps.
simonp@8440 1474
simonp@8406 1475 <li><p>Let <var>title</var> be the value of the
simonp@8304 1476 <code title>title</code> <span data-anolis-spec=xmlss>pseudo-attribute</span> or the empty string if the
simonp@8304 1477 <code title>title</code> <span data-anolis-spec=xmlss>pseudo-attribute</span> is not specified.</p></li>
simonp@8304 1478
simonp@8304 1479 <li><p>If there is an <code title>alternate</code> <span data-anolis-spec=xmlss>pseudo-attribute</span>
simonp@8244 1480 whose value is a <span data-anolis-spec=dom>case-sensitive</span> match
simonp@8406 1481 for "<code title>yes</code>" and <var>title</var> is the
simonp@8244 1482 empty string terminate these steps.</p></li>
simonp@8244 1483
simonp@8304 1484 <li><p>If there is a <code title>type</code> <span data-anolis-spec=xmlss>pseudo-attribute</span> whose
simonp@8244 1485 value is not a <span>supported styling language</span> the user agent
simonp@8244 1486 may terminate these steps.</p></li>
simonp@8244 1487
simonp@8406 1488 <li><p>Let <var>input URL</var> be the value specified by the
simonp@8372 1489 <code title>href</code> <span data-anolis-spec=xmlss>pseudo-attribute</span>.
simonp@8372 1490
simonp@8522 1491 <li><p>Let <var>document</var> be <var>node</var>'s <span data-anolis-spec=dom title=concept-node-document>node document</span>
simonp@8372 1492
simonp@8522 1493 <li><p>Let <var>base URL</var> be <var>document</var>'s <span data-anolis-spec=html>document base URL</span>.
simonp@8372 1494
simonp@8522 1495 <li><p>Let <var>referrer</var> be <var>document</var>'s <span data-anolis-spec=html title="the document's address">address</span>.
simonp@8522 1496
simonp@8523 1497 <li><p>Let <var>parsed URL</var> be the return value of invoking the <span data-anolis-spec=url title=concept-url-parser>URL parser</span> with the
simonp@8523 1498 string <var>input URL</var> and the base URL <var>base URL</var>.
simonp@8523 1499
simonp@8523 1500 <li><p>If <var>parsed URL</var> is failure, terminate these steps.
simonp@8523 1501
simonp@8523 1502 <li><p>Let <var>response</var> be the result of <span title="fetch a CSS style sheet">fetching a CSS style sheet</span> with parsed URL <var>parsed URL</var>,
simonp@8523 1503 referrer <var>referrer</var> and document <var>document</var>.
simonp@8372 1504
simonp@8522 1505 <li><p>If <var>response</var> is an error, terminate these steps.
simonp@8244 1506
simonp@8244 1507 <li>
simonp@8305 1508 <p><span>Create a CSS style sheet</span> with the following properties:</p>
simonp@8244 1509
simonp@8244 1510 <dl>
simonp@8305 1511 <dt><span title=concept-css-style-sheet-location>location</span></dt>
simonp@8406 1512 <dd><p>The result of invoking the <span data-anolis-spec=url title=concept-url-serializer>URL serializer</span> with <var>parsed URL</var>.</p></dd>
simonp@8244 1513
simonp@8441 1514 <dt><span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span></dt>
simonp@8372 1515 <dd><p>null.</p></dd>
simonp@8244 1516
simonp@8305 1517 <dt><span title=concept-css-style-sheet-owner-node>owner node</span></dt>
simonp@8441 1518 <dd><p><var>node</var>.</p></dd>
simonp@8244 1519
simonp@8305 1520 <dt><span title=concept-css-style-sheet-owner-css-rule>owner CSS rule</span></dt>
simonp@8372 1521 <dd><p>null.</p></dd>
simonp@8244 1522
simonp@8305 1523 <dt><span title=concept-css-style-sheet-media>media</span></dt>
simonp@8304 1524 <dd><p>The value of the <code title>media</code> <span data-anolis-spec=xmlss>pseudo-attribute</span>
simonp@8244 1525 if any, or the empty string otherwise.</p></dd>
simonp@8244 1526
simonp@8305 1527 <dt><span title=concept-css-style-sheet-title>title</span></dt>
simonp@8406 1528 <dd><p><var>title</var>.</p></dd>
simonp@8244 1529
simonp@8305 1530 <dt><span title=concept-css-style-sheet-alternate-flag>alternate flag</span></dt>
simonp@8304 1531 <dd><p>Set if the <code title>alternate</code> <span data-anolis-spec=xmlss>pseudo-attribute</span>
simonp@8244 1532 value is a <span data-anolis-spec=dom>case-sensitive</span> match for
simonp@8304 1533 "<code title>yes</code>", or clear otherwise.
simonp@8372 1534
simonp@8372 1535 <dt><span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span>
simonp@8406 1536 <dd><p>Set if <var>response</var> is <span data-anolis-spec=fetch>CORS-same-origin</span>, or clear otherwise.
simonp@8244 1537 </dl>
simonp@8244 1538 </li>
simonp@8244 1539 </ol>
simonp@8244 1540
simonp@8244 1541
simonp@8244 1542 <h4>Requirements on User Agents Implementing the HTTP
simonp@8244 1543 <code title>Link</code> Header</h4>
simonp@8244 1544
simonp@8244 1545 <!-- XXX ref, one day -->
simonp@8244 1546
simonp@8244 1547 <!-- XXX deal with media param -->
simonp@8244 1548
simonp@8539 1549 <p class=atrisk>For each HTTP <code title>Link</code> header of which one
simonp@8244 1550 of the link relation types is an
simonp@8244 1551 <span data-anolis-spec=dom>ASCII case-insensitive</span> match
simonp@8304 1552 for "<code title>stylesheet</code>" these steps
simonp@8244 1553 must be run:</p>
simonp@8244 1554
simonp@8244 1555 <ol>
simonp@8406 1556 <li><p>Let <var>title</var> be the value of the first of all the
simonp@8453 1557 <code title>title</code> parameters.
simonp@8244 1558 If there are no such parameters it is the empty string.</p></li>
simonp@8244 1559
simonp@8244 1560 <li><p>If one of the (other) link relation types is an
simonp@8244 1561 <span data-anolis-spec=dom>ASCII case-insensitive</span> match for
simonp@8406 1562 "<code title>alternate</code>" and <var>title</var> is the
simonp@8244 1563 empty string terminate these steps.</p></li>
simonp@8244 1564
simonp@8435 1565 <li><p>Let <var>input URL</var> be the value specified. <span class=issue title>Be more specific</span>
simonp@8372 1566
simonp@8435 1567 <li><p>Let <var>base URL</var> be the document's <span data-anolis-spec=html>document base URL</span>. <span class=issue title>Is there a document at this
simonp@8372 1568 point?</span>
simonp@8372 1569
simonp@8522 1570 <li><p>Let <var>referrer</var> be the document's <span data-anolis-spec=html title="the document's address">address</span>.
simonp@8522 1571
simonp@8406 1572 <li><p>Let <var>origin</var> be the document's <span data-anolis-spec=html>origin</span>.
simonp@8372 1573
simonp@8523 1574 <li><p>Let <var>parsed URL</var> be the return value of invoking the <span data-anolis-spec=url title=concept-url-parser>URL parser</span> with the
simonp@8523 1575 string <var>input URL</var> and the base URL <var>base URL</var>.
simonp@8523 1576
simonp@8523 1577 <li><p>If <var>parsed URL</var> is failure, terminate these steps.
simonp@8523 1578
simonp@8523 1579 <li><p>Let <var>response</var> be the result of <span title="fetch a CSS style sheet">fetching a CSS style sheet</span> with parsed URL <var>parsed URL</var>,
simonp@8523 1580 referrer <var>referrer</var> and document being the document. <span class=issue title>What if the HTML parser hasn't decided on quirks/non-quirks yet?</span>
simonp@8244 1581
simonp@8244 1582 <li>
simonp@8305 1583 <p><span>Create a CSS style sheet</span> with the following properties:</p>
simonp@8244 1584
simonp@8244 1585 <dl>
simonp@8305 1586 <dt><span title=concept-css-style-sheet-location>location</span></dt>
simonp@8406 1587 <dd><p>The result of invoking the <span data-anolis-spec=url title=concept-url-serializer>URL serializer</span> with <var>parsed URL</var>.</p></dd>
simonp@8244 1588
simonp@8305 1589 <dt><span title=concept-css-style-sheet-owner-node>owner node</span></dt>
simonp@8372 1590 <dd><p>null.</p></dd>
simonp@8244 1591
simonp@8441 1592 <dt><span title=concept-css-style-sheet-parent-css-style-sheet>parent CSS style sheet</span></dt>
simonp@8372 1593 <dd><p>null.</p></dd>
simonp@8244 1594
simonp@8305 1595 <dt><span title=concept-css-style-sheet-owner-css-rule>owner CSS rule</span></dt>
simonp@8372 1596 <dd><p>null.</p></dd>
simonp@8244 1597
simonp@8305 1598 <dt><span title=concept-css-style-sheet-media>media</span></dt>
simonp@8304 1599 <dd><p>The value of the first <code title>media</code> parameter.</p></dd>
simonp@8244 1600 <!-- XXX register media parameter? bah -->
simonp@8244 1601
simonp@8305 1602 <dt><span title=concept-css-style-sheet-title>title</span></dt>
simonp@8406 1603 <dd><p><var>title</var>.</p></dd>
simonp@8244 1604
simonp@8305 1605 <dt><span title=concept-css-style-sheet-alternate-flag>alternate flag</span></dt>
simonp@8244 1606 <dd><p>Set if one of the specified link relation type for this HTTP
simonp@8406 1607 <code title>Link</code> header is an
simonp@8244 1608 <span data-anolis-spec=dom>ASCII case-insensitive</span> match for
simonp@8304 1609 "<code title>alternate</code>", or false otherwise.
simonp@8372 1610
simonp@8372 1611 <dt><span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span>
simonp@8406 1612 <dd><p>Set if <var>response</var> is <span data-anolis-spec=fetch>CORS-same-origin</span>, or clear otherwise.
simonp@8244 1613 </dl>
simonp@8244 1614 </li>
simonp@8244 1615 </ol>
simonp@8244 1616
simonp@8244 1617
simonp@8244 1618 <h3>CSS Rules</h3>
simonp@8244 1619
simonp@8244 1620 <p>A <dfn>CSS rule</dfn> is an abstract concept that
simonp@8244 1621 denotes a rule as defined by the CSS specification. A
simonp@8244 1622 <span>CSS rule</span> is represented as an object that implements a subclass of
simonp@8244 1623 the <code>CSSRule</code> interface, and which has the following
simonp@8244 1624 associated state items:</p>
simonp@8244 1625
simonp@8244 1626 <dl>
simonp@8305 1627 <dt><dfn title=concept-css-rule-type>type</dfn></dt>
simonp@8244 1628 <dd><p>A non-negative integer associated with a particular type of rule.
simonp@8444 1629 This item is initialized when a rule is created and cannot change.</p></dd>
simonp@8244 1630
simonp@8305 1631 <dt><dfn title=concept-css-rule-text>text</dfn></dt>
simonp@8244 1632 <dd><p>A text representation of the rule suitable for direct use in a style sheet.
simonp@8444 1633 This item is initialized when a rule is created and can be changed.</p></dd>
simonp@8244 1634
simonp@8305 1635 <dt><dfn title=concept-css-rule-parent-css-rule>parent CSS rule</dfn></dt>
simonp@8436 1636 <dd><p>A reference to an enclosing <span>CSS rule</span> or null.
simonp@8444 1637 If the rule has an enclosing rule when it is created, then this item is initialized to the enclosing rule; otherwise it is null. It can be changed to
simonp@8444 1638 null.</p></dd>
simonp@8244 1639
simonp@8305 1640 <dt><dfn title=concept-css-rule-parent-css-style-sheet>parent CSS style sheet</dfn></dt>
simonp@8436 1641 <dd><p>A reference to a parent <span>CSS style sheet</span> or null.
simonp@8444 1642 This item is initialized to reference an associated style sheet when the rule is created. It can be changed to null.</p></dd>
simonp@8372 1643
simonp@8406 1644 <dt><dfn title=concept-css-rule-child-css-rules>child CSS rules</dfn>
simonp@8444 1645 <dd><p>A list of child <span title="CSS rule">CSS rules</span>. The list can be mutated.
simonp@8244 1646 </dl>
simonp@8244 1647
simonp@8244 1648 <p>In addition to the above state, each <span>CSS rule</span> may be associated
simonp@8305 1649 with other state in accordance with its <span title=concept-css-rule-type>type</span>.</p>
simonp@8244 1650
simonp@8433 1651 <p>To <dfn>parse a CSS rule</dfn> from a string <var>string</var>, invoke <span data-anolis-spec=csssyntax>parse a rule</span> with <var>string</var> and return
simonp@8433 1652 the value returned.</p>
simonp@8244 1653
simonp@8373 1654 <p>To <dfn>serialize a CSS rule</dfn>, perform one of the following in accordance with the <span>CSS rule</span>'s
simonp@8373 1655 <span title="concept-css-rule-type">type</span>:</p>
simonp@8244 1656
simonp@8244 1657 <dl class="switch">
simonp@8244 1658 <dt><code>CSSStyleRule</code></dt>
simonp@8244 1659 <dd>
simonp@8244 1660 <p>The result of concatenating the following:</p>
simonp@8244 1661 <ol>
simonp@8244 1662 <li>The result of performing <span>serialize a group of selectors</span> on the rule's associated selectors.</li>
simonp@8304 1663 <li>The string "<code title> { </code>", i.e., a single SPACE (U+0020), followed by LEFT CURLY BRACKET (U+007B),
simonp@8244 1664 followed by a single SPACE (U+0020).</li>
simonp@8244 1665 <li>The result of performing <span>serialize a CSS declaration block</span> on the rule's associated declarations.</li>
simonp@8304 1666 <li>If the rule is associated with one or more declarations, the string "<code title> </code>", i.e., a single SPACE (U+0020).</li>
simonp@8304 1667 <li>The string "<code title>}</code>", RIGHT CURLY BRACKET (U+007D).
simonp@8244 1668 </ol>
simonp@8244 1669 </dd>
simonp@8244 1670
simonp@8244 1671 <dt><code>CSSCharsetRule</code></dt>
simonp@8244 1672 <dd>
simonp@8244 1673 <p>The result of concatenating the following:</p>
simonp@8244 1674 <ol>
simonp@8304 1675 <li>The string "<code title>@charset</code>" followed by a single SPACE (U+0020).</li>
simonp@8244 1676 <li>The result of performing <span>serialize a string</span> on the rule's character encoding.</li>
simonp@8304 1677 <li>The string "<code title>;</code>", i.e., SEMICOLON (U+003B).
simonp@8244 1678 </ol>
simonp@8244 1679 <div class="example">
simonp@8244 1680 <pre>@charset "UTF-8";</pre>
simonp@8226 1681 </div>
simonp@8244 1682 </dd>
simonp@8244 1683
simonp@8244 1684 <dt><code>CSSImportRule</code></dt>
simonp@8244 1685 <dd>
simonp@8244 1686 <p>The result of concatenating the following:</p>
simonp@8226 1687 <ol>
simonp@8304 1688 <li>The string "<code title>@import</code>" followed by a single SPACE (U+0020).</li>
simonp@8244 1689 <li>The result of performing <span>serialize a URL</span> on the rule's location.</li>
simonp@8244 1690 <li>If the rule's associated media list is not empty, a single SPACE (U+0020) followed by the
simonp@8244 1691 result of performing <span>serialize a media query list</span> on the media list.
simonp@8304 1692 <li>The string "<code title>;</code>", i.e., SEMICOLON (U+003B).
simonp@8226 1693 </ol>
simonp@8244 1694 <div class="example">
simonp@8244 1695 <pre>@import url("import.css");</pre>
simonp@8244 1696 <pre>@import url("print.css") print;</pre>
simonp@8244 1697 </div>
simonp@8244 1698 </dd>
simonp@8244 1699
simonp@8244 1700 <dt><code>CSSMediaRule</code></dt>
simonp@8435 1701 <dd><p class="issue">...</p></dd>
simonp@8244 1702
simonp@8582 1703 <dt><code title>CSSFontFaceRule</code></dt>
simonp@8435 1704 <dd><p class="issue">...</p></dd>
simonp@8244 1705
simonp@8244 1706 <dt><code>CSSPageRule</code></dt>
simonp@8435 1707 <dd><p class="issue">...</p></dd>
simonp@8244 1708
simonp@8244 1709 <dt><code>CSSNamespaceRule</code></dt>
simonp@8304 1710 <dd><p>The literal string "<code title>@namespace</code>", followed by a single SPACE
simonp@8244 1711 (U+0020), followed by the
simonp@8244 1712 <span title="serialize an identifier">identifier escaped</span> value of the
simonp@8244 1713 <code title="dom-CSSNamespaceRule-prefix">prefix</code> attribute (if
simonp@8244 1714 any), followed by a single SPACE (U+0020) if there is a prefix, followed by the
simonp@8244 1715 <span title="serialize a URL">URL escaped</span> value of the
simonp@8244 1716 <code title="dom-CSSNamespaceRule-namespaceURI">namespaceURI</code>
simonp@8304 1717 attribute, followed the character "<code title>;</code>" (U+003B).</p></dd>
simonp@8244 1718 </dl>
simonp@8244 1719
simonp@8406 1720 <p>To <dfn>insert a CSS rule</dfn> <var>rule</var> in a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
simonp@8287 1721 <ol>
simonp@8406 1722 <li><p>Set <var>new rule</var> to the results of performing <span>parse a CSS rule</span>
simonp@8433 1723 on argument <var>rule</var>.
simonp@8433 1724 <li><p>If <var>new rule</var> is a syntax error, <span data-anolis-spec='dom' title='concept-throw'>throw</span>
simonp@8433 1725 a <code data-anolis-spec='dom'>SyntaxError</code> exception.</p></li>
simonp@8406 1726 <li><p>If <var>new rule</var> is an <code title>@charset</code> at-rule, <span data-anolis-spec='dom' title='concept-throw'>throw</span> a
simonp@8287 1727 <code data-anolis-spec='dom'>SyntaxError</code> exception.
simonp@8406 1728 <li><p>Set <var>length</var> to the number of items in <var>list</var>.</p></li>
simonp@8406 1729 <li><p>If <var>index</var> is greater than <var>length</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
simonp@8287 1730 an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
simonp@8406 1731 <li><p>If <var>new rule</var> cannot be inserted into <var>list</var> at the zero-index position <var>index</var> due to constraints
simonp@8304 1732 specified by CSS, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
simonp@8287 1733 a <code data-anolis-spec='dom'>HierarchyRequestError</code> exception. <span data-anolis-ref>CSS</span></p>
simon@8381 1734 <p class='note'>For example, a CSS style sheet cannot contain an <code title>@import</code> at-rule after a style rule.</p></li>
simonp@8406 1735 <li><p>If <var>new rule</var> is an <code title>@namespace</code> at-rule, and <var>list</var> contains anything other than
simonp@8288 1736 <code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
simonp@8288 1737 <span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
simonp@8406 1738 <li><p>Insert <var>new rule</var> into <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
simonp@8406 1739 <li><p>Return <var>index</var>.
simonp@8287 1740 </ol>
simonp@8287 1741
simonp@8406 1742 <p>To <dfn>remove a CSS rule</dfn> from a CSS rule list <var>list</var> at index <var>index</var>, follow these steps:</p>
simonp@8287 1743 <ol>
simonp@8406 1744 <li><p>Set <var>length</var> to the number of items in <var>list</var>.</p></li>
simonp@8406 1745 <li><p>If <var>index</var> is greater than or equal to <var>length</var>, then <span data-anolis-spec='dom' title='concept-throw'>throw</span>
simonp@8287 1746 an <code data-anolis-spec='dom'>IndexSizeError</code> exception.</p></li>
simonp@8406 1747 <li><p>Set <var>old rule</var> to the <var>index</var>th item in <var>list</var>.</p></li>
simonp@8406 1748 <li><p>If <var>old rule</var> is an <code title>@namespace</code> at-rule, and <var>list</var> contains anything other than
simonp@8288 1749 <code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
simonp@8288 1750 <span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
simonp@8406 1751 <li><p>Remove rule <var>old rule</var> from <var>list</var> at the zero-indexed position <var>index</var>.<p></li>
simonp@8444 1752 <li><p>Set <var>old rule</var>'s <span title=concept-css-rule-parent-css-rule>parent CSS rule</span> and
simonp@8444 1753 <span title=concept-css-rule-parent-css-style-sheet>parent CSS style sheet</span> to null.
simonp@8287 1754 </ol>
simonp@8287 1755
simonp@8244 1756
simonp@8244 1757 <h4>The <code title>CSSRuleList</code> Interface</h4>
simonp@8229 1758
simonp@8229 1759 <p>The <code>CSSRuleList</code> interface represents an ordered collection of CSS style rules.</p>
simonp@8229 1760
simonp@8229 1761 <pre class=idl>[ArrayClass]
simonp@8229 1762 interface <dfn>CSSRuleList</dfn> {
simonp@8229 1763 getter <span>CSSRule</span>? <span title=dom-CSSRuleList-item>item</span>(unsigned long index);
simonp@8229 1764 readonly attribute unsigned long <span title=dom-CSSRuleList-length>length</span>;
simonp@8229 1765 };</pre>
simonp@8229 1766
simonp@8304 1767 <p>The object's <span data-anolis-spec=webidl>supported property indices</span> are the numbers in the range zero to one less than the number of
simonp@8304 1768 <code>CSSRule</code> objects represented by the collection. If there are no such <code>CSSRule</code> objects, then there are no
simonp@8304 1769 <span data-anolis-spec=webidl>supported property indices</span>.
simonp@8304 1770
simonp@8406 1771 <p>The <dfn title=dom-CSSRuleList-item><code>item(<var>index</var>)</code></dfn> method must return the <var>index</var>th <code>CSSRule</code>
simonp@8406 1772 object in the collection. If there is no <var>index</var>th object in the collection, then the method must return null.
simonp@8304 1773
simonp@8304 1774 <p>The <dfn title=dom-CSSRuleList-length><code>length</code></dfn> attribute must return the number of <code>CSSRule</code> objects represented by the
simonp@8304 1775 collection.
simonp@8226 1776
simonp@8244 1777 <h4>The <code title>CSSRule</code> Interface</h4>
simonp@8226 1778
simonp@8226 1779 <!--
simonp@8226 1780 //
simonp@8226 1781 // All members defined since DOM-2 Style. The only differences are:
simonp@8226 1782 //
simonp@8226 1783 // 1. removal of UNKNOWN_RULE = 0 constant
simonp@8226 1784 // 2. addition of NAMESPACE_RULE = 10 constant
simonp@8226 1785 // 3. removal of commented raises(DOMException) on setting cssText
simonp@8226 1786 //
simonp@8226 1787 -->
simonp@8226 1788
simonp@8226 1789 <p>The <code>CSSRule</code> interface represents an abstract, base CSS style rule. Each
simonp@8244 1790 distinct CSS style rule type is represented by a distinct interface that
simonp@8244 1791 inherits from this interface.</p>
simonp@8226 1792
simonp@8226 1793 <pre class=idl>interface <dfn>CSSRule</dfn> {
simonp@8262 1794 const unsigned short <span title=dom-CSSRule-STYLE_RULE>STYLE_RULE</span> = 1;
simonp@8262 1795 const unsigned short <span title=dom-CSSRule-CHARSET_RULE>CHARSET_RULE</span> = 2;
simonp@8262 1796 const unsigned short <span title=dom-CSSRule-IMPORT_RULE>IMPORT_RULE</span> = 3;
simonp@8262 1797 const unsigned short <span title=dom-CSSRule-MEDIA_RULE>MEDIA_RULE</span> = 4;
simonp@8262 1798 const unsigned short <span title=dom-CSSRule-FONT_FACE_RULE>FONT_FACE_RULE</span> = 5;
simonp@8262 1799 const unsigned short <span title=dom-CSSRule-PAGE_RULE>PAGE_RULE</span> = 6;
simonp@8262 1800 const unsigned short <span title=dom-CSSRule-NAMESPACE_RULE>NAMESPACE_RULE</span> = 10;
simonp@8262 1801 readonly attribute unsigned short <span title=dom-CSSRule-type>type</span>;
simonp@8262 1802 attribute DOMString <span title=dom-CSSRule-cssText>cssText</span>;
simonp@8262 1803 readonly attribute <span>CSSRule</span>? <span title=dom-CSSRule-parentRule>parentRule</span>;
simonp@8262 1804 readonly attribute <span>CSSStyleSheet</span>? <span title=dom-CSSRule-parentStyleSheet>parentStyleSheet</span>;
simonp@8226 1805 };</pre>
simonp@8226 1806
simonp@8263 1807 <p>The <dfn title=dom-CSSRule-type><code>type</code></dfn> attribute must return the CSS rule type, as follows:
simonp@8263 1808
simonp@8263 1809 <dl class=switch>
simonp@8263 1810 <dt>If the object is a <code>CSSStyleRule</code>
simonp@8263 1811 <dd><p>Return <dfn title=dom-CSSRule-STYLE_RULE><code>STYLE_RULE</code></dfn> (numeric value 1).
simonp@8263 1812 <dt>If the object is a <code>CSSCharsetRule</code>
simonp@8263 1813 <dd><p>Return <dfn title=dom-CSSRule-CHARSET_RULE><code>CHARSET_RULE</code></dfn> (numberic value 2).
simonp@8263 1814 <dt>If the object is a <code>CSSImportRule</code>
simonp@8263 1815 <dd><p>Return <dfn title=dom-CSSRule-IMPORT_RULE><code>IMPORT_RULE</code></dfn> (numberic value 3).
simonp@8263 1816 <dt>If the object is a <code>CSSMediaRule</code>
simonp@8263 1817 <dd><p>Return <dfn title=dom-CSSRule-MEDIA_RULE><code>MEDIA_RULE</code></dfn> (numeric value 4).
simonp@8582 1818 <dt>If the object is a <code title>CSSFontFaceRule</code>
simonp@8263 1819 <dd><p>Return <dfn title=dom-CSSRule-FONT_FACE_RULE><code>FONT_FACE_RULE</code></dfn> (numeric value 5).
simonp@8263 1820 <dt>If the object is a <code>CSSPageRule</code>
simonp@8263 1821 <dd><p>Return <dfn title=dom-CSSRule-PAGE_RULE><code>PAGE_RULE</code></dfn> (numeric value 6).
simonp@8263 1822 <dt>If the object is a <code>CSSNamespaceRule</code>
simonp@8263 1823 <dd><p>Return <dfn title=dom-CSSRule-NAMESPACE_RULE><code>NAMESPACE_RULE</code></dfn> (numeric value 10).
simonp@8263 1824 <dt>Otherwise
simonp@8263 1825 <dd><p>Return a value defined on the <a href='http://wiki.csswg.org/spec/cssom-constants'>CSSOM Constants</a> wiki page.
simonp@8263 1826 </dl>
simonp@8263 1827
simonp@8263 1828 <p class=note>The value 0, formerly known as <code title>UNKNOWN_RULE</code>, is made
simonp@8263 1829 obsolete by this specification. This value will not be re-allocated in the future and will remain reserved.</p>
simonp@8226 1830
simonp@8226 1831 <p>The <dfn title=dom-CSSRule-cssText><code>cssText</code></dfn> attribute must return a <span title='serialize a CSS rule'>serialization</span> of the
simonp@8226 1832 <span>CSS rule</span>.</p>
simonp@8226 1833 <p>On setting the <code title=dom-CSSRule-cssText>cssText</code> attribute these steps must be run:</p>
simonp@8226 1834 <ol>
simonp@8433 1835 <li><p>Let <var>new rule</var> be the returned value of <span title='parse a CSS rule'>parsing</span> the value.</p></li>
simonp@8433 1836 <li><p>If <var>new rule</var> is a syntax error, terminate this algorithm.</p></li>
simonp@8433 1837 <li><p>If the <span title=concept-css-rule-type>type</span> of <var>new rule</var> does not match the <span title=concept-css-rule-type>type</span> of
simonp@8226 1838 the current object
simonp@8226 1839 <span data-anolis-spec=dom title=concept-throw>throw</span> an
simonp@8293 1840 <code data-anolis-spec=dom>InvalidModificationError</code> exception.</li>
simonp@8433 1841 <li><p>Replace the current object with <var>new rule</var>.</p></li>
simonp@8226 1842 </ol>
simonp@8226 1843
simonp@8436 1844 <p>The <dfn title=dom-CSSRule-parentRule><code>parentRule</code></dfn> attribute must return the <span title=concept-css-rule-parent-css-rule>parent CSS
simonp@8436 1845 rule</span>.</p>
simonp@8304 1846 <p class='note'>For example, <code title>@media</code> can enclose a rule, in which case <code title=dom-CSSRule-parentRule>parentRule</code> would
simonp@8436 1847 be non-null; in cases where there is no enclosing rule, <code title=dom-CSSRule-parentRule>parentRule</code> will be null.</p>
simonp@8436 1848
simonp@8436 1849 <p>The <dfn title=dom-CSSRule-parentStyleSheet><code>parentStyleSheet</code></dfn> attribute must return the
simonp@8436 1850 <span title=concept-css-rule-parent-css-style-sheet>parent CSS style sheet</span>.</p>
simonp@8289 1851 <p class='note'>The only circumstance where null is returned when a rule has been <span title="remove a CSS rule">removed</span>.</p>
simonp@8304 1852 <p class='note'>Removing a <code data-anolis-spec=dom>Node</code> that implements the <code>LinkStyle</code> interface from a
simonp@8304 1853 <code data-anolis-spec=dom>Document</code> instance does not (by itself) cause the <code>CSSStyleSheet</code> referenced by a <code>CSSRule</code> to be
simonp@8304 1854 unreachable.</p>
simonp@8226 1855
simonp@8226 1856
simonp@8244 1857 <h4>The <code title>CSSStyleRule</code> Interface</h4>
simonp@8226 1858
simonp@8226 1859 <!--
simonp@8226 1860 //
simonp@8226 1861 // All members defined since DOM-2 Style. The only differences are:
simonp@8226 1862 //
simonp@8226 1863 // 1. removal of commented raises(DOMException) on setting selectorText
simonp@8226 1864 //
simonp@8226 1865 -->
simonp@8226 1866
simon@8381 1867 <p>The <code>CSSStyleRule</code> interface represents a style rule.</p>
simon@8381 1868
simon@8381 1869 <p class=note>CSS 2.1 calls style rule <a href="http://www.w3.org/TR/CSS21/syndata.html#rule-sets">rule sets</a>.</p>
simonp@8226 1870
simonp@8226 1871 <pre class=idl>interface <dfn>CSSStyleRule</dfn> : <span>CSSRule</span> {
simonp@8226 1872 attribute DOMString <span title=dom-CSSStyleRule-selectorText>selectorText</span>;
simonp@8820 1873 [SameObject, PutForwards=<span title=dom-CSSStyleDeclaration-cssText>cssText</span>] readonly attribute <span>CSSStyleDeclaration</span> <!--
simonp@8436 1874 --><span title=dom-CSSStyleRule-style>style</span>;
simonp@8226 1875 };</pre>
simonp@8226 1876
simonp@8304 1877 <p>The <dfn title=dom-CSSStyleRule-selectorText><code>selectorText</code></dfn> attribute, on getting, must return the result of
simonp@8304 1878 <span title='serialize a group of selectors'>serializing</span> the associated <span>group of selectors</span>.</p>
simonp@8226 1879 <p>On setting the <code title=dom-CSSStyleRule-selectorText>selectorText</code> attribute these steps must be run:</p>
simonp@8226 1880 <ol>
simonp@8226 1881 <li><p>Run the <span>parse a group of selectors</span> algorithm on the given value.</p></li>
simonp@8226 1882 <li><p>If the algorithm returns a non-null value replace the associated <span>group of selectors</span> with the returned value.</p></li>
simonp@8289 1883 <li><p>Otherwise, if the algorithm returns a null value, do nothing.</p></li>
simonp@8226 1884 </ol>
simonp@8226 1885
simonp@8590 1886 <p>The <dfn title=dom-CSSStyleRule-style><code>style</code></dfn> attribute must return a <code>CSSStyleDeclaration</code> object for the style rule, with the
simonp@8807 1887 <span title=concept-css-declaration-block-declarations>declarations</span> being the declared declarations in the rule, in
simonp@8807 1888 <span title=concept-declarations-specified-order>specified order</span>.</p>
simonp@8807 1889
simonp@8807 1890 <p>The <dfn title=concept-declarations-specified-order>specified order</dfn> for declarations is the same as specified, but with shorthand properties
simonp@8807 1891 expanded into their longhand properties, in canonical order. If a property is specified more than once (after shorthand expansion), only the
simonp@8807 1892 one with greatest cascading order must be represented, at the same relative position as it was specified. <span data-anolis-ref>CSSCASCADE</span>
simonp@8226 1893
simonp@8244 1894 <h4>The <code title>CSSCharsetRule</code> Interface</h4>
simonp@8226 1895
simonp@8304 1896 <p>The <code>CSSCharsetRule</code> interface represents an <code title>@charset</code> at-rule.</p>
simonp@8226 1897
simonp@8226 1898 <pre class=idl>interface <dfn>CSSCharsetRule</dfn> : <span>CSSRule</span> {
simonp@8226 1899 attribute DOMString <span title=dom-CSSCharsetRule-encoding>encoding</span>;
simonp@8226 1900 };</pre>
simonp@8226 1901
simonp@8304 1902 <p>The <dfn title=dom-CSSCharsetRule-encoding><code>encoding</code></dfn> attribute must return the encoding information specified by the
simonp@8304 1903 <code title>@charset</code> at-rule.</p>
simonp@8226 1904
simonp@8226 1905
simonp@8244 1906 <h4>The <code title>CSSImportRule</code> Interface</h4>
simonp@8226 1907
simonp@8304 1908 <p>The <code>CSSImportRule</code> interface represents an <code title>@import</code> at-rule.</p>
simonp@8226 1909
simonp@8226 1910 <pre class=idl>interface <dfn>CSSImportRule</dfn> : <span>CSSRule</span> {
simonp@8226 1911 readonly attribute DOMString <span title=dom-CSSImportRule-href>href</span>;
simonp@8820 1912 [SameObject, PutForwards=<span title=dom-MediaList-mediaText>mediaText</span>] readonly attribute <span>MediaList</span> <!--
simonp@8820 1913 --><span title=dom-CSSImportRule-media>media</span>;
simonp@8820 1914 [SameObject] readonly attribute <span>CSSStyleSheet</span> <span title=dom-CSSImportRule-styleSheet>styleSheet</span>;
simonp@8226 1915 };</pre>
simonp@8226 1916
simonp@8304 1917 <p>The <dfn title=dom-CSSImportRule-href><code>href</code></dfn> attribute must return the <span data-anolis-spec=url title=concept-url>URL</span> specified by
simonp@8304 1918 the <code title>@import</code> at-rule.</p>
simonp@8227 1919 <p class='note'>To get the resolved <span data-anolis-spec=url title=concept-url>URL</span> use the <code title='dom-StyleSheet-href'>href</code>
simonp@8303 1920 attribute of the associated <span>CSS style sheet</span>.</p>
simonp@8226 1921
simonp@8226 1922 <p>The <dfn title=dom-CSSImportRule-media><code>media</code></dfn> attribute must return the value of the <code title='dom-StyleSheet-media'>media</code>
simonp@8303 1923 attribute of the associated <span>CSS style sheet</span>.</p>
simonp@8303 1924
simonp@8303 1925 <p>The <dfn title=dom-CSSImportRule-styleSheet><code>styleSheet</code></dfn> attribute must return the associated <span>CSS style sheet</span>.</p>
simonp@8372 1926 <p class='note'>If loading of the style sheet fails its <span title=concept-css-style-sheet-css-rules>CSS rules</span>
simonp@8304 1927 list is simply empty, i.e., an <code title>@import</code> at-rule always has an associated <span>CSS style sheet</span>.</p>
simonp@8226 1928
simonp@8226 1929
simonp@8482 1930 <h4>The <code title>CSSGroupingRule</code> Interface</h4>
simonp@8482 1931
simonp@8482 1932 <p>The <code>CSSGroupingRule</code> interface represents an at-rule that contains other rules nested inside itself.
simonp@8482 1933
simonp@8482 1934 <pre class=idl>interface <dfn>CSSGroupingRule</dfn> : <span>CSSRule</span> {
simonp@8820 1935 [SameObject] readonly attribute <span>CSSRuleList</span> <span title=dom-CSSGroupingRule-cssRules>cssRules</span>;
simonp@8482 1936 unsigned long <span title=dom-CSSGroupingRule-insertRule>insertRule</span>(DOMString rule, unsigned long index);
simonp@8482 1937 void <span title=dom-CSSGroupingRule-deleteRule>deleteRule</span>(unsigned long index);
simonp@8483 1938 };</pre>
simonp@8482 1939
simonp@8482 1940 <p>The <dfn title=dom-CSSGroupingRule-cssRules><code>cssRules</code></dfn> attribute must return a <code>CSSRuleList</code> object for the
simonp@8482 1941 <span title=concept-css-rule-child-css-rules>child CSS rules</span>.</p>
simonp@8482 1942
simonp@8482 1943 <p>The <dfn title=dom-CSSGroupingRule-insertRule><code>insertRule(<var>rule</var>, <var>index</var>)</code></dfn> method must return the result of
simonp@8482 1944 invoking <span>insert a CSS rule</span> <var>rule</var> into the <span title=concept-css-rule-child-css-rules>child CSS rules</span> at
simonp@8482 1945 <var>index</var>.</p>
simonp@8482 1946
simonp@8482 1947 <p>The <dfn title=dom-CSSGroupingRule-deleteRule><code>deleteRule(<var>index</var>)</code></dfn> method must <span>remove a CSS rule</span> from the
simonp@8482 1948 <span title=concept-css-rule-child-css-rules>child CSS rules</span> at <var>index</var>.</p>
simonp@8482 1949
simonp@8482 1950
simonp@8244 1951 <h4>The <code title>CSSMediaRule</code> Interface</h4>
simonp@8226 1952
simonp@8304 1953 <p>The <code>CSSMediaRule</code> interface represents an <code title>@media</code> at-rule.</p>
simonp@8226 1954
simonp@8482 1955 <pre class=idl>interface <dfn>CSSMediaRule</dfn> : <span>CSSGroupingRule</span> {
simonp@8820 1956 [SameObject, PutForwards=<span title=dom-MediaList-mediaText>mediaText</span>] readonly attribute <span>MediaList</span> <!--
simonp@8820 1957 --><span title=dom-CSSMediaRule-media>media</span>;
simonp@8226 1958 };</pre>
simonp@8226 1959
simonp@8226 1960 <p>The <dfn title=dom-CSSMediaRule-media><code>media</code></dfn> attribute must return a <code>MediaList</code> object for the list of media queries specified
simonp@8304 1961 with the <code title>@media</code> at-rule.</p>
simonp@8304 1962
simonp@8226 1963
simonp@8244 1964 <h4>The <code title>CSSPageRule</code> Interface</h4>
simonp@8226 1965
simonp@8304 1966 <p>The <code>CSSPageRule</code> interface represents an <code title>@page</code> at-rule.</p>
simonp@8445 1967 <p class="issue">Need to define the rules for
simonp@8327 1968 <dfn>parse a list of CSS page selectors</dfn> and
simonp@8327 1969 <dfn>serialize a list of CSS page selectors</dfn>.</p>
simonp@8226 1970
simonp@8226 1971 <pre class=idl>interface <dfn>CSSPageRule</dfn> : <span>CSSRule</span> {
simonp@8226 1972 attribute DOMString <span title=dom-CSSPageRule-selectorText>selectorText</span>;
simonp@8820 1973 [SameObject, PutForwards=<span title=dom-CSSStyleDeclaration-cssText>cssText</span>] readonly attribute <span>CSSStyleDeclaration</span> <!--
simonp@8484 1974 --><span title=dom-CSSPageRule-style>style</span>;
simonp@8226 1975 };</pre>
simonp@8226 1976
simonp@8304 1977 <p>The <dfn title=dom-CSSPageRule-selectorText><code>selectorText</code></dfn> attribute, on getting, must return the result of
simonp@8327 1978 <span title='serialize a list of CSS page selectors'>serializing</span> the associated <span>list of CSS page selectors</span>.</p>
simonp@8226 1979 <p>On setting the <code title=dom-CSSPageRule-selectorText>selectorText</code> attribute these steps must be run:</p>
simonp@8226 1980 <ol>
simonp@8327 1981 <li><p>Run the <span>parse a list of CSS page selectors</span> algorithm on the given value.</p></li>
simonp@8327 1982 <li><p>If the algorithm returns a non-null value replace the associated <span>list of CSS page selectors</span> with the returned value.</p></li>
simonp@8289 1983 <li><p>Otherwise, if the algorithm returns a null value, do nothing.</p></li>
simonp@8226 1984 </ol>
simonp@8226 1985
simonp@8820 1986 <p>The <dfn title=dom-CSSPageRule-style><code>style</code></dfn> attribute must return a <code>CSSStyleDeclaration</code> for the <code title>@page</code>
simonp@8304 1987 at-rule.</p>
simonp@8226 1988
simonp@8226 1989
simonp@8244 1990 <h4>The <code title>CSSNamespaceRule</code> Interface</h4>
simonp@8226 1991
simonp@8304 1992 <p>The <code>CSSNamespaceRule</code> interface represents an <code title>@namespace</code> at-rule.</p>
simonp@8226 1993
simonp@8226 1994 <pre class=idl>interface <dfn>CSSNamespaceRule</dfn> : <span>CSSRule</span> {
simonp@8335 1995 [TreatNullAs=EmptyString] attribute DOMString <span title=dom-CSSNamespaceRule-namespaceURI>namespaceURI</span>;
simonp@8335 1996 [TreatNullAs=EmptyString] attribute DOMString <span title=dom-CSSNamespaceRule-prefix>prefix</span>;
simonp@8226 1997 };</pre>
simonp@8226 1998
simonp@8288 1999 <p>The <dfn title=dom-CSSNamespaceRule-namespaceURI><code>namespaceURI</code></dfn> attribute, on getting, must return the namespace of the
simonp@8304 2000 <code title>@namespace</code> at-rule.
simonp@8301 2001
simonp@8301 2002 <p>On setting, the <code title=dom-CSSNamespaceRule-namespaceURI>namespaceURI</code> attribute must run the following steps:</p>
simonp@8288 2003
simonp@8288 2004 <ol>
simonp@8406 2005 <li><p>Let <var>parent</var> be the <span title=concept-css-rule-parent-css-style-sheet>parent CSS style sheet</span>.
simonp@8406 2006 <li><p>Let <var>list</var> be the <span title=concept-css-style-sheet-css-rules>CSS rules</span> of <var>parent</var>, or
simonp@8406 2007 null if <var>parent</var> is null.
simonp@8406 2008 <li><p>If <var>list</var> is not null and contains anything other than
simonp@8288 2009 <code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
simonp@8288 2010 <span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
simonp@8288 2011 <li><p>Set the namespace of the <code title>@namespace</code> at-rule to the given value.
simonp@8288 2012 </ol>
simonp@8226 2013
simonp@8304 2014 <p>The <dfn title=dom-CSSNamespaceRule-prefix><code>prefix</code></dfn> attribute must return the prefix of the <code title>@namespace</code> at-rule or the
simonp@8301 2015 empty string if there is no prefix.
simonp@8301 2016
simonp@8301 2017 <p>On setting, the <code title=dom-CSSNamespaceRule-prefix>prefix</code> attribute must run the following steps:</p>
simonp@8288 2018
simonp@8288 2019 <ol>
simonp@8406 2020 <li><p>Let <var>parent</var> be the <span title=concept-css-rule-parent-css-style-sheet>parent CSS style sheet</span>.
simonp@8406 2021 <li><p>Let <var>list</var> be the <span title=concept-css-style-sheet-css-rules>CSS rules</span> of <var>parent</var>, or
simonp@8406 2022 null if <var>parent</var> is null.
simonp@8406 2023 <li><p>If <var>list</var> is not null and contains anything other than
simonp@8288 2024 <code title>@charset</code> at-rules, <code title>@import</code> at-rules, and <code title>@namespace</code> at-rules,
simonp@8288 2025 <span data-anolis-spec='dom' title='concept-throw'>throw</span> an <code data-anolis-spec=dom>InvalidStateError</code> exception.
simonp@8288 2026 <li><p>Set the prefix of the <code title>@namespace</code> at-rule to the given value.
simonp@8288 2027 </ol>
simonp@8226 2028
simonp@8226 2029
simonp@8244 2030 <h3>CSS Declaration Blocks</h3>
simonp@8244 2031
simonp@8244 2032 <p>A <dfn>CSS declaration block</dfn> is an ordered collection of CSS
simonp@8244 2033 properties with their associated values, also named CSS declarations. In
simonp@8244 2034 the DOM a <span>CSS declaration block</span> is a
simonp@8244 2035 <code>CSSStyleDeclaration</code> object. A
simonp@8244 2036 <span>CSS declaration block</span> has two associated properties:</p>
simonp@8244 2037
simonp@8244 2038 <dl>
simonp@8305 2039 <dt><dfn title=concept-css-declaration-block-readonly-flag>readonly flag</dfn></dt>
simonp@8244 2040 <dd><p>Clear if the object can be manipulated. Set if it can not be
simonp@8244 2041 manipulated. Unless otherwise stated it is clear.</p></dd>
simonp@8244 2042
simonp@8305 2043 <dt><dfn title=concept-css-declaration-block-declarations>declarations</dfn></dt>
simonp@8244 2044 <dd><p>The CSS declarations associated with the object.</p></dd>
simonp@8244 2045 </dl>
simonp@8244 2046
simonp@8434 2047 <p>To <dfn>parse a CSS declaration block</dfn> from a string <var>string</var>, invoke <span data-anolis-spec=csssyntax>parse a list of declarations</span> with
simonp@8434 2048 <var>string</var> and return the value returned.</p>
simonp@8244 2049
simonp@8795 2050 <p>To <dfn>serialize a CSS declaration</dfn> with property name <var>property</var>, value <var>value</var> and optionally an <i>important</i> flag set, follow
simonp@8795 2051 these steps:
simonp@8244 2052
simonp@8244 2053 <ol>
simonp@8795 2054 <li><p>Let <var>s</var> be the empty string.
simonp@8795 2055 <li><p>Append <var>property</var> to <var>s</var>.
simonp@8795 2056 <li><p>Append "<code title>: </code>" (U+003A U+0020) to <var>s</var>.
simonp@8795 2057 <li><p>Append <var>value</var> to <var>s</var>.
simonp@8795 2058 <li><p>If the <i>important</i> flag is set, append "<code title> !important</code>" (U+0020 U+0021 U+0069 U+006D U+0070 U+006F U+0072 U+0074 U+0061 U+006E
simonp@8795 2059 U+0074) to <var>s</var>.
simonp@8795 2060 <li><p>Append "<code title>;</code>" (U+003B) to <var>s</var>.
simonp@8795 2061 <li><p>Return <var>s</var>.
simonp@8795 2062 </ol>
simonp@8795 2063
simonp@8795 2064 <p>To <dfn>serialize a CSS declaration block</dfn> <var>declaration block</var> means to run the steps below:</p>
simonp@8795 2065
simonp@8795 2066 <ol>
simonp@8795 2067 <li><p>Let <var>list</var> be an empty array.
simonp@8795 2068 <li><p>Let <var>already serialized</var> be an empty array.
simonp@8795 2069 <li><p><i>Declaration loop</i>: For each declaration <var>declaration</var> in <var>declaration block</var>'s
simonp@8795 2070 <span title=concept-css-declaration-block-declarations>declarations</span>, follow these substeps:
simonp@8795 2071 <ol>
simonp@8795 2072 <li><p>Let <var>property</var> be <var>declaration</var>'s property name.
simonp@8795 2073 <li><p>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>.
simonp@8795 2074 <li><p>If <var>property</var> maps to one or more shorthand properties, let <var>shorthands</var> be an array of those shorthand properties, in
simonp@8795 2075 <span title=concept-shorthands-preferred-order>preferred order</span>, and follow these substeps:
simonp@8226 2076 <ol>
simonp@8795 2077 <li><p>Let <var>longhands</var> an array consisting of all declarations in <var>declaration block</var>'s
simonp@8795 2078 <span title=concept-css-declaration-block-declarations>declarations</span> that that are not in <var>already serialized</var> and have a property name that
simonp@8795 2079 maps to one of the shorthand properties in <var>shorthands</var>.
simonp@8795 2080 <li><p><i>Shorthand loop</i>: For each <var>shorthand</var> in <var>shorthands</var>, follow these substeps:
simonp@8795 2081 <ol>
simonp@8795 2082 <li><p>If all properties that map to <var>shorthand</var> are not present in <var>longhands</var>, continue with the steps labeled <i>shorthand loop</i>.
simonp@8795 2083 <li><p>Let <var>current longhands</var> be an empty array.
simonp@8795 2084 <li><p>Append all declarations in <var>longhands</var> have a property name that maps to <var>shorthand</var> to <var>current longhands</var>.
simonp@8795 2085 <li><p>If there is one or more declarations in <var>current longhands</var> have their <i>important</i> set and one or more with it unset, continue with
simonp@8795 2086 the steps labeled <i>shorthand loop</i>.
simonp@8795 2087 <li><p>Let <var>value</var> be the result of invoking <span>serialize a CSS value</span> of <var>current longhands</var>.
simonp@8795 2088 <li><p>If <var>value</var> is the empty string, continue with the steps labeled <i>shorthand loop</i>.
simonp@8795 2089 <li><p>Let <var>serialized declaration</var> be the result of invoking <span>serialize a CSS declaration</span> with property name
simonp@8795 2090 <var>shorthand</var>, value <var>value</var>, and the <i>important</i> flag set if the declarations in <var>current longhands</var> have their
simonp@8795 2091 <i>important</i> flag set.
simonp@8795 2092 <li><p>Append <var>serialized declaration</var> to <var>list</var>.
simonp@8795 2093 <li><p>Append the property names of all items of <var>current longhands</var> to <var>already serialized</var>.
simonp@8795 2094 <li><p>Remove the items present in <var>current longhands</var> from <var>longhands</var>.
simonp@8795 2095 </ol>
simonp@8226 2096 </ol>
simonp@8795 2097 <li><p>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>.
simonp@8795 2098 <li><p>Let <var>value</var> be the result of invoking <span>serialize a CSS value</span> of <var>declaration</var>.
simonp@8795 2099 <li><p>Let <var>serialized declaration</var> be the result of invoking <span>serialize a CSS declaration</span> with property name <var>property</var>, value
simonp@8795 2100 <var>value</var>, and the <i>important</i> flag set if <var>declaration</var> has its <i>important</i> flag set.
simonp@8795 2101 <li><p>Append <var>serialized declaration</var> to <var>list</var>.
simonp@8795 2102 <li><p>Append <var>property</var> to <var>already serialized</var>.
simonp@8795 2103 </ol>
simonp@8795 2104 <li><p>Return <var>list</var> joined with "<code title> </code>" (U+0020).
simonp@8244 2105 </ol>
simonp@8244 2106
simonp@8244 2107 <p class="note">The serialization of an empty CSS declaration block is the empty string.</p>
simonp@8244 2108
simonp@8244 2109 <p class="note">The serialization of a non-empty CSS declaration block does not include any surrounding whitespace, i.e., no whitepsace appears
simonp@8244 2110 before the first property name and no whitespace appears after the final semicolon delimiter that follows the last property value.</p>
simonp@8244 2111
simonp@8795 2112 <p>The <dfn title=concept-shorthands-preferred-order>preferred order</dfn> of a list of shorthand properties <var>shorthands</var> is as follows:
simonp@8795 2113
simonp@8795 2114 <ol>
simonp@8795 2115 <li><p>Order <var>shorthands</var> lexicographically.
simonp@8823 2116 <li><p>Move all items in <var>shorthands</var> that begin with "<code title>-</code>" (U+002D) last in the list, retaining their relative order.
simonp@8823 2117 <li><p>Move all items in <var>shorthands</var> that begin with "<code title>-</code>" (U+002D) but do not begin with "<code title>-webkit-</code>" last in the
simonp@8823 2118 list, retaining their relative order.
simonp@8795 2119 <li><p>Order <var>shorthands</var> by the number of longhand properties that map to it, with the greatest number first.
simonp@8795 2120 </ol>
simonp@8244 2121
simonp@8244 2122 <h4>The <code title>CSSStyleDeclaration</code> Interface</h4>
simonp@8226 2123
simonp@8226 2124 <!--
simonp@8226 2125 //
simonp@8226 2126 // All members defined since DOM-2 Style. The only differences are:
simonp@8226 2127 //
simonp@8226 2128 // 1. removal of commented raises(DOMException) on setting cssText
simonp@8226 2129 // 2. removal of raises(DOMException) on {set,remove}Property
simonp@8226 2130 // 3. removal of getPropertyCSSValue() method
simonp@8226 2131 //
simonp@8226 2132 -->
simonp@8226 2133
simonp@8226 2134 <p>The <code>CSSStyleDeclaration</code> interface represents a <span>CSS declaration block</span>, including its underlying state, where this
simonp@8244 2135 underlying state depends upon the source of the <code>CSSStyleDeclaration</Code> instance.</p>
simonp@8226 2136
simonp@8226 2137 <pre class=idl>interface <dfn>CSSStyleDeclaration</dfn> {
simonp@8262 2138 attribute DOMString <span title=dom-CSSStyleDeclaration-cssText>cssText</span>;
simonp@8262 2139 readonly attribute unsigned long <span title=dom-CSSStyleDeclaration-length>length</span>;
simonp@8266 2140 getter DOMString <span title=dom-CSSStyleDeclaration-item>item</span>(unsigned long index);
simonp@8262 2141 DOMString <span title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue</span>(DOMString property);
simonp@8262 2142 DOMString <span title=dom-CSSStyleDeclaration-getPropertyPriority>getPropertyPriority</span>(DOMString property);
simonp@8350 2143 void <span title=dom-CSSStyleDeclaration-setProperty>setProperty</span>(DOMString property, [TreatNullAs=EmptyString] DOMString value, <!--
simonp@8870 2144 -->[TreatNullAs=EmptyString] optional DOMString priority);
simonp@8262 2145 DOMString <span title=dom-CSSStyleDeclaration-removeProperty>removeProperty</span>(DOMString property);
simonp@8262 2146 readonly attribute <span>CSSRule</span>? <span title=dom-CSSStyleDeclaration-length>parentRule</span>;
simonp@8350 2147 attribute DOMString <span title=dom-CSSStyleDeclaration-cssFloat>cssFloat</span>;<!-- setProperty's value arg has [TreatNullAs=EmptyString] -->
simonp@8226 2148 };</pre>
simonp@8226 2149
simonp@8266 2150 <p>The object's <span data-anolis-spec=webidl>supported property indices</span> are the numbers in the range zero to one less than the number of declarations in
simonp@8305 2151 the <span title=concept-css-declaration-block-declarations>declarations</span>. If there are no such declarations, then there are no
simonp@8305 2152 <span data-anolis-spec=webidl>supported property indices</span>.
simonp@8266 2153
simonp@8304 2154 <p>The <dfn title=dom-CSSStyleDeclaration-cssText><code>cssText</code></dfn> attribute must return the result of
simonp@8305 2155 <span title='serialize a CSS declaration block'>serializing</span> the <span title=concept-css-declaration-block-declarations>declarations</span>.</p>
simonp@8226 2156 <p>Setting the <code title=dom-CSSStyleDeclaration-cssText>cssText</code> attribute must run these steps:
simonp@8226 2157 <ol>
simonp@8305 2158 <li><p>If the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> is set, <span data-anolis-spec=dom title=concept-throw>throw</span>
simonp@8305 2159 a <code data-anolis-spec=dom>NoModificationAllowedError</code> exception and terminate these steps.</li>
simonp@8305 2160 <li><p>Empty the <span title=concept-css-declaration-block-declarations>declarations</span>.</li>
simonp@8590 2161 <li><p><span title='Parse a CSS declaration block'>Parse</span> the given value and, if the return value is not the empty list, insert the items in the list
simonp@8807 2162 into the <span title=concept-css-declaration-block-declarations>declarations</span>, in <span title=concept-declarations-specified-order>specified
simonp@8807 2163 order</span>.</p></li>
simonp@8226 2164 </ol>
simonp@8226 2165
simonp@8327 2166 <p>The <dfn title=dom-CSSStyleDeclaration-length><code>length</code></dfn> attribute must return the number of declarations in the
simonp@8327 2167 <span title=concept-css-declaration-block-declarations>declarations</span>.</p>
simonp@8304 2168
simonp@8406 2169 <p>The <dfn title=dom-CSSStyleDeclaration-item><code>item(<var>index</var>)</code></dfn> method must return the name of the property at position
simonp@8406 2170 <var>index</var>.</p>
simonp@8406 2171
simonp@8406 2172 <p>The <dfn title=dom-CSSStyleDeclaration-getPropertyValue><code>getPropertyValue(<var>property</var>)</code></dfn> method must run these steps:</p>
simonp@8226 2173 <ol>
simonp@8592 2174 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>.
simonp@8594 2175 <li><p>If <var>property</var> is a shorthand property, then follow these substeps:
simonp@8594 2176 <ol>
simonp@8594 2177 <li><p>Let <var>list</var> be a new empty array.
simonp@8594 2178 <li><p>For each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical order, follow these substeps:
simonp@8594 2179 <ol>
simonp@8594 2180 <li><p>If <var>longhand</var> is a <span data-anolis-spec=dom>case-sensitive</span> match for a property of a declaration in the
simonp@8594 2181 <span title=concept-css-declaration-block-declarations>declarations</span>, let <var>declaration</var> be that declaration, or null otherwise.
simonp@8594 2182 <li><p>If <var>declaration</var> is null, return the empty string and terminate these steps.
simonp@8594 2183 <li><p>Append the <var>declaration</var> to <var>list</var>.
simonp@8594 2184 </ol>
simonp@8594 2185 <li><p>Return the <span title='serialize a CSS value'>serialization</span> of <var>list</var> and terminate these steps.
simonp@8594 2186 </ol>
simonp@8406 2187 <li><p>If <var>property</var> is a <span data-anolis-spec=dom>case-sensitive</span>
simonp@8226 2188 match for a property of a declaration in the
simonp@8594 2189 <span title=concept-css-declaration-block-declarations>declarations</span>, return the result of invoking
simonp@8594 2190 <span>serialize a CSS value</span> of that declaration and terminate these steps.
simonp@8226 2191 <li><p>Return the empty string.
simonp@8226 2192 </ol>
simonp@8226 2193
simonp@8406 2194 <p>The <dfn title=dom-CSSStyleDeclaration-getPropertyPriority><code>getPropertyPriority(<var>property</var>)</code></dfn> method must run these steps:
simonp@8226 2195 <ol>
simonp@8592 2196 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>.
simonp@8586 2197 <li><p>If <var>property</var> is a shorthand property, follow these substeps:
simonp@8586 2198 <ol>
simonp@8586 2199 <li><p>Let <var>list</var> be a new array.
simonp@8586 2200 <li><p>For each longhand property <var>longhand</var> that <var>property</var> maps to, append the result of invoking
simonp@8586 2201 <code title=dom-CSSStyleDeclaration-getPropertyPriority>getPropertyPriority()</code> with <var>longhand</var> as argument to <var>list</var>.
simonp@8586 2202 <li><p>If all items in <var>list</var> are the string "<code title>important</code>", return the string "<code title>important</code>" and terminate these
simonp@8586 2203 steps.
simonp@8586 2204 </ol>
simonp@8586 2205 <li><p>Otherwise, follow these substeps:
simonp@8586 2206 <ol>
simonp@8586 2207 <li><p>If <var>property</var> is a
simonp@8586 2208 <span data-anolis-spec=dom>case-sensitive</span> match for a property of a
simonp@8586 2209 declaration in the <span title=concept-css-declaration-block-declarations>declarations</span> that has the
simonp@8592 2210 <i>important</i> flag set, return
simonp@8586 2211 the string "<code title>important</code>".</p>
simonp@8586 2212 </ol>
simonp@8226 2213 <li><p>Return the empty string.
simonp@8226 2214 </ol>
simonp@8450 2215 <div class='example'><p>E.g. for <code title>background-color:lime !IMPORTANT</code> the return
simonp@8450 2216 value would be "<code title>important</code>".</div>
simonp@8304 2217
simonp@8406 2218 <p>The <dfn title=dom-CSSStyleDeclaration-setProperty><code>setProperty(<var>property</var>, <var>value</var>,
simonp@8406 2219 <var>priority</var>)</code></dfn> method must run these steps:</p>
simonp@8226 2220 <ol>
simonp@8305 2221 <li><p>If the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> is set, <span data-anolis-spec=dom title=concept-throw>throw</span>
simonp@8826 2222 a <code data-anolis-spec=dom>NoModificationAllowedError</code> exception and terminate these steps.</li>
simonp@8592 2223 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>.
simonp@8592 2224 <li><p>If <var>property</var> is not a <span data-anolis-spec=dom>case-sensitive</span> match for a <span>supported CSS property</span>, terminate this
simonp@8592 2225 algorithm.</p></li>
simonp@8406 2226 <li><p>If <var>value</var> is the empty string, invoke <code title='dom-CSSStyleDeclaration-removeProperty'>removeProperty()</code>
simonp@8406 2227 with <var>property</var> as argument and terminate this algorithm.</p></li>
simonp@8870 2228 <li><p>If <var>priority</var> is not specified, let <var>priority action</var> be "leave as is". Otherwise, if <var>priority</var> is the empty string, let
simonp@8870 2229 <var>priority action</var> be "unset important". Otherwise, if <var>priority</var> is an <span data-anolis-spec=dom>ASCII case-insensitive</span> match for the
simonp@8870 2230 string "<code title>important</code>", set <var>priority action</var> to "set important". Otherwise, terminate this algorithm.
simonp@8226 2231 <li>
simonp@8594 2232 <p>Let <var>component value list</var> be the result of <span title='parse a CSS value'>parsing</span> <var>value</var>.
simonp@8594 2233 <p class='note'><var>value</var> can not include "<code title>!important</code>".</p>
simonp@8226 2234 </li>
simonp@8594 2235 <li><p>If <var>component value list</var> is null terminate these steps.
simonp@8594 2236 <li><p>If <var>property</var> is a shorthand property, then for each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical
simonp@8594 2237 order, <span title="set a CSS property">set the CSS property</span> <var>longhand</var> to the appropriate value(s) from <var>component value list</var>, with
simonp@8870 2238 <i>priority action</i> being <var>priority action</var>, and with the list of declarations being the
simonp@8594 2239 <span title=concept-css-declaration-block-declarations>declarations</span>.
simonp@8594 2240 <li><p>Otherwise, <span title="set a CSS property">set the CSS property</span> <var>property</var> to <var>component value list</var>, with
simonp@8870 2241 <i>priority action</i> being <var>priority action</var>, and with the list of declarations being the
simonp@8594 2242 <span title=concept-css-declaration-block-declarations>declarations</span>.
simonp@8594 2243 </ol>
simonp@8594 2244
simonp@8870 2245 <p>To <dfn>set a CSS property</dfn> <var>property</var> to a value <var>component value list</var> and with <i>priority action</i> being either "set
simonp@8870 2246 important", "unset important" or "leave as is", in a list of declarations <var>declarations</var>, follow these steps:
simonp@8594 2247
simonp@8594 2248 <ol>
simonp@8594 2249 <li><p>If <var>property</var> is a <span data-anolis-spec=dom>case-sensitive</span> match for a property of a declaration in
simonp@8594 2250 <var>declarations</var>, let <var>declaration</var> be that declaration.
simonp@8594 2251 <li><p>Otherwise, append a new declaration with the property name <var>property</var> to <var>declarations</var> and let <var>declaration</var> be that
simonp@8594 2252 declaration.
simonp@8594 2253 <li><p>Set <var>declaration</var>'s value to <var>component value list</var>.
simonp@8870 2254 <li><p>If <i>priority action</i> is "set important", set the declaration's <i>important</i> flag.
simonp@8870 2255 <li><p>Otherwise, if <i>priority action</i> is "unset important", unset the declaration's <i>important</i> flag.
simonp@8226 2256 </ol>
simonp@8226 2257
simonp@8406 2258 <p>The <dfn title=dom-CSSStyleDeclaration-removeProperty><code>removeProperty(<var>property</var>)</code></dfn> method must run these steps:</p>
simonp@8226 2259 <ol>
simonp@8305 2260 <li><p>If the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> is set, <span data-anolis-spec=dom title=concept-throw>throw</span>
simonp@8305 2261 a <code data-anolis-spec=dom>NoModificationAllowedError</code> exception and terminate these steps.</li>
simonp@8592 2262 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>.
simonp@8406 2263 <li><p>Let <var>value</var> be the return value of invoking <code title='dom-CSSStyleDeclaration-getPropertyValue'>getPropertyValue()</code>
simonp@8406 2264 with <var>property</var> as argument.
simonp@8586 2265 <li><p>If <var>property</var> is a shorthand property, for each longhand property <var>longhand</var> that <var>property</var> maps to, invoke
simonp@8586 2266 <code title=dom-CSSStyleDeclaration-removeProperty>removeProperty()</code> with <var>longhand</var> as argument.
simonp@8592 2267 <li><p>Otherwise, if <var>property</var> is a <span data-anolis-spec=dom>case-sensitive</span> match for a property of a declaration in the
simonp@8592 2268 <span title=concept-css-declaration-block-declarations>declarations</span>, remove the declaration.
simonp@8406 2269 <li><p>Return <var>value</var>.
simonp@8226 2270 </ol>
simonp@8226 2271
simonp@8304 2272 <p>The <dfn title=dom-CSSStyleDeclaration-parentRule><code>parentRule</code></dfn> attribute must return the <code>CSSrule</code> object the
simonp@8304 2273 <code>CSSStyleDeclaration</code> is object is associated with or null if it is not associated with a <code>CSSrule</code> object.</p>
simonp@8289 2274
simonp@8291 2275 <p>The <dfn title=dom-CSSStyleDeclaration-cssFloat><code>cssFloat</code></dfn>
simonp@8291 2276 attribute, on getting, must return the result of invoking
simonp@8291 2277 <code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with
simonp@8291 2278 <code title>float</code> as argument. On setting, the attribute must invoke
simonp@8291 2279 <code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with
simonp@8291 2280 <code title>float</code> as first argument, as second argument the given value, and no third argument.
simonp@8291 2281 Any exceptions thrown must be re-thrown.
simonp@8291 2282
simonp@8592 2283 <p>For each CSS property <var>property</var> that is a <span>supported CSS property</span>,
simonp@8406 2284 the following partial interface applies where <var>camel-cased attribute</var>
simonp@8291 2285 is obtained by running the <span>CSS property to IDL attribute</span> algorithm for
simonp@8291 2286 <var>property</var>.</p>
simonp@8291 2287
simonp@8352 2288 <pre class="idl extract">partial interface <span>CSSStyleDeclaration</span> {
simonp@8406 2289 attribute DOMString _<span title=dom-CSSStyleDeclaration-camel-cased-attribute><var>camel-cased attribute</var></span>;
simonp@8291 2290 };</pre>
simonp@8291 2291
simonp@8406 2292 <p>The <dfn title=dom-CSSStyleDeclaration-camel-cased-attribute><code><var>camel-cased attribute</var></code></dfn> attribute, on getting, must return the
simonp@8351 2293 result of invoking <code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with the
simonp@8331 2294 argument being the result of running the <span>IDL attribute to CSS property</span>
simonp@8406 2295 algorithm for <var>camel-cased attribute</var>.</p>
simonp@8406 2296
simonp@8406 2297 <p>Setting the <code title=dom-CSSStyleDeclaration-camel-cased-attribute><var>camel-cased attribute</var></code> attribute must invoke
simonp@8331 2298 <code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with the
simonp@8331 2299 first argument being the result of running the <span>IDL attribute to CSS property</span>
simonp@8406 2300 algorithm for <var>camel-cased attribute</var>, as second argument the given value, and no third argument. Any
simonp@8291 2301 exceptions thrown must be re-thrown.</p>
simonp@8289 2302
simonp@8450 2303 <div class=example><p>For example, for the 'font-size' property there would be a <code title>fontSize</code> IDL attribute.</div>
simonp@8351 2304
glenn@8354 2305 <!-- [GA] Remove spec text for so called "dashed-attribute" until consensus obtains on whether to include in spec.
glenn@8354 2306
simonp@8592 2307 <p>For each CSS property <var>property</var> that is a <span>supported CSS property</span>, except for properties that have no "<code title>-</code>" (U+002D)
simonp@8592 2308 in the property name, user agents must act as if there was a WebIDL <span data-anolis-spec=webidl>regular attribute</span> member as part of the
simonp@8351 2309 <code>CSSStyleDeclaration</code> interface with the type being <code title>DOMString</code> and the <span data-anolis-spec=webidl>identifier</span> being
simonp@8406 2310 <var>property</var>, and let <var>dashed attribute</var> be <var>property</var>.
simonp@8406 2311
simonp@8406 2312 <p>The <dfn title=dom-CSSStyleDeclaration-dashed-attribute><code><var>dashed attribute</var></code></dfn> attribute, on getting, must return the
simonp@8351 2313 result of invoking <code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with the
simonp@8406 2314 argument being <var>dashed attribute</var>.</p>
simonp@8406 2315
simonp@8406 2316 <p>Setting the <code title=dom-CSSStyleDeclaration-dashed-attribute><var>dashed attribute</var></code> attribute must invoke
simonp@8351 2317 <code title=dom-CSSStyleDeclaration-setProperty>setProperty()</code> with the
simonp@8406 2318 first argument being <var>dashed attribute</var>, as second argument the given value, and no third argument. Any
simonp@8351 2319 exceptions thrown must be re-thrown.</p>
simonp@8351 2320
simonp@8351 2321 <div class=example>
simonp@8351 2322 <p>For example, for the 'font-size' property there would be a <code title>font-size</code> IDL attribute. In JavaScript, the property can be accessed as
simonp@8406 2323 follows, assuming <var>element</var> is an <span data-anolis-spec=html title="HTML elements">HTML element</span>:
simonp@8406 2324 <pre><var>element</var>.style['font-size'];</pre>
simonp@8351 2325 </div>
simonp@8351 2326
simonp@8351 2327 <p class=note>WebIDL does not allow dashes in identifiers in its syntax.
simonp@8351 2328
simonp@8435 2329 <p class=issue>The <code title=dom-CSSStyleDeclaration-dashed-attribute><var>dashed attribute</var></code> attributes will be removed from the specification
simonp@8352 2330 if implementations remove support. User agents that currently support them are urged to experiment with removing support.
simonp@8352 2331
glenn@8354 2332 -->
glenn@8354 2333
simonp@8406 2334 <p>The <dfn>CSS property to IDL attribute</dfn> algorithm for <var>property</var> is as
simonp@8244 2335 follows:</p>
simonp@8244 2336
simonp@8244 2337 <ol>
simonp@8406 2338 <li><p>Let <var>output</var> be the empty string.
simonp@8244 2339
simonp@8406 2340 <li><p>Let <var>uppercase next</var> be unset.
simonp@8244 2341
simonp@8406 2342 <li><p>For each character <var>c</var> in <var>property</var>:
simonp@8244 2343
simonp@8226 2344 <ol>
simonp@8406 2345 <li><p>If <var>c</var> is "<code title>-</code>" (U+002D), let <var>uppercase next</var> be set.
simonp@8244 2346
simonp@8406 2347 <li><p>Otherwise, if <var>uppercase next</var> is set, let <var>uppercase next</var> be unset and append <var>c</var>
simonp@8406 2348 <span data-anolis-spec=dom>converted to ASCII uppercase</span> to <var>output</var>.
simonp@8244 2349
simonp@8406 2350 <li><p>Otherwise, append <var>c</var> to <var>output</var>.
simonp@8226 2351 </ol>
simonp@8244 2352
simonp@8406 2353 <li><p>Return <var>output</var>.
simonp@8244 2354 </ol>
simonp@8244 2355
simonp@8406 2356 <p>The <dfn>IDL attribute to CSS property</dfn> algorithm for <var>attribute</var> is as
simonp@8244 2357 follows:</p>
simonp@8244 2358
simonp@8244 2359 <ol>
simonp@8406 2360 <li><p>Let <var>output</var> be the empty string.
simonp@8244 2361
simonp@8406 2362 <li><p>For each character <var>c</var> in <var>attribute</var>:
simonp@8244 2363
simonp@8226 2364 <ol>
simonp@8406 2365 <li><p>If <var>c</var> is in the range U+0041 to U+005A (ASCII uppercase), append "<code title>-</code>" (U+002D) followed by <var>c</var>
simonp@8406 2366 <span data-anolis-spec=dom>converted to ASCII lowercase</span> to <var>output</var>.
simonp@8244 2367
simonp@8406 2368 <li><p>Otherwise, append <var>c</var> to <var>output</var>.
simonp@8226 2369 </ol>
simonp@8244 2370
simonp@8406 2371 <li><p>Return <var>output</var>.
simonp@8244 2372 </ol>
simonp@8244 2373
simonp@8226 2374
simonp@8244 2375 <h3>CSS Values</h3>
simonp@8244 2376
simonp@8244 2377
simonp@8244 2378 <h4>Parsing CSS Values</h4>
simonp@8244 2379
simonp@8449 2380 <p>To <dfn>parse a CSS value</dfn> <var>value</var> for a given
simonp@8449 2381 <var>property</var> means to follow these steps:
simonp@8449 2382
simonp@8449 2383 <ol>
simonp@8449 2384 <li><p>Let <var>list</var> be the value returned by invoking <span data-anolis-spec=csssyntax>parse a list of component values</span> from <var>value</var>.
simonp@8592 2385 <li><p>Match <var>list</var> against the grammar for the property <var>property</var> in the CSS specification.
simonp@8449 2386 <li><p>If the above step failed, return null.
simonp@8449 2387 <li><p>Return <var>list</var>.
simonp@8449 2388 </ol>
simonp@8244 2389
simonp@8304 2390 <p class="note">"<code title>!important</code>" declarations are not
simonp@8244 2391 part of the property value space and will therefore cause
simonp@8289 2392 <span>parse a CSS value</span> to return null.</p>
simonp@8244 2393
simonp@8244 2394
simonp@8244 2395
simonp@8244 2396 <h4>Serializing CSS Values</h4>
simonp@8244 2397
simonp@8244 2398 <!-- based on http://damowmow.com/playground/canon.txt -->
simonp@8244 2399
simonp@8594 2400 <p>To <dfn>serialize a CSS value</dfn> of a declaration <var>declaration</var> or a list of longhand declarations <var>list</var>, follow
simonp@8244 2401 these rules:</p>
simonp@8244 2402
simonp@8595 2403 <ol>
simonp@8595 2404 <li><p>If this algorithm is invoked with a list <var>list</var>, follow these substeps:
simonp@8595 2405 <ol>
simonp@8795 2406 <li><p>Let <var>shorthand</var> be the shorthand property that exactly maps to all the longhand properties in <var>list</var>. If there are multiple such
simonp@8795 2407 shorthand properties, use the first in <span title=concept-shorthands-preferred-order>preferred order</span>.
simonp@8595 2408 <li><p>If <var>shorthand</var> cannot represent the values of <var>list</var> in its grammar, return the empty string and terminate these steps.
simonp@8595 2409 <li><p>Let <var>trimmed list</var> be a new empty array.
simonp@8595 2410 <li><p>For each declaration <var>declaration</var> in <var>list</var>, if <var>declaration</var>'s value is not the initial value, or if
simonp@8595 2411 <var>declaration</var> is a required component of the <var>shorthand</var> property, append <var>declaration</var> to <var>trimmed list</var>.
simonp@8595 2412 <li><p>If <var>trimmed list</var> is empty, append the value of the first item in <var>list</var> to <var>trimmed list</var>.
simonp@8595 2413 <li><p>Let <var>values</var> be a new empty array.
simonp@8595 2414 <li><p>For each declaration <var>declaration</var> in <var>trimmed list</var>, invoke <span>serialize a CSS value</span> of <var>declaration</var>, and
simonp@8595 2415 append the result to <var>values</var>.
simonp@8595 2416 <li><p>Return the result of joining <var>values</var> as appropriate according to the grammar of <var>shorthand</var> and terminate these steps.
simonp@8595 2417 </ol>
simonp@8595 2418 <li><p>Let <var>values</var> be a new empty array.
simonp@8595 2419 <li><p>Append the result of invoking <span>serialize a CSS component value</span> of <var>declaration</var>'s value to <var>values</var>.
simonp@8595 2420 <li><p>If the grammar of the property of <var>declaration</var> is defined to be whitespace-separated, return the result of invoking <span>serialize a
simonp@8595 2421 whitespace-separated list</span> of <var>values</var> and terminate these steps.
simonp@8595 2422 <li><p>If the grammar of the property of <var>declaration</var> is defined to be comma-separated, return the result of invoking <span>serialize a
simonp@8595 2423 comma-separated list</span> of <var>values</var>.
simonp@8595 2424 </ol>
simonp@8244 2425
simonp@8244 2426 <p>To
simonp@8244 2427 <dfn>serialize a CSS component value</dfn>
simonp@8244 2428 depends on the component, as follows:</p>
simonp@8244 2429
simonp@8244 2430 <dl class="switch">
simonp@8244 2431 <dt>keyword</dt>
simonp@8244 2432 <dd><p>The keyword
simonp@8244 2433 <span data-anolis-spec=dom>converted to ASCII lowercase</span>.</p></dd>
simonp@8244 2434
simonp@8244 2435 <dt>&lt;angle></dt>
simonp@8244 2436 <dd><p>The number of degrees serialized as per &lt;number> followed by
simonp@8304 2437 the literal string "<code title>deg</code>".</p></dd>
simonp@8244 2438
simonp@8244 2439 <dt>&lt;color></dt>
simonp@8244 2440 <dd>
simonp@8244 2441 <p>If &lt;color&gt; is a component of a resolved or computed value, then
simonp@8304 2442 return the color using the <code title>rgb()</code> or <code title>rgba()</code> functional
simonp@8244 2443 notation as follows:</p>
simonp@8244 2444 <ol>
simonp@8244 2445 <li>If the alpha component of the color is equal to one, then return the serialization of the
simonp@8304 2446 <code title>rgb()</code> functional equivalent of the opaque color.</li>
simonp@8244 2447 <li>If the alpha component of the color is not equal to one, then return the serialization of the
simonp@8304 2448 <code title>rgba()</code> functional equivalent of the non-opaque color.</li>
simonp@8244 2449 </ol>
simonp@8304 2450 <p>The serialization of the <code title>rgb()</code> functional equivalent is the concatenation of the following:</p>
simonp@8244 2451 <ol>
simonp@8304 2452 <li>The string "<code title>rgb(</code>".</li>
simonp@8244 2453 <li>The shortest base-ten integer serialization of the color's red component.</li>
simonp@8304 2454 <li>The string "<code title>, </code>".</li>
simonp@8244 2455 <li>The shortest base-ten serialization of the color's green component.</li>
simonp@8304 2456 <li>The string "<code title>, </code>".</li>
simonp@8244 2457 <li>The shortest base-ten serialization of the color's blue component.</li>
simonp@8304 2458 <li>The string "<code title>)</code>".</li>
simonp@8244 2459 </ol>
simonp@8304 2460 <p>The serialization of the <code title>rgba()</code> functional equivalent is the concatenation of the following:</p>
simonp@8244 2461 <ol>
simonp@8304 2462 <li>The string "<code title>rgba(</code>".</li>
simonp@8244 2463 <li>The shortest base-ten serialization of the color's red component.</li>
simonp@8304 2464 <li>The string "<code title>, </code>".</li>
simonp@8244 2465 <li>The shortest base-ten serialization of the color's green component.</li>
simonp@8304 2466 <li>The string "<code title>, </code>".</li>
simonp@8244 2467 <li>The shortest base-ten serialization of the color's blue component.</li>
simonp@8304 2468 <li>The string "<code title>, </code>".</li>
simonp@8244 2469 <li>The shortest serialization of the &lt;number&gt; that denotes the color's alpha component.</li>
simonp@8304 2470 <li>The string "<code title>)</code>".</li>
simonp@8244 2471 </ol>
simonp@8244 2472
simonp@8304 2473 <p>In the above rules, the string "<code title>, </code>" denotes a COMMA (U+002C) followed by a single SPACE (U+0020).</p>
simonp@8244 2474
simonp@8244 2475 <p>If &lt;color&gt; is a component of a specified value, then
simonp@8244 2476 return the color as follows:</p>
simonp@8244 2477 <ol>
simonp@8244 2478 <li>If the color was explicitly specified by the author, then return the original, author specified color value.</li>
simonp@8244 2479 <li>Otherwise, return the value that would be returned if the color were a component of a computed value.</li>
simonp@8244 2480 </ol>
simonp@8435 2481 <p class="issue">Should author specified values be normalized for case? Or should original case be preserved?</p>
simonp@8244 2482 </dd>
simonp@8244 2483 <!--
simonp@8244 2484 <dt>It is a system color</dt>
simonp@8244 2485
simonp@8244 2486 <dd>See below (you use the representation given in the specification that
simonp@8244 2487 defines the keyword).</dd>
simonp@8244 2488
simonp@8244 2489 <dt>Alpha component is equal to 1.0</dt>
simonp@8244 2490
simonp@8244 2491 <dd>The color is an uppercase six-digit hexadecimal value, prefixed with a
simonp@8304 2492 <code title>#</code> character (U+0023 NUMBER SIGN), with the first two digits
simonp@8244 2493 representing the red component, the next two digits representing the green
simonp@8244 2494 component, and the last two digits representing the blue component, the
simonp@8244 2495 digits being in the range 0-9 A-F (U+0030 to U+0039 and U+0041 to
simonp@8244 2496 U+0046).</dd>
simonp@8244 2497
simonp@8244 2498 <dt>Alpha component is less than 1.0</dt>
simonp@8244 2499
simonp@8304 2500 <dd>The color is in the CSS <code title>rgba()</code> functional-notation format:
simonp@8304 2501 the literal string <code title>rgba</code> (U+0072 U+0067 U+0062 U+0061) followed
simonp@8244 2502 by a U+0028 LEFT PARENTHESIS, a <span>color component integer</span>
simonp@8244 2503 representing the red component, a <span>color component separator</span>, a
simonp@8244 2504 <span>color component integer</span> for the green component, a <span>color
simonp@8244 2505 component separator</span>, a <span>color component integer</span> for the
simonp@8244 2506 blue component, another <span>color component separator</span> a U+0030
simonp@8244 2507 DIGIT ZERO, a U+002E FULL STOP (representing the decimal point), one or
simonp@8244 2508 more digits in the range 0-9 (U+0030 to U+0039) representing the fractional
simonp@8244 2509 part of the alpha value, and finally a U+0029 RIGHT PARENTHESIS.</dd>
simonp@8244 2510
simonp@8304 2511 <dt>The keyword <code title>transparent</code> is used</dt>
simonp@8304 2512
simonp@8304 2513 <dd>The color is <code title>rgba(0, 0, 0, 0)</code>.</dd>
simonp@8244 2514 -->
simonp@8244 2515
simonp@8244 2516 <dt>&lt;counter></dt>
simonp@8244 2517 <dd>
simonp@8244 2518 <p>The concatenation of:</p>
simonp@8244 2519 <ol>
simonp@8244 2520 <li><p>If &lt;counter> has three CSS component values the string
simonp@8304 2521 "<code title>counters(</code>".</p></li>
simonp@8244 2522 <li><p>If &lt;counter> has two CSS component values the string
simonp@8304 2523 "<code title>counter(</code>".</p></li>
simonp@8244 2524 <li><p>The result of
simonp@8244 2525 <span title="serialize a comma-separated list">serializing</span> the
simonp@8226 2526 <span title="serialize a CSS component value">serialized</span>
simonp@8244 2527 CSS component values belonging to &lt;counter> as list while omitting
simonp@8244 2528 the last CSS component value if it is 'decimal'.</p></li>
simonp@8304 2529 <li><p>"<code title>)</code>" (U+0029).</p></li>
simonp@8244 2530 </ol>
simonp@8244 2531 </dd>
simonp@8244 2532
simonp@8244 2533 <dt>&lt;frequency></dt>
simonp@8244 2534 <dd><p>The frequency in hertz serialized as per &lt;number> followed by
simonp@8304 2535 the literal string "<code title>hz</code>".</dd>
simonp@8244 2536
simonp@8244 2537 <dt>&lt;identifier></dt>
simonp@8244 2538 <dd><p>The identifier
simonp@8244 2539 <span title="serialize an identifier">escaped</span>.</p></dd>
simonp@8244 2540
simonp@8244 2541 <dt>&lt;integer></dt>
simonp@8244 2542 <dd><p>A base-ten integer using digits 0-9 (U+0030 to U+0039) in the
simonp@8304 2543 shortest form possible, preceded by "<code title>-</code>" (U+002D) if it is
simonp@8244 2544 negative.</p></dd>
simonp@8244 2545
simonp@8244 2546 <dt>&lt;length></dt>
simonp@8244 2547 <dd>
simonp@8244 2548 <p>A length of zero is represented by the literal string
simonp@8304 2549 "<code title>0px</code>".</p>
simonp@8244 2550
simonp@8244 2551 <p>Absolute lengths: the number of millimeters serialized as per
simonp@8304 2552 &lt;number> followed by the literal string "<code title>mm</code>".</p>
simonp@8435 2553 <p class="issue">Rumor has it absolute lengths will become relative
simonp@8244 2554 lengths. Centimeters would be compatible with &lt;resolution>...</p>
simonp@8244 2555
simonp@8244 2556 <p>Relative lengths: the &lt;number> component serialized as per
simonp@8244 2557 &lt;number> followed by the unit in its canonical form as defined in its
simonp@8244 2558 respective specification.</p>
simonp@8244 2559 </dd>
simonp@8244 2560
simonp@8244 2561 <dt>&lt;number></dt>
simonp@8485 2562 <dd>
simonp@8485 2563 <p>A base-ten number using digits 0-9 (U+0030 to U+0039) in the shortest form possible, using "<code title>.</code>" to separate decimals (if any), preceded
simonp@8485 2564 by "<code title>-</code>" (U+002D) if it is negative.
simonp@8485 2565
simonp@8485 2566 <p class=note>JavaScript's <code title>ToString</code> algorithm cannot be used since it can serialize numbers using an exponent, which would not round-trip
simonp@8485 2567 in CSS.
simonp@8244 2568
simonp@8244 2569 <dt>&lt;percentage></dt>
simonp@8244 2570 <dd><p>The &lt;number> component serialized as per &lt;number> followed
simonp@8304 2571 by the literal string "<code title>%</code>" (U+0025).</p></dd>
simonp@8244 2572
simonp@8244 2573 <dt>&lt;resolution></dt>
simonp@8244 2574 <dd><p>The resolution in dots per centimeter serialized as per
simonp@8304 2575 &lt;number> followed by the literal string "<code title>dpcm</code>".</dd>
simonp@8244 2576
simonp@8244 2577 <dt>&lt;shape></dt>
simonp@8304 2578 <dd><p>The string "<code title>rect(</code>", followed by the result
simonp@8244 2579 of <span title="serialize a comma-separated list">serializing</span> the
simonp@8244 2580 <span title="serialize a CSS component value">serialized</span>
simonp@8244 2581 CSS component values belonging to &lt;shape> as list, followed by
simonp@8304 2582 "<code title>)</code>" (U+0029).</p></dd>
simonp@8244 2583
simonp@8244 2584 <dt>&lt;string></dt>
simonp@8244 2585 <dt>&lt;family-name></dt>
simonp@8244 2586 <dt>&lt;specific-voice></dt>
simonp@8244 2587 <dd><p>The string
simonp@8244 2588 <span title="serialize a string">string escaped</span>.</p></dd>
simonp@8244 2589
simonp@8244 2590 <dt>&lt;time></dt>
simonp@8244 2591 <dd><p>The time in seconds serialized as per &lt;number> followed by
simonp@8304 2592 the literal string "<code title>s</code>".</dd>
simonp@8244 2593
simonp@8244 2594 <dt>&lt;uri></dt>
simonp@8244 2595 <dd><p>The <span data-anolis-spec=url title=concept-absolute-url>absolute URL</span>
simonp@8244 2596 <span title="serialize a URL">URL escaped</span>.</p></dd>
simonp@8244 2597 </dl>
simonp@8244 2598
simonp@8244 2599 <p>
simonp@8244 2600 &lt;absolute-size>,
simonp@8244 2601 &lt;border-width>,
simonp@8244 2602 &lt;border-style>,
simonp@8244 2603 &lt;bottom>,
simonp@8244 2604 &lt;generic-family>,
simonp@8244 2605 &lt;generic-voice>,
simonp@8244 2606 &lt;left>,
simonp@8244 2607 &lt;margin-width>,
simonp@8244 2608 &lt;padding-width>,
simonp@8244 2609 &lt;relative-size>,
simonp@8244 2610 &lt;right>, and
simonp@8244 2611 &lt;top>,
simonp@8244 2612 are considered macros by this specification. They all represent instances
simonp@8244 2613 of components outlined above.</p>
simonp@8244 2614
simonp@8435 2615 <p class="issue">One idea is that we can remove this section somewhere in
simonp@8244 2616 the CSS3/CSS4 timeline by moving the above definitions to the drafts that
simonp@8244 2617 define the CSS components.</p>
simonp@8244 2618
simonp@8244 2619
simonp@8244 2620 <h5>Examples</h5>
simonp@8244 2621
simonp@8244 2622 <p>Here are some examples of before and after results on specified values.
simonp@8244 2623 The before column could be what the author wrote in a style sheet, while
simonp@8244 2624 the after column shows what querying the DOM would return.</p>
simonp@8244 2625
simonp@8244 2626 <div class="example">
simonp@8559 2627 <table class="complex data">
simonp@8244 2628 <thead>
simonp@8244 2629 <tr><th>Before<th>After
simonp@8244 2630 <tbody>
simonp@8304 2631 <tr><td><code title>background: none</code><td><code title>background: rgba(0, 0, 0, 0)</code>
simonp@8304 2632 <tr><td><code title>outline: none</code><td><code title>outline: invert</code>
simonp@8304 2633 <tr><td><code title>border: none</code><td><code title>border: medium</code>
simonp@8304 2634 <tr><td><code title>list-style: none</code><td><code title>list-style: disc</code>
simonp@8304 2635 <tr><td><code title>margin: 0 1px 1px 1px</code><td><code title>margin: 0px 1px 1px</code>
simonp@8304 2636 <tr><td><code title>azimuth: behind left</code><td><code title>azimuth: 220deg</code>
simonp@8304 2637 <tr><td><code title>font-family: a, 'b"', serif</code><td><code title>font-family: "a", "b\"", serif</code>
simonp@8304 2638 <tr><td><code title>content: url('h)i') '\[\]'</code><td><code title>content: url("h)i") "[]"</code>
simonp@8304 2639 <tr><td><code title>azimuth: leftwards</code><td><code title>azimuth: leftwards</code>
simonp@8304 2640 <tr><td><code title>color: rgb(18, 52, 86)</code><td><code title>color: #123456</code>
simonp@8304 2641 <tr><td><code title>color: rgba(000001, 0, 0, 1)</code><td><code title>color: #000000</code>
simonp@8244 2642 </table>
simonp@8244 2643
simonp@8435 2644 <p class="issue">Some of these need to be updated per the new rules.</p>
simonp@8244 2645 </div>
simonp@8244 2646
simonp@8244 2647
simonp@8244 2648 <h2>DOM Access to CSS Declaration Blocks</h2>
simonp@8244 2649
simonp@8244 2650
simonp@8244 2651 <h3>The <code>ElementCSSInlineStyle</code> Interface</h3>
simonp@8226 2652
simonp@8226 2653 <p>The <code>ElementCSSInlineStyle</code> interface provides access to inline style properties of an element.</p>
simonp@8226 2654
simonp@8226 2655 <pre class=idl>[NoInterfaceObject]
simonp@8226 2656 interface <dfn>ElementCSSInlineStyle</dfn> {
simonp@8820 2657 [SameObject, PutForwards=<span title=dom-CSSStyleDeclaration-cssText>cssText</span>] readonly attribute <span>CSSStyleDeclaration</span> <!--
simonp@8484 2658 --><span title=dom-ElementCSSInlineStyle-style>style</span>;
simonp@8226 2659 };</pre>
simonp@8226 2660
simonp@8226 2661 <p>The <dfn title=dom-ElementCSSInlineStyle-style><code>style</code></dfn> attribute must return a <span>CSS declaration block</span> with the
simonp@8434 2662 <span title=concept-css-declaration-block-declarations>declarations</span> being set to the result of <span title='Parse a CSS declaration block'>parsing</span>
simonp@8807 2663 the <code title>style</code> content attribute, in <span title=concept-declarations-specified-order>specified order</span>. If the
simonp@8434 2664 <code title>style</code> content attribute is absent, the object represents an empty list of
simonp@8434 2665 declarations. Mutating the <code>CSSStyleDeclaration</code> object must set the
simonp@8226 2666 <code title>style</code> content attribute on the element to the
simonp@8226 2667 <span title='serialize a CSS declaration block'>serialization</span> of the
simonp@8305 2668 <code>CSSStyleDeclaration</code>'s <span title=concept-css-declaration-block-declarations>declarations</span>.
simonp@8820 2669 The object is live; if the
simonp@8327 2670 <code title>style</code> content attribute is set, changed or removed, the <span title=concept-css-declaration-block-declarations>declarations</span> must be
simonp@8327 2671 updated as appropriate.</p>
simonp@8226 2672
simonp@8371 2673 <p>If the user agent supports HTML, the following IDL applies: <span data-anolis-ref class=informative>HTML</span>
simonp@8371 2674
simonp@8371 2675 <pre class=idl><span data-anolis-spec=html>HTMLElement</span> implements <span>ElementCSSInlineStyle</span>;</pre>
simonp@8371 2676
simonp@8371 2677 <p>If the user agent supports SVG, the following IDL applies: <span data-anolis-ref class=informative>SVG</span>
simonp@8371 2678
simonp@8371 2679 <pre class=idl>SVGElement implements <span>ElementCSSInlineStyle</span>;</pre>
simonp@8226 2680
simonp@8226 2681
simonp@8244 2682 <h3>Extensions to the <code title>Window</code> Interface</h3>
simonp@8226 2683
simonp@8226 2684 <pre class=idl>partial interface <span data-anolis-spec=html>Window</span> {
simonp@8820 2685 [NewObject] <span>CSSStyleDeclaration</span> <!--
simonp@8820 2686 --><span title=dom-Window-getComputedStyle>getComputedStyle</span>(<span data-anolis-spec=dom>Element</span> elt, optional DOMString pseudoElt);
simonp@8226 2687 };</pre>
simonp@8226 2688
simonp@8406 2689 <p>The <dfn title=dom-Window-getComputedStyle><code>getComputedStyle(<var>elt</var>, <var>pseudoElt</var>)</code></dfn> method must run these
simonp@8304 2690 steps:</p>
simonp@8226 2691 <ol>
simonp@8406 2692 <li><p>Let <var>doc</var> be the
simonp@8226 2693 <code data-anolis-spec=dom>Document</code>
simonp@8226 2694 associated with the <code data-anolis-spec=html>Window</code> object on
simonp@8226 2695 which the method was invoked.</p></li>
simonp@8406 2696 <li><p>Let <var>obj</var> be <var>elt</var>.</p></li>
simonp@8406 2697 <li><p>If <var>pseudoElt</var> is as an
simonp@8226 2698 <span data-anolis-spec=dom>ASCII case-insensitive</span> match for
simonp@8346 2699 either ':before' or '::before' let
simonp@8406 2700 <var>obj</var> be the <span>::before pseudo-element</span> of
simonp@8406 2701 <var>elt</var>.</p></li>
simonp@8406 2702 <li><p>If <var>pseudoElt</var> is as an
simonp@8226 2703 <span data-anolis-spec=dom>ASCII case-insensitive</span> match for
simonp@8346 2704 either ':after' or '::after' let
simonp@8406 2705 <var>obj</var> be the <span>::after pseudo-element</span> of
simonp@8406 2706 <var>elt</var>.</p></li>
simonp@8226 2707 <li>
simonp@8822 2708 <p>Return a live <span>CSS declaration block</span> with the
simonp@8305 2709 <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> set and the
simonp@8590 2710 <span title=concept-css-declaration-block-declarations>declarations</span> set to all longhand properties
simonp@8592 2711 that are <span title="supported CSS property">supported CSS properties</span> with the value being the <span>resolved value</span>
simonp@8406 2712 computed for <var>obj</var> using the style rules associated
simonp@8406 2713 with <var>doc</var>.</p>
simonp@8406 2714 <p class='note'>This means that even if <var>obj</var> is in a
simonp@8304 2715 different document (e.g. one fetched via <code title>XMLHttpRequest</code>) it
simonp@8226 2716 will still use the style rules associated with the document that is
simonp@8226 2717 associated with the global object on which
simonp@8226 2718 <code title='dom-Window-getComputedStyle'>getComputedStyle()</code> was
simonp@8226 2719 invoked to compute the <span>CSS declaration block</span>.</p>
simonp@8226 2720 </li>
simonp@8226 2721 </ol>
simonp@8226 2722 <p class='note'>Because of historical IDL limitations the <code title=dom-Window-getComputedStyle>getComputedStyle()</code> method used to be on
simonp@8304 2723 a separate interface, <code title>ViewCSS</code>.</p>
simonp@8226 2724
simonp@8552 2725 <p class=warning>The <code title=dom-Window-getComputedStyle>getComputedStyle()</code> method exposes information from <span title="CSS style sheet">CSS style
simonp@8552 2726 sheets</span> with the <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> unset.
simonp@8226 2727
simonp@8244 2728 <h3>The <code title>GetStyleUtils</code> Interface</h3>
simonp@8226 2729
simonp@8406 2730 <p>The <dfn>associated document</dfn> of an object <var>obj</var> is <var>obj</var>'s <span data-anolis-spec=dom title=concept-node-document>node
simonp@8406 2731 document</span> if <var>obj</var> is an <code data-anolis-spec=dom>Element</code> object, or <var>obj</var>'s associated
simonp@8406 2732 <code data-anolis-spec=dom>Element</code> object's <span data-anolis-spec=dom title=concept-node-document>node document</span> if <var>obj</var> is a
simonp@8304 2733 <code>PseudoElement</code> object.</p>
simonp@8226 2734
simonp@8226 2735 <pre class=idl>[NoInterfaceObject]
simonp@8226 2736 interface <dfn>GetStyleUtils</dfn> {
simonp@8822 2737 [SameObject] readonly attribute <span>CSSStyleDeclaration</span> <span title=dom-GetStyleUtils-cascadedStyle>cascadedStyle</span>;
simonp@8822 2738 <!--[SameObject] readonly attribute <span>CSSStyleDeclaration</span> <span title=dom-GetStyleUtils-defaultStyle>defaultStyle</span>;
simonp@8822 2739 -->[SameObject] readonly attribute <span>CSSStyleDeclaration</span> <span title=dom-GetStyleUtils-rawComputedStyle>rawComputedStyle</span>;
simonp@8822 2740 [SameObject] readonly attribute <span>CSSStyleDeclaration</span> <span title=dom-GetStyleUtils-usedStyle>usedStyle</span>;
simonp@8226 2741 };</pre>
simonp@8226 2742
simonp@8822 2743 <p class=atrisk>The <dfn title=dom-GetStyleUtils-cascadedStyle><code>cascadedStyle</code></dfn> attribute must return a live <span>CSS declaration block</span>
simonp@8336 2744 with the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> set and the
simonp@8590 2745 <span title=concept-css-declaration-block-declarations>declarations</span> set to all longhand properties
simonp@8812 2746 that are <span title="supported CSS property">supported CSS properties</span> that have a <span>cascaded value</span> for the <span data-anolis-spec=dom>context
simonp@8812 2747 object</span>, with the value being the <span>cascaded value</span> computed for the <span data-anolis-spec=dom>context object</span> using the style rules
simonp@8812 2748 associated with the <span data-anolis-spec=dom>context object</span>'s <span>associated document</span>.</p>
simonp@8226 2749
simonp@8822 2750 <!--<p class=atrisk>The <dfn title=dom-GetStyleUtils-defaultStyle><code>defaultStyle</code></dfn> attribute must return a live <span>CSS declaration
simonp@8822 2751 block</span> with the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> set and the
simonp@8592 2752 <span title=concept-css-declaration-block-declarations>declarations</span> set to all longhand properties that are
simonp@8592 2753 <span title="supported CSS property">supported CSS properties</span> with the value being the
simonp@8590 2754 <span>computed value</span> computed for the <span data-anolis-spec=dom>context object</span> using the user-agent-level style rules and user-level style rules
simonp@8590 2755 associated with the <span data-anolis-spec=dom>context object</span>'s <span>associated document</span>, ignoring transitions, animations, author-level style
simonp@8810 2756 rules, author-level presentational hints and override-level style rules.</p>-->
simonp@8226 2757
simonp@8822 2758 <p class=atrisk>The <dfn title=dom-GetStyleUtils-rawComputedStyle><code>rawComputedStyle</code></dfn> attribute must return a live <span>CSS declaration
simonp@8820 2759 block</span> with the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> set and the
simonp@8590 2760 <span title=concept-css-declaration-block-declarations>declarations</span> set to all longhand properties
simonp@8592 2761 that are <span title="supported CSS property">supported CSS properties</span> with the value being the <span>computed value</span>
simonp@8226 2762 computed for the <span data-anolis-spec=dom>context object</span> using the style rules associated
simonp@8226 2763 with the <span data-anolis-spec=dom>context object</span>'s <span>associated document</span>.</p>
simonp@8226 2764
simonp@8822 2765 <p class=atrisk>The <dfn title=dom-GetStyleUtils-usedStyle><code>usedStyle</code></dfn> attribute must return a live <span>CSS declaration block</span> with the
simonp@8305 2766 <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> set and the
simonp@8590 2767 <span title=concept-css-declaration-block-declarations>declarations</span> set to all longhand properties
simonp@8592 2768 that are <span title="supported CSS property">supported CSS properties</span> with the value being the <span>used value</span>
simonp@8226 2769 computed for the <span data-anolis-spec=dom>context object</span> using the style rules associated
simonp@8226 2770 with the <span data-anolis-spec=dom>context object</span>'s <span>associated document</span>.</p>
simonp@8226 2771
simonp@8813 2772 <p class=warning>The <code title=dom-GetStyleUtils-cascadedStyle>cascadedStyle</code>, <code title=dom-GetStyleUtils-rawComputedStyle>rawComputedStyle</code>
simonp@8813 2773 and <code title=dom-GetStyleUtils-usedStyle>usedStyle</code> methods expose information from <span title="CSS style sheet">CSS style sheets</span> with the
simonp@8552 2774 <span title=concept-css-style-sheet-origin-clean-flag>origin-clean flag</span> unset.
simonp@8226 2775
simonp@8226 2776
simonp@8244 2777 <h3>Extensions to the <code title>Element</code> Interface</h3>
simonp@8226 2778
simonp@8226 2779 <pre class=idl>partial interface <span data-anolis-spec=dom>Element</span> {
simonp@8226 2780 <span>PseudoElement</span>? <span title=dom-Element-pseudo>pseudo</span>(DOMString pseudoElt);
simonp@8226 2781 };
simonp@8226 2782
simonp@8226 2783 <span data-anolis-spec=dom>Element</span> implements <span>GetStyleUtils</span>;</pre>
simonp@8226 2784
simonp@8406 2785 <p class=atrisk>The <dfn title=dom-Element-pseudo><code>pseudo(<var>pseudoElt</var>)</code></dfn> method, when invoked, must run the following steps:
simonp@8226 2786 <ol>
simonp@8406 2787 <li><p>If <var>pseudoElt</var> is as an <span data-anolis-spec=dom>ASCII case-insensitive</span> match for either ':before' or
simonp@8346 2788 '::before' return the <code>PseudoElement</code> representing the <span>::before pseudo-element</span> of the
simonp@8329 2789 <span data-anolis-spec=dom>context object</span>.</p></li>
simonp@8406 2790 <li><p>If <var>pseudoElt</var> is as an <span data-anolis-spec=dom>ASCII case-insensitive</span> match for either ':after' or
simonp@8346 2791 '::after' return the <code>PseudoElement</code> representing the <span>::after pseudo-element</span> of the
simonp@8329 2792 <span data-anolis-spec=dom>context object</span>.</p></li>
simonp@8226 2793 <li><p>Return null.</p></li>
simonp@8226 2794 </ol>
simonp@8226 2795 <p>When invoked with an argument that returns a <code>PseudoElement</code> object representing a particular pseudo-element, the same object must be
simonp@8226 2796 returned as returned by an earlier call that represent the same pseudo-element.</p>
simonp@8226 2797
simonp@8226 2798
simonp@8226 2799
simonp@8244 2800 <h3>The <code title>PseudoElement</code> Interface</h3>
simonp@8226 2801
simonp@8336 2802 <p class=atrisk>The <code>PseudoElement</code> interface is used for representing CSS pseudo-elements. A <code>PseudoElement</code> object is associated with an
simonp@8304 2803 <code data-anolis-spec=dom>Element</code> object.</p>
simonp@8226 2804
simonp@8226 2805 <pre class=idl>interface <dfn>PseudoElement</dfn> {
simonp@8226 2806 };
simonp@8226 2807
simonp@8226 2808 <span>PseudoElement</span> implements <span>GetStyleUtils</span>;</pre>
simonp@8226 2809
simonp@8226 2810
simonp@8244 2811 <h2>Resolved Values</h2>
simonp@8244 2812
simonp@8244 2813 <p><code title="dom-Window-getComputedStyle">getComputedStyle()</code> was
simonp@8244 2814 historically defined to return the "computed value" of an element or
simonp@8244 2815 pseudo-element. However, the concept of "computed value" changed between
simonp@8244 2816 revisions of CSS while the implementation of
simonp@8244 2817 <code title="dom-Window-getComputedStyle">getComputedStyle()</code> had to
simonp@8244 2818 remain the same for compatibility with deployed scripts. To address this
simonp@8244 2819 issue this specification introduces the concept of a
simonp@8244 2820 <dfn>resolved value</dfn>.</p>
simonp@8244 2821
simonp@8244 2822 <p>The <span>resolved value</span> for a given property can be determined
simonp@8244 2823 as follows:</p>
simonp@8244 2824
simonp@8244 2825 <dl class="switch">
simonp@8244 2826 <!--
simonp@8244 2827 We want to treat shorthand properties like any other value basically.
simonp@8244 2828
simonp@8346 2829 <dt>'background'
simonp@8346 2830 <dt>'border'
simonp@8346 2831 <dt>'border-collapse'
simonp@8346 2832 <dt>'border-color'
simonp@8346 2833 <dt>'border-spacing'
simonp@8346 2834 <dt>'border-style'
simonp@8346 2835 <dt>'border-top'
simonp@8346 2836 <dt>'border-right'
simonp@8346 2837 <dt>'border-bottom'
simonp@8346 2838 <dt>'border-left'
simonp@8346 2839 <dt>'border-width'
simonp@8346 2840 <dt>'font'
simonp@8346 2841 <dt>'list-style'
simonp@8346 2842 <dt>'margin'
simonp@8346 2843 <dt>'outline'
simonp@8244 2844 <!- - overflow is not - ->
simonp@8346 2845 <dt>'padding'
simonp@8346 2846 <dt>'pause'
simonp@8244 2847 <dd>
simonp@8244 2848 <p>There is no <span>resolved value</span>.</p>
simonp@8244 2849 </dd>
simonp@8244 2850 -->
simonp@8244 2851
simonp@8346 2852 <dt>'line-height'</dt>
simonp@8327 2853 <dd><p>The <span>resolved value</span> is the <span>used value</span>.</p></dd>
simonp@8244 2854
simonp@8346 2855 <dt>'height'</dt>
simonp@8346 2856 <dt>'margin'</dt>
simonp@8346 2857 <dt>'margin-bottom'</dt>
simonp@8346 2858 <dt>'margin-left'</dt>
simonp@8346 2859 <dt>'margin-right'</dt>
simonp@8346 2860 <dt>'margin-top'</dt>
simonp@8346 2861 <dt>'padding'</dt>
simonp@8346 2862 <dt>'padding-bottom'</dt>
simonp@8346 2863 <dt>'padding-left'</dt>
simonp@8346 2864 <dt>'padding-right'</dt>
simonp@8346 2865 <dt>'padding-top'</dt>
simonp@8346 2866 <dt>'width'</dt>
simonp@8244 2867 <dd><p>If the property applies to the element or pseudo-element and the
simonp@8346 2868 <span>resolved value</span> of the 'display' property is not
simonp@8346 2869 'none', the <span>resolved value</span> is the
simonp@8244 2870 <span>used value</span>. Otherwise the <span>resolved value</span> is the
simonp@8327 2871 <span>computed value</span>.</p></dd>
simonp@8244 2872
simonp@8346 2873 <dt>'bottom'</dt>
simonp@8346 2874 <dt>'left'</dt>
simonp@8346 2875 <dt>'right'</dt>
simonp@8346 2876 <dt>'top'</dt>
simonp@8244 2877 <dd><p>If the property applies to a positioned element and the
simonp@8346 2878 <span>resolved value</span> of the 'display' property is not
simonp@8346 2879 'none', the <span>resolved value</span> is the
simonp@8244 2880 <span>used value</span>. Otherwise the <span>resolved value</span> is the
simonp@8244 2881 computed value.</p></dd>
simonp@8244 2882
simonp@8244 2883 <dt>Any other property</dt>
simonp@8327 2884 <dd><p>The <span>resolved value</span> is the <span>computed value</span>.</p></dd>
simonp@8244 2885 </dl>
simonp@8244 2886
simonp@8244 2887
simonp@8244 2888 <h2>IANA Considerations</h2>
simonp@8244 2889
simonp@8244 2890
simonp@8406 2891 <h3><dfn title="http-default-style"><code title>Default-Style</code></dfn></h3>
simonp@8244 2892
simonp@8244 2893 <p>This section describes a header field for registration in the Permanent
simonp@8244 2894 Message Header Field Registry.
simonp@8435 2895 <!--<a href="issue">[RFC3864]</a>--></p>
simonp@8244 2896
simonp@8244 2897 <dl>
simonp@8244 2898 <dt>Header field name</dt>
simonp@8244 2899 <dd>Default-Style</dd>
simonp@8244 2900 <dt>Applicable protocol</dt>
simonp@8244 2901 <dd>http</dd>
simonp@8244 2902 <dt>Status</dt>
simonp@8244 2903 <dd>standard</dd>
simonp@8244 2904 <dt>Author/Change controller</dt>
simonp@8244 2905 <dd>W3C</dd>
simonp@8244 2906 <dt>Specification document(s)</dt>
simonp@8244 2907 <dd>This document is the relevant specification.</dd>
simonp@8244 2908 <dt>Related information</dt>
simonp@8244 2909 <dd>None.</dd>
simonp@8244 2910 </dl>
simonp@8244 2911
simonp@8244 2912
simonp@8244 2913 <h2 class=no-num>References</h2>
simonp@8244 2914
simonp@8244 2915 <div id=anolis-references></div>
simonp@8244 2916
simonp@8244 2917
simonp@8244 2918 <h2 class="no-num">Change History</h2>
simonp@8244 2919
simonp@8244 2920 <p>This section documents the primary technical changes of CSSOM related functionality, with a focus on changes to API signatures.</p>
simonp@8244 2921
simonp@8244 2922 <h3 class="no-num">Changes From DOM-2 Style</h3>
simonp@8244 2923
simonp@8244 2924 <ul>
simonp@8304 2925 <li><p>Remove definition of <code title>CSSRule.UNKNOWN_RULE</code>, reserving its value (0) to prevent future reuse.</p></li>
simonp@8304 2926 <li><p>Remove definition of <code title>DOMImplementationCSS</code> interface.</p></li>
simonp@8244 2927 </ul>
simonp@8244 2928
simonp@8244 2929
simonp@8244 2930 <h2 class="no-num">Acknowledgments</h2>
simonp@8244 2931
simonp@8244 2932 <p>The editors would like to thank
simonp@8244 2933
simonp@8244 2934 Alexey Feldgendler,
simonp@8244 2935 Bj&ouml;rn H&ouml;hrmann,
simonp@8244 2936 Boris Zbasky,
simonp@8244 2937 Brian Kardell,
simonp@8244 2938 Christian Krebs,
simonp@8244 2939 Daniel Glazman,
simonp@8244 2940 David Baron,
simonp@8244 2941 <i>fantasai</i>,
simonp@8244 2942 Hallvord R. M. Steen,
simonp@8244 2943 Ian Hickson,
simonp@8244 2944 John Daggett,
simonp@8244 2945 Lachlan Hunt,
simonp@8810 2946 Mike Sherov,
simonp@8244 2947 Morten Stenshorne,
simonp@8596 2948 Øyvind Stenhaug,
simonp@8870 2949 Peter Sloetjes,
simonp@8244 2950 Philip Taylor,
simonp@8244 2951 Robert O'Callahan,
simonp@8807 2952 Simon Sapin,
simonp@8244 2953 Sjoerd Visscher,
simonp@8244 2954 <!--Simon Pieters,-->
simonp@8244 2955 Sylvain Galineau,
simonp@8244 2956 Tarquin Wilton-Jones, and
simonp@8244 2957 Zack Weinberg
simonp@8244 2958
simonp@8244 2959 for contributing to this specification.</p>
simonp@8244 2960
simonp@8244 2961 <p>Additional thanks to Ian Hickson for writing the
simonp@8244 2962 initial version of the alternative style sheets API and canonicalization
simonp@8244 2963 (now serialization) rules for CSS values.</p>
simonp@8244 2964
simonp@8244 2965 <!-- XXX NOTES
simonp@8244 2966
simonp@8244 2967 <style type=text/css;charset=utf-8> does create a StyleSheet in Firefox
simonp@8244 2968 and Opera, but does not create a StyleSheet in IE. I prefer IE.
simonp@8244 2969
simonp@8244 2970 <style type=TEXT/CSS> sets the style sheet type to text/css in Firefox and
simonp@8244 2971 TEXT/CSS in Opera and IE. I prefer Firefox.
simonp@8244 2972
simonp@8244 2973 <style> sets the style sheet location to the document location Firefox,
simonp@8244 2974 the empty string in IE, and null in Opera. I prefer Opera
simonp@8244 2975
simonp@8244 2976 <style media="x"> invokes .sheet.media.mediaText = "x"
simonp@8244 2977
simonp@8244 2978 <style> does not "have" a title
simonp@8244 2979
simonp@8244 2980 .cascadedStyle that returns less keywords than currentStyle, no inherit,
simonp@8244 2981 etc.
simonp@8244 2982
simonp@8244 2983 Markup style: http://krijnhoetmer.nl/irc-logs/whatwg/20100204#l-529
simonp@8244 2984 -->
simonp@8226 2985 </body>
simonp@8226 2986 </html>
simonp@8226 2987

mercurial