NEW 71819
getBoundingClientRect() yields global coordinates for XHTML elements embedded in SVG
https://bugs.webkit.org/show_bug.cgi?id=71819
Summary getBoundingClientRect() yields global coordinates for XHTML elements embedded...
Gavin Kistner
Reported 2011-11-08 08:11:00 PST
Created attachment 114073 [details] Test case with four foreignObjects in an SVG and displaying script output Given an SVG document with XHTML content embedded via <foreignObject>, the getBoundingClientRect() method should return the coordinates of the element with respect to foreignObject's coordinate space. Instead, it currently is returning the bounding box for object transformed into the web browser viewport. In the attachment (or hosted URL) the return value for getBoundingClientRect() should be the same for all four cases, always showing: {left:0, top:0, right:16, bottom:16}. The CSSOM View Module spec[1] for getBoundingClientRect() says: > The getClientRects() and getBoundingClientRect() methods provide information about the > position of the border box edges of an element relative to the viewport. …and elsewhere[2] explicitly defines _viewport_ as: > [...] 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. The current behavior is understandable, as it makes code like this[3] work more easily. However the current behavior is * …wrong, per the spec * …different from Firefox v7 (which gets this right), and * …less useful than the spec (scripter transformations can identify all four real screen corners of a rotated object, not the screen-aligned bounding box). [1] http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientrect-methods [2] http://www.w3.org/TR/cssom-view/#terminology [3] http://phrogz.net/SVG/html_location_in_svg.svg
Attachments
Test case with four foreignObjects in an SVG and displaying script output (1.86 KB, image/svg+xml)
2011-11-08 08:11 PST, Gavin Kistner
no flags
Zoom foreignObject reproduction (1.02 KB, text/html)
2021-04-27 12:14 PDT, Josh K
no flags
Stephen Chenney
Comment 1 2012-03-22 17:11:58 PDT
There are numerous Chromium bugs surrounding transforms of foreign objects and events. e.g. http://code.google.com/p/chromium/issues/detail?id=116566 My guess is that this is the same issue.
Josh K
Comment 2 2021-04-27 12:14:45 PDT
Created attachment 427180 [details] Zoom foreignObject reproduction I think this is the same or a closely related issue to https://bugs.webkit.org/show_bug.cgi?id=173841, and here is a modified reproduction of that issue but inside a <foreignObject>
Radar WebKit Bug Importer
Comment 3 2023-09-05 12:31:15 PDT
Note You need to log in before you can comment on or make changes to this bug.