Created attachment 39557 [details]
In caretRangeFromPoint(), there is the following code:
Node* node = result.innerNode();
Since we do not check whether the 'node' is a Text related node, there is a
possibility that a range is created even when the mouse is not pointed in the
Please open caretRangeFromPointInNonTextNode.html,
click mouse right before the first word "type", in the range created by
caretRangeFromPoint(), the node is the Text node, the start/end offset is 0.
click mouse several characters ahead of word "type" (the empty space in the
left of "type"), although the 'node' is a HTMLBodyElement, but it has the
same visible position as the above, and the range created is the same as above.
Is this the correct behavior?
I think my assumption is that this function converts mouse position to the
character position within an element, so a null range should be returned if
click the empty spaces ahead of word "type".
Created attachment 41194 [details]
behavior difference between Document.caretRangeFromPoint in webkit and event.rangeOffset in FireFox
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?
Seems that none of document.caretRangeFromPoint(), event.target, and document.elementFromPoint() shows any difference in the above 2 clicks.
Should I apply for a new API for such differentiation?