Skip to content

Commit 639274e

Browse files
author
Simon Pieters
committed
[cssom-view] Add CaretPosition#getClientRect()
1 parent 4ad8228 commit 639274e

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

cssom-view/Overview.html

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<h1 id="cssom-view-module">CSSOM View Module</h1>
1515

16-
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 16 April 2013</h2>
16+
<h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 22 April 2013</h2>
1717

1818
<dl>
1919

@@ -69,7 +69,7 @@ <h2 class="no-num no-toc" id="sotd">Status of this Document</h2>
6969
can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
7070
index at http://www.w3.org/TR/.</a></em>
7171

72-
<p>This is the 16 April 2013 Editor's Draft of CSSOM View. Please send
72+
<p>This is the 22 April 2013 Editor's Draft of CSSOM View. Please send
7373
comments to
7474
<a href="mailto:www-style@w3.org?subject=%5Bcssom-view%5D%20">www-style@w3.org</a>
7575
(<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
@@ -435,6 +435,7 @@ <h3 id="the-caretposition-interface"><span class="secno">5.1 </span>The <code ti
435435
<pre class="idl"><span class="idlInterface" id="widl-def-CaretPosition">interface <span class="idlInterfaceID">CaretPosition</span> {
436436
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>Node</a></span> <span class="idlAttrName"><a href="#widl-CaretPosition-offsetNode">offsetNode</a></span>;</span>
437437
<span class="idlAttribute"> readonly attribute <span class="idlAttrType"><a>unsigned long</a></span> <span class="idlAttrName"><a href="#widl-CaretPosition-offset">offset</a></span>;</span>
438+
<span class="idlMethod"> <span class="idlMethType"><a>ClientRect</a>?</span> <span class="idlMethName"><a href="#widl-CaretPosition-getClientRect-ClientRect">getClientRect</a></span> ();</span>
438439
};</span></pre>
439440
<dl class="attributes">
440441
<dt class="attribute" id="widl-CaretPosition-offsetNode">
@@ -446,6 +447,13 @@ <h3 id="the-caretposition-interface"><span class="secno">5.1 </span>The <code ti
446447
<dd>
447448
<p>The <code>offset</code> attribute must return the <a href="#caret-offset">caret offset</a>.</dd>
448449
</dl>
450+
<dl class="methods">
451+
<dt class="method" id="widl-CaretPosition-getClientRect-ClientRect">
452+
<code>getClientRect</code> (), returns <span class="idlMethType"><a>ClientRect</a>?</span></dt>
453+
<dd>
454+
<p>The <code>getClientRect</code> operation 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">getClientRects()</code> method on the range.
455+
<li><p>If <var>list</var> is empty, return null. <li><p>Return the <code>ClientRect</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>ClientRect</code> object for the caret in the widget as represented by the <a href="#caret-offset">caret offset</a> value. <li><p>Return null. </ol></dd>
456+
</dl>
449457

450458

451459
<h2 id="extensions-to-the-element-interface"><span class="secno">6 </span>Extensions to the <code title="">Element</code> Interface</h2>
@@ -468,11 +476,11 @@ <h2 id="extensions-to-the-element-interface"><span class="secno">6 </span>Extens
468476
<dt class="attribute" id="widl-Element-scrollTop">
469477
<code>scrollTop</code> of type <span class="idlAttrType"><a>long</a></span></dt>
470478
<dd>
471-
<p>The <code>scrollTop</code> attribute must return the result of running these steps:</p> <ol> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a> or the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a> return zero and terminate these steps.</li> <li><p>If the element is the root element return the value of <code title="dom-Window-scrollY">scrollY</code>.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any overflow, return the value of <code title="dom-Window-scrollY">scrollY</code>.</li> <li><p>Return the y-coordinate of the <a href="#content">content</a> at the alignment point with the top of the <a href="#content-edge">content edge</a> of the element.</li> </ol> <p>When setting the <code>scrollTop</code> attribute these steps must be run:</p> <ol> <li><p>Let <var title="">y</var> be the given value.</li> <li><p>If the element does not have any associated CSS layout box, the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, or the element has no overflow, terminate these steps.</li> <li><p>If the element is the root element invoke <code title="dom-Window-scroll">scroll()</code> with zero as first argument and <var title="">y</var> as second.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any vertical overflow, invoke <code title="dom-Window-scroll">scroll()</code> with <code title="dom-Window-scrollX">scrollX</code> as first argument and <var title="">y</var> as second.</li> <li><p><a href="#scroll-an-element" title="scroll an element">Scroll the element</a> to <code title="dom-Element-scrollLeft">scrollLeft</code>,<var title="">y</var>. </ol></dd>
479+
<p>The <code>scrollTop</code> attribute must return the result of running these steps:</p> <ol> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a> or the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a> return zero and terminate these steps.</li> <li><p>If the element is the root element return the value of <code title="dom-Window-scrollY">scrollY</code>.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any overflow, return the value of <code title="dom-Window-scrollY">scrollY</code>.</li> <li><p>Return the y-coordinate of the <a href="#content">content</a> at the alignment point with the top of the <a href="#content-edge">content edge</a> of the element.</li> </ol> <p>When setting the <code>scrollTop</code> attribute these steps must be run:</p> <ol> <li><p>Let <var title="">y</var> be the given value.</li> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a>, the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, or the element has no overflow, terminate these steps.</li> <li><p>If the element is the root element invoke <code title="dom-Window-scroll">scroll()</code> with zero as first argument and <var title="">y</var> as second.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any vertical overflow, invoke <code title="dom-Window-scroll">scroll()</code> with <code title="dom-Window-scrollX">scrollX</code> as first argument and <var title="">y</var> as second.</li> <li><p><a href="#scroll-an-element" title="scroll an element">Scroll the element</a> to <code title="dom-Element-scrollLeft">scrollLeft</code>,<var title="">y</var>. </ol></dd>
472480
<dt class="attribute" id="widl-Element-scrollLeft">
473481
<code>scrollLeft</code> of type <span class="idlAttrType"><a>long</a></span></dt>
474482
<dd>
475-
<p>The <code>scrollLeft</code> attribute must return the result of running these steps:</p> <ol> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a> or the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a> return zero and terminate these steps.</li> <li><p>If the element is the root element return the value of <code title="dom-Window-scrollX">scrollX</code>.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any overflow, return the value of <code title="dom-Window-scrollX">scrollX</code>.</li> <li><p>Return the x-coordinate of the <a href="#content">content</a> at the alignment point with the left of the <a href="#content-edge">content edge</a> of the element.</li> </ol> <p>When setting the <code>scrollLeft</code> attribute these steps must be run:</p> <ol> <li><p>Let <var title="">x</var> be the given value.</li> <li><p>If the element does not have any associated CSS layout box, the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, or the element has no overflow, terminate these steps.</li> <li><p>If the element is the root element invoke <code title="dom-Window-scroll">scroll()</code> with <var title="">x</var> as first argument and zero as second.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any vertical overflow, invoke <code title="dom-Window-scroll">scroll()</code> with <var title="">x</var> as first argument and <code title="dom-Window-scrollY">scrollY</code> as second.</li> <li><p><a href="#scroll-an-element" title="Scroll an element">Scroll the element</a> to <var title="">x</var>,<code title="dom-Element-scrollTop">scrollTop</code>. </ol></dd>
483+
<p>The <code>scrollLeft</code> attribute must return the result of running these steps:</p> <ol> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a> or the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a> return zero and terminate these steps.</li> <li><p>If the element is the root element return the value of <code title="dom-Window-scrollX">scrollX</code>.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any overflow, return the value of <code title="dom-Window-scrollX">scrollX</code>.</li> <li><p>Return the x-coordinate of the <a href="#content">content</a> at the alignment point with the left of the <a href="#content-edge">content edge</a> of the element.</li> </ol> <p>When setting the <code>scrollLeft</code> attribute these steps must be run:</p> <ol> <li><p>Let <var title="">x</var> be the given value.</li> <li><p>If the element does not have any associated <a href="#css-layout-box">CSS layout box</a>, the element is the root element and the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, or the element has no overflow, terminate these steps.</li> <li><p>If the element is the root element invoke <code title="dom-Window-scroll">scroll()</code> with <var title="">x</var> as first argument and zero as second.</li> <li><p>If the element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>, the <code class="external"><a href="http://dom.spec.whatwg.org/#document">Document</a></code> is in <a class="external" href="http://dom.spec.whatwg.org/#concept-document-quirks" title="concept-quirks-mode">quirks mode</a>, and the element does not have any vertical overflow, invoke <code title="dom-Window-scroll">scroll()</code> with <var title="">x</var> as first argument and <code title="dom-Window-scrollY">scrollY</code> as second.</li> <li><p><a href="#scroll-an-element" title="Scroll an element">Scroll the element</a> to <var title="">x</var>,<code title="dom-Element-scrollTop">scrollTop</code>. </ol></dd>
476484
<dt class="attribute" id="widl-Element-scrollWidth">
477485
<code>scrollWidth</code> of type <span class="idlAttrType"><a>long</a></span>, readonly</dt>
478486
<dd>
@@ -641,7 +649,7 @@ <h2 id="extensions-to-the-htmlelement-interface"><span class="secno">7 </span>Ex
641649
<dt class="attribute" id="widl-HTMLElement-offsetParent">
642650
<code>offsetParent</code> of type <span class="idlAttrType"><a>Element</a></span>, readonly</dt>
643651
<dd>
644-
<p>The <code>offsetParent</code> attribute must return the result of running these steps:</p> <ol> <li> <p>If any of the following holds true return null and terminate this algorithm:</p> <ul> <li>The element does not have an associated CSS layout box.</li> <li>The element is the root element.</li> <li>The element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>.</li> <li>The element's computed value of the '<code>position</code>' property is <code>fixed</code>.</li> </ul> </li> <li> <p>Return the nearest ancestor element of the element for which at least one of the following is true and terminate 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 <a href="#the-html-body-element">the HTML <code>body</code> element</a>.</li> <li>The computed value of the '<code>position</code>' property of the element is <code>static</code> and the ancestor is one of the following <a class="external" href="http://dev.w3.org/html5/spec/single-page.html#html-elements" title="HTML elements">HTML elements</a>: <code>td</code>, <code>th</code>, or <code>table</code>.</li> </ul> </li> <li><p>Return null.</li> </ol></dd>
652+
<p>The <code>offsetParent</code> attribute must return the result of running these steps:</p> <ol> <li> <p>If any of the following holds true return null and terminate this algorithm:</p> <ul> <li>The element does not have an associated <a href="#css-layout-box">CSS layout box</a>.</li> <li>The element is the root element.</li> <li>The element is <a href="#the-html-body-element">the HTML <code>body</code> element</a>.</li> <li>The element's computed value of the '<code>position</code>' property is <code>fixed</code>.</li> </ul> </li> <li> <p>Return the nearest ancestor element of the element for which at least one of the following is true and terminate 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 <a href="#the-html-body-element">the HTML <code>body</code> element</a>.</li> <li>The computed value of the '<code>position</code>' property of the element is <code>static</code> and the ancestor is one of the following <a class="external" href="http://dev.w3.org/html5/spec/single-page.html#html-elements" title="HTML elements">HTML elements</a>: <code>td</code>, <code>th</code>, or <code>table</code>.</li> </ul> </li> <li><p>Return null.</li> </ol></dd>
645653
<dt class="attribute" id="widl-HTMLElement-offsetTop">
646654
<code>offsetTop</code> of type <span class="idlAttrType"><a>long</a></span>, readonly</dt>
647655
<dd>

cssom-view/idl/CaretPosition.idl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,26 @@ interface CaretPosition {
1414
"<p>The {@name} {@type} must return the <span>caret offset</span>.</p>"
1515
]
1616
readonly attribute unsigned long offset;
17+
18+
[Documentation=
19+
"<p>The {@name} {@type} must follow these steps, aborting on the first step that\
20+
returns a value:</p>\
21+
<ol>\
22+
<li>\
23+
<p>If <span>caret range</span> is not null:\
24+
<ol>\
25+
<li><p>Let <var>list</var> be the result of invoking the\
26+
<code title=dom-Range-getClientRects>getClientRects()</code> method on the\
27+
range.
28+
<li><p>If <var>list</var> is empty, return null.\
29+
<li><p>Return the <code>ClientRect</code> object in <var>list</var> at index 0.\
30+
</ol>\
31+
<li><p>If <span>caret node</span> is a text entry widget that is a replaced element,\
32+
and that is in the document, return a <code>ClientRect</code> object for the caret\
33+
in the widget as represented by the <span>caret offset</span> value.\
34+
<li><p>Return null.\
35+
</ol>"
36+
]
37+
ClientRect? getClientRect ();
1738

1839
};

0 commit comments

Comments
 (0)