New issue
Advanced search Search tips

Issue 592334 link

Starred by 0 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2016
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

getBoundingClientRect values way off if element has a scaled child

Reported by monfera....@gmail.com, Mar 7 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36

Steps to reproduce the problem:
1. Create a div (parent)
2. Put a div underneath it with inline CSS transform: scale(6,1)
3. Compare parent.getBoundingClientRect().width with parent.offsetWidth

What is the expected behavior?
I'd expect parent.getBoundingClientRect().width to be around parent.offsetWidth, sans rounding and maybe some other small differences

What went wrong?
parent.getBoundingClientRect().width reports 25.35 when offsetWidth is 160 (correct range). Cause appears to be the presence of CSS scaling on child element. Number is around 1/6.32 times what it should be.

Did this work before? N/A 

Chrome version: 48.0.2564.116  Channel: stable
OS Version: OS X 10.11.3
Flash Version: Shockwave Flash 20.0 r0

See the screenshot. Most values suggest around 160 pixels width for the selected DIV, but its getBoundingClientRect().width erroneously reports 25.35. The factor of difference is incredibly close to the X scaling value on the child element.
 
chrome-bug-getBoundingClientRect.png
414 KB View Download
A further test revealed that it's not the scaling on the CHILD element that causes incorrect getBoundingClientRect reporting, but another (inverse, 1/x) scaling on the DIV that CONTAINS the highlighted (queried) DIV. I confirm it by first setting the scaling to (1,1) on the child (no change; still bad width) and then setting it to (1,1) on the containing DIV (after which I'm getting the correct value).
Components: -UI Blink>Layout
Labels: -OS-Mac OS-All
Removing OS=Mac, since this does not look Mac-specific. Still needs triage, moving to Blink>Layout for triage.

Comment 3 by e...@chromium.org, Mar 19 2016

Status: WontFix (was: Unconfirmed)
getBoundingClientRect takes transforms into account, offsetWidth does not. This is intentional and as per spec.

Sign in to add a comment