summaryrefslogtreecommitdiffstats
path: root/toolkit/components/reader/AboutReader.jsm
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-06-01 21:58:35 +0000
committerMoonchild <moonchild@palemoon.org>2020-06-01 21:58:35 +0000
commitc6ca4380e9e5e95df9de02daf8bfb9a6ebc22810 (patch)
treec7672903a2030d37f861b12900165a015f49d10a /toolkit/components/reader/AboutReader.jsm
parent451509e2c0188a4164d4b3d1d9f5839ed1e95246 (diff)
parent744b044935f7d1d67fbe0df42d898efcbdd00536 (diff)
downloadUXP-c6ca4380e9e5e95df9de02daf8bfb9a6ebc22810.tar
UXP-c6ca4380e9e5e95df9de02daf8bfb9a6ebc22810.tar.gz
UXP-c6ca4380e9e5e95df9de02daf8bfb9a6ebc22810.tar.lz
UXP-c6ca4380e9e5e95df9de02daf8bfb9a6ebc22810.tar.xz
UXP-c6ca4380e9e5e95df9de02daf8bfb9a6ebc22810.zip
Merge remote-tracking branch 'origin/redwood' into release
Diffstat (limited to 'toolkit/components/reader/AboutReader.jsm')
-rw-r--r--toolkit/components/reader/AboutReader.jsm89
1 files changed, 2 insertions, 87 deletions
diff --git a/toolkit/components/reader/AboutReader.jsm b/toolkit/components/reader/AboutReader.jsm
index 9d9362a0c..3958af081 100644
--- a/toolkit/components/reader/AboutReader.jsm
+++ b/toolkit/components/reader/AboutReader.jsm
@@ -70,8 +70,6 @@ var AboutReader = function(win, articlePromise) {
Services.obs.addObserver(this, "inner-window-destroyed", false);
- doc.addEventListener("visibilitychange", this);
-
this._setupStyleDropdown();
this._setupButton("close-button", this._onReaderClose.bind(this), "aboutReader.toolbar.close");
@@ -238,14 +236,6 @@ AboutReader.prototype = {
}
break;
- case "devicelight":
- this._handleDeviceLight(aEvent.value);
- break;
-
- case "visibilitychange":
- this._handleVisibilityChange();
- break;
-
case "pagehide":
// Close the Banners Font-dropdown, cleanup Android BackPressListener.
this._closeDropdowns();
@@ -310,10 +300,6 @@ AboutReader.prototype = {
const FONT_SIZE_MIN = 1;
const FONT_SIZE_MAX = 9;
- // Sample text shown in Android UI.
- let sampleText = this._doc.querySelector(".font-size-sample");
- sampleText.textContent = gStrings.GetStringFromName("aboutReader.fontTypeSample");
-
let currentSize = Services.prefs.getIntPref("reader.font_size");
currentSize = Math.max(FONT_SIZE_MIN, Math.min(FONT_SIZE_MAX, currentSize));
@@ -503,77 +489,8 @@ AboutReader.prototype = {
}, true);
},
- _handleDeviceLight(newLux) {
- // Desired size of the this._luxValues array.
- let luxValuesSize = 10;
- // Add new lux value at the front of the array.
- this._luxValues.unshift(newLux);
- // Add new lux value to this._totalLux for averaging later.
- this._totalLux += newLux;
-
- // Don't update when length of array is less than luxValuesSize except when it is 1.
- if (this._luxValues.length < luxValuesSize) {
- // Use the first lux value to set the color scheme until our array equals luxValuesSize.
- if (this._luxValues.length == 1) {
- this._updateColorScheme(newLux);
- }
- return;
- }
- // Holds the average of the lux values collected in this._luxValues.
- let averageLuxValue = this._totalLux / luxValuesSize;
-
- this._updateColorScheme(averageLuxValue);
- // Pop the oldest value off the array.
- let oldLux = this._luxValues.pop();
- // Subtract oldLux since it has been discarded from the array.
- this._totalLux -= oldLux;
- },
-
- _handleVisibilityChange() {
- let colorScheme = Services.prefs.getCharPref("reader.color_scheme");
- if (colorScheme != "auto") {
- return;
- }
-
- // Turn off the ambient light sensor if the page is hidden
- this._enableAmbientLighting(!this._doc.hidden);
- },
-
- // Setup or teardown the ambient light tracking system.
- _enableAmbientLighting(enable) {
- if (enable) {
- this._win.addEventListener("devicelight", this);
- this._luxValues = [];
- this._totalLux = 0;
- } else {
- this._win.removeEventListener("devicelight", this);
- delete this._luxValues;
- delete this._totalLux;
- }
- },
-
- _updateColorScheme(luxValue) {
- // Upper bound value for "dark" color scheme beyond which it changes to "light".
- let upperBoundDark = 50;
- // Lower bound value for "light" color scheme beyond which it changes to "dark".
- let lowerBoundLight = 10;
- // Threshold for color scheme change.
- let colorChangeThreshold = 20;
-
- // Ignore changes that are within a certain threshold of previous lux values.
- if ((this._colorScheme === "dark" && luxValue < upperBoundDark) ||
- (this._colorScheme === "light" && luxValue > lowerBoundLight))
- return;
-
- if (luxValue < colorChangeThreshold)
- this._setColorScheme("dark");
- else
- this._setColorScheme("light");
- },
-
_setColorScheme(newColorScheme) {
- // "auto" is not a real color scheme
- if (this._colorScheme === newColorScheme || newColorScheme === "auto")
+ if (this._colorScheme === newColorScheme)
return;
let bodyClasses = this._doc.body.classList;
@@ -585,10 +502,8 @@ AboutReader.prototype = {
bodyClasses.add(this._colorScheme);
},
- // Pref values include "dark", "light", and "auto", which automatically switches
- // between light and dark color schemes based on the ambient light level.
+ // Pref values include "dark", "light", and "sepia".
_setColorSchemePref(colorSchemePref) {
- this._enableAmbientLighting(colorSchemePref === "auto");
this._setColorScheme(colorSchemePref);
AsyncPrefs.set("reader.color_scheme", colorSchemePref);