Bug 620714 - Chrome scrollbars appears too early when touching a chrome scrollbox [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Tue, 21 Dec 2010 19:40:02 +0100
changeset 67151 ac4824435f189be0bec1eaa0230b163947e231cc
parent 67150 b8cd409005013b52b9affda4d1d97332223c62a0
child 67152 12b3e6b94d82b21a6a1d51569639f1e9b7676c3d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs620714
Bug 620714 - Chrome scrollbars appears too early when touching a chrome scrollbox [r=mfinkle]
mobile/chrome/content/input.js
--- a/mobile/chrome/content/input.js
+++ b/mobile/chrome/content/input.js
@@ -194,17 +194,17 @@ MouseModule.prototype = {
     // returned if none found.
     let [targetScrollbox, targetScrollInterface, dragger]
       = ScrollUtils.getScrollboxFromElement(aEvent.target);
 
     // stop kinetic panning if targetScrollbox has changed
     if (this._kinetic.isActive() && this._dragger != dragger)
       this._kinetic.end();
 
-    this._targetScrollbox = targetScrollbox;
+    this._targetScrollbox = targetScrollInterface ? targetScrollInterface.element : targetScrollbox;
     this._targetScrollInterface = targetScrollInterface;
 
     // Do tap
     let event = document.createEvent("Events");
     event.initEvent("TapDown", true, true);
     event.clientX = aEvent.clientX;
     event.clientY = aEvent.clientY;
     let success = aEvent.target.dispatchEvent(event);
@@ -585,44 +585,54 @@ var ScrollUtils = {
     isDraggable: function isDraggable(target, scroller) {
       let sX = {}, sY = {};
       scroller.getScrolledSize(sX, sY);
       let rect = target.getBoundingClientRect();
       return { x: sX.value > rect.width, y: sY.value > rect.height };
     },
 
     dragStart: function dragStart(cx, cy, target, scroller) {
-      scroller.element.setAttribute("panning", "true");
+      scroller.element.addEventListener("PanBegin", this._showScrollbars, false);
     },
 
-    dragStop : function dragStop(dx, dy, scroller) {
-      scroller.element.removeAttribute("panning");
+    dragStop: function dragStop(dx, dy, scroller) {
+      scroller.element.removeEventListener("PanBegin", this._showScrollbars, false);
       return this.dragMove(dx, dy, scroller);
     },
 
-    dragMove : function dragMove(dx, dy, scroller) {
+    dragMove: function dragMove(dx, dy, scroller) {
       if (scroller.getPosition) {
         try {
-
           let oldX = {}, oldY = {};
           scroller.getPosition(oldX, oldY);
 
           scroller.scrollBy(dx, dy);
 
           let newX = {}, newY = {};
           scroller.getPosition(newX, newY);
 
           return (newX.value != oldX.value) || (newY.value != oldY.value);
 
         } catch (e) { /* we have no time for whiny scrollers! */ }
       }
 
       return false;
+    },
+
+    _showScrollbars: function _showScrollbars(aEvent) {
+      let scrollbox = aEvent.target;
+      scrollbox.setAttribute("panning", "true");
+
+      // Wait for panning to be completely finished before removing scrollbars
+      scrollbox.addEventListener("PanFinished", function(aEvent) {
+        scrollbox.removeEventListener("PanFinished", arguments.callee, false);
+        scrollbox.removeAttribute("panning");
+      }, false);
     }
-  },
+  }
 };
 
 /**
  * DragData handles processing drags on the screen, handling both
  * locking of movement on one axis, and click detection.
  */
 function DragData() {
   this._domUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);