diff --git a/browser/base/content/browser-tabview.js b/browser/base/content/browser-tabview.js index 2cd896d17fd0..6f561ecc0ab4 100644 --- a/browser/base/content/browser-tabview.js +++ b/browser/base/content/browser-tabview.js @@ -233,15 +233,9 @@ let TabView = { event.preventDefault(); self._initFrame(function() { - let groupItems = self._window.GroupItems; - let tabItem = groupItems.getNextGroupItemTab(event.shiftKey); - if (!tabItem) - return; - - // Switch to the new tab, and close the old group if it's now empty. - let oldGroupItem = groupItems.getActiveGroupItem(); - window.gBrowser.selectedTab = tabItem.tab; - oldGroupItem.closeIfEmpty(); + let tabItem = self._window.GroupItems.getNextGroupItemTab(event.shiftKey); + if (tabItem) + window.gBrowser.selectedTab = tabItem.tab; }); } }, true); diff --git a/browser/base/content/tabview/groupitems.js b/browser/base/content/tabview/groupitems.js index 147f601f2bac..50e1091f68dc 100644 --- a/browser/base/content/tabview/groupitems.js +++ b/browser/base/content/tabview/groupitems.js @@ -623,21 +623,6 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { } }, - // ---------- - // Function: closeIfEmpty - // Closes the group if it's empty, unlocked, has no title, is closable, and - // autoclose is enabled (see pauseAutoclose()). Returns true if the close - // occurred and false otherwise. - closeIfEmpty: function() { - if (!this._children.length && !this.locked.close && !this.getTitle() && - !GroupItems.getUnclosableGroupItemId() && - !GroupItems._autoclosePaused) { - this.close(); - return true; - } - return false; - }, - // ---------- // Function: _unhide // Shows the hidden group. @@ -885,9 +870,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { item.groupItemData = {}; item.addSubscriber(this, "close", function() { - let dontClose = !item.closedManually && gBrowser._numPinnedTabs > 0; - self.remove(item, { dontClose: dontClose }); - + self.remove(item); if (self._children.length > 0 && self._activeTab) { GroupItems.setActiveGroupItem(self); UI.setActiveTab(self._activeTab); @@ -975,11 +958,17 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), { if (typeof item.setResizable == 'function') item.setResizable(true, options.immediately); - let closed = options.dontClose ? false : this.closeIfEmpty(); - if (closed) - this._makeClosestTabActive(); - else if (!options.dontArrage) + if (this._children.length == 0 && !this.locked.close && !this.getTitle() && + !options.dontClose) { + if (!GroupItems.getUnclosableGroupItemId()) { + this.close(); + this._makeClosestTabActive(); + } else { + // this.close(); this line is causing the leak but the leak doesn't happen after re-enabling it + } + } else if (!options.dontArrange) { this.arrange({animate: !options.immediately}); + } this._sendToSubscribers("childRemoved",{ groupItemId: this.id, item: item }); } catch(e) { @@ -1692,7 +1681,6 @@ let GroupItems = { _arrangesPending: [], _removingHiddenGroups: false, _delayedModUpdates: [], - _autoclosePaused: false, minGroupHeight: 110, minGroupWidth: 125, @@ -2448,21 +2436,5 @@ let GroupItems = { return new Point( Math.max(size.x, GroupItems.minGroupWidth), Math.max(size.y, GroupItems.minGroupHeight)); - }, - - // ---------- - // Function: pauseAutoclose() - // Temporarily disable the behavior that closes groups when they become - // empty. This is used when entering private browsing, to avoid trashing the - // user's groups while private browsing is shuffling things around. - pauseAutoclose: function GroupItems_pauseAutoclose() { - this._autoclosePaused = true; - }, - - // ---------- - // Function: unpauseAutoclose() - // Re-enables the auto-close behavior. - resumeAutoclose: function GroupItems_resumeAutoclose() { - this._autoclosePaused = false; } }; diff --git a/browser/base/content/tabview/tabitems.js b/browser/base/content/tabview/tabitems.js index 90ba952dda15..6ae5513d0af3 100644 --- a/browser/base/content/tabview/tabitems.js +++ b/browser/base/content/tabview/tabitems.js @@ -201,7 +201,6 @@ function TabItem(tab, options) { // press close button or middle mouse click if (iQ(e.target).hasClass("close") || Utils.isMiddleClick(e)) { - self.closedManually = true; self.close(); } else { if (!Items.item(this).isDragging) diff --git a/browser/base/content/tabview/ui.js b/browser/base/content/tabview/ui.js index 873c7016bceb..b106e78514e2 100644 --- a/browser/base/content/tabview/ui.js +++ b/browser/base/content/tabview/ui.js @@ -479,17 +479,6 @@ let UI = { let event = document.createEvent("Events"); event.initEvent("tabviewshown", true, false); - // Close the active group if it was empty. This will happen when the - // user returns to Panorama after looking at an app tab, having - // closed all other tabs. (If the user is looking at an orphan tab, then - // there is no active group for the purposes of this check.) - let activeGroupItem = null; - if (!GroupItems.getActiveOrphanTab()) { - activeGroupItem = GroupItems.getActiveGroupItem(); - if (activeGroupItem && activeGroupItem.closeIfEmpty()) - activeGroupItem = null; - } - if (zoomOut && currentTab && currentTab._tabViewTabItem) { item = currentTab._tabViewTabItem; // If there was a previous currentTab we want to animate @@ -503,8 +492,11 @@ let UI = { self.setActiveTab(item); - if (activeGroupItem && item.parent) - activeGroupItem.setTopChild(item); + if (item.parent) { + var activeGroupItem = GroupItems.getActiveGroupItem(); + if (activeGroupItem) + activeGroupItem.setTopChild(item); + } self._resize(true); dispatchEvent(event); @@ -599,10 +591,8 @@ let UI = { // Pauses the storage activity that conflicts with sessionstore updates and // private browsing mode switches. Calls can be nested. storageBusy: function UI_storageBusy() { - if (!this._storageBusyCount) { + if (!this._storageBusyCount) TabItems.pauseReconnecting(); - GroupItems.pauseAutoclose(); - } this._storageBusyCount++; }, @@ -620,7 +610,6 @@ let UI = { TabItems.resumeReconnecting(); GroupItems._updateTabBar(); - GroupItems.resumeAutoclose(); } }, diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index c1e6bfa8db1f..89411c76dae1 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -80,7 +80,6 @@ _BROWSER_FILES = \ browser_tabview_bug608184.js \ browser_tabview_bug608158.js \ browser_tabview_bug610242.js \ - browser_tabview_bug612470.js \ browser_tabview_bug613541.js \ browser_tabview_bug616729.js \ browser_tabview_bug616967.js \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug588265.js b/browser/base/content/test/tabview/browser_tabview_bug588265.js index f509135bf58f..308ed2bb760d 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug588265.js +++ b/browser/base/content/test/tabview/browser_tabview_bug588265.js @@ -122,7 +122,6 @@ function testGroups(groupItemOne, groupItemTwo, contentWindow) { finish(); }); gBrowser.removeTab(groupItemTwo.getChild(0).tab); - groupItemTwo.close(); } window.addEventListener("tabviewhidden", onTabViewHidden, false); EventUtils.synthesizeKey("t", { accelKey: true }); diff --git a/browser/base/content/test/tabview/browser_tabview_bug595943.js b/browser/base/content/test/tabview/browser_tabview_bug595943.js index 746bf51029e5..f4ef74ce2d4f 100644 --- a/browser/base/content/test/tabview/browser_tabview_bug595943.js +++ b/browser/base/content/test/tabview/browser_tabview_bug595943.js @@ -81,7 +81,7 @@ function onTabViewWindowLoaded() { window.removeEventListener("tabviewhidden", onTabViewHidden, false); ok(!TabView.isVisible(), "Tab View is hidden because we clicked on the app tab"); - // Remove the tab we're looking at. + // Remove the tab we're looking at. Note: this will also close groupItem (verified below) gBrowser.removeTab(normalXulTab); // Make sure we haven't returned to TabView; this is the crux of this test @@ -93,12 +93,9 @@ function onTabViewWindowLoaded() { gBrowser.unpinTab(appXulTab); gBrowser.removeTab(appXulTab); - ok(groupItem.closeIfEmpty(), "the second group was empty"); - // Verify ending state is(gBrowser.tabs.length, 1, "we finish with one tab"); - is(contentWindow.GroupItems.groupItems.length, 1, - "we finish with one group"); + is(contentWindow.GroupItems.groupItems.length, 1, "we finish with one group"); ok(!TabView.isVisible(), "we finish with Tab View hidden"); finish(); @@ -107,4 +104,4 @@ function onTabViewWindowLoaded() { window.addEventListener("tabviewhidden", onTabViewHidden, false); EventUtils.sendMouseEvent({ type: "mousedown" }, normalXulTab._tabViewTabItem.container, contentWindow); EventUtils.sendMouseEvent({ type: "mouseup" }, normalXulTab._tabViewTabItem.container, contentWindow); -} +} \ No newline at end of file diff --git a/browser/base/content/test/tabview/browser_tabview_bug612470.js b/browser/base/content/test/tabview/browser_tabview_bug612470.js deleted file mode 100644 index 4b68791a96f6..000000000000 --- a/browser/base/content/test/tabview/browser_tabview_bug612470.js +++ /dev/null @@ -1,110 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is tabview bug 612470 test. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Patrick Walton - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -// Tests that groups behave properly when closing all tabs but app tabs. - -let appTab, contentWindow; -let originalGroup, originalGroupTab, newGroup, newGroupTab; - -function test() { - waitForExplicitFinish(); - - appTab = gBrowser.selectedTab; - gBrowser.pinTab(appTab); - originalGroupTab = gBrowser.addTab(); - - addEventListener("tabviewshown", createGroup, false); - TabView.toggle(); -} - -function createGroup() { - removeEventListener("tabviewshown", createGroup, false); - - contentWindow = document.getElementById("tab-view").contentWindow; - is(contentWindow.GroupItems.groupItems.length, 1, "There's only one group"); - - originalGroup = contentWindow.GroupItems.groupItems[0]; - - // Create a new group. - let box = new contentWindow.Rect(20, 400, 300, 300); - newGroup = new contentWindow.GroupItem([], { bounds: box }); - - contentWindow.GroupItems.setActiveGroupItem(newGroup); - - addEventListener("tabviewhidden", addTab, false); - TabView.toggle(); -} - -function addTab() { - removeEventListener("tabviewhidden", addTab, false); - - newGroupTab = gBrowser.addTab(); - is(newGroup.getChildren().length, 1, "One tab is in the new group"); - executeSoon(removeTab); -} - -function removeTab() { - is(gBrowser.visibleTabs.length, 2, "There are two tabs displayed"); - gBrowser.removeTab(newGroupTab); - - is(newGroup.getChildren().length, 0, "No tabs are in the new group"); - is(gBrowser.visibleTabs.length, 1, "There is one tab displayed"); - is(contentWindow.GroupItems.groupItems.length, 2, - "There are two groups still"); - - addEventListener("tabviewshown", checkForRemovedGroup, false); - TabView.toggle(); -} - -function checkForRemovedGroup() { - removeEventListener("tabviewshown", checkForRemovedGroup, false); - - is(contentWindow.GroupItems.groupItems.length, 1, - "There is now only one group"); - - addEventListener("tabviewhidden", finishTest, false); - TabView.toggle(); -} - -function finishTest() { - removeEventListener("tabviewhidden", finishTest, false); - - gBrowser.removeTab(originalGroupTab); - gBrowser.unpinTab(appTab); - finish(); -} -