[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:
Jonas Jenwald 2023-10-31 11:39:04 +01:00
parent 50c0fccda6
commit eebc230cf1
7 changed files with 109 additions and 81 deletions

View file

@ -41,6 +41,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
}
const OptionKind = {
BROWSER: 0x01,
VIEWER: 0x02,
API: 0x04,
WORKER: 0x08,
@ -53,6 +54,42 @@ const OptionKind = {
* primitive types and cannot rely on any imported types.
*/
const defaultOptions = {
canvasMaxAreaInBytes: {
/** @type {number} */
value: -1,
kind: OptionKind.BROWSER,
},
isInAutomation: {
/** @type {boolean} */
value: false,
kind: OptionKind.BROWSER,
},
supportsDocumentFonts: {
/** @type {boolean} */
value: true,
kind: OptionKind.BROWSER,
},
supportsIntegratedFind: {
/** @type {boolean} */
value: false,
kind: OptionKind.BROWSER,
},
supportsMouseWheelZoomCtrlKey: {
/** @type {boolean} */
value: true,
kind: OptionKind.BROWSER,
},
supportsMouseWheelZoomMetaKey: {
/** @type {boolean} */
value: true,
kind: OptionKind.BROWSER,
},
supportsPinchToZoom: {
/** @type {boolean} */
value: true,
kind: OptionKind.BROWSER,
},
annotationEditorMode: {
/** @type {number} */
value: 0,
@ -367,6 +404,9 @@ class AppOptions {
continue;
}
if (kind === OptionKind.PREFERENCE) {
if (defaultOption.kind & OptionKind.BROWSER) {
throw new Error(`Invalid kind for preference: ${name}`);
}
const value = defaultOption.value,
valueType = typeof value;