[webkit-dev] Fwd: how to achieve similar behavior as event.rangeParent and event.rangeOffset in FireFox.
xji at chromium.org
Tue Oct 20 10:36:21 PDT 2009
I am trying to annotate the word when hover over, which needs to
differentiate those 2 hits.
Would appreciate your suggestions on how to solve the issue.
On Wed, Oct 14, 2009 at 6:10 PM, Xiaomei Ji <xji at chromium.org> wrote:
> I am using caretRangeFromPoint to convert mouse position to the character
> position within an element.
> I am trying to use it to achieve the same behavior as event.rangeParent and
> event.rangeOffset in FireFox. So I think it should return different results
> if hit test on a text node or the text node's parent element whose first
> child is the text node.
> But the behavior of Document.caretRangeFromPoint() is different.
> I attached a test case in this email. Following are the steps to show the
> 1. open the attached page
> 2. mouse click right before the first word "the" in the list, the container
> node and offset in the range returned from caretRangeFromPoint() is the
> node "the first", and offset 0.
> 3. mouse click some where in the empty space around the bullet before "the
> first". caretRangeFromPoint() returns the same as the above.
> By comparison, open the above page in Firefox and repeat the above steps, you
> will see the node (and offset) returned from event.rangeParent/rangeOffset in
> FireFox are different if click on the text node and the element node.
> Does webkit have anyway to tell the difference (hit test hits different type of nodes)?
> Seems that none of document.caretRangeFromPoint()'s containerNodes, event.target, and document.elementFromPoint() shows any difference in the above 2 clicks.
> Should I propose a new API for such differentiation?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev