Bug 575939 - View is pannable once context menu has been displayed [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Wed, 30 Jun 2010 19:22:57 +0200
changeset 66339 009428469bc27e7ac532dc232fbb9001765e3f6f
parent 66338 be44142cc0f05d263876948e61900cf31b2793a8
child 66340 6f8ad1be8eae2a1c780390323ce6ee2448b41baf
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
bugs575939
Bug 575939 - View is pannable once context menu has been displayed [r=mfinkle]
mobile/chrome/content/InputHandler.js
mobile/chrome/content/browser.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -133,17 +133,16 @@ function InputHandler(browserViewContain
   window.addEventListener("MozMagnifyGesture", this, true);
 
   /* these handle key strokes in the browser view (where page content appears) */
   browserViewContainer.addEventListener("keypress", this, false);
   browserViewContainer.addEventListener("keyup", this, false);
   browserViewContainer.addEventListener("keydown", this, false);
   browserViewContainer.addEventListener("DOMMouseScroll", this, true);
   browserViewContainer.addEventListener("MozMousePixelScroll", this, true);
-  browserViewContainer.addEventListener("contextmenu", this, true);
 
   this.addModule(new MouseModule(this, browserViewContainer));
   this.addModule(new KeyModule(this, browserViewContainer));
   this.addModule(new GestureModule(this, browserViewContainer));
   this.addModule(new ScrollwheelModule(this, browserViewContainer));
 }
 
 
@@ -350,55 +349,59 @@ function MouseModule(owner, browserViewC
   this._clicker = null;
 
   this._downUpEvents = [];
   this._targetScrollInterface = null;
 
   var self = this;
   this._kinetic = new KineticController(Util.bind(this._dragBy, this),
                                         Util.bind(this._kineticStop, this));
+
+  messageManager.addMessageListener("Browser:ContextMenu", this);
 }
 
 
 MouseModule.prototype = {
   handleEvent: function handleEvent(evInfo) {
     let evt = evInfo.event;
-    if (evt.button !== 0 && evt.type != "contextmenu")
+    if (evt.button !== 0)
       return;
 
     switch (evt.type) {
       case "mousedown":
         this._onMouseDown(evInfo);
         break;
       case "mousemove":
         this._onMouseMove(evInfo);
         break;
       case "mouseup":
         this._onMouseUp(evInfo);
         break;
-      case "contextmenu":
-        // TODO: Make "contextmenu" a first class part of InputHandler
-        // Bug 554639
-        if (ContextHelper.popupNode) {
-          if (this._clicker)
-            this._clicker.panBegin();
-          if (this._dragger)
-            this._dragger.dragStop(0, 0, this._targetScrollInterface);
-          this.cancelPending();
-        }
-        break;
       case "MozMagnifyGestureStart":
       case "MozMagnifyGesture":
         // disallow kinetic panning after gesture
         if (this._dragData.dragging)
           this._doDragStop(0, 0, true);
         break;
     }
   },
 
+  receiveMessage: function receiveMessage(aMessage) {
+    // TODO: Make "contextmenu" a first class part of InputHandler
+    // Bug 554639
+    if (aMessage.name != "Browser:ContextMenu" || !ContextHelper.popupState)
+      return;
+
+    if (this._clicker)
+      this._clicker.panBegin();
+    if (this._dragger)
+      this._dragger.dragStop(0, 0, this._targetScrollInterface);
+    this.cancelPending();
+  },
+
   /**
    * This gets invoked by the input handler if another module grabs.  We should
    * reset our state or something here.  This is probably doing the wrong thing
    * in its current form.
    */
   cancelPending: function cancelPending() {
     if (this._kinetic.isActive())
       this._kinetic.end();
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -471,21 +471,21 @@ var Browser = {
       // Let the view know that the layout might have changed
       Browser.forceChromeReflow();
       bv.onAfterVisibleMove();
     }
     let notifications = document.getElementById("notifications");
     notifications.addEventListener("AlertActive", notificationHandler, false);
     notifications.addEventListener("AlertClose", notificationHandler, false);
 
+    BrowserUI.init();
+
     // initialize input handling
     ih = new InputHandler(container);
 
-    BrowserUI.init();
-
     window.controllers.appendController(this);
     window.controllers.appendController(BrowserUI);
 
     var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
     os.addObserver(gXPInstallObserver, "addon-install-blocked", false);
     os.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
 
     // clear out tabs the user hasn't touched lately on memory crunch