diff options
author | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2019-04-25 20:31:18 -0400 |
---|---|---|
committer | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2019-04-27 07:43:13 -0400 |
commit | 952e65590368931781327d1662061d46fa15ddd2 (patch) | |
tree | abd034f3cce0a3aaf216c2f1f83dc688e2d6e46f /toolkit/components/reader/Readerable.js | |
parent | 945b03265637bc8bf5bcd960909d1e8a4ddd5440 (diff) | |
download | UXP-952e65590368931781327d1662061d46fa15ddd2.tar UXP-952e65590368931781327d1662061d46fa15ddd2.tar.gz UXP-952e65590368931781327d1662061d46fa15ddd2.tar.lz UXP-952e65590368931781327d1662061d46fa15ddd2.tar.xz UXP-952e65590368931781327d1662061d46fa15ddd2.zip |
Replace explicit pref observer with lazy preference getters. Tag #361.
Diffstat (limited to 'toolkit/components/reader/Readerable.js')
-rw-r--r-- | toolkit/components/reader/Readerable.js | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/toolkit/components/reader/Readerable.js b/toolkit/components/reader/Readerable.js index 71c23eb5b..cee8adc08 100644 --- a/toolkit/components/reader/Readerable.js +++ b/toolkit/components/reader/Readerable.js @@ -23,30 +23,7 @@ var Readerable = { DEBUG: 0, get isEnabledForParseOnLoad() { - delete this.isEnabledForParseOnLoad; - - // Listen for future pref changes. - Services.prefs.addObserver("reader.parse-on-load.", this, false); - - return this.isEnabledForParseOnLoad = this._getStateForParseOnLoad(); - }, - - _getStateForParseOnLoad() { - let isEnabled = Services.prefs.getBoolPref("reader.parse-on-load.enabled"); - let isForceEnabled = Services.prefs.getBoolPref("reader.parse-on-load.force-enabled"); - return isForceEnabled || isEnabled; - }, - - observe(aMessage, aTopic, aData) { - switch (aTopic) { - case "nsPref:changed": - if (aData.startsWith("reader.parse-on-load.")) { - this.isEnabledForParseOnLoad = this._getStateForParseOnLoad(); - } else if (aData === "reader.parse-node-limit") { - this.parseNodeLimit = Services.prefs.getIntPref(aData); - } - break; - } + return this.isEnabled || this.isForceEnabled; }, log(msg) { @@ -112,3 +89,8 @@ var Readerable = { return true; }, }; + +XPCOMUtils.defineLazyPreferenceGetter( + Readerable, "isEnabled", "reader.parse-on-load.enabled", true); +XPCOMUtils.defineLazyPreferenceGetter( + Readerable, "isForceEnabled", "reader.parse-on-load.force-enabled", false); |