Bug 1498812 - Part 2: Switch GeckoViewScrollChild to use the visual viewport. r=snorp
authorJan Henning <jh+bugzilla@buttercookie.de>
Fri, 11 Jan 2019 19:49:04 +0000
changeset 513531 bbbb9e3c793d7f9ea29e24aa23b46ee2d7e2b49d
parent 513530 466e822d2986e2481e8d0b812334b047fee0f3b0
child 513532 bf744ce7867af3c2548b1ec10233692f11f1ecf9
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)
reviewerssnorp
bugs1498812, 1371796
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 1498812 - Part 2: Switch GeckoViewScrollChild to use the visual viewport. r=snorp Given the usage example of pull-to-refresh in bug 1371796, downstream consumers will probably more interested in the true visible scroll position of the user within the page, i.e. the visual viewport. Listening for *visual* viewport events will also definitively be required to get the saveAndRestoreState GeckoView test properly working once we switch Gecko's session store helper function to use the *visual* viewport scroll position. Differential Revision: https://phabricator.services.mozilla.com/D15682
mobile/android/chrome/geckoview/GeckoViewScrollChild.js
--- a/mobile/android/chrome/geckoview/GeckoViewScrollChild.js
+++ b/mobile/android/chrome/geckoview/GeckoViewScrollChild.js
@@ -3,37 +3,39 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 ChromeUtils.import("resource://gre/modules/GeckoViewChildModule.jsm");
 
 class GeckoViewScrollChild extends GeckoViewChildModule {
   onEnable() {
     debug `onEnable`;
-    addEventListener("scroll", this, false);
+    addEventListener("mozvisualscroll", this, { mozSystemGroup: true });
   }
 
   onDisable() {
     debug `onDisable`;
-    removeEventListener("scroll", this);
+    removeEventListener("mozvisualscroll", { mozSystemGroup: true });
   }
 
   handleEvent(aEvent) {
-    if (aEvent.originalTarget.defaultView != content) {
+    if (aEvent.originalTarget.ownerGlobal != content) {
       return;
     }
 
     debug `handleEvent: ${aEvent.type}`;
 
     switch (aEvent.type) {
-      case "scroll":
+      case "mozvisualscroll":
+        let x = {}, y = {};
+        content.windowUtils.getVisualViewportOffset(x, y);
         this.eventDispatcher.sendRequest({
           type: "GeckoView:ScrollChanged",
-          scrollX: Math.round(content.scrollX),
-          scrollY: Math.round(content.scrollY),
+          scrollX: x.value,
+          scrollY: y.value,
         });
         break;
     }
   }
 }
 
 let {debug, warn} = GeckoViewScrollChild.initLogging("GeckoViewScroll");
 let module = GeckoViewScrollChild.create(this);