Bug 1520081 - Use the minimum scale size even if the minimum-scale in viewport meta tag is greater than 1.0. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 25 Jan 2019 07:01:45 +0000
changeset 512517 8c3a041f077f9d01e12aff3fe2dbc9beb0ed82f8
parent 512516 30b603686936b9247510a0276e765e558bb91ae6
child 512518 9bab87de8e3c8be666f0bc459519b4f26d8483a3
child 512539 0b28e8a97af41f05727b0da6228e343bf6e57da4
push id10566
push userarchaeopteryx@coole-files.de
push dateMon, 28 Jan 2019 12:41:12 +0000
treeherdermozilla-beta@69a3d7c8d04b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1520081
milestone66.0a1
first release with
nightly linux32
8c3a041f077f / 66.0a1 / 20190125095457 / files
nightly linux64
8c3a041f077f / 66.0a1 / 20190125095457 / files
nightly mac
8c3a041f077f / 66.0a1 / 20190125095457 / files
nightly win32
8c3a041f077f / 66.0a1 / 20190125095457 / files
nightly win64
8c3a041f077f / 66.0a1 / 20190125095457 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1520081 - Use the minimum scale size even if the minimum-scale in viewport meta tag is greater than 1.0. r=botond Differential Revision: https://phabricator.services.mozilla.com/D17451
gfx/layers/apz/test/mochitest/helper_minimum_scale_1_0.html
gfx/layers/apz/test/mochitest/mochitest.ini
gfx/layers/apz/test/mochitest/test_group_minimum_scale_size.html
layout/generic/nsGfxScrollFrame.cpp
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_minimum_scale_1_0.html
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=200, minimum-scale=1.0, initial-scale=2.0">
+  <title>Tests that the layout viewport is expanted to the minimum scale size (minimim-scale >= 1.0)</title>
+  <script type="application/javascript" src="apz_test_utils.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
+  <style>
+    html,body {
+      overflow-x: hidden;
+      margin: 0;
+    }
+    div {
+      position: absolute;
+    }
+  </style>
+</head>
+<body>
+  <div style="width: 200%; height: 200%; background-color: green"></div>
+  <div style="width: 100%; height: 100%; background-color: blue"></div>
+  <script type="application/javascript">
+    async function test(testDriver) {
+      SpecialPowers.getDOMWindowUtils(window).scrollToVisual(100, 0);
+
+      const promiseForVisualViewportScroll = new Promise(resolve => {
+        window.visualViewport.addEventListener("scroll", () => {
+          resolve();
+        }, { once: true });
+      });
+
+      await waitUntilApzStable();
+
+      await promiseForVisualViewportScroll;
+
+      is(visualViewport.offsetLeft, 100,
+         "The visual viewport offset should be moved");
+    }
+
+    waitUntilApzStable().then(test).then(subtestDone);
+  </script>
+</body>
+</html>
+
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -13,16 +13,18 @@
 [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_minimum_scale_size.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_group_minimum_scale_size.html
@@ -0,0 +1,62 @@
+<!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">
+const prefs = [
+  // We need the APZ paint logging information
+  ["apz.test.logging_enabled", true],
+  // Dropping the touch slop to 0 makes the tests easier to write because
+  // we can just do a one-pixel drag to get over the pan threshold rather
+  // than having to hard-code some larger value.
+  ["apz.touch_start_tolerance", "0.0"],
+  // The subtests in this test do touch-drags to pan the page, but we don't
+  // want those pans to turn into fling animations, so we increase the
+  // fling-min threshold velocity to an arbitrarily large value.
+  ["apz.fling_min_velocity_threshold", "10000"],
+  // The helper_bug1280013's div gets a displayport on scroll, but if the
+  // test takes too long the displayport can expire before we read the value
+  // out of the test. So we disable displayport expiry for these tests.
+  ["apz.displayport_expiry_ms", 0],
+  // Prevent the dynamic toolbar from interfering with main-thread scroll
+  // offset values.
+  ["browser.chrome.dynamictoolbar", false],
+  // Explicitly enable pinch-zooming, so this test can run on desktop
+  // even though zooming isn't enabled by default on desktop yet.
+  ["apz.allow_zooming", true],
+  // Pinch-zooming currently requires meta viewport support (this requirement
+  // will eventually be removed).
+  ["dom.meta-viewport.enabled", true],
+  // Pinch-zooming currently requires container scrolling (this requirement
+  // will eventually be removed).
+  ["layout.scroll.root-frame-containers", 1],
+  // Retained displaylists don't work well with container scrolling, so
+  // they too need to be disabled for now.
+  ["layout.display-list.retain", false],
+  ["layout.display-list.retain.chrome", false],
+  // We use the Visual Viewport API to tell the visual viewport offset.
+  ["dom.visualviewport.enabled", true],
+];
+
+const subtests = [
+  { file: "helper_minimum_scale_1_0.html", prefs },
+];
+
+if (isApzEnabled()) {
+  SimpleTest.waitForExplicitFinish();
+  // 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
@@ -5506,23 +5506,16 @@ void ScrollFrameHelper::UpdateMinimumSca
   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;
-  }
-
   nsSize maximumPossibleSize =
       CSSSize::ToAppUnits(ScreenSize(displaySize) / viewportInfo.GetMinZoom());
 
   mMinimumScaleSize =
       Min(maximumPossibleSize,
           nsSize(aScrollableOverflow.XMost(), aScrollableOverflow.YMost()));
   mMinimumScaleSize = Max(aICBSize, mMinimumScaleSize);