Bug 1448078 - Set the extradragspace attribute before TabsInTitlebar does its initial update. r?johannh
MozReview-Commit-ID: 4jYJ8K3EWfa
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -37,16 +37,18 @@ var TabsInTitlebar = {
this.onWidgetAdded = this.onWidgetRemoved = function(aWidgetId, aArea) {
if (aArea == CustomizableUI.AREA_TABSTRIP || aArea == CustomizableUI.AREA_MENUBAR)
this._update(true);
};
CustomizableUI.addListener(this);
addEventListener("resolutionchange", this, false);
+ gDragSpaceObserver.init();
+
this._update(true, true);
},
allowedBy(condition, allow) {
if (allow) {
if (condition in this._disallowed) {
delete this._disallowed[condition];
this._update(true);
@@ -272,16 +274,17 @@ var TabsInTitlebar = {
function(node) { node.style.width = width + "px"; });
},
uninit() {
removeEventListener("resolutionchange", this);
Services.prefs.removeObserver(this._prefName, this);
this._menuObserver.disconnect();
CustomizableUI.removeListener(this);
+ gDragSpaceObserver.uninit();
}
};
function updateTitlebarDisplay() {
if (AppConstants.platform == "macosx") {
if (TabsInTitlebar.enabled) {
document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
document.documentElement.removeAttribute("drawtitle");
@@ -298,8 +301,40 @@ function updateTitlebarDisplay() {
}
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.updateAppearance(true);
+ },
+};
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1291,20 +1291,16 @@ var gBrowserInit = {
}
gBrowser.updateBrowserRemoteness(initBrowser, isRemote, {
remoteType, sameProcessAsFrameLoader
});
gUIDensity.init();
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- gDragSpaceObserver.init();
- }
-
// Hack to ensure that the about:home favicon is loaded
// instantaneously, to avoid flickering and improve perceived performance.
this._callWithURIToLoad(uriToLoad => {
if (uriToLoad == "about:home") {
gBrowser.setIcon(gBrowser.selectedTab, "chrome://branding/content/icon32.png");
} else if (uriToLoad == "about:privatebrowsing") {
gBrowser.setIcon(gBrowser.selectedTab, "chrome://browser/skin/privatebrowsing/favicon.svg");
}
@@ -1844,20 +1840,16 @@ var gBrowserInit = {
callback(uriToLoad);
else
uriToLoad.then(callback);
},
onUnload() {
gUIDensity.uninit();
- if (AppConstants.CAN_DRAW_IN_TITLEBAR) {
- gDragSpaceObserver.uninit();
- }
-
TabsInTitlebar.uninit();
// In certain scenarios it's possible for unload to be fired before onload,
// (e.g. if the window is being closed after browser.js loads but before the
// load completes). In that case, there's nothing to do here.
if (!this._loadHandled)
return;
@@ -5627,48 +5619,16 @@ var gTabletModePageCounter = {
}
},
};
function displaySecurityInfo() {
BrowserPageInfo(null, "securityTab");
}
-// 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.updateAppearance(true);
- },
-};
-
// Updates the UI density (for touch and compact mode) based on the uidensity pref.
var gUIDensity = {
MODE_NORMAL: 0,
MODE_COMPACT: 1,
MODE_TOUCH: 2,
uiDensityPref: "browser.uidensity",
autoTouchModePref: "browser.touchmode.auto",