diff --git a/toolkit/components/pdfjs/README.mozilla b/toolkit/components/pdfjs/README.mozilla --- a/toolkit/components/pdfjs/README.mozilla +++ b/toolkit/components/pdfjs/README.mozilla @@ -1,5 +1,5 @@ This is the PDF.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 2.14.13 +Current extension version is: 2.14.110 -Taken from upstream commit: 234aa9a50 +Taken from upstream commit: 0dd6bc9a8 diff --git a/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm b/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm --- a/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm +++ b/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm @@ -1,6 +1,6 @@ -/* Copyright 2021 Mozilla Foundation +/* Copyright 2022 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * diff --git a/toolkit/components/pdfjs/content/build/pdf.js b/toolkit/components/pdfjs/content/build/pdf.js --- a/toolkit/components/pdfjs/content/build/pdf.js +++ b/toolkit/components/pdfjs/content/build/pdf.js @@ -54,11 +54,10 @@ exports.getVerbosityLevel = getVerbosityLevel; exports.info = info; exports.isArrayBuffer = isArrayBuffer; exports.isArrayEqual = isArrayEqual; exports.isAscii = isAscii; -exports.isSameOrigin = isSameOrigin; exports.objectFromMap = objectFromMap; exports.objectSize = objectSize; exports.setVerbosityLevel = setVerbosityLevel; exports.shadow = shadow; exports.string32 = string32; @@ -444,27 +443,10 @@ if (!cond) { unreachable(msg); } } -function isSameOrigin(baseUrl, otherUrl) { - let base; - - try { - base = new URL(baseUrl); - - if (!base.origin || base.origin === "null") { - return false; - } - } catch (e) { - return false; - } - - const other = new URL(otherUrl, base); - return base.origin === other.origin; -} - function _isValidProtocol(url) { if (!url) { return false; } @@ -1058,11 +1040,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.build = exports.RenderTask = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDocumentLoadingTask = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultStandardFontDataFactory = exports.DefaultCanvasFactory = exports.DefaultCMapReaderFactory = void 0; +exports.build = exports.RenderTask = exports.PDFWorkerUtil = exports.PDFWorker = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFDocumentLoadingTask = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.DefaultStandardFontDataFactory = exports.DefaultCanvasFactory = exports.DefaultCMapReaderFactory = void 0; exports.getDocument = getDocument; exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory; exports.version = void 0; var _util = __w_pdfjs_require__(1); @@ -1181,26 +1163,37 @@ } params[key] = value; } - params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; params.CMapReaderFactory = params.CMapReaderFactory || DefaultCMapReaderFactory; params.StandardFontDataFactory = params.StandardFontDataFactory || DefaultStandardFontDataFactory; params.ignoreErrors = params.stopAtErrors !== true; params.fontExtraProperties = params.fontExtraProperties === true; params.pdfBug = params.pdfBug === true; params.enableXfa = params.enableXfa === true; + if (!Number.isInteger(params.rangeChunkSize) || params.rangeChunkSize < 1) { + params.rangeChunkSize = DEFAULT_RANGE_CHUNK_SIZE; + } + if (typeof params.docBaseUrl !== "string" || (0, _display_utils.isDataScheme)(params.docBaseUrl)) { params.docBaseUrl = null; } - if (!Number.isInteger(params.maxImageSize)) { + if (!Number.isInteger(params.maxImageSize) || params.maxImageSize < -1) { params.maxImageSize = -1; } + if (typeof params.cMapUrl !== "string") { + params.cMapUrl = null; + } + + if (typeof params.standardFontDataUrl !== "string") { + params.standardFontDataUrl = null; + } + if (typeof params.useWorkerFetch !== "boolean") { params.useWorkerFetch = params.CMapReaderFactory === _display_utils.DOMCMapReaderFactory && params.StandardFontDataFactory === _display_utils.DOMStandardFontDataFactory; } if (typeof params.isEvalSupported !== "boolean") { @@ -1213,11 +1206,11 @@ if (typeof params.useSystemFonts !== "boolean") { params.useSystemFonts = !params.disableFontFace; } - if (typeof params.ownerDocument === "undefined") { + if (typeof params.ownerDocument !== "object" || params.ownerDocument === null) { params.ownerDocument = globalThis.document; } if (typeof params.disableRange !== "boolean") { params.disableRange = false; @@ -1302,11 +1295,11 @@ source.contentDispositionFilename = pdfDataRangeTransport.contentDispositionFilename; } const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", { docId, - apiVersion: '2.14.13', + apiVersion: '2.14.110', source: { data: source.data, url: source.url, password: source.password, disableAutoFetch: source.disableAutoFetch, @@ -1331,21 +1324,17 @@ return workerId; } class PDFDocumentLoadingTask { - static get idCounters() { - return (0, _util.shadow)(this, "idCounters", { - doc: 0 - }); - } + static #docId = 0; constructor() { this._capability = (0, _util.createPromiseCapability)(); this._transport = null; this._worker = null; - this.docId = `d${PDFDocumentLoadingTask.idCounters.doc++}`; + this.docId = `d${PDFDocumentLoadingTask.#docId++}`; this.destroyed = false; this.onPassword = null; this.onProgress = null; this.onUnsupportedFeature = null; } @@ -2143,23 +2132,22 @@ const PDFWorkerUtil = { isWorkerDisabled: false, fallbackWorkerSrc: null, fakeWorkerId: 0 }; +exports.PDFWorkerUtil = PDFWorkerUtil; ; class PDFWorker { - static get _workerPorts() { - return (0, _util.shadow)(this, "_workerPorts", new WeakMap()); - } + static #workerPorts = new WeakMap(); constructor({ name = null, port = null, verbosity = (0, _util.getVerbosityLevel)() } = {}) { - if (port && PDFWorker._workerPorts.has(port)) { + if (port && PDFWorker.#workerPorts.has(port)) { throw new Error("Cannot use more than one PDFWorker per port."); } this.name = name; this.destroyed = false; @@ -2168,11 +2156,11 @@ this._port = null; this._webWorker = null; this._messageHandler = null; if (port) { - PDFWorker._workerPorts.set(port, this); + PDFWorker.#workerPorts.set(port, this); this._initializeFromPort(port); return; } @@ -2267,19 +2255,12 @@ this._setupFakeWorker(); } }); const sendTest = () => { - const testObj = new Uint8Array([255]); - - try { - messageHandler.send("test", testObj, [testObj.buffer]); - } catch (ex) { - (0, _util.warn)("Cannot use postMessage transfers."); - testObj[0] = 0; - messageHandler.send("test", testObj); - } + const testObj = new Uint8Array(); + messageHandler.send("test", testObj, [testObj.buffer]); }; sendTest(); return; } catch (e) { @@ -2328,12 +2309,11 @@ this._webWorker.terminate(); this._webWorker = null; } - PDFWorker._workerPorts.delete(this._port); - + PDFWorker.#workerPorts.delete(this._port); this._port = null; if (this._messageHandler) { this._messageHandler.destroy(); @@ -2344,12 +2324,12 @@ static fromPort(params) { if (!params?.port) { throw new Error("PDFWorker.fromPort - invalid method signature."); } - if (this._workerPorts.has(params.port)) { - return this._workerPorts.get(params.port); + if (this.#workerPorts.has(params.port)) { + return this.#workerPorts.get(params.port); } return new PDFWorker(params); } @@ -3136,13 +3116,11 @@ } exports.RenderTask = RenderTask; class InternalRenderTask { - static get canvasInUse() { - return (0, _util.shadow)(this, "canvasInUse", new WeakSet()); - } + static #canvasInUse = new WeakSet(); constructor({ callback, params, objs, @@ -3189,15 +3167,15 @@ if (this.cancelled) { return; } if (this._canvas) { - if (InternalRenderTask.canvasInUse.has(this._canvas)) { + if (InternalRenderTask.#canvasInUse.has(this._canvas)) { throw new Error("Cannot use the same canvas during multiple render() operations. " + "Use different canvas or ensure previous operations were " + "cancelled or completed."); } - InternalRenderTask.canvasInUse.add(this._canvas); + InternalRenderTask.#canvasInUse.add(this._canvas); } if (this._pdfBug && globalThis.StepperManager?.enabled) { this.stepper = globalThis.StepperManager.create(this._pageIndex); this.stepper.init(this.operatorList); @@ -3233,11 +3211,11 @@ if (this.gfx) { this.gfx.endDrawing(); } if (this._canvas) { - InternalRenderTask.canvasInUse.delete(this._canvas); + InternalRenderTask.#canvasInUse.delete(this._canvas); } this.callback(error || new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex + 1}`, "canvas")); } @@ -3297,23 +3275,23 @@ if (this.operatorList.lastChunk) { this.gfx.endDrawing(); if (this._canvas) { - InternalRenderTask.canvasInUse.delete(this._canvas); + InternalRenderTask.#canvasInUse.delete(this._canvas); } this.callback(); } } } } -const version = '2.14.13'; +const version = '2.14.110'; exports.version = version; -const build = '234aa9a50'; +const build = '0dd6bc9a8'; exports.build = build; /***/ }), /* 5 */ /***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => { @@ -9207,11 +9185,11 @@ linkService } = this; const link = document.createElement("a"); if (data.url) { - linkService.addLinkAttributes?.(link, data.url, data.newWindow); + linkService.addLinkAttributes(link, data.url, data.newWindow); } else if (data.action) { this._bindNamedAction(link, data.action); } else if (data.dest) { this._bindLink(link, data.dest); } else { @@ -11100,12 +11078,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.XfaLayer = void 0; -var _util = __w_pdfjs_require__(1); - var _xfa_text = __w_pdfjs_require__(17); class XfaLayer { static setupStorage(html, id, element, storage, intent) { const storedData = storage.getValue(id, { @@ -11223,11 +11199,11 @@ Object.assign(html.style, value); } } if (isHTMLAnchorElement) { - linkService.addLinkAttributes?.(html, attributes.href, attributes.newWindow); + linkService.addLinkAttributes(html, attributes.href, attributes.newWindow); } if (storage && attributes.dataId) { this.setupStorage(html, attributes.dataId, element, storage); } @@ -12401,14 +12377,14 @@ var _svg = __w_pdfjs_require__(22); var _xfa_layer = __w_pdfjs_require__(20); -const pdfjsVersion = '2.14.13'; -const pdfjsBuild = '234aa9a50'; +const pdfjsVersion = '2.14.110'; +const pdfjsBuild = '0dd6bc9a8'; ; })(); /******/ return __webpack_exports__; /******/ })() ; }); \ No newline at end of file diff --git a/toolkit/components/pdfjs/content/build/pdf.sandbox.external.js b/toolkit/components/pdfjs/content/build/pdf.sandbox.external.js --- a/toolkit/components/pdfjs/content/build/pdf.sandbox.external.js +++ b/toolkit/components/pdfjs/content/build/pdf.sandbox.external.js @@ -1,6 +1,6 @@ -/* Copyright 2021 Mozilla Foundation +/* Copyright 2022 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * diff --git a/toolkit/components/pdfjs/content/build/pdf.scripting.js b/toolkit/components/pdfjs/content/build/pdf.scripting.js --- a/toolkit/components/pdfjs/content/build/pdf.scripting.js +++ b/toolkit/components/pdfjs/content/build/pdf.scripting.js @@ -1398,21 +1398,27 @@ _mkTargetName(event) { return event.target ? `[ ${event.target.name} ]` : ""; } _parseDate(cFormat, cDate) { - const ddate = Date.parse(cDate); - - if (isNaN(ddate)) { - try { - return this._util.scand(cFormat, cDate); - } catch (error) { - return null; + let date = null; + + try { + date = this._util.scand(cFormat, cDate); + } catch (error) {} + + if (!date) { + date = Date.parse(cDate); + + if (isNaN(date)) { + date = null; + } else { + date = new Date(date); } - } else { - return new Date(ddate); - } + } + + return date; } AFMergeChange(event = globalThis.event) { if (event.willCommit) { return event.value.toString(); @@ -4697,10 +4703,14 @@ return buf.join(""); } scand(cFormat, cDate) { + if (typeof cDate !== "string") { + return new Date(cDate); + } + if (cDate === "") { return new Date(); } switch (cFormat) { @@ -4855,20 +4865,20 @@ this._scandCache.set(cFormat, [re, actions]); } const [re, actions] = this._scandCache.get(cFormat); - const matches = new RegExp(re, "g").exec(cDate); + const matches = new RegExp(`^${re}$`, "g").exec(cDate); if (!matches || matches.length !== actions.length + 1) { return null; } const data = { - year: 0, + year: 2000, month: 0, - day: 0, + day: 1, hours: 0, minutes: 0, seconds: 0, am: null }; @@ -4935,13 +4945,13 @@ } })); var _initialization = __w_pdfjs_require__(1); -const pdfjsVersion = '2.14.13'; -const pdfjsBuild = '234aa9a50'; +const pdfjsVersion = '2.14.110'; +const pdfjsBuild = '0dd6bc9a8'; })(); /******/ return __webpack_exports__; /******/ })() ; }); \ No newline at end of file diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.js b/toolkit/components/pdfjs/content/build/pdf.worker.js --- a/toolkit/components/pdfjs/content/build/pdf.worker.js +++ b/toolkit/components/pdfjs/content/build/pdf.worker.js @@ -98,11 +98,11 @@ if (testMessageProcessed) { return; } testMessageProcessed = true; - handler.send("test", data instanceof Uint8Array && data[0] === 255); + handler.send("test", data instanceof Uint8Array); }); handler.on("configure", function wphConfigure(data) { (0, _util.setVerbosityLevel)(data.verbosity); }); handler.on("GetDocRequest", function wphSetupDoc(data) { @@ -115,11 +115,11 @@ let terminated = false; let cancelXHRs = null; const WorkerTasks = []; const verbosity = (0, _util.getVerbosityLevel)(); const apiVersion = docParams.apiVersion; - const workerVersion = '2.14.13'; + const workerVersion = '2.14.110'; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); } @@ -711,11 +711,10 @@ exports.getVerbosityLevel = getVerbosityLevel; exports.info = info; exports.isArrayBuffer = isArrayBuffer; exports.isArrayEqual = isArrayEqual; exports.isAscii = isAscii; -exports.isSameOrigin = isSameOrigin; exports.objectFromMap = objectFromMap; exports.objectSize = objectSize; exports.setVerbosityLevel = setVerbosityLevel; exports.shadow = shadow; exports.string32 = string32; @@ -1101,27 +1100,10 @@ if (!cond) { unreachable(msg); } } -function isSameOrigin(baseUrl, otherUrl) { - let base; - - try { - base = new URL(baseUrl); - - if (!base.origin || base.origin === "null") { - return false; - } - } catch (e) { - return false; - } - - const other = new URL(otherUrl, base); - return base.origin === other.origin; -} - function _isValidProtocol(url) { if (!url) { return false; } @@ -2005,14 +1987,12 @@ remove(ref) { this._set.delete(ref.toString()); } - forEach(callback) { - for (const ref of this._set.values()) { - callback(ref); - } + [Symbol.iterator]() { + return this._set.values(); } clear() { this._set.clear(); } @@ -2044,14 +2024,12 @@ putAlias(ref, aliasRef) { this._map.set(ref.toString(), this.get(aliasRef)); } - forEach(callback) { - for (const value of this._map.values()) { - callback(value); - } + [Symbol.iterator]() { + return this._map.values(); } clear() { this._map.clear(); } @@ -3602,12 +3580,10 @@ var _primitives = __w_pdfjs_require__(5); var _xfa_fonts = __w_pdfjs_require__(12); -var _stream = __w_pdfjs_require__(10); - var _annotation = __w_pdfjs_require__(22); var _base_stream = __w_pdfjs_require__(9); var _crypto = __w_pdfjs_require__(73); @@ -3616,10 +3592,12 @@ var _cleanup_helper = __w_pdfjs_require__(66); var _parser = __w_pdfjs_require__(27); +var _stream = __w_pdfjs_require__(10); + var _object_loader = __w_pdfjs_require__(71); var _operator_list = __w_pdfjs_require__(62); var _evaluator = __w_pdfjs_require__(25); @@ -4090,21 +4068,11 @@ return false; } class PDFDocument { - constructor(pdfManager, arg) { - let stream; - - if (arg instanceof _base_stream.BaseStream) { - stream = arg; - } else if ((0, _util.isArrayBuffer)(arg)) { - stream = new _stream.Stream(arg); - } else { - throw new Error("PDFDocument: Unknown argument type"); - } - + constructor(pdfManager, stream) { if (stream.length <= 0) { throw new _util.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes."); } this.pdfManager = pdfManager; @@ -10233,13 +10201,14 @@ processed.put(xResources.objId); } } } - processed.forEach(ref => { + for (const ref of processed) { nonBlendModesSet.put(ref); - }); + } + return false; } async fetchBuiltInCMap(name) { const cachedData = this.builtInCMapCache.get(name); @@ -10431,12 +10400,18 @@ } const maxImageSize = this.options.maxImageSize; if (maxImageSize !== -1 && w * h > maxImageSize) { - (0, _util.warn)("Image exceeded maximum allowed size and was removed."); - return; + const msg = "Image exceeded maximum allowed size and was removed."; + + if (this.options.ignoreErrors) { + (0, _util.warn)(msg); + return; + } + + throw new Error(msg); } let optionalContent; if (dict.has("OC")) { @@ -11823,15 +11798,33 @@ textAdvanceScale: 0, spaceInFlowMin: 0, spaceInFlowMax: 0, trackingSpaceMin: Infinity, negativeSpaceMax: -Infinity, + notASpace: -Infinity, transform: null, fontName: null, hasEOL: false }; + const twoLastChars = [" ", " "]; + let twoLastCharsPos = 0; + + function saveLastChar(char) { + const nextPos = (twoLastCharsPos + 1) % 2; + const ret = twoLastChars[twoLastCharsPos] !== " " && twoLastChars[nextPos] === " "; + twoLastChars[twoLastCharsPos] = char; + twoLastCharsPos = nextPos; + return ret; + } + + function resetLastChars() { + twoLastChars[0] = twoLastChars[1] = " "; + twoLastCharsPos = 0; + } + const TRACKING_SPACE_FACTOR = 0.1; + const NOT_A_SPACE_FACTOR = 0.03; const NEGATIVE_SPACE_FACTOR = -0.2; const SPACE_IN_FLOW_MIN_FACTOR = 0.1; const SPACE_IN_FLOW_MAX_FACTOR = 0.6; const self = this; const xref = this.xref; @@ -11890,10 +11883,11 @@ const scaleLineX = Math.hypot(textState.textLineMatrix[0], textState.textLineMatrix[1]); const scaleCtmX = Math.hypot(textState.ctm[0], textState.ctm[1]); textContentItem.textAdvanceScale = scaleCtmX * scaleLineX; textContentItem.trackingSpaceMin = textState.fontSize * TRACKING_SPACE_FACTOR; + textContentItem.notASpace = textState.fontSize * NOT_A_SPACE_FACTOR; textContentItem.negativeSpaceMax = textState.fontSize * NEGATIVE_SPACE_FACTOR; textContentItem.spaceInFlowMin = textState.fontSize * SPACE_IN_FLOW_MIN_FACTOR; textContentItem.spaceInFlowMax = textState.fontSize * SPACE_IN_FLOW_MAX_FACTOR; textContentItem.hasEOL = false; textContentItem.initialized = true; @@ -12020,23 +12014,29 @@ if (Math.abs(advanceX) > 0.5 * textContentItem.width) { appendEOL(); return true; } + resetLastChars(); flushTextContentItem(); return true; } if (Math.abs(advanceX) > textContentItem.width) { appendEOL(); return true; } + if (advanceY <= textOrientation * textContentItem.notASpace) { + resetLastChars(); + } + if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) { textContentItem.height += advanceY; } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) { if (textContentItem.str.length === 0) { + resetLastChars(); textContent.items.push({ str: " ", dir: "ltr", width: 0, height: Math.abs(advanceY), @@ -12060,23 +12060,29 @@ if (Math.abs(advanceY) > 0.5 * textContentItem.height) { appendEOL(); return true; } + resetLastChars(); flushTextContentItem(); return true; } if (Math.abs(advanceY) > textContentItem.height) { appendEOL(); return true; } + if (advanceX <= textOrientation * textContentItem.notASpace) { + resetLastChars(); + } + if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) { textContentItem.width += advanceX; } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) { if (textContentItem.str.length === 0) { + resetLastChars(); textContent.items.push({ str: " ", dir: "ltr", width: Math.abs(advanceX), height: 0, @@ -12129,19 +12135,20 @@ glyphWidth = glyph.vmetric ? glyph.vmetric[0] : -glyphWidth; } let scaledDim = glyphWidth * scale; - if (glyph.isWhitespace && (i === 0 || i + 1 === ii || glyphs[i - 1].isWhitespace || glyphs[i + 1].isWhitespace || extraSpacing)) { + if (glyph.isWhitespace) { if (!font.vertical) { charSpacing += scaledDim + textState.wordSpacing; textState.translateTextMatrix(charSpacing * textState.textHScale, 0); } else { charSpacing += -scaledDim + textState.wordSpacing; textState.translateTextMatrix(0, -charSpacing); } + saveLastChar(" "); continue; } if (!compareWithLastPosition()) { continue; @@ -12165,18 +12172,19 @@ if (scaledDim) { textChunk.prevTransform = getCurrentTextTransform(); } - if (glyph.isWhitespace) { + let glyphUnicode = glyph.unicode; + glyphUnicode = NormalizedUnicodes[glyphUnicode] || glyphUnicode; + glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode); + + if (saveLastChar(glyphUnicode)) { textChunk.str.push(" "); - } else { - let glyphUnicode = glyph.unicode; - glyphUnicode = NormalizedUnicodes[glyphUnicode] || glyphUnicode; - glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode); - textChunk.str.push(glyphUnicode); - } + } + + textChunk.str.push(glyphUnicode); if (charSpacing) { if (!font.vertical) { textState.translateTextMatrix(charSpacing * textState.textHScale, 0); } else { @@ -12185,10 +12193,12 @@ } } } function appendEOL() { + resetLastChars(); + if (textContentItem.initialized) { textContentItem.hasEOL = true; flushTextContentItem(); } else { textContent.items.push({ @@ -12204,10 +12214,11 @@ } function addFakeSpaces(width, transf, textOrientation) { if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) { if (textContentItem.initialized) { + resetLastChars(); textContentItem.str.push(" "); } return false; } @@ -12219,10 +12230,11 @@ height = width; width = 0; } flushTextContentItem(); + resetLastChars(); textContent.items.push({ str: " ", dir: "ltr", width: Math.abs(width), height: Math.abs(height), @@ -26571,10 +26583,31 @@ } locaEntries.sort((a, b) => { return a.index - b.index; }); + + for (i = 0; i < numGlyphs; i++) { + const { + offset, + endOffset + } = locaEntries[i]; + + if (offset !== 0 || endOffset !== 0) { + break; + } + + const nextOffset = locaEntries[i + 1].offset; + + if (nextOffset === 0) { + continue; + } + + locaEntries[i].endOffset = nextOffset; + break; + } + const missingGlyphs = Object.create(null); let writeOffset = 0; itemEncode(locaData, 0, writeOffset); for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) { @@ -39392,13 +39425,13 @@ } get _byteSize() { let byteSize = 0; - this._imageCache.forEach(imageData => { + for (const imageData of this._imageCache) { byteSize += imageData.byteSize; - }); + } return byteSize; } get _cacheLimitReached() { @@ -42375,46 +42408,38 @@ } return (0, _util.shadow)(this, "jsActions", actions); } - fontFallback(id, handler) { - const promises = []; - this.fontCache.forEach(function (promise) { - promises.push(promise); - }); - return Promise.all(promises).then(translatedFonts => { - for (const translatedFont of translatedFonts) { - if (translatedFont.loadedName === id) { - translatedFont.fallback(handler); - return; - } - } - }); - } - - cleanup(manuallyTriggered = false) { + async fontFallback(id, handler) { + const translatedFonts = await Promise.all(this.fontCache); + + for (const translatedFont of translatedFonts) { + if (translatedFont.loadedName === id) { + translatedFont.fallback(handler); + return; + } + } + } + + async cleanup(manuallyTriggered = false) { (0, _cleanup_helper.clearGlobalCaches)(); this.globalImageCache.clear(manuallyTriggered); this.pageKidsCountCache.clear(); this.pageIndexCache.clear(); this.nonBlendModesSet.clear(); - const promises = []; - this.fontCache.forEach(function (promise) { - promises.push(promise); - }); - return Promise.all(promises).then(translatedFonts => { - for (const { - dict - } of translatedFonts) { - delete dict.cacheKey; - } - - this.fontCache.clear(); - this.builtInCMapCache.clear(); - this.standardFontDataCache.clear(); - }); + const translatedFonts = await Promise.all(this.fontCache); + + for (const { + dict + } of translatedFonts) { + delete dict.cacheKey; + } + + this.fontCache.clear(); + this.builtInCMapCache.clear(); + this.standardFontDataCache.clear(); } async getPageDict(pageIndex) { const nodesToVisit = [this.toplevelPagesDict]; const visitedNodes = new _primitives.RefSet(); @@ -61871,13 +61896,13 @@ } })); var _worker = __w_pdfjs_require__(1); -const pdfjsVersion = '2.14.13'; -const pdfjsBuild = '234aa9a50'; +const pdfjsVersion = '2.14.110'; +const pdfjsBuild = '0dd6bc9a8'; })(); /******/ return __webpack_exports__; /******/ })() ; }); \ No newline at end of file diff --git a/toolkit/components/pdfjs/content/web/viewer.html b/toolkit/components/pdfjs/content/web/viewer.html --- a/toolkit/components/pdfjs/content/web/viewer.html +++ b/toolkit/components/pdfjs/content/web/viewer.html @@ -43,21 +43,21 @@
-
- - - -
@@ -160,43 +160,49 @@ Rotate Counterclockwise
- - +
+ + +
- - - - +
+ + + + +
- - - +
+ + + +