Bug 1449689 - Merge updateTitlebarDisplay function into TabsInTitlebar.update. r?johannh draft
authorDão Gottwald <dao@mozilla.com>
Wed, 28 Mar 2018 20:47:21 +0200
changeset 773965 555b9e07b0612793b7021f9ea42cebe09efebedc
parent 773963 fdc23cfe4902ffd831adf0f9418177342906b241
push id104363
push userdgottwald@mozilla.com
push dateWed, 28 Mar 2018 18:48:41 +0000
reviewersjohannh
bugs1449689
milestone61.0a1
Bug 1449689 - Merge updateTitlebarDisplay function into TabsInTitlebar.update. r?johannh MozReview-Commit-ID: IV5wrqoJmjB
browser/base/content/browser-tabsintitlebar.js
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -132,22 +132,30 @@ var TabsInTitlebar = {
   update() {
     if (!this._initialized || window.fullScreen) {
       return;
     }
 
     let allowed = (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");
+      }
     }
 
-    updateTitlebarDisplay();
-
     this._layOutTitlebar(allowed);
 
     ToolbarIconColor.inferFromText("tabsintitlebar", allowed);
   },
 
   _layOutTitlebar(drawInTitlebar) {
     if (!this._windowLayoutReady) {
       return;
@@ -285,33 +293,16 @@ var TabsInTitlebar = {
     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");
-    } 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");
-  }
-}
-
 function onTitlebarMaxClick() {
   if (window.windowState == window.STATE_MAXIMIZED)
     window.restore();
   else
     window.maximize();
 }
 
 // Adds additional drag space to the window by listening to