Bug 454667: Ability to close tabs, r=gavin

This commit is contained in:
Mark Finkle 2008-09-29 01:43:33 -05:00
Родитель 1b42de5061
Коммит 3e87a9415b
6 изменённых файлов: 43 добавлений и 2 удалений

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

@ -733,6 +733,11 @@ var BrowserUI = {
this.show(UIMODE_URLEDIT); this.show(UIMODE_URLEDIT);
}, },
closeTab : function(aTab) {
Browser.content.removeTab(aTab);
this.show(UIMODE_NONE);
},
selectTab : function(aTab) { selectTab : function(aTab) {
Browser.content.selectTab(aTab); Browser.content.selectTab(aTab);
this.show(UIMODE_NONE); this.show(UIMODE_NONE);

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

@ -296,7 +296,7 @@
</hbox> </hbox>
<vbox id="tab-list-container" style="-moz-stack-sizing: ignore;" top="60" left="0"> <vbox id="tab-list-container" style="-moz-stack-sizing: ignore;" top="60" left="0">
<richlistbox id="tab-list" onselect="BrowserUI.selectTab(this.selectedItem);"/> <richlistbox id="tab-list" onselect="BrowserUI.selectTab(this.selectedItem);" onclosetab="BrowserUI.closeTab(this);"/>
<hbox> <hbox>
<toolbarbutton id="newtab-button" command="cmd_newTab"/> <toolbarbutton id="newtab-button" command="cmd_newTab"/>
<toolbarbutton id="retrievetab-button" command=""/> <toolbarbutton id="retrievetab-button" command=""/>

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

@ -305,11 +305,24 @@
if (!tab) if (!tab)
return; return;
var nextTab = this.tabList.selectedItem;
if (tab == this.tabList.selectedItem) {
nextTab = tab.nextSibling;
if (!nextTab)
nextTab = tab.previousSibling;
if (!nextTab)
return;
}
var display = this.getDisplayForTab(tab); var display = this.getDisplayForTab(tab);
if (display) if (display)
display.removeChild(display); display.parentNode.removeChild(display);
tab.parentNode.removeChild(tab); tab.parentNode.removeChild(tab);
this.tabList.selectedItem = nextTab;
this.displayList.selectedPanel = this.getDisplayForTab(nextTab);
this.selectTab(nextTab);
var evt = document.createEvent("Events"); var evt = document.createEvent("Events");
evt.initEvent("TabClose", true, false); evt.initEvent("TabClose", true, false);
tab.dispatchEvent(evt); tab.dispatchEvent(evt);
@ -343,8 +356,11 @@
nextDisplay = this.getDisplayForTab(nextTab); nextDisplay = this.getDisplayForTab(nextTab);
} }
var uniqueId = Date.now() + displayList.childNodes.length;
if (!display) { if (!display) {
display = document.createElementNS(XUL_NS, "deck"); display = document.createElementNS(XUL_NS, "deck");
display.setAttribute("id", "display-" + uniqueId)
displayList.insertBefore(display, nextDisplay); displayList.insertBefore(display, nextDisplay);
} }
display.appendChild(browser); display.appendChild(browser);
@ -358,6 +374,7 @@
if (!tab) { if (!tab) {
tab = document.createElementNS(XUL_NS, "richlistitem"); tab = document.createElementNS(XUL_NS, "richlistitem");
tab.setAttribute("id", "tab-" + uniqueId)
tab.setAttribute("type", "documenttab"); tab.setAttribute("type", "documenttab");
this.tabList.appendChild(tab); this.tabList.appendChild(tab);
} }
@ -1221,6 +1238,13 @@
</xul:stack> </xul:stack>
</content> </content>
<implementation> <implementation>
<constructor><![CDATA[
let close = document.getAnonymousElementByAttribute(this, "anonid", "close");
let closefn = new Function("event", parentNode.getAttribute("onclosetab"));
var self = this;
close.addEventListener("mousedown", function(event) { closefn.call(self, event); event.stopPropagation(); }, true);
]]></constructor>
<method name="updateTab"> <method name="updateTab">
<parameter name="browser"/> <parameter name="browser"/>
<body> <body>
@ -1242,6 +1266,7 @@
]]> ]]>
</body> </body>
</method> </method>
<method name="markInvalid"> <method name="markInvalid">
<parameter name="browser"/> <parameter name="browser"/>
<body> <body>

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

@ -29,6 +29,7 @@ classic.jar:
notification.css (skin/notification.css) notification.css (skin/notification.css)
images/close.png (skin/images/close.png) images/close.png (skin/images/close.png)
images/close-small.png (skin/images/close-small.png) images/close-small.png (skin/images/close-small.png)
images/tab_close.png (skin/images/tab_close.png)
images/default-favicon.png (skin/images/default-favicon.png) images/default-favicon.png (skin/images/default-favicon.png)
images/identity.png (skin/images/identity.png) images/identity.png (skin/images/identity.png)
images/starred48.png (skin/images/starred48.png) images/starred48.png (skin/images/starred48.png)

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

@ -338,6 +338,16 @@ richlistitem[type="documenttab"][selected="true"] {
border: 1px solid white !important; border: 1px solid white !important;
} }
.documenttab-close {
width: 24px;
height: 24px;
list-style-image: url(chrome://browser/skin/images/tab_close.png);
}
richlistitem[type="documenttab"]:only-child .documenttab-close {
display: none;
}
#newtab-button { #newtab-button {
list-style-image: url("images/left_buttons.png"); list-style-image: url("images/left_buttons.png");
-moz-image-region: rect(0px 48px 48px 0px); -moz-image-region: rect(0px 48px 48px 0px);

Двоичные данные
mobile/chrome/skin/images/tab_close.png Normal file

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

После

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