Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
Add "Close Tab button" option functionality
Browse files Browse the repository at this point in the history
It implemented using own styles based on "closebuttons" attribute
of tabContainer.

Fixes ithinc#114.
  • Loading branch information
phts committed Oct 19, 2014
1 parent e574385 commit d0749b2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion chrome/content/preferences.xul
Expand Up @@ -578,9 +578,9 @@
onsyncfrompreference="return $('closeButtons').value == 2 ? this.value : $('closeButtons').value;">
<menupopup>
<menuitem value="0" label="&closeButtons.0.label;"/>
<menuitem value="1" label="&closeButtons.1.label;"/>
<menuitem value="18" label="&closeButtons.18.label;"/>
<menuitem value="16" label="&closeButtons.16.label;"/>
<menuitem value="1" label="&closeButtons.1.label;"/>
<menuitem value="2" label="&closeButtons.2.label;" hidden="true"/>
</menupopup>
</menulist>
Expand Down
27 changes: 17 additions & 10 deletions chrome/content/tabutils.js
Expand Up @@ -2852,17 +2852,24 @@ tabutils._tabPrefObserver = {

//Close buttons
TU_hookCode("gBrowser.mTabContainer.adjustTabstrip",
[/let tab.*/, function() {
let tab;
Array.some(this.tabbrowser.visibleTabs, function(aTab) {
return !aTab.collapsed && getComputedStyle(aTab).MozBoxFlex > 0 && (tab = aTab);
});
}],
["this.mCloseButtons", "($& & 0x0f)"],
["this.mCloseButtons != 3", "(this.mCloseButtons & 0x0f) != 3 && !(this.mCloseButtons & 0x20)"],
["this._closeWindowWithLastTab", "false", "g"],
["numTabs > 2", "false"],
["}", function() {
this.setAttribute("closeButtonOnPointedTab", (this.mCloseButtons & 0x0f) == 1 || !!(this.mCloseButtons & 0x10));
var def = "alltabs";
var map = {
0: "activetab",
1: "alltabs",
2: "hidden",
16: "activepointedtab",
18: "pointedtab"
};
var value = map[this.mCloseButtons] || def;
if (value == "alltabs") {
let tab = this.tabbrowser.visibleTabs[this.tabbrowser._numPinnedTabs];
if (tab && tab.getBoundingClientRect().width <= this.mTabClipWidth) {
value = "hidden";
}
}
this.setAttribute("closebuttons", value);
}]
);

Expand Down
26 changes: 12 additions & 14 deletions chrome/skin/tabutils.css
Expand Up @@ -9,12 +9,21 @@ menuseparator:last-child {
}

/* Close Tab buttons */
.tabbrowser-tabs[closeButtonOnPointedTab="true"] > .tabbrowser-tab:hover .tab-close-button,
.tabbrowser-tabs[closebuttons="activetab"] > .tabbrowser-tab:only-child .tab-close-button,
.tabbrowser-tabs[closebuttons="alltabs"] > .tabbrowser-tab:only-child .tab-close-button {
.tabbrowser-tabs[closebuttons="pointedtab"] > .tabbrowser-tab:hover .tab-close-button,
.tabbrowser-tabs[closebuttons="activepointedtab"] > .tabbrowser-tab:hover .tab-close-button,
.tabbrowser-tabs[closebuttons="activetab"] > .tabbrowser-tab[selected] .tab-close-button,
.tabbrowser-tabs[closebuttons="activepointedtab"] > .tabbrowser-tab[selected] .tab-close-button,
.tabbrowser-tabs[closebuttons="alltabs"] > .tabbrowser-tab .tab-close-button {
display: -moz-box;
}

.tabbrowser-tabs[closebuttons="pointedtab"] > .tabbrowser-tab:not(:hover) .tab-close-button,
.tabbrowser-tabs[closebuttons="activetab"] > .tabbrowser-tab:not([selected]) .tab-close-button,
.tabbrowser-tabs[closebuttons="activepointedtab"] > .tabbrowser-tab:not(:hover):not([selected]) .tab-close-button,
.tabbrowser-tabs[closebuttons="hidden"] > .tabbrowser-tab .tab-close-button {
display: none;
}

/* All Tabs button */
.tabs-alltabs-button[showTabCounter="true"] {
visibility: visible !important; /* Fx12 */
Expand Down Expand Up @@ -47,12 +56,6 @@ menuseparator:last-child {
-moz-box-flex: 0 !important;
}

.tabbrowser-tabs[tabfittitle="true"][closeButtonOnPointedTab="true"][closebuttons="activetab"] > .tabbrowser-tab:not([selected]):not(:hover) .tab-close-button,
.tabbrowser-tabs[tabfittitle="true"][closeButtonOnPointedTab="true"]:not([closebuttons="activetab"]):not([closebuttons="alltabs"]) > .tabbrowser-tab:not(:hover) .tab-close-button {
display: -moz-box;
visibility: hidden;
}

/* Tab Highlighting */
.tabbrowser-tab[locked] .tab-throbber:not([busy]),
.tabbrowser-tab[locked] .tab-throbber:not([busy]) + .tab-icon-image,
Expand Down Expand Up @@ -87,11 +90,6 @@ menuseparator:last-child {
-moz-image-region: rect(1px, 111px, 15px, 97px) !important;
}

.tabbrowser-tabs[closeButtonOnPointedTab="false"][closebuttons="activetab"] > .tabbrowser-tab[autoReload]:not([selected]):hover .tab-close-button,
.tabbrowser-tabs[closeButtonOnPointedTab="false"]:not([closebuttons="activetab"]):not([closebuttons="alltabs"]) > .tabbrowser-tab[autoReload]:hover .tab-close-button {
visibility: hidden;
}

/* Pinned Tab */
.tabbrowser-tabs[orient="vertical"] > .tabbrowser-tab[pinned],
.tabbrowser-tabs[autoFaviconizePinned="true"] > .tabbrowser-tab[pinned],
Expand Down
7 changes: 0 additions & 7 deletions chrome/skin/tabutils_mac.css
@@ -1,10 +1,3 @@
/* Close Tab buttons */
window[OS="Darwin"][v4="true"] .tabbrowser-tabs[closeButtonOnPointedTab="true"][closebuttons="activetab"] > .tabbrowser-tab:not([selected]):not(:hover) .tab-close-button,
window[OS="Darwin"][v4="true"] .tabbrowser-tabs[closeButtonOnPointedTab="true"]:not([closebuttons="activetab"]):not([closebuttons="alltabs"]) > .tabbrowser-tab:not(:hover) .tab-close-button {
display: -moz-box;
visibility: hidden;
}

/* Tab Stacking */
window[OS="Darwin"][v4="true"] .tabbrowser-tab[group-selected]:not([group-counter="1"])[group-collapsed] .tab-twisty {
-moz-appearance: treetwisty;
Expand Down

0 comments on commit d0749b2

Please sign in to comment.