8000 csswg-drafts/cssom-view/TR/Overview.html at a2a6df1c5f5bb98319512b9bd2e0f54c18bd90af · 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
<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>