-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathOverview.html
More file actions
1387 lines (1109 loc) · 60.1 KB
/
Overview.html
File metadata and controls
1387 lines (1109 loc) · 60.1 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: " }
.issue { padding:.5em; border:solid red }
.issue::before { content:"Issue: " }
xem.ct { text-transform:lowercase; font-variant:small-caps; font-style:normal }
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 24 April 2008</h2>
<dl>
<dt>This Version:
<dd><a
href="http://www.w3.org/TR/2008/ED-cssom-view-20080424/">http://www.w3.org/TR/2008/ED-cssom-view-20080424/</a>
<dt>Latest Version:
<dd><a
href="http://www.w3.org/TR/cssom-view/">http://www.w3.org/TR/cssom-view/</a>
<dt>Previous Versions:
<dd><a
href="http://www.w3.org/TR/2008/WD-cssom-view-20080222/">http://www.w3.org/TR/2008/WD-cssom-view-20080222/</a>
<dd><a
href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Views-20001113/</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> © 2008 <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.org/"><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.
<p>The CSSOM View Module also supercedes DOM Level 2 Views and therefore
defines the <code><a href="#abstractview">AbstractView</a></code> and
<code><a href="#documentview">DocumentView</a></code> interfaces and
extensions for them.
<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. It probably contains errors.
Its publication here does not imply endorsement of its contents by W3C.
<!--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="#dependencies"><span class=secno>2.1
</span>Dependencies</a>
<li><a href="#terminology"><span class=secno>2.2 </span>Terminology</a>
</ul>
<li><a href="#dom-features"><span class=secno>3. </span>DOM Features</a>
<li><a href="#the-abstractview-interface"><span class=secno>4. </span>The
<code title="">AbstractView</code> Interface</a>
<ul class=toc>
<li><a href="#the-media-interface"><span class=secno>4.1 </span>The
<code title="">Media</code> Interface</a>
</ul>
<li><a href="#the-screenview-interface"><span class=secno>5. </span>The
<code title="">ScreenView</code> Interface</a>
<ul class=toc>
<li><a href="#the-screen-interface"><span class=secno>5.1 </span>The
<code title="">Screen</code> Interface</a>
</ul>
<li><a href="#the-documentview-interface"><span class=secno>6. </span>The
<code title="">DocumentView</code> Interface</a>
<li><a href="#the-elementview-interface"><span class=secno>7. </span>The
<code title="">ElementView</code> Interface</a>
<ul class=toc>
<li><a href="#the-getclientrects"><span class=secno>7.1 </span>The <code
title="">getClientRects()</code> and <code
title="">getBoundingClientRect()</code> methods</a>
<li><a href="#scroll-attributes"><span class=secno>7.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>7.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="#the-htmlelementview-interface"><span class=secno>8.
</span>The <code title="">HTMLElementView</code> Interface</a>
<ul class=toc>
<li><a href="#offset-attributes"><span class=secno>8.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="#the-rangeview-interface"><span class=secno>9. </span>The
<code title="">RangeView</code> Interface</a>
<li><a href="#the-mouseeventview-interface"><span class=secno>10.
</span>The <code title="">MouseEventView</code> Interface</a>
<li><a href="#rectangles"><span class=secno>11. </span>Rectangles</a>
<ul class=toc>
<li><a href="#the-clientrectlist-interface"><span class=secno>11.1
</span>The <code title="">ClientRectList</code> Interface</a>
<li><a href="#the-clientrect-interface"><span class=secno>11.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 identical way without differences between no quirks,
limited quirks and no quirks mode, as defined by HTML 5. [<cite><a
href="#ref-html5">HTML5</a></cite>]
<p>As well as serving as a specification for that "de facto" standard this
specification also obsoletes DOM Level 2 Views by taking the concepts
defined in that specification, making them more concrete, and integrating
them with the various "de facto" concepts.
<p>Finally, the specification defines a couple of new features that the CSS
WG considers to be useful for authors.
<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=dependencies><span class=secno>2.1 </span>Dependencies</h3>
<p>This specification depends on several definitions and features defined
in the HTML 5 specification. [<cite><a
href="#ref-html5">HTML5</a></cite>]
<p>This specification also depends on several features defined in the DOM
Level 2 Events and DOM Level 3 Core specifications. [<cite><a
href="#ref-dom2events">DOM2Events</a></cite>] [<cite><a
href="#ref-dom3core">DOM3Core</a></cite>]
<h3 id=terminology><span class=secno>2.2 </span>Terminology</h3>
<p>The terms <dfn id=html-element>HTML element</dfn>, <dfn
id=view>view</dfn> and <dfn id=default>default view</dfn> are defined by
HTML 5. [<cite><a href="#ref-html5">HTML5</a></cite>]
<p><dfn id=the-html>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>The terms <dfn id=css-pixel>CSS pixel</dfn>, <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>The terms <dfn id=viewport>viewport</dfn>, <dfn
id=initial-containing-block>initial containing block</dfn> are defined by
CSS 2.1 unless there's 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>document content</dfn> refers to the area on
the <a href="#canvas">canvas</a> that is rendered upon, excluding content
on negative axis.
<h2 id=dom-features><span class=secno>3. </span>DOM Features</h2>
<p>This specification defines the <a
href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#DOMFeatures">DOM
feature</a> "<code>Views</code>" for versions "<code>2.0</code>" and
"<code>3.0</code>". User agents supporting this specification <em
class=ct>must</em> support that feature and versions. [<cite><a
href="#ref-dom3core">DOM3Core</a></cite>]
<p>Authors are encouraged to stay away from DOM features as user agents
claiming to support the DOM feature might not support the feature you need
and user agents supporting parts of the specification might not claim
support for the DOM feature.
<h2 id=the-abstractview-interface><span class=secno>4. </span>The <code
title="">AbstractView</code> Interface</h2>
<p>The <code><a href="#abstractview">AbstractView</a></code> interface is a
base interface that all <a href="#view" title=view>views</a> <em
class=ct>must</em> derive from.
<pre class=idl>interface <dfn id=abstractview>AbstractView</dfn> {
readonly attribute <a href="#documentview">DocumentView</a> <a href="#abstractview-document" title=abstractview-document>document</a>;
readonly attribute <a href="#media">Media</a> <a href="#abstractview-media" title=abstractview-media>media</a>;
};</pre>
<p>The <dfn id=abstractview-document
title=abstractview-document><code>document</code></dfn> attribute, on
getting, <em class=ct>must</em> return the object implementing the
<code><a href="#documentview">DocumentView</a></code> interface that is
associated with the <a href="#view">view</a>.
<p>The <dfn id=abstractview-media
title=abstractview-media><code>media</code></dfn> attribute, on getting,
<em class=ct>must</em> return an object implementing the <code><a
href="#media">Media</a></code> interface. It <em class=ct>must</em> always
return the same object.
<h3 id=the-media-interface><span class=secno>4.1 </span>The <code
title="">Media</code> Interface</h3>
<pre class=idl>interface <dfn id=media>Media</dfn> {
readonly attribute DOMString <a href="#media-type">type</a>;
boolean <a href="#media-matchmedium" title=media-matchmedium>matchMedium</a>(in DOMString <var title="">mediaquery</var>);
};</pre>
<p>The <dfn id=media-type><code>type</code></dfn> attribute, on getting,
<em class=ct>must</em> return the string that represents the media type of
the current <a href="#view">view</a> used for rendering the
<code>Document</code>. The media types are defined by CSS 2.1 (<code
title="">screen</code>, <code>print</code>, et cetera). [<cite><a
href="#ref-css21">CSS21</a></cite>]
<div class=example>
<p>The following snippet determines whether the page is rendered using the
projection media type:</p>
<pre><code>var isProjection = media.type == "projection"</code></pre>
</div>
<p>The <dfn id=media-matchmedium
title=media-matchmedium><code>matchMedium(<var>mediaquery</var>)</code></dfn>
method, when invoked, <em class=ct>must</em> return the result of the
following algorithm:
<ol>
<li>
<p>If <var title="">mediaquery</var> can be parsed according to the rules
given in the Media Queries specification and matches the state of the
current <a href="#view">view</a> return <code>true</code> and terminate
this algorithm. [<cite><a href="#ref-mq">MQ</a></cite>]
<li>
<p>Otherwise, return <code>false</code>.
</ol>
<div class=example>
<p>The following snippet determines whether the device is a color device:</p>
<pre><code>var isColorDevice = media.matchMedium("(color)")</code></pre>
</div>
<h2 id=the-screenview-interface><span class=secno>5. </span>The <code
title="">ScreenView</code> Interface</h2>
<p>An object implementing the <code><a
href="#screenview">ScreenView</a></code> interface represents a <a
href="#view">view</a> for visual media. If the <a href="#default">default
view</a> is visual the <span
title=documentview-defaultview>defaultView</span> attribute on the
<code>Document</code> object <em class=ct>must</em> return an object
implementing this interface.
<pre
class=idl>interface <dfn id=screenview>ScreenView</dfn> : <a href="#abstractview">AbstractView</a> {
// viewport
readonly attribute long <a href="#screenview-innerwidth">innerWidth</a>;
readonly attribute long <a href="#screenview-innerheight">innerHeight</a>;
readonly attribute long <a href="#screenview-pagexoffset">pageXOffset</a>;
readonly attribute long <a href="#screenview-pageyoffset">pageYOffset</a>;
void <a href="#screenview-scroll" title=screenview-scroll>scroll</a>(in long <var title="">x</var>, in long <var title="">y</var>);
void <a href="#screenview-scrollto" title=screenview-scrollto>scrollTo</a>(in long <var title="">x</var>, in long <var title="">y</var>);
void <a href="#screenview-scrollby" title=screenview-scrollby>scrollBy</a>(in long <var title="">x</var>, in long <var title="">y</var>);
// client
readonly attribute long <a href="#screenview-screenx">screenX</a>;
readonly attribute long <a href="#screenview-screeny">screenY</a>;
readonly attribute long <a href="#screenview-outerwidth">outerWidth</a>;
readonly attribute long <a href="#screenview-outerheight">outerHeight</a>;
// output device
readonly attribute <a href="#screen">Screen</a> <a href="#screenview-screen" title=screenview-screen>screen</a>;
};</pre>
<p>All coordinates and dimensions on the <a
href="#screenview">ScreenView</a> interface are expressed in <a
href="#css-pixel" title="CSS pixel">CSS pixels</a>.
<p>The <dfn id=screenview-innerwidth><code>innerWidth</code></dfn>
attribute, on getting, <em class=ct>must</em> return the <a
href="#viewport">viewport</a> width.
<div class=example>
<p>The following snippet shows how to obtain the width of the viewport,
including the rendered scrollbar:</p>
<pre><code>var viewportWidth = innerWidth</code></pre>
</div>
<p>The <dfn id=screenview-innerheight><code>innerHeight</code></dfn>
attribute, on getting, <em class=ct>must</em> return the <a
href="#viewport">viewport</a> height.
<p>The <dfn id=screenview-pagexoffset><code>pageXOffset</code></dfn>
attribute, on getting, <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=screenview-pageyoffset><code>pageYOffset</code></dfn>
attribute, on getting, <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=screenview-scroll
title=screenview-scroll><code>scroll(<var title="">x</var>,<var
title="">y</var>)</code></dfn> method is invoked, the user agent <em
class=ct>must</em> run the following algorithm:
<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">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">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">document content</a> height - <a
href="#viewport">viewport</a> height).
<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">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">document content</a> with
the top of the <a href="#viewport">viewport</a>.
</ol>
<p>When the <dfn id=screenview-scrollto
title=screenview-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 <code title=screenview-scroll><a
href="#screenview-scroll">scroll()</a></code> method was invoked with the
same arguments.
<p>When the <dfn id=screenview-scrollby
title=screenview-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 <code title=screenview-scroll><a
href="#screenview-scroll">scroll()</a></code> method was invoked with <var
title="">x</var> plus <code><a
href="#screenview-pagexoffset">pageXOffset</a></code> as first argument
and <var title="">y</var> plus <code><a
href="#screenview-pageyoffset">pageYOffset</a></code> as second argument.
<p>The <dfn id=screenview-screenx><code>screenX</code></dfn> attribute, on
getting, <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=screenview-screeny><code>screenY</code></dfn> attribute, on
getting, <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=screenview-outerwidth><code>outerWidth</code></dfn>
attribute, on getting, <em class=ct>must</em> return the width of the
client window as number of CSS pixels. If there is no client window this
attribute <em class=ct>must</em> return zero.
<p>The <dfn id=screenview-outerheight><code>outerHeight</code></dfn>
attribute, on getting, <em class=ct>must</em> return the height of the
client window as number of CSS pixels. If there is no client window this
attribute <em class=ct>must</em> return zero.
<p>The <dfn id=screenview-screen
title=screenview-screen><code>screen</code></dfn> attribute, on getting,
<em class=ct>must</em> return an object implementing the <code><a
href="#screen">Screen</a></code> interface. It <em class=ct>must</em>
always return the same object.
<h3 id=the-screen-interface><span class=secno>5.1 </span>The <code
title="">Screen</code> Interface</h3>
<p>As its name suggests, the <code><a href="#screen">Screen</a></code>
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="#screen-availwidth">availWidth</a>;
readonly attribute unsigned long <a href="#screen-availheight">availHeight</a>;
readonly attribute unsigned long <a href="#screen-width">width</a>;
readonly attribute unsigned long <a href="#screen-height">height</a>;
readonly attribute unsigned long <a href="#screen-colordepth">colorDepth</a>;
readonly attribute unsigned long <a href="#screen-pixeldepth">pixelDepth</a>;
};</pre>
<p>All coordinates and dimensions on the <a href="#screen">Screen</a>
interface are expressed in <a href="#css-pixel" title="CSS pixel">CSS
pixels</a>.
<p>The <dfn id=screen-availwidth><code>availWidth</code></dfn> attribute,
on getting, <em class=ct>must</em> return the available width of the
rendering surface of the output device.
<p>The <dfn id=screen-availheight><code>availHeight</code></dfn> attribute,
on getting, <em class=ct>must</em> return the available height of the
rendering surface of the output device.
<p>The <dfn id=screen-width><code>width</code></dfn> attribute, on getting,
<em class=ct>must</em> return the width of the output device.
<p>The <dfn id=screen-height><code>height</code></dfn> attribute, on
getting, <em class=ct>must</em> return the height of the output device.
<p>The <dfn id=screen-colordepth><code>colorDepth</code></dfn> and <dfn
id=screen-pixeldepth><code>pixelDepth</code></dfn> attributes <em
class=ct>must</em> both return the number of bits allocated to colors 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 -->
<p class=note>Bits allocated to handling transparancy are not taken into
account.
<h2 id=the-documentview-interface><span class=secno>6. </span>The <code
title="">DocumentView</code> Interface</h2>
<p>Objects implementing the <code>Document</code> interface, as defined in
DOM Level 3 Core, <em class=ct>must</em> also implement the <code><a
href="#documentview">DocumentView</a></code> interface. [<cite><a
href="#ref-dom3core">DOM3Core</a></cite>]
<pre class=idl>interface <dfn id=documentview>DocumentView</dfn> {
readonly attribute <a href="#abstractview">AbstractView</a> <a href="#documentview-defaultview">defaultView</a>;
Element <a href="#documentview-elementfrompoint">elementFromPoint</a>(in float <var title="">x</var>, in float <var title="">y</var>);
Range <a href="#documentview-caretrangefrompoint">caretRangeFromPoint</a>(in float <var title="">x</var>, in float <var title="">y</var>);
};</pre>
<p>The <dfn id=documentview-defaultview><code>defaultView</code></dfn>
attribute, on getting, <em class=ct>must</em> return an object
implementing the <code><a href="#abstractview">AbstractView</a></code>
interface that is the <a href="#default">default view</a> for this
document. If there is no default view available this attribute <em
class=ct>must</em> return <code>null</code>.
<p>The <dfn id=documentview-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, or <var title="">y</var> is greather
than the <a href="#viewport">viewport</a> height, 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=documentview-caretrangefrompoint
title=caretrangefrompoint><code>caretRangeFromPoint(<var title="">x</var>,
<var title="">y</var>)</code></dfn> method, when invoked, <em
class=ct>must</em> return an empty text range for the position where a
text insertion point indicator would have been inserted if editing was
enabled and hit testing was performed at the coordinates
<var>x</var>,<var>y</var> in the <a href="#viewport">viewport</a>. If
either argument is negative, <var title="">x</var> is greater than the <a
href="#viewport">viewport</a> width, <var title="">y</var> is greather
than the <a href="#viewport">viewport</a> height, no insertion point
indicator would have been inserted, or editing is not supported, the
method <em class=ct>must</em> return <code>null</code>. [<cite><a
href="#ref-dom2tr">DOM2TR</a></cite>]
<p class=note>The specifics of hit testing are out of scope of this
specification and therefore the exact details of <code><a
href="#documentview-elementfrompoint">elementFromPoint()</a></code> and
<code><a
href="#documentview-caretrangefrompoint">caretRangeFromPoint()</a></code>
are too. Hit testing might be defined in a future revision of CSS or
HTML 5.
<h2 id=the-elementview-interface><span class=secno>7. </span>The <code
title="">ElementView</code> Interface</h2>
<p>Objects implementing the <code>Element</code> interface, as defined by
DOM Level 3 Core, <em class=ct>must</em> also implement the <code><a
href="#elementview">ElementView</a></code> interface. [<cite><a
href="#ref-dom3core">DOM3Core</a></cite>]
<pre class=idl>interface <dfn id=elementview>ElementView</dfn> {
<a href="#clientrectlist">ClientRectList</a> <a href="#elementview-getclientrects">getClientRects</a>();
<a href="#clientrect">ClientRect</a> <a href="#elementview-getboundingclientrect">getBoundingClientRect</a>();
attribute long <a href="#elementview-scrolltop">scrollTop</a>; // scroll on setting
attribute long <a href="#elementview-scrollleft">scrollLeft</a>; // scroll on setting
readonly attribute long <a href="#elementview-scrollwidth">scrollWidth</a>;
readonly attribute long <a href="#elementview-scrollheight">scrollHeight</a>;
readonly attribute long <a href="#elementview-clienttop">clientTop</a>;
readonly attribute long <a href="#elementview-clientleft">clientLeft</a>;
readonly attribute long <a href="#elementview-clientwidth">clientWidth</a>;
readonly attribute long <a href="#elementview-clientheight">clientHeight</a>;
};</pre>
<h3 id=the-getclientrects><span class=secno>7.1 </span>The <code
title="">getClientRects()</code> and <code
title="">getBoundingClientRect()</code> methods</h3>
<p>The <code><a
href="#elementview-getclientrects">getClientRects()</a></code> and
<code><a
href="#elementview-getboundingclientrect">getBoundingClientRect</a></code>
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=elementview-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 return an empty <code><a
href="#clientrectlist">ClientRectList</a></code> object and stop this
algorithm.
<li>
<p>If the element is in the <code>http://www.w3.org/2000/svg</code>
namespace return a <code><a
href="#clientrectlist">ClientRectList</a></code> object containing a
single <code><a href="#clientrect">ClientRect</a></code> object that
describes the bounding box of the element as defined by SVG
specification. [<cite><a href="#ref-svg">SVG</a></cite>]
<li>
<p>Return a <code><a href="#clientrectlist">ClientRectList</a></code>
object containing a list of <code><a
href="#clientrect">ClientRect</a></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. [<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=elementview-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 <code><a
href="#elementview-getclientrects">getClientRects()</a></code> on the
same element this method was invoked on.
<li>
<p>If the <var>list</var> is empty return a <code><a
href="#clientrect">ClientRect</a></code> object whose <code
title=clientrect-top><a href="#clientrect-top">top</a></code>, <code
title=clientrect-right><a href="#clientrect-right">right</a></code>,
<code title=clientrect-bottom><a
href="#clientrect-bottom">bottom</a></code> and <code
title=clientrect-left><a href="#clientrect-left">left</a></code> members
are zero.
<li>
<p>Otherwise, return a <code><a href="#clientrect">ClientRect</a></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.
</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>7.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=elementview-scrolltop><code>scrollTop</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return the value that is the result of running the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box return zero
and stop this algorithm.
<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 <var>A</var>.
</ol>
<p>When setting the <code><a
href="#elementview-scrolltop">scrollTop</a></code> attribute to <var
title="">y</var> on element <var>A</var> user agents <em
class=ct>must</em> run the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box or vertical
overflow stop this algorithm.
<li>
<p>If <var title="">y</var> is infinite or NaN stop this algorithm.</p>
<li>
<p>Let <var title="">y</var> be min(<var title="">y</var>, <a
href="#content">content</a> height - <a href="#content-edge">content
edge</a> height).
<li>
<p>If <var title="">y</var> is negative let it be zero.
<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 <var>A</var>.
</ol>
<p>The <dfn id=elementview-scrollleft><code>scrollLeft</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return the value that is the result of running the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box return zero
and stop this algorithm.
<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 <var>A</var>.
</ol>
<p>When setting the <code><a
href="#elementview-scrollleft">scrollLeft</a></code> attribute to <var
title="">x</var> on element <var>A</var> user agents <em
class=ct>must</em> run the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box or
horizontal overflow stop this algorithm.
<li>
<p>If <var title="">x</var> is infinite or NaN stop this algorithm.</p>
<li>
<dl>
<dt>If <var>A</var> 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 <var>A</var> 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>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>.
</ol>
<p>The <dfn id=elementview-scrollwidth><code>scrollWidth</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return value that is the result of the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box return zero
and stop this algorithm.
<li>
<p>Return the computed value of the <code>padding-left</code> property of
<var>A</var>, plus the computed value of the <code>padding-right</code>
property of <var>A</var>, plus the <a href="#content">content</a> width
of <var>A</var>.
</ol>
<p>The <dfn id=elementview-scrollheight><code>scrollHeight</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return value that is the result of the following algorithm:
<ol>
<li>
<p>If <var>A</var> does not have an associated CSS layout box return zero
and stop this algorithm.
<li>
<p>Return the computed value of the <code>padding-top</code> property of
<var>A</var>, plus the computed value of the <code>padding-bottom</code>
property of <var>A</var>, plus the <a href="#content">content</a> height
of <var>A</var>.
</ol>
<!-- for inline boxes offsetWidth and offsetHeight are identical to offset* -->
<h3 id=client-attributes><span class=secno>7.3 </span>The <code
title="">clientTop</code>, <code title="">clientLeft</code>, <code
title="">clientWidth</code>, and <code title="">clientHeight</code>
attributes</h3>
<p>The <dfn id=elementview-clienttop><code>clientTop</code></dfn>, <dfn
id=elementview-clientleft><code>clientLeft</code></dfn>, <dfn
id=elementview-clientwidth><code>clientWidth</code></dfn>, and <dfn
id=elementview-clientheight><code>clientHeight</code></dfn> attributes, on
getting, <em class=ct>must</em> return zero if the element does not have
an associated CSS layout box or if the layout box is inline. Otherwise,
these attributes <em class=ct>must</em> behave as defined in the remainder
of this section.
<p>On getting, the <code><a
href="#elementview-clienttop">clientTop</a></code> attribute returns the
computed value of the <code>border-top-width</code> property plus the
width of any scrollbar rendered between the top <a
href="#padding-edge">padding edge</a> and the top <a
href="#border-edge">border edge</a>.
<p>On getting, the <code><a
href="#elementview-clientleft">clientLeft</a></code> attribute returns the
computed value of the <code>border-left-width</code> property plus the
width of any scrollbar rendered between the left <a
href="#padding-edge">padding edge</a> and the left <a
href="#border-edge">border edge</a>.
<p>On getting, the <code><a
href="#elementview-clientwidth">clientWidth</a></code> attribute returns
the <a href="#viewport">viewport</a> width if the element is the root
element and the width of the <a href="#padding-edge">padding edge</a>
(excluding the width of any rendered scrollbar between the <a
href="#padding-edge">padding edge</a> and the <a
href="#border-edge">border edge</a>) otherwise.
<p>On getting, the <code><a
href="#elementview-clientheight">clientHeight</a></code> attribute returns
the <a href="#viewport">viewport</a> height if the element is the root
element and the height of the <a href="#padding-edge">padding edge</a>
(excluding the width of any rendered scrollbar between the <a
href="#padding-edge">padding edge</a> and the <a
href="#border-edge">border edge</a>) otherwise.
<h2 id=the-htmlelementview-interface><span class=secno>8. </span>The <code
title="">HTMLElementView</code> Interface</h2>
<p>Objects implementing the <code>HTMLElement</code> interface, as defined
by HTML 5, <em class=ct>must</em> also implement the <code><a
href="#htmlelementview">HTMLElementView</a></code> interface. [<cite><a
href="#ref-html5">HTML5</a></cite>]
<pre class=idl>interface <dfn id=htmlelementview>HTMLElementView</dfn> {
readonly attribute Element <a href="#htmlelementview-offsetparent">offsetParent</a>;
readonly attribute long <a href="#htmlelementview-offsettop">offsetTop</a>;
readonly attribute long <a href="#htmlelementview-offsetleft">offsetLeft</a>;
readonly attribute long <a href="#htmlelementview-offsetwidth">offsetWidth</a>;
readonly attribute long <a href="#htmlelementview-offsetheight">offsetHeight</a>;
};</pre>
<p>All coordinates and dimensions on the <code><a
href="#htmlelementview">HTMLElementView</a></code> interface are expressed
in <a href="#css-pixel" title="CSS pixel">CSS pixels</a>.
<h3 id=offset-attributes><span class=secno>8.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</h3>
<p>The <dfn id=htmlelementview-offsetparent><code>offsetParent</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return the element determined by the following algorithm:
<ol>
<li>
<p>If any of the following holds true return <code>null</code> and stop
this algorithm:</p>
<ul>
<li><var>A</var> is the root element.
<li><var>A</var> is <a href="#the-html">the HTML <code>body</code>
element</a>.
<li>The computed value of the <code>position</code> property for element
<var>A</var> is <code>fixed</code>.
</ul>
<li>
<p>If <var>A</var> is an <code>area</code> <a href="#html-element">HTML
element</a> which has a <code>map</code> <a href="#html-element">HTML
element</a> somewhere in the ancestor chain return the nearest ancestor
<code>map</code> <a href="#html-element">HTML element</a> and stop this
algorithm.
<li>
<p>Return the nearest ancestor element of <var>A</var> for which at least
one of the following is true and stop this algorithm if such an ancestor
is found:</p>
<ul>
<li>The computed value of the <code>position</code> property is not
<code>static</code>.
<li>It is <a href="#the-html">the HTML <code>body</code> element</a>.
<li>The computed value of the <code>position</code> property of
<var>A</var> is <code>static</code> and the ancestor is one of the
following <a href="#html-element" title="HTML element">HTML
elements</a>: <code>td</code>, <code>th</code>, or <code>table</code>.
</ul>
<li>
<p>Return <code>null</code>.
</ol>
<p>The <dfn id=htmlelementview-offsettop><code>offsetTop</code></dfn>
attribute, when called on element <var>A</var>, <em class=ct>must</em>
return the value that is the result of the following algorithm:
<ol>
<li>
<p>If <var>A</var> is <a href="#the-html">the HTML <code>body</code>
element</a> or does not have an associated CSS layout box return zero
and stop this algorithm.
<li>
<p>If the <code><a
href="#htmlelementview-offsetparent">offsetParent</a></code> of
<var>A</var> is <code>null</code> or <a href="#the-html">the HTML
<code>body</code> element</a> return the y-coordinate of the top <a
href="#border-edge">border edge</a> of <var>A</var> and stop this
algorithm.
<li>
<p>Return the result of subtracting the y-coordinate of the top <a
href="#padding-edge">padding edge</a> of the <code><a
href="#htmlelementview-offsetparent">offsetParent</a></code> of
<var>A</var> from the y-coordinate of the top <a
href="#border-edge">border edge</a> of <var>A</var>, relative to the <a
href="#initial-containing-block">initial containing block</a> origin.