Bug 907098 - Prevent scrolling of chrome content using apz. r=mbrubeck
authorJim Mathies <jmathies@mozilla.com>
Mon, 09 Sep 2013 13:57:25 -0500
changeset 146214 f583bcbb5e82affa7895b0b65d2a0794c47b6cfa
parent 146213 5b664dac677c05dcd2a0ccb080c3792cfee3f4f6
child 146215 14eb0d5731d64b657282f9e94107f6e65aa5a529
push id25245
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 20:57:55 +0000
treeherdermozilla-central@a468b2e34b04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs907098
milestone26.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 907098 - Prevent scrolling of chrome content using apz. r=mbrubeck
browser/metro/base/content/apzc.js
browser/metro/base/content/browser-scripts.js
browser/metro/base/content/browser.xul
browser/metro/base/content/input.js
--- a/browser/metro/base/content/apzc.js
+++ b/browser/metro/base/content/apzc.js
@@ -11,16 +11,22 @@ let Cr = Components.results;
 /**
  * Handler for APZC display port and pan begin/end notifications.
  * These notifications are only sent by widget/windows/winrt code when
  * the pref: layers.async-pan-zoom.enabled is true.
  */
 
 var APZCObserver = {
   _debugEvents: false,
+  _enabled: false,
+
+  get enabled() {
+    return this._enabled;
+  },
+
   init: function() {
     this._enabled = Services.prefs.getBoolPref(kAsyncPanZoomEnabled);
     if (!this._enabled) {
       return;
     }
 
     let os = Services.obs;
     os.addObserver(this, "apzc-request-content-repaint", false);
--- a/browser/metro/base/content/browser-scripts.js
+++ b/browser/metro/base/content/browser-scripts.js
@@ -103,16 +103,17 @@ let ScriptContexts = {};
   ["TopSites", "chrome://browser/content/TopSites.js"],
   ["Sanitizer", "chrome://browser/content/sanitize.js"],
   ["SanitizeUI", "chrome://browser/content/sanitizeUI.js"],
   ["SSLExceptions", "chrome://browser/content/exceptions.js"],
   ["ItemPinHelper", "chrome://browser/content/helperui/ItemPinHelper.js"],
   ["NavButtonSlider", "chrome://browser/content/NavButtonSlider.js"],
   ["ContextUI", "chrome://browser/content/ContextUI.js"],
   ["FlyoutPanelsUI", "chrome://browser/content/flyoutpanels/FlyoutPanelsUI.js"],
+  ["APZCObserver", "chrome://browser/content/apzc.js"],
 ].forEach(function (aScript) {
   let [name, script] = aScript;
   XPCOMUtils.defineLazyGetter(window, name, function() {
     let sandbox;
     if (script in ScriptContexts) {
       sandbox = ScriptContexts[script];
     } else {
       sandbox = ScriptContexts[script] = {};
--- a/browser/metro/base/content/browser.xul
+++ b/browser/metro/base/content/browser.xul
@@ -42,17 +42,16 @@
         xmlns:html="http://www.w3.org/1999/xhtml">
 
   <script type="application/javascript" src="chrome://browser/content/browser.js"/>
   <script type="application/javascript" src="chrome://browser/content/browser-scripts.js"/>
   <script type="application/javascript" src="chrome://browser/content/browser-ui.js"/>
   <script type="application/javascript" src="chrome://browser/content/Util.js"/>
   <script type="application/javascript" src="chrome://browser/content/input.js"/>
   <script type="application/javascript" src="chrome://browser/content/appbar.js"/>
-  <script type="application/javascript" src="chrome://browser/content/apzc.js"/>
   <broadcasterset id="broadcasterset">
     <broadcaster id="bcast_contentShowing" disabled="false"/>
     <broadcaster id="bcast_urlbarState" mode="editing"/>
     <broadcaster id="bcast_preciseInput" input="precise"/>
     <broadcaster id="bcast_windowState" viewstate=""/>
     <broadcaster id="bcast_loadingState" loading="false"/>
   </broadcasterset>
 
--- a/browser/metro/base/content/input.js
+++ b/browser/metro/base/content/input.js
@@ -306,18 +306,25 @@ var TouchModule = {
    */
   _onTouchMove: function _onTouchMove(aEvent) {
     if (aEvent.touches.length > 1)
       return;
 
     if (this._isCancellable) {
       // only the first touchmove is cancellable.
       this._isCancellable = false;
-      if (aEvent.defaultPrevented)
+      if (aEvent.defaultPrevented) {
         this._isCancelled = true;
+      }
+      // Help out chrome ui elements that want input.js vs. apz scrolling: call
+      // preventDefault when apz is enabled on anything that isn't in the
+      // browser.
+      if (APZCObserver.enabled && aEvent.target.ownerDocument == document) {
+        aEvent.preventDefault();
+      }
     }
 
     if (this._isCancelled)
       return;
 
     let touch = aEvent.changedTouches[0];
     if (!this._targetScrollbox) {
       return;
@@ -347,18 +354,16 @@ var TouchModule = {
         // Only pan when mouse event isn't part of a click. Prevent jittering on tap.
         this._kinetic.addData(sX - dragData.prevPanX, sY - dragData.prevPanY);
 
         // dragBy will reset dX and dY values to 0
         this._dragBy(this.dX, this.dY);
 
         // Let everyone know when mousemove begins a pan
         if (!oldIsPan && dragData.isPan()) {
-          //this._longClickTimeout.clear();
-
           let event = document.createEvent("Events");
           event.initEvent("PanBegin", true, false);
           this._targetScrollbox.dispatchEvent(event);
 
           Browser.selectedBrowser.messageManager.sendAsyncMessage("Browser:PanBegin", {});
         }
       }
     }