From cd181eb74632789a6c64b10d56b01ec5eddbaa04 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Mon, 21 Aug 2023 10:07:25 +0200 Subject: [PATCH] Exclude `lineEndings`, in Annotation-data, in MOZCENTRAL builds (PR 14899 follow-up) This was added in PR 14899, over a year ago, however it's still completely unused in the PDF.js library/viewer. In hindsight I think that it was a mistake to add unused functionality, and the issue should probably have been WONTFIXed instead, however we probably can't just remove it now. Thanks to the pre-processor, we can at least exclude this code in the *built-in* Firefox PDF Viewer. --- src/core/annotation.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/annotation.js b/src/core/annotation.js index 5674b1b75..f8e95574d 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -848,6 +848,9 @@ class Annotation { * @param {Array} lineEndings - The line endings array. */ setLineEndings(lineEndings) { + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { + throw new Error("Not implemented: setLineEndings"); + } this.lineEndings = ["None", "None"]; // The default values. if (Array.isArray(lineEndings) && lineEndings.length === 2) { @@ -3937,8 +3940,10 @@ class LineAnnotation extends MarkupAnnotation { const lineCoordinates = dict.getArray("L"); this.data.lineCoordinates = Util.normalizeRect(lineCoordinates); - this.setLineEndings(dict.getArray("LE")); - this.data.lineEndings = this.lineEndings; + if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { + this.setLineEndings(dict.getArray("LE")); + this.data.lineEndings = this.lineEndings; + } if (!this.appearance) { // The default stroke color is black. @@ -4112,7 +4117,10 @@ class PolylineAnnotation extends MarkupAnnotation { this.data.hasOwnCanvas = this.data.noRotate; this.data.vertices = []; - if (!(this instanceof PolygonAnnotation)) { + if ( + (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) && + !(this instanceof PolygonAnnotation) + ) { // Only meaningful for polyline annotations. this.setLineEndings(dict.getArray("LE")); this.data.lineEndings = this.lineEndings;