-
Notifications
You must be signed in to change notification settings - Fork 792
Expand file tree
/
Copy pathOverview.src.html
More file actions
949 lines (720 loc) · 38.8 KB
/
Overview.src.html
File metadata and controls
949 lines (720 loc) · 38.8 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
<!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 }
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 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><a href="[VERSION]/">http://www.w3.org/TR/[YEAR]/WD-cssom-view-[CDATE]/</a></dd>
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/cssom-view/">http://www.w3.org/TR/cssom-view/</a></dd>
<dt>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>
<!-- copyright -->
</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 view information 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>
<!-- status -->
<p>This is the first public Working Draft of the CSSOM View Module.
<h2 id="toc" class="no-num no-toc">Table of Contents</h2>
<!-- toc -->
<h2 id="conformance">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.
[<cite><span>RFC2119</span></cite>]</p>
<p>A conforming user agent implements all the requirements made by this
specification.</p>
<h3 id="dependencies">Dependencies</h3>
<p>This specification depends on several definitions and features defined
in the HTML 5 specification. [<cite><span>HTML5</span></cite>]</p>
<p>This specification also depends on several features defined in the
DOM Level 2 Events and DOM Level 3 Core specifications.
[<cite><span>DOM2Events</span></cite>]
[<cite><span>DOM3Core</span></cite>]</p>
<h3 id="terminology">Terminology</h3>
<p>The term <dfn>HTML element</dfn> is defined by the HTML 5
specification. [<cite><span>HTML5</span></cite>]</p>
<p><dfn>The HTML <code>body</code> element</dfn> is the first
<code>body</code> <span>HTML element</span> child of the root <span>HTML
element</span> <code>html</code>.</p>
<h2 id="the-windowview-interface">The <code title="">WindowView</code> Interface</h2>
<p>Objects implementing the <code>Window</code> interface
<em class="ct">must</em> also implement the <code>WindowView</code>
interface. [<cite><span>HTML5</span></cite>]</p>
<pre class="idl">interface <dfn id="windowview">WindowView</dfn> {
readonly attribute float <span>innerWidth</span>;
readonly attribute float <span>innerHeight</span>;
readonly attribute float <span>outerWidth</span>;
readonly attribute float <span>outerHeight</span>;
readonly attribute float <span>pageXOffset</span>;
readonly attribute float <span>pageYOffset</span>;
readonly attribute float <span>screenX</span>;
readonly attribute float <span>screenY</span>;
readonly attribute <span>Media</span> <span title="windowview-media">media</span>;
readonly attribute <span>Screen</span> <span title="windowview-screen">screen</span>;
};</pre>
<p>The <dfn id="windowview-innerwidth"><code>innerWidth</code></dfn>
attribute, on getting, <em class="ct">must</em> return the viewport width
as number of CSS pixels.
<span class="note">This is including, if rendered, the vertical
scrollbar.</span></p>
<p>The <dfn id="windowview-innerheight"><code>innerHeight</code></dfn>
attribute, on getting, <em class="ct">must</em> return the viewport height
as number of CSS pixels. <span class="note">This is including, if
rendered, the horizontal scrollbar.</span></p>
<p>The <dfn id="windowview-outerwidth"><code>outerWidth</code></dfn>
attribute, on getting, <em class="ct">must</em> return the width of the
browser window as number of CSS pixels. If there is no browser window this
attribute <em class="ct">must</em> return zero.</p>
<p>The <dfn id="windowview-outerheight"><code>outerHeight</code></dfn>
attribute, on getting, <em class="ct">must</em> return the height of the
browser window as number of CSS pixels. If there is no browser windows
this attribute <em class="ct">must</em> return zero.</p>
<p>The <dfn id="windowview-pagexoffset"><code>pageXOffset</code></dfn>
attribute, on getting, <em class="ct">must</em> return the number of CSS
pixels the user has scrolled towards the right within the viewport.</p>
<!-- XXX viewport - initial containing block -->
<p>The <dfn id="windowview-pageyoffset"><code>pageYOffset</code></dfn>
attribute, on getting, <em class="ct">must</em> return the number of CSS
pixels the user has scrolled towards the bottom within the viewport.</p>
<p>The <dfn id="windowview-screenx"><code>screenX</code></dfn>
attribute, on getting, <em class="ct">must</em> return the amount of CSS
pixels between the left of the browser window and the left of the screen
of the output device. If there is no browser window this attribute
<em class="ct">must</em> return zero.</p>
<p>The <dfn id="windowview-screeny"><code>screenY</code></dfn>
attribute, on getting, <em class="ct">must</em> return the amount of CSS
pixels between the top of the browser window and the top of the screen of
the output device. If there is no browser window this attribute
<em class="ct">must</em> return zero.</p>
<p>The
<dfn id="windowview-media" title="windowview-media"><code>media</code></dfn>
attribute, on getting, <em class="ct">must</em> return an object
implementing the <code>Media</code> interface.</p>
<p>The
<dfn id="windowview-screen" title="windowview-screen"><code>screen</code></dfn>
attribute, on getting, <em class="ct">must</em> return an object
implementing the <code>Screen</code> interface.</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 float <span>availWidth</span>;
readonly attribute float <span>availHeight</span>;
readonly attribute float <span>width</span>;
readonly attribute float <span>height</span>;
readonly attribute float <span>colorDepth</span>;
readonly attribute float <span>pixelDepth</span>;
};</pre>
<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 as number of CSS pixels.</p>
<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 as number of CSS
pixels.</p>
<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 as
number of CSS pixels.</p>
<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
as number of CSS pixels.</p>
<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 lowest number of bits from the
color components of the output device. If the device is not a color device
these attributes <em class="ct">must</em> return zero.</p>
<!-- pixelDepth is not supported by Internet Explorer 7 -->
<h3 id="the-media-interface">The <code title="">Media</code> Interface</h3>
<pre class="idl">interface <dfn id="media">Media</dfn> {
readonly attribute DOMString <span>type</span>;
boolean <span>query</span>(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 canvas'
current rendering mode in canonical form. That is, identical to how it is
defined by the CSS specification. [<cite><span>CSS21</span></cite>]</p>
<p>The
<dfn id="media-query" title="query"><code>query(<var>mediaquery</var>)</code></dfn>
method, when invoked, <em class="ct">must</em> return the result of the
following algorithm:</p>
<ol>
<li>If <var title="">mediaquery</var> can not be parsed according to the
rules given in the Media Queries specification return <code>false</code>
and terminate this algorithm.</li>
<li>If <var title="">mediaquery</var> matches the state of the current view
return <code>true</code> and terminate this algorithm.</li>
<li>Return <code>false</code>.</li>
</ol>
<h2 id="the-documentview-interface">The <code title="">DocumentView</code> Interface</h2>
<p class="issue">This conflicts with an interface in DOM Level 2 Views.
Maybe this specification combined with HTML 5 (for AbstractView) can
obsolete that one as it is completely useless in practice.</p>
<p>Objects implementing the <code>Document</code> interface
<em class="ct">must</em> also implement the <code>DocumentView</code>
interface. [<cite><span>DOM3Core</span></cite>]</p>
<pre class="idl">interface <dfn id="documentview">DocumentView</dfn> {
Element <span>elementFromPoint</span>(in unsigned long <var title="">x</var>, in unsigned long <var title="">y</var>);
};</pre>
<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 <var>x</var>,<var>y</var>
in the viewport. The element to be returned is determined through hit
testing. If either argument is negative or if there is no element at
the given position the method, when invoked, <em class="ct">must</em>
return <code>null</code>.</p>
<p class="issue">Hit testing is currently defined exactly nowhere.</p>
<h2>The <code title="">ElementView</code> Interface</h2>
<!-- http://lists.w3.org/Archives/Public/www-archive/2007Aug/att-0003/offset-mess.htm -->
<p>Objects implementing the <code>Element</code> interface
<em class="ct">must</em> also implement the <code>ElementView</code>
interface. [<cite><span>DOM3Core</span></cite>]</p>
<pre class="idl">interface <dfn id="elementview">ElementView</dfn> {
<span>TextRectangleList</span> <span>getClientRects</span>();
<span>TextRectangle</span> <span>getBoundingClientRect</span>();
readonly attribute Element <span>offsetParent</span>;
readonly attribute float <span>offsetTop</span>;
readonly attribute float <span>offsetLeft</span>;
readonly attribute float <span>offsetWidth</span>;
readonly attribute float <span>offsetHeight</span>;
attribute float <span>scrollTop</span>; // scroll on setting
attribute float <span>scrollLeft</span>; // scroll on setting
readonly attribute float <span>scrollWidth</span>;
readonly attribute float <span>scrollHeight</span>;
readonly attribute float <span>clientTop</span>;
readonly attribute float <span>clientLeft</span>;
readonly attribute float <span>clientWidth</span>;
readonly attribute float <span>clientHeight</span>;
};</pre>
<h3>The <code title="">getClientRects()</code> and
<code title="">getBoundingClientRect()</code> methods</h3>
<p>The <code>getClientRects()</code> and <code>getBoundingClientRect</code>
methods provide information about the position of the border box edges of
an element relative to the viewport.</p>
<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:</p>
<ol>
<li><p>If the element on which it was invoked does not have an associated
CSS layout box return an empty (static) <code>TextRectangleList</code>
object and stop this algorithm.</p></li>
<li><p>Return a (static) <code>TextRectangleList</code> object containing
a list of (static) <code>TextRectangle</code> objects in content order
describing the border boxes, even if they are empty, for the element on
which it was invoked.</p></li>
</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:</p>
<ol>
<li><p>If the element on which it was invoked does not have an associated
CSS layout box return a (static) <code>TextRectangle</code> object whose
<code title="textrectangle-top">top</code>,
<code title="textrectangle-right">right</code>,
<code title="textrectangle-bottom">bottom</code> and
<code title="textrectangle-left">left</code> members are zero.</p></li>
<li><p>Let <var>list</var> be the result of invoking
<code>getClientRects()</code> on the same element this method was invoked
on.</p></li>
<li><p>If <var>list</var> is empty return a (static)
<code>TextRectangle</code> object whose
<code title="textrectangle-top">top</code>,
<code title="textrectangle-right">right</code>,
<code title="textrectangle-bottom">bottom</code> and
<code title="textrectangle-left">left</code> members are zero.</p></li>
<li><p>Otherwise, return a union of the border boxes in <var>list</var>,
excluding border boxes that are empty, as a single
<code>TextRectangle</code> object. If all border boxes are empty let the
<code title="textrectangle-top">top</code> attribute of the new
<code>TextRectangle</code> object be the value of the
<code title="textrectangle-top">top</code> attribute of the first border
box in the list returned. Do likewise for
<code title="textrectangle-left">left</code> and then let
<code title="textrectangle-bottom">bottom</code> be equal to
<code title="textrectangle-bottom">top</code> and
<code title="textrectangle-right">right</code> to
<code title="textrectangle-left">left</code>.</p></li>
</ol>
<h3 id="offset-attributes">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="elementview-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:</p>
<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>
<li><var>A</var> is <span>the HTML <code>body</code>
element</span>.</li>
<li>The computed value of the <code>position</code> property for
element <var>A</var> is <code>fixed</code>.</li>
</ul>
</li>
<li><p>If <var>A</var> is an <code>area</code> <span>HTML element</span>
which has a <code>map</code> <span>HTML element</span> somewhere in the
ancestor chain return the nearest ancestor <code>map</code>
<span>HTML element</span> and stop this algorithm.</p></li>
<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>
<li>It is <span>the HTML <code>body</code> element</span>.</li>
<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 <span title="HTML element">HTML elements</span>:
<code>td</code>, <code>th</code>, or <code>table</code>.</li>
</ul>
</li>
<li><p>Return <code>null</code>.</p></li>
</ol>
<p>The <dfn id="elementview-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:</p>
<ol>
<li><p>If element <var>A</var> is <span>the HTML <code>body</code>
element</span>, has a computed value of the <code>display</code> property
of <code>none</code>, or does not have an associated CSS layout box
return zero and stop this algorithm.</p></li>
<li><p>If the <code>offsetParent</code> of element <var>A</var> is
<code>null</code> or <span>the HTML <code>body</code> element</span>
return the distance, as number of CSS pixels, between the top border edge
of element <var>A</var> and the canvas origin and stop this
algorithm.</p></li>
<li><p>Return the distance as number of CSS pixels between the top border
edge of the <code>offsetParent</code> of element <var>A</var>
and the top border edge of element <var>A</var>.</p></li>
</ol>
<p>The <dfn id="elementview-offsetleft"><code>offsetLeft</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:</p>
<ol>
<li><p>If element <var>A</var> is <span>the HTML <code>body</code>
element</span>, has a computed value of the <code>display</code> propery
that is <code>none</code>, or does not have an associated CSS layout box
return zero and stop this algorithm.</p></li>
<li><p>If the <code>offsetParent</code> of element <var>A</var> is
<code>null</code> or <span>the HTML <code>body</code> element</span>
return the distance, as number of CSS pixels, between the left border
edge of element <var>A</var> and the left of the canvas origin and stop
this algorithm.</p></li>
<li><p>Return the distance, as number of CSS pixels, between the left
border edge of the <code>offsetParent</code> of element
<var>A</var> and the left border edge of element
<var>A</var>.</p></li>
</ol>
<!--
When html:area has an html:map and that has an associated html:img
The shape attribute is set to default
offsetLeft and offsetTop are 0.
The shape attribute is set to circle
offsetLeft is the center-x value minus the radius and offsetTop is the center-y value minus the radius.
The shape attribute is set to rect
The shape attribute is set to poly
offsetLeft is the minimum of all x values and offsetTop is the minimum of all y values.
-->
<p>The <dfn id="elementview-offsetwidth"><code>offsetWidth</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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p>Return the number of CSS pixels of the border box width of element
<var>A</var>.</p></li>
</ol>
<p>The <dfn id="elementview-offsetheight"><code>offsetHeight</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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p>Return the number of CSS pixels of the border box height of element
<var>A</var>.</p>
</ol>
<h3 id="scroll-attributes">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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p class="issue">...</p></li>
</ol>
<p>When setting the <code>scrollTop</code> attribute to <var title="">y</var>
on element <var>A</var> user agents <em class="ct">must</em> run the
following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have vertical overflow stop
this algorithm.</p></li>
<li><p>If <var title="">y</var> is negative act as if it was zero.</p></li>
<li><p class="issue">...</p></li>
</ol>
<!-- XXX need to figure out right terminology -->
<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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p class="issue">...</p></li>
</ol>
<p>When setting the <code>scrollLeft</code> attribute to <var title="">x</var>
on element <var>A</var> user agents <em class="ct">must</em> run the
following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have horizontal overflow
stop this algorithm.</p></li>
<li><p>If <var title="">y</var> is negative act as if it was zero.</p></li>
<li><p class="issue">...</p></li>
</ol>
<!-- XXX need to figure out right terminology -->
<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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p>Return the computed value of the <code>padding-left</code> property
of element <var>A</var>, plus the computed value of the <code>padding-right</code>
property of element <var>A</var>, plus the combined width of the margin box
children of element <var>A</var> subtracting all the collapsed margins of
those children, as number of CSS pixels.</p></li>
</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:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box return zero and stop this algorithm.</p></li>
<li><p>Return the computed value of the <code>padding-top</code> property
of element <var>A</var>, plus the computed value of the <code>padding-bottom</code>
property of element <var>A</var>, plus the combined height of the margin box
children of element <var>A</var> subtracting all the collapsed margins
of those children, as number of CSS pixels.</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 id="elementview-clienttop"><code>clientTop</code></dfn>
attribute, when called on element <var>A</var>,
<em class="ct">must</em> return the result of the following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box or if it is an inline box return zero and stop this
algorithm.</p></li>
<li><p>Return the computed value of the <code>border-top-width</code>
property as number of CSS pixels plus the width of any scrollbar rendered
between the top padding box and top border box as number of CSS
pixels.</p></li>
</ol>
<p>The <dfn id="elementview-clientleft"><code>clientLeft</code></dfn>
attribute, when called on element <var>A</var>,
<em class="ct">must</em> return the result of the following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box or if it is an inline box return zero and stop this
algorithm.</p></li>
<li><p>Return the computed value of the <code>border-left-width</code>
property as number CSS pixels plus the width of any scrollbar rendered
between the left padding box and left border box as number of CSS
pixels.</p></li>
</ol>
<p>The <dfn id="elementview-clientwidth"><code>clientWidth</code></dfn>
attribute, when called on element <var>A</var>,
<em class="ct">must</em> return the result of the following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box or if it is an inline box return zero and stop this
algorithm.</p></li>
<li><p>If element <var>A</var> is the root element return the width of
the viewport as number of CSS pixels and stop this algorithm.</p></li>
<li><p>Return the width of the padding box of element <var>A</var>
(excluding the width of any rendered scrollbar between the padding and
border box) as number of CSS pixels.</p></li>
</ol>
<p>The <dfn id="elementview-clientheight"><code>clientHeight</code></dfn>
attribute, when called on element <var>A</var>,
<em class="ct">must</em> return the result of the following algorithm:</p>
<ol>
<li><p>If element <var>A</var> does not have an associated CSS
layout box or if it is an inline box return zero and stop this
algorithm.</p></li>
<li><p>If element <var>A</var> is the root element return the height of
the viewport as number of CSS pixels and stop this algorithm.</p></li>
<li><p>Return the height of the padding box of element <var>A</var>
(excluding the width of any rendered scrollbar between the padding and
border box) as number of CSS pixels.</p></li>
</ol>
<h2 id="the-rangeview-interface">The <code title="">RangeView</code> Interface</h2>
<p>Objects implementing the <code>Range</code> interface
<em class="ct">must</em> also implement the <code>RangeView</code>
interface. [<cite><span>DOM2TR</span></cite>]</p>
<pre class="idl">interface <dfn>RangeView</dfn> {
<span>TextRectangleList</span> <span title="rangeview-getclientrects">getClientRects</span>();
<span>TextRectangle</span> <span title="rangeview-getboundingclientrect">getBoundingClientRect</span>();
};</pre>
<p>The
<dfn id="rangeview-getclientrects" title="rangeview-getclientrects"><code>getClientRects()</code></dfn>
method, when invoked, <em class="ct">must</em> return an empty (static)
<code>TextRectangleList</code> object if the range is empty (if the
boundary-points are identical) and otherwise a (static)
<code>TextRectangleList</code> object based on the following
conditions:</p>
<ul>
<li>For each element selected by the range, whose parent is not selected
by the range, include the border boxes returned by invoking
<code>getClientRects()</code> on the element.</li>
<li>For each <code>Text</code> node selected or partially selected by the
range, include a <code>TextRectangle</code> object for each CSS box
associated with the text in the range (the part that is selected, not the
whole line box). The bounds of these <code>TextRectangle</code> objects
are computed using font metrics; thus, for horizontal writing, the
vertical dimension of each box is determined by the font ascent and
descent, and the horizontal dimension by the text advance width.</li>
<li>The <code>TextRectangle</code> objects are in content order.</li>
</ul>
<p>The
<dfn id="rangeview-getboundingclientrect" title="rangeview-getboundingclientrect"><code>getBoundingClientRect()</code></dfn>
method, when invoked, <em class="ct">must</em> return the result of the
following algorithm:</p>
<ol>
<li><p>Let <var>list</var> be the result of invoking
<code title="rangeview-getclientrects">getClientRects()</code> on the
same range this method was invoked on.</p></li>
<li><p>If <var>list</var> is empty return a (static)
<code>TextRectangle</code> object whose
<code title="textrectangle-top">top</code>,
<code title="textrectangle-right">right</code>,
<code title="textrectangle-bottom">bottom</code> and
<code title="textrectangle-left">left</code> members are zero.</p></li>
<li><p>Otherwise, return a union of the boxes in <var>list</var>,
excluding boxes that are empty, as a single <code>TextRectangle</code>
object. If all boxes are empty let the
<code title="textrectangle-top">top</code> attribute of the new
<code>TextRectangle</code> object be the value of the
<code title="textrectangle-top">top</code> attribute of the first border
box in the list returned. Do likewise for
<code title="textrectangle-left">left</code> and then let
<code title="textrectangle-bottom">bottom</code> be equal to
<code title="textrectangle-bottom">top</code> and
<code title="textrectangle-right">right</code> to
<code title="textrectangle-left">left</code>.</p></li>
</ol>
<h2 id="the-mouseeventview-interface">The <code title="">MouseEventView</code> Interface</h2>
<p>Objects implementing the <code>MouseEvent</code> interface
<em class="ct">must</em> also implement the <code>MouseEventView</code>
interface. [<cite><span>DOM2Events</span></cite>]</p>
<pre class="idl">interface <dfn>MouseEventView</dfn> {
readonly attribute long <span title="mouseeventview-screenx">screenX</span>;
readonly attribute long <span title="mouseeventview-screeny">screenY</span>;
readonly attribute long <span>pageX</span>;
readonly attribute long <span>pageY</span>;
readonly attribute long <span>clientX</span>;
readonly attribute long <span>clientY</span>;
readonly attribute long <span>offsetX</span>;
readonly attribute long <span>offsetY</span>;
readonly attribute long <span title="mouseeventview-x">x</span>;
readonly attribute long <span title="mouseeventview-y">y</span>;
};</pre>
<p>The
<dfn id="mouseeventview-screenx" title="mouseeventview-screenx"><code>screenX</code></dfn>
attribute, on getting, <em class="ct">must</em> return the horizontal
coordinate, as number of CSS pixels, of the position where the event
occurred relative to the origin of the screen.</p>
<p>The
<dfn id="mouseeventview-screeny" title="mouseeventview-screeny"><code>screenY</code></dfn>
attribute, on getting, <em class="ct">must</em> return the vertical
coordinate, as number of CSS pixels, of the position where the event
occurred relative to the origin of the screen.</p>
<p>The <dfn id="mouseeventview-pagex"><code>pageX</code></dfn> attribute,
on getting, <em class="ct">must</em> return the horizontal coordinate, as
number of CSS pixels, of the position where the event occurred relative to
the origin of the canvas.</p>
<p>The <dfn id="mouseeventview-pagey"><code>pageY</code></dfn> attribute,
on getting, <em class="ct">must</em> return the vertical coordinate, as
number of CSS pixels, of the position where the event occurred relative to
the origin of the canvas.</p>
<p>The <dfn id="mouseeventview-clientx"><code>clientX</code></dfn> attribute,
on getting, <em class="ct">must</em> return the horizontal coordinate, as
number of CSS pixels, of the position where the event occurred relative to
the origin of the viewport.</p>
<p>The <dfn id="mouseeventview-clienty"><code>clientY</code></dfn> attribute,
on getting, <em class="ct">must</em> return the vertical coordinate, as
number of CSS pixels, of the position where the event occurred relative to
the origin of the viewport.</p>
<p>The <dfn id="mouseeventview-offsetx"><code>offsetX</code></dfn>
attribute, on getting, <em class="ct">must</em> return the horizontal
coordinate, as number of CSS pixels, of the position where the event
occurred relative to the origin of the padding box of the target
node.</p>
<!-- this can cause negative values -->
<p>The <dfn id="mouseeventview-offsety"><code>offsetY</code></dfn>
attribute, on getting, <em class="ct">must</em> return the vertical
coordinate, as number of CSS pixels, of the position where the event
occurred relative to the origin of the padding box of the target
node.</p>
<!-- this can cause negative values -->
<p>The
<dfn id="mouseeventview-x" title="mouseeventview-x"><code>x</code></dfn>
attribute, on getting, <em class="ct">must</em> return the value of
<code>pageX</code>.</p>
<p>The
<dfn id="mouseeventview-y" title="mouseeventview-y"><code>y</code></dfn>
attribute, on getting, <em class="ct">must</em> return the value of
<code>pageY</code>.</p>
<p class="issue">Need to more carefully check the
<code title="">x</code> and <code title="">y</code> members and likely the
others too.</p>
<h2>Rectangles</h2>
<h3 id="the-textrectanglelist-interface">The <code title="">TextRectangleList</code> Interface</h3>
<p>The <code>TextRectangleList</code> object consists of an ordered list
of <code>TextRectangle</code> objects.</p>
<pre class="idl">interface <dfn>TextRectangleList</dfn> {
readonly attribute unsigned long <span title="textrectanglelist-length">length</span>;
<span>TextRectangle</span> <span title="textrectanglelist-item">item</span>(in unsigned long <var title="">index</var>);
};</pre>
<p>The
<dfn id="textrectanglelist-length" title="textrectanglelist-length"><code>length</code></dfn>
attribute <em class="ct">must</em> return the total number of
<code>TextRectangle</code> objects associated with the object.</p>
<p>The
<dfn id="textrectanglelist-item" title="textrectanglelist-item"><code>item(<var title="">index</var>)</code></dfn>
method, when invoked, <em class="ct">must</em> raise an
<code>INDEX_SIZE_ERR</code> exception when <var title="">index</var> is
negative or greater than the number of <code>TextRectangle</code> objects
associated with the object. Otherwise, the <code>TextRectangle</code>
object at <var title="">index</var> <em class="ct">must</em> be
returned.</p>
<p>In ECMAScript implementations, objects that implement the
<code>TextRectangleList</code> interface <em class="ct">must</em> also
have a <code>[[Get]]</code> method that, when invoked with a number, acts
like the <code title="textrectanglelist-item">item()</code> method would
when invoked with that argument.</p>
<h3 id="the-textrectangle-interface">The <code title="">TextRectangle</code> Interface</h3>
<p>Objects implementing the <code>TextRectangle</code> interface represent
a rectangular box. The type of box is specified by the method that returns
a <code>TextRectangle</code> object.</p>
<pre class="idl">interface <dfn>TextRectangle</dfn> {
readonly attribute float <span title="textrectangle-top">top</span>;
readonly attribute float <span title="textrectangle-right">right</span>;
readonly attribute float <span title="textrectangle-bottom">bottom</span>;
readonly attribute float <span title="textrectangle-left">left</span>;
};</pre>
<p>The
<dfn id="textrectangle-top" title="textrectangle-top"><code>top</code></dfn>
attribute, on getting, <em class="ct">must</em> return the distance
between the top of the viewport and the top of the rectangle box as number
of CSS pixels.</p>
<p>The
<dfn id="textrectangle-right" title="textrectangle-right"><code>right</code></dfn>
attribute, on getting, <em class="ct">must</em> return the distance
between the left of the viewport and the right of the rectangle box as
number of CSS pixels.</p>
<p>The
<dfn id="textrectangle-bottom" title="textrectangle-bottom"><code>bottom</code></dfn>
attribute, on getting, <em class="ct">must</em> return the distance between
the top of the viewport and the bottom of the rectangle box as number of
CSS pixels.</p>
<p>The
<dfn id="textrectangle-left" title="textrectangle-left"><code>left</code></dfn>
attribute, on getting, <em class="ct">must</em> return the distance between
the left of the viewport and the left of the rectangle box as number of
CSS pixels.</p>
<!-- XXX svg:foreignObject is not defined anywhere for practical purpose
<p class="note">The <code>svg:foreignObject</code> element represents an
initial containing block for its descendents.</p>
-->
<h2 class="no-num">References</h2>
<p>All references are normative<!--, unless stated otherwise-->.</p>
<dl>
<dt>[<dfn id="ref-dom2events">DOM2Events</dfn>]</dt>
<dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Events/">Document
Object Model (DOM) Level 2 Events Specification</a></cite>, T. Pixley,
editor. W3C, November 2000.</dd>
<dt>[<dfn id="ref-dom2tr">DOM2TR</dfn>]</dt>
<dd><cite><a href="http://www.w3.org/TR/DOM-Level-2-Traversal-Range/">Document
Object Model (DOM) Level 2 Traversal and Range Specification</a></cite>,
J. Kesselman, J. Robie, M. Champion, P. Sharpe, V. Apparao, L. Wood,
editors. W3C, November 2000.</dd>
<dt>[<dfn id="ref-dom3core">DOM3Core</dfn>]</dt>
<dd><cite><a href="http://www.w3.org/TR/DOM-Level-3-Core">Document Object
Model (DOM) Level 3 Core Specification</a></cite>, A. Le Hors, P. Le
Hégaret, L. Wood, G. Nicol, J. Robie, M. Champion, S. Byrne,
editors. W3C, April 2004.</dd>
<dt>[<dfn id="ref-html5">HTML5</dfn>]</dt>
<dd><cite><a href="http://www.w3.org/html/wg/html5/">HTML 5</a></cite>
(work in progress), I. Hickson, D. Hyatt, editors. W3C, 2008.</dd>
<dd><cite><a href="http://www.whatwg.org/specs/web-apps/current-work/">HTML 5</a></cite>
(work in progress), I. Hickson, editor. WHATWG, 2008.</dd>
<dt>[<dfn id="ref-rfc2119">RFC2119</dfn>]</dt>
<dd><cite><a href="http://ietf.org/rfc/rfc2119">Key words for use in RFCs to
Indicate Requirement Levels</a></cite>, S. Bradner. IETF, March 1997.</dd>
</dl>
<h2 class="no-num">Acknowledgments</h2>
<p>The editor would like to thank
Alexey Feldgendler,
David Vest,
Hallvord R. M. Steen,
Morten Stenshorne,
Robert O'Callahan,
Simon Pieters, and
Tarquin Wilton-Jones
for their contributions to this document.</p>
<p>Special thanks to the Microsoft employees who first implemented many of
the features specified in this draft, which were first widely deployed by
the Windows Internet Explorer browser.</p>
</body>
</html>