Bug 1438573 - Remove obsolete lightweight-theme-optimized notification. r?MattN draft
authorDão Gottwald <dao@mozilla.com>
Thu, 15 Feb 2018 18:03:25 +0100
changeset 755661 acf002e27f0535cd0effe9f11d981bc0086706f3
parent 755533 9b69cc60e5848f2f8802c911fd00771b50eed41f
push id99236
push userdgottwald@mozilla.com
push dateThu, 15 Feb 2018 17:04:04 +0000
reviewersMattN
bugs1438573
milestone60.0a1
Bug 1438573 - Remove obsolete lightweight-theme-optimized notification. r?MattN MozReview-Commit-ID: Fn1itKmbVU3
toolkit/modules/LightweightThemeConsumer.jsm
--- a/toolkit/modules/LightweightThemeConsumer.jsm
+++ b/toolkit/modules/LightweightThemeConsumer.jsm
@@ -15,33 +15,26 @@ ChromeUtils.import("resource:///modules/
 ChromeUtils.defineModuleGetter(this, "LightweightThemeImageOptimizer",
   "resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
 
 this.LightweightThemeConsumer =
  function LightweightThemeConsumer(aDocument) {
   this._doc = aDocument;
   this._win = aDocument.defaultView;
 
-  let screen = this._win.screen;
-  this._lastScreenWidth = screen.width;
-  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 });
+  this._win.addEventListener("unload", this, { once: true });
 };
 
 LightweightThemeConsumer.prototype = {
   _lastData: null,
-  _lastScreenWidth: null,
-  _lastScreenHeight: null,
   // Whether the active lightweight theme should be shown on the window.
   _enabled: true,
   // Whether a lightweight theme is enabled.
   _active: false,
 
   enable() {
     this._enabled = true;
     this._update(this._lastData);
@@ -71,37 +64,24 @@ LightweightThemeConsumer.prototype = {
     if (parsedData && parsedData.window && parsedData.window !== outerWindowID) {
       return;
     }
 
     this._update(parsedData);
   },
 
   handleEvent(aEvent) {
-    let {width, height} = this._win.screen;
-
-    if (this._lastScreenWidth != width || this._lastScreenHeight != height) {
-      this._lastScreenWidth = width;
-      this._lastScreenHeight = height;
-      if (!this._active)
-        return;
-      this._update(this._lastData);
-      Services.obs.notifyObservers(this._win, "lightweight-theme-optimized",
-                                   JSON.stringify(this._lastData));
+    switch (aEvent.type) {
+      case "unload":
+        Services.obs.removeObserver(this, "lightweight-theme-styling-update");
+        this._win = this._doc = null;
+        break;
     }
   },
 
-  destroy() {
-    Services.obs.removeObserver(this, "lightweight-theme-styling-update");
-
-    this._win.removeEventListener("resize", this);
-
-    this._win = this._doc = null;
-  },
-
   _update(aData) {
     if (!aData) {
       aData = { headerURL: "", footerURL: "", textcolor: "", accentcolor: "" };
       this._lastData = aData;
     } else {
       this._lastData = aData;
       aData = LightweightThemeImageOptimizer.optimize(aData, this._win.screen);
     }