Bug 1438573 - Remove obsolete lightweight-theme-optimized notification. r?MattN
MozReview-Commit-ID: Fn1itKmbVU3
--- 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);
}