Limit more SVG-specific code to the GENERIC viewer

Given that the SVG back-end is not defined anywhere except in GENERIC builds, we can remove a little bit more unnecessary code in e.g. the Firefox PDF Viewer.
This commit is contained in:
Jonas Jenwald 2022-07-16 10:31:25 +02:00
parent 90bf659b29
commit 290aeaf755
2 changed files with 23 additions and 6 deletions

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);