forked from w3c/csswg-drafts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcssom-view-source
More file actions
1400 lines (1084 loc) · 59.6 KB
/
cssom-view-source
File metadata and controls
1400 lines (1084 loc) · 59.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSSOM View Module</title>
<style type="text/css">
pre.idl { border:solid thin; background:#eee; color:#000; padding:0.5em }
pre.idl :link, pre.idl :visited { color:inherit; background:transparent }
dfn { font-weight:bold; font-style:normal }
div.example { margin-left:1em; padding-left:1em; border-left:double; color:#222; background:#fcfcfc }
div.example code { color:inherit }
p.note { margin-left:2em; color:green; font-style:italic; font-weight:bold }
p.note::before { content:"Note: " }
.XXX { padding:.5em; border:solid red }
.XXX::before { content:"Issue: " }
code { color:orangered }
code :link, code :visited { color:inherit }
</style>
<link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
</head>
<body class="draft">
<div class="head">
<!--logo-->
<h1 id="cssom-view-module">CSSOM View Module</h1>
<h2 class="no-num no-toc" id="w3c-doctype">[LONGSTATUS] [DATE: 3 August 2002]</h2>
<dl>
<dt>This Version:</dt>
<dd class=dontpublish><a href="http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html">http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html</a></dd>
<dd class=publish><a href="[VERSION]">[VERSION]</a></dd>
<dt class=dontpublish>Participate:</dt>
<dd class=dontpublish><a href="mailto:www-style@w3.org?subject==%5Bcssom%5D%20">www-style@w3.org</a> (<a href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
<dd class=dontpublish><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=CSS&component=CSSOM%20View">File a bug</a>
<dd class=dontpublish><a href="http://wiki.whatwg.org/wiki/IRC">IRC: #css on Freenode</a>
<dt class=publish>Latest Version:</dt>
<dd class=publish><a href="[LATEST]">[LATEST]</a></dd>
<dt class=publish>Latest Editor Draft:</dt>
<dd class=publish><a href="http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html">http://dvcs.w3.org/hg/csswg/raw-file/tip/cssom-view/Overview.html</a></dd>
<dt class=dontpublish>Previous Versions:</dt>
<dd class=dontpublish><a href="http://www.w3.org/TR/2009/WD-cssom-view-20090804/">http://www.w3.org/TR/2009/WD-cssom-view-20090804/</a></dd>
<dd class=dontpublish><a href="http://www.w3.org/TR/2008/WD-cssom-view-20080222/">http://www.w3.org/TR/2008/WD-cssom-view-20080222/</a></dd>
<dd class=dontpublish><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/</a></dd>
<dt>Editors:</dt>
<dd><a href="http://www.w3.org/wiki/User:Gadams">Glenn Adams</a>
(<a href="http://www.cox.com/">Cox Communications, Inc.</a>)
<<a href="mailto:glenn.adams@cox.com">glenn.adams@cox.com</a>></dd>
<dd><a href="">Shane Stephens</a>
(<a href="http://www.google.com/">Google, Inc.</a>)
<<a href="mailto:shans@google.com">shans@google.com</a>></dd>
<dt>Previous Editor:</dt>
<dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
<<a href="mailto:annevk@opera.com">annevk@opera.com</a>></dd>
</dl>
<p class="dontpublish copyright"><a rel=license href="http://creativecommons.org/publicdomain/zero/1.0/"><img src="http://i.creativecommons.org/p/zero/1.0/80x15.png" alt=CC0></a>
To the extent possible under law, the editors have waived all copyright and
related or neighboring rights to this work. In addition, as of
[DATE: 01 Jan 1901], the editors have made this specification available
under the <a rel=license href="http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0">Open
Web Foundation Agreement, Version 1.0</a>.</p>
<div class=publish><!--copyright--></div>
</div>
<hr>
<h2 id="abstract" class="no-num no-toc">Abstract</h2>
<p>The APIs introduced by this specification provide authors with a way to
inspect and manipulate the visual view of a document. This includes
getting the position of element layout boxes, obtaining the width
of the viewport through script, and also scrolling an element.</p>
<h2 id="sotd" class="no-num no-toc">Status of this Document</h2>
<p><em>This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
index at http://www.w3.org/TR/.</a></em>
<p>This is the [DATE: 3 August 2002] [LONGSTATUS] of CSSOM View. Please send
comments to
<a href="mailto:www-style@w3.org?subject=%5Bcssom-view%5D%20">www-style@w3.org</a>
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
with <samp>[cssom-view]</samp> at the start of the subject line.
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<p>Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite this
document as other than work in progress.
<h2 id="toc" class="no-num no-toc">Table of Contents</h2>
<!-- toc -->
<h2 id="background">Background</h2>
<p>Many of the features defined in this specification have been supported
by browsers for a long period of time. The goal of this specification is
to define these features in such a way that they can be implemented by all
browsers in an interoperable manner. The specification also defines a
couple of new features that will hopefully be useful to authors. (If they
are not you can bug us!)</p>
<h2 id="conformance">Conformance</h2>
<p>All diagrams, examples, and notes in this specification are
non-normative, as are all sections explicitly marked non-normative.
Everything else in this specification is normative.
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this document are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification. <span
data-anolis-ref>RFC2119</span>
<p>Requirements phrased in the imperative as part of algorithms
(such as "strip any leading space characters" or "return false and
terminate these steps") are to be interpreted with the meaning of the
key word ("must", "should", "may", etc) used in introducing the
algorithm.
<p>Conformance requirements phrased as algorithms or specific steps
may be implemented in any manner, so long as the end result is
equivalent. (In particular, the algorithms defined in this
specification are intended to be easy to follow, and not intended to
be performant.)
<p id="hardwareLimitations">User agents may impose
implementation-specific limits on otherwise unconstrained inputs,
e.g. to prevent denial of service attacks, to guard against running
out of memory, or to work around platform-specific limitations.
<p>When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that e.g. the author can't change the behavior by overriding attributes or methods with custom properties or functions in ECMAScript.
<p>Unless otherwise stated, string comparisons are done in a <span>case-sensitive</span> manner.
<p>A conforming user agent implements all the requirements made by this
specification.</p>
<h3 id="webidl">Web IDL</h3>
<p>The IDL fragments in this specification must be
interpreted as required for conforming IDL fragments, as described in the
Web IDL specification. <span data-anolis-ref>WEBIDL</span>
<h2 id="terminology">Terminology</h2>
<p>Terminology used in this specification is from
DOM Core,
CSSOM and
HTML.
<span data-anolis-ref>DOM</span>
<span data-anolis-ref>CSSOM</span>
<span data-anolis-ref>HTML</span>
<p class=XXX><dfn><code>MouseEvent</code></dfn> is defined in …
<p><dfn>The HTML <code>body</code> element</dfn> is the first
<code>body</code>
<span data-anolis-spec=html title="HTML elements">HTML element</span> child of the root
<span data-anolis-spec=html title="HTML elements">HTML element</span> <code>html</code>.</p>
<p><dfn id="content-edge">Content edge</dfn>,
<dfn id="padding-edge">padding edge</dfn>,
<dfn id="border-edge">border edge</dfn>, and
<dfn id="canvas">canvas</dfn> are defined by CSS.
<!--<span data-anolis-ref>CSS</span>-->
<p><dfn id="viewport">Viewport</dfn> and
<dfn id="initial-containing-block">initial containing block</dfn> are
defined by CSS 2.1 unless there is an ancestor <code>foreignObject</code>
element in the <code>http://www.w3.org/2000/svg</code> namespace in which
case that element acts as viewport and initial containing block.
<!--<span data-anolis-ref>CSS</span>-->
<p>The term <dfn>content</dfn> refers to the dimensions of the element's
content area, including overflown content.
<!--<span data-anolis-ref>CSS</span>-->
<p>The term <dfn>document content</dfn> refers to the area on the
<span>canvas</span> that is rendered upon, excluding content on negative
axis.</p>
<h3>CSS pixels</h3>
<p>All coordinates and dimensions for the APIs defined in this
specification are in CSS pixels. <!--<span data-anolis-ref>CSS</span>-->
<p class="note">This does not apply to e.g.
<code title=dom-Window-matchMedia>matchMedia()</code> as the units
are explicitly given there.</p>
<h2 id="extensions-to-the-window-interface">Extensions to the <code title>Window</code> Interface</h2>
<pre class="idl">partial interface <span data-anolis-spec=html>Window</span> {
<span>MediaQueryList</span> <span title=dom-Window-matchMedia>matchMedia</span>(DOMString <var title>media_query_list</var>);
readonly attribute <span>Screen</span> <span title=dom-Window-screen>screen</span>;
// viewport
readonly attribute long <span title=dom-Window-innerWidth>innerWidth</span>;
readonly attribute long <span title=dom-Window-innerHeight>innerHeight</span>;
// viewport scrolling
readonly attribute long <span title="dom-Window-scrollX">scrollX</span>;
readonly attribute long <span title="dom-Window-pageXOffset">pageXOffset</span>;
readonly attribute long <span title="dom-Window-scrollY">scrollY</span>;
readonly attribute long <span title="dom-Window-pageYOffset">pageYOffset</span>;
void <span title=dom-Window-scroll>scroll</span>(long <var title>x</var>, long <var title>y</var>);
void <span title=dom-Window-scrollto>scrollTo</span>(long <var title>x</var>, long <var title>y</var>);
void <span title="dom-Window-scrollby">scrollBy</span>(long <var title>x</var>, long <var title>y</var>);
// client
readonly attribute long <span title=dom-Window-screenX>screenX</span>;
readonly attribute long <span title=dom-Window-screenY>screenY</span>;
readonly attribute long <span title=dom-Window-outerWidth>outerWidth</span>;
readonly attribute long <span title=dom-Window-outerHeight>outerHeight</span>;
};</pre>
<p>When the
<dfn title="dom-Window-matchMedia"><code>matchMedia(<var title>media_query_list</var>)</code></dfn>
method is invoked these steps must be run:</p>
<ol>
<li><p>Let <var title>parsed_media_query_list</var> be the result of
<span title="parse a media query list" data-anolis-spec=cssom>parsing</span>
<var title>media_query_list</var>.</p></li>
<li><p>Return a <em>new</em> <code>MediaQueryList</code> object,
associated with the <code data-anolis-spec=html>Window</code> object, with
<var title>parsed_media_query_list</var> as its associated
media query list.</p></li>
</ol>
<p>The
<dfn title=dom-Window-screen><code>screen</code></dfn>
attribute must return the <code>Screen</code> object
associated with the <code data-anolis-spec=html>Window</code> object. It always returns the same
object.</p>
<p class="note">Accessing <code title="dom-Window-screen">screen</code> through a <code data-anolis-spec=html>WindowProxy</code> object might yield different results
when the <code data-anolis-spec=dom>Document</code> is navigated.</p>
<p>The <dfn title=dom-Window-innerWidth><code>innerWidth</code></dfn>
attribute must return the
<span>viewport</span> width including the size of a rendered scroll bar
(if any).</p>
<div class="example">
<p>The following snippet shows how to obtain the width of the
viewport:</p>
<pre><code>var viewportWidth = innerWidth</code></pre>
</div>
<p>The <dfn title=dom-Window-innerHeight><code>innerHeight</code></dfn>
attribute must return the
<span>viewport</span> height including the size of a rendered scroll bar
(if any).</p>
<p>The
<dfn title=dom-Window-scrollX><code>scrollX</code></dfn> and
<dfn title=dom-Window-pageXOffset><code>pageXOffset</code></dfn>
attributes must return the x-coordinate,
relative to the <span>initial containing block</span> origin, of the left
of the <span>viewport</span>.</p>
<p>The
<dfn title=dom-Window-scrollY><code>scrollY</code></dfn> and
<dfn title=dom-Window-pageYOffset><code>pageYOffset</code></dfn>
attributes must return the y-coordinate,
relative to the <span>initial containing block</span> origin, of the top
of the <span>viewport</span>.</p>
<p>When the
<dfn title=dom-Window-scroll><code>scroll(<var>x</var>,<var>y</var>)</code></dfn>
method is invoked these steps must be run:</p>
<ol>
<li><p>If either <var title>x</var> or <var title>y</var> is
infinite or NaN terminate this algorithm.</p></li>
<li>
<dl>
<dt>If <span>document content</span> can have overflow to the right
<dd><p>Let <var title>x</var> be max(0, min(<var title>x</var>,
<span>content</span> width - <span>content edge</span>
width)).</p></dd>
<dt>If <span>document content</span> can have overflow to the left
(under right-to-left conditions)
<dd><p>Let <var title>x</var> be min(0, max(<var title>x</var>,
<span>content edge</span> width - <span>content</span>
width)).</p></dd>
</dl>
<li><p>Let <var title>y</var> be max(0, min(<var title>y</var>,
<span>document content</span> height - <span>viewport</span>
height excluding the size of a rendered scroll bar (if any))).</p></li>
<li><p>Align the x-coordinate <var title>x</var> of the
<span>document content</span> with the left of the <span>viewport</span>
and align the y-coordinate <var title>y</var> of the <span>document
content</span> with the top of the <span>viewport</span>.</p></li>
<li><p>If the aligning caused content to move <span data-anolis-spec=html>queue a task</span>
to
<span data-anolis-spec=dom title=concept-event-fire>fire an event</span>
named <code title="event-scroll">scroll</code> that bubbles at the
<code data-anolis-spec=dom>Document</code> object, unless a
<span data-anolis-spec=html title=concept-task>task</span> to fire that event at the <code data-anolis-spec=dom>Document</code> object
was already <span data-anolis-spec=html title="queue a task">queued</span>.</p></li>
</ol>
<p>When the
<dfn title=dom-Window-scrollto><code>scrollTo(<var title>x</var>,<var title>y</var>)</code></dfn>
method is invoked, the user agent must act as if the
<code title=dom-Window-scroll>scroll()</code> method was invoked with
the same arguments.</p>
<p>When the
<dfn title=dom-Window-scrollby><code>scrollBy(<var title>x</var>,<var title>y</var>)</code></dfn>
method is invoked, the user agent must act as if the
<code title=dom-Window-scroll>scroll()</code> method was invoked with
<var title>x</var> plus <code title="dom-Window-scrollX">scrollX</code>
as first argument and <var title>y</var> plus
<code title="dom-Window-scrollY">scrollY</code> as second argument.</p>
<p>The <dfn title="dom-Window-screenX"><code>screenX</code></dfn>
attribute must return the x-coordinate,
relative to the origin of the screen of the output device, of the top of
the client window as number of pixels, or zero if there is no such
thing.</p>
<p>The <dfn title=dom-Window-screenY><code>screenY</code></dfn>
attribute must return the y-coordinate,
relative to the origin of the screen of the output device, of the left of
the client window as number of pixels, or zero if there is no such
thing.</p>
<p>The <dfn title=dom-Window-outerWidth><code>outerWidth</code></dfn>
attribute must return the width of the
client window. If there is no client window this
attribute must return zero.</p>
<p>The <dfn title=dom-Window-outerHeight><code>outerHeight</code></dfn>
attribute must return the height of the
client window. If there is no client window
this attribute must return zero.</p>
<h3 id="the-mediaquerylist-interface">The <code title>MediaQueryList</code> Interface</h3>
<p>A <code>MediaQueryList</code> object has an associated media query list
set on creation and an associated
<dfn>list of media query list listeners</dfn>, which is initially
empty.</p>
<p>If the associated media query list changes in evaluation then, for each
listener in the <span>list of media query list listeners</span> — in
appending order, <span data-anolis-spec=html>queue a task</span> that invokes the listener,
passing as argument the <code>MediaQueryList</code> object.</p>
<div class="example">
<p>A simple piece of code that detects changes in the orientation of the
viewport can be written as follows:</p>
<pre><code>function handleOrientationChange(mql) {
if(mql.matches) // landscape
…
else
…
}
var mql = matchMedia("(orientation:landscape)")
mql.addListener(handleOrientationChange)</code></pre>
</div>
<pre class="idl">interface <dfn id="mediaquerylist">MediaQueryList</dfn> {
readonly attribute DOMString <span title="dom-MediaQueryList-media">media</span>;
readonly attribute boolean <span title="dom-MediaQueryList-matches">matches</span>;
void <span title="dom-MediaQueryList-addListener">addListener</span>(<span>MediaQueryListListener</span> <var title>listener</var>);
void <span title="dom-MediaQueryList-removeListener">removeListener</span>(<span>MediaQueryListListener</span> <var title>listener</var>);
};
[Callback, NoInterfaceObject]
interface <dfn id="mediaquerylistlistener">MediaQueryListListener</dfn> {
void <span>handleChange</span>(<span>MediaQueryList</span> <var title>mql</var>);
};</pre>
<p>The
<dfn title="dom-MediaQueryList-media"><code>media</code></dfn>
must return the
<span title="serialize a media query list" data-anolis-spec=cssom>serialized</span> form of the associated media query list.</p>
<p>The <dfn title="dom-MediaQueryList-matches"><code>matches</code></dfn>
must return true if the associated media query list
matches the state of the rendered <code data-anolis-spec=dom>Document</code> and false if it
does not.</p>
<p>When the
<dfn title="dom-MediaQueryList-addListener"><code>addListener(<var>listener</var>)</code></dfn>
is invoked <var title>listener</var> must be
appended to the <span>list of media query list listeners</span>, unless
it is already in the <span>list of media query list listeners</span>.</p>
<p>When the
<dfn title="dom-MediaQueryList-removeListener"><code>removeListener(<var>listener</var>)</code></dfn>
is invoked <var title>listener</var> must be
removed from the <span>list of media query list listeners</span>.</p>
<h3 id="the-screen-interface">The <code title>Screen</code> Interface</h3>
<p>As its name suggests, the <code>Screen</code> interface represents
information about the screen of the output device.</p>
<pre class="idl">interface <dfn id="screen">Screen</dfn> {
readonly attribute unsigned long <span title=dom-Screen-availWidth>availWidth</span>;
readonly attribute unsigned long <span title=dom-Screen-availHeight>availHeight</span>;
readonly attribute unsigned long <span title=dom-Screen-width>width</span>;
readonly attribute unsigned long <span title=dom-Screen-height>height</span>;
readonly attribute unsigned long <span title=dom-Screen-colorDepth>colorDepth</span>;
readonly attribute unsigned long <span title=dom-Screen-pixelDepth>pixelDepth</span>;
};</pre>
<p>The <dfn title=dom-Screen-availWidth><code>availWidth</code></dfn>
attribute must return the available width of the
rendering surface of the output device.</p>
<p>The <dfn title=dom-Screen-availHeight><code>availHeight</code></dfn>
attribute must return the available height of the
rendering surface of the output device.</p>
<p>The <dfn title=dom-Screen-width><code>width</code></dfn> attribute
must return the width of the output device.</p>
<p>The <dfn title=dom-Screen-height><code>height</code></dfn> attribute
must return the height of the output device.</p>
<p>The <dfn title=dom-Screen-colorDepth><code>colorDepth</code></dfn> and
<dfn title=dom-Screen-pixelDepth><code>pixelDepth</code></dfn> attributes
must both return the number of bits allocated to
colors (i.e. excluding the alpha channel) in the output device. If the
output device does not support colors these attributes
must return zero.</p>
<!-- pixelDepth is not supported by Internet Explorer 7 -->
<h2 id="extensions-to-the-document-interface">Extensions to the <code title>Document</code> Interface</h2>
<pre class="idl">partial interface <span data-anolis-spec=dom>Document</span> {
<span data-anolis-spec=dom>Element</span>? <span title=dom-Document-elementFromPoint>elementFromPoint</span>(float <var title>x</var>, float <var title>y</var>);
<span>CaretPosition</span>? <span title=dom-Document-caretPositionFromPoint>caretPositionFromPoint</span>(float <var title>x</var>, float <var title>y</var>);
};</pre>
<p>The
<dfn title=dom-Document-elementFromPoint><code>elementFromPoint(<var>x</var>, <var>y</var>)</code></dfn>
method must return the element at coordinates <var>x</var>,<var>y</var> in
the <span>viewport</span>. The element to be returned is determined
through hit testing. If either argument is negative, <var title>x</var> is
greater than the <span>viewport</span> width excluding the size of a
rendered scroll bar (if any), or <var title>y</var> is greater than the
<span>viewport</span> height excluding the size of a rendered scroll bar
(if any), the method must return null. If there is no element at the given
position the method must return the root element, if any, or null
otherwise.</p>
<p>The
<dfn title=dom-Document-caretPositionFromPoint><code>caretPositionFromPoint(<var>x</var>, <var>y</var>)</code></dfn>
method must return the result of running these steps:</p>
<ol>
<li><p>If either argument is negative, <var title>x</var> is greater
than the <span>viewport</span> width excluding the size of a rendered
scroll bar (if any), <var title>y</var> is greather than the
<span>viewport</span> height excluding the size of a rendered scroll bar
(if any) return null.</p></li>
<li><p>If at the coordinates <var title>x</var>,<var title>y</var>
in the <span>viewport</span> no text insertion point indicator would have
been inserted return null.</p></li>
<li>
<p>If at the coordinates <var title>x</var>,<var title>y</var>
in the <span>viewport</span> a text insertion point indicator would have
been inserted in a text entry widget which is also a replaced element
return a <span>caret position</span> with its properties set as
follows:</p>
<dl>
<dt><span>caret node</span></dt>
<dd><p>The node corresponding to the text entry widget.</p></dd>
<dt><span>caret offset</span></dt>
<dd><p>The amount of 16-bit units to the left of where the
text insertion point indicator would have inserted.</p></dd>
<dt><span>caret range</span></dt>
<dd><p>null</p></dd>
</dl>
</li>
<li>
<p>Otherwise, return a <span>caret position</span> where the
<span>caret range</span> is a collapsed
<code data-anolis-spec=dom>Range</code> object for the position
where the text insertion point indicator would have been inserted and
the other properties are set as follows:</p>
<dl>
<dt><span>caret node</span></dt>
<dd><p>The <code data-anolis-spec=dom title=dom-Range-startContainer>startContainer</code>
of the <span>caret range</span>.</p></dd>
<dt><span>caret offset</span></dt>
<dd><p>The <code data-anolis-spec=dom title=dom-Range-startOffset>startOffset</code> of
the <span>caret range</span>.</p>
</dl>
</li>
</ol>
<p class="note">The specifics of hit testing are out of scope of this
specification and therefore the exact details of
<code title=dom-Document-elementFromPoint>elementFromPoint()</code> and
<code title=dom-Document-caretPositionFromPoint>caretPositionFromPoint()</code>
are therefore too. Hit testing will hopefully be defined in a future
revision of CSS or HTML.</p>
<h3 id=the-caretposition-interface>The <code title>CaretPosition</code> Interface</h3>
<p>A <dfn>caret position</dfn> gives the position of a
text insertion point indicator. It always has an associated
<dfn>caret node</dfn>, <dfn>caret offset</dfn>, and
<dfn>caret range</dfn>. It is represented by a <code>CaretPosition</code>
object.</p>
<pre class="idl">interface <dfn id="caretposition">CaretPosition</dfn> {
readonly attribute <span data-anolis-spec=dom>Node</span> <span title=dom-CaretPosition-offsetNode>offsetNode</span>;
readonly attribute unsigned long <span title=dom-CaretPosition-offset>offset</span>;<!--
readonly attribute <span data-anolis-spec=dom>Range</span>? <span title="dom-CaretPosition-range">range</span>;-->
};</pre>
<p>The
<dfn title=dom-CaretPosition-offsetNode><code>offsetNode</code></dfn>
attribute must return the <span>caret node</span>.</p>
<p>The
<dfn title=dom-CaretPosition-offset><code>offset</code></dfn>
attribute must return the <span>caret offset</span>.</p>
<!--
<p>The
<dfn id="dom-caretposition-range" title="dom-CaretPosition-range"><code>range</code></dfn>
attribute must return the <span>caret range</span>.</p>
-->
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
<h2 id="extensions-to-the-element-interface">Extensions to the <code title>Element</code> Interface</h2>
<pre class="idl">partial interface <span data-anolis-spec=dom>Element</span> {
<span>ClientRectList</span> <span title=dom-Element-getClientRects>getClientRects</span>();
<span>ClientRect</span> <span title=dom-Element-getBoundingClientRect>getBoundingClientRect</span>();
// scrolling
void <span title=dom-Element-scrollIntoView>scrollIntoView</span>(optional boolean <var title>top</var>);
attribute long <span title=dom-Element-scrollTop>scrollTop</span>; // scroll on setting
attribute long <span title=dom-Element-scrollLeft>scrollLeft</span>; // scroll on setting
readonly attribute long <span title=dom-Element-scrollWidth>scrollWidth</span>;
readonly attribute long <span title=dom-Element-scrollHeight>scrollHeight</span>;
readonly attribute long <span title=dom-Element-clientTop>clientTop</span>;
readonly attribute long <span title=dom-Element-clientLeft>clientLeft</span>;
readonly attribute long <span title=dom-Element-clientWidth>clientWidth</span>;
readonly attribute long <span title=dom-Element-clientHeight>clientHeight</span>;
};</pre>
<h3>The <code title>getClientRects()</code> and
<code title>getBoundingClientRect()</code> methods</h3>
<p>The <code title=dom-Element-getClientRects>getClientRects()</code> and <code title=dom-Element-getBoundingClientRect>getBoundingClientRect()</code>
methods provide information about the position of the border box edges of
an element relative to the viewport. The objects these methods return
must be static. That is, changes to the underlying
document are not reflected in the objects.</p>
<p>The
<dfn title=dom-Element-getClientRects><code>getClientRects()</code></dfn>
method, when invoked, must return the result of the
following algorithm:</p>
<ol>
<li><p>If the element on which it was invoked does not have an associated
CSS layout box and is not in the <code>http://www.w3.org/2000/svg</code>
namespace return an empty <code>ClientRectList</code> object and stop
this algorithm.</p></li>
<li><p>If the element does not have an associated CSS layout box and is
in the <code>http://www.w3.org/2000/svg</code> namespace return a
<code>ClientRectList</code> object containing a single
<code>ClientRect</code> object that describes the bounding box of the
element as defined by the SVG specification.
<span data-anolis-ref>SVG</span>
<li>
<p>Return a <code>ClientRectList</code> object containing a list of
<code>ClientRect</code> objects in content order describing the border
boxes (including those with a height or width of zero) with the
following constraints:</p>
<ul>
<li><p>If the element on which the method was invoked has a computed
value for <code>display</code> property of <code>table</code> or
<code>inline-table</code> include both the table box and the caption
box, if any, but not the anonymous container box.
<!--<span data-anolis-ref>CSS</span>-->
<li><p>Replace each
<a href="http://www.w3.org/TR/CSS21/visuren.html#anonymous-block-level">anonymous
block box</a> with its child box(es) and repeat this until no anonymous
block boxes are left in the final list.
<!--<span data-anolis-ref>CSS</span>-->
</ul>
</li>
</ol>
<p>The
<dfn title=dom-Element-getBoundingClientRect><code>getBoundingClientRect()</code></dfn>
method, when invoked, must return the result of the
following algorithm:</p>
<ol>
<li><p>Let <var>list</var> be the result of invoking
<code title=dom-Element-getClientRects>getClientRects()</code> on the
same element this method was invoked on.</p></li>
<li><p>If the <var>list</var> is empty return a <code>ClientRect</code>
object whose <code title=dom-ClientRect-top>top</code>,
<code title=dom-ClientRect-right>right</code>,
<code title=dom-ClientRect-bottom>bottom</code> and
<code title=dom-ClientRect-left>left</code> members are zero.</p></li>
<li><p>Otherwise, return a <code>ClientRect</code> object describing the
smallest rectangle that includes the first rectangle in <var>list</var>
and all of the remaining rectangles of which the height or width is not
zero.</p></li>
</ol>
<div class="example">
<p>The following snippet gets the dimensions of the first
<code>div</code> element in a document:</p>
<pre><code>var example = document.getElementsByTagName("div")[0].getBoundingClientRect();
var exampleWidth = example.width;
var exampleHeight = example.height;</code></pre>
</div>
<h3><code title>Element</code> Scrolling Members</h3>
<p>To <dfn>scroll an element into view</dfn>, optionally with an
<i title>align to top flag</i> set, means to run these steps for each
ancestor element or <span>viewport</span> that establishes a
scrolling box, in order of innermost to outermost scrolling box:</p>
<ol>
<li><p>If the <code data-anolis-spec=dom>Document</code> associated
with the element to be
scrolled into view is not <span data-anolis-spec=html>same origin</span> with the
<code data-anolis-spec=dom>Document</code> associated with the element or
<span>viewport</span> associated with the scrolling box, terminate these
steps.</p></li>
<li><p>If the <i title>align to top flag</i> is set align the top of
the border box of the element to be scrolled into view with the top of
the scrolling box.</p></li>
<li><p>Otherwise, if the <i title>align to top flag</i> is not set
align the bottom of the border box of the element to be scrolled into
view with the bottom of the scrolling box.</p></li>
<li><p>Align the left of the border box of the element to be scrolled
into view with the left of the scrolling box.</p</li>
<!-- RTL is not special cased in implementations?! -->
<li><p>If the aligning did not cause content to move terminate these
steps.</p></li>
<li>
<dl>
<dt>If the scrolling box is associated with an element</dt>
<dd><p><span data-anolis-spec=html>Queue a task</span> to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span>
named <code title="event-scroll">scroll</code> at the element
associated with the scrolling box, unless a <span data-anolis-spec=html title=concept-task>task</span> to fire
that event at that element was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></dd>
<dt>If the scrolling box is associated with a <span>viewport</span></dt>
<dd><p><span data-anolis-spec=html>Queue a task</span> to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span>
named <code title="event-scroll">scroll</code> that bubbles at the
<code data-anolis-spec=dom>Document</code> object associated with the <span>viewport</span>,
unless a <span data-anolis-spec=html title=concept-task>task</span> to fire that event at that
<code data-anolis-spec=dom>Document</code> object was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></dd>
</dl>
</li>
</ol>
<p>To <dfn>scroll an element</dfn> to <var title>x</var>,<var title>y</var> means to:</p>
<ol>
<li><p>If either <var title>x</var> or <var title>y</var> is
infinite or NaN terminate this algorithm.</p>
<li>
<dl>
<dt>If the element can have overflow to the right</dt>
<dd><p>Let <var title>x</var> be max(0, min(<var title>x</var>,
<span>content</span> width -
<span>content edge</span> width)).</p></dd>
<dt>If the element can have overflow to the left (under right-to-left
conditions)</dt>
<dd><p>Let <var title>x</var> be min(0, max(<var title>x</var>,
<span>content edge</span> width -
<span>content</span> width)).</p></dd>
</dl>
</li>
<li><p>Let <var title>y</var> be max(0, min(<var title>y</var>,
<span>content</span> height - <span>content edge</span> height)).</p></li>
<li><p>Align <span>content</span> x-coordinate <var title>x</var> with
the left of the <span>content edge</span> of the element and align
<span>content</span> y-coordinate <var title>y</var> with
the top of the <span>content edge</span> of the element.</p></li>
<li><p>If the aligning caused content to move <span data-anolis-spec=html>queue a task</span>
to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span> named
<code title="event-scroll">scroll</code> at the element, unless a
<span data-anolis-spec=html title=concept-task>task</span> to fire that event at that element was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></li>
</ol>
<p>The
<dfn title=dom-Element-scrollIntoView><code>scrollIntoView([<var>top</var>])</code></dfn>
method must run these steps:</p>
<ol>
<li><p>If the element does not have any associated CSS layout box
terminate these steps.</p></li>
<li><p><span title="scroll an element into view">Scroll the element into view</span>
with the <i title>align to top flag</i> set if <var title>top</var>
is true or omitted.</p></li>
</ol>
<p>The <dfn title=dom-Element-scrollTop><code>scrollTop</code></dfn>
attribute must return the result of running these
steps:</p>
<ol>
<li><p>If the element does not have any associated CSS layout box or the
element is the root element and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span> return zero and terminate these steps.</p></li>
<li><p>If the element is the root element return the value of
<code title="dom-Window-scrollY">scrollY</code>.</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
the <code data-anolis-spec=dom>Document</code> is in <span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, and the element
does not have any overflow, return the value of
<code title=dom-Window-scrollY>scrollY</code>.</p></li>
<li><p>Return the y-coordinate of the <span>content</span> at the
alignment point with the top of the <span>content edge</span> of the
element.</p></li>
</ol>
<p>When setting the <code title=dom-Element-scrollTop>scrollTop</code>
attribute these steps must be run:</p>
<ol>
<li><p>Let <var title>y</var> be the given value.</p></li>
<li><p>If the element does not have any associated CSS layout box, the
element is the root element and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, or the element has no overflow, terminate these
steps.</p></li>
<li><p>If the element is the root element invoke
<code title=dom-Window-scroll>scroll()</code> with zero as first
argument and <var title>y</var> as second.</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
the <code data-anolis-spec=dom>Document</code> is in <span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, and the element
does not have any vertical overflow, invoke
<code title=dom-Window-scroll>scroll()</code> with
<code title=dom-Window-scrollX>scrollX</code> as first
argument and <var title>y</var> as second.</p></li>
<li><p><span title="scroll an element">Scroll the element</span> to
<code title=dom-Element-scrollLeft>scrollLeft</code>,<var title>y</var>.
</ol>
<p>The <dfn title=dom-Element-scrollLeft><code>scrollLeft</code></dfn>
attribute must return the result of running these
steps:</p>
<ol>
<li><p>If the element does not have any associated CSS layout box or the
element is the root element and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span> return zero and terminate these steps.</p></li>
<li><p>If the element is the root element return the value of
<code title=dom-Window-scrollX>scrollX</code>.</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
the <code data-anolis-spec=dom>Document</code> is in <span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, and the element
does not have any overflow, return the value of
<code title=dom-Window-scrollX>scrollX</code>.</p></li>
<li><p>Return the x-coordinate of the <span>content</span> at the
alignment point with the left of the <span>content edge</span> of the
element.</p></li>
</ol>
<p>When setting the <code title=dom-Element-scrollLeft>scrollLeft</code> attribute these steps
must be run:</p>
<ol>
<li><p>Let <var title>x</var> be the given value.</p></li>
<li><p>If the element does not have any associated CSS layout box, the
element is the root element and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, or the element has no overflow, terminate these
steps.</p></li>
<li><p>If the element is the root element invoke
<code title=dom-Window-scroll>scroll()</code> with
<var title>x</var> as first argument and zero as second.</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>,
the <code data-anolis-spec=dom>Document</code> is in <span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>, and the element
does not have any vertical overflow, invoke
<code title="dom-Window-scroll">scroll()</code> with
<var title>x</var> as first argument and
<code title=dom-Window-scrollY>scrollY</code> as second.</p></li>
<li><p><span title="Scroll an element">Scroll the element</span> to
<var title>x</var>,<code title=dom-Element-scrollTop>scrollTop</code>.
</ol>
<p>The <dfn title=dom-Element-scrollWidth><code>scrollWidth</code></dfn>
attribute must return the result of running these
steps:</p>
<ol>
<li><p>If the element does not have any associated CSS layout box return
zero and terminate these steps.</p></li>
<li><p>If the element is the root element and the
<code data-anolis-spec=dom>Document</code> is not in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>
return
max(<span>document content</span> width, value of <code title=dom-Window-innerWidth>innerWidth</code>).</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>
and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>
return
max(<span>document content</span> width, value of <code title=dom-Window-innerWidth>innerWidth</code>).</p></li>
<li><p>Return the computed value of the '<code>padding-left</code>'
property, plus the computed value of the '<code>padding-right</code>',
plus the <span>content</span> width of the element.</p></li>
</ol>
<p>The <dfn title=dom-Element-scrollHeight><code>scrollHeight</code></dfn>
attribute must return the result of running these
steps:</p>
<ol>
<li><p>If the element does not have any associated CSS layout box return
zero and terminate these steps.</p></li>
<li><p>If the element is the root element and the
<code data-anolis-spec=dom>Document</code> is not in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>
return
max(<span>document content</span> height, value of <code title=dom-Window-innerHeight>innerHeight</code>).</p></li>
<li><p>If the element is <span>the HTML <code>body</code> element</span>
and the <code data-anolis-spec=dom>Document</code> is in
<span data-anolis-spec=dom title=concept-quirks-mode>quirks mode</span>
return
max(<span>document content</span> height, value of <code title=dom-Window-innerHeight>innerHeight</code>).</p></li>
<li><p>Return the computed value of the '<code>padding-top</code>'
property, plus the computed value of the '<code>padding-bottom</code>',
plus the <span>content</span> height of the element.</p></li>
</ol>
<!-- for inline boxes offsetWidth and offsetHeight are identical to offset* -->
<h3 id="client-attributes">The <code title>clientTop</code>,
<code title>clientLeft</code>, <code title>clientWidth</code>, and
<code title>clientHeight</code> attributes</h3>
<p>The <dfn title=dom-Element-clientTop><code>clientTop</code></dfn>,
<dfn title=dom-Element-clientLeft><code>clientLeft</code></dfn>,
<dfn title=dom-Element-clientWidth><code>clientWidth</code></dfn>, and
<dfn title=dom-Element-clientHeight><code>clientHeight</code></dfn>
attributes must return zero if the element does not
have any associated CSS layout box or if the CSS layout box is inline.
Otherwise, these attributes must behave as defined in
the remainder of this section.</p>
<p>The <code title=dom-Element-clientTop>clientTop</code> attribute returns the computed value of the
'<code>border-top-width</code>' property plus the width of any scrollbar
rendered between the top <span>padding edge</span> and the top
<span>border edge</span>.</p>
<p>The <code title=dom-Element-clientLeft>clientLeft</code> attribute returns the computed
value of the '<code>border-left-width</code>' property plus the width of
any scrollbar rendered between the left <span>padding edge</span> and the
left <span>border edge</span>.
<p>The <code title=dom-Element-clientWidth>clientWidth</code> attribute returns the
<span>viewport</span> width excluding the size of a rendered scroll bar
(if any) if the element is the root element and the
width of the <span>padding edge</span> (excluding the width of any
rendered scrollbar between the <span>padding edge</span> and the
<span>border edge</span>) otherwise.</p>
<p>The <code title=dom-Element-clientHeight>clientHeight</code> attribute returns the
<span>viewport</span> height excluding the size of a rendered scroll bar
(if any) if the element is the root element and the
height of the <span>padding edge</span> (excluding the width of any
rendered scrollbar between the <span>padding edge</span> and the
<span>border edge</span>) otherwise.</p>
<h2 id="extensions-to-the-htmlelement-interface">Extensions to the <code title>HTMLElement</code> Interface</h2>
<pre class="idl">partial interface <span data-anolis-spec=html>HTMLElement</span> {
readonly attribute Element <span title=dom-HTMLElement-offsetParent>offsetParent</span>;
readonly attribute long <span title=dom-HTMLElement-offsetTop>offsetTop</span>;