Bug 930094 - [Australis] Browser windows sometimes have the nav-bar drawn in the titlebar. r=dao, Gijs.

This commit is contained in:
Mike Conley 2014-02-04 16:56:07 -05:00
Родитель af6ea4bcc1
Коммит a676b557f8
4 изменённых файлов: 81 добавлений и 54 удалений

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

@ -173,6 +173,7 @@ toolbar[customizing] > .overflow-button {
}
%ifdef CAN_DRAW_IN_TITLEBAR
#main-window:not([chromemargin]) > #titlebar,
#main-window[inFullscreen] > #titlebar,
#main-window[inFullscreen] .titlebar-placeholder,
#main-window:not([tabsintitlebar]) .titlebar-placeholder {

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

@ -4481,6 +4481,9 @@ var TabsInTitlebar = {
// Try to avoid reflows in this code by calculating dimensions first and
// then later set the properties affecting layout together in a batch.
// Get the full height of the tabs toolbar:
let tabsToolbar = $("TabsToolbar");
let fullTabsHeight = rect(tabsToolbar).height;
// Buttons first:
let captionButtonsBoxWidth = rect($("titlebar-buttonbox")).width;
#ifdef XP_MACOSX
@ -4495,11 +4498,9 @@ var TabsInTitlebar = {
let menuHeight = rect(menubar).height;
let menuStyles = window.getComputedStyle(menubar);
let fullMenuHeight = verticalMargins(menuStyles) + menuHeight;
#endif
// Get the full height of the tabs toolbar:
let tabsToolbar = $("TabsToolbar");
let tabsStyles = window.getComputedStyle(tabsToolbar);
let fullTabsHeight = rect(tabsToolbar).height + verticalMargins(tabsStyles);
fullTabsHeight += verticalMargins(tabsStyles);
#endif
// If the navbar overlaps the tabbar using negative margins, we need to take those into
// account so we don't overlap it
@ -4509,16 +4510,6 @@ var TabsInTitlebar = {
// And get the height of what's in the titlebar:
let titlebarContentHeight = rect(titlebarContent).height;
// Padding surrounds the tab-view-deck when we are in customization mode,
// so take that into account:
let areCustomizing = document.documentElement.hasAttribute("customizing") ||
document.documentElement.hasAttribute("customize-exiting");
let customizePadding = 0;
if (areCustomizing) {
let deckStyle = window.getComputedStyle($("tab-view-deck"));
customizePadding = parseFloat(deckStyle.paddingTop);
}
// Begin setting CSS properties which will cause a reflow
// If the menubar is around (menuHeight is non-zero), try to adjust
@ -4551,10 +4542,6 @@ var TabsInTitlebar = {
// Next, we calculate how much we need to stretch the titlebar down to
// go all the way to the bottom of the tab strip, if necessary.
let tabAndMenuHeight = fullTabsHeight + fullMenuHeight;
// Oh, and don't forget customization mode:
if (areCustomizing) {
tabAndMenuHeight += customizePadding;
}
if (tabAndMenuHeight > titlebarContentHeight) {
// We need to increase the titlebar content's outer height (ie including margins)
@ -4566,12 +4553,6 @@ var TabsInTitlebar = {
// On non-OSX, we can just use bottom margin:
#ifndef XP_MACOSX
titlebarContent.style.marginBottom = extraMargin + "px";
#else
// Otherwise, center the content. This means taking the titlebar's
// padding into account:
let halfMargin = (extraMargin - titlebarPadding) / 2;
titlebarContent.style.marginTop = halfMargin + "px";
titlebarContent.style.marginBottom = (titlebarPadding + halfMargin) + "px";
#endif
titlebarContentHeight += extraMargin;
}
@ -4606,6 +4587,7 @@ var TabsInTitlebar = {
updateTitlebarDisplay();
// Reset the margins and padding that might have been modified:
titlebarContent.style.marginTop = "";
titlebarContent.style.marginBottom = "";
titlebar.style.marginBottom = "";
menubar.style.paddingBottom = "";
@ -4630,16 +4612,37 @@ var TabsInTitlebar = {
#ifdef CAN_DRAW_IN_TITLEBAR
function updateTitlebarDisplay() {
document.getElementById("titlebar").hidden = !TabsInTitlebar.enabled;
#ifdef XP_MACOSX
// OS X and the other platforms differ enough to necessitate this kind of
// special-casing. Like the other platforms where we CAN_DRAW_IN_TITLEBAR,
// we draw in the OS X titlebar when putting the tabs up there. However, OS X
// also draws in the titlebar when a lightweight theme is applied, regardless
// of whether or not the tabs are drawn in the titlebar.
if (TabsInTitlebar.enabled) {
document.documentElement.setAttribute("chromemargin-nonlwtheme", "0,-1,-1,-1");
document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
document.documentElement.removeAttribute("drawtitle");
} else {
// We set chromemargin-nonlwtheme to "" instead of removing it as a way of
// making sure that LightweightThemeConsumer doesn't take it upon itself to
// detect this value again if and when we do a lwtheme state change.
document.documentElement.setAttribute("chromemargin-nonlwtheme", "");
let isCustomizing = document.documentElement.hasAttribute("customizing");
let hasLWTheme = document.documentElement.hasAttribute("lwtheme");
if (!hasLWTheme || isCustomizing) {
document.documentElement.removeAttribute("chromemargin");
}
document.documentElement.setAttribute("drawtitle", "true");
}
#else
if (TabsInTitlebar.enabled)
#ifdef XP_WIN
document.documentElement.setAttribute("chromemargin", "0,2,2,2");
#else
document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
#endif
else
document.documentElement.removeAttribute("chromemargin");
#endif
}
#endif

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

@ -59,7 +59,7 @@
}
}
#main-window[chromehidden~="toolbar"] > #titlebar {
#main-window[chromehidden~="toolbar"]:not(:-moz-lwtheme) > #titlebar {
padding-top: 22px;
}
@ -2658,7 +2658,7 @@ toolbarbutton.chevron > .toolbarbutton-menu-dropmarker {
box-shadow: @focusRingShadow@;
}
#titlebar {
#main-window:not(:-moz-lwtheme) > #titlebar {
padding-top: @spaceAboveTabbar@;
min-height: @tabHeight@;
}
@ -4093,13 +4093,26 @@ window > chatbox {
%include ../shared/customizableui/customizeMode.inc.css
#main-window[customize-entered] #titlebar {
#main-window[customize-entered] > #titlebar {
padding-top: 0;
}
#main-window[tabsintitlebar][customize-entered] #titlebar-content {
margin-bottom: 0px !important;
margin-top: 11px !important;
#main-window[tabsintitlebar]:not([customizing]):not(:-moz-lwtheme) > #titlebar > #titlebar-content,
#main-window[tabsintitlebar][customize-entering] > #titlebar > #titlebar-content,
#main-window[tabsintitlebar][customize-exiting] > #titlebar > #titlebar-content {
margin-top: 2px;
margin-bottom: 11px;
}
#main-window[tabsintitlebar][customize-entered] > #titlebar > #titlebar-content,
#main-window:not([tabsintitlebar]):not(:-moz-lwtheme) > #titlebar > #titlebar-content {
margin-top: 11px;
margin-bottom: 0px;
}
#main-window[tabsintitlebar]:-moz-lwtheme > #titlebar > #titlebar-content {
margin-top: 11px;
margin-bottom: 11px;
}
#main-window[customize-entered] #tab-view-deck {
@ -4124,8 +4137,11 @@ window > chatbox {
border-bottom-width: 0;
}
#main-window[customize-entered] #TabsToolbar {
#main-window[tabsintitlebar][customize-entered] #TabsToolbar {
margin-top: 9px;
}
#main-window[customize-entered] #TabsToolbar {
background-clip: padding-box;
border-right: 3px solid transparent;
border-left: 3px solid transparent;

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

@ -42,9 +42,7 @@ LightweightThemeConsumer.prototype = {
_lastScreenWidth: null,
_lastScreenHeight: null,
_enabled: true,
#ifdef XP_MACOSX
_chromemarginDefault: undefined,
#endif
_active: false,
enable: function() {
this._enabled = true;
@ -100,8 +98,9 @@ LightweightThemeConsumer.prototype = {
if (!this._enabled)
return;
var root = this._doc.documentElement;
var active = !!aData.headerURL;
let root = this._doc.documentElement;
let active = !!aData.headerURL;
let stateChanging = (active != this._active);
if (active) {
root.style.color = aData.textcolor || "black";
@ -117,6 +116,8 @@ LightweightThemeConsumer.prototype = {
root.removeAttribute("lwtheme");
}
this._active = active;
_setImage(root, active, aData.headerURL);
if (this._footerId) {
let footer = this._doc.getElementById(this._footerId);
@ -129,20 +130,26 @@ LightweightThemeConsumer.prototype = {
}
#ifdef XP_MACOSX
// Sample whether or not we draw in the titlebar by default the first time we update.
// If the root has no chromemargin attribute, getAttribute will return null, and
// we'll remove the attribute when the lw-theme is deactivated.
if (this._chromemarginDefault === undefined)
this._chromemarginDefault = root.getAttribute("chromemargin");
// On OS X, we extend the lightweight theme into the titlebar, which means setting
// the chromemargin attribute. Some XUL applications already draw in the titlebar,
// so we need to save the chromemargin value before we overwrite it with the value
// that lets us draw in the titlebar. We stash this value on the root attribute so
// that XUL applications have the ability to invalidate the saved value.
if (stateChanging) {
if (!root.hasAttribute("chromemargin-nonlwtheme")) {
root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
}
if (active) {
root.setAttribute("chromemargin", "0,-1,-1,-1");
}
else {
if (this._chromemarginDefault)
root.setAttribute("chromemargin", this._chromemarginDefault);
else
root.removeAttribute("chromemargin");
if (active) {
root.setAttribute("chromemargin", "0,-1,-1,-1");
} else {
let defaultChromemargin = root.getAttribute("chromemargin-nonlwtheme");
if (defaultChromemargin) {
root.setAttribute("chromemargin", defaultChromemargin);
} else {
root.removeAttribute("chromemargin");
}
}
}
#endif
}