New issue
Advanced search Search tips

Issue 882899 link

Starred by 1 user

Issue metadata

Status: Duplicate
Merged: issue 738022
Owner: ----
Closed: Sep 11
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

getBoundingClientRect return invalid postion when devicePixelRatio != 1

Reported by achmedzh...@gmail.com, Sep 11

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36

Steps to reproduce the problem:
0. Run Windows 10, change system font size to > 100% (for example 125%)
1. Open simple page with HTML:

<svg>
  <g transform="translate(200, 100)" id="fo-g" >
    <foreignObject _ngcontent-c18="" pointer-events="all" style="overflow:visible;" width="50" height="50">
    <div id="fo-block" >
      <span _ngcontent-c18="" class="tag-title-text">Paragraph</span>
      </div>
      </foreignObject>
  </g>
</svg>

And JavaScript

let text = 'g rect \n' + JSON.stringify(document.getElementById('fo-g').getBoundingClientRect());
text += '\n\n';
text += 'foreignObject  div  rect\n ' + JSON.stringify(document.getElementById('fo-block').getBoundingClientRect());

text += '\n\n';

text += 'window.devicePixelRatio ' + window.devicePixelRatio;

let traceTag = document.createElement('pre');
document.body.appendChild(traceTag)

traceTag.appendChild(document.createTextNode(text));

I created page with jsfiddle https://jsfiddle.net/8u9nvozm/19/

2. See results on the screen.

What is the expected behavior?
Coordinates x,y are not depeneded from DPI. Firefox work well.

What went wrong?
Сoordinates from the method do not match the coordinates on the screen.

Did this work before? No 

Does this work in other browsers? N/A

Chrome version: 68.0.3440.106  Channel: stable
OS Version: 10.0
Flash Version:
 
getBoundingClientRect-dpr-125.PNG
138 KB View Download
Mergedinto: 738022
Status: Duplicate (was: Unconfirmed)
I found workaround: when set zoom=window.devicePixelRatio to the div element then 
getBoundingClientRect returns correct corrdinates.


#882899 is about size, but this issues is about position
The underlying issue the same - if it's size or position doesn't really matter.
Ok

Sign in to add a comment