gecko-dev/browser/base/content/browser-tabsintitlebar.js
Mike Conley b457d05277 Bug 1356920 - Don't calculate and flush layout inside browser-tabsintitlebar.js. r=dao
Folded together the following revisions:

Bug 1356920 - Remove all toolbar layout code from browser-tabsintitlebar. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7805

***

Bug 1356920 - Move TabsToolbar and toolbar-menubar into the titlebar, and put the titlebar into the navigator-toolbox. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7806

***

Bug 1356920 - Put a spacer in the menubar to push titlebar items to the end, and stop the menu from stretching vertically. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7822

***

Bug 1356920 - Adjust CSS rules for new XUL document structure. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7807

***

Bug 1356920 - Fix placement of tracking protection icon. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7808

***

Bug 1356920 - Get rid of the spacer before the window caption buttons now in the TabsToolbar. r=dao

The spacer isn't necessary, since the tabbrowser-tabs node will flex to fill the available
space anyways.

Differential Revision: https://phabricator.services.mozilla.com/D7809

***

Bug 1356920 - Move movingtab attribute to navigator-toolbox to account for TabsToolbar not being a sibling of nav-bar anymore. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7810

***

Bug 1356920 - Hide the window caption buttons hbox if the native titlebar is being drawn. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7811

***

Bug 1356920 - Keep the macOS window caption buttons vertically centered when drag space is enabled. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7812

***

Bug 1356920 - Switch window caption XUL nodes from IDs to classes so that more than one can exist per doc. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7813

***

Bug 1356920 - Move titlebar items out into a preprocessed file to be included at build-time. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7814

***

Bug 1356920 - Reorganize TabsToolbar contents to force most items to the bottom of it. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D9669

***

Bug 1356920 - Update CSS to account for new DOM structure under TabsToolbar. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D9670

***

Bug 1356920 - Fix titlebar button rendering when using a lwtheme without the Windows compositor. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D9671

***

Bug 1356920 - Put an ordinal rule on the window caption buttons to help ensure they stay at the end of the toolbar. r=dao

This is to ensure that the buttons are placed after the post-tabs titlebar placeholder.

Differential Revision: https://phabricator.services.mozilla.com/D7815

***

Bug 1356920 - Stretch window caption buttons to fill vertical space on Windows 8+ when using extra drag space. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7817

***

Bug 1356920 - Update onViewToolbarsPopupShowing to search for toolbars that are grandchildren of the toolbox. r?jaws

Differential Revision: https://phabricator.services.mozilla.com/D7818

***

Bug 1356920 - Hide the titlebar items in the TabsToolbar if the menubar is being displayed. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7825

***

Bug 1356920 - Fix selector for titlebar. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7826

***

Bug 1356920 - Fix titlebar themeing on Linux. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7828

***

Bug 1356920 - Remove browser-tabsintitlebar layout flushes from performance test whitelist. r?florian

Differential Revision: https://phabricator.services.mozilla.com/D7829

***

Bug 1356920 - Fix bottom border of tabbar to account for new DOM structure. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7830

***

Bug 1356920 - Hide the titlebar-buttonbox-container when in fullscreen mode. r=dao

Differential Revision: https://phabricator.services.mozilla.com/D7833

--HG--
extra : rebase_source : fe4acce0443df2fad8e15bf54733b7d810cdd2ca
2018-10-25 12:03:14 -04:00

131 lines
3.3 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var TabsInTitlebar = {
init() {
this._readPref();
Services.prefs.addObserver(this._prefName, this);
gDragSpaceObserver.init();
this._initialized = true;
this.update();
},
allowedBy(condition, allow) {
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();
}
},
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")
this._readPref();
},
_initialized: false,
_disallowed: {},
_prefName: "browser.tabs.drawInTitlebar",
_readPref() {
this.allowedBy("pref",
Services.prefs.getBoolPref(this._prefName));
},
update() {
if (!this._initialized || window.fullScreen) {
return;
}
let allowed = this.systemSupported &&
(Object.keys(this._disallowed)).length == 0;
if (allowed) {
document.documentElement.setAttribute("tabsintitlebar", "true");
if (AppConstants.platform == "macosx") {
document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
document.documentElement.removeAttribute("drawtitle");
} else {
document.documentElement.setAttribute("chromemargin", "0,2,2,2");
}
} else {
document.documentElement.removeAttribute("tabsintitlebar");
document.documentElement.removeAttribute("chromemargin");
if (AppConstants.platform == "macosx") {
document.documentElement.setAttribute("drawtitle", "true");
}
}
ToolbarIconColor.inferFromText("tabsintitlebar", allowed);
},
uninit() {
Services.prefs.removeObserver(this._prefName, this);
gDragSpaceObserver.uninit();
},
};
function onTitlebarMaxClick() {
if (window.windowState == window.STATE_MAXIMIZED)
window.restore();
else
window.maximize();
}
// Adds additional drag space to the window by listening to
// the corresponding preference.
var gDragSpaceObserver = {
pref: "browser.tabs.extraDragSpace",
init() {
this.update();
Services.prefs.addObserver(this.pref, this);
},
uninit() {
Services.prefs.removeObserver(this.pref, this);
},
observe(aSubject, aTopic, aPrefName) {
if (aTopic != "nsPref:changed" || aPrefName != this.pref) {
return;
}
this.update();
},
update() {
if (Services.prefs.getBoolPref(this.pref)) {
document.documentElement.setAttribute("extradragspace", "true");
} else {
document.documentElement.removeAttribute("extradragspace");
}
TabsInTitlebar.update();
},
};