cssom/Overview.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>

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

mercurial