Only include the renderer
-preference in builds where SVGGraphics
is defined
After PR 13117 it's now (finally) possible for *different* build targets to specify individual options/preferences, and we can utilize that to only expose the `renderer`-preference in builds where `SVGGraphics` is actually defined. Note that for e.g. `MOZCENTRAL`-builds, trying to enable SVG-rendering will throw immediately and the preference thus doesn't make sense to include there. Also, update the dummy `SVGGraphics` to use a class, tweak the `PDFJSDev`-check in `src/display/svg.js` to agree fully with the option/preference, and remove an unnecessary `eslint-disable`.
This commit is contained in:
parent
f07d50f8ee
commit
7548dc5ea2
@ -133,14 +133,6 @@
|
|||||||
"description": "Whether to prevent the extension from reporting the extension and browser version to the extension developers.",
|
"description": "Whether to prevent the extension from reporting the extension and browser version to the extension developers.",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"renderer": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"canvas",
|
|
||||||
"svg"
|
|
||||||
],
|
|
||||||
"default": "canvas"
|
|
||||||
},
|
|
||||||
"renderInteractiveForms": {
|
"renderInteractiveForms": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
isNum,
|
isNum,
|
||||||
OPS,
|
OPS,
|
||||||
TextRenderingMode,
|
TextRenderingMode,
|
||||||
|
unreachable,
|
||||||
Util,
|
Util,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
@ -29,11 +30,16 @@ import { DOMSVGFactory } from "./display_utils.js";
|
|||||||
import { isNodeJS } from "../shared/is_node.js";
|
import { isNodeJS } from "../shared/is_node.js";
|
||||||
|
|
||||||
/** @type {any} */
|
/** @type {any} */
|
||||||
let SVGGraphics = function () {
|
let SVGGraphics = class {
|
||||||
throw new Error("Not implemented: SVGGraphics");
|
constructor() {
|
||||||
|
unreachable("Not implemented: SVGGraphics");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
if (
|
||||||
|
typeof PDFJSDev === "undefined" ||
|
||||||
|
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||||
|
) {
|
||||||
const SVG_DEFAULTS = {
|
const SVG_DEFAULTS = {
|
||||||
fontStyle: "normal",
|
fontStyle: "normal",
|
||||||
fontWeight: "normal",
|
fontWeight: "normal",
|
||||||
@ -438,8 +444,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||||||
let maskCount = 0;
|
let maskCount = 0;
|
||||||
let shadingCount = 0;
|
let shadingCount = 0;
|
||||||
|
|
||||||
// eslint-disable-next-line no-shadow
|
SVGGraphics = class {
|
||||||
SVGGraphics = class SVGGraphics {
|
|
||||||
constructor(commonObjs, objs, forceDataSchema = false) {
|
constructor(commonObjs, objs, forceDataSchema = false) {
|
||||||
this.svgFactory = new DOMSVGFactory();
|
this.svgFactory = new DOMSVGFactory();
|
||||||
|
|
||||||
|
@ -52,9 +52,6 @@ const defaultOptions = {
|
|||||||
value: false,
|
value: false,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* The `disablePreferences` is, conditionally, defined below.
|
|
||||||
*/
|
|
||||||
enablePermissions: {
|
enablePermissions: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: false,
|
||||||
@ -95,9 +92,6 @@ const defaultOptions = {
|
|||||||
value: "./images/",
|
value: "./images/",
|
||||||
kind: OptionKind.VIEWER,
|
kind: OptionKind.VIEWER,
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* The `locale` is, conditionally, defined below.
|
|
||||||
*/
|
|
||||||
maxCanvasPixels: {
|
maxCanvasPixels: {
|
||||||
/** @type {number} */
|
/** @type {number} */
|
||||||
value: 16777216,
|
value: 16777216,
|
||||||
@ -117,7 +111,7 @@ const defaultOptions = {
|
|||||||
renderer: {
|
renderer: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: "canvas",
|
value: "canvas",
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER,
|
||||||
},
|
},
|
||||||
renderInteractiveForms: {
|
renderInteractiveForms: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
@ -265,6 +259,8 @@ if (
|
|||||||
: "../build/pdf.sandbox.js",
|
: "../build/pdf.sandbox.js",
|
||||||
kind: OptionKind.VIEWER,
|
kind: OptionKind.VIEWER,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultOptions.renderer.kind += OptionKind.PREFERENCE;
|
||||||
} else if (PDFJSDev.test("CHROME")) {
|
} else if (PDFJSDev.test("CHROME")) {
|
||||||
defaultOptions.disableTelemetry = {
|
defaultOptions.disableTelemetry = {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
|
Loading…
Reference in New Issue
Block a user