how to achieve similar behavior as event.rangeParent and event.rangeOffset in FireFox.

View: New views
2 Messages — Rating Filter:   Alert me  

how to achieve similar behavior as event.rangeParent and event.rangeOffset in FireFox.

by Xiaomei Ji :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
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

document.elementFromPoint() Method
  • the first
  • the second

  • _______________________________________________
    webkit-dev mailing list
    webkit-dev@...
    http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

    Parent Message unknown Fwd: how to achieve similar behavior as event.rangeParent and event.rangeOffset in FireFox.

    by Xiaomei Ji :: Rate this Message:

    Reply to Author | View Threaded | Show Only this Message

    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.

    Thanks,
    Xiaomei


    On Wed, Oct 14, 2009 at 6:10 PM, Xiaomei Ji <xji@...> 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 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



    _______________________________________________
    webkit-dev mailing list
    webkit-dev@...
    http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev