Commit 477d3ef5 authored by Makoto Kato's avatar Makoto Kato
Browse files

Bug 1621241 - Don't apply safe-area-insets-* if device doesn't have cutout area. r=smaug

This is a mistake implementation of cutout support.

When OS/device doesn't support cutout (safe-area-insets-*), widget returns 0 for safe area insets values.
So if it is 0, we shouldn't set safe-area-insets.

Also, I will add test for this by bug 1622713. Actually, no Android emulator that supports notch.

Differential Revision: https://phabricator.services.mozilla.com/D67275

--HG--
extra : moz-landing-system : lando
parent 2922453b
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -10454,6 +10454,11 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
  //
  ScreenIntMargin windowSafeAreaInsets;

  if (windowSafeAreaInsets == aSafeAreaInsets) {
    // no safe area insets.
    return windowSafeAreaInsets;
  }

  int32_t screenLeft, screenTop, screenWidth, screenHeight;
  nsresult rv =
      aScreen->GetRect(&screenLeft, &screenTop, &screenWidth, &screenHeight);
@@ -10469,16 +10474,22 @@ ScreenIntMargin nsContentUtils::GetWindowSafeAreaInsets(
  // window's rect of safe area
  safeAreaRect = safeAreaRect.Intersect(aWindowRect);

  windowSafeAreaInsets.top = std::max(safeAreaRect.y - aWindowRect.y, 0);
  windowSafeAreaInsets.left = std::max(safeAreaRect.x - aWindowRect.x, 0);
  windowSafeAreaInsets.top =
      aSafeAreaInsets.top ? std::max(safeAreaRect.y - aWindowRect.y, 0) : 0;
  windowSafeAreaInsets.left =
      aSafeAreaInsets.left ? std::max(safeAreaRect.x - aWindowRect.x, 0) : 0;
  windowSafeAreaInsets.right =
      std::max((aWindowRect.x + aWindowRect.width) -
      aSafeAreaInsets.right
          ? std::max((aWindowRect.x + aWindowRect.width) -
                         (safeAreaRect.x + safeAreaRect.width),
               0);
                     0)
          : 0;
  windowSafeAreaInsets.bottom =
      std::max(aWindowRect.y + aWindowRect.height -
      aSafeAreaInsets.bottom
          ? std::max(aWindowRect.y + aWindowRect.height -
                         (safeAreaRect.y + safeAreaRect.height),
               0);
                     0)
          : 0;

  return windowSafeAreaInsets;
}