[webkit-dev] how to achieve similar behavior as event.rangeParent and event.rangeOffset in FireFox.

Xiaomei Ji xji at chromium.org
Wed Oct 14 18:10:29 PDT 2009


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
difference:

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 text
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?


Thanks,

Xiaomei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091014/5acab0e0/attachment.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091014/5acab0e0/attachment-0001.html>


More information about the webkit-dev mailing list