Bug 1344307 - Clean up lightweight theme footer handling. r?jaws draft
authorDão Gottwald <dao@mozilla.com>
Fri, 03 Mar 2017 19:41:28 +0100
changeset 493265 cb762307eef3196a36442eaf68c26a62824b670e
parent 493227 77d5a39a4677ed8e32a7ed46561c962d807fa7b1
child 547817 6ed9f86d5ef4b5a008003a9c844e2aa43f4e3b64
push id47710
push userdgottwald@mozilla.com
push dateFri, 03 Mar 2017 18:42:15 +0000
reviewersjaws
bugs1344307
milestone54.0a1
Bug 1344307 - Clean up lightweight theme footer handling. r?jaws MozReview-Commit-ID: BIUszE69HhH
browser/base/content/browser.css
browser/base/content/browser.xul
toolkit/modules/LightweightThemeConsumer.jsm
toolkit/themes/linux/global/global.css
toolkit/themes/osx/global/global.css
toolkit/themes/windows/global/global.css
--- a/browser/base/content/browser.css
+++ b/browser/base/content/browser.css
@@ -446,21 +446,21 @@ toolbar:not(#TabsToolbar) > #personal-bo
 }
 
 %ifdef XP_MACOSX
 #main-window[inFullscreen="true"] {
   padding-top: 0; /* override drawintitlebar="true" */
 }
 %endif
 
-#browser-bottombox[lwthemefooter="true"] {
+:root[lwthemefooter=true] #browser-bottombox:-moz-lwtheme {
   background-repeat: no-repeat;
   background-position: bottom left;
   background-color: var(--lwt-accent-color);
-  background-image: var(--lwt-header-image);
+  background-image: var(--lwt-footer-image);
 }
 
 .menuitem-iconic-tooltip {
   -moz-binding: url("chrome://browser/content/urlbarBindings.xml#menuitem-iconic-tooltip");
 }
 
 /* Hide menu elements intended for keyboard access support */
 #main-menubar[openedwithkey=false] .show-only-for-keyboard {
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -47,17 +47,16 @@
         chromemargin="0,2,2,2"
 #else
         chromemargin="0,-1,-1,-1"
 #endif
         tabsintitlebar="true"
 #endif
         titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
         lightweightthemes="true"
-        lightweightthemesfooter="browser-bottombox"
         windowtype="navigator:browser"
         macanimationtype="document"
         screenX="4" screenY="4"
         fullscreenbutton="true"
         sizemode="normal"
         retargetdocumentfocus="urlbar"
         persist="screenX screenY width height sizemode">
 
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -12,17 +12,16 @@ Cu.import("resource://gre/modules/AppCon
 
 XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
   "resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
 
 this.LightweightThemeConsumer =
  function LightweightThemeConsumer(aDocument) {
   this._doc = aDocument;
   this._win = aDocument.defaultView;
-  this._footerId = aDocument.documentElement.getAttribute("lightweightthemesfooter");
 
   let screen = this._win.screen;
   this._lastScreenWidth = screen.width;
   this._lastScreenHeight = screen.height;
 
   Services.obs.addObserver(this, "lightweight-theme-styling-update", false);
 
   var temp = {};
@@ -118,25 +117,22 @@ LightweightThemeConsumer.prototype = {
       root.setAttribute("lwtheme", "true");
     } else {
       root.removeAttribute("lwthemetextcolor");
       root.removeAttribute("lwtheme");
     }
 
     this._active = active;
 
-    _setImage(root, active, aData.headerURL, "--lwt-header-image");
-    if (this._footerId) {
-      let footer = this._doc.getElementById(this._footerId);
-      _setImage(footer, active, aData.footerURL, "--lwt-footer-image");
-      if (active && aData.footerURL)
-        footer.setAttribute("lwthemefooter", "true");
-      else
-        footer.removeAttribute("lwthemefooter");
-    }
+    _setImage(root, active, "--lwt-header-image", aData.headerURL);
+    _setImage(root, active, "--lwt-footer-image", aData.footerURL);
+    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")) {
@@ -154,21 +150,21 @@ LightweightThemeConsumer.prototype = {
         }
       }
     }
     Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
                                  JSON.stringify(aData));
   }
 }
 
-function _setImage(aElement, aActive, aURL, aVariableName) {
+function _setImage(aRoot, aActive, aVariableName, aURL) {
   if (aActive && aURL) {
-    aElement.style.setProperty(aVariableName, `url("${aURL.replace(/"/g, '\\"')}")`);
+    aRoot.style.setProperty(aVariableName, `url("${aURL.replace(/"/g, '\\"')}")`);
   } else {
-    aElement.style.removeProperty(aVariableName);
+    aRoot.style.removeProperty(aVariableName);
   }
 }
 
 function _parseRGB(aColorString) {
   var rgb = aColorString.match(/^rgba?\((\d+), (\d+), (\d+)/);
   rgb.shift();
   return rgb.map(x => parseInt(x));
 }
--- a/toolkit/themes/linux/global/global.css
+++ b/toolkit/themes/linux/global/global.css
@@ -150,17 +150,16 @@ sidebarheader > label {
 toolbar[mode="text"] .toolbarbutton-text {
   padding: 0 !important;
   margin: 3px 5px !important;
 }
 
 /* ::::: miscellaneous formatting ::::: */
 
 :root:-moz-lwtheme,
-[lwthemefooter="true"],
 statusbarpanel:-moz-lwtheme {
   -moz-appearance: none;
 }
 
 sidebarheader:-moz-lwtheme {
   background: none;
 }
 
--- a/toolkit/themes/osx/global/global.css
+++ b/toolkit/themes/osx/global/global.css
@@ -110,18 +110,17 @@ statusbarpanel {
 }
 
 .statusbarpanel-iconic {
   padding: 0px;
 }    
 
 /* ::::: miscellaneous formatting ::::: */
 
-:root:-moz-lwtheme,
-[lwthemefooter="true"] {
+:root:-moz-lwtheme {
   -moz-appearance: none;
 }
 
 :root:-moz-lwtheme-darktext {
   text-shadow: 0 -0.5px 1.5px white;
 }
 
 :root:-moz-lwtheme-brighttext {
--- a/toolkit/themes/windows/global/global.css
+++ b/toolkit/themes/windows/global/global.css
@@ -151,18 +151,17 @@ sidebarheader > label {
 
 toolbar[mode="text"] .toolbarbutton-text {
   padding: 0 !important;
   margin: 3px 5px !important;
 }
 
 /* ::::: miscellaneous formatting ::::: */
 
-:root:-moz-lwtheme,
-[lwthemefooter="true"] {
+:root:-moz-lwtheme {
   -moz-appearance: none;
 }
 
 :root:-moz-lwtheme-darktext {
   text-shadow: 0 -0.5px 1.5px white;
 }
 
 :root:-moz-lwtheme-brighttext {