зеркало из https://github.com/mozilla/gecko-dev.git
Bug 572160 - Put tabs in the title bar when the window is maximized. r=gavin ui-r=faaborg a=b
--HG-- extra : rebase_source : 8416d48d6c903409c40d7360a9cfa1c01b188828
This commit is contained in:
Родитель
aadee20e82
Коммит
1bf1e788ff
|
@ -381,6 +381,7 @@ pref("browser.tabs.loadDivertedInBackground", false);
|
|||
pref("browser.tabs.loadBookmarksInBackground", false);
|
||||
pref("browser.tabs.tabClipWidth", 140);
|
||||
pref("browser.tabs.animate", true);
|
||||
pref("browser.tabs.drawInTitlebar", true);
|
||||
|
||||
// Where to show tab close buttons:
|
||||
// 0 on active tab only
|
||||
|
|
|
@ -87,13 +87,34 @@ toolbar[printpreview="true"] {
|
|||
}
|
||||
|
||||
%ifdef CAN_DRAW_IN_TITLEBAR
|
||||
#main-window[inFullscreen] > #titlebar {
|
||||
#main-window[inFullscreen] > #titlebar,
|
||||
#main-window[inFullscreen] .titlebar-placeholder,
|
||||
#main-window:not([tabsintitlebar]) .titlebar-placeholder {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#titlebar {
|
||||
-moz-binding: url("chrome://global/content/bindings/general.xml#windowdragbox");
|
||||
}
|
||||
|
||||
#main-window[tabsintitlebar] #TabsToolbar {
|
||||
-moz-binding: url("chrome://global/content/bindings/toolbar.xml#toolbar-drag");
|
||||
}
|
||||
|
||||
#titlebar-spacer,
|
||||
#main-window[tabsintitlebar]:not([inFullscreen]) .tabbrowser-arrowscrollbox > scrollbox > .scrollbox-innerbox {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.tabbrowser-tab,
|
||||
.tabs-newtab-button {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#main-window[tabsintitlebar] #appmenu-button-container,
|
||||
#main-window[tabsintitlebar] #titlebar-buttonbox {
|
||||
position: relative;
|
||||
}
|
||||
%endif
|
||||
|
||||
toolbarpaletteitem[place="palette"] > toolbaritem > hbox[type="places"] {
|
||||
|
|
|
@ -1286,7 +1286,8 @@ function BrowserStartup() {
|
|||
|
||||
BookmarksMenuButton.init();
|
||||
|
||||
// initialize the private browsing UI
|
||||
TabsInTitlebar.init();
|
||||
|
||||
gPrivateBrowsingUI.init();
|
||||
|
||||
setTimeout(delayedStartup, 0, isLoadingBlank, mustLoadSidebar);
|
||||
|
@ -1677,6 +1678,7 @@ function BrowserShutdown()
|
|||
gPrivateBrowsingUI.uninit();
|
||||
IndexedDBPromptHelper.uninit();
|
||||
AddonManager.removeAddonListener(AddonsMgrListener);
|
||||
TabsInTitlebar.uninit();
|
||||
|
||||
var enumerator = Services.wm.getEnumerator(null);
|
||||
enumerator.getNext();
|
||||
|
@ -2747,10 +2749,6 @@ var PrintPreviewListener = {
|
|||
this._printPreviewTab = null;
|
||||
},
|
||||
_toggleAffectedChrome: function () {
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
updateAppButtonDisplay();
|
||||
#endif
|
||||
|
||||
gNavToolbox.hidden = gInPrintPreviewMode;
|
||||
|
||||
if (gInPrintPreviewMode)
|
||||
|
@ -2760,6 +2758,10 @@ var PrintPreviewListener = {
|
|||
|
||||
if (this._chromeState.sidebarOpen)
|
||||
toggleSidebar(this._sidebarCommand);
|
||||
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
updateAppButtonDisplay();
|
||||
#endif
|
||||
},
|
||||
_hideChrome: function () {
|
||||
this._chromeState = {};
|
||||
|
@ -3459,6 +3461,8 @@ function BrowserCustomizeToolbar()
|
|||
PlacesToolbarHelper.customizeStart();
|
||||
BookmarksMenuButton.customizeStart();
|
||||
|
||||
TabsInTitlebar.allowedBy("customizing-toolbars", false);
|
||||
|
||||
var customizeURL = "chrome://global/content/customizeToolbar.xul";
|
||||
gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
|
||||
|
||||
|
@ -3529,6 +3533,8 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) {
|
|||
PlacesStarButton.updateState();
|
||||
}
|
||||
|
||||
TabsInTitlebar.allowedBy("customizing-toolbars", true);
|
||||
|
||||
// Re-enable parts of the UI we disabled during the dialog
|
||||
var menubar = document.getElementById("main-menubar");
|
||||
for (var i = 0; i < menubar.childNodes.length; ++i)
|
||||
|
@ -4761,6 +4767,7 @@ var TabsOnTop = {
|
|||
document.documentElement.setAttribute("tabsontop", enabled);
|
||||
document.getElementById("TabsToolbar").setAttribute("tabsontop", enabled);
|
||||
gBrowser.tabContainer.setAttribute("tabsontop", enabled);
|
||||
TabsInTitlebar.allowedBy("tabs-on-top", enabled);
|
||||
},
|
||||
get enabled () {
|
||||
return gNavToolbox.getAttribute("tabsontop") == "true";
|
||||
|
@ -4773,6 +4780,115 @@ var TabsOnTop = {
|
|||
}
|
||||
}
|
||||
|
||||
var TabsInTitlebar = {
|
||||
init: function () {
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
this._readPref();
|
||||
Services.prefs.addObserver(this._prefName, this, false);
|
||||
|
||||
// Don't trust the initial value of the sizemode attribute; wait for the resize event.
|
||||
this.allowedBy("sizemode", false);
|
||||
window.addEventListener("resize", function (event) {
|
||||
if (event.target != window)
|
||||
return;
|
||||
let sizemode = document.documentElement.getAttribute("sizemode");
|
||||
TabsInTitlebar.allowedBy("sizemode",
|
||||
sizemode == "maximized" || sizemode == "fullscreen");
|
||||
}, false);
|
||||
|
||||
this._initialized = true;
|
||||
#endif
|
||||
},
|
||||
|
||||
allowedBy: function (condition, allow) {
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
if (allow) {
|
||||
if (condition in this._disallowed) {
|
||||
delete this._disallowed[condition];
|
||||
this._update();
|
||||
}
|
||||
} else {
|
||||
if (!(condition in this._disallowed)) {
|
||||
this._disallowed[condition] = null;
|
||||
this._update();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
},
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
observe: function (subject, topic, data) {
|
||||
if (topic == "nsPref:changed")
|
||||
this._readPref();
|
||||
},
|
||||
|
||||
_initialized: false,
|
||||
_disallowed: {},
|
||||
_prefName: "browser.tabs.drawInTitlebar",
|
||||
|
||||
_readPref: function () {
|
||||
this.allowedBy("pref",
|
||||
Services.prefs.getBoolPref(this._prefName));
|
||||
},
|
||||
|
||||
_update: function () {
|
||||
if (!this._initialized)
|
||||
return;
|
||||
|
||||
let allowed = true;
|
||||
for (let something in this._disallowed) {
|
||||
allowed = false;
|
||||
break;
|
||||
}
|
||||
|
||||
let docElement = document.documentElement;
|
||||
if (allowed == (docElement.getAttribute("tabsintitlebar") == "true"))
|
||||
return;
|
||||
|
||||
function $(id) document.getElementById(id);
|
||||
let titlebar = $("titlebar");
|
||||
|
||||
if (allowed) {
|
||||
let availTop = screen.availTop;
|
||||
function top(ele) ele.boxObject.screenY - availTop;
|
||||
function bottom(ele) top(ele) + rect(ele).height;
|
||||
function rect(ele) ele.getBoundingClientRect();
|
||||
|
||||
let tabsToolbar = $("TabsToolbar");
|
||||
let appmenuButtonBox = $("appmenu-button-container");
|
||||
let captionButtonsBox = $("titlebar-buttonbox");
|
||||
|
||||
this._sizePlaceholder("appmenu-button", rect(appmenuButtonBox).width);
|
||||
this._sizePlaceholder("caption-buttons", rect(captionButtonsBox).width);
|
||||
|
||||
let maxMargin = top(gNavToolbox);
|
||||
let tabsBottom = maxMargin + rect(tabsToolbar).height;
|
||||
let titlebarBottom = Math.max(bottom(appmenuButtonBox), bottom(captionButtonsBox));
|
||||
let distance = tabsBottom - titlebarBottom;
|
||||
titlebar.style.marginBottom = - Math.min(distance, maxMargin) + "px";
|
||||
|
||||
docElement.setAttribute("tabsintitlebar", "true");
|
||||
} else {
|
||||
docElement.removeAttribute("tabsintitlebar");
|
||||
|
||||
titlebar.style.marginBottom = "";
|
||||
}
|
||||
},
|
||||
|
||||
_sizePlaceholder: function (type, width) {
|
||||
Array.forEach(document.querySelectorAll(".titlebar-placeholder[type='"+ type +"']"),
|
||||
function (node) { node.width = width; });
|
||||
},
|
||||
#endif
|
||||
|
||||
uninit: function () {
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
this._initialized = false;
|
||||
Services.prefs.removeObserver(this._prefName, this);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef MENUBAR_CAN_AUTOHIDE
|
||||
function updateAppButtonDisplay() {
|
||||
var displayAppButton =
|
||||
|
@ -4787,6 +4903,8 @@ function updateAppButtonDisplay() {
|
|||
document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
|
||||
else
|
||||
document.documentElement.removeAttribute("chromemargin");
|
||||
|
||||
TabsInTitlebar.allowedBy("drawing-in-titlebar", displayAppButton);
|
||||
#else
|
||||
document.getElementById("appmenu-toolbar-button").hidden =
|
||||
!displayAppButton;
|
||||
|
|
|
@ -485,6 +485,11 @@
|
|||
# hiddenWindow.xul.
|
||||
#include browser-menubar.inc
|
||||
</toolbaritem>
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
<hbox class="titlebar-placeholder" type="appmenu-button" ordinal="0"/>
|
||||
<hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"/>
|
||||
#endif
|
||||
</toolbar>
|
||||
|
||||
<toolbar id="nav-bar" class="toolbar-primary chromeclass-toolbar"
|
||||
|
@ -850,6 +855,10 @@
|
|||
label="&closeTab.label;"
|
||||
tooltiptext="&closeTab.label;"/>
|
||||
|
||||
#ifdef CAN_DRAW_IN_TITLEBAR
|
||||
<hbox class="titlebar-placeholder" type="appmenu-button" ordinal="0"/>
|
||||
<hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"/>
|
||||
#endif
|
||||
</toolbar>
|
||||
|
||||
<toolbarpalette id="BrowserToolbarPalette">
|
||||
|
|
|
@ -2638,6 +2638,9 @@
|
|||
|
||||
Services.prefs.addObserver("browser.tabs.", this._prefObserver, false);
|
||||
window.addEventListener("resize", this, false);
|
||||
|
||||
if (window.TabsInTitlebar)
|
||||
TabsInTitlebar.allowedBy("tabs-visible", this.visible);
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
|
@ -2700,6 +2703,9 @@
|
|||
<property name="visible"
|
||||
onget="return !this._container.collapsed;">
|
||||
<setter><![CDATA[
|
||||
if (val == this.visible)
|
||||
return val;
|
||||
|
||||
this._container.collapsed = !val;
|
||||
|
||||
if (val)
|
||||
|
@ -2709,6 +2715,9 @@
|
|||
document.getElementById("menu_close").setAttribute("label",
|
||||
this.tabbrowser.mStringBundle.getString(val ? "tabs.closeTab" : "tabs.close"));
|
||||
|
||||
if (window.TabsInTitlebar)
|
||||
TabsInTitlebar.allowedBy("tabs-visible", val);
|
||||
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
|
|
@ -418,6 +418,7 @@ let UI = {
|
|||
gTabViewFrame.style.marginTop = "";
|
||||
#endif
|
||||
gTabViewDeck.selectedIndex = 1;
|
||||
gWindow.TabsInTitlebar.allowedBy("tabview-open", false);
|
||||
gTabViewFrame.contentWindow.focus();
|
||||
|
||||
gBrowser.updateTitlebar();
|
||||
|
@ -484,6 +485,7 @@ let UI = {
|
|||
gTabViewFrame.style.marginTop = gBrowser.boxObject.y + "px";
|
||||
#endif
|
||||
gTabViewDeck.selectedIndex = 0;
|
||||
gWindow.TabsInTitlebar.allowedBy("tabview-open", true);
|
||||
gBrowser.contentWindow.focus();
|
||||
|
||||
gBrowser.updateTitlebar();
|
||||
|
|
|
@ -74,6 +74,31 @@
|
|||
background-color: -moz-Dialog;
|
||||
}
|
||||
|
||||
%ifdef WINSTRIPE_AERO
|
||||
@media not all and (-moz-windows-compositor) {
|
||||
%endif
|
||||
#main-window[tabsintitlebar] #titlebar-content:not(:-moz-lwtheme),
|
||||
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) {
|
||||
background-color: ActiveCaption;
|
||||
color: CaptionText;
|
||||
}
|
||||
#main-window[tabsintitlebar] #titlebar-content:not(:-moz-lwtheme):-moz-window-inactive,
|
||||
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme):-moz-window-inactive {
|
||||
background-color: InactiveCaption;
|
||||
color: InactiveCaptionText;
|
||||
}
|
||||
|
||||
#main-window[tabsintitlebar] #titlebar:-moz-lwtheme {
|
||||
visibility: hidden;
|
||||
}
|
||||
#main-window[tabsintitlebar] #titlebar-content:-moz-lwtheme {
|
||||
-moz-binding: url("chrome://global/content/bindings/general.xml#windowdragbox");
|
||||
visibility: visible;
|
||||
}
|
||||
%ifdef WINSTRIPE_AERO
|
||||
}
|
||||
%endif
|
||||
|
||||
#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar)[iconsize="small"],
|
||||
#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar)[defaulticonsize="small"]:not([iconsize]) {
|
||||
padding-top: 1px;
|
||||
|
@ -376,6 +401,14 @@
|
|||
-moz-appearance: -moz-window-button-box-maximized;
|
||||
}
|
||||
|
||||
.titlebar-placeholder[type="appmenu-button"] {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.titlebar-placeholder[type="caption-buttons"] {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
/* titlebar command buttons */
|
||||
|
||||
#titlebar-min {
|
||||
|
|
Загрузка…
Ссылка в новой задаче