Bug 1446762 - Update the lwt header image on resolution change. r?MattN draft
authorDão Gottwald <dao@mozilla.com>
Fri, 20 Apr 2018 14:21:00 +0200
changeset 785605 2bd9df8e3b869c0b9717374965ead3b41a491e73
parent 785586 cc0d7de218cb0c260c8ba0cf6637845ad2222f49
push id107265
push userdgottwald@mozilla.com
push dateFri, 20 Apr 2018 12:21:31 +0000
reviewersMattN
bugs1446762, 1438573
milestone61.0a1
Bug 1446762 - Update the lwt header image on resolution change. r?MattN This was previously implemented using the resize event, and was wrongly removed in bug 1438573. MozReview-Commit-ID: ATZdPgoOGRF
toolkit/modules/LightweightThemeConsumer.jsm
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -57,16 +57,18 @@ function LightweightThemeConsumer(aDocum
   this._doc = aDocument;
   this._win = aDocument.defaultView;
 
   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("resolutionchange", this);
   this._win.addEventListener("unload", this, { once: true });
 }
 
 LightweightThemeConsumer.prototype = {
   _lastData: null,
   // Whether the active lightweight theme should be shown on the window.
   _enabled: true,
   // Whether a lightweight theme is enabled.
@@ -102,18 +104,24 @@ LightweightThemeConsumer.prototype = {
       return;
     }
 
     this._update(parsedData);
   },
 
   handleEvent(aEvent) {
     switch (aEvent.type) {
+      case "resolutionchange":
+        if (this._active) {
+          this._update(this._lastData);
+        }
+        break;
       case "unload":
         Services.obs.removeObserver(this, "lightweight-theme-styling-update");
+        this._win.removeEventListener("resolutionchange", this);
         this._win = this._doc = null;
         break;
     }
   },
 
   _update(aData) {
     if (!aData) {
       aData = { headerURL: "", footerURL: "", textcolor: "", accentcolor: "" };