mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Change the compatibilityParams
, used with AppOptions, to a Map
This is needed for upcoming changes, and simplifies both checking if an entry exists and iteration of the entries.
This commit is contained in:
parent
e92a6a14ff
commit
57ee035573
1 changed files with 9 additions and 13 deletions
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
// eslint-disable-next-line no-var
|
// eslint-disable-next-line no-var
|
||||||
var compatibilityParams = Object.create(null);
|
var compatParams = new Map();
|
||||||
if (
|
if (
|
||||||
typeof PDFJSDev !== "undefined" &&
|
typeof PDFJSDev !== "undefined" &&
|
||||||
PDFJSDev.test("LIB") &&
|
PDFJSDev.test("LIB") &&
|
||||||
|
@ -34,9 +34,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
|
|
||||||
// Limit canvas size to 5 mega-pixels on mobile.
|
// Limit canvas size to 5 mega-pixels on mobile.
|
||||||
// Support: Android, iOS
|
// Support: Android, iOS
|
||||||
(function checkCanvasSizeLimitation() {
|
(function () {
|
||||||
if (isIOS || isAndroid) {
|
if (isIOS || isAndroid) {
|
||||||
compatibilityParams.maxCanvasPixels = 5242880;
|
compatParams.set("maxCanvasPixels", 5242880);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
@ -447,8 +447,8 @@ const userOptions = Object.create(null);
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
// Apply any compatibility-values to the user-options,
|
// Apply any compatibility-values to the user-options,
|
||||||
// see also `AppOptions.remove` below.
|
// see also `AppOptions.remove` below.
|
||||||
for (const name in compatibilityParams) {
|
for (const [name, value] of compatParams) {
|
||||||
userOptions[name] = compatibilityParams[name];
|
userOptions[name] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,10 +464,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING || LIB")) {
|
||||||
if (kind & OptionKind.BROWSER) {
|
if (kind & OptionKind.BROWSER) {
|
||||||
throw new Error(`Cannot mix "PREFERENCE" and "BROWSER" kind: ${name}`);
|
throw new Error(`Cannot mix "PREFERENCE" and "BROWSER" kind: ${name}`);
|
||||||
}
|
}
|
||||||
if (
|
if (typeof compatParams === "object" && compatParams.has(name)) {
|
||||||
typeof compatibilityParams === "object" &&
|
|
||||||
compatibilityParams[name] !== undefined
|
|
||||||
) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Should not have compatibility-value for "PREFERENCE" kind: ${name}`
|
`Should not have compatibility-value for "PREFERENCE" kind: ${name}`
|
||||||
);
|
);
|
||||||
|
@ -554,9 +551,8 @@ class AppOptions {
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
// Re-apply a compatibility-value, if it exists, to the user-options.
|
// Re-apply a compatibility-value, if it exists, to the user-options.
|
||||||
const val = compatibilityParams[name];
|
if (compatParams.has(name)) {
|
||||||
if (val !== undefined) {
|
userOptions[name] = compatParams.get(name);
|
||||||
userOptions[name] = val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -571,7 +567,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||||
}
|
}
|
||||||
for (const name in userOptions) {
|
for (const name in userOptions) {
|
||||||
// Ignore any compatibility-values in the user-options.
|
// Ignore any compatibility-values in the user-options.
|
||||||
if (compatibilityParams[name] !== undefined) {
|
if (compatParams.has(name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue