Skip to content

Commit b0b079c

Browse files
committed
rename the styleMedia methods and let them al take lists
1 parent 067882f commit b0b079c

2 files changed

Lines changed: 121 additions & 112 deletions

File tree

cssom-view/Overview.html

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
<h1 id=cssom-view-module>CSSOM View Module</h1>
2929

30-
<h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 26 May 2010</h2>
30+
<h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 15 July 2010</h2>
3131

3232
<dl>
3333
<dt>This Version:
3434

3535
<dd><a
36-
href="http://www.w3.org/TR/2010/ED-cssom-view-20100526/">http://www.w3.org/TR/2010/ED-cssom-view-20100526/</a>
36+
href="http://www.w3.org/TR/2010/ED-cssom-view-20100715/">http://www.w3.org/TR/2010/ED-cssom-view-20100715/</a>
3737

3838
<dt>Latest Version:
3939

@@ -300,8 +300,8 @@ <h3 id=css-pixels><span class=secno>2.3. </span>CSS pixels</h3>
300300
href="#ref-css21">CSS21</a></cite>]
301301

302302
<p class=note>This does not apply to e.g. <a
303-
href="#dom-stylemedia-matchmedium"><code
304-
title=dom-StyleMedia-matchMedium>matchMedium()</code></a> as the units are
303+
href="#dom-stylemedia-matchmedia"><code
304+
title=dom-StyleMedia-matchMedia>matchMedia()</code></a> as the units are
305305
explicitly given there.
306306

307307
<h2 id=dom-features><span class=secno>3. </span>DOM Features</h2>
@@ -481,10 +481,10 @@ <h3 id=the-stylemedia-interface><span class=secno>4.1. </span>The <code
481481

482482
<pre class=idl>interface <dfn id=stylemedia>StyleMedia</dfn> {
483483
readonly attribute DOMString <a href="#dom-stylemedia-type" title=dom-StyleMedia-type>type</a>;
484-
boolean <a href="#dom-stylemedia-matchmedium" title=dom-StyleMedia-matchMedium>matchMedium</a>(DOMString <var title="">medium</var>);
484+
boolean <a href="#dom-stylemedia-matchmedia" title=dom-StyleMedia-matchMedia>matchMedia</a>(DOMString <var title="">mq_list</var>);
485485

486-
void <a href="#dom-StyleMedia-addMediumListener" title=dom-StyleMedia-addMediumListener>addMediumListener</a>(DOMString <var title="">medium</var>, <a href="#booleancallback">BooleanCallback</a> <var title="">mediumcallback</var>);
487-
void <a href="#dom-StyleMedia-removeMediumListener" title=dom-StyleMedia-removeMediumListener>removeMediumListener</a>(DOMString <var title="">medium</var>, <a href="#booleancallback">BooleanCallback</a> <var title="">mediumcallback</var>);
486+
void <a href="#dom-stylemedia-addmedialistener" title=dom-StyleMedia-addMediaListener>addMediaListener</a>(DOMString <var title="">mq_list</var>, <a href="#booleancallback">BooleanCallback</a> <var title="">mq_callback</var>);
487+
void <a href="#dom-stylemedia-removemedialistener" title=dom-StyleMedia-removeMediaListener>removeMediaListener</a>(DOMString <var title="">mq_list</var>, <a href="#booleancallback">BooleanCallback</a> <var title="">mq_callback</var>);
488488
};
489489

490490
[Callback=FunctionOnly, NoInterfaceObject]
@@ -507,24 +507,24 @@ <h3 id=the-stylemedia-interface><span class=secno>4.1. </span>The <code
507507
<pre><code>var isProjection = media.type == "projection"</code></pre>
508508
</div>
509509

510-
<p>The <dfn id=dom-stylemedia-matchmedium
511-
title=dom-StyleMedia-matchMedium><code>matchMedium(<var
512-
title="">medium</var>)</code></dfn> method <em class=ct>must</em> run
510+
<p>The <dfn id=dom-stylemedia-matchmedia
511+
title=dom-StyleMedia-matchMedia><code>matchMedia(<var
512+
title="">mq_list</var>)</code></dfn> method <em class=ct>must</em> run
513513
these steps:
514514

515515
<ol>
516516
<li>
517-
<p>Let <var title="">m</var> be the result of <a
518-
href="#parse-a-media-query" title="parse a media query">parsing</a> the
519-
given value.
517+
<p>Let <var title="">parsed_mq_list</var> be the result of <span
518+
title="parse a list of media queries">parsing</span> <var
519+
title="">mq_list</var>.
520520

521521
<li>
522-
<p>If <var title="">m</var> is null terminate these steps.
522+
<p>If <var title="">parsed_mq_list</var> is null terminate these steps.
523523

524524
<li>
525-
<p>If <var title="">m</var> matches the state of the rendered <a
526-
href="#document"><code>Document</code></a> return true and terminate
527-
this algorithm.
525+
<p>If <var title="">parsed_mq_list</var> matches the state of the
526+
rendered <a href="#document"><code>Document</code></a> return true and
527+
terminate this algorithm.
528528

529529
<li>
530530
<p>Otherwise, return false.
@@ -533,80 +533,79 @@ <h3 id=the-stylemedia-interface><span class=secno>4.1. </span>The <code
533533
<div class=example>
534534
<p>The following snippet determines whether the device is a color device:</p>
535535

536-
<pre><code>var isColorDevice = styleMedia.matchMedium("(color)")</code></pre>
536+
<pre><code>var isColorDevice = styleMedia.matchMedia("(color)")</code></pre>
537537
</div>
538538

539539
<p>Each <a href="#window"><code>Window</code></a> has an associated ordered
540-
<dfn id=list-of-media-query-listeners>list of media query listeners</dfn>.
541-
Each listener consists of a media query and a callback.
540+
<dfn id=list-of-media-listeners>list of media listeners</dfn>. Each
541+
listener consists of a list of media queries and a callback.
542542

543543
<p class=note>Due to the rules for <a
544-
href="#dom-StyleMedia-addMediumListener"><code
545-
title=dom-StyleMedia-addMediumListener>addMediumListener()</code></a>
546-
below each listener is unique. Media queries and callbacks are not
544+
href="#dom-stylemedia-addmedialistener"><code
545+
title=dom-StyleMedia-addMediaListener>addMediaListener()</code></a> below
546+
each listener is unique. Lists of media queries and callbacks are not
547547
necessarily unique.
548548

549-
<p>The <dfn id=dom-StyleMedia-addMediumListener
550-
title=dom-StyleMedia-addMediumListener><code>addMediumListener(<var
551-
title="">medium</var>, <var title="">mediumcallback</var>)</code></dfn>
549+
<p>The <dfn id=dom-stylemedia-addmedialistener
550+
title=dom-StyleMedia-addMediaListener><code>addMediaListener(<var
551+
title="">mq_list</var>, <var title="">mq_callback</var>)</code></dfn>
552552
method <em class=ct>must</em> run these steps:</p>
553553
<!-- based on dom-MediaList-appendMedium -->
554554

555555
<ol>
556556
<li>
557-
<p>Let <var title="">m</var> be the result of <a
558-
href="#parse-a-media-query" title="parse a media query">parsing</a> the
559-
given value.
557+
<p>Let <var title="">parsed_mq_list</var> be the result of <span
558+
title="parse a list of media queries">parsing</span> <var
559+
title="">mq_list</var>.
560560

561561
<li>
562-
<p>If <var title="">m</var> is null terminate these steps.
562+
<p>If <var title="">parsed_mq_list</var> is null terminate these steps.
563563

564564
<li>
565565
<p>If <a href="#compare-media-queries" title="compare media
566-
queries">comparing</a> <var title="">m</var> with any of the media
567-
queries in the <a href="#list-of-media-query-listeners">list of media
568-
query listeners</a> returns true <em>and</em> the associated callback of
569-
that media query is the same as <var title="">mediumcallback</var>,
566+
queries">comparing</a> <var title="">parsed_mq_list</var> with any of
567+
the list of media queries in the <a href="#list-of-media-listeners">list
568+
of media listeners</a> returns true <em>and</em> the associated callback
569+
of that media query is the same as <var title="">mq_callback</var>,
570570
terminate these steps.
571571

572572
<li>
573-
<p>Append the tuple of <var title="">m</var> and <var
574-
title="">mediumcallback</var> to the <a
575-
href="#list-of-media-query-listeners">list of media query listeners</a>.
573+
<p>Append the tuple of <var title="">parsed_mq_list</var> and <var
574+
title="">mq_callback</var> to the <a
575+
href="#list-of-media-listeners">list of media listeners</a>.
576576
</ol>
577577

578-
<p>The <dfn id=dom-StyleMedia-removeMediumListener
579-
title=dom-StyleMedia-removeMediumListener><code>removeMediumListener(<var
580-
title="">medium</var>, <var title="">mediumcallback</var>)</code></dfn>
578+
<p>The <dfn id=dom-stylemedia-removemedialistener
579+
title=dom-StyleMedia-removeMediaListener><code>removeMediaListener(<var
580+
title="">mq_list</var>, <var title="">mq_callback</var>)</code></dfn>
581581
method <em class=ct>must</em> run these steps:
582582

583583
<ol>
584584
<li>
585-
<p>Let <var title="">m</var> be the result of <a
586-
href="#parse-a-media-query" title="parse a media query">parsing</a> the
587-
given value.
585+
<p>Let <var title="">parsed_mq_list</var> be the result of <span
586+
title="parse a list of media queries">parsing</span> <var
587+
title="">mq_list</var>.
588588

589589
<li>
590-
<p>If <var title="">m</var> is null terminate these steps.
590+
<p>If <var title="">parsed_mq_list</var> is null terminate these steps.
591591

592592
<li>
593593
<p>If <a href="#compare-media-queries" title="compare media
594594
queries">comparing</a> <var title="">m</var> with any of the media
595-
queries in the <a href="#list-of-media-query-listeners">list of media
596-
query listeners</a> returns true <em>and</em> the associated callback of
597-
that media query is the same as <var title="">mediumcallback</var>,
598-
remove the tuple of <var title="">m</var> and <var
599-
title="">mediumcallback</var> from the <a
600-
href="#list-of-media-query-listeners">list of media query listeners</a>.
595+
queries in the <a href="#list-of-media-listeners">list of media
596+
listeners</a> returns true <em>and</em> the associated callback of that
597+
media query is the same as <var title="">mq_callback</var>, remove the
598+
tuple of <var title="">m</var> and <var title="">mq_callback</var> from
599+
the <a href="#list-of-media-listeners">list of media listeners</a>.
601600
</ol>
602601

603-
<p>If one or more media queries in the <a
604-
href="#list-of-media-query-listeners">list of media query listeners</a>
605-
changes in evaluation then for each media query of which the evaluation
606-
changes, in the order of the <a href="#list-of-media-query-listeners">list
607-
of media query listeners</a>, <a href="#queue-a-task">queue a task</a>
608-
that invokes the associated callback, passing as argument whether the
609-
media query matches the state of the rendered <a
602+
<p>If one or more lists of media queries in the <a
603+
href="#list-of-media-listeners">list of media listeners</a> changes in
604+
evaluation then for each list of media queries of which the evaluation
605+
changes, in the order of the <a href="#list-of-media-listeners">list of
606+
media listeners</a>, <a href="#queue-a-task">queue a task</a> that invokes
607+
the associated callback, passing as argument whether the list of media
608+
queries matches the state of the rendered <a
610609
href="#document"><code>Document</code></a> at the time the <a
611610
href="#task">task</a> was <a href="#queue-a-task" title="queue a
612611
task">queued</a>.
@@ -621,18 +620,19 @@ <h3 id=the-stylemedia-interface><span class=secno>4.1. </span>The <code
621620
else
622621
&hellip;
623622
}
624-
styleMedia.addMediumListener("(orientation:landscape)", handleOrientationChange)</code></pre>
623+
styleMedia.addMediaListener("(orientation:landscape)", handleOrientationChange)</code></pre>
625624

626625
<p>A more generic handler for media query changes could be written as
627626
follows:</p>
628627

629628
<pre><code>function handleMediaQueryChange(query, matches) {
630629
&hellip;
631630
}
632-
function addMediumListener(query) {
633-
styleMedia.addMediumListener(query,
631+
function addMediaListener(query) {
632+
styleMedia.addMediaListener(
633+
query,
634634
function(matches) { handleMediaQueryChange(query, matches) }
635-
)
635+
)
636636
}</code></pre>
637637
</div>
638638

@@ -673,7 +673,9 @@ <h3 id=the-screen-interface><span class=secno>4.2. </span>The <code
673673
<!-- pixelDepth is not supported by Internet Explorer 7 -->
674674

675675
<p class=note>Bits allocated to handling transparency are not taken into
676-
account.
676+
account.</p>
677+
<!-- this note is there because it does not work reliably on Windows in
678+
all browsers -->
677679

678680
<h2 id=extensions-to-the-document-interface><span class=secno>5.
679681
</span>Extensions to the <code title="">Document</code> Interface</h2>

0 commit comments

Comments
 (0)