Commit 00cc7201 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1753995 - Remove non-test usage of WindowUtils.screenPixelsPerCSSPixel. r=mconley

It does the same as window.devicePixelRatio. However a bunch of this
code is copy-pasted code trying to scale a canvas, but not messing with
full zoom is the right thing to do.

The full zoom value in the top level browser.xhtml page is always 1
anyways, and WindowsPreviewPerTab looking at the current browser tab's
full zoom is just bizarre...

Differential Revision: https://phabricator.services.mozilla.com/D138020
parent 03ade0a6
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1279,8 +1279,7 @@ var gIdentityHandler = {
    let urlString = value + "\n" + gBrowser.contentTitle;
    let htmlString = '<a href="' + value + '">' + value + "</a>";

    let windowUtils = window.windowUtils;
    let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
    let scale = window.devicePixelRatio;
    let canvas = document.createElementNS(
      "http://www.w3.org/1999/xhtml",
      "canvas"
+1 −2
Original line number Diff line number Diff line
@@ -432,8 +432,7 @@
      // Until canvas is HiDPI-aware (bug 780362), we need to scale the desired
      // canvas size (in CSS pixels) to the window's backing resolution in order
      // to get a full-resolution drag image for use on HiDPI displays.
      let windowUtils = window.windowUtils;
      let scale = windowUtils.screenPixelsPerCSSPixel / windowUtils.fullZoom;
      let scale = window.devicePixelRatio;
      let canvas = this._dndCanvas;
      if (!canvas) {
        this._dndCanvas = canvas = document.createElementNS(
+1 −1
Original line number Diff line number Diff line
@@ -474,7 +474,7 @@ class SearchOneOffs {
      // This is likely because the clientWidth getter rounds the value, but
      // the panel's border width is not an integer.
      // As a workaround, decrement the width if the scale is not an integer.
      let scale = this.window.windowUtils.screenPixelsPerCSSPixel;
      let scale = this.window.devicePixelRatio;
      if (Math.floor(scale) != scale) {
        --buttonsWidth;
      }
+1 −15
Original line number Diff line number Diff line
@@ -202,20 +202,6 @@ PreviewController.prototype = {
    this.canvasPreview.height = aRequestedHeight;
  },

  get zoom() {
    // Note that winutils.fullZoom accounts for "quantization" of the zoom factor
    // from nsIContentViewer due to conversion through appUnits.
    // We do -not- want screenPixelsPerCSSPixel here, because that would -also-
    // incorporate any scaling that is applied due to hi-dpi resolution options.
    return this.tab.linkedBrowser.fullZoom;
  },

  get screenPixelsPerCSSPixel() {
    let chromeWin = this.tab.ownerGlobal;
    let windowUtils = chromeWin.windowUtils;
    return windowUtils.screenPixelsPerCSSPixel;
  },

  get browserDims() {
    return this.tab.linkedBrowser.getBoundingClientRect();
  },
@@ -295,7 +281,7 @@ PreviewController.prototype = {
      composite.mozOpaque = false;

      let ctx = composite.getContext("2d");
      let scale = this.screenPixelsPerCSSPixel / this.zoom;
      let scale = this.win.devicePixelRatio;

      composite.width = winWidth * scale;
      composite.height = winHeight * scale;