Files
tubestation/browser/base/content/browser-tabsintitlebar.js
Emilio Cobos Álvarez 5d9d166821 Bug 1930292 - Stop setting non-zero chromemargin values. r=win-reviewers,handyman
These only do something on Windows, and after windows 7 they are not
useful at all.

If this has no fallout I plan to simplify the code further in a
follow-up (we can basically make this a boolean attribute again or so).

Differential Revision: https://phabricator.services.mozilla.com/D228528
2024-11-16 01:48:48 +00:00

92 lines
2.4 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);
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 "gtk":
isSupported = window.matchMedia("(-moz-gtk-csd-available)").matches;
break;
}
delete this.systemSupported;
return (this.systemSupported = isSupported);
},
get enabled() {
return document.documentElement.getAttribute("tabsintitlebar") == "true";
},
observe(subject, topic) {
if (topic == "nsPref:changed") {
this._readPref();
}
},
_initialized: false,
_disallowed: {},
_prefName: "browser.tabs.inTitlebar",
_readPref() {
let hiddenTitlebar = Services.appinfo.drawInTitlebar;
this.allowedBy("pref", hiddenTitlebar);
},
_update() {
if (!this._initialized) {
return;
}
let allowed =
this.systemSupported &&
!window.fullScreen &&
!Object.keys(this._disallowed).length;
if (allowed) {
document.documentElement.setAttribute("tabsintitlebar", "true");
document.documentElement.setAttribute("chromemargin", "0,0,0,0");
if (AppConstants.platform == "macosx") {
document.documentElement.removeAttribute("drawtitle");
}
} else {
document.documentElement.removeAttribute("tabsintitlebar");
document.documentElement.removeAttribute("chromemargin");
if (AppConstants.platform == "macosx") {
document.documentElement.setAttribute("drawtitle", "true");
}
}
ToolbarIconColor.inferFromText("tabsintitlebar", allowed);
TabBarVisibility.update(true);
},
uninit() {
Services.prefs.removeObserver(this._prefName, this);
},
};