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

Bug 1753995 - Remove nsDOMWindowUtils.screenPixelsPerCSSPixel. r=smaug,dholbert

For all purposes, this is the same as devicePixelRatio. It was meant to
skip the resistFingerprinting check the devicePixelRatio getter does,
but we do that now using CallerType in WebIDL, so if we cared about that
for these tests (which we don't) we could just do
SpecialPowers.wrap(window).devicePixelRatio.

As a follow-up we could move the NoOverride to window for symmetry. But
it's only used by devtools touch simulation so not sure if worth it.

Differential Revision: https://phabricator.services.mozilla.com/D138021
parent 00cc7201
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -121,8 +121,7 @@ const Layout = {
  },

  CSSToDevicePixels(win, x, y, width, height) {
    const winUtil = win.windowUtils;
    const ratio = winUtil.screenPixelsPerCSSPixel;
    const ratio = win.devicePixelRatio;

    // CSS pixels and ratio can be not integer. Device pixels are always integer.
    // Do our best and hope it works.
+1 −3
Original line number Diff line number Diff line
@@ -371,9 +371,7 @@ function getBoundsForDOMElm(aID) {
}

function CSSToDevicePixels(aWindow, aX, aY, aWidth, aHeight) {
  var winUtil = aWindow.windowUtils;

  var ratio = winUtil.screenPixelsPerCSSPixel;
  var ratio = aWindow.devicePixelRatio;

  // CSS pixels and ratio can be not integer. Device pixels are always integer.
  // Do our best and hope it works.
+0 −13
Original line number Diff line number Diff line
@@ -2189,19 +2189,6 @@ nsDOMWindowUtils::GetViewId(Element* aElement, nsViewID* aResult) {
  return NS_ERROR_NOT_AVAILABLE;
}

NS_IMETHODIMP
nsDOMWindowUtils::GetScreenPixelsPerCSSPixel(float* aScreenPixels) {
  nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
  NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
  nsCOMPtr<nsPIDOMWindowInner> innerWindow = window->GetCurrentInnerWindow();
  NS_ENSURE_STATE(innerWindow);
  // XXX Why does this API exist? Callers should just use devicePixelRatio!
  *aScreenPixels =
      nsGlobalWindowInner::Cast(innerWindow)
          ->GetDevicePixelRatio(CallerType::System, IgnoreErrors());
  return NS_OK;
}

NS_IMETHODIMP
nsDOMWindowUtils::GetScreenPixelsPerCSSPixelNoOverride(float* aScreenPixels) {
  nsPresContext* presContext = GetPresContext();
+1 −2
Original line number Diff line number Diff line
@@ -31,8 +31,7 @@ add_task(async () => {
  SpecialPowers.setFullZoom(window, 2.0);

  const rect = target.getBoundingClientRect();
  const screenPixelsPerCSSPixel =
    SpecialPowers.DOMWindowUtils.screenPixelsPerCSSPixel;
  const screenPixelsPerCSSPixel = window.devicePixelRatio;
  const screenPixelsPerCSSPixelNoOverride =
    SpecialPowers.DOMWindowUtils.screenPixelsPerCSSPixelNoOverride;

+1 −3
Original line number Diff line number Diff line
@@ -9,13 +9,11 @@
<iframe width=100></iframe>
<iframe width=100></iframe>
<script>
const utils = SpecialPowers.DOMWindowUtils;

function getScreenPosition(aElement, aOffsetX, aOffsetY) {
  const rect = aElement.getBoundingClientRect();
  const x = aOffsetX + window.mozInnerScreenX + rect.left;
  const y = aOffsetY + window.mozInnerScreenY + rect.top;
  const scale = utils.screenPixelsPerCSSPixel;
  const scale = window.devicePixelRatio;
  return [Math.round(x * scale), Math.round(y * scale)];
}

Loading