Re: Transformed Pointer Coordinates?

On Feb 11, 2013, at 4:56 PM, Robert O'Callahan <robert@ocallahan.org> 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 <Jacob.Rossi@microsoft.com> 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: http://dev.w3.org/csswg/cssom-view/#widl-Element-getClientRects-ClientRectList. 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?

Slightly related to this discussion is a proposal at the SVG WG meeting[1] to support 3D transformation matrices[2]. We want to make it possible to map a point to a transformation matrix. The point in the case of the SVG WG is a dictionary:

dictionary Point {
	double x = 0;
	double y = 0;
	double z = 0;
	double w = 0;
}

The w might be unnecessary since implementations seem to normalize the point by the intermediate w value. It would be great to align these two use cases.

Greetings,
Dirk

[1] http://www.w3.org/2013/02/07-svg-minutes.html#item03
[2] http://www.w3.org/Graphics/SVG/WG/wiki/Proposals/Matrix

> 
> Rob
> -- 
> 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 01:55:00 UTC