Re: Transformed Pointer Coordinates?

On Feb 11, 2013, at 4:56 PM, Robert O'Callahan <> wrote:

> I'd like to make some progress here so we can implement something...
> On Thu, Jan 31, 2013 at 2:04 PM, Jacob Rossi <> wrote:
> At least in pages I've built, going from one element to another was the more common scenario for me.  So before learning about these webkit APIs, I was expecting something off of Element or Node. For example:
>      toNode.convertPointFromNode(fromNode, pt)  //Converts the Point pt from the coordinate system used by fromNode into the coordinate system of toNode and returns it
> So then you can do:
>     htmlElement.convertPointFromNode(document, pt)  //Same as convertPointFromPageToNode
>     document.convertPointFromNode(htmlElement, pt) //Same as convertPointFromNodeToPage
>     htmlElement1.convertPointFromNode(htmlElement2, pt) //Convert between 2 elements
> Sounds reasonable. So something like this?
> [Constructor(float x, float y)]
> interface DOMPoint {
>   attribute float x;
>   attribute float y;
> }
> partial interface Node {
>   DOMPoint convertPointFromNode(Node from, DOMPoint pt);
> }
> 'pt' is in CSS pixels relative to the top-left of "from"'s first border-box. Returns a point in CSS pixels relative to the top-left of the destination node's first border-box.
> Edge cases:
> 1) If 'from' is a Document, the point is relative to the top-left of the CSS viewport. Likewise if the destination node is a Document.

Can you clarify how that behaves when the document is scrolled? It sounds like it's equivalent to "client" coordinates, and therefore clientX/clientY on events, which is good.

> 2) If 'from' is a text node, use the first box from the list computed by Range.getClientRect. Likewise if the destination node is a text node.
> 3) If 'from' or the destination are an Element, follow the CSSOM spec for getClientRects() to deal with anonymous boxes: The first box in the list produced by getClientRects is used.
> 4) If 'from' or the destination node are not a Document, text node, or Element, throw INVALID_NODE_TYPE_ERR.
> 5) If 'from' and the destination node have no common ancestor browsing context, throw NOT_FOUND_ERR.
> 6) If the destination point is not uniquely determined (e.g. because the destination node has a singular transform on it), return 0,0.
> Any thoughts?

This sounds good.


Received on Tuesday, 12 February 2013 02:05:21 UTC