8000 csswg-drafts/cssom-view/TR/Overview.html at f8db0ce918d14e17694dbbded50a2d53ca9e0eb2 · w3c/csswg-drafts · GitHub
Skip to content

Latest commit

 

History

History
executable file
·
1833 lines (1522 loc) · 133 KB

File metadata and controls

executable file
·
1833 lines (1522 loc) · 133 KB
<p>The <dfn id="dom-window-pagexoffset" title="dom-Window-pageXOffset"><code>pageXOffset</code></dfn> attribute must return the value returned by the
<code title="dom-Window-scrollX"><a href="#dom-window-scrollx">scrollX</a></code> attribute.</p>
<p>The <dfn id="dom-window-scrolly" title="dom-Window-scrollY"><code>scrollY</code></dfn> attribute attribute must 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>, or zero if there is no <a href="#viewport">viewport</a>. <!--fingerprint--></p>
<p>The <dfn id="dom-window-pageyoffset" title="dom-Window-pageYOffset"><code>pageYOffset</code></dfn> attribute must return the value returned by the
<code title="dom-Window-scrollY"><a href="#dom-window-scrolly">scrollY</a></code> attribute.</p>
<p>When the <dfn id="dom-window-scroll" title="dom-Window-scroll"><code>scroll(<var>x</var>, <var>y</var>, <var>options</var>)</code></dfn> method is invoked these
steps must be run:</p>
<ol>
<li><p>If there is no <a href="#viewport">viewport</a>, abort these steps.
<li><p>Let <var>viewport width</var> be the width of the <a href="#viewport">viewport</a> excluding the width of the scroll bar, if any.
<li><p>Let <var>viewport height</var> be the height of the <a href="#viewport">viewport</a> excluding the height of the scroll bar, if any.
<li>
<dl class="switch">
<dt>If the <a href="#viewport">viewport</a> has rightward <a href="#overflow-directions" title="overflow directions">overflow direction</a>
<dd><p>Let <var>x</var> be max(0, min(<var>x</var>,
<a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a> width - <var>viewport width</var>)).</dd>
<dt>If the <a href="#viewport">viewport</a> has leftward <a href="#overflow-directions" title="overflow directions">overflow direction</a>
<dd><p>Let <var>x</var> be min(0, max(<var>x</var>,
<var>viewport width</var> - <a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a>
width)).</dd>
</dl>
<li>
<dl class="switch">
<dt>If the <a href="#viewport">viewport</a> has downward <a href="#overflow-directions" title="overflow directions">overflow direction</a>
<dd><p>Let <var>y</var> be max(0, min(<var>y</var>,
<a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a> height - <var>viewport height</var>)).</dd>
<dt>If the <a href="#viewport">viewport</a> has upward <a href="#overflow-directions" title="overflow directions">overflow direction</a>
<dd><p>Let <var>y</var> be min(0, max(<var>y</var>,
<var>viewport height</var> - <a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a>
height)).</dd>
</dl>
<li><p>Let <var>position</var> be the scroll position the <a href="#viewport">viewport</a> would have by aligning the x-coordinate <var>x</var> of the
<a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a> with the left of the <a href="#viewport">viewport</a> and aligning the y-coordinate <var>y</var> of the
<a href="#viewport">viewport</a> <a href="#scrolling-area">scrolling area</a> with the top of the <a href="#viewport">viewport</a>.
<li><p>If <var>position</var> is the same as the <a href="#viewport">viewport</a>'s current scroll position, and the <a href="#viewport">viewport</a> does not have an ongoing
<a href="#concept-smooth-scroll" title="concept-smooth-scroll">smooth scroll</a>, abort these steps.
<li><p>Let <var>task</var> be these steps:
<ol>
<li><p><a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#concept-event-fire" title="concept-event-fire">Fire an event</a> named <code title="">scroll</code> that bubbles at the
<code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> object.
</ol>
<li><p><a href="#perform-a-scroll">Perform a scroll</a> of the <a href="#viewport">viewport</a> to <var>position</var>, with the set of steps <var>task</var>, and the
<code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#document">Document</a></code>'s root element as the associated element, if there is one, or null otherwise, and the scroll behavior being the
value of the <code title="">behavior</code> dictionary member of <var>options</var>.
</ol>
<p>When the <dfn id="dom-window-scrollto" title="dom-Window-scrollTo"><code>scrollTo(<var>x</var>, <var>y</var>, <var>options</var>)</code></dfn> method is invoked, the
user agent must act as if the <code title="dom-Window-scroll"><a href="#dom-window-scroll">scroll()</a></code> method was invoked with the same arguments.</p>
<p>When the <dfn id="dom-window-scrollby" title="dom-Window-scrollBy"><code>scrollBy(<var>x</var>, <var>y</var>, <var>options</var>)</code></dfn> method is invoked, the
user agent must act as if the <code title="dom-Window-scroll"><a href="#dom-window-scroll">scroll()</a></code> method was invoked with
<var>x</var> plus <code title="dom-Window-scrollX"><a href="#dom-window-scrollx">scrollX</a></code>
as first argument and <var>y</var> plus
<code title="dom-Window-scrollY"><a href="#dom-window-scrolly">scrollY</a></code> as second argument.</p>
<p>The <dfn id="dom-window-screenx" title="dom-Window-screenX"><code>screenX</code></dfn> attribute must return the x-coordinate,
relative to the origin of the screen of the output device, of the left of
the client window as number of pixels, or zero if there is no such
thing. <!--fingerprint--></p>
<p>The <dfn id="dom-window-screeny" title="dom-Window-screenY"><code>screenY</code></dfn> attribute must return the y-coordinate,
relative to the origin of the screen of the output device, of the top of
the client window as number of pixels, or zero if there is no such
thing. <!--fingerprint--></p>
<p>The <dfn id="dom-window-outerwidth" title="dom-Window-outerWidth"><code>outerWidth</code></dfn> attribute must return the width of the
client window. If there is no client window this
attribute must return zero. <!--fingerprint--></p>
<p>The <dfn id="dom-window-outerheight" title="dom-Window-outerHeight"><code>outerHeight</code></dfn> attribute must return the height of the
client window. If there is no client window this
attribute must return zero. <!--fingerprint--></p>
<p>The <dfn id="dom-window-devicepixelratio" title="dom-Window-devicePixelRatio"><code>devicePixelRatio</code></dfn> attribute must return the result of the following algorithm:
<ol>
<li><p>If there is no output device, return 1 and abort these steps.
<li><p>Let <var>CSS pixel size</var> be the size of a CSS pixel at the current <a href="#page-zoom">page zoom</a> scale factor and at a <a href="#pinch-zoom">pinch zoom</a> scale
factor of 1.0.
<li><p>Let <var>device pixel size</var> be the size of a device pixel of the output device, in one dimension (vertical or horizontal). If the device pixel is
not square, then use the smaller of the vertical or horizontal size of the smallest bounding box of the device pixel.
<li><p>Return the result of dividing <var>CSS pixel size</var> by <var>device pixel size</var>.
</ol>
<h4 id="the-features-argument-to-the-open()-method"><span class="secno">5.1 </span>The <var>features</var> argument to the <code title="">open()</code> method</h4>
<p>HTML defines the <code class="external" data-anolis-spec="html" title="dom-open"><a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#dom-open">open()</a></code> method but has no defined effect for the third argument, <var>features</var>.
<a href="#refsHTML">[HTML]</a>
<p>This specification defines the effect of the <var>features</var> argument for user agents that do not opt to ignore it, as follows:
<ol>
<li><p>If the method does not result in a new <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#auxiliary-browsing-context">auxiliary browsing context</a> being created, terminate these steps.
<li><p>Let <var>target</var> be the new <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#auxiliary-browsing-context">auxiliary browsing context</a>.
<li><p>Let <var>tokens</var> be the result of <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#split-a-string-on-commas" title="split a string on commas">splitting <var>features</var> on commas</a>.
<li><p>Let <var>parsed features</var> be a new empty dictionary.
<li><p><i>Token loop</i>: For each token <var>token</var> in <var>tokens</var>, follow these substeps:
<ol>
<li><p>Let <var>input</var> be <var>token</var>.
<li><p>Let <var>position</var> point at the first character of <var>input</var>.
<li><p><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#skip-whitespace">Skip whitespace</a>.
<li><p><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are not <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#space-character" title="space character">space
characters</a> nor "<code title="">=</code>" (U+003D). Let <var>name</var> be the collected characters, <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#converted-to-ascii-lowercase">converted to ASCII
lowercase</a>.
<li><p>If <var>name</var> is in <var>parsed features</var> or if <var>name</var> is not a <a href="#supported-open()-feature-name">supported <code title="">open()</code> feature name</a>,
continue <i>token loop</i>.
<li><p><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#skip-whitespace">Skip whitespace</a>.
<li><p>If the character at <var>position</var> is not "<code title="">=</code>" (U+003D), continue <i>token loop</i>.
<li><p>Advance <var>position</var> by one.
<li><p>If <var>position</var> is past the end of <var>input</var>, continue <i>token loop</i>.
<li><p><a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#collect-a-sequence-of-characters">Collect a sequence of characters</a> that are any characters. Let <var>raw value</var> be the collected characters.
<li><p>Let <var>value</var> be the result of invoking the <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#rules-for-parsing-integers">rules for parsing integers</a> on <var>raw value</var>.
<li><p>If <var>value</var> is an error, continue <i>token loop</i>.
<li><p>Set <var>name</var> in <var>parsed features</var> to <var>value</var>.
</ol>
<li><p>If <code title="dom-open-features-left"><a href="#dom-open-features-left">left</a></code> is present in <var>parsed features</var>, follow these substeps:
<ol>
<li><p>Let <var>x</var> be the value of <code title="dom-open-features-left"><a href="#dom-open-features-left">left</a></code>.
<li><p>Optionally, clamp <var>x</var> in a user-agent-defined manner so that the window does not move outside the available space.
<li><p>Optionally, move <var>target</var>'s window such that the window's left edge is at the horizontal coordinate <var>x</var> relative to the left edge of
the output device, measured in CSS pixels of <var>target</var>. The positive axis is rightward.
</ol>
<li><p>If <code title="dom-open-features-top"><a href="#dom-open-features-top">top</a></code> is present in <var>parsed features</var>, follow these substeps:
<ol>
<li><p>Let <var>y</var> be the value of <code title="dom-open-features-top"><a href="#dom-open-features-top">top</a></code>.
<li><p>Optionally, clamp <var>y</var> in a user-agent-defined manner so that the window does not move outside the available space.
<li><p>Optionally, move <var>target</var>'s window such that the window's top edge is at the vertical coordinate <var>y</var> relative to the top edge of
the output device, measured in CSS pixels of <var>target</var>. The positive axis is downward.
</ol>
<li><p>If <code title="dom-open-features-width"><a href="#dom-open-features-width">width</a></code> is present in <var>parsed features</var>, follow these substeps:
<ol>
<li><p>Let <var>x</var> be the value of <code title="dom-open-features-width"><a href="#dom-open-features-width">width</a></code>.
<li><p>Optionally, clamp <var>x</var> in a user-agent-defined manner so that the window does not get too small or bigger than the available space.
<li><p>Optionally, size <var>target</var>'s window by moving its right edge such that the distance between the left and right edges of the viewport are
<var>x</var> CSS pixels of <var>target</var>.
<li><p>Optionally, move <var>target</var>'s window in a user-agent-defined manner so that it does not grow outside the available space.
</ol>
<li><p>If <code title="dom-open-features-height"><a href="#dom-open-features-height">height</a></code> is present in <var>parsed features</var>, follow these substeps:
<ol>
<li><p>Let <var>y</var> be the value of <code title="dom-open-features-height"><a href="#dom-open-features-height">height</a></code>.
<li><p>Optionally, clamp <var>y</var> in a user-agent-defined manner so that the window does not get too small or bigger than the available space.
<li><p>Optionally, size <var>target</var>'s window by moving its bottom edge such that the distance between the top and bottom edges of the viewport are
<var>y</var> CSS pixels of <var>target</var>.
<li><p>Optionally, move <var>target</var>'s window in a user-agent-defined manner so that it does not grow outside the available space.
</ol>
</ol>
<p>A <dfn id="supported-open()-feature-name">supported <code title="">open()</code> feature name</dfn> is one of the following:
<dl>
<dt><dfn id="dom-open-features-width" title="dom-open-features-width">width</dfn>
<dd><p>The width of the viewport.
<dt><dfn id="dom-open-features-height" title="dom-open-features-height">height</dfn>
<dd><p>The height of the viewport.
<dt><dfn id="dom-open-features-left" title="dom-open-features-left">left</dfn>
<dd><p>The left position of the window.
<dt><dfn id="dom-open-features-top" title="dom-open-features-top">top</dfn>
<dd><p>The top position of the window.
</dl>
<h3 id="the-mediaquerylist-interface"><span class="secno">5.2 </span>The <code title="">MediaQueryList</code> Interface</h3>
<p>A <code><a href="#mediaquerylist">MediaQueryList</a></code> object has an associated media query list set on creation and an associated
<dfn id="list-of-media-query-list-listeners">list of media query list listeners</dfn>, which is initially empty.</p>
<p>If the associated media query list changes in evaluation then, for each
listener in the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a> — in
appending order, <a class="external" data-anolis-spec="html" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#queue-a-task">queue a task</a> that invokes the listener,
passing as argument the <code><a href="#mediaquerylist">MediaQueryList</a></code> object.</p>
<div class="example">
<p>A simple piece of code that detects changes in the orientation of the viewport can be written as follows:</p>
<pre>function handleOrientationChange(mql) {
if(mql.matches) // landscape
else
}
var mql = matchMedia("(orientation:landscape)")
mql.addListener(handleOrientationChange)</pre>
</div>
<pre class="idl">interface <dfn id="mediaquerylist">MediaQueryList</dfn> {
readonly attribute DOMString <a href="#dom-mediaquerylist-media" title="dom-MediaQueryList-media">media</a>;
readonly attribute boolean <a href="#dom-mediaquerylist-matches" title="dom-MediaQueryList-matches">matches</a>;
void <a href="#dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener">addListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> listener);
void <a href="#dom-mediaquerylist-removelistener" title="dom-MediaQueryList-removeListener">removeListener</a>(<a href="#mediaquerylistlistener">MediaQueryListListener</a> listener);
};
callback <dfn id="mediaquerylistlistener">MediaQueryListListener</dfn> = void (<a href="#mediaquerylist">MediaQueryList</a> list);</pre>
<p>The <dfn id="dom-mediaquerylist-media" title="dom-MediaQueryList-media"><code>media</code></dfn> attribute must return the
<a class="external" data-anolis-spec="cssom" href="http://dev.w3.org/csswg/cssom/#serialize-a-media-query-list" title="serialize a media query list">serialized</a> form of the associated media query list.</p>
<p>The <dfn id="dom-mediaquerylist-matches" title="dom-MediaQueryList-matches"><code>matches</code></dfn> attribute must return true if the associated media query list
matches the state of the rendered <code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> and false if it does not. <!--fingerprint--></p>
<p>When the <dfn id="dom-mediaquerylist-addlistener" title="dom-MediaQueryList-addListener"><code>addListener(<var>listener</var>)</code></dfn> method is invoked <var>listener</var> must
be appended to the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>, unless
it is already in the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>.</p>
<p>When the <dfn id="dom-mediaquerylist-removelistener" title="dom-MediaQueryList-removeListener"><code>removeListener(<var>listener</var>)</code></dfn> method is invoked
<var>listener</var> must be removed from the <a href="#list-of-media-query-list-listeners">list of media query list listeners</a>.</p>
<h3 id="the-screen-interface"><span class="secno">5.3 </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.</p>
<pre class="idl">interface <dfn id="screen">Screen</dfn> {
readonly attribute double <a href="#dom-screen-availwidth" title="dom-Screen-availWidth">availWidth</a>;
readonly attribute double <a href="#dom-screen-availheight" title="dom-Screen-availHeight">availHeight</a>;
readonly attribute double <a href="#dom-screen-width" title="dom-Screen-width">width</a>;
readonly attribute double <a href="#dom-screen-height" title="dom-Screen-height">height</a>;
readonly attribute unsigned long <a href="#dom-screen-colordepth" title="dom-Screen-colorDepth">colorDepth</a>;
readonly attribute unsigned long <a href="#dom-screen-pixeldepth" title="dom-Screen-pixelDepth">pixelDepth</a>;
};</pre>
<p>The <dfn id="dom-screen-availwidth" title="dom-Screen-availWidth"><code>availWidth</code></dfn> attribute must return the available width of the rendering surface of the output device,
in CSS pixels. <!--fingerprint--></p>
<p>The <dfn id="dom-screen-availheight" title="dom-Screen-availHeight"><code>availHeight</code></dfn> attribute must return the available height of the rendering surface of the output
device, in CSS pixels. <!--fingerprint--></p>
<p>The <dfn id="dom-screen-width" title="dom-Screen-width"><code>width</code></dfn> attribute must return the width of the output device, in CSS pixels. <!--fingerprint--></p>
<p>The <dfn id="dom-screen-height" title="dom-Screen-height"><code>height</code></dfn> attribute must return the height of the output device, in CSS pixels. <!--fingerprint--></p>
<p>The <dfn id="dom-screen-colordepth" title="dom-Screen-colorDepth"><code>colorDepth</code></dfn> attribute must return 24.</p>
<p>The <dfn id="dom-screen-pixeldepth" title="dom-Screen-pixelDepth"><code>pixelDepth</code></dfn> attribute must return 24.</p>
<p class="note">The <code title="dom-Screen-colorDepth"><a href="#dom-screen-colordepth">colorDepth</a></code> and <code title="dom-Screen-pixelDepth"><a href="#dom-screen-pixeldepth">pixelDepth</a></code> attributes are useless but are
included for compatibility.
<h2 id="extensions-to-the-document-interface"><span class="secno">6 </span>Extensions to the <code title="">Document</code> Interface</h2>
<pre class="idl">partial interface <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#document">Document</a> {
<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#element">Element</a>? <a href="#dom-document-elementfrompoint" title="dom-Document-elementFromPoint">elementFromPoint</a>(double x, double y);
sequence&lt;<a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#element">Element</a>&gt; <a href="#dom-document-elementsfrompoint" title="dom-Document-elementsFromPoint">elementsFromPoint</a>(double x, double y);
<a href="#caretposition">CaretPosition</a>? <a href="#dom-document-caretpositionfrompoint" title="dom-Document-caretPositionFromPoint">caretPositionFromPoint</a>(double x, double y);
};</pre>
<p>The <dfn id="dom-document-elementfrompoint" title="dom-Document-elementFromPoint"><code>elementFromPoint(<var>x</var>, <var>y</var>)</code></dfn> method must follow these steps:
<ol>
<li><p>If either argument is negative, <var>x</var> is greater than the <a href="#viewport">viewport</a> width excluding the size of a rendered scroll bar (if any), or
<var>y</var> is greater than the <a href="#viewport">viewport</a> height excluding the size of a rendered scroll bar (if any), or there is no <a href="#viewport">viewport</a>
associated with the document, return null and terminate these steps.
<li><p>If there is a <a href="#layout-box">layout box</a> in the <a href="#viewport">viewport</a> that would be a target for hit testing at coordinates <var>x</var>,<var>y</var>,
when applying the <a href="#transforms">transforms</a> that apply to the descendants of the <a href="#viewport">viewport</a>, return the associated element and terminate these steps.
<li><p>If the document has a root element, return the root element and terminate these steps.
<li><p>Return null.
</ol>
<p class="note">The <code title="dom-Document-elementFromPoint"><a href="#dom-document-elementfrompoint">elementFromPoint()</a></code> method does not necessarily return the top-most painted element. For
instance, an element can be excluded from being a target for hit testing by using the 'pointer-events' CSS property.
<p class="atrisk">The <dfn id="dom-document-elementsfrompoint" title="dom-Document-elementsFromPoint"><code>elementsFromPoint(<var>x</var>, <var>y</var>)</code></dfn> method must follow these steps:
<ol>
<li><p>Let <var>sequence</var> be a new empty sequence.
<li><p>If either argument is negative, <var>x</var> is greater than the <a href="#viewport">viewport</a> width excluding the size of a rendered scroll bar (if any), or
<var>y</var> is greater than the <a href="#viewport">viewport</a> height excluding the size of a rendered scroll bar (if any), or there is no <a href="#viewport">viewport</a>
associated with the document, return <var>sequence</var> and terminate these steps.
<li><p>For each <a href="#layout-box">layout box</a> in the <a href="#viewport">viewport</a>, in paint order, starting with the topmost box, that would be a target for hit testing at
coordinates <var>x</var>,<var>y</var> even if nothing would be overlapping it, when applying the <a href="#transforms">transforms</a> that apply to the descendants of the
<a href="#viewport">viewport</a>, append the associated element to <var>sequence</var>.
<li><p>If the document has a root element, and the last item in <var>sequence</var> is not the root element, append the root element to <var>sequence</var>.
<li><p>Return <var>sequence</var>.
</ol>
<p>The <dfn id="dom-document-caretpositionfrompoint" title="dom-Document-caretPositionFromPoint"><code>caretPositionFromPoint(<var>x</var>, <var>y</var>)</code></dfn> method must return the
result of running these steps:</p>
<ol>
<li><p>If there is no <a href="#viewport">viewport</a> associated with the document, return null.
<li><p>If either argument is negative, <var>x</var> is greater
than the <a href="#viewport">viewport</a> width excluding the size of a rendered
scroll bar (if any), <var>y</var> is greather than the
<a href="#viewport">viewport</a> height excluding the size of a rendered scroll bar
(if any) return null.</li>
<li><p>If at the coordinates <var>x</var>,<var>y</var>
in the <a href="#viewport">viewport</a> no text insertion point indicator would have
been inserted when applying the <a href="#transforms">transforms</a> that apply to the descendants of the <a href="#viewport">viewport</a>, return null.</li>
<li>
<p>If at the coordinates <var>x</var>,<var>y</var>
in the <a href="#viewport">viewport</a> a text insertion point indicator would have
been inserted in a text entry widget which is also a replaced element, when applying the <a href="#transforms">transforms</a> that apply to the descendants of the
<a href="#viewport">viewport</a>, return a <a href="#caret-position">caret position</a> with its properties set as follows:</p>
<dl>
<dt><a href="#caret-node">caret node</a></dt>
<dd><p>The node corresponding to the text entry widget.</dd>
<dt><a href="#caret-offset">caret offset</a></dt>
<dd><p>The amount of 16-bit units to the left of where the
text insertion point indicator would have inserted.</dd>
<dt><a href="#caret-range">caret range</a></dt>
<dd><p>null</dd>
</dl>
</li>
<li>
<p>Otherwise, return a <a href="#caret-position">caret position</a> where the
<a href="#caret-range">caret range</a> is a collapsed
<code class="external" data-anolis-spec="dom"><a href="http://dom.spec.whatwg.org/#range">Range</a></code> object for the position
where the text insertion point indicator would have been inserted when applying the <a href="#transforms">transforms</a> that apply to the descendants of the
<a href="#viewport">viewport</a>, and the other properties are set as follows:</p>
<dl>
<dt><a href="#caret-node">caret node</a></dt>
<dd><p>The <code class="external" data-anolis-spec="dom" title="dom-Range-startContainer"><a href="http://dom.spec.whatwg.org/#dom-range-startcontainer">startContainer</a></code>
of the <a href="#caret-range">caret range</a>.</dd>
<dt><a href="#caret-offset">caret offset</a></dt>
<dd><p>The <code class="external" data-anolis-spec="dom" title="dom-Range-startOffset"><a href="http://dom.spec.whatwg.org/#dom-range-startoffset">startOffset</a></code> of
the <a href="#caret-range">caret range</a>.</p>
</dl>
</li>
</ol>
<p class="note">The specifics of hit testing are out of scope of this
specification and therefore the exact details of
<code title="dom-Document-elementFromPoint"><a href="#dom-document-elementfrompoint">elementFromPoint()</a></code> and
<code title="dom-Document-caretPositionFromPoint"><a href="#dom-document-caretpositionfrompoint">caretPositionFromPoint()</a></code>
are therefore too. Hit testing will hopefully be defined in a future
revision of CSS or HTML.</p>
<h3 id="the-caretposition-interface"><span class="secno">6.1 </span>The <code title="">CaretPosition</code> Interface</h3>
<p>A <dfn id="caret-position">caret position</dfn> gives the position of a text insertion point indicator. It always has an associated
<dfn id="caret-node">caret node</dfn>, <dfn id="caret-offset">caret offset</dfn>, and <dfn id="caret-range">caret range</dfn>. It is represented by a <code><a href="#caretposition">CaretPosition</a></code> object.</p>
<pre class="idl">interface <dfn id="caretposition">CaretPosition</dfn> {
readonly attribute <a class="external" data-anolis-spec="dom" href="http://dom.spec.whatwg.org/#node">Node</a> <a href="#dom-caretposition-offsetnode" title="dom-CaretPosition-offsetNode">offsetNode</a>;
readonly attribute unsigned long <a href="#dom-caretposition-offset" title="dom-CaretPosition-offset">offset</a>;
<a href="#domrect">DOMRect</a>? <a href="#dom-caretposition-getclientrect" title="dom-CaretPosition-getClientRect">getClientRect</a>();
};</pre>
<p>The <dfn id="dom-caretposition-offsetnode" title="dom-CaretPosition-offsetNode"><code>offsetNode</code></dfn> attribute must return the <a href="#caret-node">caret node</a>.</p>
<p>The <dfn id="dom-caretposition-offset" title="dom-CaretPosition-offset"><code>offset</code></dfn> attribute must return the <a href="#caret-offset">caret offset</a>.</p>
<p>The <dfn id="dom-caretposition-getclientrect" title="dom-CaretPosition-getClientRect"><code>getClientRect()</code></dfn> method must follow these steps, aborting on the first step that
returns a value:</p>
<ol>
<li>
<p>If <a href="#caret-range">caret range</a> is not null:
<ol>
<li><p>Let <var>list</var> be the result of invoking the
<code title="dom-Range-getClientRects"><a href="#dom-range-getclientrects">getClientRects()</a></code> method on the
range.
<li><p>If <var>list</var> is empty, return null.
<li><p>Return the <code><a href="#domrect">DOMRect</a></code> object in <var>list</var> at index 0.
</ol>
<li><p>If <a href="#caret-node">caret node</a> is a text entry widget that is a replaced element,
and that is in the document, return a <code><a href="#domrect">DOMRect</a></code> object for the caret
in the widget as represented by the <a href="#caret-offset">caret offset</a> value. The <a href="#transforms">transforms</a> that apply to the element and its ancestors are
applied.
<li><p>Return null.
</ol>