Bug 1016944 - Events are processed twice in BrowserElementPanning.js for nested in-process mozbrowser iframes. r=fabrice
authorVivien Nicolas <vnicolas@mozilla.com>
Fri, 11 Jul 2014 16:17:19 +0200
changeset 215511 5e3f42130258a30d1d23bb8321366cecd208be70
parent 215510 673ad6aa248df39a782794180387b5379c2bc575
child 215512 8f50bc05d3373561b0d0e6a27a063361c0b37970
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1016944
milestone33.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 1016944 - Events are processed twice in BrowserElementPanning.js for nested in-process mozbrowser iframes. r=fabrice
dom/browser-element/BrowserElementPanning.js
--- a/dom/browser-element/BrowserElementPanning.js
+++ b/dom/browser-element/BrowserElementPanning.js
@@ -79,22 +79,40 @@ const ContentPanning = {
       // missing events if .stopPropagation() has been called.
       els.addSystemEventListener(global, type,
                                  this.handleEvent.bind(this),
                                  /* useCapture = */ false);
     }.bind(this));
   },
 
   handleEvent: function cp_handleEvent(evt) {
-    // Ignore events targeting a <iframe mozbrowser> since those will be
-    // handle by the BrowserElementPanning.js instance of it.
+    // Ignore events targeting an oop <iframe mozbrowser> since those will be
+    // handle by the BrowserElementPanning.js instance in the child process.
     if (evt.target instanceof Ci.nsIMozBrowserFrame) {
       return;
     }
 
+    // For in-process <iframe mozbrowser> the events are not targetting
+    // directly the container iframe element, but some node of the document.
+    // So, the BrowserElementPanning instance of the system app will receive
+    // the sequence of touch events, as well as the BrowserElementPanning
+    // instance in the targetted app.
+    // As a result, multiple mozbrowser iframes will try to interpret the
+    // sequence of touch events, which may results into multiple clicks.
+    let targetWindow = evt.target.ownerDocument.defaultView;
+    let frameElement = targetWindow.frameElement;
+    while (frameElement) {
+      targetWindow = frameElement.ownerDocument.defaultView;
+      frameElement = targetWindow.frameElement;
+    }
+
+    if (content !== targetWindow) {
+      return;
+    }
+
     if (evt.defaultPrevented || evt.multipleActionsPrevented) {
       // clean up panning state even if touchend/mouseup has been preventDefault.
       if(evt.type === 'touchend' || evt.type === 'mouseup') {
         if (this.dragging &&
             (this.watchedEventsType === 'mouse' ||
              this.findPrimaryPointer(evt.changedTouches))) {
           this._finishPanning();
         }