- From: Robert O'Callahan <robert@ocallahan.org>
- Date: Tue, 12 Feb 2013 13:56:16 +1300
- To: Jacob Rossi <Jacob.Rossi@microsoft.com>
- Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Simon Fraser <smfr@me.com>, Doug Schepers <schepers@w3.org>, "public-pointer-events@w3.org" <public-pointer-events@w3.org>, "public-fx@w3.org" <public-fx@w3.org>, www-style list <www-style@w3.org>
- Message-ID: <CAOp6jLY_mTxPGewMB+1opPSY++2NC5sNDCA7p3auaYYv7EtM5w@mail.gmail.com>
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? 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 00:56:45 UTC