-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
1555 lines (1251 loc) · 67.4 KB
/
Overview.html
File metadata and controls
1555 lines (1251 loc) · 67.4 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 PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang=en-US>
<head>
<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: " }
em.ct { font-weight:bold; font-style:normal }
code { color:orangered }
code :link, code :visited { color:inherit }
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel=stylesheet>
<body class=draft>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1 id=cssom-view-module>CSSOM View Module</h1>
<h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 25 August 2010</h2>
<dl>
<dt>This Version:
<dd><a
href="http://www.w3.org/TR/2010/ED-cssom-view-20100825/">http://www.w3.org/TR/2010/ED-cssom-view-20100825/</a>
<dt>Latest Version:
<dd><a
href="http://www.w3.org/TR/cssom-view/">http://www.w3.org/TR/cssom-view/</a>
<dt>Latest Editor Version:
<dd><a
href="http://dev.w3.org/csswg/cssom-view/">http://dev.w3.org/csswg/cssom-view/</a>
<dt>Previous Versions:
<dd><a
href="http://www.w3.org/TR/2009/WD-cssom-view-20090804/">http://www.w3.org/TR/2009/WD-cssom-view-20090804/</a>
<dd><a
href="http://www.w3.org/TR/2008/WD-cssom-view-20080222/">http://www.w3.org/TR/2008/WD-cssom-view-20080222/</a>
<dt>Editor:
<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>>
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2010 <a
href="http://www.w3.org/"><acronym title="World Wide Web
Consortium">W3C</acronym></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute
of Technology">MIT</acronym></a>, <a href="http://www.ercim.eu/"><acronym
title="European Research Consortium for Informatics and
Mathematics">ERCIM</acronym></a>, <a
href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright--></div>
<hr>
<h2 class="no-num no-toc" id=abstract>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.
<h2 class="no-num no-toc" id=sotd>Status of this Document</h2>
<!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcssom-view%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“cssom-view” in the subject, preferably like this:
“[<!---->cssom-view<!---->] <em>…summary of
comment…</em>”
<p>This document was produced by the <a href="/Style/CSS/members">CSS
Working Group</a> (part of the <a href="/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent
Policy</a>. W3C maintains a <a href="/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="/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the
W3C Patent Policy</a>.</p>
<!--end-status-->
<h2 class="no-num no-toc" id=toc>Table of Contents</h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#background"><span class=secno>1. </span>Background</a>
<li><a href="#conformance"><span class=secno>2. </span>Conformance
Criteria</a>
<ul class=toc>
<li><a href="#webidl"><span class=secno>2.1. </span>Web IDL</a>
<li><a href="#terminology"><span class=secno>2.2. </span>Terminology</a>
<li><a href="#css-pixels"><span class=secno>2.3. </span>CSS pixels</a>
</ul>
<li><a href="#extensions-to-the-window-interface"><span class=secno>3.
</span>Extensions to the <code title="">Window</code> Interface</a>
<ul class=toc>
<li><a href="#the-mediaquerylist-interface"><span class=secno>3.1.
</span>The <code title="">MediaQueryList</code> Interface</a>
<li><a href="#the-screen-interface"><span class=secno>3.2. </span>The
<code title="">Screen</code> Interface</a>
</ul>
<li><a href="#extensions-to-the-document-interface"><span class=secno>4.
</span>Extensions to the <code title="">Document</code> Interface</a>
<ul class=toc>
<li><a href="#the-caretposition-interface"><span class=secno>4.1.
</span>The <code title="">CaretPosition</code> Interface</a>
</ul>
<li><a href="#extensions-to-the-element-interface"><span class=secno>5.
</span>Extensions to the <code title="">Element</code> Interface</a>
<ul class=toc>
<li><a href="#the-getclientrects-and-getboundingclient"><span
class=secno>5.1. </span>The <code title="">getClientRects()</code> and
<code title="">getBoundingClientRect()</code> methods</a>
<li><a href="#scroll-attributes"><span class=secno>5.2. </span>The <code
title="">scrollTop</code>, <code title="">scrollLeft</code>, <code
title="">scrollWidth</code>, and <code title="">scrollHeight</code>
attributes</a>
<li><a href="#client-attributes"><span class=secno>5.3. </span>The <code
title="">clientTop</code>, <code title="">clientLeft</code>, <code
title="">clientWidth</code>, and <code title="">clientHeight</code>
attributes</a>
</ul>
<li><a href="#extensions-to-the-htmlelement-interface"><span
class=secno>6. </span>Extensions to the <code title="">HTMLElement</code>
Interface</a>
<ul class=toc>
<li><a href="#offset-attributes"><span class=secno>6.1. </span>The <code
title="">offsetParent</code>, <code title="">offsetTop</code>, <code
title="">offsetLeft</code>, <code title="">offsetWidth</code>, and
<code title="">offsetHeight</code> attributes</a>
</ul>
<li><a href="#extensions-to-the-range-interface"><span class=secno>7.
</span>Extensions to the <code title="">Range</code> Interface</a>
<li><a href="#extensions-to-the-mouseevent-interface"><span class=secno>8.
</span>Extensions to the <code title="">MouseEvent</code> Interface</a>
<li><a href="#rectangles"><span class=secno>9. </span>Rectangles</a>
<ul class=toc>
<li><a href="#the-clientrectlist-interface"><span class=secno>9.1.
</span>The <code title="">ClientRectList</code> Interface</a>
<li><a href="#the-clientrect-interface"><span class=secno>9.2.
</span>The <code title="">ClientRect</code> Interface</a>
</ul>
<li class=no-num><a href="#references">References</a>
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
</ul>
<!--end-toc-->
<h2 id=background><span class=secno>1. </span>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!)
<h2 id=conformance><span class=secno>2. </span>Conformance Criteria</h2>
<p>Everything in this specification is normative except for diagrams,
examples, notes and sections marked non-normative.</p>
<!--<p>The key word <em class="ct">must</em>, <em class="ct">must not</em>,
<em class="ct">should</em> and <em class="ct">may</em> in this document
are to be interpreted as described in RFC 2119.-->
<p>The key word <em class=ct>must</em> in this document is to be
interpreted as described in RFC 2119. [<cite><a
href="#ref-rfc2119">RFC2119</a></cite>]
<p>A conforming user agent implements all the requirements made by this
specification.
<h3 id=webidl><span class=secno>2.1. </span>Web IDL</h3>
<p>The IDL fragments in this specification <em class=ct>must</em> be
interpreted as required for conforming IDL fragments, as described in the
Web IDL specification. [<cite><a href="#ref-webidl">WebIDL</a></cite>]
<h3 id=terminology><span class=secno>2.2. </span>Terminology</h3>
<p><dfn id=document><code>Document</code></dfn> and <dfn
id=element><code>Element</code></dfn> are defined by DOM Level 3 Core.
[<cite><a href="#ref-dom3core">DOM3Core</a></cite>]
<p><dfn id=range><code>Range</code></dfn> is defined in DOM Level 2
Traversal and Range. [<cite><a href="#ref-dom2tr">DOM2TR</a></cite>]
<p><dfn id=mouseevent><code>MouseEvent</code></dfn> is defined in DOM Level
2 Events. [<cite><a href="#ref-dom2events">DOM2Events</a></cite>]
<p> <dfn id=compare-lists-of-media-queries>Compare lists of media
queries</dfn> and <dfn id=parse-a-list-of-media-queries>parse a list of
media queries</dfn> are defined by the CSSOM. [<cite><a
href="#ref-cssom">CSSOM</a></cite>]
<p> <dfn id=fire-a-simple-event title="Fire a simple event">Firing a simple
event named <var title="">e</var></dfn>, <dfn id=html-element>HTML
element</dfn>, <dfn id=htmlelement><code>HTMLElement</code></dfn>, <dfn
id=queue-a-task>queue a task</dfn>, <dfn id=quirks-mode>quirks mode</dfn>,
<dfn id=task>task</dfn>, and <dfn id=window><code>Window</code></dfn> are
defined by HTML5. [<cite><a href="#ref-html5">HTML5</a></cite>]
<p><dfn id=the-html-body-element>The HTML <code>body</code> element</dfn>
is the first <code>body</code> <a href="#html-element">HTML element</a>
child of the root <a href="#html-element">HTML element</a>
<code>html</code>.
<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 2.1. [<cite><a
href="#ref-css21">CSS21</a></cite>]
<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. [<cite><a
href="#ref-css21">CSS21</a></cite>] [<cite><a
href="#ref-svg">SVG</a></cite>]
<p>The term <dfn id=content>content</dfn> refers to the dimensions of the
element's content area, including overflown content. [<cite><a
href="#ref-css21">CSS21</a></cite>]
<p>The term <dfn id=document-content>document content</dfn> refers to the
area on the <a href="#canvas">canvas</a> that is rendered upon, excluding
content on negative axis.
<h3 id=css-pixels><span class=secno>2.3. </span>CSS pixels</h3>
<p>All coordinates and dimensions for the APIs defined in this
specification are in CSS pixels. [<cite><a
href="#ref-css21">CSS21</a></cite>]
<p class=note>This does not apply to e.g. <a
href="#dom-window-matchmedia"><code
title=dom-Window-matchMedia>matchMedia()</code></a> as the units are
explicitly given there.
<h2 id=extensions-to-the-window-interface><span class=secno>3.
</span>Extensions to the <code title="">Window</code> Interface</h2>
<pre class=idl>[Supplemental] interface <a href="#window">Window</a> {
<a href="#mediaquerylist">MediaQueryList</a> <span>matchMedia</span>(DOMString <var title="">media_query_list</var>);
readonly attribute <a href="#screen">Screen</a> <a href="#dom-window-screen" title=dom-Window-screen>screen</a>;
// viewport
readonly attribute long <a href="#dom-window-innerwidth">innerWidth</a>;
readonly attribute long <a href="#dom-window-innerheight">innerHeight</a>;
readonly attribute long <a href="#dom-window-pagexoffset">pageXOffset</a>;
readonly attribute long <a href="#dom-window-pageyoffset">pageYOffset</a>;
void <a href="#dom-window-scroll" title=dom-Window-scroll>scroll</a>(long <var title="">x</var>, long <var title="">y</var>);
void <a href="#dom-window-scrollto" title=dom-Window-scrollto>scrollTo</a>(long <var title="">x</var>, long <var title="">y</var>);
void <a href="#dom-window-scrollby" title=dom-Window-scrollby>scrollBy</a>(long <var title="">x</var>, long <var title="">y</var>);
// client
readonly attribute long <a href="#dom-window-screenx">screenX</a>;
readonly attribute long <a href="#dom-window-screeny">screenY</a>;
readonly attribute long <a href="#dom-window-outerwidth">outerWidth</a>;
readonly attribute long <a href="#dom-window-outerheight">outerHeight</a>;
};</pre>
<p>When the <dfn id=dom-window-matchmedia
title=dom-Window-matchMedia><code>matchMedia(<var
title="">media_query_list</var>)</code></dfn> method is invoked these
steps must be run:
<ol>
<li>
<p>Let <var title="">parsed_media_query_list</var> be the result of <a
href="#parse-a-list-of-media-queries" title="parse a list of media
queries">parsing</a> <var title="">media_query_list</var>.
<li>
<p>Return a <em>new</em> <a
href="#mediaquerylist"><code>MediaQueryList</code></a> object,
associated with the <a href="#window"><code>Window</code></a> object,
with <var title="">parsed_media_query_list</var> as its associated media
query list.
</ol>
<p>The <dfn id=dom-window-screen
title=dom-Window-screen><code>screen</code></dfn> attribute <em
class=ct>must</em> return the <a href="#screen"><code>Screen</code></a>
object associated with the <a href="#window"><code>Window</code></a>
object. It always returns the same object.
<p class=note>Accessing <a href="#dom-window-screen"><code
title=dom-Window-screen>screen</code></a> through a
<code>WindowProxy</code> object might yield different results when the <a
href="#document"><code>Document</code></a> is navigated.
<p>The <dfn id=dom-window-innerwidth><code>innerWidth</code></dfn>
attribute <em class=ct>must</em> return the <a
href="#viewport">viewport</a> width including the size of a rendered
scroll bar (if any).
<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 id=dom-window-innerheight><code>innerHeight</code></dfn>
attribute <em class=ct>must</em> return the <a
href="#viewport">viewport</a> height including the size of a rendered
scroll bar (if any).
<p>The <dfn id=dom-window-pagexoffset><code>pageXOffset</code></dfn>
attribute <em class=ct>must</em> return the x-coordinate, relative to the
<a href="#initial-containing-block">initial containing block</a> origin,
of the left of the <a href="#viewport">viewport</a>.
<p>The <dfn id=dom-window-pageyoffset><code>pageYOffset</code></dfn>
attribute <em class=ct>must</em> return the y-coordinate, relative to the
<a href="#initial-containing-block">initial containing block</a> origin,
of the top of the <a href="#viewport">viewport</a>.
<p>When the <dfn id=dom-window-scroll
title=dom-Window-scroll><code>scroll(<var title="">x</var>,<var
title="">y</var>)</code></dfn> method is invoked these steps <em
class=ct>must</em> be run:
<ol>
<li>
<p>If either <var title="">x</var> or <var title="">y</var> is infinite
or NaN stop this algorithm.
<li>
<dl>
<dt>If <a href="#document-content">document content</a> can have
overflow to the right
<dd>
<ol>
<li>
<p>Let <var title="">x</var> be min(<var title="">x</var>, <a
href="#content">content</a> width - <a href="#content-edge">content
edge</a> width).
<li>
<p>If <var title="">x</var> is negative let it be zero.
</ol>
<dt>If <a href="#document-content">document content</a> can have
overflow to the left (under right-to-left conditions)
<dd>
<ol>
<li>
<p>Let <var title="">x</var> be max(<var title="">x</var>, <a
href="#content-edge">content edge</a> width - <a
href="#content">content</a> width).
<li>
<p>If <var title="">x</var> is non-negative let it be zero.
</ol>
</dl>
<li>
<p>Let <var title="">y</var> be min(<var title="">y</var>, <a
href="#document-content">document content</a> height - <a
href="#viewport">viewport</a> height excluding the size of a rendered
scroll bar (if any)).
<li>
<p>If <var title="">y</var> is negative let it be zero.
<li>
<p>Align the x-coordinate <var title="">x</var> of the <a
href="#document-content">document content</a> with the left of the <a
href="#viewport">viewport</a> and align the y-coordinate <var
title="">y</var> of the <a href="#document-content">document content</a>
with the top of the <a href="#viewport">viewport</a>.
<li>
<p>If the aligning caused content to move <a href="#queue-a-task">queue a
task</a> to <a href="#fire-a-simple-event">fire a simple event</a> named
<code title=event-scroll>scroll</code> that bubbles at the <a
href="#document"><code>Document</code></a> object, unless a <a
href="#task">task</a> to fire that event at the <a
href="#document"><code>Document</code></a> object was already <a
href="#queue-a-task" title="queue a task">queued</a>.
</ol>
<p>When the <dfn id=dom-window-scrollto
title=dom-Window-scrollto><code>scrollTo(<var title="">x</var>,<var
title="">y</var>)</code></dfn> method is invoked, the user agent <em
class=ct>must</em> act as if the <a href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> method was invoked with the
same arguments.
<p>When the <dfn id=dom-window-scrollby
title=dom-Window-scrollby><code>scrollBy(<var title="">x</var>,<var
title="">y</var>)</code></dfn> method is invoked, the user agent <em
class=ct>must</em> act as if the <a href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> method was invoked with <var
title="">x</var> plus <a
href="#dom-window-pagexoffset"><code>pageXOffset</code></a> as first
argument and <var title="">y</var> plus <a
href="#dom-window-pageyoffset"><code>pageYOffset</code></a> as second
argument.
<p>The <dfn id=dom-window-screenx><code>screenX</code></dfn> attribute <em
class=ct>must</em> 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>The <dfn id=dom-window-screeny><code>screenY</code></dfn> attribute <em
class=ct>must</em> 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>The <dfn id=dom-window-outerwidth><code>outerWidth</code></dfn>
attribute <em class=ct>must</em> return the width of the client window. If
there is no client window this attribute <em class=ct>must</em> return
zero.
<p>The <dfn id=dom-window-outerheight><code>outerHeight</code></dfn>
attribute <em class=ct>must</em> return the height of the client window.
If there is no client window this attribute <em class=ct>must</em> return
zero.
<h3 id=the-mediaquerylist-interface><span class=secno>3.1. </span>The <code
title="">MediaQueryList</code> Interface</h3>
<p>A <a href="#mediaquerylist"><code>MediaQueryList</code></a> object has
an associated media query list set on creation and an associated <dfn
id=list-of-media-query-list-listeners>list of media query list
listeners</dfn>, which is initially empty.
<p>If the associated media query list changes in evaluation then, for each
listener in the <a href="#list-of-media-query-list-listeners">list of
media query list listeners</a> — in appending order, <a
href="#queue-a-task">queue a task</a> that invokes the listener, passing
as argument whether the associated list of media queries matches the state
of the rendered <a href="#document"><code>Document</code></a> at the time
the <a href="#task">task</a> was <a href="#queue-a-task" title="queue a
task">queued</a>.
<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(landscape) {
if(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 <a href="#dom-MediaQueryList-media" title=dom-MediaQueryList-media>media</a>;
readonly attribute DOMString <a href="#dom-MediaQueryList-matches" title=dom-MediaQueryList-matches>matches</a>;
void <a href="#dom-mediaquerylist-addlistener" title=dom-MediaQueryList-addListener>addListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> <var title="">listener</var>);
void <a href="#dom-mediaquerylist-removelistener" title=dom-MediaQueryList-removeListener>removeListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> <var title="">listener</var>);
};
[Callback=FunctionOnly, NoInterfaceObject]
interface <dfn id=mediaquerylistlistener>MediaQueryListListener</dfn> {
void <span>handleChange</span>(boolean <var title="">matches</var>);
};</pre>
<p>The <dfn id=dom-MediaQueryList-media
title=dom-MediaQueryList-media><code>media</code></dfn> <em
class=ct>must</em> return the <span title="serialize a media query
list">serialized</span> form of the associated media query list.
<p>The <dfn id=dom-MediaQueryList-matches
title=dom-MediaQueryList-matches><code>matches</code></dfn> <em
class=ct>must</em> return true if the associated media query list matches
the state of the rendered <a href="#document"><code>Document</code></a>
and false if it does not.
<p>When the <dfn id=dom-mediaquerylist-addlistener
title=dom-MediaQueryList-addListener><code>addListener(<var
title="">listener</var>)</code></dfn> is invoked <var
title="">listener</var> <em class=ct>must</em> be appended to the <a
href="#list-of-media-query-list-listeners">list of media query list
listeners</a>.
<p>When the <dfn id=dom-mediaquerylist-removelistener
title=dom-MediaQueryList-removeListener><code>removeListener(<var
title="">listener</var>)</code></dfn> is invoked the last listener in the
<a href="#list-of-media-query-list-listeners">list of media query list
listeners</a> that matches <var title="">listener</var> <e class=ct>must
be removed from the <a href="#list-of-media-query-list-listeners">list of
media query list listeners</a>.</e>
<h3 id=the-screen-interface><span class=secno>3.2. </span>The <code
title="">Screen</code> Interface</h3>
<p>As its name suggests, the <a href="#screen"><code>Screen</code></a>
interface represents information about the screen of the output device.
<pre class=idl>interface <dfn id=screen>Screen</dfn> {
readonly attribute unsigned long <a href="#dom-screen-availwidth">availWidth</a>;
readonly attribute unsigned long <a href="#dom-screen-availheight">availHeight</a>;
readonly attribute unsigned long <a href="#dom-screen-width">width</a>;
readonly attribute unsigned long <a href="#dom-screen-height">height</a>;
readonly attribute unsigned long <a href="#dom-screen-colordepth">colorDepth</a>;
readonly attribute unsigned long <a href="#dom-screen-pixeldepth">pixelDepth</a>;
};</pre>
<p>The <dfn id=dom-screen-availwidth><code>availWidth</code></dfn>
attribute <em class=ct>must</em> return the available width of the
rendering surface of the output device.
<p>The <dfn id=dom-screen-availheight><code>availHeight</code></dfn>
attribute <em class=ct>must</em> return the available height of the
rendering surface of the output device.
<p>The <dfn id=dom-screen-width><code>width</code></dfn> attribute <em
class=ct>must</em> return the width of the output device.
<p>The <dfn id=dom-screen-height><code>height</code></dfn> attribute <em
class=ct>must</em> return the height of the output device.
<p>The <dfn id=dom-screen-colordepth><code>colorDepth</code></dfn> and <dfn
id=dom-screen-pixeldepth><code>pixelDepth</code></dfn> attributes <em
class=ct>must</em> 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 <em class=ct>must</em>
return zero.</p>
<!-- pixelDepth is not supported by Internet Explorer 7 -->
<h2 id=extensions-to-the-document-interface><span class=secno>4.
</span>Extensions to the <code title="">Document</code> Interface</h2>
<pre class=idl>[Supplemental] interface <a href="#document">Document</a> {
Element <a href="#dom-document-elementfrompoint">elementFromPoint</a>(float <var title="">x</var>, float <var title="">y</var>);
<a href="#caretposition">CaretPosition</a> <a href="#dom-document-caretpositionfrompoint">caretPositionFromPoint</a>(float <var title="">x</var>, float <var title="">y</var>);
};</pre>
<p>The <dfn id=dom-document-elementfrompoint
title=elementfrompoint><code>elementFromPoint(<var title="">x</var>, <var
title="">y</var>)</code></dfn> method, when invoked, <em
class=ct>must</em> return the element at coordinates
<var>x</var>,<var>y</var> in the <a href="#viewport">viewport</a>. The
element to be returned is determined through hit testing. If either
argument is negative, <var title="">x</var> is greater than the <a
href="#viewport">viewport</a> width excluding the size of a rendered
scroll bar (if any), or <var title="">y</var> is greather than the <a
href="#viewport">viewport</a> height excluding the size of a rendered
scroll bar (if any), the method <em class=ct>must</em> return
<code>null</code>. If there is no element at the given position the method
<em class=ct>must</em> return the root element, if any, or
<code>null</code> otherwise.
<p>The <dfn id=dom-document-caretpositionfrompoint
title=caretpositionfrompoint><code>caretPositionFromPoint(<var
title="">x</var>, <var title="">y</var>)</code></dfn> method, when
invoked, <em class=ct>must</em> return the result of running these steps:
<ol>
<li>
<p>If either argument is negative, <var title="">x</var> is greater than
the <a href="#viewport">viewport</a> width excluding the size of a
rendered scroll bar (if any), <var title="">y</var> is greather than the
<a href="#viewport">viewport</a> height excluding the size of a rendered
scroll bar (if any) return null.
<li>
<p>If at the coordinates <var title="">x</var>,<var title="">y</var> in
the <a href="#viewport">viewport</a> no text insertion point indicator
would have been inserted return null.
<li>
<p>If at the coordinates <var title="">x</var>,<var title="">y</var> in
the <a href="#viewport">viewport</a> a text insertion point indicator
would have been inserted in a text entry widget which is also a replaced
element return a <a href="#caret-position">caret position</a> with its
properties set as follows:</p>
<dl>
<dt><a href="#caret-node">caret node</a>
<dd>
<p>The node corresponding to the text entry widget.
<dt><a href="#caret-offset">caret offset</a>
<dd>
<p>The amount of 16-bit units to the left of where the text insertion
point indicator would have inserted.
<dt><a href="#caret-range">caret range</a>
<dd>
<p>null
</dl>
<li>
<p>Otherwise, return a <a href="#caret-position">caret position</a> where
the <a href="#caret-range">caret range</a> is a collapsed <a
href="#range"><code>Range</code></a> 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><a href="#caret-node">caret node</a>
<dd>
<p>The <code title=dom-Range-startContainer>startContainer</code> of
the <a href="#caret-range">caret range</a>.
<dt><a href="#caret-offset">caret offset</a>
<dd>
<p>The <code title=dom-Range-startOffset>startOffset</code> of the <a
href="#caret-range">caret range</a>.</p>
</dl>
</ol>
<p class=note>The specifics of hit testing are out of scope of this
specification and therefore the exact details of <a
href="#dom-document-elementfrompoint"><code>elementFromPoint()</code></a>
and <a
href="#dom-document-caretpositionfrompoint"><code>caretPositionFromPoint()</code></a>
are therefore too. Hit testing will hopefully be defined in a future
revision of CSS or HTML.
<h3 id=the-caretposition-interface><span class=secno>4.1. </span>The <code
title="">CaretPosition</code> Interface</h3>
<p>A <dfn id=caret-position>caret position</dfn> gives the position of a
text insertion point indicator. It always has an associated <dfn
id=caret-node>caret node</dfn>, <dfn id=caret-offset>caret offset</dfn>,
and <dfn id=caret-range>caret range</dfn>. It is represented by a <a
href="#caretposition"><code>CaretPosition</code></a> object.
<pre class=idl>interface <dfn id=caretposition>CaretPosition</dfn> {
readonly attribute <span>Node</span> <a href="#dom-caretposition-offsetnode" title=dom-CaretPosition-offsetNode>offsetNode</a>;
readonly attribute unsigned long <a href="#dom-caretposition-offset" title=dom-CaretPosition-offset>offset</a>;
readonly attribute <a href="#range">Range</a> <a href="#dom-caretposition-range" title=dom-CaretPosition-range>range</a>;
};</pre>
<p>The <dfn id=dom-caretposition-offsetnode
title=dom-CaretPosition-offsetNode><code>offsetNode</code></dfn> attribute
<em class=ct>must</em> return the <a href="#caret-node">caret node</a>.
<p>The <dfn id=dom-caretposition-offset
title=dom-CaretPosition-offset><code>offset</code></dfn> attribute <em
class=ct>must</em> return the <a href="#caret-offset">caret offset</a>.
<p>The <dfn id=dom-caretposition-range
title=dom-CaretPosition-range><code>range</code></dfn> attribute <em
class=ct>must</em> return the <a href="#caret-range">caret range</a>.</p>
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
<h2 id=extensions-to-the-element-interface><span class=secno>5.
</span>Extensions to the <code title="">Element</code> Interface</h2>
<pre class=idl>[Supplemental] interface <a href="#element">Element</a> {
<a href="#clientrectlist">ClientRectList</a> <a href="#dom-element-getclientrects">getClientRects</a>();
<a href="#clientrect">ClientRect</a> <a href="#dom-element-getboundingclientrect">getBoundingClientRect</a>();
attribute long <a href="#dom-element-scrolltop">scrollTop</a>; // scroll on setting
attribute long <a href="#dom-element-scrollleft">scrollLeft</a>; // scroll on setting
readonly attribute long <a href="#dom-element-scrollwidth">scrollWidth</a>;
readonly attribute long <a href="#dom-element-scrollheight">scrollHeight</a>;
readonly attribute long <a href="#dom-element-clienttop">clientTop</a>;
readonly attribute long <a href="#dom-element-clientleft">clientLeft</a>;
readonly attribute long <a href="#dom-element-clientwidth">clientWidth</a>;
readonly attribute long <a href="#dom-element-clientheight">clientHeight</a>;
};</pre>
<h3 id=the-getclientrects-and-getboundingclient><span class=secno>5.1.
</span>The <code title="">getClientRects()</code> and <code
title="">getBoundingClientRect()</code> methods</h3>
<p>The <a
href="#dom-element-getclientrects"><code>getClientRects()</code></a> and
<a
href="#dom-element-getboundingclientrect"><code>getBoundingClientRect()</code></a>
methods provide information about the position of the border box edges of
an element relative to the viewport. The objects these methods return <em
class=ct>must</em> be static. That is, changes to the underlying document
are not reflected in the objects.
<p>The <dfn
id=dom-element-getclientrects><code>getClientRects()</code></dfn> method,
when invoked, <em class=ct>must</em> return the result of the following
algorithm:
<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 <a
href="#clientrectlist"><code>ClientRectList</code></a> object and stop
this algorithm.
<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 <a
href="#clientrectlist"><code>ClientRectList</code></a> object containing
a single <a href="#clientrect"><code>ClientRect</code></a> object that
describes the bounding box of the element as defined by the SVG
specification. [<cite><a href="#ref-svg">SVG</a></cite>]
<li>
<p>Return a <a href="#clientrectlist"><code>ClientRectList</code></a>
object containing a list of <a
href="#clientrect"><code>ClientRect</code></a> 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. [<cite><a
href="#ref-css21">CSS21</a></cite>]
<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. [<cite><a
href="#ref-css21">CSS21</a></cite>]
</ul>
</ol>
<p>The <dfn
id=dom-element-getboundingclientrect><code>getBoundingClientRect()</code></dfn>
method, when invoked, <em class=ct>must</em> return the result of the
following algorithm:
<ol>
<li>
<p>Let <var>list</var> be the result of invoking <a
href="#dom-element-getclientrects"><code>getClientRects()</code></a> on
the same element this method was invoked on.
<li>
<p>If the <var>list</var> is empty return a <a
href="#clientrect"><code>ClientRect</code></a> object whose <a
href="#dom-clientrect-top"><code
title=dom-clientrect-top>top</code></a>, <a
href="#dom-clientrect-right"><code
title=dom-clientrect-right>right</code></a>, <a
href="#dom-clientrect-bottom"><code
title=dom-clientrect-bottom>bottom</code></a> and <a
href="#dom-clientrect-left"><code
title=dom-clientrect-left>left</code></a> members are zero.
<li>
<p>Otherwise, return a <a href="#clientrect"><code>ClientRect</code></a>
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.
</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 id=scroll-attributes><span class=secno>5.2. </span>The <code
title="">scrollTop</code>, <code title="">scrollLeft</code>, <code
title="">scrollWidth</code>, and <code title="">scrollHeight</code>
attributes</h3>
<p>The <dfn id=dom-element-scrolltop><code>scrollTop</code></dfn> attribute
<em class=ct>must</em> return the result of running these steps:
<ol>
<li>
<p>If the element does not have any associated CSS layout box or the
element is the root element and the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a> return zero and terminate these
steps.
<li>
<p>If the element is the root element return the value of <a
href="#dom-window-pageyoffset"><code>pageYOffset</code></a>.
<li>
<p>If the element is <a href="#the-html-body-element">the HTML
<code>body</code> element</a>, the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, and the element does not have any
overflow, return the value of <a
href="#dom-window-pageyoffset"><code>pageYOffset</code></a>.
<li>
<p>Return the y-coordinate of the <a href="#content">content</a> at the
alignment point with the top of the <a href="#content-edge">content
edge</a> of the element.
</ol>
<p>When setting the <a
href="#dom-element-scrolltop"><code>scrollTop</code></a> attribute these
steps <em class=ct>must</em> be run:
<ol>
<li>
<p>Let <var title="">y</var> be the given value.
<li>
<p>If the element does not have any associated CSS layout box, the
element is the root element and the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, or the element has no overflow,
terminate these steps.
<li>
<p>If the element is the root element invoke <a
href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> with zero as first argument
and <var title="">y</var> as second.
<li>
<p>If the element is <a href="#the-html-body-element">the HTML
<code>body</code> element</a>, the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, and the element does not have any
vertical overflow, invoke <a href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> with zero as first argument
and <var title="">y</var> as second.
<li>
<p>If <var title="">y</var> is infinite or NaN stop this algorithm.</p>
<li>
<p>Let <var title="">y</var> be max(0, min(<var title="">y</var>, <a
href="#content">content</a> height - <a href="#content-edge">content
edge</a> height)).
<li>
<p>Align <a href="#content">content</a> y-coordinate <var
title="">y</var> with the top of the <a href="#content-edge">content
edge</a> of the element.
<li>
<p>If the aligning caused content to move <a href="#queue-a-task">queue a
task</a> to <a href="#fire-a-simple-event">fire a simple event</a> named
<code title=event-scroll>scroll</code> at the element, unless a <a
href="#task">task</a> to fire that event at the element was already <a
href="#queue-a-task" title="queue a task">queued</a>.
</ol>
<p>The <dfn id=dom-element-scrollleft><code>scrollLeft</code></dfn>
attribute <em class=ct>must</em> return the result of running these steps:
<ol>
<li>
<p>If the element does not have any associated CSS layout box or the
element is the root element and the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a> return zero and terminate these
steps.
<li>
<p>If the element is the root element return the value of <a
href="#dom-window-pagexoffset"><code>pageXOffset</code></a>.
<li>
<p>If the element is <a href="#the-html-body-element">the HTML
<code>body</code> element</a>, the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, and the element does not have any
overflow, return the value of <a
href="#dom-window-pagexoffset"><code>pageXOffset</code></a>.
<li>
<p>Return the x-coordinate of the <a href="#content">content</a> at the
alignment point with the left of the <a href="#content-edge">content
edge</a> of the element.
</ol>
<p>When setting the <a
href="#dom-element-scrollleft"><code>scrollLeft</code></a> attribute these
steps <em class=ct>must</em> be run:
<ol>
<li>
<p>Let <var title="">x</var> be the given value.
<li>
<p>If the element does not have any associated CSS layout box, the
element is the root element and the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, or the element has no overflow,
terminate these steps.
<li>
<p>If the element is the root element invoke <a
href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> with <var title="">x</var>
as first argument and zero as second.
<li>
<p>If the element is <a href="#the-html-body-element">the HTML
<code>body</code> element</a>, the <a
href="#document"><code>Document</code></a> is in <a
href="#quirks-mode">quirks mode</a>, and the element does not have any
vertical overflow, invoke <a href="#dom-window-scroll"><code
title=dom-Window-scroll>scroll()</code></a> with <var title="">x</var>
as first argument and zero as second.
<li>
<p>If <var title="">x</var> is infinite or NaN stop this algorithm.</p>
<li>
<dl>
<dt>If the element can have overflow to the right
<dd>
<p>Let <var title="">x</var> be max(0, min(<var title="">x</var>, <a
href="#content">content</a> width - <a href="#content-edge">content
edge</a> width)).
<dt>If the element 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>, <a
href="#content-edge">content edge</a> width - <a
href="#content">content</a> width)).
</dl>
<li>
<p>Align <a href="#content">content</a> x-coordinate <var
title="">x</var> with the left of the <a href="#content-edge">content
edge</a> of <var>A</var>.
<li>
<p>If the aligning caused content to move <a href="#queue-a-task">queue a
task</a> to <a href="#fire-a-simple-event">fire a simple event</a> named