|
16 | 16 |
|
17 | 17 | <h1>CSSOM View Module</h1> |
18 | 18 |
|
19 | | - <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 9 January 2014</h2> |
| 19 | + <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 6 June 2014</h2> |
20 | 20 |
|
21 | 21 | <dl> |
22 | 22 |
|
@@ -83,7 +83,7 @@ <h2 class="no-num no-toc" id="sotd">Status of This Document</h2> |
83 | 83 | can be found in the <a href="http://www.w3.org/TR/">W3C technical reports |
84 | 84 | index at http://www.w3.org/TR/.</a></em> |
85 | 85 |
|
86 | | -<p>This is the 9 January 2014 Editor's Draft of CSSOM View. Please send |
| 86 | +<p>This is the 6 June 2014 Editor's Draft of CSSOM View. Please send |
87 | 87 | comments to |
88 | 88 | <a href="mailto:www-style@w3.org?subject=%5Bcssom-view%5D%20">www-style@w3.org</a> |
89 | 89 | (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) |
@@ -815,45 +815,106 @@ <h4 id="the-features-argument-to-the-open()-method"><span class="secno">5.1 </sp |
815 | 815 |
|
816 | 816 | <h3 id="the-mediaquerylist-interface"><span class="secno">5.2 </span>The <code title="">MediaQueryList</code> Interface</h3> |
817 | 817 |
|
818 | | -<p>A <code><a href="#mediaquerylist">MediaQueryList</a></code> object has an associated media query list set on creation and an associated |
819 | | -<dfn id="list-of-media-query-list-listeners">list of media query list listeners</dfn>, which is initially empty.</p> |
820 | | -<p>If the associated media query list changes in evaluation then, for each |
821 | | -listener in the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a> — in |
822 | | -appending order, <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#queue-a-task">queue a task</a> that invokes the listener, |
823 | | -passing as argument the <code><a href="#mediaquerylist">MediaQueryList</a></code> object.</p> |
| 818 | +<p>A <code><a href="#mediaquerylist">MediaQueryList</a></code> object has an associated media query list set on creation.</p> |
| 819 | + |
| 820 | +<p>A <code><a href="#mediaquerylist">MediaQueryList</a></code> object has an associated <dfn id="concept-mediaquerylist-media" title="concept-MediaQueryList-media">media</dfn> which is the |
| 821 | +<a class="external" data-anolis-spec="cssom" href="http://dev.w3.org/csswg/cssom/#serialize-a-media-query-list" title="serialize a media query list">serialized</a> form of the associated media query list.</p> |
| 822 | + |
| 823 | +<p>A <code><a href="#mediaquerylist">MediaQueryList</a></code> object has an associated <dfn id="concept-mediaquerylist-matches" title="concept-MediaQueryList-matches">matches state</dfn> which is |
| 824 | +true if the associated media query list matches the state of the rendered <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#document">Document</a></code>, and false otherwise.</p> |
| 825 | + |
| 826 | +<p>If the associated media query list changes in evaluation, the user agent must <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#queue-a-task">queue a task</a> to run these steps:</p> |
| 827 | + |
| 828 | +<ol> |
| 829 | + |
| 830 | + <li><p>Let <var>target</var> be the <code><a href="#mediaquerylist">MediaQueryList</a></code> object.</li> |
| 831 | + |
| 832 | + <li><p>Let <var>event</var> be a new <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-event" title="concept-event">event</a> |
| 833 | + using the <code><a href="#mediaquerylistevent">MediaQueryListEvent</a></code> interface, |
| 834 | + with its <code class="external" data-anolis-spec="dom" title="dom-Event-type"><a href="http://dom.spec.whatwg.org/#dom-event-type">type</a></code> attribute initialized to <code title="">change</code>, |
| 835 | + its <code class="external" data-anolis-spec="dom" title="dom-Event-isTrusted"><a href="http://dom.spec.whatwg.org/#dom-event-istrusted">isTrusted</a></code> attribute initialized to true, |
| 836 | + its <code title="dom-MediaQueryListEvent-media"><a href="#dom-mediaquerylistevent-media">media</a></code> attribute initialized to <var>target</var>'s <a href="#concept-mediaquerylist-media" title="concept-MediaQueryList-media">media</a>, |
| 837 | + and its <code title="dom-MediaQueryListEvent-matches"><a href="#dom-mediaquerylistevent-matches">matches</a></code> attribute initialized to <var>target</var>'s <a href="#concept-mediaquerylist-matches" title="concept-MediaQueryList-matches">matches state</a>. <!--fingerprint--></li> |
| 838 | + |
| 839 | + <li><p><a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-event-dispatch" title="concept-event-dispatch">Dispatch</a> <var>event</var> to <var>target</var>.</li> |
| 840 | + |
| 841 | +</ol> |
| 842 | + |
824 | 843 | <div class="example"> |
825 | 844 | <p>A simple piece of code that detects changes in the orientation of the viewport can be written as follows:</p> |
826 | | -<pre>function handleOrientationChange(mql) { |
827 | | - if(mql.matches) // landscape |
| 845 | +<pre>function handleOrientationChange(event) { |
| 846 | + if(event.matches) // landscape |
828 | 847 | … |
829 | 848 | else |
830 | 849 | … |
831 | 850 | } |
832 | 851 | var mql = matchMedia("(orientation:landscape)") |
833 | | - mql.addListener(handleOrientationChange)</pre> |
| 852 | + mql.onchange = handleOrientationChange</pre> |
834 | 853 | </div> |
835 | 854 |
|
836 | | -<pre class="idl">interface <dfn id="mediaquerylist">MediaQueryList</dfn> { |
| 855 | +<pre class="idl">interface <dfn id="mediaquerylist">MediaQueryList</dfn> : <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#eventtarget">EventTarget</a> { |
837 | 856 | readonly attribute DOMString <a href="#dom-mediaquerylist-media" title="dom-MediaQueryList-media">media</a>; |
838 | 857 | readonly attribute boolean <a href="#dom-mediaquerylist-matches" title="dom-MediaQueryList-matches">matches</a>; |
839 | | - void <a href="#dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener">addListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> listener); |
840 | | - void <a href="#dom-mediaquerylist-removelistener" title="dom-MediaQueryList-removeListener">removeListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> listener); |
841 | | -}; |
842 | | - |
843 | | -callback <dfn id="mediaquerylistlistener">MediaQueryListListener</dfn> = void (<a href="#mediaquerylist">MediaQueryList</a> list);</pre> |
| 858 | + void <a href="#dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener">addListener</a>(<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#eventlistener">EventListener</a>? listener); |
| 859 | + void <a href="#dom-mediaquerylist-removelistener" title="dom-MediaQueryList-removeListener">removeListener</a>(<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#eventlistener">EventListener</a>? listener); |
| 860 | + attribute <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler">EventHandler</a> onchange; |
| 861 | +};</pre> |
844 | 862 |
|
845 | | -<p>The <dfn id="dom-mediaquerylist-media" title="dom-MediaQueryList-media"><code>media</code></dfn> attribute must return the |
846 | | -<a class="external" data-anolis-spec="cssom" href="http://dev.w3.org/csswg/cssom/#serialize-a-media-query-list" title="serialize a media query list">serialized</a> form of the associated media query list.</p> |
| 863 | +<p>The <dfn id="dom-mediaquerylist-media" title="dom-MediaQueryList-media"><code>media</code></dfn> attribute must return |
| 864 | +the associated <a href="#concept-mediaquerylist-media" title="concept-MediaQueryList-media">media</a>.</p> |
847 | 865 |
|
848 | | -<p>The <dfn id="dom-mediaquerylist-matches" title="dom-MediaQueryList-matches"><code>matches</code></dfn> attribute must return true if the associated media query list |
849 | | -matches the state of the rendered <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> and false if it does not. <!--fingerprint--></p> |
| 866 | +<p>The <dfn id="dom-mediaquerylist-matches" title="dom-MediaQueryList-matches"><code>matches</code></dfn> attribute must return |
| 867 | +the associated <a href="#concept-mediaquerylist-matches" title="concept-MediaQueryList-matches">matches state</a>. <!--fingerprint--></p> |
850 | 868 |
|
851 | | -<p>When the <dfn id="dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener"><code>addListener(<var>listener</var>)</code></dfn> method is invoked <var>listener</var> must |
852 | | -be appended to the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>, unless |
853 | | -it is already in the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>.</p> |
| 869 | +<p>When the <dfn id="dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener"><code>addListener(<var>listener</var>)</code></dfn> method is invoked |
| 870 | +the user agent must invoke the <code class="external" data-anolis-spec="dom" title="dom-EventTarget-addEventListener"><a href="http://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener</a></code> method |
| 871 | +with <code title="">change</code> as the first argument and <var>listener</var> as the second argument.</p> |
854 | 872 |
|
855 | 873 | <p>When the <dfn id="dom-mediaquerylist-removelistener" title="dom-MediaQueryList-removeListener"><code>removeListener(<var>listener</var>)</code></dfn> method is invoked |
856 | | -<var>listener</var> must be removed from the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>.</p> |
| 874 | +the user agent must invoke the <code class="external" data-anolis-spec="dom" title="dom-EventTarget-removeEventListener"><a href="http://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener">removeEventListener</a></code> method |
| 875 | +with <code title="">change</code> as the first argument and <var>listener</var> as the second argument.</p> |
| 876 | + |
| 877 | +<p class="note">This specification initially had a custom callback mechanism with <code title="dom-MediaQueryList-addListener"><a href="#dom-mediaquerylist-addlistener">addListener</a></code> and |
| 878 | +<code title="dom-MediaQueryList-removeListener"><a href="#dom-mediaquerylist-removelistener">removeListener</a></code>, and the callback was invoked with the associated media query list as argument. |
| 879 | +Now the normal event mechanism is used instead. |
| 880 | +For backwards compatibility, the <code title="dom-MediaQueryList-addListener"><a href="#dom-mediaquerylist-addlistener">addListener</a></code> and <code title="dom-MediaQueryList-removeListener"><a href="#dom-mediaquerylist-removelistener">removeListener</a></code> methods |
| 881 | +are basically aliases for <code class="external" data-anolis-spec="dom" title="dom-EventTarget-addEventListener"><a href="http://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener">addEventListener</a></code> and <code class="external" data-anolis-spec="dom" title="dom-EventTarget-removeEventListener"><a href="http://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener">removeEventListener</a></code>, respectively, |
| 882 | +and the <code title="">change</code> event masquerades as a <code><a href="#mediaquerylist">MediaQueryList</a></code>.</p> |
| 883 | + |
| 884 | +<p>The following are the <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handlers">event handlers</a> |
| 885 | +(and their corresponding <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-event-type" title="event handler event type">event handler event types</a>) that must be supported, |
| 886 | +as <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-idl-attributes">event handler IDL attributes</a>, by all objects implementing the <code><a href="#mediaquerylist">MediaQueryList</a></code> interface:</p> |
| 887 | + |
| 888 | +<table class="complex data"> |
| 889 | + <thead> |
| 890 | + <tr> |
| 891 | + <th><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handlers" title="event handlers">Event handler</a></th> |
| 892 | + <th><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#event-handler-event-type">Event handler event type</a></th> |
| 893 | + </tr> |
| 894 | + </thead> |
| 895 | + <tbody> |
| 896 | + <tr> |
| 897 | + <td><dfn id="handler-mediaquerylist-onchange" title="handler-MediaQueryList-onchange">onchange</dfn> |
| 898 | + <td><code title="">change</code> |
| 899 | + </tr> |
| 900 | + </tbody> |
| 901 | +</table> |
| 902 | + |
| 903 | +<pre class="idl">[<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-event-constructor" title="concept-event-constructor">Constructor</a>(DOMString type, optional <a href="#mediaquerylisteventinit">MediaQueryListEventInit</a> eventInitDict), |
| 904 | + Exposed=Window,Worker] |
| 905 | +interface <dfn id="mediaquerylistevent">MediaQueryListEvent</dfn> : <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#event">Event</a> { |
| 906 | + readonly attribute DOMString <a href="#dom-mediaquerylistevent-media" title="dom-MediaQueryListEvent-media">media</a>; |
| 907 | + readonly attribute boolean <a href="#dom-mediaquerylistevent-matches" title="dom-MediaQueryListEvent-matches">matches</a>; |
| 908 | +}; |
| 909 | + |
| 910 | +dictionary <dfn id="mediaquerylisteventinit">MediaQueryListEventInit</dfn> : <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#eventinit">EventInit</a> { |
| 911 | + DOMString media = ''; |
| 912 | + boolean matches = false; |
| 913 | +};</pre> |
| 914 | + |
| 915 | +<p>The <dfn id="dom-mediaquerylistevent-media" title="dom-MediaQueryListEvent-media"><code>media</code></dfn> attribute must return the value it was initialized to.</p> |
| 916 | + |
| 917 | +<p>The <dfn id="dom-mediaquerylistevent-matches" title="dom-MediaQueryListEvent-matches"><code>matches</code></dfn> attribute must return the value it was initialized to.</p> |
857 | 918 |
|
858 | 919 | <h3 id="the-screen-interface"><span class="secno">5.3 </span>The <code title="">Screen</code> Interface</h3> |
859 | 920 |
|
@@ -1491,7 +1552,7 @@ <h2 id="extensions-to-the-htmlelement-interface"><span class="secno">8 </span>Ex |
1491 | 1552 |
|
1492 | 1553 | <h2 id="excensions-to-the-htmlimageelement-interface"><span class="secno">9 </span>Excensions to the <code title="">HTMLImageElement</code> Interface</h2> |
1493 | 1554 |
|
1494 | | -<pre class="idl">partial interface <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/embedded-content-1.html#htmlimageelement">HTMLImageElement</a> { |
| 1555 | +<pre class="idl">partial interface <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/edits.html#htmlimageelement">HTMLImageElement</a> { |
1495 | 1556 | readonly attribute double <a href="#dom-htmlimageelement-x" title="dom-HTMLImageElement-x">x</a>; |
1496 | 1557 | readonly attribute double <a href="#dom-htmlimageelement-y" title="dom-HTMLImageElement-y">y</a>; |
1497 | 1558 | };</pre> |
|
0 commit comments