mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
[Firefox] Fetch browser preferences/options together with the viewer preferences (bug 1862192)
Currently we *synchronously* fetch a number of browser preferences/options, from the platform code, during the viewer respectively PDF document initialization paths. This seems unnecessary, and we can re-factor the code to instead include the relevant data when fetching the regular viewer preferences.
This commit is contained in:
parent
50c0fccda6
commit
eebc230cf1
7 changed files with 109 additions and 81 deletions
|
@ -45,14 +45,25 @@ class BasePreferences {
|
|||
}
|
||||
|
||||
this.#initializedPromise = this._readFromStorage(this.#defaults).then(
|
||||
prefs => {
|
||||
({ browserPrefs, prefs }) => {
|
||||
const BROWSER_PREFS =
|
||||
typeof PDFJSDev === "undefined"
|
||||
? AppOptions.getAll(OptionKind.BROWSER)
|
||||
: PDFJSDev.eval("BROWSER_PREFERENCES");
|
||||
const options = Object.create(null);
|
||||
|
||||
for (const [name, defaultVal] of Object.entries(BROWSER_PREFS)) {
|
||||
const prefVal = browserPrefs?.[name];
|
||||
options[name] =
|
||||
typeof prefVal === typeof defaultVal ? prefVal : defaultVal;
|
||||
}
|
||||
for (const [name, defaultVal] of Object.entries(this.#defaults)) {
|
||||
const prefVal = prefs?.[name];
|
||||
// Ignore preferences whose types don't match the default values.
|
||||
this.#prefs[name] =
|
||||
options[name] = this.#prefs[name] =
|
||||
typeof prefVal === typeof defaultVal ? prefVal : defaultVal;
|
||||
}
|
||||
AppOptions.setAll(this.#prefs, /* init = */ true);
|
||||
AppOptions.setAll(options, /* init = */ true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue