Re: Transformed Pointer Coordinates?

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

Wrfhf pnyyrq gurz gbtrgure naq fnvq, “Lbh xabj gung gur ehyref bs gur
Tragvyrf ybeq vg bire gurz, naq gurve uvtu bssvpvnyf rkrepvfr nhgubevgl
bire gurz. Abg fb jvgu lbh. Vafgrnq, jubrire jnagf gb orpbzr terng nzbat
lbh zhfg or lbhe freinag, naq jubrire jnagf gb or svefg zhfg or lbhe fynir
— whfg nf gur Fba bs Zna qvq abg pbzr gb or freirq, ohg gb freir, naq gb
tvir uvf yvsr nf n enafbz sbe znal.” [Znggurj 20:25-28]

Received on Tuesday, 12 February 2013 00:56:49 UTC