Bug 663613 - remove 'new tab' button from groups; r=ian, ui-r=limi

This commit is contained in:
Raymond Lee 2011-06-23 11:42:50 +08:00
Родитель 20462bfa02
Коммит 189d542c97
18 изменённых файлов: 112 добавлений и 266 удалений

Просмотреть файл

@ -124,15 +124,6 @@ function GroupItem(listOfEls, options) {
.css({zIndex: -100})
.appendTo("body");
// ___ New Tab Button
this.$ntb = iQ("<div>")
.addClass('newTabButton')
.click(function() {
self.newTab();
})
.attr('title', tabviewString('groupItem.newTabButton'))
.appendTo($container);
// ___ Resizer
this.$resizer = iQ("<div>")
.addClass('resizer')
@ -1669,7 +1660,6 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// element
if (Utils.isLeftClick(e) &&
self.$closeButton[0] != target &&
self.$ntb[0] != target &&
self.$titlebar[0] != target &&
!self.$titlebar.contains(target) &&
!self.$appTabTray.contains(target)) {

Просмотреть файл

@ -144,11 +144,6 @@ body {
/* Other
----------------------------------*/
.newTabButton {
position: absolute !important;
z-index: 99999;
}
.titlebar {
position: absolute;
}

Просмотреть файл

@ -1,53 +1,37 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let contentWindow;
let groupItemTwoId;
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", setup, false);
TabView.toggle();
registerCleanupFunction(function() {
while (gBrowser.tabs[1])
gBrowser.removeTab(gBrowser.tabs[1]);
hideTabView(function() {});
});
gBrowser.loadOneTab("about:blank", { inBackground: true });
showTabView(setup);
}
function setup() {
window.removeEventListener("tabviewshown", setup, false);
registerCleanupFunction(function() {
let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
if (groupItem)
closeGroupItem(groupItem, function() {});
});
let contentWindow = document.getElementById("tab-view").contentWindow;
let contentWindow = TabView.getContentWindow();
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
let groupItemOne = contentWindow.GroupItems.groupItems[0];
// add a blank tab to group one.
createNewTabItemInGroupItem(groupItemOne, contentWindow, function() {
is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
is(groupItemOne.getChildren().length, 2, "Group one has 2 tab items");
// create group two with a blank tab.
let groupItemTwo = createEmptyGroupItem(contentWindow, 250, 250, 40);
createNewTabItemInGroupItem(groupItemTwo, contentWindow, function() {
// start the first test.
testGroups(groupItemOne, groupItemTwo, contentWindow);
});
});
}
function createNewTabItemInGroupItem(groupItem, contentWindow, callback) {
// click on the + button to create a blank tab in group item
let newTabButton = groupItem.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
ok(!TabView.isVisible(), "Tab View is hidden because we just opened a tab");
TabView.toggle();
};
let onTabViewShown = function() {
window.removeEventListener("tabviewshown", onTabViewShown, false);
ok(TabView.isVisible(), "Tab View is visible");
callback();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
window.addEventListener("tabviewshown", onTabViewShown, false);
EventUtils.sendMouseEvent({ type: "click" }, newTabButton[0], contentWindow);
let groupItemTwo = createGroupItemWithBlankTabs(window, 250, 250, 40, 1);
groupItemTwoId = groupItemTwo.id;
testGroups(groupItemOne, groupItemTwo, contentWindow);
}
function testGroups(groupItemOne, groupItemTwo, contentWindow) {
@ -70,15 +54,12 @@ function testGroups(groupItemOne, groupItemTwo, contentWindow) {
is(contentWindow.UI.getActiveTab(), groupItemOne.getChild(0),
"The first tab item in group one is active");
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
whenTabViewIsHidden(function() {
is(groupItemOne.getChildren().length, 2,
"The num of childen in group one is 2");
// clean up and finish
groupItemTwo.addSubscriber("close", function onClose() {
groupItemTwo.removeSubscriber("close", onClose);
closeGroupItem(groupItemTwo, function() {
gBrowser.removeTab(groupItemOne.getChild(1).tab);
is(contentWindow.GroupItems.groupItems.length, 1, "Has only one group");
is(groupItemOne.getChildren().length, 1,
@ -87,10 +68,7 @@ function testGroups(groupItemOne, groupItemTwo, contentWindow) {
finish();
});
gBrowser.removeTab(groupItemTwo.getChild(0).tab);
groupItemTwo.close();
}
window.addEventListener("tabviewhidden", onTabViewHidden, false);
});
EventUtils.synthesizeKey("t", { accelKey: true });
});
// close a tab item in group one

Просмотреть файл

@ -3,6 +3,7 @@
let originalTab;
let newTabOne;
let groupItemTwoId;
function test() {
waitForExplicitFinish();
@ -11,10 +12,20 @@ function test() {
// add a tab to the existing group.
newTabOne = gBrowser.addTab();
let onTabviewShown = function() {
window.removeEventListener("tabviewshown", onTabviewShown, false);
registerCleanupFunction(function() {
while (gBrowser.tabs[1])
gBrowser.removeTab(gBrowser.tabs[1]);
hideTabView(function() {});
});
let contentWindow = document.getElementById("tab-view").contentWindow;
showTabView(function() {
let contentWindow = TabView.getContentWindow();
registerCleanupFunction(function() {
let groupItem = contentWindow.GroupItems.groupItem(groupItemTwoId);
if (groupItem)
closeGroupItem(groupItem, function() {});
});
is(contentWindow.GroupItems.groupItems.length, 1,
"There is one group item on startup");
@ -25,22 +36,13 @@ function test() {
"The currently selected tab should be the first tab in the groupItemOne");
// create another group with a tab.
let groupItemTwo = createEmptyGroupItem(contentWindow, 300, 300, 200);
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
let groupItemTwo = createGroupItemWithBlankTabs(window, 300, 300, 200, 1);
groupItemTwoId = groupItemTwoId;
hideTabView(function() {
// start the test
testGroupSwitch(contentWindow, groupItemOne, groupItemTwo);
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
// click on the + button
let newTabButton = groupItemTwo.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
EventUtils.sendMouseEvent({ type: "click" }, newTabButton[0], contentWindow);
};
window.addEventListener("tabviewshown", onTabviewShown, false);
TabView.toggle();
});
});
}
function testGroupSwitch(contentWindow, groupItemOne, groupItemTwo) {

Просмотреть файл

@ -23,75 +23,49 @@ function test() {
}
function testOne() {
whenSearchEnabledAndDisabled(testTwo);
hideSearchWhenSearchEnabled(testTwo);
// press cmd/ctrl F
EventUtils.synthesizeKey("f", {accelKey: true}, cw);
}
function testTwo() {
whenSearchEnabledAndDisabled(testThree);
hideSearchWhenSearchEnabled(testThree);
// press /
EventUtils.synthesizeKey("VK_SLASH", {}, cw);
}
function testThree() {
let onTabViewShown = function () {
is(cw.UI.getActiveTab(), groupItem.getChild(0),
"The active tab is newly created tab item");
ok(win.TabView.isVisible(), "Tab View is visible");
// create another group with a tab.
let groupItem = createGroupItemWithBlankTabs(win, 300, 300, 200, 1);
is(cw.UI.getActiveTab(), groupItem.getChild(0),
"The active tab is newly created tab item");
let onSearchEnabled = function () {
let doc = cw.document;
let searchBox = cw.iQ("#searchbox");
let hasFocus = doc.hasFocus() && doc.activeElement == searchBox[0];
ok(hasFocus, "The search box has focus");
whenSearchIsEnabled(function () {
let doc = cw.document;
let searchBox = cw.iQ("#searchbox");
let hasFocus = doc.hasFocus() && doc.activeElement == searchBox[0];
ok(hasFocus, "The search box has focus");
let tab = win.gBrowser.tabs[1];
searchBox.val(tab._tabViewTabItem.$tabTitle[0].innerHTML);
let tab = win.gBrowser.tabs[1];
searchBox.val(tab._tabViewTabItem.$tabTitle[0].innerHTML);
cw.performSearch();
cw.performSearch();
whenTabViewIsHidden(function () {
is(tab, win.gBrowser.selectedTab, "The search result tab is shown");
waitForFocus(finish);
}, win);
whenTabViewIsHidden(function () {
is(tab, win.gBrowser.selectedTab, "The search result tab is shown");
finish()
}, win);
// use the tabview menu (the same as pressing cmd/ctrl + e)
win.document.getElementById("menu_tabview").doCommand();
};
whenSearchEnabled(onSearchEnabled);
EventUtils.synthesizeKey("VK_SLASH", {}, cw);
};
whenTabViewIsHidden(function () {
showTabView(onTabViewShown, win);
// use the tabview menu (the same as pressing cmd/ctrl + e)
win.document.getElementById("menu_tabview").doCommand();
}, win);
// click on the + button
let groupItem = createEmptyGroupItem(cw, 300, 300, 200);
let newTabButton = groupItem.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
EventUtils.sendMouseEvent({type: "click"}, newTabButton[0], cw);
EventUtils.synthesizeKey("VK_SLASH", {}, cw);
}
function whenSearchEnabledAndDisabled(callback) {
whenSearchEnabled(function () {
whenSearchDisabled(callback);
cw.hideSearch();
});
function hideSearchWhenSearchEnabled(callback) {
whenSearchIsEnabled(function() {
hideSearch(callback, win);
}, win);
}
function whenSearchEnabled(callback) {
cw.addEventListener("tabviewsearchenabled", function onSearchEnabled() {
cw.removeEventListener("tabviewsearchenabled", onSearchEnabled, false);
callback();
}, false);
}
function whenSearchDisabled(callback) {
cw.addEventListener("tabviewsearchdisabled", function onSearchDisabled() {
cw.removeEventListener("tabviewsearchdisabled", onSearchDisabled, false);
callback();
}, false);
}

Просмотреть файл

@ -4,18 +4,16 @@
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
TabView.toggle();
showTabView(onTabViewWindowLoaded);
}
let originalGroupItem = null;
let originalTab = null;
function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(TabView.isVisible(), "Tab View is visible");
let contentWindow = document.getElementById("tab-view").contentWindow;
let contentWindow = TabView.getContentWindow();
is(contentWindow.GroupItems.groupItems.length, 1, "There is one group item on startup");
originalGroupItem = contentWindow.GroupItems.groupItems[0];
@ -58,19 +56,7 @@ function testGroupItemWithTabItem(contentWindow) {
let groupItem = createEmptyGroupItem(contentWindow, 300, 300, 200);
let tabItemCount = 0;
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
is(groupItem.getChildren().length, ++tabItemCount,
"The number of children in new tab group is increased by 1");
ok(!TabView.isVisible(), "Tab View is hidden because we just opened a tab");
TabView.toggle();
};
let onTabViewShown = function() {
window.removeEventListener("tabviewshown", onTabViewShown, false);
let tabItem = groupItem.getChild(groupItem.getChildren().length - 1);
ok(tabItem, "Tab item exists");
@ -85,19 +71,12 @@ function testGroupItemWithTabItem(contentWindow) {
ok(tabItemClosed, "The tab item is closed");
is(groupItem.getChildren().length, --tabItemCount,
"The number of children in new tab group is decreased by 1");
ok(TabView.isVisible(), "Tab View is still shown");
// Now there should only be one tab left, so we need to hide TabView
// and go into that tab.
is(gBrowser.tabs.length, 1, "There is only one tab left");
let endGame = function() {
window.removeEventListener("tabviewhidden", endGame, false);
ok(!TabView.isVisible(), "Tab View is hidden");
finish();
};
window.addEventListener("tabviewhidden", endGame, false);
// after the last selected tabitem is closed, there would be not active
// tabitem on the UI so we set the active tabitem before toggling the
@ -106,7 +85,11 @@ function testGroupItemWithTabItem(contentWindow) {
ok(tabItems[0], "A tab item exists");
contentWindow.UI.setActive(tabItems[0]);
TabView.toggle();
hideTabView(function() {
ok(!TabView.isVisible(), "Tab View is hidden");
closeGroupItem(groupItem, finish);
});
});
// remove the tab item. The code detects mousedown and mouseup so we stimulate here
@ -115,15 +98,14 @@ function testGroupItemWithTabItem(contentWindow) {
EventUtils.sendMouseEvent({ type: "mousedown" }, closeButton[0], contentWindow);
EventUtils.sendMouseEvent({ type: "mouseup" }, closeButton[0], contentWindow);
TabView.toggle();
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
window.addEventListener("tabviewshown", onTabViewShown, false);
// click on the + button
let newTabButton = groupItem.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
EventUtils.synthesizeMouse(newTabButton[0], 1, 1, {}, contentWindow);
whenTabViewIsHidden(function() {
is(groupItem.getChildren().length, ++tabItemCount,
"The number of children in new tab group is increased by 1");
ok(!TabView.isVisible(), "Tab View is hidden because we just opened a tab");
showTabView(onTabViewShown);
});
groupItem.newTab();
}

Просмотреть файл

@ -4,45 +4,33 @@
function test() {
waitForExplicitFinish();
window.addEventListener("tabviewshown", onTabViewWindowLoaded, false);
TabView.toggle();
registerCleanupFunction(function() {
while (gBrowser.tabs[1])
gBrowser.removeTab(gBrowser.tabs[1]);
hideTabView(function() {});
});
showTabView(onTabViewWindowLoaded);
}
function onTabViewWindowLoaded() {
window.removeEventListener("tabviewshown", onTabViewWindowLoaded, false);
ok(TabView.isVisible(), "Tab View is visible");
let contentWindow = document.getElementById("tab-view").contentWindow;
let contentWindow = TabView.getContentWindow();
registerCleanupFunction(function() {
let groupItem = contentWindow.GroupItems.groupItem(groupItemId);
if (groupItem)
closeGroupItem(groupItem, function() {});
});
// create a group item
let box = new contentWindow.Rect(20, 400, 300, 300);
let groupItem = new contentWindow.GroupItem([], { bounds: box });
// create a tab item in the new group
let onTabViewHidden = function() {
window.removeEventListener("tabviewhidden", onTabViewHidden, false);
ok(!TabView.isVisible(), "Tab View is hidden because we just opened a tab");
// show tab view
TabView.toggle();
};
let onTabViewShown = function() {
window.removeEventListener("tabviewshown", onTabViewShown, false);
is(groupItem.getChildren().length, 1, "The new group has a tab item");
// start the tests
waitForFocus(function() {
testUndoGroup(contentWindow, groupItem);
}, contentWindow);
};
window.addEventListener("tabviewhidden", onTabViewHidden, false);
window.addEventListener("tabviewshown", onTabViewShown, false);
// click on the + button
let newTabButton = groupItem.container.getElementsByClassName("newTabButton");
ok(newTabButton[0], "New tab button exists");
EventUtils.sendMouseEvent({ type: "click" }, newTabButton[0], contentWindow);
let groupItem = createGroupItemWithBlankTabs(window, 300, 300, 400, 1);
groupItemId = groupItem.id;
is(groupItem.getChildren().length, 1, "The new group has a tab item");
// start the tests
waitForFocus(function() {
testUndoGroup(contentWindow, groupItem);
}, contentWindow);
}
function testUndoGroup(contentWindow, groupItem) {
@ -113,13 +101,6 @@ function testCloseUndoGroup(contentWindow, groupItem) {
let theGroupItem = contentWindow.GroupItems.groupItem(groupItem.id);
ok(!theGroupItem, "The group item doesn't exists");
let endGame = function() {
window.removeEventListener("tabviewhidden", endGame, false);
ok(!TabView.isVisible(), "Tab View is hidden");
finish();
};
window.addEventListener("tabviewhidden", endGame, false);
// after the last selected tabitem is closed, there would be not active
// tabitem on the UI so we set the active tabitem before toggling the
// visibility of tabview
@ -127,7 +108,10 @@ function testCloseUndoGroup(contentWindow, groupItem) {
ok(tabItems[0], "A tab item exists");
contentWindow.UI.setActive(tabItems[0]);
TabView.toggle();
hideTabView(function() {
ok(!TabView.isVisible(), "Tab View is hidden");
finish();
});
});
let closeButton = groupItem.container.getElementsByClassName("close");

Просмотреть файл

@ -32,6 +32,9 @@ function createGroupItemWithTabs(win, width, height, padding, urls, animate) {
ok(newItem.container, "Created element "+t+":"+newItem.container);
++t;
});
// to set one of tabItem to be active since we load tabs into a group
// in a non-standard flow.
contentWindow.UI.setActive(groupItem);
return groupItem;
}

Просмотреть файл

@ -1,4 +1,3 @@
tabview.groupItem.newTabButton=New tab
tabview.groupItem.defaultName=Name this tab group…
tabview.groupItem.undoCloseGroup=Undo Close Group
tabview.search.otherWindowTabs=Tabs from other windows

Просмотреть файл

@ -79,7 +79,6 @@ browser.jar:
skin/classic/browser/tabbrowser/tab-overflow-border.png (tabbrowser/tab-overflow-border.png)
skin/classic/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator.png)
skin/classic/browser/tabview/edit-light.png (tabview/edit-light.png)
skin/classic/browser/tabview/new-tab.png (tabview/new-tab.png)
skin/classic/browser/tabview/search.png (tabview/search.png)
skin/classic/browser/tabview/stack-expander.png (tabview/stack-expander.png)
skin/classic/browser/tabview/tabview.png (tabview/tabview.png)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 466 B

Просмотреть файл

@ -385,25 +385,6 @@ html[dir=rtl] .guideTrench {
/* Other
----------------------------------*/
.newTabButton {
width: 16px;
height: 15px;
bottom: 10px;
left: 10px;
cursor: pointer;
opacity: .3;
background-image: url(chrome://browser/skin/tabview/new-tab.png);
}
html[dir=rtl] .newTabButton {
left: auto;
right: 10px;
}
.newTabButton:hover {
opacity: 1;
}
.active {
box-shadow: 5px 5px 3px rgba(0,0,0,.5);
}

Просмотреть файл

@ -117,7 +117,6 @@ browser.jar:
skin/classic/browser/tabbrowser/tabDragIndicator.png (tabbrowser/tabDragIndicator.png)
skin/classic/browser/tabview/close.png (tabview/close.png)
skin/classic/browser/tabview/edit-light.png (tabview/edit-light.png)
skin/classic/browser/tabview/new-tab.png (tabview/new-tab.png)
skin/classic/browser/tabview/search.png (tabview/search.png)
skin/classic/browser/tabview/stack-expander.png (tabview/stack-expander.png)
skin/classic/browser/tabview/tabview.png (tabview/tabview.png)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 466 B

Просмотреть файл

@ -376,25 +376,6 @@ html[dir=rtl] .guideTrench {
/* Other
----------------------------------*/
.newTabButton {
width: 16px;
height: 15px;
bottom: 10px;
left: 10px;
cursor: pointer;
opacity: .3;
background-image: url(chrome://browser/skin/tabview/new-tab.png);
}
html[dir=rtl] .newTabButton {
left: auto;
right: 10px;
}
.newTabButton:hover {
opacity: 1;
}
.active {
box-shadow: 5px 5px 3px rgba(0,0,0,.5);
}

Просмотреть файл

@ -96,7 +96,6 @@ browser.jar:
skin/classic/browser/tabview/close.png (tabview/close.png)
skin/classic/browser/tabview/edit-light.png (tabview/edit-light.png)
skin/classic/browser/tabview/grain.png (tabview/grain.png)
skin/classic/browser/tabview/new-tab.png (tabview/new-tab.png)
skin/classic/browser/tabview/search.png (tabview/search.png)
skin/classic/browser/tabview/stack-expander.png (tabview/stack-expander.png)
skin/classic/browser/tabview/tabview.png (tabview/tabview.png)
@ -211,7 +210,6 @@ browser.jar:
skin/classic/aero/browser/tabview/close.png (tabview/close.png)
skin/classic/aero/browser/tabview/edit-light.png (tabview/edit-light.png)
skin/classic/aero/browser/tabview/grain.png (tabview/grain.png)
skin/classic/aero/browser/tabview/new-tab.png (tabview/new-tab.png)
skin/classic/aero/browser/tabview/search.png (tabview/search.png)
skin/classic/aero/browser/tabview/stack-expander.png (tabview/stack-expander.png)
skin/classic/aero/browser/tabview/tabview.png (tabview/tabview.png)

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 466 B

Просмотреть файл

@ -398,25 +398,6 @@ html[dir=rtl] .guideTrench {
/* Other
----------------------------------*/
.newTabButton {
width: 16px;
height: 15px;
bottom: 10px;
left: 10px;
cursor: pointer;
opacity: .3;
background-image: url(chrome://browser/skin/tabview/new-tab.png);
}
html[dir=rtl] .newTabButton {
left: auto;
right: 10px;
}
.newTabButton:hover {
opacity: 1;
}
.active {
box-shadow: 5px 5px 3px rgba(0,0,0,.5);
}