Bug 869940 - Fix selection when APZC is enabled. r=jimm
authorBrian R. Bondy <netzen@gmail.com>
Thu, 25 Jul 2013 13:15:20 -0400
changeset 152326 692b48b7c022b69a5a215b2bc3df04dd0f334ff8
parent 152325 6a8926881a44ace1739d0e873e5b2b948a434e0c
child 152327 e110da5fee57b5b9cc5711bf6f776f6ee469bb5c
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs869940
milestone25.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 869940 - Fix selection when APZC is enabled. r=jimm
browser/metro/base/content/input.js
--- a/browser/metro/base/content/input.js
+++ b/browser/metro/base/content/input.js
@@ -195,21 +195,16 @@ var TouchModule = {
     // context menu has appeared.
     if (ContextMenuUI.popupState) {
       this.cancelPending();
     }
   },
 
   /** Begin possible pan and send tap down event. */
   _onTouchStart: function _onTouchStart(aEvent) {
-    if (Services.prefs.getBoolPref(kAsyncPanZoomEnabled) &&
-        !StartUI.isStartPageVisible) {
-      return;
-    }
-
     if (aEvent.touches.length > 1)
       return;
 
     this._isCancelled = false;
     this._isCancellable = true;
 
     if (aEvent.defaultPrevented) {
       this._isCancelled = true;
@@ -236,57 +231,55 @@ var TouchModule = {
 
     this._targetScrollbox = targetScrollInterface ? targetScrollInterface.element : targetScrollbox;
     this._targetScrollInterface = targetScrollInterface;
 
     if (!this._targetScrollbox) {
       return;
     }
 
+    // Don't allow kinetic panning if APZC is enabled and the pan element is the deck
+    let deck = document.getElementById("browsers");
+    if (Services.prefs.getBoolPref(kAsyncPanZoomEnabled) &&
+        !StartUI.isStartPageVisible &&
+        this._targetScrollbox == deck) {
+      return;
+    }
+
     // XXX shouldn't dragger always be valid here?
     if (dragger) {
       let draggable = dragger.isDraggable(targetScrollbox, targetScrollInterface);
       dragData.locked = !draggable.x || !draggable.y;
       if (draggable.x || draggable.y) {
         this._dragger = dragger;
         if (dragger.freeDrag)
           dragData.alwaysFreeDrag = dragger.freeDrag();
         this._doDragStart(aEvent, draggable);
       }
     }
   },
 
   /** Send tap up event and any necessary full taps. */
   _onTouchEnd: function _onTouchEnd(aEvent) {
-    if (Services.prefs.getBoolPref(kAsyncPanZoomEnabled) &&
-        !StartUI.isStartPageVisible) {
-      return;
-    }
-
     if (aEvent.touches.length > 0 || this._isCancelled || !this._targetScrollbox)
       return;
 
     // onMouseMove will not record the delta change if we are waiting for a
     // paint. Since this is the last input for this drag, we override the flag.
     this._waitingForPaint = false;
     this._onTouchMove(aEvent);
 
     let dragData = this._dragData;
     this._doDragStop();
   },
 
   /**
    * If we're in a drag, do what we have to do to drag on.
    */
   _onTouchMove: function _onTouchMove(aEvent) {
-    if (Services.prefs.getBoolPref(kAsyncPanZoomEnabled) &&
-        !StartUI.isStartPageVisible) {
-      return;
-    }
-
     if (aEvent.touches.length > 1)
       return;
 
     if (this._isCancellable) {
       // only the first touchmove is cancellable.
       this._isCancellable = false;
       if (aEvent.defaultPrevented)
         this._isCancelled = true;
@@ -365,18 +358,25 @@ var TouchModule = {
 
     // Note: it is possible for kinetic scrolling to be active from a
     // mousedown/mouseup event previous to this one. In this case, we
     // want the kinetic panner to tell our drag interface to stop.
 
     if (dragData.isPan()) {
       if (Date.now() - this._dragStartTime > kStopKineticPanOnDragTimeout)
         this._kinetic._velocity.set(0, 0);
-      // Start kinetic pan.
-      this._kinetic.start();
+
+      // Start kinetic pan if we i) aren't using async pan zoom or ii) if we
+      // are on the start page, iii) If the scroll element is not browsers
+      let deck = document.getElementById("browsers");
+      if (!Services.prefs.getBoolPref(kAsyncPanZoomEnabled) ||
+          StartUI.isStartPageVisible ||
+          this._targetScrollbox != deck) {
+        this._kinetic.start();
+      }
     } else {
       this._kinetic.end();
       if (this._dragger)
         this._dragger.dragStop(0, 0, this._targetScrollInterface);
       this._dragger = null;
     }
   },