|
16 | 16 | <h1>CSS Object Model (CSSOM)</h1> |
17 | 17 |
|
18 | 18 |
|
19 | | - <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 28 June 2013</h2> |
| 19 | + <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 9 August 2013</h2> |
20 | 20 |
|
21 | 21 | <dl> |
22 | 22 |
|
@@ -90,7 +90,7 @@ <h2 class="no-num no-toc" id="sotd">Status of This Document</h2> |
90 | 90 | can be found in the |
91 | 91 | <a href="http://www.w3.org/TR/">W3C technical reports index at http://www.w3.org/TR/.</a></em> |
92 | 92 |
|
93 | | -<p class="dontpublish">This is the 28 June 2013 Editor's Draft of CSSOM. Please send comments to |
| 93 | +<p class="dontpublish">This is the 9 August 2013 Editor's Draft of CSSOM. Please send comments to |
94 | 94 | <a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a> |
95 | 95 | (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) |
96 | 96 | with <samp>[cssom]</samp> at the start of the subject line. |
@@ -1960,7 +1960,9 @@ <h4 id="the-cssstylerule-interface"><span class="secno">6.4.3 </span>The <code t |
1960 | 1960 |
|
1961 | 1961 | <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 |
1962 | 1962 | <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a> being the declared declarations in the rule, in the same order as they were |
1963 | | -specified, with shorthand properties expanded into their longhand properties, in canonical order.</p> |
| 1963 | +specified, with shorthand properties expanded into their longhand properties, in canonical order. If a property is specified more than once, it must be |
| 1964 | +represented as one item in the <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a> at the position of the last declaration for that |
| 1965 | +property.</p> |
1964 | 1966 |
|
1965 | 1967 |
|
1966 | 1968 | <h4 id="the-csscharsetrule-interface"><span class="secno">6.4.4 </span>The <code title="">CSSCharsetRule</code> Interface</h4> |
@@ -2117,45 +2119,77 @@ <h3 id="css-declaration-blocks"><span class="secno">6.5 </span>CSS Declaration B |
2117 | 2119 | <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 |
2118 | 2120 | <var>string</var> and return the value returned.</p> |
2119 | 2121 |
|
2120 | | -<p>To <dfn id="serialize-a-css-declaration-block">serialize a CSS declaration block</dfn> |
2121 | | -represented by a <code><a href="#cssstyledeclaration">CSSStyleDeclaration</a></code> instance named <var>d</var>, |
2122 | | -let <var>s</var> be the empty string, then run the steps below:</p> |
| 2122 | +<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 |
| 2123 | +these steps: |
2123 | 2124 |
|
2124 | 2125 | <ol> |
2125 | | - <li><p>If <code title=""><var>d</var>.length</code> is zero (0), then return <var>s</var>.</li> |
2126 | | - <li><p>For each <var>i</var> from zero (0) through <code title=""><var>d</var>.length</code> - 1 (inclusive), perform the following sub-steps:</p> |
2127 | | - <ol> |
2128 | | - <li><p>Let <var>n</var> be the value returned by <code title=""><var>d</var>.item(<var>i</var>)</code>.</li> |
2129 | | - <li><p>Let <var>v</var> be the value returned by <code title=""><var>d</var>.getPropertyValue(<var>n</var>)</code>.</li> |
2130 | | - <li><p>If <var>v</var> is the empty string, then continue.</li> |
2131 | | - <li> |
2132 | | - <p>Otherwise (<var>v</var> is non-empty), perform the following sub-steps:</p> |
2133 | | - <ol> |
2134 | | - <li><p>If <var>s</var> is not empty, then append a single SPACE (U+0020) to <var>s</var>.</li> |
2135 | | - <li><p>Append <var>n</var> to <var>s</var>.</li> |
2136 | | - <li><p>Append COLON (U+003A) followed by a single SPACE (U+0020), i.e., "<code title="">: </code>", to <var>s</var>.</li> |
2137 | | - <li><p>Append <var>v</var> to <var>s</var>.</li> |
2138 | | - </ol> |
2139 | | - </li> |
2140 | | - <li><p>Let <var>p</var> be the value returned by <code title=""><var>d</var>.getPropertyPriority(<var>n</var>)</code>.</li> |
2141 | | - <li> |
2142 | | - <p>If <var>p</var> is not the empty string, then perform the following sub-steps:</p> |
| 2126 | + <li><p>Let <var>s</var> be the empty string. |
| 2127 | + <li><p>Append <var>property</var> to <var>s</var>. |
| 2128 | + <li><p>Append "<code title="">: </code>" (U+003A U+0020) to <var>s</var>. |
| 2129 | + <li><p>Append <var>value</var> to <var>s</var>. |
| 2130 | + <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 |
| 2131 | + U+0074) to <var>s</var>. |
| 2132 | + <li><p>Append "<code title="">;</code>" (U+003B) to <var>s</var>. |
| 2133 | + <li><p>Return <var>s</var>. |
| 2134 | +</ol> |
| 2135 | + |
| 2136 | +<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> |
| 2137 | + |
| 2138 | +<ol> |
| 2139 | + <li><p>Let <var>list</var> be an empty array. |
| 2140 | + <li><p>Let <var>already serialized</var> be an empty array. |
| 2141 | + <li><p><i>Declaration loop</i>: For each declaration <var>declaration</var> in <var>declaration block</var>'s |
| 2142 | + <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>, follow these substeps: |
| 2143 | + <ol> |
| 2144 | + <li><p>Let <var>property</var> be <var>declaration</var>'s property name. |
| 2145 | + <li><p>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>. |
| 2146 | + <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 |
| 2147 | + <a href="#concept-shorthands-preferred-order" title="concept-shorthands-preferred-order">preferred order</a>, and follow these substeps: |
2143 | 2148 | <ol> |
2144 | | - <li><p>Append a single SPACE (U+0020) followed by EXCLAMATION MARK (U+0021), i.e., "<code title=""> !</code>", to <var>s</var>.</li> |
2145 | | - <li><p>Append <var>p</var> to <var>s</var>.</li> |
| 2149 | + <li><p>Let <var>longhands</var> an array consisting of all declarations in <var>declaration block</var>'s |
| 2150 | + <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 |
| 2151 | + maps to one of the shorthand properties in <var>shorthands</var>. |
| 2152 | + <li><p><i>Shorthand loop</i>: For each <var>shorthand</var> in <var>shorthands</var>, follow these substeps: |
| 2153 | + <ol> |
| 2154 | + <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>. |
| 2155 | + <li><p>Let <var>current longhands</var> be an empty array. |
| 2156 | + <li><p>Append all declarations in <var>longhands</var> have a property name that maps to <var>shorthand</var> to <var>current longhands</var>. |
| 2157 | + <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 |
| 2158 | + the steps labeled <i>shorthand loop</i>. |
| 2159 | + <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>. |
| 2160 | + <li><p>If <var>value</var> is the empty string, continue with the steps labeled <i>shorthand loop</i>. |
| 2161 | + <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 |
| 2162 | + <var>shorthand</var>, value <var>value</var>, and the <i>important</i> flag set if the declarations in <var>current longhands</var> have their |
| 2163 | + <i>important</i> flag set. |
| 2164 | + <li><p>Append <var>serialized declaration</var> to <var>list</var>. |
| 2165 | + <li><p>Append the property names of all items of <var>current longhands</var> to <var>already serialized</var>. |
| 2166 | + <li><p>Remove the items present in <var>current longhands</var> from <var>longhands</var>. |
| 2167 | + </ol> |
2146 | 2168 | </ol> |
2147 | | - </li> |
2148 | | - <li><p>Append SEMICOLON (U+003B), i.e., "<code title="">;</code>", to <var>s</var>.</li> |
2149 | | - </ol> |
2150 | | - </li> |
2151 | | - <li><p>Return <var>s</var>.</li> |
| 2169 | + <li><p>If <var>property</var> is in <var>already serialized</var>, continue with the steps labeled <i>declaration loop</i>. |
| 2170 | + <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>. |
| 2171 | + <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 |
| 2172 | + <var>value</var>, and the <i>important</i> flag set if <var>declaration</var> has its <i>important</i> flag set. |
| 2173 | + <li><p>Append <var>serialized declaration</var> to <var>list</var>. |
| 2174 | + <li><p>Append <var>property</var> to <var>already serialized</var>. |
| 2175 | + </ol> |
| 2176 | + <li><p>Return <var>list</var> joined with "<code title=""> </code>" (U+0020). |
2152 | 2177 | </ol> |
2153 | 2178 |
|
2154 | 2179 | <p class="note">The serialization of an empty CSS declaration block is the empty string.</p> |
2155 | 2180 |
|
2156 | 2181 | <p class="note">The serialization of a non-empty CSS declaration block does not include any surrounding whitespace, i.e., no whitepsace appears |
2157 | 2182 | before the first property name and no whitespace appears after the final semicolon delimiter that follows the last property value.</p> |
2158 | 2183 |
|
| 2184 | +<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: |
| 2185 | + |
| 2186 | +<ol> |
| 2187 | + <li><p>Order <var>shorthands</var> lexicographically. |
| 2188 | + <li><p>Move all items in <var>shorthands</var> that begin with "<code title="">-</code>" (U+002D) last in the list. |
| 2189 | + <li><p>Move all items in <var>shorthands</var> that begin with "<code title="">-</code>" (U+002D) but do no begin with "<code title="">-webkit-</code>" last in the |
| 2190 | + list. |
| 2191 | + <li><p>Order <var>shorthands</var> by the number of longhand properties that map to it, with the greatest number first. |
| 2192 | +</ol> |
2159 | 2193 |
|
2160 | 2194 | <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.5.1 </span>The <code title="">CSSStyleDeclaration</code> Interface</h4> |
2161 | 2195 |
|
@@ -2198,7 +2232,8 @@ <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.5.1 </span>The |
2198 | 2232 | <li><p>Empty the <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>.</li> |
2199 | 2233 | <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 |
2200 | 2234 | into the <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>, in the same order as they were specified, with shorthand properties |
2201 | | - expanded into their longhand properties, in canonical order.</li> |
| 2235 | + expanded into their longhand properties, in canonical order. If a property is specified more than once, it must be represented as one item in the |
| 2236 | + <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a> at the position of the last declaration for that property.</li> |
2202 | 2237 | </ol> |
2203 | 2238 |
|
2204 | 2239 | <p>The <dfn id="dom-cssstyledeclaration-length" title="dom-CSSStyleDeclaration-length"><code>length</code></dfn> attribute must return the number of declarations in the |
@@ -2439,7 +2474,8 @@ <h4 id="serializing-css-values"><span class="secno">6.6.2 </span>Serializing CSS |
2439 | 2474 | <ol> |
2440 | 2475 | <li><p>If this algorithm is invoked with a list <var>list</var>, follow these substeps: |
2441 | 2476 | <ol> |
2442 | | - <li><p>Let <var>shorthand</var> be the shorthand property that exactly maps to all the longhand properties in <var>list</var>. |
| 2477 | + <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 |
| 2478 | + shorthand properties, use the first in <a href="#concept-shorthands-preferred-order" title="concept-shorthands-preferred-order">preferred order</a>. |
2443 | 2479 | <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. |
2444 | 2480 | <li><p>Let <var>trimmed list</var> be a new empty array. |
2445 | 2481 | <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 |
@@ -2696,7 +2732,8 @@ <h3 id="the-elementcssinlinestyle-interface"><span class="secno">7.1 </span>The |
2696 | 2732 | <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 |
2697 | 2733 | <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> |
2698 | 2734 | the <code title="">style</code> content attribute, in the same order as specified, with shorthand properties expanded to their longhand properties, in canonical |
2699 | | -order. If the |
| 2735 | +order. If a property is specified more than once, it must be represented as one item in the |
| 2736 | +<a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a> at the position of the last declaration for that property. If the |
2700 | 2737 | <code title="">style</code> content attribute is absent, the object represents an empty list of |
2701 | 2738 | declarations. Mutating the <code><a href="#cssstyledeclaration">CSSStyleDeclaration</a></code> object must set the |
2702 | 2739 | <code title="">style</code> content attribute on the element to the |
|
0 commit comments