- From: Xiaomei Ji <xji@chromium.org>
- Date: Fri, 9 Oct 2009 10:04:52 -0700
- To: Olli@pettay.fi
- Cc: public-webapps@w3.org, sam@webkit.org, webkit-dev@lists.webkit.org
- Message-ID: <a7aebc750910091004p2c40a068of31b4cab51c9fc14@mail.gmail.com>
Hi Olli, Thanks for your comments. I see your point. 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. Thanks, Xiaomei On Thu, Oct 8, 2009 at 12:25 PM, Olli Pettay <Olli.Pettay@helsinki.fi>wrote: > On 10/8/09 10:07 PM, Xiaomei Ji wrote: > >> 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. >> > Do you really want to expose those (native) anonymous DOM nodes to > web? What should happen if one tries to append them to normal DOM? > Or removes them? Or adds (mutation) event listener to them? > > I think we need a bit different kind of API for form controls. > > -Olli > > > > > >> 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 Friday, 9 October 2009 17:05:24 UTC