[cssom-view] Add CaretPosition#getClientRect()

Mon, 22 Apr 2013 15:55:38 +0200

author
Simon Pieters <simonp@opera.com>
date
Mon, 22 Apr 2013 15:55:38 +0200
changeset 7973
20a1acb17302
parent 7972
f2b03be2c8d5
child 7974
8aa80407ee99

[cssom-view] Add CaretPosition#getClientRect()

cssom-view/Overview.html file | annotate | diff | comparison | revisions
cssom-view/idl/CaretPosition.idl file | annotate | diff | comparison | revisions
     1.1 --- a/cssom-view/Overview.html	Mon Apr 22 12:09:10 2013 +0200
     1.2 +++ b/cssom-view/Overview.html	Mon Apr 22 15:55:38 2013 +0200
     1.3 @@ -13,7 +13,7 @@
     1.4  
     1.5     <h1 id="cssom-view-module">CSSOM View Module</h1>
     1.6  
     1.7 -   <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 16 April 2013</h2>
     1.8 +   <h2 class="no-num no-toc" id="w3c-doctype">Editor's Draft 22 April 2013</h2>
     1.9  
    1.10     <dl>
    1.11  
    1.12 @@ -69,7 +69,7 @@
    1.13     can be found in the <a href="http://www.w3.org/TR/">W3C technical reports
    1.14     index at http://www.w3.org/TR/.</a></em>
    1.15  
    1.16 -<p>This is the 16 April 2013 Editor's Draft of CSSOM View. Please send
    1.17 +<p>This is the 22 April 2013 Editor's Draft of CSSOM View. Please send
    1.18  comments to
    1.19  <a href="mailto:www-style@w3.org?subject=%5Bcssom-view%5D%20">www-style@w3.org</a>
    1.20  (<a href="http://lists.w3.org/Archives/Public/www-style/">archived</a>)
    1.21 @@ -435,6 +435,7 @@
    1.22  <pre class="idl"><span class="idlInterface" id="widl-def-CaretPosition">interface <span class="idlInterfaceID">CaretPosition</span> {
    1.23  <span class="idlAttribute">    readonly attribute <span class="idlAttrType"><a>Node</a></span> <span class="idlAttrName"><a href="#widl-CaretPosition-offsetNode">offsetNode</a></span>;</span>
    1.24  <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>
    1.25 +<span class="idlMethod">    <span class="idlMethType"><a>ClientRect</a>?</span> <span class="idlMethName"><a href="#widl-CaretPosition-getClientRect-ClientRect">getClientRect</a></span> ();</span>
    1.26  };</span></pre>
    1.27  <dl class="attributes">
    1.28  <dt class="attribute" id="widl-CaretPosition-offsetNode">
    1.29 @@ -446,6 +447,13 @@
    1.30  <dd>
    1.31  <p>The <code>offset</code> attribute  must return the <a href="#caret-offset">caret offset</a>.</dd>
    1.32  </dl>
    1.33 +<dl class="methods">
    1.34 +<dt class="method" id="widl-CaretPosition-getClientRect-ClientRect">
    1.35 +<code>getClientRect</code> (), returns <span class="idlMethType"><a>ClientRect</a>?</span></dt>
    1.36 +<dd>
    1.37 +<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.
    1.38 +       <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>
    1.39 +</dl>
    1.40  
    1.41  
    1.42    <h2 id="extensions-to-the-element-interface"><span class="secno">6 </span>Extensions to the <code title="">Element</code> Interface</h2>
    1.43 @@ -468,11 +476,11 @@
    1.44  <dt class="attribute" id="widl-Element-scrollTop">
    1.45  <code>scrollTop</code> of type <span class="idlAttrType"><a>long</a></span></dt>
    1.46  <dd>
    1.47 -<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>
    1.48 +<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>
    1.49  <dt class="attribute" id="widl-Element-scrollLeft">
    1.50  <code>scrollLeft</code> of type <span class="idlAttrType"><a>long</a></span></dt>
    1.51  <dd>
    1.52 -<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>
    1.53 +<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>
    1.54  <dt class="attribute" id="widl-Element-scrollWidth">
    1.55  <code>scrollWidth</code> of type <span class="idlAttrType"><a>long</a></span>, readonly</dt>
    1.56  <dd>
    1.57 @@ -641,7 +649,7 @@
    1.58  <dt class="attribute" id="widl-HTMLElement-offsetParent">
    1.59  <code>offsetParent</code> of type <span class="idlAttrType"><a>Element</a></span>, readonly</dt>
    1.60  <dd>
    1.61 -<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>
    1.62 +<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>
    1.63  <dt class="attribute" id="widl-HTMLElement-offsetTop">
    1.64  <code>offsetTop</code> of type <span class="idlAttrType"><a>long</a></span>, readonly</dt>
    1.65  <dd>
     2.1 --- a/cssom-view/idl/CaretPosition.idl	Mon Apr 22 12:09:10 2013 +0200
     2.2 +++ b/cssom-view/idl/CaretPosition.idl	Mon Apr 22 15:55:38 2013 +0200
     2.3 @@ -14,5 +14,26 @@
     2.4     "<p>The {@name} {@type}  must return the <span>caret offset</span>.</p>"
     2.5    ]
     2.6    readonly attribute unsigned long offset;
     2.7 +  
     2.8 +  [Documentation=
     2.9 +   "<p>The {@name} {@type} must follow these steps, aborting on the first step that\
    2.10 +    returns a value:</p>\
    2.11 +    <ol>\
    2.12 +     <li>\
    2.13 +      <p>If <span>caret range</span> is not null:\
    2.14 +      <ol>\
    2.15 +       <li><p>Let <var>list</var> be the result of invoking the\
    2.16 +       <code title=dom-Range-getClientRects>getClientRects()</code> method on the\
    2.17 +       range.
    2.18 +       <li><p>If <var>list</var> is empty, return null.\
    2.19 +       <li><p>Return the <code>ClientRect</code> object in <var>list</var> at index 0.\
    2.20 +      </ol>\
    2.21 +     <li><p>If <span>caret node</span> is a text entry widget that is a replaced element,\
    2.22 +     and that is in the document, return a <code>ClientRect</code> object for the caret\
    2.23 +     in the widget as represented by the <span>caret offset</span> value.\
    2.24 +     <li><p>Return null.\
    2.25 +    </ol>"
    2.26 +  ]
    2.27 +  ClientRect? getClientRect ();
    2.28  
    2.29  };

mercurial