Merge pull request #16543 from Snuffleupagus/limit-more-to-GENERIC

Limit more code to GENERIC builds
This commit is contained in:
Jonas Jenwald 2023-06-15 13:58:52 +02:00 committed by GitHub
commit a37f7d2477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1614 additions and 1640 deletions

View File

@ -1552,6 +1552,9 @@ class PDFPageProxy {
annotationMode = AnnotationMode.ENABLE,
printAnnotationStorage = null,
} = {}) {
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
throw new Error("Not implemented: getOperatorList");
}
function operatorListChanged() {
if (intentState.operatorList.lastChunk) {
intentState.opListReadCapability.resolve(intentState.operatorList);

View File

@ -21,21 +21,17 @@ import {
ImageKind,
OPS,
TextRenderingMode,
unreachable,
Util,
warn,
} from "../shared/util.js";
import { isNodeJS } from "../shared/is_node.js";
/** @type {any} */
// eslint-disable-next-line import/no-mutable-exports
let SVGGraphics = class {
constructor() {
unreachable("Not implemented: SVGGraphics");
if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("GENERIC")) {
throw new Error(
'Module "SVGGraphics" shall not be used outside GENERIC builds.'
);
}
};
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
const SVG_DEFAULTS = {
fontStyle: "normal",
fontWeight: "normal",
@ -51,11 +47,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
contentType = "",
forceDataSchema = false
) {
if (
URL.createObjectURL &&
typeof Blob !== "undefined" &&
!forceDataSchema
) {
if (URL.createObjectURL && typeof Blob !== "undefined" && !forceDataSchema) {
return URL.createObjectURL(new Blob([data], { type: contentType }));
}
// Blob/createObjectURL is not available, falling back to data schema.
@ -177,9 +169,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
});
return output instanceof Uint8Array ? output : new Uint8Array(output);
} catch (e) {
warn(
"Not compressing PNG because zlib.deflateSync is unavailable: " + e
);
warn("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
}
return deflateSyncUncompressed(literals);
@ -378,7 +368,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
}
}
// eslint-disable-next-line no-inner-declarations
function opListToTree(opList) {
let opTree = [];
const tmp = [];
@ -406,7 +395,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
* @param value {number} - The float number to format.
* @returns {string}
*/
// eslint-disable-next-line no-inner-declarations
function pf(value) {
if (Number.isInteger(value)) {
return value.toString();
@ -432,7 +420,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
* @param m {Array} - The transform matrix to format.
* @returns {string}
*/
// eslint-disable-next-line no-inner-declarations
function pm(m) {
if (m[4] === 0 && m[5] === 0) {
if (m[1] === 0 && m[2] === 0) {
@ -463,7 +450,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
let maskCount = 0;
let shadingCount = 0;
SVGGraphics = class {
class SVGGraphics {
constructor(commonObjs, objs, forceDataSchema = false) {
deprecated(
"The SVG back-end is no longer maintained and *may* be removed in the future."
@ -731,14 +718,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this.nextLine();
break;
case OPS.transform:
this.transform(
args[0],
args[1],
args[2],
args[3],
args[4],
args[5]
);
this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
break;
case OPS.constructPath:
this.constructPath(args[0], args[1]);
@ -892,11 +872,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
x += charWidth;
}
current.tspan.setAttributeNS(
null,
"x",
current.xcoords.map(pf).join(" ")
);
current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
if (vertical) {
current.tspan.setAttributeNS(
null,
@ -1328,15 +1304,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
case OPS.curveTo3:
x = args[j + 2];
y = args[j + 3];
d.push(
"C",
pf(args[j]),
pf(args[j + 1]),
pf(x),
pf(y),
pf(x),
pf(y)
);
d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
j += 4;
break;
case OPS.closePath:
@ -1741,7 +1709,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
}
return this.tgrp;
}
};
}
export { SVGGraphics };

View File

@ -69,7 +69,6 @@ import { AnnotationEditorLayer } from "./display/editor/annotation_editor_layer.
import { AnnotationEditorUIManager } from "./display/editor/tools.js";
import { AnnotationLayer } from "./display/annotation_layer.js";
import { GlobalWorkerOptions } from "./display/worker_options.js";
import { SVGGraphics } from "./display/svg.js";
import { XfaLayer } from "./display/xfa_layer.js";
/* eslint-disable-next-line no-unused-vars */
@ -79,6 +78,11 @@ const pdfjsVersion =
const pdfjsBuild =
typeof PDFJSDev !== "undefined" ? PDFJSDev.eval("BUNDLE_BUILD") : void 0;
const SVGGraphics =
typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")
? require("./display/svg.js").SVGGraphics
: null;
export {
AbortException,
AnnotationEditorLayer,