Bug 928640 - middle click open recent tabs and restore all tabs broken, r=jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Sun, 20 Oct 2013 22:06:24 +0200
changeset 166319 f77442b1881340c7886087823bc639a532013205
parent 166318 df6f7d68a3d2d34082b6d134e068e25bb1b560ee
child 166320 fee649b730fe1d7d1c59e2a2438cf86c0a8f1d65
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs928640
milestone27.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 928640 - middle click open recent tabs and restore all tabs broken, r=jaws
browser/base/content/browser-places.js
browser/components/sessionstore/src/RecentlyClosedTabsAndWindowsMenuUtils.jsm
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -495,30 +495,16 @@ HistoryMenu.prototype = {
     // no restorable tabs, so disable menu
     if (SessionStore.getClosedTabCount(window) == 0)
       undoMenu.setAttribute("disabled", true);
     else
       undoMenu.removeAttribute("disabled");
   },
 
   /**
-    * Re-open a closed tab and put it to the end of the tab strip.
-    * Used for a middle click.
-    * @param aEvent
-    *        The event when the user clicks the menu item
-    */
-  _undoCloseMiddleClick: function PHM__undoCloseMiddleClick(aEvent) {
-    if (aEvent.button != 1)
-      return;
-
-    undoCloseTab(aEvent.originalTarget.value);
-    gBrowser.moveTabToEnd();
-  },
-
-  /**
    * Populate when the history menu is opened
    */
   populateUndoSubmenu: function PHM_populateUndoSubmenu() {
     var undoMenu = this._rootElt.getElementsByClassName("recentlyClosedTabsMenu")[0];
     var undoPopup = undoMenu.firstChild;
 
     // remove existing menu items
     while (undoPopup.hasChildNodes())
--- a/browser/components/sessionstore/src/RecentlyClosedTabsAndWindowsMenuUtils.jsm
+++ b/browser/components/sessionstore/src/RecentlyClosedTabsAndWindowsMenuUtils.jsm
@@ -60,20 +60,18 @@ this.RecentlyClosedTabsAndWindowsMenuUti
         if (i == 0)
           element.setAttribute("key", "key_undoCloseTab");
         fragment.appendChild(element);
       }
 
       fragment.appendChild(doc.createElementNS(kNSXUL, "menuseparator"));
       let restoreAllTabs = fragment.appendChild(doc.createElementNS(kNSXUL, aTagName));
       restoreAllTabs.setAttribute("label", navigatorBundle.GetStringFromName("menuRestoreAllTabs.label"));
-      restoreAllTabs.addEventListener("command", function() {
-        for (var i = 0; i < closedTabs.length; i++)
-          undoCloseTab(0);
-      }, false);
+      restoreAllTabs.setAttribute("oncommand",
+              "for (var i = 0; i < " + closedTabs.length + "; i++) undoCloseTab(0);");
     }
     return fragment;
   },
 
   /**
   * Builds up a document fragment of UI items for the recently closed windows.
   * @param   aWindow
   *          A window that can be used to create the elements and document fragment.
@@ -123,16 +121,31 @@ this.RecentlyClosedTabsAndWindowsMenuUti
       fragment.appendChild(doc.createElementNS(kNSXUL, "menuseparator"));
       let restoreAllWindows = fragment.appendChild(doc.createElementNS(kNSXUL, aTagName));
       restoreAllWindows.setAttribute("label", navigatorBundle.GetStringFromName("menuRestoreAllWindows.label"));
       restoreAllWindows.setAttribute("oncommand",
         "for (var i = 0; i < " + closedWindowData.length + "; i++) undoCloseWindow();");
     }
     return fragment;
   },
+
+
+  /**
+    * Re-open a closed tab and put it to the end of the tab strip.
+    * Used for a middle click.
+    * @param aEvent
+    *        The event when the user clicks the menu item
+    */
+  _undoCloseMiddleClick: function(aEvent) {
+    if (aEvent.button != 1)
+      return;
+
+    aEvent.view.undoCloseTab(aEvent.originalTarget.value);
+    aEvent.view.gBrowser.moveTabToEnd();
+  },
 };
 
 function setImage(aItem, aElement) {
   let iconURL = aItem.image;
   // don't initiate a connection just to fetch a favicon (see bug 467828)
   if (/^https?:/.test(iconURL))
     iconURL = "moz-anno:favicon:" + iconURL;
   aElement.setAttribute("image", iconURL);