Bug 1520455 - Don't use the minimum scale size on fullscreen state to avoid the layout viewport gets larger than the visual viewport. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 21 Jan 2019 23:35:09 +0000
changeset 514764 ada22b635f8d13adb7725c2fcac51d0e12e3ed59
parent 514763 2195f346d368042482357dc178255030ca610265
child 514765 c46ba0dfc91c8f734dc36f8c6faa5c9be0638a21
child 514781 956bd26eec5a9174753b63931d1a927a59cd4716
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1520455, 1516377, 1508177
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520455 - Don't use the minimum scale size on fullscreen state to avoid the layout viewport gets larger than the visual viewport. r=botond This is a workaround. To properly fix the issue we need to fix both of bug 1516377 and bug 1508177. Differential Revision: https://phabricator.services.mozilla.com/D17103
gfx/layers/apz/test/mochitest/helper_fullscreen.html
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_fullscreen.html
layout/generic/nsGfxScrollFrame.cpp
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_fullscreen.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width; initial-scale=1.0">
+  <title>Tests that layout viewport is not larger than visual viewport on fullscreen</title>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <style>
+    body {
+      margin: 0;
+      padding: 0;
+      overflow-x: hidden;
+    }
+  </style>
+</head>
+<body>
+  <div style="background: blue; width: 100%; height: 100%;"></div>
+  <div style="background: red; width: 200%; height: 100px;">overflowed element</div>
+  <div id="target" style="background: green; width: 100px; height: 100px;"></div>
+  <script type="application/javascript">
+    function waitForFullscreenChange() {
+      return new Promise(resolve => {
+        document.addEventListener("fullscreenchange", resolve);
+      });
+    }
+
+    async function test(testDriver) {
+      target.requestFullscreen();
+
+      await waitForFullscreenChange();
+
+      is(document.fullscreenElement, target,
+         "The target element should have been fullscreen-ed");
+
+      // Try to move rightward, but it should NOT happen.
+      SpecialPowers.getDOMWindowUtils(window).scrollToVisual(200, 0);
+
+      await waitUntilApzStable();
+
+      is(visualViewport.offsetLeft, 0,
+         "The visual viewport offset should never be moved");
+
+      document.exitFullscreen();
+    }
+
+    waitUntilApzStable().then(test).then(subtestDone);
+  </script>
+</body>
+</html>
+
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -11,16 +11,18 @@
 [test_bug1253683.html]
   skip-if = (os == 'android') || (verify && debug && (os == 'linux')) # wheel events not supported on mobile
 [test_bug1277814.html]
   skip-if = (os == 'android') # wheel events not supported on mobile
 [test_bug1304689.html]
 [test_bug1304689-2.html]
 [test_bug1464568.html]
 [test_frame_reconstruction.html]
+[test_fullscreen.html]
+  run-if = (os == 'android')
 [test_group_mouseevents.html]
   skip-if = (toolkit == 'android') # mouse events not supported on mobile
 [test_group_pointerevents.html]
   skip-if = os == 'win' && os_version == '10.0' # Bug 1404836
 [test_group_touchevents.html]
   skip-if = (verify && debug && (os == 'win'))
 [test_group_touchevents-2.html]
   skip-if = (verify && debug && (os == 'win'))
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/test_fullscreen.html
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+    if (isApzEnabled()) {
+      SimpleTest.waitForExplicitFinish();
+
+      const subtests = [
+        { file: "helper_fullscreen.html",
+          prefs: [
+            ["apz.test.logging_enabled", true],
+            ["full-screen-api.allow-trusted-requests-only", false],
+            ["dom.visualviewport.enabled", true],
+          ],
+        },
+      ];
+      // Run the actual test in its own window, because it requires that the
+      // root APZC be scrollable. Mochitest pages themselves often run
+      // inside an iframe which means we have no control over the root APZC.
+      window.onload = () => {
+        runSubtestsSeriallyInFreshWindows(subtests)
+        .then(SimpleTest.finish, SimpleTest.finish);
+      };
+    }
+  </script>
+</head>
+<body>
+</body>
+</html>
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -5488,16 +5488,22 @@ void ScrollFrameHelper::UpdateMinimumSca
       manager->DisplaySize(),
       PixelCastJustification::LayoutDeviceIsScreenForBounds);
   if (displaySize.width == 0 || displaySize.height == 0) {
     return;
   }
 
   Document* doc = pc->Document();
   MOZ_ASSERT(doc, "The document should be valid");
+  if (doc->GetFullscreenElement()) {
+    // Don't use the minimum scale size in the case of fullscreen state.
+    // FIXME: 1508177: We will no longer need this.
+    return;
+  }
+
   nsViewportInfo viewportInfo = doc->GetViewportInfo(displaySize);
   // FIXME: Bug 1520081 - Drop this check. We should use the minimum-scale size
   // even if the minimum-scale size is greater than 1.0.
   if (viewportInfo.GetMinZoom() >=
       pc->CSSToDevPixelScale() * LayoutDeviceToScreenScale(1.0f)) {
     return;
   }