Bug 1390885 - Remove code that adjusts the titlebar to drawing lwthemes inside the titlebar. r=nhnt11 draft
authorJohann Hofmann <jhofmann@mozilla.com>
Thu, 28 Sep 2017 23:16:04 +0200
changeset 672181 6f93145c9bdab0046d6ab9a06a148f90d3bf07c9
parent 671801 76a26ef7c493311c170ae83eb0c1d6592a21396d
child 733742 d3190dc2617cb4f7fcde1df7740d760bc39d76e6
push id82181
push userbmo:jhofmann@mozilla.com
push dateThu, 28 Sep 2017 21:16:39 +0000
reviewersnhnt11
bugs1390885, 1392219
milestone58.0a1
Bug 1390885 - Remove code that adjusts the titlebar to drawing lwthemes inside the titlebar. r=nhnt11 We got rid of drawing lwthemes inside the titlebar on OSX in bug 1392219 but there was still some code that adjusted the titlebar, which we forgot remove. Incidentally, that code was also causing a bug (even before we removed the in-titlebar drawing) which we now don't need to worry about anymore now. MozReview-Commit-ID: 44HR25Uyp8B
browser/base/content/browser-tabsintitlebar.js
toolkit/modules/LightweightThemeConsumer.jsm
--- a/browser/base/content/browser-tabsintitlebar.js
+++ b/browser/base/content/browser-tabsintitlebar.js
@@ -283,36 +283,21 @@ var TabsInTitlebar = {
     Services.prefs.removeObserver(this._prefName, this);
     this._menuObserver.disconnect();
     CustomizableUI.removeListener(this);
   }
 };
 
 function updateTitlebarDisplay() {
   if (AppConstants.platform == "macosx") {
-    // OS X and the other platforms differ enough to necessitate this kind of
-    // special-casing. Like the other platforms where we CAN_DRAW_IN_TITLEBAR,
-    // we draw in the OS X titlebar when putting the tabs up there. However, OS X
-    // also draws in the titlebar when a lightweight theme is applied, regardless
-    // of whether or not the tabs are drawn in the titlebar.
     if (TabsInTitlebar.enabled) {
-      document.documentElement.setAttribute("chromemargin-nonlwtheme", "0,-1,-1,-1");
       document.documentElement.setAttribute("chromemargin", "0,-1,-1,-1");
       document.documentElement.removeAttribute("drawtitle");
     } else {
-      // We set chromemargin-nonlwtheme to "" instead of removing it as a way of
-      // making sure that LightweightThemeConsumer doesn't take it upon itself to
-      // detect this value again if and when we do a lwtheme state change.
-      document.documentElement.setAttribute("chromemargin-nonlwtheme", "");
-      let isCustomizing = document.documentElement.hasAttribute("customizing");
-      let hasLWTheme = document.documentElement.hasAttribute("lwtheme");
-      let isPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
-      if ((!hasLWTheme || isCustomizing) && !isPrivate) {
-        document.documentElement.removeAttribute("chromemargin");
-      }
+      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");
   }
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -155,37 +155,16 @@ LightweightThemeConsumer.prototype = {
     _setImage(root, active, "--lwt-additional-images", aData.additionalBackgrounds);
     _setProperties(root, active, aData);
 
     if (active && aData.footerURL)
       root.setAttribute("lwthemefooter", "true");
     else
       root.removeAttribute("lwthemefooter");
 
-    // On OS X, we extend the lightweight theme into the titlebar, which means setting
-    // the chromemargin attribute. Some XUL applications already draw in the titlebar,
-    // so we need to save the chromemargin value before we overwrite it with the value
-    // that lets us draw in the titlebar. We stash this value on the root attribute so
-    // that XUL applications have the ability to invalidate the saved value.
-    if (AppConstants.platform == "macosx" && stateChanging) {
-      if (!root.hasAttribute("chromemargin-nonlwtheme")) {
-        root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
-      }
-
-      if (active) {
-        root.setAttribute("chromemargin", "0,-1,-1,-1");
-      } else {
-        let defaultChromemargin = root.getAttribute("chromemargin-nonlwtheme");
-        if (defaultChromemargin) {
-          root.setAttribute("chromemargin", defaultChromemargin);
-        } else {
-          root.removeAttribute("chromemargin");
-        }
-      }
-    }
     Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
                                  JSON.stringify(aData));
   }
 }
 
 function _setImage(aRoot, aActive, aVariableName, aURLs) {
   if (aURLs && !Array.isArray(aURLs)) {
     aURLs = [aURLs];