Skip to content

Commit 1eb2b13

Browse files
author
Simon Pieters
committed
[cssom] Expose all supported CSS properties as IDL attributes on CSSStyleDeclaration
1 parent aa1d707 commit 1eb2b13

3 files changed

Lines changed: 126 additions & 6 deletions

File tree

cssom/Overview.html

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ <h1 id="cssom">CSS Object Model (CSSOM)</h1>
1818

1919
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
2020

21-
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 15 April 2013</h2>
21+
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 16 April 2013</h2>
2222

2323
<dl>
2424

@@ -83,7 +83,7 @@ <h2 class="no-num no-toc" id="sotd">Status of this Document</h2>
8383
can be found in the
8484
<a href="http://www.w3.org/TR/">W3C technical reports index at http://www.w3.org/TR/.</a></em>
8585

86-
<p class="dontpublish">This is the 15 April 2013 Editor's Draft of CSSOM. Please send comments to
86+
<p class="dontpublish">This is the 16 April 2013 Editor's Draft of CSSOM. Please send comments to
8787
<a href="mailto:www-style@w3.org?subject=%5Bcssom%5D%20">www-style@w3.org</a>
8888
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
8989
with <samp>[cssom]</samp> at the start of the subject line.
@@ -1978,7 +1978,66 @@ <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.5.1 </span>The
19781978
<p>The <code>removeProperty</code> operation must run these steps:</p> <ol> <li><p>If the <a href="#css-declaration-block-readonly-flag">CSS declaration block readonly flag</a> is set, <a class="external" href="http://dom.spec.whatwg.org/#concept-throw" title="concept-throw">throw</a> a '<code class="external"><a href="http://dom.spec.whatwg.org/#nomodificationallowederror">NoModificationAllowedError</a></code>' and terminate these steps.</li> <li><p>If <var>property</var> is an <a class="external" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for a property of a declaration in the <span>collection of CSS declarations</span> remove the declaration.</li> </ol></dd>
19791979
</dl>
19801980

1981+
1982+
<p>For each CSS property <var>property</var> that the user agent supports, the following
1983+
partial interface applies where <var>attribute</var> is obtained by running the
1984+
<a href="#css-property-to-idl-attribute">CSS property to IDL attribute</a> algorithm for <var>property</var>.
1985+
1986+
<pre class="idl">partial interface CSSStyleDeclaration {
1987+
attribute DOMString <var>attribute</var>;
1988+
};</pre>
1989+
1990+
<p>Getting the <var>attribute</var> attribute must return the result of invoking
1991+
<code title="dom-CSSStyleDeclaration-getPropertyValue">getPropertyValue()</code> with as
1992+
argument the result of running the <a href="#idl-attribute-to-css-property">IDL attribute to CSS property</a>
1993+
algorithm for <var>attribute</var>.</p>
1994+
1995+
<p>Setting the <var>attribute</var> attribute must invoke
1996+
<code title="dom-CSSStyleDeclaration-setPropertyValue">setPropertyValue()</code> with as
1997+
first argument the result of running the <a href="#idl-attribute-to-css-property">IDL attribute to CSS property</a>
1998+
algorithm for <var>attribute</var>, as second argument the given value, and no third argument. Any
1999+
exceptions thrown must be re-thrown.</p>
2000+
2001+
<p>The <dfn id="css-property-to-idl-attribute">CSS property to IDL attribute</dfn> algorithm for <var>property</var> is as
2002+
follows:</p>
2003+
2004+
<ol>
2005+
<li><p>Let <var>output</var> be the empty string.
2006+
2007+
<li><p>Let <var>uppercase next</var> be unset.
2008+
2009+
<li><p>For each character <var>c</var> in <var>property</var>:
2010+
2011+
<ol>
2012+
<li><p>If <var>c</var> is "<code title="">-</code>" (U+002D), let <var>uppercase next</var> be set.
2013+
2014+
<li><p>Otherwise, if <var>uppercase next</var> is set, let <var>uppercase next</var> be unset and append <var>c</var> converted to ASCII uppercase to <var>output</var>.
2015+
2016+
<li><p>Otherwise, append <var>c</var> to <var>output</var>.
2017+
</ol>
2018+
2019+
<li><p>Return <var>output</var>.
2020+
</ol>
2021+
2022+
<p>The <dfn id="idl-attribute-to-css-property">IDL attribute to CSS property</dfn> algorithm for <var>attribute</var> is as
2023+
follows:</p>
19812024

2025+
<ol>
2026+
<li><p>Let <var>output</var> be the empty string.
2027+
2028+
<li><p>For each character <var>c</var> in <var>attribute</var>:
2029+
2030+
<ol>
2031+
<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> converted to ASCII lowercase to <var>output</var>.
2032+
2033+
<li><p>Otherwise, append <var>c</var> to <var>output</var>.
2034+
</ol>
2035+
2036+
<li><p>Return <var>output</var>.
2037+
</ol>
2038+
2039+
2040+
<!--
19822041
<hr>
19832042
19842043
<p>For the table below, the IDL attribute in the first column
@@ -2003,9 +2062,9 @@ <h4 id="the-cssstyledeclaration-interface"><span class="secno">6.5.1 </span>The
20032062
<th>IDL attribute
20042063
<th>CSS property
20052064
<tbody>
2006-
<!--CSSOM-DECLARATIONTABLE-->
2065+
<!- -CSSOM-DECLARATIONTABLE- ->
20072066
</table>
2008-
2067+
-->
20092068
<!--
20102069
<h4>CSS Properties</h4>
20112070

cssom/cssom-source

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,66 @@
15341534
<h4>The <code>CSSStyleDeclaration</code> Interface</h4>
15351535

15361536
<!--{@idl(CSSStyleDeclaration)}-->
1537+
1538+
<p>For each CSS property <var>property</var> that the user agent supports, the following
1539+
partial interface applies where <var>attribute</var> is obtained by running the
1540+
<span>CSS property to IDL attribute</span> algorithm for <var>property</var>.
1541+
1542+
<pre class=idl>partial interface CSSStyleDeclaration {
1543+
attribute DOMString <var>attribute</var>;
1544+
};</pre>
1545+
1546+
<p>Getting the <var>attribute</var> attribute must return the result of invoking
1547+
<code title=dom-CSSStyleDeclaration-getPropertyValue>getPropertyValue()</code> with as
1548+
argument the result of running the <span>IDL attribute to CSS property</span>
1549+
algorithm for <var>attribute</var>.</p>
1550+
1551+
<p>Setting the <var>attribute</var> attribute must invoke
1552+
<code title=dom-CSSStyleDeclaration-setPropertyValue>setPropertyValue()</code> with as
1553+
first argument the result of running the <span>IDL attribute to CSS property</span>
1554+
algorithm for <var>attribute</var>, as second argument the given value, and no third argument. Any
1555+
exceptions thrown must be re-thrown.</p>
1556+
1557+
<p>The <dfn>CSS property to IDL attribute</dfn> algorithm for <var>property</var> is as
1558+
follows:</p>
1559+
1560+
<ol>
1561+
<li><p>Let <var>output</var> be the empty string.
1562+
1563+
<li><p>Let <var>uppercase next</var> be unset.
1564+
1565+
<li><p>For each character <var>c</var> in <var>property</var>:
1566+
1567+
<ol>
1568+
<li><p>If <var>c</var> is "<code title>-</code>" (U+002D), let <var>uppercase next</var> be set.
1569+
1570+
<li><p>Otherwise, if <var>uppercase next</var> is set, let <var>uppercase next</var> be unset and append <var>c</var> converted to ASCII uppercase to <var>output</var>.
1571+
1572+
<li><p>Otherwise, append <var>c</var> to <var>output</var>.
1573+
</ol>
1574+
1575+
<li><p>Return <var>output</var>.
1576+
</ol>
1577+
1578+
<p>The <dfn>IDL attribute to CSS property</dfn> algorithm for <var>attribute</var> is as
1579+
follows:</p>
15371580

1581+
<ol>
1582+
<li><p>Let <var>output</var> be the empty string.
1583+
1584+
<li><p>For each character <var>c</var> in <var>attribute</var>:
1585+
1586+
<ol>
1587+
<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> converted to ASCII lowercase to <var>output</var>.
1588+
1589+
<li><p>Otherwise, append <var>c</var> to <var>output</var>.
1590+
</ol>
1591+
1592+
<li><p>Return <var>output</var>.
1593+
</ol>
1594+
1595+
1596+
<!--
15381597
<hr>
15391598

15401599
<p>For the table below, the IDL attribute in the first column
@@ -1559,9 +1618,9 @@
15591618
<th>IDL attribute
15601619
<th>CSS property
15611620
<tbody>
1562-
<!--CSSOM-DECLARATIONTABLE-->
1621+
<!- -CSSOM-DECLARATIONTABLE- ->
15631622
</table>
1564-
1623+
-->
15651624
<!--
15661625
<h4>CSS Properties</h4>
15671626

cssom/data/xrefs/css/cssom.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"css declaration block": "css-declaration-block",
1212
"css declaration block declarations": "css-declaration-block-declarations",
1313
"css declaration block readonly flag": "css-declaration-block-readonly-flag",
14+
"css property to idl attribute": "css-property-to-idl-attribute",
1415
"css rule": "rule",
1516
"css style sheet": "css-style-sheet",
1617
"document style sheets": "document-style-sheets",
@@ -19,6 +20,7 @@
1920
"escape a character": "escape-a-character",
2021
"escape a character as code point": "escape-a-character-as-code-point",
2122
"http-default-style": "default-style",
23+
"idl attribute to css property": "idl-attribute-to-css-property",
2224
"insert a css rule": "insert-a-css-rule",
2325
"last style sheet set name": "last-style-sheet-set-name",
2426
"parse a css declaration block": "parse-a-css-declaration-block",

0 commit comments

Comments
 (0)