mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Move the compatibilityParams
into the web/app_options.js
file
Given that we've over time been reducing the number of `compatibilityParams` in use, there's now few enough left that I think it makes sense to simply inline them directly in the `web/app_options.js` file. Note that we recently inlined/removed the separate `src/display/api_compatibility.js` file, see PR 13525, and that it (in my opinion) thus makes sense to do the same in the `web/`-folder. This patch will also slightly reduce the size of *built* `web/viewer.js` file, which cannot hurt.
This commit is contained in:
parent
7305b7464f
commit
6c95d0cb2c
7 changed files with 47 additions and 67 deletions
|
@ -13,7 +13,39 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||
const compatibilityParams = Object.create(null);
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
const userAgent =
|
||||
(typeof navigator !== "undefined" && navigator.userAgent) || "";
|
||||
const platform =
|
||||
(typeof navigator !== "undefined" && navigator.platform) || "";
|
||||
const maxTouchPoints =
|
||||
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;
|
||||
|
||||
const isAndroid = /Android/.test(userAgent);
|
||||
const isIOS =
|
||||
/\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) ||
|
||||
(platform === "MacIntel" && maxTouchPoints > 1);
|
||||
const isIOSChrome = /CriOS/.test(userAgent);
|
||||
|
||||
// Disables URL.createObjectURL() usage in some environments.
|
||||
// Support: Chrome on iOS
|
||||
(function checkOnBlobSupport() {
|
||||
// Sometimes Chrome on iOS loses data created with createObjectURL(),
|
||||
// see issue 8081.
|
||||
if (isIOSChrome) {
|
||||
compatibilityParams.disableCreateObjectURL = true;
|
||||
}
|
||||
})();
|
||||
|
||||
// Limit canvas size to 5 mega-pixels on mobile.
|
||||
// Support: Android, iOS
|
||||
(function checkCanvasSizeLimitation() {
|
||||
if (isIOS || isAndroid) {
|
||||
compatibilityParams.maxCanvasPixels = 5242880;
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
const OptionKind = {
|
||||
VIEWER: 0x02,
|
||||
|
@ -95,7 +127,7 @@ const defaultOptions = {
|
|||
maxCanvasPixels: {
|
||||
/** @type {number} */
|
||||
value: 16777216,
|
||||
compatibility: viewerCompatibilityParams.maxCanvasPixels,
|
||||
compatibility: compatibilityParams.maxCanvasPixels,
|
||||
kind: OptionKind.VIEWER,
|
||||
},
|
||||
pdfBugEnabled: {
|
||||
|
@ -348,4 +380,4 @@ class AppOptions {
|
|||
}
|
||||
}
|
||||
|
||||
export { AppOptions, OptionKind };
|
||||
export { AppOptions, compatibilityParams, OptionKind };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue