Closed
Bug 700477
Opened 13 years ago
Closed 13 years ago
getBoundingClientRect() wrong for XHTML embedded in SVG
Categories
(Core :: SVG, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: phrogz, Unassigned)
References
Details
Attachments
(1 file)
2.52 KB,
application/octet-stream
|
Details |
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.21 Safari/535.7 Steps to reproduce: Embedded XHTML inside a <foreignObject> inside SVG and asked for the getBoundingClientRect() of an HTML element therein. Actual results: Received coordinates of the element within the embedded `<body>` inside the SVG document, not affected by the scaling or placement of the `<foreignObject>` inside the SVG container. Expected results: Received coordinates relative to the viewport of the browser window.
Reporter | ||
Comment 1•13 years ago
|
||
View the test file hosted here: http://phrogz.net/SVG/html_location_in_svg_in_html.xhtml The actual application was the desire to find the location in SVG coordinate space of embedded XHTML contents, in order to connect SVG elements to the embedded HTML contents, as seen here: http://phrogz.net/svg/html_location_in_svg.svg The proposed technique is to translate the embedded HTML element coordinates into screen space (using getBoundingClientRect()) and then transform those coordinates into a local SVG space. This works as intended on Chrome/Safari.
Comment 2•13 years ago
|
||
This is the behavior the spec calls for, as far as I can tell. In particular, http://dev.w3.org/csswg/cssom-view/#the-getclientrects-and-getboundingclientrect-methods says: The getClientRects() and getBoundingClientRect() methods provide information about the position of the border box edges of an element relative to the viewport. and http://dev.w3.org/csswg/cssom-view/#viewport says: Viewport and initial containing block are defined by CSS 2.1 unless there is an ancestor foreignObject element in the http://www.w3.org/2000/svg namespace in which case that element acts as viewport and initial containing block.
Comment 3•13 years ago
|
||
Or in other words, the return value for getBoundingClientRect in a <foreignObject> is in the coordinate system of that <foreignObject>; you can then use its CTM to do whatever else you want as described in comment 1.
Reporter | ||
Comment 4•13 years ago
|
||
Wow…right you are. I totally missed that definition of viewport. Looks like it's Webkit at fault here. :)
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → INVALID
Comment 5•13 years ago
|
||
Gavin, are you going to file a bug on WebKit, or should I?
Reporter | ||
Comment 6•13 years ago
|
||
Boris: I am planning on filing a bug. I think I could make a slightly clearer use case/repro case for them first.
Comment 7•13 years ago
|
||
Sounds good. Thanks!
Reporter | ||
Comment 8•13 years ago
|
||
FWIW the corresponding Webkit bug is https://bugs.webkit.org/show_bug.cgi?id=71819
Updated•13 years ago
|
See Also: → https://bugs.webkit.org/show_bug.cgi?id=71819
Comment 9•13 years ago
|
||
Note also http://lists.w3.org/Archives/Public/www-style/2011Nov/0629.html Depending on the outcome of that, the spec (and our behavior) might change... If you have thoughts on the issue, it'd be good to follow up on that mailing list.
You need to log in
before you can comment on or make changes to this bug.
Description
•