Merge pull request #16543 from Snuffleupagus/limit-more-to-GENERIC
Limit more code to GENERIC builds
This commit is contained in:
commit
a37f7d2477
@ -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);
|
||||
|
@ -21,41 +21,33 @@ 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 = {
|
||||
const SVG_DEFAULTS = {
|
||||
fontStyle: "normal",
|
||||
fontWeight: "normal",
|
||||
fillColor: "#000000",
|
||||
};
|
||||
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
||||
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
||||
const LINE_CAP_STYLES = ["butt", "round", "square"];
|
||||
const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
||||
};
|
||||
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
||||
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
||||
const LINE_CAP_STYLES = ["butt", "round", "square"];
|
||||
const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
||||
|
||||
const createObjectURL = function (
|
||||
const createObjectURL = function (
|
||||
data,
|
||||
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.
|
||||
@ -74,9 +66,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
|
||||
}
|
||||
return buffer;
|
||||
};
|
||||
};
|
||||
|
||||
const convertImgDataToPng = (function () {
|
||||
const convertImgDataToPng = (function () {
|
||||
const PNG_HEADER = new Uint8Array([
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
||||
]);
|
||||
@ -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);
|
||||
@ -317,9 +307,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
|
||||
return encode(imgData, kind, forceDataSchema, isMask);
|
||||
};
|
||||
})();
|
||||
})();
|
||||
|
||||
class SVGExtraState {
|
||||
class SVGExtraState {
|
||||
constructor() {
|
||||
this.fontSizeScale = 1;
|
||||
this.fontWeight = SVG_DEFAULTS.fontWeight;
|
||||
@ -376,10 +366,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
function opListToTree(opList) {
|
||||
function opListToTree(opList) {
|
||||
let opTree = [];
|
||||
const tmp = [];
|
||||
|
||||
@ -398,16 +387,15 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
}
|
||||
}
|
||||
return opTree;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Format a float number as a string.
|
||||
*
|
||||
* @param value {number} - The float number to format.
|
||||
* @returns {string}
|
||||
*/
|
||||
// eslint-disable-next-line no-inner-declarations
|
||||
function pf(value) {
|
||||
function pf(value) {
|
||||
if (Number.isInteger(value)) {
|
||||
return value.toString();
|
||||
}
|
||||
@ -422,9 +410,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
i--;
|
||||
} while (s[i] === "0");
|
||||
return s.substring(0, s[i] === "." ? i : i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Format a transform matrix as a string. The standard rotation, scale and
|
||||
* translation matrices are replaced by their shorter forms, and for
|
||||
* identity matrices an empty string is returned to save memory.
|
||||
@ -432,8 +420,7 @@ 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) {
|
||||
function pm(m) {
|
||||
if (m[4] === 0 && m[5] === 0) {
|
||||
if (m[1] === 0 && m[2] === 0) {
|
||||
if (m[0] === 1 && m[3] === 1) {
|
||||
@ -454,16 +441,16 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
`matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` +
|
||||
`${pf(m[5])})`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// The counts below are relevant for all pages, so they have to be global
|
||||
// instead of being members of `SVGGraphics` (which is recreated for
|
||||
// each page).
|
||||
let clipCount = 0;
|
||||
let maskCount = 0;
|
||||
let shadingCount = 0;
|
||||
// The counts below are relevant for all pages, so they have to be global
|
||||
// instead of being members of `SVGGraphics` (which is recreated for
|
||||
// each page).
|
||||
let clipCount = 0;
|
||||
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 };
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user