Merge pull request #15173 from Snuffleupagus/deprecated-svg

[api-minor] Deprecate the SVG back-end
This commit is contained in:
Tim van der Meij 2022-07-17 12:47:58 +02:00 committed by GitHub
commit 5bfba89b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 7 deletions

View File

@ -14,6 +14,7 @@
*/
/* globals __non_webpack_require__ */
import { deprecated, DOMSVGFactory } from "./display_utils.js";
import {
FONT_IDENTITY_MATRIX,
IDENTITY_MATRIX,
@ -24,7 +25,6 @@ import {
Util,
warn,
} from "../shared/util.js";
import { DOMSVGFactory } from "./display_utils.js";
import { isNodeJS } from "../shared/is_node.js";
/** @type {any} */
@ -467,6 +467,9 @@ if (
SVGGraphics = class {
constructor(commonObjs, objs, forceDataSchema = false) {
deprecated(
"The SVG back-end is no longer maintained and *may* be removed in the future."
);
this.svgFactory = new DOMSVGFactory();
this.current = new SVGExtraState();

View File

@ -1795,10 +1795,17 @@ const PDFViewerApplication = {
this.pdfViewer.cleanup();
this.pdfThumbnailViewer.cleanup();
// We don't want to remove fonts used by active page SVGs.
this.pdfDocument.cleanup(
/* keepLoadedFonts = */ this.pdfViewer.renderer === RendererType.SVG
);
if (
typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")
) {
// We don't want to remove fonts used by active page SVGs.
this.pdfDocument.cleanup(
/* keepLoadedFonts = */ this.pdfViewer.renderer === RendererType.SVG
);
} else {
this.pdfDocument.cleanup();
}
},
forceRendering() {

View File

@ -344,7 +344,11 @@ class PDFPageView {
}
this._resetZoomLayer();
}
if (this.svg) {
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
this.svg
) {
this.paintedViewportMap.delete(this.svg);
delete this.svg;
}
@ -380,7 +384,11 @@ class PDFPageView {
docStyle.setProperty("--scale-factor", this.viewport.scale);
}
if (this.svg) {
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
this.svg
) {
this.cssTransform({
target: this.svg,
redrawAnnotationLayer: true,
@ -733,6 +741,8 @@ class PDFPageView {
};
const paintTask =
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
this.renderer === RendererType.SVG
? this.paintOnSvg(canvasWrapper)
: this.paintOnCanvas(canvasWrapper);