Bug 1438573 - Remove obsolete lightweight-theme-optimized notification. r=MattN
authorDão Gottwald <dao@mozilla.com>
Thu, 15 Feb 2018 18:03:25 +0100
changeset 459025 0e527d53161edc667ae1c708ba5beda9b666c73b
parent 459024 00c1b135cf04a90430d94abed4722b54b4e890d0
child 459026 3b06c176e18dee55b119dd4137e159782da68f5d
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN
bugs1438573
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);
     }