Bug 1434401 - Remove the "root-element" binding from :root and create the LightweightThemeConsumer directly from browser.js;r=dao draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 13 Feb 2018 09:16:10 -0800
changeset 754478 e54adefcdacf0ca470d02fd80c7ddfabf0af42b2
parent 754399 38b3c1d03a594664c6b32c35533734283c258f43
push id98894
push userbgrinstead@mozilla.com
push dateTue, 13 Feb 2018 17:16:42 +0000
reviewersdao
bugs1434401
milestone60.0a1
Bug 1434401 - Remove the "root-element" binding from :root and create the LightweightThemeConsumer directly from browser.js;r=dao MozReview-Commit-ID: GZiovTZpu6a
browser/base/content/browser.js
browser/base/content/browser.xul
toolkit/content/minimal-xul.css
toolkit/content/widgets/dialog.xml
toolkit/content/widgets/general.xml
toolkit/content/widgets/wizard.xml
toolkit/modules/LightweightThemeConsumer.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -25,16 +25,17 @@ XPCOMUtils.defineLazyModuleGetters(this,
   ContextualIdentityService: "resource://gre/modules/ContextualIdentityService.jsm",
   CustomizableUI: "resource:///modules/CustomizableUI.jsm",
   Deprecated: "resource://gre/modules/Deprecated.jsm",
   DownloadsCommon: "resource:///modules/DownloadsCommon.jsm",
   E10SUtils: "resource://gre/modules/E10SUtils.jsm",
   ExtensionsUI: "resource:///modules/ExtensionsUI.jsm",
   FormValidationHandler: "resource:///modules/FormValidationHandler.jsm",
   LanguagePrompt: "resource://gre/modules/LanguagePrompt.jsm",
+  LightweightThemeConsumer: "resource://gre/modules/LightweightThemeConsumer.jsm",
   LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm",
   Log: "resource://gre/modules/Log.jsm",
   LoginManagerParent: "resource://gre/modules/LoginManagerParent.jsm",
   NewTabUtils: "resource://gre/modules/NewTabUtils.jsm",
   PageActions: "resource:///modules/PageActions.jsm",
   PageThumbs: "resource://gre/modules/PageThumbs.jsm",
   PanelMultiView: "resource:///modules/PanelMultiView.jsm",
   PanelView: "resource:///modules/PanelMultiView.jsm",
@@ -1308,16 +1309,17 @@ var gBrowserInit = {
     Services.obs.notifyObservers(window, "browser-window-before-show");
 
     if (!window.toolbar.visible) {
       // adjust browser UI for popups
       gURLBar.setAttribute("readonly", "true");
     }
 
     // Misc. inits.
+    new LightweightThemeConsumer(document);
     TabletModeUpdater.init();
     CombinedStopReload.ensureInitialized();
     gPrivateBrowsingUI.init();
     BrowserPageActions.init();
     gAccessibilityServiceIndicator.init();
 
     if (window.matchMedia("(-moz-os-version: windows-win8)").matches &&
         window.matchMedia("(-moz-windows-default-theme)").matches) {
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -46,17 +46,16 @@
 #ifdef XP_WIN
         chromemargin="0,2,2,2"
 #else
         chromemargin="0,-1,-1,-1"
 #endif
         tabsintitlebar="true"
 #endif
         titlemenuseparator="&mainWindow.titlemodifiermenuseparator;"
-        lightweightthemes="true"
         windowtype="navigator:browser"
         macanimationtype="document"
         screenX="4" screenY="4"
         fullscreenbutton="true"
         sizemode="normal"
         retargetdocumentfocus="urlbar"
         persist="screenX screenY width height sizemode">
 
--- a/toolkit/content/minimal-xul.css
+++ b/toolkit/content/minimal-xul.css
@@ -25,17 +25,16 @@
   -moz-user-focus: ignore;
   -moz-user-select: none;
   display: -moz-box;
   box-sizing: border-box;
 }
 
 :root {
   text-rendering: optimizeLegibility;
-  -moz-binding: url("chrome://global/content/bindings/general.xml#root-element");
   -moz-control-character-visibility: visible;
 }
 
 :root:-moz-locale-dir(rtl) {
   direction: rtl;
 }
 
 /* hide the content and destroy the frame */
--- a/toolkit/content/widgets/dialog.xml
+++ b/toolkit/content/widgets/dialog.xml
@@ -8,17 +8,17 @@
   %globalKeysDTD;
 ]>
 
 <bindings id="dialogBindings"
           xmlns="http://www.mozilla.org/xbl"
           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
           xmlns:xbl="http://www.mozilla.org/xbl">
 
-  <binding id="dialog" extends="chrome://global/content/bindings/general.xml#root-element">
+  <binding id="dialog">
     <resources>
       <stylesheet src="chrome://global/skin/dialog.css"/>
     </resources>
     <content>
       <xul:vbox class="box-inherit dialog-content-box" flex="1">
         <children/>
       </xul:vbox>
 
--- a/toolkit/content/widgets/general.xml
+++ b/toolkit/content/widgets/general.xml
@@ -52,35 +52,16 @@
           ]]>
         </setter>
       </property>
 
       <field name="labelElement"/>
     </implementation>      
   </binding>
 
-  <binding id="root-element">
-    <implementation>
-      <field name="_lightweightTheme">null</field>
-      <constructor><![CDATA[
-        if (this.hasAttribute("lightweightthemes")) {
-          let temp = {};
-          ChromeUtils.import("resource://gre/modules/LightweightThemeConsumer.jsm", temp);
-          this._lightweightTheme = new temp.LightweightThemeConsumer(this.ownerDocument);
-        }
-      ]]></constructor>
-      <destructor><![CDATA[
-        if (this._lightweightTheme) {
-          this._lightweightTheme.destroy();
-          this._lightweightTheme = null;
-        }
-      ]]></destructor>
-    </implementation>
-  </binding>
-
   <binding id="iframe" role="outerdoc">
     <implementation>
       <property name="docShell" readonly="true">
         <getter><![CDATA[
           let {frameLoader} = this;
           return frameLoader ? frameLoader.docShell : null;
         ]]></getter>
       </property>
--- a/toolkit/content/widgets/wizard.xml
+++ b/toolkit/content/widgets/wizard.xml
@@ -15,17 +15,17 @@
    xmlns:xbl="http://www.mozilla.org/xbl">
 
   <binding id="wizard-base">
     <resources>
       <stylesheet src="chrome://global/skin/wizard.css"/>
     </resources>
   </binding>
 
-  <binding id="wizard" extends="chrome://global/content/bindings/general.xml#root-element">
+  <binding id="wizard">
     <resources>
       <stylesheet src="chrome://global/skin/wizard.css"/>
     </resources>
     <content>
       <xul:hbox class="wizard-header" anonid="Header"/>
 
       <xul:deck class="wizard-page-box" flex="1" anonid="Deck">
         <children includes="wizardpage"/>
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -42,16 +42,17 @@ this.LightweightThemeConsumer =
   this._lastScreenHeight = screen.height;
 
   Services.obs.addObserver(this, "lightweight-theme-styling-update");
 
   var temp = {};
   ChromeUtils.import("resource://gre/modules/LightweightThemeManager.jsm", temp);
   this._update(temp.LightweightThemeManager.currentThemeForDisplay);
   this._win.addEventListener("resize", this);
+  this._win.addEventListener("unload", this.destroy.bind(this), { once: true });
 };
 
 LightweightThemeConsumer.prototype = {
   _lastData: null,
   _lastScreenWidth: null,
   _lastScreenHeight: null,
   // Whether the active lightweight theme should be shown on the window.
   _enabled: true,