RE: Transformed Pointer Coordinates?

On Wed, Jan 30, 2013 at 1:42 AM, Robert O'Callahan < rocallahan@gmail.com > wrote:
> On Wed, Jan 30, 2013 at 5:20 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
>> Not particularly happy with the naming, but +1 on the ability *so much*.
>>
>> I suspect it should go in CSSOM View?
>
> Probably.

I agree, CSSOM View makes sense to me.  I opened up a bug to track this:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=20832


> As for naming: should we call the type CSSPoint? Or is it OK to take "Point" for this? convertPointFromPageToNode doesn't strike me as a great name but it's probably not worth changing.

I'd be a bit worried Point might collide with existing variables sites use in the global scope. DOMPoint or CSSPoint seems better to me.

> There are a bunch of edge cases to sort out --- e.g. nodes with no associated CSS box; nodes with more than one CSS box; nodes in a different document; nodes inside a container with a singular CSS transform; etc. I have no idea how Webkit handles any of those.
>
> In theory one could run into problems using these APIs to convert points from one node to another, where both nodes are in a subtree whose root has a singular CSS transform. Converting through the page coordinate system would lose information unnecessarily. That problem may not be worth worrying about.

My 2 cents:

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

And probably also:

     svgElement.convertPointFromNode(htmlElement, pt) //Covert between SVG and HTML nodes' coord systems

Also, I wonder if it might be useful to get the transform matrix between 2 nodes as a CSSMatrix object. 

Received on Thursday, 31 January 2013 01:07:55 UTC