Skip to content

Commit d179130

Browse files
committed
introduce Media object
1 parent 990c4a2 commit d179130

2 files changed

Lines changed: 99 additions & 23 deletions

File tree

cssom/Overview.html

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
<div class=head>
3636
<h1 id=cssom>Cascading Style Sheets Object Model (<abbr>CSSOM</abbr>)</h1>
3737

38-
<h2 class="no-num no-toc" id="">Editor's draft <!--W3C Working Draft--> 9
38+
<h2 class="no-num no-toc" id="">Editor's draft <!--W3C Working Draft--> 13
3939
June 2007</h2>
4040

4141
<dl>
4242
<dt>This version:</dt>
4343
<!--
44-
<dd><a href="http://www.w3.org/TR/2007/WD-cssom-20070609/">http://www.w3.org/TR/2007/WD-cssom-20070609/</a></dd>
44+
<dd><a href="http://www.w3.org/TR/2007/WD-cssom-20070613/">http://www.w3.org/TR/2007/WD-cssom-20070613/</a></dd>
4545
-->
4646

4747
<dd>...
@@ -269,6 +269,9 @@ <h2 class="no-num no-toc" id=toc>Table of Contents</h2>
269269
<ul class=toc>
270270
<li><a href="#the-screen"><span class=secno>4.1.1. </span>The <code
271271
title="">Screen</code> Interface</a>
272+
273+
<li><a href="#the-media"><span class=secno>4.1.2. </span>The <code
274+
title="">Media</code> Interface</a>
272275
</ul>
273276

274277
<li><a href="#the-documentlayout"><span class=secno>4.2. </span>The
@@ -301,7 +304,7 @@ <h2 class="no-num no-toc" id=toc>Table of Contents</h2>
301304

302305
<li><a href="#canon"><span class=secno>5. </span>Canonicalization </a>
303306
<ul class=toc>
304-
<li><a href="#media"><span class=secno>5.1. </span>Media queries</a>
307+
<li><a href="#media0"><span class=secno>5.1. </span>Media queries</a>
305308
<ul class=toc>
306309
<li><a href="#examples1"><span class=secno>5.1.1. </span>Examples</a>
307310
</ul>
@@ -544,8 +547,8 @@ <h4 id=ltxml-stylesheet><span class=secno>2.2.3.
544547
<dt><code title=stylesheet-media><a
545548
href="#stylesheet-media">media</a></code>
546549

547-
<dd>This <em class=ct>must</em> be the value of the <code>media</code>
548-
pseudo-attribute.
550+
<dd>This <em class=ct>must</em> be the value of the <code
551+
title="">media</code> pseudo-attribute.
549552

550553
<dt><code title=stylesheet-title><a
551554
href="#stylesheet-title">title</a></code>
@@ -1653,8 +1656,8 @@ <h4 id=the-cssrule><span class=secno>3.4.1. </span>The <code
16531656
<p>The <dfn id=cssrule-parentrule
16541657
title=cssrule-parentrule><code>parentRule</code></dfn> attribute <em
16551658
class=ct>must</em> return the nearest enclosing rule of the current rule
1656-
or <code>null</code> if there is no enclosing rule. For example, an
1657-
<code>@media</code> block enclosing the current rule.
1659+
or <code>null</code> if there is no enclosing rule. For example, an <code
1660+
title="">@media</code> block enclosing the current rule.
16581661

16591662
<p>The <dfn id=cssrule-parentstylesheet
16601663
title=cssrule-parentstylesheet><code>parentStyleSheet</code></dfn>
@@ -1803,7 +1806,7 @@ <h4 id=the-cssmediarule><span class=secno>3.4.5. </span>The <code
18031806
return the value of that constant.
18041807

18051808
<p>The <code><a href="#cssmediarule">CSSMediaRule</a></code> object
1806-
represents an <code>@media</code> rule specified (if any) in a <a
1809+
represents an <code title="">@media</code> rule specified (if any) in a <a
18071810
href="#css-style-sheet">CSS style sheet</a>. It is a single statement that
18081811
contains zero or more rulesets which are contrained by one or more media
18091812
queries (unless one happens to be <code>all</code>).
@@ -1820,13 +1823,13 @@ <h4 id=the-cssmediarule><span class=secno>3.4.5. </span>The <code
18201823
title=cssmediarule-media><code>media</code></dfn> attribute, on getting,
18211824
<em class=ct>must</em> return a <code><a
18221825
href="#medialist">MediaList</a></code> object containing a list of media
1823-
queries specified with the <code>@media</code> rule.
1826+
queries specified with the <code title="">@media</code> rule.
18241827

18251828
<p>The <dfn id=cssmediarule-cssrules
18261829
title=cssmediarule-cssrules><code>cssRules</code></dfn> attribute, on
18271830
getting, <em class=ct>must</em> return a <code><a
18281831
href="#cssrulelist">CSSRuleList</a></code> object containing a list of all
1829-
the rulesets specified within the <code>@media</code> rule.
1832+
the rulesets specified within the <code title="">@media</code> rule.
18301833

18311834
<p>The <dfn id=cssmediarule-insertrule
18321835
title=cssmediarule-insertrule><code>insertRule(<var title="">rule</var>,
@@ -2481,6 +2484,7 @@ <h3 id=the-windowlayout><span class=secno>4.1. </span>The <code><a
24812484
readonly attribute float <a href="#windowlayout-pageyoffset" title=windowlayout-pageyoffset>pageYOffset</a>;
24822485
readonly attribute float <a href="#windowlayout-screenx" title=windowlayout-screenx>screenX</a>;
24832486
readonly attribute float <a href="#windowlayout-screeny" title=windowlayout-screeny>screenY</a>;
2487+
readonly attribute <a href="#media">Media</a> <a href="#windowlayout-media" title=windowlayout-media>media</a>;
24842488
readonly attribute <a href="#screen">Screen</a> <a href="#windowlayout-screen" title=windowlayout-screen>screen</a>;
24852489
};</pre>
24862490
<!-- XXX float? -->
@@ -2534,16 +2538,22 @@ <h3 id=the-windowlayout><span class=secno>4.1. </span>The <code><a
25342538
device. If there is no browser window this attribute <em
25352539
class=ct>must</em> return zero.
25362540

2541+
<p>The <dfn id=windowlayout-media
2542+
title=windowlayout-media><code>media</code></dfn> attribute, on getting,
2543+
<em class=ct>must</em> return a <code><a href="#media">Media</a></code>
2544+
object.
2545+
25372546
<p>The <dfn id=windowlayout-screen
25382547
title=windowlayout-screen><code>screen</code></dfn> attribute, on getting,
25392548
<em class=ct>must</em> return a <code><a href="#screen">Screen</a></code>
25402549
object.
25412550

25422551
<p>If the user agent supports multiple views and the current view does not
25432552
have a notion of an output device the above attributes with the exception
2544-
of <code title=windowlayout-screen><a
2545-
href="#windowlayout-screen">screen</a></code> <em class=ct>should</em>
2546-
return zero. [DOM2View]
2553+
of <code title=windowlayout-media><a
2554+
href="#windowlayout-media">media</a></code> and <code
2555+
title=windowlayout-screen><a href="#windowlayout-screen">screen</a></code>
2556+
<em class=ct>should</em> return zero. [DOM2View]
25472557

25482558
<h4 id=the-screen><span class=secno>4.1.1. </span>The <code
25492559
title="">Screen</code> Interface</h4>
@@ -2590,6 +2600,36 @@ <h4 id=the-screen><span class=secno>4.1.1. </span>The <code
25902600
have a notion of an output device the above attributes <em
25912601
class=ct>should</em> return zero. [DOM2View]
25922602

2603+
<h4 id=the-media><span class=secno>4.1.2. </span>The <code
2604+
title="">Media</code> Interface</h4>
2605+
<!-- XXX arguably this is the wrong place -->
2606+
2607+
<pre class=idl>interface <dfn id=media>Media</dfn> {
2608+
readonly attribute DOMString <a href="#type" title=media-type>type</a>;
2609+
boolean <a href="#matchmedia" title=media-matchmedia>matchMedia</a>(in DOMString <var title="">mediaquery</var>);
2610+
};</pre>
2611+
2612+
<p>The <dfn id=type title=media-type><code>type</code></dfn> attribute, on
2613+
getting, <em class=ct>must</em> return the string that represents the
2614+
canvas' current rendering mode (<code><a href="#screen">screen</a></code>,
2615+
<code>print</code>, etc). This is a lowercase string, as defined by the
2616+
CSS specification. [CSS]
2617+
2618+
<p>The <dfn id=matchmedia title=media-matchmedia><code>matchMedia(<var
2619+
title="">mediaquery</var>)</code></dfn> method, when invoked, <em
2620+
class=ct>must</em> return the result of the following algorithm:
2621+
2622+
<ol>
2623+
<li>If <var title="">mediaquery</var> can not be parsed according to the
2624+
rules given in the Media Query specification return <code>false</code>
2625+
and terminate this algorithm.
2626+
2627+
<li>If <var title="">mediaquery</var> matches the state of the current
2628+
view return <code>true</code> and terminate this algorithm.
2629+
2630+
<li>Return <code>false</code>.
2631+
</ol>
2632+
25932633
<h3 id=the-documentlayout><span class=secno>4.2. </span>The <code
25942634
title="">DocumentLayout</code> Interface</h3>
25952635

@@ -3132,7 +3172,7 @@ <h2 id=canon><span class=secno>5. </span>Canonicalization</h2>
31323172
<p>The definitions from this section are used later to define attribute
31333173
values, et cetera.
31343174

3135-
<h3 id=media><span class=secno>5.1. </span>Media queries</h3>
3175+
<h3 id=media0><span class=secno>5.1. </span>Media queries</h3>
31363176

31373177
<p>The <dfn id=canon-media title=canon-media>canonicalization of a media
31383178
query</dfn> can be determined as follows:

cssom/Overview.src.html

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ <h4><code>&lt;?xml-stylesheet?></code> processing instruction</h4>
296296

297297
<dt><code title="stylesheet-media">media</code></dt>
298298

299-
<dd>This <em class="ct">must</em> be the value of the <code>media</code>
300-
pseudo-attribute.</dd>
299+
<dd>This <em class="ct">must</em> be the value of the
300+
<code title="">media</code> pseudo-attribute.</dd>
301301

302302
<dt><code title="stylesheet-title">title</code></dt>
303303

@@ -1266,7 +1266,7 @@ <h4>The <code title="">CSSRule</code> Interface</h4>
12661266
<dfn id="cssrule-parentrule" title="cssrule-parentrule"><code>parentRule</code></dfn>
12671267
attribute <em class="ct">must</em> return the nearest enclosing rule of the
12681268
current rule or <code>null</code> if there is no enclosing rule. For example,
1269-
an <code>@media</code> block enclosing the current rule.</p>
1269+
an <code title="">@media</code> block enclosing the current rule.</p>
12701270

12711271
<p>The
12721272
<dfn id="cssrule-parentstylesheet" title="cssrule-parentstylesheet"><code>parentStyleSheet</code></dfn>
@@ -1393,10 +1393,11 @@ <h4>The <code title="">CSSMediaRule</code> Interface</h4>
13931393
constant. On these objects the <code title="cssrule-type">type</code>
13941394
attribute <em class="ct">must</em> return the value of that constant.</p>
13951395

1396-
<p>The <code>CSSMediaRule</code> object represents an <code>@media</code>
1397-
rule specified (if any) in a <span>CSS style sheet</span>. It is a single
1398-
statement that contains zero or more rulesets which are contrained by one or
1399-
more media queries (unless one happens to be <code>all</code>).</p>
1396+
<p>The <code>CSSMediaRule</code> object represents an
1397+
<code title="">@media</code> rule specified (if any) in a <span>CSS style
1398+
sheet</span>. It is a single statement that contains zero or more rulesets
1399+
which are contrained by one or more media queries (unless one happens to be
1400+
<code>all</code>).</p>
14001401

14011402
<pre class="idl">interface <dfn>CSSMediaRule</dfn> : <span>CSSRule</span> {
14021403
readonly attribute <span>MediaList</span> <span title="cssmediarule-media">media</span>;
@@ -1409,13 +1410,13 @@ <h4>The <code title="">CSSMediaRule</code> Interface</h4>
14091410
<dfn id="cssmediarule-media" title="cssmediarule-media"><code>media</code></dfn>
14101411
attribute, on getting, <em class="ct">must</em> return a
14111412
<code>MediaList</code> object containing a list of media queries specified
1412-
with the <code>@media</code> rule.</p>
1413+
with the <code title="">@media</code> rule.</p>
14131414

14141415
<p>The
14151416
<dfn id="cssmediarule-cssrules" title="cssmediarule-cssrules"><code>cssRules</code></dfn>
14161417
attribute, on getting, <em class="ct">must</em> return a
14171418
<code>CSSRuleList</code> object containing a list of all the rulesets
1418-
specified within the <code>@media</code> rule.</p>
1419+
specified within the <code title="">@media</code> rule.</p>
14191420

14201421
<p>The
14211422
<dfn id="cssmediarule-insertrule" title="cssmediarule-insertrule"><code>insertRule(<var title="">rule</var>,
@@ -2034,6 +2035,7 @@ <h3>The <code>WindowLayout</code> Interface</h3>
20342035
readonly attribute float <span title="windowlayout-pageyoffset">pageYOffset</span>;
20352036
readonly attribute float <span title="windowlayout-screenx">screenX</span>;
20362037
readonly attribute float <span title="windowlayout-screeny">screenY</span>;
2038+
readonly attribute <span>Media</span> <span title="windowlayout-media">media</span>;
20372039
readonly attribute <span>Screen</span> <span title="windowlayout-screen">screen</span>;
20382040
};</pre>
20392041
<!-- XXX float? -->
@@ -2087,13 +2089,19 @@ <h3>The <code>WindowLayout</code> Interface</h3>
20872089
output device. If there is no browser window this attribute
20882090
<em class="ct">must</em> return zero.</p>
20892091

2092+
<p>The
2093+
<dfn id="windowlayout-media" title="windowlayout-media"><code>media</code></dfn>
2094+
attribute, on getting, <em class="ct">must</em> return a <code>Media</code>
2095+
object.</p>
2096+
20902097
<p>The
20912098
<dfn id="windowlayout-screen" title="windowlayout-screen"><code>screen</code></dfn>
20922099
attribute, on getting, <em class="ct">must</em> return a <code>Screen</code>
20932100
object.</p>
20942101

20952102
<p>If the user agent supports multiple views and the current view does not
20962103
have a notion of an output device the above attributes with the exception of
2104+
<code title="windowlayout-media">media</code> and
20972105
<code title="windowlayout-screen">screen</code> <em class="ct">should</em>
20982106
return zero. [DOM2View]</p>
20992107

@@ -2145,6 +2153,34 @@ <h4>The <code title="">Screen</code> Interface</h4>
21452153
<em class="ct">should</em> return zero. [DOM2View]</p>
21462154

21472155

2156+
<h4>The <code title="">Media</code> Interface</h4>
2157+
<!-- XXX arguably this is the wrong place -->
2158+
2159+
<pre class="idl">interface <dfn id="media">Media</dfn> {
2160+
readonly attribute DOMString <span title="media-type">type</span>;
2161+
boolean <span title="media-matchmedia">matchMedia</span>(in DOMString <var title="">mediaquery</var>);
2162+
};</pre>
2163+
2164+
<p>The <dfn title="media-type"><code>type</code></dfn> attribute, on getting,
2165+
<em class="ct">must</em> return the string that represents the canvas' current
2166+
rendering mode (<code>screen</code>, <code>print</code>, etc). This is a
2167+
lowercase string, as defined by the CSS specification. [CSS]</p>
2168+
2169+
<p>The
2170+
<dfn title="media-matchmedia"><code>matchMedia(<var title="">mediaquery</var>)</code></dfn>
2171+
method, when invoked, <em class="ct">must</em> return the result of the
2172+
following algorithm:</p>
2173+
2174+
<ol>
2175+
<li>If <var title="">mediaquery</var> can not be parsed according to the
2176+
rules given in the Media Query specification return <code>false</code> and
2177+
terminate this algorithm.</li>
2178+
2179+
<li>If <var title="">mediaquery</var> matches the state of the current view
2180+
return <code>true</code> and terminate this algorithm.</li>
2181+
2182+
<li>Return <code>false</code>.</li>
2183+
</ol>
21482184

21492185

21502186
<h3>The <code title="">DocumentLayout</code> Interface</h3>

0 commit comments

Comments
 (0)