Skip to content

Commit c1a5bbd

Browse files
committed
first draft of caretPositionFromPoint
1 parent ed6cded commit c1a5bbd

File tree

2 files changed

+179
-40
lines changed

2 files changed

+179
-40
lines changed

cssom-view/Overview.html

Lines changed: 97 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727

2828
<h1 id=cssom-view-module>CSSOM View Module</h1>
2929

30-
<h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 9 September 2009</h2>
30+
<h2 class="no-num no-toc" id=w3c-doctype>Editor's Draft 17 November 2009</h2>
3131

3232
<dl>
3333
<dt>This Version:
3434

3535
<dd><a
36-
href="http://www.w3.org/TR/2009/ED-cssom-view-20090909/">http://www.w3.org/TR/2009/ED-cssom-view-20090909/</a>
36+
href="http://www.w3.org/TR/2009/ED-cssom-view-20091117/">http://www.w3.org/TR/2009/ED-cssom-view-20091117/</a>
3737

3838
<dt>Latest Version:
3939

@@ -588,10 +588,17 @@ <h2 id=the-documentview-interface><span class=secno>6 </span>The <code
588588
class=idl>[NoInterfaceObject] interface <dfn id=documentview>DocumentView</dfn> {
589589
readonly attribute <a href="#abstractview">AbstractView</a> <a href="#dom-documentview-defaultview">defaultView</a>;
590590
Element <a href="#dom-documentview-elementfrompoint">elementFromPoint</a>(float <var title="">x</var>, float <var title="">y</var>);
591-
Range <a href="#dom-documentview-caretrangefrompoint">caretRangeFromPoint</a>(float <var title="">x</var>, float <var title="">y</var>);
591+
<a href="#caretposition">CaretPosition</a> <a href="#dom-documentview-caretpositionfrompoint">caretPositionFromPoint</a>(float <var title="">x</var>, float <var title="">y</var>);
592592
};
593593

594-
<a href="#document">Document</a> implements <a href="#documentview">DocumentView</a>;</pre>
594+
<a href="#document">Document</a> implements <a href="#documentview">DocumentView</a>;
595+
596+
interface <dfn id=caretposition>CaretPosition</dfn> {
597+
readonly attribute <span>Node</span> <a href="#dom-caretposition-offsetnode" title=dom-CaretPosition-offsetNode>offsetNode</a>;
598+
readonly attribute unsigned long <a href="#dom-caretposition-offset" title=dom-CaretPosition-offset>offset</a>;
599+
readonly attribute <a href="#range">Range</a> <a href="#dom-caretposition-range" title=dom-CaretPosition-range>range</a>;
600+
};
601+
</pre>
595602

596603
<p>The <dfn id=dom-documentview-defaultview><code>defaultView</code></dfn>
597604
attribute, on getting, <em class=ct>must</em> return an object
@@ -615,29 +622,97 @@ <h2 id=the-documentview-interface><span class=secno>6 </span>The <code
615622
<em class=ct>must</em> return the root element, if any, or
616623
<code>null</code> otherwise.
617624

618-
<p>The <dfn id=dom-documentview-caretrangefrompoint
619-
title=caretrangefrompoint><code>caretRangeFromPoint(<var title="">x</var>,
620-
<var title="">y</var>)</code></dfn> method, when invoked, <em
621-
class=ct>must</em> return an empty text range for the position where a
622-
text insertion point indicator would have been inserted if editing was
623-
enabled and hit testing was performed at the coordinates
624-
<var>x</var>,<var>y</var> in the <a href="#viewport">viewport</a>. If
625-
either argument is negative, <var title="">x</var> is greater than the <a
626-
href="#viewport">viewport</a> width excluding the size of a rendered
627-
scroll bar (if any), <var title="">y</var> is greather than the <a
628-
href="#viewport">viewport</a> height excluding the size of a rendered
629-
scroll bar (if any), or no insertion point indicator would have been
630-
inserted, the method <em class=ct>must</em> return <code>null</code>.
631-
[<cite><a href="#ref-dom2tr">DOM2TR</a></cite>]</p>
632-
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
625+
<p>The <dfn id=dom-documentview-caretpositionfrompoint
626+
title=caretpositionfrompoint><code>caretPositionFromPoint(<var
627+
title="">x</var>, <var title="">y</var>)</code></dfn> method, when
628+
invoked, <em class=ct>must</em> return the result of running these steps:
629+
630+
<ol>
631+
<li>
632+
<p>If either argument is negative, <var title="">x</var> is greater than
633+
the <a href="#viewport">viewport</a> width excluding the size of a
634+
rendered scroll bar (if any), <var title="">y</var> is greather than the
635+
<a href="#viewport">viewport</a> height excluding the size of a rendered
636+
scroll bar (if any) return null.
637+
638+
<li>
639+
<p>If at the coordinates <var title="">x</var>,<var title="">y</var> in
640+
the <a href="#viewport">viewport</a> no text insertion point indicator
641+
would have been inserted return null.
642+
643+
<li>
644+
<p>If at the coordinates <var title="">x</var>,<var title="">y</var> in
645+
the <a href="#viewport">viewport</a> a text insertion point indicator
646+
would have been inserted in a text entry widget which is also a replaced
647+
element return a <a href="#caret-position">caret position</a> with its
648+
properties set as follows:</p>
649+
650+
<dl>
651+
<dt><a href="#caret-node">caret node</a>
652+
653+
<dd>
654+
<p>The node corresponding to the text entry widget.
655+
656+
<dt><a href="#caret-offset">caret offset</a>
657+
658+
<dd>
659+
<p>The amount of 16-bit units to the left of where the text insertion
660+
point indicator would have inserted.
661+
662+
<dt><a href="#caret-range">caret range</a>
663+
664+
<dd>
665+
<p>null
666+
</dl>
667+
668+
<li>
669+
<p>Otherwise, return a <a href="#caret-position">caret position</a> where
670+
the <a href="#caret-range">caret range</a> is a collapsed <code><a
671+
href="#range">Range</a></code> object for the position where the text
672+
insertion point indicator would have been inserted and the other
673+
properties are set as follows:</p>
674+
675+
<dl>
676+
<dt><a href="#caret-node">caret node</a>
677+
678+
<dd>
679+
<p>The <code title=dom-Range-startContainer>startContainer</code> of
680+
the <a href="#caret-range">caret range</a>.
681+
682+
<dt><a href="#caret-offset">caret offset</a>
683+
684+
<dd>
685+
<p>The <code title=dom-Range-startOffset>startOffset</code> of the <a
686+
href="#caret-range">caret range</a>.</p>
687+
</dl>
688+
</ol>
633689

634690
<p class=note>The specifics of hit testing are out of scope of this
635691
specification and therefore the exact details of <code><a
636692
href="#dom-documentview-elementfrompoint">elementFromPoint()</a></code>
637693
and <code><a
638-
href="#dom-documentview-caretrangefrompoint">caretRangeFromPoint()</a></code>
639-
are too. Hit testing might be defined in a future revision of CSS or
640-
HTML5.
694+
href="#dom-documentview-caretpositionfrompoint">caretPositionFromPoint()</a></code>
695+
are therefore too. Hit testing will hopefully be defined in a future
696+
revision of CSS or HTML.
697+
698+
<p>A <dfn id=caret-position>caret position</dfn> gives the position of a
699+
text insertion point indicator. It always has an associated <dfn
700+
id=caret-node>caret node</dfn>, <dfn id=caret-offset>caret offset</dfn>,
701+
and <dfn id=caret-range>caret range</dfn>. It is represented by a <code><a
702+
href="#caretposition">CaretPosition</a></code> object.
703+
704+
<p>The <dfn id=dom-caretposition-offsetnode
705+
title=dom-CaretPosition-offsetNode><code>offsetNode</code></dfn> attribute
706+
<em class=ct>must</em> return the <a href="#caret-node">caret node</a>.
707+
708+
<p>The <dfn id=dom-caretposition-offset
709+
title=dom-CaretPosition-offset><code>offset</code></dfn> attribute <em
710+
class=ct>must</em> return the <a href="#caret-offset">caret offset</a>.
711+
712+
<p>The <dfn id=dom-caretposition-range
713+
title=dom-CaretPosition-range><code>range</code></dfn> attribute <em
714+
class=ct>must</em> return the <a href="#caret-range">caret range</a>.</p>
715+
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
641716

642717
<h2 id=extensions-to-the-element-interface><span class=secno>7
643718
</span>Extensions to the <code title="">Element</code> Interface</h2>

cssom-view/Overview.src.html

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,17 @@ <h2 id="the-documentview-interface">The <code title="">DocumentView</code> Inter
445445
<pre class="idl">[NoInterfaceObject] interface <dfn id="documentview">DocumentView</dfn> {
446446
readonly attribute <span>AbstractView</span> <span>defaultView</span>;
447447
Element <span>elementFromPoint</span>(float <var title="">x</var>, float <var title="">y</var>);
448-
Range <span>caretRangeFromPoint</span>(float <var title="">x</var>, float <var title="">y</var>);
448+
<span>CaretPosition</span> <span>caretPositionFromPoint</span>(float <var title="">x</var>, float <var title="">y</var>);
449449
};
450450

451-
<span>Document</span> implements <span>DocumentView</span>;</pre>
451+
<span>Document</span> implements <span>DocumentView</span>;
452+
453+
interface <dfn id="caretposition">CaretPosition</dfn> {
454+
readonly attribute <span>Node</span> <span title="dom-CaretPosition-offsetNode">offsetNode</span>;
455+
readonly attribute unsigned long <span title="dom-CaretPosition-offset">offset</span>;
456+
readonly attribute <span>Range</span> <span title="dom-CaretPosition-range">range</span>;
457+
};
458+
</pre>
452459

453460
<p>The <dfn id="dom-documentview-defaultview"><code>defaultView</code></dfn>
454461
attribute, on getting, <em class="ct">must</em> return an object
@@ -472,27 +479,84 @@ <h2 id="the-documentview-interface">The <code title="">DocumentView</code> Inter
472479
element, if any, or <code>null</code> otherwise.</p>
473480

474481
<p>The
475-
<dfn id="dom-documentview-caretrangefrompoint" title="caretrangefrompoint"><code>caretRangeFromPoint(<var title="">x</var>,
482+
<dfn id="dom-documentview-caretpositionfrompoint" title="caretpositionfrompoint"><code>caretPositionFromPoint(<var title="">x</var>,
476483
<var title="">y</var>)</code></dfn> method, when invoked,
477-
<em class="ct">must</em> return an empty text range for the position where
478-
a text insertion point indicator would have been inserted if editing was
479-
enabled and hit testing was performed at the coordinates
480-
<var>x</var>,<var>y</var> in the <span>viewport</span>. If either argument
481-
is negative, <var title="">x</var> is greater than the
482-
<span>viewport</span> width excluding the size of a rendered scroll bar
483-
(if any), <var title="">y</var> is greather than the
484-
<span>viewport</span> height excluding the size of a rendered scroll bar
485-
(if any), or no insertion point indicator would have been inserted, the
486-
method <em class="ct">must</em> return
487-
<code>null</code>. [<cite><span>DOM2TR</span></cite>]</p>
484+
<em class="ct">must</em> return the result of running these steps:</p>
488485

489-
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
486+
<ol>
487+
<li><p>If either argument is negative, <var title="">x</var> is greater
488+
than the <span>viewport</span> width excluding the size of a rendered
489+
scroll bar (if any), <var title="">y</var> is greather than the
490+
<span>viewport</span> height excluding the size of a rendered scroll bar
491+
(if any) return null.</p></li>
492+
493+
<li><p>If at the coordinates <var title="">x</var>,<var title="">y</var>
494+
in the <span>viewport</span> no text insertion point indicator would have
495+
been inserted return null.</p></li>
496+
497+
<li>
498+
<p>If at the coordinates <var title="">x</var>,<var title="">y</var>
499+
in the <span>viewport</span> a text insertion point indicator would have
500+
been inserted in a text entry widget which is also a replaced element
501+
return a <span>caret position</span> with its properties set as
502+
follows:</p>
503+
504+
<dl>
505+
<dt><span>caret node</span></dt>
506+
<dd><p>The node corresponding to the text entry widget.</p></dd>
507+
508+
<dt><span>caret offset</span></dt>
509+
<dd><p>The amount of 16-bit units to the left of where the
510+
text insertion point indicator would have inserted.</p></dd>
511+
512+
<dt><span>caret range</span></dt>
513+
<dd><p>null</p></dd>
514+
</dl>
515+
</li>
516+
517+
<li>
518+
<p>Otherwise, return a <span>caret position</span> where the
519+
<span>caret range</span> is a collapsed <code>Range</code> object for
520+
the position where the text insertion point indicator would have been
521+
inserted and the other properties are set as follows:</p>
490522

523+
<dl>
524+
<dt><span>caret node</span></dt>
525+
<dd><p>The <code title="dom-Range-startContainer">startContainer</code>
526+
of the <span>caret range</span>.</p></dd>
527+
528+
<dt><span>caret offset</span></dt>
529+
<dd><p>The <code title="dom-Range-startOffset">startOffset</code> of
530+
the <span>caret range</span>.</p>
531+
</dl>
532+
</li>
533+
</ol>
534+
491535
<p class="note">The specifics of hit testing are out of scope of this
492536
specification and therefore the exact details of
493-
<code>elementFromPoint()</code> and <code>caretRangeFromPoint()</code> are
494-
too. Hit testing might be defined in a future revision of CSS or
495-
HTML5.</p>
537+
<code>elementFromPoint()</code> and <code>caretPositionFromPoint()</code>
538+
are therefore too. Hit testing will hopefully be defined in a future
539+
revision of CSS or HTML.</p>
540+
541+
<p>A <dfn>caret position</dfn> gives the position of a
542+
text insertion point indicator. It always has an associated
543+
<dfn>caret node</dfn>, <dfn>caret offset</dfn>, and
544+
<dfn>caret range</dfn>. It is represented by a <code>CaretPosition</code>
545+
object.</p>
546+
547+
<p>The
548+
<dfn id="dom-caretposition-offsetnode" title="dom-CaretPosition-offsetNode"><code>offsetNode</code></dfn>
549+
attribute <em class="ct">must</em> return the <span>caret node</span>.</p>
550+
551+
<p>The
552+
<dfn id="dom-caretposition-offset" title="dom-CaretPosition-offset"><code>offset</code></dfn>
553+
attribute <em class="ct">must</em> return the <span>caret offset</span>.</p>
554+
555+
<p>The
556+
<dfn id="dom-caretposition-range" title="dom-CaretPosition-range"><code>range</code></dfn>
557+
attribute <em class="ct">must</em> return the <span>caret range</span>.</p>
558+
559+
<!-- https://bugs.webkit.org/show_bug.cgi?id=27046 -->
496560

497561

498562
<h2 id="extensions-to-the-element-interface">Extensions to the <code title="">Element</code> Interface</h2>

0 commit comments

Comments
 (0)