Bug 138033 - Safari 8: REGRESSION: getBoundingClientRect on elements inside an SVG with non-default viewBox returns incorrect values
Summary: Safari 8: REGRESSION: getBoundingClientRect on elements inside an SVG with no...
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac Other
: P3 Major
Assignee: Nobody
URL:
Keywords: InRadar, Regression, SVGHitList
Depends on:
Blocks:
 
Reported: 2014-10-23 17:39 PDT by Reza
Modified: 2022-09-03 11:15 PDT (History)
11 users (show)

See Also:


Attachments
minimal html page (1.24 KB, text/html)
2014-10-23 17:39 PDT, Reza
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reza 2014-10-23 17:39:15 PDT
Created attachment 240380 [details]
minimal html page

in the attached html page there are two similar SVG elements, one is zoomed (by setting its viewbox set to 4 times the size of actual svg) and the other one normal (its viewbox the same size as the SVG).
the RECT element inside "zoomed" SVG reports its "getBoundingClientRect" the same as the "normal" one despite the fact that the are in different locations on relative to the page.

they both report "111" as their "left" which is "100 translate + 1pixel border of SVG + 9px padding of body + 1px border of body).

the expected value for the zoomed one is 61 which is:
   100/2 = 50 pixel position of RECT inside SVG
   1px border size of SVG
   9px padding of body
   1px border of body

which makes it 61px.

this also results in wrong behaviour of Safari websinpector! if you hover the mouse over RECT in zoomed SVG in "elements" panel of webinspector to highlight the actual element, it displays a wrong spot on the page.
Comment 1 Reza 2014-10-23 18:59:21 PDT
This was working fine in previous versions
Comment 2 Jon Lee 2016-04-13 14:18:27 PDT
Using STP, looks like this is fixed.
Comment 3 Jon Lee 2016-04-13 20:03:06 PDT
Reopening. Said mentioned that it was inconsistent with Firefox (which doesn't include the border), but consistent with Chrome (which does).
Comment 4 Radar WebKit Bug Importer 2016-04-13 20:05:41 PDT
<rdar://problem/25719216>
Comment 5 Ahmad Saleem 2022-09-03 11:15:38 PDT
I am able to reproduce this bug in Safari 15.6.1 on macOS 12.5.1 using attached test case and it shows following compared to other browsers:

*** Safari 15.6.1 on macOS 12.5.1 ***

rectangle in zoomed SVG has left =  – 61 (Negative for some reasons - Either I am confusing UI or it is negative)
rectangle in normal SVG has left =  – 111 (Negative for some reasons - Either I am confusing UI or it is negative)

*** Chrome Canary 107 & Firefox Nightly 106 ***

rectangle in zoomed SVG has left =  61
rectangle in normal SVG has left =  111

_______

Just wanted to share updated results. Thanks!