Fri, 28 Jun 2013 13:55:45 +0200
[cssom] Handle shorthands in setProperty and getPropertyValue. Serialization still needs fixing though.
cssom/Overview.html | file | annotate | diff | comparison | revisions | |
cssom/Overview.src.html | file | annotate | diff | comparison | revisions |
1.1 --- a/cssom/Overview.html Fri Jun 28 11:18:48 2013 +0200 1.2 +++ b/cssom/Overview.html Fri Jun 28 13:55:45 2013 +0200 1.3 @@ -2246,7 +2246,6 @@ 1.4 <p>The <dfn id="dom-cssstyledeclaration-setproperty" title="dom-CSSStyleDeclaration-setProperty"><code>setProperty(<var>property</var>, <var>value</var>, 1.5 <var>priority</var>)</code></dfn> method must run these steps:</p> 1.6 <ol> 1.7 - <!-- XXX handle shorthands better --> 1.8 <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> 1.9 an <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#nomodificationallowederror">NoModificationAllowedError</a></code> exception and terminate these steps.</li> 1.10 <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>. 1.11 @@ -2257,11 +2256,29 @@ 1.12 <li><p>If <var>priority</var> is neither an <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for the string "<code title="">important</code>" 1.13 nor the empty string terminate this algorithm.</li> 1.14 <li> 1.15 - <p>If <a href="#parse-a-css-value" title="parse a CSS value">parsing</a> <var>value</var> returns null terminate this algorithm. 1.16 - <p class="note"><var>value</var> can not include "<code title="">!important</code>".</p> 1.17 + <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>. 1.18 + <p class="note"><var>value</var> can not include "<code title="">!important</code>".</p> 1.19 </li> 1.20 - <li><p>Finally, set <var>property</var> to <var>value</var> with the <i>important</i> flag set if <var>priority</var> is not the empty 1.21 - string, and unset otherwise.</li> 1.22 + <li><p>If <var>component value list</var> is null terminate these steps. 1.23 + <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 1.24 + 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 1.25 + the <var>important</var> flag set if <var>priority</var> is not the empty string, and with the list of declarations being the 1.26 + <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>. 1.27 + <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 1.28 + the <var>important</var> flag set if <var>priority</var> is not the empty string, and with the list of declarations being the 1.29 + <a href="#concept-css-declaration-block-declarations" title="concept-css-declaration-block-declarations">declarations</a>. 1.30 +</ol> 1.31 + 1.32 +<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 optionally with an <var>important</var> flag set, in a 1.33 +list of declarations <var>declarations</var>, follow these steps: 1.34 + 1.35 +<ol> 1.36 + <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 1.37 + <var>declarations</var>, let <var>declaration</var> be that declaration. 1.38 + <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 1.39 + declaration. 1.40 + <li><p>Set <var>declaration</var>'s value to <var>component value list</var>. 1.41 + <li><p>Set the declaration's <i>important</i> flag if <var>important</var> is set, or unset it otherwise. 1.42 </ol> 1.43 1.44 <p>The <dfn id="dom-cssstyledeclaration-removeproperty" title="dom-CSSStyleDeclaration-removeProperty"><code>removeProperty(<var>property</var>)</code></dfn> method must run these steps:</p>
2.1 --- a/cssom/Overview.src.html Fri Jun 28 11:18:48 2013 +0200 2.2 +++ b/cssom/Overview.src.html Fri Jun 28 13:55:45 2013 +0200 2.3 @@ -2131,13 +2131,23 @@ 2.4 2.5 <p>The <dfn title=dom-CSSStyleDeclaration-getPropertyValue><code>getPropertyValue(<var>property</var>)</code></dfn> method must run these steps:</p> 2.6 <ol> 2.7 - <!-- XXX handle shorthands better --> 2.8 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>. 2.9 + <li><p>If <var>property</var> is a shorthand property, then follow these substeps: 2.10 + <ol> 2.11 + <li><p>Let <var>list</var> be a new empty array. 2.12 + <li><p>For each longhand property <var>longhand</var> that <var>property</var> maps to, in canonical order, follow these substeps: 2.13 + <ol> 2.14 + <li><p>If <var>longhand</var> is a <span data-anolis-spec=dom>case-sensitive</span> match for a property of a declaration in the 2.15 + <span title=concept-css-declaration-block-declarations>declarations</span>, let <var>declaration</var> be that declaration, or null otherwise. 2.16 + <li><p>If <var>declaration</var> is null, return the empty string and terminate these steps. 2.17 + <li><p>Append the <var>declaration</var> to <var>list</var>. 2.18 + </ol> 2.19 + <li><p>Return the <span title='serialize a CSS value'>serialization</span> of <var>list</var> and terminate these steps. 2.20 + </ol> 2.21 <li><p>If <var>property</var> is a <span data-anolis-spec=dom>case-sensitive</span> 2.22 match for a property of a declaration in the 2.23 - <span title=concept-css-declaration-block-declarations>declarations</span>, return the 2.24 - <span title='serialize a CSS value'>serialization</span> of that declaration's 2.25 - value. 2.26 + <span title=concept-css-declaration-block-declarations>declarations</span>, return the result of invoking 2.27 + <span>serialize a CSS value</span> of that declaration and terminate these steps. 2.28 <li><p>Return the empty string. 2.29 </ol> 2.30 2.31 @@ -2168,7 +2178,6 @@ 2.32 <p>The <dfn title=dom-CSSStyleDeclaration-setProperty><code>setProperty(<var>property</var>, <var>value</var>, 2.33 <var>priority</var>)</code></dfn> method must run these steps:</p> 2.34 <ol> 2.35 - <!-- XXX handle shorthands better --> 2.36 <li><p>If the <span title=concept-css-declaration-block-readonly-flag>readonly flag</span> is set, <span data-anolis-spec=dom title=concept-throw>throw</span> 2.37 an <code data-anolis-spec=dom>NoModificationAllowedError</code> exception and terminate these steps.</li> 2.38 <li><p>Let <var>property</var> be <var>property</var> <span data-anolis-spec=dom>converted to ASCII lowercase</span>. 2.39 @@ -2179,11 +2188,29 @@ 2.40 <li><p>If <var>priority</var> is neither an <span data-anolis-spec=dom>ASCII case-insensitive</span> match for the string "<code title>important</code>" 2.41 nor the empty string terminate this algorithm.</p></li> 2.42 <li> 2.43 - <p>If <span title='parse a CSS value'>parsing</span> <var>value</var> returns null terminate this algorithm. 2.44 - <p class='note'><var>value</var> can not include "<code title>!important</code>".</p> 2.45 + <p>Let <var>component value list</var> be the result of <span title='parse a CSS value'>parsing</span> <var>value</var>. 2.46 + <p class='note'><var>value</var> can not include "<code title>!important</code>".</p> 2.47 </li> 2.48 - <li><p>Finally, set <var>property</var> to <var>value</var> with the <i>important</i> flag set if <var>priority</var> is not the empty 2.49 - string, and unset otherwise.</p></li> 2.50 + <li><p>If <var>component value list</var> is null terminate these steps. 2.51 + <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 2.52 + order, <span title="set a CSS property">set the CSS property</span> <var>longhand</var> to the appropriate value(s) from <var>component value list</var>, with 2.53 + the <var>important</var> flag set if <var>priority</var> is not the empty string, and with the list of declarations being the 2.54 + <span title=concept-css-declaration-block-declarations>declarations</span>. 2.55 + <li><p>Otherwise, <span title="set a CSS property">set the CSS property</span> <var>property</var> to <var>component value list</var>, with 2.56 + the <var>important</var> flag set if <var>priority</var> is not the empty string, and with the list of declarations being the 2.57 + <span title=concept-css-declaration-block-declarations>declarations</span>. 2.58 +</ol> 2.59 + 2.60 +<p>To <dfn>set a CSS property</dfn> <var>property</var> to a value <var>component value list</var> and optionally with an <var>important</var> flag set, in a 2.61 +list of declarations <var>declarations</var>, follow these steps: 2.62 + 2.63 +<ol> 2.64 + <li><p>If <var>property</var> is a <span data-anolis-spec=dom>case-sensitive</span> match for a property of a declaration in 2.65 + <var>declarations</var>, let <var>declaration</var> be that declaration. 2.66 + <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 2.67 + declaration. 2.68 + <li><p>Set <var>declaration</var>'s value to <var>component value list</var>. 2.69 + <li><p>Set the declaration's <i>important</i> flag if <var>important</var> is set, or unset it otherwise. 2.70 </ol> 2.71 2.72 <p>The <dfn title=dom-CSSStyleDeclaration-removeProperty><code>removeProperty(<var>property</var>)</code></dfn> method must run these steps:</p> 2.73 @@ -2328,12 +2355,14 @@ 2.74 2.75 <!-- based on http://damowmow.com/playground/canon.txt --> 2.76 2.77 -<p>To <dfn>serialize a CSS value</dfn> follow 2.78 +<p>To <dfn>serialize a CSS value</dfn> of a declaration <var>declaration</var> or a list of longhand declarations <var>list</var>, follow 2.79 these rules:</p> 2.80 2.81 <ul> 2.82 - <li><p><span title="Serialize a CSS component value">Serialize</span> any 2.83 - CSS component values in the value.</p></li> 2.84 + <li><p>If this algorithm is invoked with a list <var>list</var>, <span title class=issue>...</span> 2.85 + 2.86 + <li><p><span title="Serialize a CSS component value">Serialize</span> the 2.87 + CSS component values in <var>declaration</var>'s value.</p></li> 2.88 2.89 <li><p>Where multiple CSS component values can appear in any order 2.90 without changing the meaning of the value (typically represented by a