mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-15 06:15:43 +00:00
Bug 663421 - Don't close empty groups automatically; r=dao
This commit is contained in:
parent
69c847e57d
commit
93ced1d6c2
@ -355,10 +355,8 @@ let TabView = {
|
||||
if (!tabItem)
|
||||
return;
|
||||
|
||||
// Switch to the new tab, and close the old group if it's now empty.
|
||||
let oldGroupItem = groupItems.getActiveGroupItem();
|
||||
// Switch to the new tab
|
||||
window.gBrowser.selectedTab = tabItem.tab;
|
||||
oldGroupItem.closeIfEmpty();
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
|
@ -282,10 +282,8 @@ Drag.prototype = {
|
||||
Trenches.hideGuides();
|
||||
this.item.isDragging = false;
|
||||
|
||||
if (this.parent && this.parent != this.item.parent &&
|
||||
this.parent.isEmpty()) {
|
||||
this.parent.close();
|
||||
}
|
||||
if (this.parent && this.parent != this.item.parent)
|
||||
this.parent.closeIfEmpty();
|
||||
|
||||
if (this.parent && this.parent.expanded)
|
||||
this.parent.arrange();
|
||||
|
@ -725,13 +725,12 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
|
||||
// ----------
|
||||
// Function: closeIfEmpty
|
||||
// Closes the group if it's empty, 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.getTitle() &&
|
||||
!GroupItems.getUnclosableGroupItemId() &&
|
||||
!GroupItems._autoclosePaused) {
|
||||
// Closes the group if it's empty, is closable, and autoclose is enabled
|
||||
// (see pauseAutoclose()). Returns true if the close occurred and false
|
||||
// otherwise.
|
||||
closeIfEmpty: function GroupItem_closeIfEmpty() {
|
||||
if (this.isEmpty() && !UI._closedLastVisibleTab &&
|
||||
!GroupItems.getUnclosableGroupItemId() && !GroupItems._autoclosePaused) {
|
||||
this.close();
|
||||
return true;
|
||||
}
|
||||
@ -1110,7 +1109,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
|
||||
|
||||
// if a blank tab is selected while restoring a tab the blank tab gets
|
||||
// removed. we need to keep the group alive for the restored tab.
|
||||
if (item.tab._tabViewTabIsRemovedAfterRestore)
|
||||
if (item.isRemovedAfterRestore)
|
||||
options.dontClose = true;
|
||||
|
||||
let closed = options.dontClose ? false : this.closeIfEmpty();
|
||||
|
@ -523,17 +523,6 @@ let UI = {
|
||||
|
||||
Storage.saveVisibilityData(gWindow, "true");
|
||||
|
||||
// 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 (!UI.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
|
||||
|
@ -130,4 +130,7 @@ function test() {
|
||||
is(gBrowser.tabs.length, 1, "sanity check that it matches");
|
||||
is(gBrowser.selectedTab, origTab, "got the orig tab");
|
||||
is(origTab.hidden, false, "and it's not hidden -- visible!");
|
||||
|
||||
if (tabViewWindow)
|
||||
tabViewWindow.GroupItems.groupItems[0].close();
|
||||
}
|
||||
|
@ -150,6 +150,7 @@ _BROWSER_FILES = \
|
||||
browser_tabview_bug656778.js \
|
||||
browser_tabview_bug656913.js \
|
||||
browser_tabview_bug662266.js \
|
||||
browser_tabview_bug663421.js \
|
||||
browser_tabview_bug665502.js \
|
||||
browser_tabview_dragdrop.js \
|
||||
browser_tabview_exit_button.js \
|
||||
|
@ -35,10 +35,7 @@ function test() {
|
||||
is(win.gBrowser.visibleTabs.length, 1, "There is one tab displayed");
|
||||
is(cw.GroupItems.groupItems.length, 2, "There are two groups still");
|
||||
|
||||
showTabView(function () {
|
||||
is(cw.GroupItems.groupItems.length, 1, "There is now only one group");
|
||||
waitForFocus(finish);
|
||||
}, win);
|
||||
finish();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -119,7 +119,8 @@ function test() {
|
||||
|
||||
enterAndLeavePrivateBrowsing(function () {
|
||||
assertNumberOfVisibleTabs(2);
|
||||
next();
|
||||
gBrowser.selectedTab = gBrowser.tabs[0];
|
||||
closeGroupItem(cw.GroupItems.groupItems[1], next);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,88 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
function test() {
|
||||
let win, cw, groupItem;
|
||||
|
||||
function checkNumberOfGroupItems(num) {
|
||||
is(cw.GroupItems.groupItems.length, num, "there are " + num + " groupItems");
|
||||
}
|
||||
|
||||
function next() {
|
||||
if (tests.length)
|
||||
tests.shift()();
|
||||
else
|
||||
finish();
|
||||
}
|
||||
|
||||
// Empty groups should not be closed when toggling Panorama on and off.
|
||||
function test1() {
|
||||
hideTabView(function () {
|
||||
showTabView(function () {
|
||||
checkNumberOfGroupItems(2);
|
||||
next();
|
||||
}, win);
|
||||
}, win);
|
||||
}
|
||||
|
||||
// Groups should not be closed when their last tab is closed outside of Panorama.
|
||||
function test2() {
|
||||
whenTabViewIsHidden(function () {
|
||||
whenTabViewIsShown(function () {
|
||||
checkNumberOfGroupItems(2);
|
||||
next();
|
||||
}, win);
|
||||
|
||||
win.gBrowser.removeTab(win.gBrowser.selectedTab);
|
||||
}, win);
|
||||
|
||||
groupItem.newTab();
|
||||
}
|
||||
|
||||
// Groups should be closed when their last tab is closed.
|
||||
function test3() {
|
||||
whenTabViewIsHidden(function () {
|
||||
showTabView(function () {
|
||||
let tab = win.gBrowser.tabs[1];
|
||||
tab._tabViewTabItem.close();
|
||||
checkNumberOfGroupItems(1);
|
||||
next();
|
||||
}, win);
|
||||
}, win);
|
||||
|
||||
win.gBrowser.addTab();
|
||||
}
|
||||
|
||||
// Groups should be closed when their last tab is dragged out.
|
||||
function test4() {
|
||||
groupItem = createGroupItemWithBlankTabs(win, 200, 200, 20, 1);
|
||||
checkNumberOfGroupItems(2);
|
||||
|
||||
let tab = win.gBrowser.tabs[1];
|
||||
let target = tab._tabViewTabItem.container;
|
||||
|
||||
waitForFocus(function () {
|
||||
EventUtils.synthesizeMouseAtCenter(target, {type: "mousedown"}, cw);
|
||||
EventUtils.synthesizeMouse(target, 600, 5, {type: "mousemove"}, cw);
|
||||
EventUtils.synthesizeMouse(target, 600, 5, {type: "mouseup"}, cw);
|
||||
|
||||
checkNumberOfGroupItems(1);
|
||||
next();
|
||||
}, win);
|
||||
}
|
||||
|
||||
let tests = [test1, test2, test3, test4];
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
newWindowWithTabView(function (aWin) {
|
||||
registerCleanupFunction(function () aWin.close());
|
||||
|
||||
win = aWin;
|
||||
cw = win.TabView.getContentWindow();
|
||||
groupItem = createEmptyGroupItem(cw, 200, 200, 20);
|
||||
|
||||
checkNumberOfGroupItems(2);
|
||||
next();
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user