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

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

From: Xiaomei Ji <xji@chromium.org>
Date: Thu, 8 Oct 2009 12:07:16 -0700
Message-ID: <a7aebc750910081207g82b3f1ci324409f745d0b8ed@mail.gmail.com>
To: public-webapps@w3.org
Cc: sam@webkit.org, webkit-dev@lists.webkit.org
One use case is to show a tooltip of the word's definition in your
accept-language when you mouse over the word in a page.
It needs to
1. convert the mouse position to character offset within a node (by
Document.caretRangeFromPoint()<http://dev.w3.org/csswg/cssom-view/#the-documentview-interface>),
and
2. expand the range to 'word' unit.

It is useful for users, especially users from east asian countries, to read
the word's definition in their own language while browsing the internet.

And it is also userful for users to check the word's definition in their own
language while composing something, such as email. This is why I am thinking
of displaying the word's definition for <textarea>. Which needs
Document.caretRangeFromPoint() returns the <textarea> node as the range
container node, and the offset as the character offset within <textarea>.

But Document.caretRangeFromPoint() is only allowed to return nodes in the
actual DOM, that a user would be able to get to by traversing from the root
node.
<textarea> node is not part of the DOM. Document.caretRangeFromPoint() cannot
return a Range in a <textarea> since that Range would not be in the DOM.

I would like to propose another API in Document which has the same
functionality of Document.caretRangeFromPoint() but also works for
<textarea> etc. form control nodes that are not part of the DOM.

I do not have a good name in mind for such API yet.

Would like to hear what you think. Any comments are appreciated!

Thanks,
Xiaomei
Received on Thursday, 8 October 2009 19:07:48 GMT

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