W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

Re: propose an API to return Range in <textarea> etc. form control nodes (similar functionality as document.caretRangeFromPoint)

From: Maciej Stachowiak <mjs@apple.com>
Date: Fri, 16 Oct 2009 10:39:09 -0700
Cc: Anne van Kesteren <annevk@opera.com>, Olli@pettay.fi, public-webapps@w3.org, sam@webkit.org, webkit-dev@lists.webkit.org
Message-id: <8A1CEAFC-D342-4470-B877-DAA0F948D8E0@apple.com>
To: Xiaomei Ji <xji@google.com>

On Oct 16, 2009, at 10:23 AM, Xiaomei Ji wrote:

> Hi Maciej:
>
> Thanks for your comments.
>
> I have a question about "interface CaretPosition":
> In case of form control node, such as <textarea>,  the 'offset' is  
> the character offset within the <textarea> under mouse, 'offsetKind'  
> is "control", what is the value of 'containingNode"? Is it itself or  
> its shadowAncestorNode?

The node for the <textarea> would be the one reported (or of the  
<input type="text"> or whatever kind of form control it was). The  
concepts of "shawdowAncestorNode" and shadows trees in general do not  
exist as far as Web standards are concerned. These things are  
implementation details of WebKit.

  - Maciej

>
> Thanks,
> Xiaomei
>
>
> On Mon, Oct 12, 2009 at 1:50 PM, Maciej Stachowiak <mjs@apple.com>  
> wrote:
>
> On Oct 12, 2009, at 1:08 AM, Anne van Kesteren wrote:
>
> On Fri, 09 Oct 2009 19:04:52 +0200, Xiaomei Ji <xji@chromium.org>  
> wrote:
> Maybe I should propose Document.wordFromPoint() which  directly  
> returns the word under the mouse (and handles both the DOM node and  
> non-DOM form control nodes).
> It hides the information about the node and should be a useful API.
>
> Don't you need at least some context information as well besides  
> just the word? Although I suppose you can get that using a  
> combination of elementFromPoint and wordFromPoint...
>
> I think we should consider changing caretRangeFromPoint's return  
> type, if it's not too late. It's useful to get the caret position  
> inside a text form control, beyond the immediate use case.
>
> Instead of returning a Range, caretRangeFromPoint could return an  
> object like this:
>
> interface CaretPosition {
>    readonly attribute Node containingNode;
>    readonly attribute int offset;
>    readonly attribute DOMString offsetKind; // "document" or "control"
> }
>
> It could have a convenience method for converting a Range too, if  
> that's really needed (which would give null or something for a  
> control position).
>
> Regards,
> Maciej
>
>
>
Received on Friday, 16 October 2009 17:39:45 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:34 GMT