Bug 1451238 - Port
bug 1450279 to TB: Replace CAN_DRAW_IN_TITLEBAR with a run-time check. r=jorgk
--- a/mail/base/content/mainNavigationToolbox.inc
+++ b/mail/base/content/mainNavigationToolbox.inc
@@ -942,14 +942,12 @@
#endif
<!-- Help -->
#include helpMenu.inc
<spacer id="menubar_spacer" flex="100%"/>
</menubar>
</toolbaritem>
-#ifdef CAN_DRAW_IN_TITLEBAR
#ifndef XP_MACOSX
<hbox class="titlebar-placeholder" type="caption-buttons" ordinal="1000"/>
#endif
-#endif
</toolbar>
--- a/mail/base/content/messenger.xul
+++ b/mail/base/content/messenger.xul
@@ -308,33 +308,31 @@
<menuitem label="&openAddressBookDock.label;" id="tasksOpenAddressBook"
oncommand="openAddressBookDock();"/>
<menuitem label="&dockOptions.label;" id="tasksMenuDockOptions"
oncommand="openDockOptions();"/>
</menupopup>
</popupset>
#endif
-#ifdef CAN_DRAW_IN_TITLEBAR
<vbox id="titlebar">
<hbox id="titlebar-content">
<spacer id="titlebar-spacer" flex="1"/>
<hbox id="titlebar-buttonbox-container" align="start">
<hbox id="titlebar-buttonbox">
<toolbarbutton class="titlebar-button" id="titlebar-min" oncommand="window.minimize();"/>
<toolbarbutton class="titlebar-button" id="titlebar-max" oncommand="onTitlebarMaxClick();"/>
<toolbarbutton class="titlebar-button" id="titlebar-close" oncommand="window.close()"/>
</hbox>
</hbox>
#ifdef XP_MACOSX
<hbox id="titlebar-fullscreen-button"/>
#endif
</hbox>
</vbox>
-#endif
<!-- navigation-toolbox with main menubar and tabs toolbar -->
#include mainNavigationToolbox.inc
<toolbar id="tabs-toolbar">
<!-- class tabmail-tabs is unused and only maintained for add-ons. -->
<tabs flex="1"
id="tabmail-tabs"
@@ -367,26 +365,25 @@
id="alltabs-button"
type="menu"
hidden="true"
tooltiptext="&listAllTabs.label;">
<menupopup class="tabs-alltabs-popup"
id="alltabs-popup" position="after_end"
tabcontainer="tabmail-tabs"/>
</toolbarbutton>
-#ifdef CAN_DRAW_IN_TITLEBAR
+
<hbox class="titlebar-placeholder" type="caption-buttons"
#ifndef XP_MACOSX
ordinal="1000"
#endif
/>
#ifdef XP_MACOSX
<hbox class="titlebar-placeholder" type="fullscreen-button"/>
#endif
-#endif
</toolbar>
</toolbox>
<!-- XXX This extension point (tabmail-container) is only temporary!
Horizontal space shouldn't be wasted if it isn't absolutely critical.
A mechanism for adding sidebar panes will be added in bug 476154. -->
<hbox id="tabmail-container" flex="1">
--- a/mail/base/content/msgMail3PaneWindow.js
+++ b/mail/base/content/msgMail3PaneWindow.js
@@ -1646,83 +1646,87 @@ function InitPageMenu(menuPopup, event)
PageMenuParent.buildAndAddToPopup(menuPopup.triggerNode, menuPopup);
if (menuPopup.children.length == 0)
event.preventDefault();
}
var TabsInTitlebar = {
init() {
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- // Don't trust the initial value of the sizemode attribute; wait for the
- // resize event.
- this._readPref();
- Services.prefs.addObserver(this._drawInTitlePref, this);
- Services.prefs.addObserver(this._autoHidePref, this);
+ // Don't trust the initial value of the sizemode attribute; wait for the
+ // resize event.
+ this._readPref();
+ Services.prefs.addObserver(this._drawInTitlePref, this);
+ Services.prefs.addObserver(this._autoHidePref, this);
- this.allowedBy("sizemode", false);
- window.addEventListener("resize", function (event) {
- if (event.target != window)
- return;
- TabsInTitlebar.allowedBy("sizemode", true);
- });
-
- // Always disable on unsupported GTK versions.
- if (AppConstants.MOZ_WIDGET_TOOLKIT == "gtk3") {
- this.allowedBy("gtk", window.matchMedia("(-moz-gtk-csd-available)"));
- }
+ this.allowedBy("sizemode", false);
+ window.addEventListener("resize", function (event) {
+ if (event.target != window)
+ return;
+ TabsInTitlebar.allowedBy("sizemode", true);
+ });
- // We need to update the appearance of the titlebar when the menu changes
- // from the active to the inactive state. We can't, however, rely on
- // DOMMenuBarInactive, because the menu fires this event and then removes
- // the inactive attribute after an event-loop spin.
- //
- // Because updating the appearance involves sampling the heights and
- // margins of various elements, it's important that the layout be more or
- // less settled before updating the titlebar. So instead of listening to
- // DOMMenuBarActive and DOMMenuBarInactive, we use a MutationObserver to
- // watch the "invalid" attribute directly.
- let menu = document.getElementById("mail-toolbar-menubar2");
- this._menuObserver = new MutationObserver(this._onMenuMutate);
- this._menuObserver.observe(menu, {attributes: true});
+ // We need to update the appearance of the titlebar when the menu changes
+ // from the active to the inactive state. We can't, however, rely on
+ // DOMMenuBarInactive, because the menu fires this event and then removes
+ // the inactive attribute after an event-loop spin.
+ //
+ // Because updating the appearance involves sampling the heights and
+ // margins of various elements, it's important that the layout be more or
+ // less settled before updating the titlebar. So instead of listening to
+ // DOMMenuBarActive and DOMMenuBarInactive, we use a MutationObserver to
+ // watch the "invalid" attribute directly.
+ let menu = document.getElementById("mail-toolbar-menubar2");
+ this._menuObserver = new MutationObserver(this._onMenuMutate);
+ this._menuObserver.observe(menu, {attributes: true});
- let sizeMode = document.getElementById("messengerWindow");
- this._sizeModeObserver = new MutationObserver(this._onSizeModeMutate);
- this._sizeModeObserver.observe(sizeMode, {attributes: true});
+ let sizeMode = document.getElementById("messengerWindow");
+ this._sizeModeObserver = new MutationObserver(this._onSizeModeMutate);
+ this._sizeModeObserver.observe(sizeMode, {attributes: true});
- this._initialized = true;
- if (this._updateOnInit) {
- // We don't need to call this with 'true', even if original calls
- // (before init()) did, because this will be the first call and so
- // we will update anyway.
- this._update();
- }
+ this._initialized = true;
+ if (this._updateOnInit) {
+ // We don't need to call this with 'true', even if original calls
+ // (before init()) did, because this will be the first call and so
+ // we will update anyway.
+ this._update();
}
},
allowedBy(condition, allow) {
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- if (allow) {
- if (condition in this._disallowed) {
- delete this._disallowed[condition];
- this._update(true);
- }
- } else {
- if (!(condition in this._disallowed)) {
- this._disallowed[condition] = null;
- this._update(true);
- }
+ if (allow) {
+ if (condition in this._disallowed) {
+ delete this._disallowed[condition];
+ this._update(true);
+ }
+ } else {
+ if (!(condition in this._disallowed)) {
+ this._disallowed[condition] = null;
+ this._update(true);
}
}
},
updateAppearance: function updateAppearance(aForce) {
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- this._update(aForce);
+ this._update(aForce);
+ },
+
+ get systemSupported() {
+ let isSupported = false;
+ switch (AppConstants.MOZ_WIDGET_TOOLKIT) {
+ case "windows":
+ case "cocoa":
+ isSupported = true;
+ break;
+ case "gtk3":
+ isSupported = window.matchMedia("(-moz-gtk-csd-available)");
+ break;
}
+ delete this.systemSupported;
+ return this.systemSupported = isSupported;
},
get enabled() {
return document.documentElement.getAttribute("tabsintitlebar") == "true";
},
observe(subject, topic, data) {
if (topic == "nsPref:changed")
@@ -1792,17 +1796,18 @@ var TabsInTitlebar = {
// still changing in the consequent "fullscreen" event. Code there will
// call this function again when everything is ready.
// See browser-fullScreen.js: FullScreen.toggle and bug 1173768.
if (oldSizeMode == "fullscreen") {
return;
}
}
- let allowed = (Object.keys(this._disallowed)).length == 0;
+ let allowed = this.systemSupported &&
+ (Object.keys(this._disallowed)).length == 0;
let titlebar = $("titlebar");
let titlebarContent = $("titlebar-content");
let titlebarButtons = $("titlebar-buttonbox");
let menubar = $("mail-toolbar-menubar2");
if (allowed) {
// We set the tabsintitlebar attribute first so that our CSS for
@@ -1925,41 +1930,37 @@ var TabsInTitlebar = {
},
_sizePlaceholder(type, width) {
Array.forEach(document.querySelectorAll(".titlebar-placeholder[type='" + type + "']"),
function(node) { node.style.width = width + "px"; });
},
uninit() {
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- this._initialized = false;
- Services.prefs.removeObserver(this._drawInTitlePref, this);
- Services.prefs.removeObserver(this._autoHidePref, this);
- this._menuObserver.disconnect();
- }
+ this._initialized = false;
+ Services.prefs.removeObserver(this._drawInTitlePref, this);
+ Services.prefs.removeObserver(this._autoHidePref, this);
+ this._menuObserver.disconnect();
}
};
-if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- function updateTitlebarDisplay() {
- if (AppConstants.platform == "macosx") {
- if (TabsInTitlebar.enabled) {
- document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
- document.documentElement.removeAttribute("drawtitle");
- } else {
- document.documentElement.removeAttribute("chromemargin");
- document.documentElement.setAttribute("drawtitle", "true");
- }
- } else if (TabsInTitlebar.enabled) {
- // not OS X
- document.documentElement.setAttribute("chromemargin", "0,2,2,2");
+function updateTitlebarDisplay() {
+ if (AppConstants.platform == "macosx") {
+ if (TabsInTitlebar.enabled) {
+ document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
+ document.documentElement.removeAttribute("drawtitle");
} else {
document.documentElement.removeAttribute("chromemargin");
+ document.documentElement.setAttribute("drawtitle", "true");
}
+ } else if (TabsInTitlebar.enabled) {
+ // not OS X
+ document.documentElement.setAttribute("chromemargin", "0,2,2,2");
+ } else {
+ document.documentElement.removeAttribute("chromemargin");
}
}
/* Draw */
function onTitlebarMaxClick() {
if (window.windowState == window.STATE_MAXIMIZED)
window.restore();
else
--- a/mail/base/moz.build
+++ b/mail/base/moz.build
@@ -16,15 +16,12 @@ DEFINES['mozreltopsrcdir'] = CONFIG['moz
DEFINES['APP_LICENSE_BLOCK'] = '%s/content/overrides/app-license.html' % SRCDIR
if CONFIG['MOZILLA_OFFICIAL']:
DEFINES['OFFICIAL_BUILD'] = 1
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'gtk3', 'cocoa'):
DEFINES['HAVE_SHELL_SERVICE'] = 1
-if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa', 'gtk3'):
- DEFINES['CAN_DRAW_IN_TITLEBAR'] = 1
-
if CONFIG['MOZ_UPDATER']:
DEFINES['MOZ_UPDATER'] = 1
DEFINES['TOOLKIT_DIR'] = "%s/toolkit" % (CONFIG['moztopsrcdir'],)