Skip to content

Commit 0d90ec5

Browse files
author
Simon Pieters
committed
[cssom] Add getDefaultComputedStyle()
1 parent 63aefde commit 0d90ec5

2 files changed

Lines changed: 38 additions & 8 deletions

File tree

cssom/Overview.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2425,16 +2425,18 @@ <h3 id="extensions-to-the-window-interface"><span class="secno">7.2 </span>Exten
24252425

24262426

24272427
<pre class="idl"><span class="idlInterface" id="widl-def-Window">partial interface <span class="idlInterfaceID">Window</span> {
2428-
<span class="idlMethod"> <span class="idlMethType"><a>CSSStyleDeclaration</a></span> <span class="idlMethName"><a href="#widl-Window-getComputedStyle-CSSStyleDeclaration-Element-elt">getComputedStyle</a></span> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>);</span>
2429-
<span class="idlMethod"> <span class="idlMethType"><a>CSSStyleDeclaration</a></span> <span class="idlMethName"><a href="#widl-Window-getComputedStyle-CSSStyleDeclaration-Element-elt-DOMString-pseudoElt">getComputedStyle</a></span> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>);</span>
2428+
<span class="idlMethod"> <span class="idlMethType"><a>CSSStyleDeclaration</a></span> <span class="idlMethName"><a href="#widl-Window-getComputedStyle-CSSStyleDeclaration-Element-elt-DOMString-pseudoElt">getComputedStyle</a></span> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>);</span>
2429+
<span class="idlMethod"> <span class="idlMethType"><a>CSSStyleDeclaration</a></span> <span class="idlMethName"><a href="#widl-Window-getDefaultComputedStyle-CSSStyleDeclaration-Element-elt-DOMString-pseudoElt">getDefaultComputedStyle</a></span> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>);</span>
24302430
};</span></pre>
24312431
<dl class="methods">
2432-
<dt class="method" id="widl-Window-getComputedStyle-CSSStyleDeclaration-Element-elt">
2433-
<code>getComputedStyle</code> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>), returns <span class="idlMethType"><a>CSSStyleDeclaration</a></span></dt>
24342432
<dt class="method" id="widl-Window-getComputedStyle-CSSStyleDeclaration-Element-elt-DOMString-pseudoElt">
2435-
<code>getComputedStyle</code> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam"><span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>), returns <span class="idlMethType"><a>CSSStyleDeclaration</a></span></dt>
2433+
<code>getComputedStyle</code> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>), returns <span class="idlMethType"><a>CSSStyleDeclaration</a></span></dt>
24362434
<dd>
24372435
<p>The <code>getComputedStyle</code> operation must run these steps:</p> <ol> <li><p>Let <var>doc</var> be the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> associated with the <code class="external"><a href="http://dev.w3.org/html5/spec/single-page.html#window">Window</a></code> object on which the method was invoked.</li> <li><p>Let <var>obj</var> be <var>elt</var>.</li> <li><p>If <var>pseudoElt</var> is as an <a class="external" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for either '<code>:before</code>' or '<code>::before</code>' let <var>obj</var> be the '::before' pseudo-element of <var>elt</var>.</li> <li><p>If <var>pseudoElt</var> is as an <a class="external" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for either '<code>:after</code>' or '<code>::after</code>' let <var>obj</var> be the '::after' pseudo-element of <var>elt</var>.</li> <li> <p>Return a <a href="#css-declaration-block">CSS declaration block</a> with the <a href="#css-declaration-block-readonly-flag">CSS declaration block readonly flag</a> set and the <a href="#css-declaration-block-declarations">CSS declaration block declarations</a> set to all properties the user agent supports with as value the <a href="#resolved-value">resolved value</a> computed for <var>obj</var> using the style rules associated with <var>doc</var>.</p> <p class="note">This means that even if <var>obj</var> is in a different document (e.g. one fetched via <code>XMLHttpRequest</code>) it will still use the style rules associated with the document that is associated with the global object on which <code title="dom-Window-getComputedStyle">getComputedStyle()</code> was invoked to compute the <a href="#css-declaration-block">CSS declaration block</a>.</p> </li> </ol> <p class="note">Because of historical IDL limitations the <code>getComputedStyle</code> operation used to be on a separate interface, <code>ViewCSS</code>.</dd>
2436+
<dt class="method" id="widl-Window-getDefaultComputedStyle-CSSStyleDeclaration-Element-elt-DOMString-pseudoElt">
2437+
<code>getDefaultComputedStyle</code> (<span class="idlParam"><span class="idlParamType"><a>Element</a></span> <span class="idlParamName">elt</span></span>, <span class="idlParam">optional <span class="idlParamType"><a>DOMString</a></span> <span class="idlParamName">pseudoElt</span></span>), returns <span class="idlMethType"><a>CSSStyleDeclaration</a></span></dt>
2438+
<dd>
2439+
<p>The <code>getDefaultComputedStyle</code> operation must run these steps:</p> <ol> <li><p>Let <var>doc</var> be the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> associated with the <code class="external"><a href="http://dev.w3.org/html5/spec/single-page.html#window">Window</a></code> object on which the method was invoked.</li> <li><p>Let <var>obj</var> be <var>elt</var>.</li> <li><p>If <var>pseudoElt</var> is as an <a class="external" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for either '<code>:before</code>' or '<code>::before</code>' let <var>obj</var> be the '::before' pseudo-element of <var>elt</var>.</li> <li><p>If <var>pseudoElt</var> is as an <a class="external" href="http://dom.spec.whatwg.org/#ascii-case-insensitive">ASCII case-insensitive</a> match for either '<code>:after</code>' or '<code>::after</code>' let <var>obj</var> be the '::after' pseudo-element of <var>elt</var>.</li> <li> <p>Return a <a href="#css-declaration-block">CSS declaration block</a> with the <a href="#css-declaration-block-readonly-flag">CSS declaration block readonly flag</a> set and the <a href="#css-declaration-block-declarations">CSS declaration block declarations</a> set to all properties the user agent supports with as value the computed value for <var>obj</var> using the user agent-level style rules and user-level style rules associated with <var>doc</var>, ignoring author-level style rules, transitions, animations, override style sheets and presentational hints.</p> </li> </ol></dd>
24382440
</dl>
24392441

24402442

cssom/idl/Window.idl

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11

22
partial interface Window {
33

4-
CSSStyleDeclaration getComputedStyle(Element elt);
5-
64
[Documentation=
75
"<p>The {@name} {@type} must run these steps:</p>\
86
<ol>\
@@ -39,6 +37,36 @@ partial interface Window {
3937
<p class='note'>Because of historical IDL limitations the {@name} {@type} used to be on\
4038
a separate interface, <code>ViewCSS</code>.</p>"
4139
]
42-
CSSStyleDeclaration getComputedStyle(Element elt, DOMString pseudoElt);
40+
CSSStyleDeclaration getComputedStyle(Element elt, optional DOMString pseudoElt);
4341

42+
[Documentation=
43+
"<p>The {@name} {@type} must run these steps:</p>\
44+
<ol>\
45+
<li><p>Let <var>doc</var> be the\
46+
<code data-anolis-spec=dom>Document</code>\
47+
associated with the <code data-anolis-spec=html>Window</code> object on\
48+
which the method was invoked.</p></li>\
49+
<li><p>Let <var>obj</var> be <var>elt</var>.</p></li>\
50+
<li><p>If <var>pseudoElt</var> is as an\
51+
<span data-anolis-spec=dom>ASCII case-insensitive</span> match for\
52+
either '<code>:before</code>' or '<code>::before</code>' let\
53+
<var>obj</var> be the '::before' pseudo-element of\
54+
<var>elt</var>.</p></li>\
55+
<li><p>If <var>pseudoElt</var> is as an\
56+
<span data-anolis-spec=dom>ASCII case-insensitive</span> match for\
57+
either '<code>:after</code>' or '<code>::after</code>' let\
58+
<var>obj</var> be the '::after' pseudo-element of\
59+
<var>elt</var>.</p></li>\
60+
<li>\
61+
<p>Return a <span>CSS declaration block</span> with the\
62+
<span>CSS declaration block readonly flag</span> set and the\
63+
<span>CSS declaration block declarations</span> set to all properties\
64+
the user agent supports with as value the computed value\
65+
for <var>obj</var> using the user agent-level style rules and user-level style\
66+
rules associated with <var>doc</var>, ignoring author-level style rules,\
67+
transitions, animations, override style sheets and presentational hints.</p>\
68+
</li>\
69+
</ol>"
70+
]
71+
CSSStyleDeclaration getDefaultComputedStyle(Element elt, optional DOMString pseudoElt);
4472
};

0 commit comments

Comments
 (0)