Fix and backport Bugzilla 1873382 and 1929955: Multiply zoom by spoofed pixel ratio; Correct dPR calculation

Backport Patchset

Book-keeping

Bugzilla Issue(s)

  • https://bugzilla.mozilla.org/show_bug.cgi?id=1873382 - d15c9aa0
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1929955 - 95a08b6d
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1954493 - e74cdc0e4cb1fdfc20eb287a850fa3d0fa0ae589
  • https://bugzilla.mozilla.org/show_bug.cgi?id=1957617 - d68d1c9346deaff44ea789233bfcb38396d19d82

Target Channels

  • Alpha
  • Stable
  • Legacy

Notes

problem:

  • currently breaks spec (lols) and a red flag since dPR (2) !== dpi (96) etc
    • at 100% zoom we report css/matchmedia etc as the zoom value as if dPR was 1
    • "-moz-device-pixel-ratio": 1 "-webkit-min-device-pixel-ratio": 1 "dpcm": 37.79527499999999 "dpi": 96.00000000000003 "dpi_css": 96 "dppx": 1

      • ^ and these all change when we zoom
    • but we report window.devicePixelRatio as 2
      • ^ and it does NOT change when we zoom, it is hardcoded

solution: fairly straightforward

  • change our css/mactmedia values to double (since our base spoof is 2)
  • multiply window.devicePixelRatio (which is 2) by zoom
  • then everything matches at any zoom level

cc: @fkilic @pierov

Edited Apr 03, 2025 by Pier Angelo Vendrame
Assignee Loading
Time tracking Loading