Bug 889717 - Do not send focus when the user taps to stop scrolling. r=vingtetun
authorAnthony Ricaud <anthony@ricaud.me>
Wed, 04 Sep 2013 08:29:46 -0400
changeset 158441 e92a979238640641475862420bac820117d493e2
parent 158440 008139ec2abb425e1bc4c978e793bb7f1e2a618e
child 158442 9dc1fcc1964eb4fd71e562148cdcf78aa1c6211d
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs889717
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 889717 - Do not send focus when the user taps to stop scrolling. r=vingtetun
dom/browser-element/BrowserElementPanning.js
--- a/dom/browser-element/BrowserElementPanning.js
+++ b/dom/browser-element/BrowserElementPanning.js
@@ -178,16 +178,22 @@ const ContentPanning = {
       KineticPanning.stop();
 
       if (oldTarget && oldTarget == this.target)
         this.preventNextClick = true;
     }
 
     this.position.set(screenX, screenY);
     KineticPanning.record(new Point(0, 0), evt.timeStamp);
+
+    // We prevent start events to avoid sending a focus event at the end of this
+    // touch series. See bug 889717.
+    if (this.panning || this.preventNextClick) {
+      evt.preventDefault();
+    }
   },
 
   onTouchEnd: function cp_onTouchEnd(evt) {
     let touch = null;
     if (!this.dragging ||
         (this.watchedEventsType == 'touch' &&
          !(touch = this.findPrimaryPointer(evt.changedTouches)))) {
       return;
@@ -209,20 +215,25 @@ const ContentPanning = {
     // same element.
     if (this.hybridEvents) {
       let target =
         content.document.elementFromPoint(touch.clientX, touch.clientY);
       click |= (target === this.pointerDownTarget);
     }
 
     if (this.target && click && (this.panning || this.preventNextClick)) {
-      let target = this.target;
-      let view = target.ownerDocument ? target.ownerDocument.defaultView
-                                      : target;
-      view.addEventListener('click', this, true, true);
+      if (this.hybridEvents) {
+        let target = this.target;
+        let view = target.ownerDocument ? target.ownerDocument.defaultView
+                                        : target;
+        view.addEventListener('click', this, true, true);
+      } else {
+        // We prevent end events to avoid sending a focus event. See bug 889717.
+        evt.preventDefault();
+      }
     }
 
     this._finishPanning();
 
     // Now that we're done, avoid entraining the thing we just panned.
     this.pointerDownTarget = null;
   },