Bug 856264 - Defect - if context menu visible, tapping and holding another link will not produce new context menu. r=jmathies
authorJonathan Wilde <jwilde@jwilde.me>
Mon, 15 Jul 2013 10:58:26 -0700
changeset 138532 4a49288dc2d07dbb121f4854d4662541dc60eb78
parent 138531 8b2b8ac3507a9acca15e19f683f0e951577d4005
child 138533 302fb81f07292d351c06908a11fab95afc5ef1df
push id24961
push useremorley@mozilla.com
push dateTue, 16 Jul 2013 08:58:21 +0000
treeherdermozilla-central@41ed26826acb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies
bugs856264
milestone25.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 856264 - Defect - if context menu visible, tapping and holding another link will not produce new context menu. r=jmathies
browser/metro/base/content/helperui/MenuUI.js
--- a/browser/metro/base/content/helperui/MenuUI.js
+++ b/browser/metro/base/content/helperui/MenuUI.js
@@ -333,43 +333,57 @@ var MenuControlUI = {
     this._menuPopup.hide();
   }
 };
 
 function MenuPopup(aPanel, aPopup) {
   this._panel = aPanel;
   this._popup = aPopup;
   this._wantTypeBehind = false;
+  this._willReshowPopup = false;
 
   window.addEventListener('MozAppbarShowing', this, false);
 }
 MenuPopup.prototype = {
   get _visible() { return !this._panel.hidden; },
   get _commands() { return this._popup.childNodes[0]; },
 
   show: function (aPositionOptions) {
-    if (this._visible)
-      return;
+    if (this._visible) {
+      this._willReshowPopup = true;
+      let self = this;
+      this._panel.addEventListener("transitionend", function () {
+        self._show(aPositionOptions);
+        self._panel.removeEventListener("transitionend", arguments.callee);
+      });
+    } else {
+      this._show(aPositionOptions);
+    }
+  },
 
+  _show: function (aPositionOptions) {
     window.addEventListener("keypress", this, true);
     window.addEventListener("mousedown", this, true);
     Elements.stack.addEventListener("PopupChanged", this, false);
     Elements.browsers.addEventListener("PanBegin", this, false);
 
     this._panel.hidden = false;
     this._position(aPositionOptions || {});
 
     let self = this;
     this._panel.addEventListener("transitionend", function () {
       self._panel.removeEventListener("transitionend", arguments.callee);
       self._panel.removeAttribute("showingfrom");
 
+      let eventName = self._willReshowPopup ? "popupmoved" : "popupshown";
       let event = document.createEvent("Events");
-      event.initEvent("popupshown", true, false);
-      document.dispatchEvent(event);
+      event.initEvent(eventName, true, false);
+      self._panel.dispatchEvent(event);
+
+      self._willReshowPopup = false;
     });
 
     let popupFrom = !aPositionOptions.bottomAligned ? "above" : "below";
     this._panel.setAttribute("showingfrom", popupFrom);
 
     // Ensure the panel actually gets shifted before getting animated
     setTimeout(function () {
       self._panel.setAttribute("showing", "true");
@@ -388,19 +402,21 @@ MenuPopup.prototype = {
     let self = this;
     this._panel.addEventListener("transitionend", function () {
       self._panel.removeEventListener("transitionend", arguments.callee);
       self._panel.removeAttribute("hiding");
       self._panel.hidden = true;
       self._popup.style.maxWidth = "none";
       self._popup.style.maxHeight = "none";
 
-      let event = document.createEvent("Events");
-      event.initEvent("popuphidden", true, false);
-      document.dispatchEvent(event);
+      if (!self._willReshowPopup) {
+        let event = document.createEvent("Events");
+        event.initEvent("popuphidden", true, false);
+        self._panel.dispatchEvent(event);
+      }
     });
 
     this._panel.setAttribute("hiding", "true");
     setTimeout(()=>this._panel.removeAttribute("showing"), 0);
   },
 
   _position: function _position(aPositionOptions) {
     let aX = aPositionOptions.xPos;