-
Notifications
You must be signed in to change notification settings - Fork 791
Expand file tree
/
Copy pathcssom-view-source
More file actions
executable file
·456 lines (330 loc) · 19.2 KB
/
cssom-view-source
File metadata and controls
executable file
·456 lines (330 loc) · 19.2 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
<!doctype html>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>CSSOM View Module</title>
<link rel="stylesheet" href="cssom.css">
<link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/W3C-[STATUS]">
</head>
<body class="draft">
<div class="head">
<!--logo-->
<h1 id="cssom-view-module">CSSOM View Module</h1>
<h2 class="no-num no-toc" id="w3c-doctype">[LONGSTATUS] [DATE: 3 August 2002]</h2>
<dl>
<dt>This Version:</dt>
<dd class=dontpublish><a href="http://dev.w3.org/csswg/cssom-view/">http://dev.w3.org/csswg/cssom-view/</a></dd>
<dd class=publish><a href="[VERSION]">[VERSION]</a></dd>
<dt class=dontpublish>Participate:</dt>
<dd class=dontpublish><a href="mailto:www-style@w3.org?subject==%5Bcssom%5D%20">www-style@w3.org</a> (<a href="http://lists.w3.org/Archives/Public/www-style/">archives</a>)
<dd class=dontpublish><a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=CSS&component=CSSOM%20View">File a bug</a> (<a href="https://www.w3.org/Bugs/Public/buglist.cgi?component=CSSOM%20View&product=CSS&resolution=---">open bugs</a>) <script async="" src="https://w3c-test.org/resources.whatwg.org/file-bug.js"></script>
<dd class=dontpublish><a href="irc://irc.w3.org:6665/css">IRC: #css on W3C</a></dd>
<dt class=publish>Latest Version:</dt>
<dd class=publish><a href="[LATEST]">[LATEST]</a></dd>
<dt class=publish>Latest Editor Draft:</dt>
<dd class=publish><a href="http://dev.w3.org/csswg/cssom-view/">http://dev.w3.org/csswg/cssom-view/</a></dd>
<dt class=dontpublish>Previous Versions:</dt>
<dd class=dontpublish><a href="http://www.w3.org/TR/2009/WD-cssom-view-20090804/">http://www.w3.org/TR/2009/WD-cssom-view-20090804/</a></dd>
<dd class=dontpublish><a href="http://www.w3.org/TR/2008/WD-cssom-view-20080222/">http://www.w3.org/TR/2008/WD-cssom-view-20080222/</a></dd>
<dd class=dontpublish><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/">http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/</a></dd>
<dt>Editors:</dt>
<dd><a href="http://www.w3.org/wiki/User:Gadams">Glenn Adams</a>
(<a href="http://www.cox.com/">Cox Communications, Inc.</a>)
<<a href="mailto:glenn.adams@cox.com">glenn.adams@cox.com</a>></dd>
<dd><a>Simon Pieters</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
<<a href="mailto:simponp@opera.com">simonp@opera.com</a>></dd>
<dt>Previous Editor:</dt>
<dd><a href="http://annevankesteren.nl/">Anne van Kesteren</a>
(<a href="http://www.opera.com/">Opera Software ASA</a>)
<<a href="mailto:annevk@opera.com">annevk@opera.com</a>></dd>
</dl>
<!--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 visual view of a document. This includes
getting the position of element layout boxes, obtaining the width
of the viewport through script, and also scrolling an element.</p>
<h2 id="sotd" class="no-num no-toc">Status of this Document</h2>
<p><em>This section describes the status of this document at the time of
its publication. Other documents may supersede this document. A list of
current W3C publications and the latest revision of this technical report
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
index at http://www.w3.org/TR/.</a></em>
<p>This is the [DATE: 3 August 2002] [LONGSTATUS] of CSSOM View. Please send
comments to
<a href="mailto:www-style@w3.org?subject=%5Bcssom-view%5D%20">www-style@w3.org</a>
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
with <samp>[cssom-view]</samp> at the start of the subject line.
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<p>Publication as a Working Draft does not imply endorsement by the W3C
Membership. This is a draft document and may be updated, replaced or
obsoleted by other documents at any time. It is inappropriate to cite this
document as other than work in progress.
<h2 id="toc" class="no-num no-toc">Table of Contents</h2>
<!-- toc -->
<h2 id="background">Background</h2>
<p>Many of the features defined in this specification have been supported
by browsers for a long period of time. The goal of this specification is
to define these features in such a way that they can be implemented by all
browsers in an interoperable manner. The specification also defines a
couple of new features that will hopefully be useful to authors. (If they
are not you can bug us!)</p>
<h2 id="conformance">Conformance</h2>
<p>All diagrams, examples, and notes in this specification are
non-normative, as are all sections explicitly marked non-normative.
Everything else in this specification is normative.
<p>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL
NOT",--> "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
"OPTIONAL" in the normative parts of this document are to be
interpreted as described in RFC2119. For readability, these words do
not appear in all uppercase letters in this specification. <span
data-anolis-ref>RFC2119</span>
<p>Requirements phrased in the imperative as part of algorithms
(such as "strip any leading space characters" or "return false and
terminate these steps") are to be interpreted with the meaning of the
key word ("must", "should", "may", etc) used in introducing the
algorithm.
<p>Conformance requirements phrased as algorithms or specific steps
may be implemented in any manner, so long as the end result is
equivalent. (In particular, the algorithms defined in this
specification are intended to be easy to follow, and not intended to
be performant.)
<p id="hardwareLimitations">User agents may impose
implementation-specific limits on otherwise unconstrained inputs,
e.g. to prevent denial of service attacks, to guard against running
out of memory, or to work around platform-specific limitations.
<p>When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that e.g. the author can't change the behavior by overriding attributes or methods with custom properties or functions in ECMAScript.
<p>Unless otherwise stated, string comparisons are done in a <span>case-sensitive</span> manner.
<p>A conforming user agent implements all the requirements made by this
specification.</p>
<h3 id="webidl">Web IDL</h3>
<p>The IDL fragments in this specification must be
interpreted as required for conforming IDL fragments, as described in the
Web IDL specification. <span data-anolis-ref>WEBIDL</span>
<h2 id="terminology">Terminology</h2>
<p>Terminology used in this specification is from
DOM Core,
CSSOM and
HTML.
<span data-anolis-ref>DOM</span>
<span data-anolis-ref>CSSOM</span>
<span data-anolis-ref>HTML</span>
<p class="issue"><dfn><code>MouseEvent</code></dfn> is defined in …
<p><dfn>The HTML <code>body</code> element</dfn> is the first
<code>body</code>
<span data-anolis-spec=html title="HTML elements">HTML element</span> child of the root
<span data-anolis-spec=html title="HTML elements">HTML element</span> <code>html</code>.</p>
<p><dfn id="content-edge">Content edge</dfn>,
<dfn id="padding-edge">padding edge</dfn>,
<dfn id="border-edge">border edge</dfn>, and
<dfn id="canvas">canvas</dfn> are defined by CSS.
<!--<span data-anolis-ref>CSS</span>-->
<p><dfn id="viewport">Viewport</dfn> and
<dfn id="initial-containing-block">initial containing block</dfn> are
defined by CSS 2.1 unless there is an ancestor <code>foreignObject</code>
element in the <code>http://www.w3.org/2000/svg</code> namespace in which
case that element acts as viewport and initial containing block.
<!--<span data-anolis-ref>CSS</span>-->
<p>The term <dfn>content</dfn> refers to the dimensions of the element's
content area, including overflown content.
<!--<span data-anolis-ref>CSS</span>-->
<p>The term <dfn>document content</dfn> refers to the area on the
<span>canvas</span> that is rendered upon, excluding content on negative
axis.</p>
<p>The term <dfn>CSS layout box</dfn> refers to the same term in CSS. For the purpose
of the requirements in this specification, elements that have a computed value of the
'<code title>display</code>' property that is <code>table-column</code> or
<code>table-column-group</code> must be considered to have an associated <span>CSS
layout box</span> (the column or column group, respectively).</p>
<h3>CSS pixels</h3>
<p>All coordinates and dimensions for the APIs defined in this
specification are in CSS pixels. <!--<span data-anolis-ref>CSS</span>-->
<p class="note">This does not apply to e.g.
<code title=widl-Window-matchMedia>matchMedia()</code> as the units
are explicitly given there.</p>
<h2 id="extensions-to-the-window-interface">Extensions to the <code title>Window</code> Interface</h2>
<!--{@idl(Window)}-->
<h3 id="the-mediaquerylist-interface">The <code title>MediaQueryList</code> Interface</h3>
<!--{@idl(MediaQueryList)}-->
<!--{@idl(MediaQueryListListener)}-->
<h3 id="the-screen-interface">The <code title>Screen</code> Interface</h3>
<!--{@idl(Screen)}-->
<h2 id="extensions-to-the-document-interface">Extensions to the <code title>Document</code> Interface</h2>
<!--{@idl(Document)}-->
<h3 id=the-caretposition-interface>The <code title>CaretPosition</code> Interface</h3>
<!--{@idl(CaretPosition)}-->
<h2 id="extensions-to-the-element-interface">Extensions to the <code title>Element</code> Interface</h2>
<!--{@idl(Element)}-->
<h3>The <code title>getClientRects()</code> and
<code title>getBoundingClientRect()</code> methods</h3>
<p>The <code title=widl-Element-getClientRects>getClientRects()</code> and <code title=widl-Element-getBoundingClientRect>getBoundingClientRect()</code>
methods provide information about the position of the border box edges of
an element relative to the viewport. The objects these methods return
must be static. That is, changes to the underlying
document are not reflected in the objects.</p>
<h3><code title>Element</code> Scrolling Members</h3>
<p>To <dfn>scroll an element into view</dfn>, optionally with an
<i title>align to top flag</i> set, means to run these steps for each
ancestor element or <span>viewport</span> that establishes a
scrolling box, in order of innermost to outermost scrolling box:</p>
<ol>
<li><p>If the <code data-anolis-spec=dom>Document</code> associated
with the element to be
scrolled into view is not <span data-anolis-spec=html>same origin</span> with the
<code data-anolis-spec=dom>Document</code> associated with the element or
<span>viewport</span> associated with the scrolling box, terminate these
steps.</p></li>
<li><p>If the <i title>align to top flag</i> is set align the top of
the border box of the element to be scrolled into view with the top of
the scrolling box.</p></li>
<li><p>Otherwise, if the <i title>align to top flag</i> is not set
align the bottom of the border box of the element to be scrolled into
view with the bottom of the scrolling box.</p></li>
<li><p>Align the left of the border box of the element to be scrolled
into view with the left of the scrolling box.</p</li>
<!-- RTL is not special cased in implementations?! -->
<li><p>If the aligning did not cause content to move terminate these
steps.</p></li>
<li>
<dl>
<dt>If the scrolling box is associated with an element</dt>
<dd><p><span data-anolis-spec=html>Queue a task</span> to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span>
named <code title="event-scroll">scroll</code> at the element
associated with the scrolling box, unless a <span data-anolis-spec=html title=concept-task>task</span> to fire
that event at that element was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></dd>
<dt>If the scrolling box is associated with a <span>viewport</span></dt>
<dd><p><span data-anolis-spec=html>Queue a task</span> to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span>
named <code title="event-scroll">scroll</code> that bubbles at the
<code data-anolis-spec=dom>Document</code> object associated with the <span>viewport</span>,
unless a <span data-anolis-spec=html title=concept-task>task</span> to fire that event at that
<code data-anolis-spec=dom>Document</code> object was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></dd>
</dl>
</li>
</ol>
<p>To <dfn>scroll an element</dfn> to <var title>x</var>,<var title>y</var> means to:</p>
<ol>
<li>
<dl>
<dt>If the element can have overflow to the right</dt>
<dd><p>Let <var title>x</var> be max(0, min(<var title>x</var>,
<span>content</span> width -
<span>content edge</span> width)).</p></dd>
<dt>If the element can have overflow to the left (under right-to-left
conditions)</dt>
<dd><p>Let <var title>x</var> be min(0, max(<var title>x</var>,
<span>content edge</span> width -
<span>content</span> width)).</p></dd>
</dl>
</li>
<li><p>Let <var title>y</var> be max(0, min(<var title>y</var>,
<span>content</span> height - <span>content edge</span> height)).</p></li>
<li><p>Align <span>content</span> x-coordinate <var title>x</var> with
the left of the <span>content edge</span> of the element and align
<span>content</span> y-coordinate <var title>y</var> with
the top of the <span>content edge</span> of the element.</p></li>
<li><p>If the aligning caused content to move <span data-anolis-spec=html>queue a task</span>
to <span data-anolis-spec=dom title=concept-event-fire>fire an event</span> named
<code title="event-scroll">scroll</code> at the element, unless a
<span data-anolis-spec=html title=concept-task>task</span> to fire that event at that element was already
<span data-anolis-spec=html title="queue a task">queued</span>.</p></li>
</ol>
<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 <code title=widl-lElement-clientTop>clientTop</code>,
<code title=widl-Element-clientLeft>clientLeft</code>,
<code title=widl-Element-clientWidth>clientWidth</code>, and
<code title=widl-Element-clientHeight>clientHeight</code>
attributes must return zero if the element does not
have any associated <span>CSS layout box</span> or if the <span>CSS layout box</span> is inline.
Otherwise, these attributes must behave as defined in
the remainder of this section.</p>
<h2 id="extensions-to-the-htmlelement-interface">Extensions to the <code title>HTMLElement</code> Interface</h2>
<!--{@idl(HTMLElement)}-->
<h2 id="extensions-to-the-range-interface">Extensions to the <code title>Range</code> Interface</h2>
<p>The objects the methods described below return must
be static.</p>
<!--{@idl(Range)}-->
<h2 id="extensions-to-the-mouseevent-interface">Extensions to the <code title>MouseEvent</code> Interface</h2>
<p class="issue">The object IDL fragment redefines some members. Can we
resolve this somehow?</p>
<!-- x/y do not match IE in the position:relative case but do match other
browsers -->
<!--{@idl(MouseEvent)}-->
<h2>Rectangles</h2>
<h3 id="the-clientrectlist-interface">The <code title>ClientRectList</code> Interface</h3>
<!--{@idl(ClientRectList)}-->
<h3 id="the-clientrect-interface">The <code title>ClientRect</code> Interface</h3>
<!--{@idl(ClientRect)}-->
<h2>Events</h2>
<h3>Resizing viewports</h3>
<p>Whenever a <span>viewport</span> has its width or height changed (e.g. as a result of the user resizing the browser window, or zooming in, or an
<code>iframe</code> element's dimensions are changed), the user agent must <span data-anolis-spec=html>queue a task</span> to
<span data-anolis-spec=html title=concept-event-fire>fire</span> a <span data-anolis-spec=html title=concept-events-trusted>trusted</span> event named
<code>resize</code> that does not bubble and is not cancelable at the <code data-anolis-spec=html>Window</code> object associated with that
<span>viewport</span>.
<h3>Scrolling</h3>
<p>Whenever a <span>viewport</span> gets scrolled in response to user interaction, the user agent must <span data-anolis-spec=html>queue a task</span> to
<span data-anolis-spec=html title=concept-event-fire>fire</span> a <span data-anolis-spec=html title=concept-events-trusted>trusted</span> event named
<code>scroll</code> that bubbles but is not cancelable at the <code data-anolis-spec=dom>Document</code> object associated with that <span>viewport</span>.
<p class=issue>Do viewports have associated documents?</p>
<p>Whenever an element gets scrolled in response to user interaction, the user agent must <span data-anolis-spec=html>queue a task</span> to
<span data-anolis-spec=html title=concept-event-fire>fire</span> a <span data-anolis-spec=html title=concept-events-trusted>trusted</span> event named
<code>scroll</code> that does not bubble and is not cancelable at the element.
<p class=issue>Should we specify that scroll events can be throttled (e.g. in a smooth scroll)?</p>
<h2 class=no-num>References</h2>
<h3 class=no-num>Normative references</h3>
<div id=anolis-references-normative></div>
<!--
<h3 class=no-num>Informative references</h3>
<div id=anolis-references-informative></div>
-->
<h2 class="no-num">Acknowledgments</h2>
<p>The editors would like to thank
Alexey Feldgendler,
Björn Höhrmann,
Dan Bates,
David Vest,
Garrett Smith,
Hallvord R. M. Steen,
Leif Arne Storset,
Luiz Agostini,
Maciej Stachowiak,
Michael Dyck,
Mike Wilson,
Morten Stenshorne,
Peter-Paul Koch,
Rachel Kmetz,
Robert O'Callahan,
Sam Weinig,
<!--Simon Pieters,-->
Scott Johnson,
Sylvain Galineau,
Tarquin Wilton-Jones,
Thomas Moore, and
Xiaomei Ji<!-- should actually use real name here -->
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>