Bug 732350 - [b2g] Cancel the click event sooner when panning has started to prevent unexpected clicks r=fabrice
authorVivien Nicolas <21@vingtetun.org>
Mon, 05 Mar 2012 09:55:51 +0100
changeset 88452 42854b29525f0b2c355ab08de5024b9e54f24bb9
parent 88451 87ad615157d415f6933395df6e943f6156ba69c8
child 88453 d8002cdcc6fb2aa097c534285f76a2c74abbf3e8
push id157
push userMs2ger@gmail.com
push dateWed, 07 Mar 2012 19:27:10 +0000
reviewersfabrice
bugs732350
milestone13.0a1
Bug 732350 - [b2g] Cancel the click event sooner when panning has started to prevent unexpected clicks r=fabrice
b2g/chrome/content/webapi.js
--- a/b2g/chrome/content/webapi.js
+++ b/b2g/chrome/content/webapi.js
@@ -176,17 +176,20 @@ const ContentPanning = {
         this.onTouchMove(evt);
         break;
       case 'mouseup':
         this.onTouchEnd(evt);
         break;
       case 'click':
         evt.stopPropagation();
         evt.preventDefault();
-        evt.target.removeEventListener('click', this, true);
+        
+        let target = evt.target;
+        let view = target.defaultView || target.ownerDocument.defaultView;
+        view.removeEventListener('click', this, true, true);
         break;
     }
   },
 
   position: new Point(0 , 0),
 
   onTouchStart: function cp_onTouchStart(evt) {
     this.dragging = true;
@@ -208,18 +211,21 @@ const ContentPanning = {
     if (!this.dragging)
       return;
     this.dragging = false;
 
     this.onTouchMove(evt);
 
     let pan = KineticPanning.isPan();
     let click = evt.detail;
-    if (click && (pan || this.preventNextClick))
-      evt.target.addEventListener('click', this, true);
+    if (click && (pan || this.preventNextClick)) {
+      let target = evt.target;
+      let view = target.defaultView || target.ownerDocument.defaultView;
+      view.addEventListener('click', this, true, true);
+    }
 
     this.preventNextClick = false;
 
     if (pan)
       KineticPanning.start(this);
   },
 
   onTouchMove: function cp_onTouchMove(evt) {