tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 3eedd1a0aa90942cbfc6d3ad54222b8b7be78d55
parent aaa8021111f6c43f1cb0ac780273c2cdd1453995
Author: Calixte Denizet <calixte.denizet@gmail.com>
Date:   Wed,  1 Oct 2025 20:02:45 +0000

Bug 1991981 - Update PDF.js to new version 9d917b289696ee9e6b90b249f251e90c7d060a2e r=pdfjs-reviewers,marco

Differential Revision: https://phabricator.services.mozilla.com/D267056

Diffstat:
Mtoolkit/components/pdfjs/content/build/pdf.mjs | 270++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------
Mtoolkit/components/pdfjs/content/build/pdf.scripting.mjs | 4++--
Mtoolkit/components/pdfjs/content/build/pdf.worker.mjs | 6+++---
Mtoolkit/components/pdfjs/content/web/viewer-geckoview.css | 4++++
Mtoolkit/components/pdfjs/content/web/viewer-geckoview.mjs | 76++++++++++++++++++++++++++++++++++++----------------------------------------
Mtoolkit/components/pdfjs/content/web/viewer.css | 11+++++++++++
Mtoolkit/components/pdfjs/content/web/viewer.mjs | 76++++++++++++++++++++++++++++++++++++----------------------------------------
Mtoolkit/components/pdfjs/moz.yaml | 4++--
8 files changed, 285 insertions(+), 166 deletions(-)

diff --git a/toolkit/components/pdfjs/content/build/pdf.mjs b/toolkit/components/pdfjs/content/build/pdf.mjs @@ -21,8 +21,8 @@ */ /** - * pdfjsVersion = 5.4.272 - * pdfjsBuild = ec4f616d2 + * pdfjsVersion = 5.4.282 + * pdfjsBuild = 9d917b289 */ /******/ // The require scope /******/ var __webpack_require__ = {}; @@ -3986,6 +3986,9 @@ class AnnotationEditorUIManager { getMode() { return this.#mode; } + isEditingMode() { + return this.#mode !== AnnotationEditorType.NONE; + } get imageManager() { return shadow(this, "imageManager", new ImageManager()); } @@ -4821,6 +4824,7 @@ class AnnotationEditor { #resizersDiv = null; #lastPointerCoords = null; #savedDimensions = null; + #fakeAnnotation = null; #focusAC = null; #focusedResizerName = ""; #hasBeenClicked = false; @@ -5011,6 +5015,8 @@ class AnnotationEditor { this.pageDimensions = parent.pageDimensions; } else { this.#stopResizing(); + this.#fakeAnnotation?.remove(); + this.#fakeAnnotation = null; } this.parent = parent; } @@ -5567,7 +5573,9 @@ class AnnotationEditor { } addStandaloneCommentButton() { if (this.#commentStandaloneButton) { - this.#commentStandaloneButton.classList.remove("hidden"); + if (this._uiManager.isEditingMode()) { + this.#commentStandaloneButton.classList.remove("hidden"); + } return; } if (!this.hasComment) { @@ -6384,6 +6392,23 @@ class AnnotationEditor { } this.#disabled = true; } + updateFakeAnnotationElement(annotationLayer) { + if (!this.#fakeAnnotation && !this.deleted) { + this.#fakeAnnotation = annotationLayer.addFakeAnnotation(this); + return; + } + if (this.deleted) { + this.#fakeAnnotation.remove(); + this.#fakeAnnotation = null; + return; + } + if (this.hasEditedComment || this._hasBeenMoved || this._hasBeenResized) { + this.#fakeAnnotation.updateEdited({ + rect: this.getPDFRect(), + popup: this.comment + }); + } + } renderAnnotationElement(annotation) { if (this.deleted) { annotation.hide(); @@ -6651,10 +6676,12 @@ class AnnotationStorage { let numberOfDeletedComments = 0; for (const value of this.#storage.values()) { if (!(value instanceof AnnotationEditor)) { - if (value.popup.deleted) { - numberOfDeletedComments += 1; - } else if (value.popup) { - numberOfEditedComments += 1; + if (value.popup) { + if (value.popup.deleted) { + numberOfDeletedComments += 1; + } else { + numberOfEditedComments += 1; + } } continue; } @@ -12761,7 +12788,7 @@ function getDocument(src = {}) { } const docParams = { docId, - apiVersion: "5.4.272", + apiVersion: "5.4.282", data, password, disableAutoFetch, @@ -14338,8 +14365,8 @@ class InternalRenderTask { } } } -const version = "5.4.272"; -const build = "ec4f616d2"; +const version = "5.4.282"; +const build = "9d917b289"; ;// ./src/display/editor/color_picker.js @@ -14911,6 +14938,30 @@ class AnnotationElement { } = this; return this.annotationStorage.getRawValue(`${AnnotationEditorPrefix}${data.id}`)?.popup?.contents || data.contentsObj?.str || ""; } + set commentText(text) { + const { + data + } = this; + const popup = { + deleted: !text, + contents: text || "" + }; + if (!this.annotationStorage.updateEditor(data.id, { + popup + })) { + this.annotationStorage.setValue(`${AnnotationEditorPrefix}${data.id}`, { + id: data.id, + annotationType: data.annotationType, + pageIndex: this.parent.page._pageIndex, + popup, + popupRef: data.popupRef, + modificationDate: new Date() + }); + } + if (!text) { + this.removePopup(); + } + } removePopup() { (this.#popupElement?.popup || this.popup)?.remove(); this.#popupElement = this.popup = null; @@ -14933,10 +14984,8 @@ class AnnotationElement { } let popup = this.#popupElement?.popup || this.popup; if (!popup && newPopup?.text) { - if (!this.parent._commentManager) { - this._createPopup(newPopup); - popup = this.#popupElement.popup; - } + this._createPopup(newPopup); + popup = this.#popupElement.popup; } if (!popup) { return; @@ -15424,6 +15473,52 @@ class AnnotationElement { return this.data.rect[3] - this.data.rect[1]; } } +class EditorAnnotationElement extends AnnotationElement { + constructor(parameters) { + super(parameters, { + isRenderable: true, + ignoreBorder: true + }); + this.editor = parameters.editor; + } + render() { + this.container.className = "editorAnnotation"; + return this.container; + } + createOrUpdatePopup() { + const { + editor + } = this; + if (!editor.hasComment) { + return; + } + this._createPopup(editor.comment); + this.extraPopupElement.popup.renderCommentButton(); + } + get hasCommentButton() { + return this.enableComment && this.editor.hasComment; + } + get commentButtonPosition() { + return this.editor.commentButtonPositionInPage; + } + get commentText() { + return this.editor.comment.text; + } + set commentText(text) { + this.editor.comment = text; + if (!text) { + this.removePopup(); + } + } + get commentData() { + return this.editor.getData(); + } + remove() { + this.container.remove(); + this.container = null; + this.removePopup(); + } +} class LinkAnnotationElement extends AnnotationElement { constructor(parameters, options = null) { super(parameters, { @@ -16048,6 +16143,9 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement { value = new Date(2000, 0, 1, parts[0], parts[1], parts[2] || 0).valueOf(); target.step = ""; } else { + if (!value.includes("T")) { + value = `${value}T00:00`; + } value = new Date(value).valueOf(); } target.type = "text"; @@ -16779,7 +16877,7 @@ class PopupElement { } } #updateCommentButtonPosition() { - if (this.#firstElement.extraPopupElement) { + if (this.#firstElement.extraPopupElement && !this.#firstElement.editor) { return; } this.renderCommentButton(); @@ -16839,33 +16937,10 @@ class PopupElement { return this.#commentText; } set comment(text) { - const element = this.#firstElement; - const { - data - } = element; if (text === this.comment) { return; } - const popup = { - deleted: !text, - contents: text || "" - }; - if (!element.annotationStorage.updateEditor(data.id, { - popup - })) { - element.annotationStorage.setValue(`${AnnotationEditorPrefix}${data.id}`, { - id: data.id, - annotationType: data.annotationType, - pageIndex: element.parent.page._pageIndex, - popup, - popupRef: data.popupRef, - modificationDate: new Date() - }); - } - this.#commentText = text; - if (!text) { - element.removePopup(); - } + this.#firstElement.commentText = this.#commentText = text; } get parentBoundingClientRect() { return this.#firstElement.layer.getBoundingClientRect(); @@ -17719,8 +17794,10 @@ class FileAttachmentAnnotationElement extends AnnotationElement { class AnnotationLayer { #accessibilityManager = null; #annotationCanvasMap = null; + #annotationStorage = null; #editableAnnotations = new Map(); #structTreeLayer = null; + #linkService = null; constructor({ div, accessibilityManager, @@ -17729,12 +17806,16 @@ class AnnotationLayer { page, viewport, structTreeLayer, - commentManager + commentManager, + linkService, + annotationStorage }) { this.div = div; this.#accessibilityManager = accessibilityManager; this.#annotationCanvasMap = annotationCanvasMap; this.#structTreeLayer = structTreeLayer || null; + this.#linkService = linkService || null; + this.#annotationStorage = annotationStorage || new AnnotationStorage(); this.page = page; this.viewport = viewport; this.zIndex = 0; @@ -17770,12 +17851,12 @@ class AnnotationLayer { const elementParams = { data: null, layer, - linkService: params.linkService, + linkService: this.#linkService, downloadManager: params.downloadManager, imageResourcesPath: params.imageResourcesPath || "", renderForms: params.renderForms !== false, svgFactory: new DOMSVGFactory(), - annotationStorage: params.annotationStorage || new AnnotationStorage(), + annotationStorage: this.#annotationStorage, enableComment: params.enableComment === true, enableScripting: params.enableScripting === true, hasJSActions: params.hasJSActions, @@ -17825,11 +17906,11 @@ class AnnotationLayer { } this.#setAnnotationCanvasMap(); } - async addLinkAnnotations(annotations, linkService) { + async addLinkAnnotations(annotations) { const elementParams = { data: null, layer: this.div, - linkService, + linkService: this.#linkService, svgFactory: new DOMSVGFactory(), parent: this }; @@ -17897,6 +17978,33 @@ class AnnotationLayer { getEditableAnnotation(id) { return this.#editableAnnotations.get(id); } + addFakeAnnotation(editor) { + const { + div + } = this; + const { + id, + rotation + } = editor; + const element = new EditorAnnotationElement({ + data: { + id, + rect: editor.getPDFRect(), + rotation + }, + editor, + layer: div, + parent: this, + enableComment: !!this._commentManager, + linkService: this.#linkService, + annotationStorage: this.#annotationStorage + }); + const htmlElement = element.render(); + div.append(htmlElement); + this.#accessibilityManager?.moveElementInDOM(div, htmlElement, htmlElement, false); + element.createOrUpdatePopup(); + return element; + } static get _defaultBorderStyle() { return shadow(this, "_defaultBorderStyle", Object.freeze({ width: 1, @@ -23419,6 +23527,7 @@ class AnnotationEditorLayer { this.#cleanup(); switch (mode) { case AnnotationEditorType.NONE: + this.div.classList.toggle("nonEditing", true); this.disableTextSelection(); this.togglePointerEvents(false); this.toggleAnnotationLayerPointerEvents(true); @@ -23443,6 +23552,7 @@ class AnnotationEditorLayer { const { classList } = this.div; + classList.toggle("nonEditing", false); if (mode === AnnotationEditorType.POPUP) { classList.toggle("commentEditing", true); } else { @@ -23481,6 +23591,7 @@ class AnnotationEditorLayer { this.#isEnabling = true; this.div.tabIndex = 0; this.togglePointerEvents(true); + this.div.classList.toggle("nonEditing", false); this.#textLayerDblClickAC?.abort(); this.#textLayerDblClickAC = null; const annotationElementIds = new Set(); @@ -23492,25 +23603,23 @@ class AnnotationEditorLayer { annotationElementIds.add(editor.annotationElementId); } } - if (!this.#annotationLayer) { - this.#isEnabling = false; - return; - } - const editables = this.#annotationLayer.getEditableAnnotations(); - for (const editable of editables) { - editable.hide(); - if (this.#uiManager.isDeletedAnnotationElement(editable.data.id)) { - continue; - } - if (annotationElementIds.has(editable.data.id)) { - continue; - } - const editor = await this.deserialize(editable); - if (!editor) { - continue; + const annotationLayer = this.#annotationLayer; + if (annotationLayer) { + for (const editable of annotationLayer.getEditableAnnotations()) { + editable.hide(); + if (this.#uiManager.isDeletedAnnotationElement(editable.data.id)) { + continue; + } + if (annotationElementIds.has(editable.data.id)) { + continue; + } + const editor = await this.deserialize(editable); + if (!editor) { + continue; + } + this.addOrRebuild(editor); + editor.enableEditing(); } - this.addOrRebuild(editor); - editor.enableEditing(); } this.#isEnabling = false; this.#uiManager._eventBus.dispatch("editorsrendered", { @@ -23522,6 +23631,7 @@ class AnnotationEditorLayer { this.#isDisabling = true; this.div.tabIndex = -1; this.togglePointerEvents(false); + this.div.classList.toggle("nonEditing", true); if (this.#textLayer && !this.#textLayerDblClickAC) { this.#textLayerDblClickAC = new AbortController(); const signal = this.#uiManager.combinedSignal(this.#textLayerDblClickAC); @@ -23569,24 +23679,26 @@ class AnnotationEditorLayer { capture: true }); } - const changedAnnotations = new Map(); - const resetAnnotations = new Map(); - for (const editor of this.#allEditorsIterator) { - editor.disableEditing(); - if (!editor.annotationElementId) { - continue; - } - if (editor.serialize() !== null) { - changedAnnotations.set(editor.annotationElementId, editor); - continue; - } else { - resetAnnotations.set(editor.annotationElementId, editor); + const annotationLayer = this.#annotationLayer; + if (annotationLayer) { + const changedAnnotations = new Map(); + const resetAnnotations = new Map(); + for (const editor of this.#allEditorsIterator) { + editor.disableEditing(); + if (!editor.annotationElementId) { + editor.updateFakeAnnotationElement(annotationLayer); + continue; + } + if (editor.serialize() !== null) { + changedAnnotations.set(editor.annotationElementId, editor); + continue; + } else { + resetAnnotations.set(editor.annotationElementId, editor); + } + this.getEditableAnnotation(editor.annotationElementId)?.show(); + editor.remove(); } - this.getEditableAnnotation(editor.annotationElementId)?.show(); - editor.remove(); - } - if (this.#annotationLayer) { - const editables = this.#annotationLayer.getEditableAnnotations(); + const editables = annotationLayer.getEditableAnnotations(); for (const editable of editables) { const { id diff --git a/toolkit/components/pdfjs/content/build/pdf.scripting.mjs b/toolkit/components/pdfjs/content/build/pdf.scripting.mjs @@ -21,8 +21,8 @@ */ /** - * pdfjsVersion = 5.4.272 - * pdfjsBuild = ec4f616d2 + * pdfjsVersion = 5.4.282 + * pdfjsBuild = 9d917b289 */ ;// ./src/scripting_api/constants.js diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.mjs b/toolkit/components/pdfjs/content/build/pdf.worker.mjs @@ -21,8 +21,8 @@ */ /** - * pdfjsVersion = 5.4.272 - * pdfjsBuild = ec4f616d2 + * pdfjsVersion = 5.4.282 + * pdfjsBuild = 9d917b289 */ /******/ // The require scope /******/ var __webpack_require__ = {}; @@ -58123,7 +58123,7 @@ class WorkerMessageHandler { docId, apiVersion } = docParams; - const workerVersion = "5.4.272"; + const workerVersion = "5.4.282"; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); } diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.css b/toolkit/components/pdfjs/content/web/viewer-geckoview.css @@ -1524,6 +1524,10 @@ .structTree{ contain:strict; } + + &.detailView{ + image-rendering:pixelated; + } } } } diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs @@ -21,8 +21,8 @@ */ /** - * pdfjsVersion = 5.4.272 - * pdfjsBuild = ec4f616d2 + * pdfjsVersion = 5.4.282 + * pdfjsBuild = 9d917b289 */ /******/ // The require scope /******/ var __webpack_require__ = {}; @@ -2877,6 +2877,8 @@ class CommentSidebar { currentTarget }) { if (currentTarget.classList.contains("selected")) { + currentTarget.classList.remove("selected"); + this.#popup._hide(); return; } const annotation = this.#elementsToAnnotations.get(currentTarget); @@ -5873,19 +5875,17 @@ class AnnotationLayerBuilder { const div = this.div = document.createElement("div"); div.className = "annotationLayer"; this.#onAppend?.(div); + this.#initAnnotationLayer(viewport, structTreeLayer); if (annotations.length === 0) { this.#annotations = annotations; - this.hide(true); + setLayerDimensions(this.div, viewport); return; } - this.#initAnnotationLayer(viewport, structTreeLayer); await this.annotationLayer.render({ annotations, imageResourcesPath: this.imageResourcesPath, renderForms: this.renderForms, - linkService: this.linkService, downloadManager: this.downloadManager, - annotationStorage: this.annotationStorage, enableComment: this.enableComment, enableScripting: this.enableScripting, hasJSActions, @@ -5910,12 +5910,14 @@ class AnnotationLayerBuilder { accessibilityManager: this._accessibilityManager, annotationCanvasMap: this._annotationCanvasMap, annotationEditorUIManager: this._annotationEditorUIManager, + annotationStorage: this.annotationStorage, page: this.pdfPage, viewport: viewport.clone({ dontFlip: true }), structTreeLayer, - commentManager: this.#commentManager + commentManager: this.#commentManager, + linkService: this.linkService }); } cancel() { @@ -5933,11 +5935,7 @@ class AnnotationLayerBuilder { hasEditableAnnotations() { return !!this.annotationLayer?.hasEditableAnnotations(); } - async injectLinkAnnotations({ - inferredLinks, - viewport, - structTreeLayer = null - }) { + async injectLinkAnnotations(inferredLinks) { if (this.#annotations === null) { throw new Error("`render` method must be called before `injectLinkAnnotations`."); } @@ -5949,11 +5947,7 @@ class AnnotationLayerBuilder { if (!newLinks.length) { return; } - if (!this.annotationLayer) { - this.#initAnnotationLayer(viewport, structTreeLayer); - setLayerDimensions(this.div, viewport); - } - await this.annotationLayer.addLinkAnnotations(newLinks, this.linkService); + await this.annotationLayer.addLinkAnnotations(newLinks); if (!this.#externalHide) { this.div.hidden = false; } @@ -6577,7 +6571,10 @@ class PDFPageDetailView extends BasePDFPageView { canvasWrapper.prepend(newCanvas); } }, hideUntilComplete); - canvas.setAttribute("aria-hidden", "true"); + canvas.ariaHidden = true; + if (this.enableOptimizedPartialRendering) { + canvas.className = "detailView"; + } const { width, height @@ -7624,11 +7621,7 @@ class PDFPageView extends BasePDFPageView { if (!this.annotationLayer) { return; } - await this.annotationLayer.injectLinkAnnotations({ - inferredLinks: Autolinker.processLinks(this), - viewport: this.viewport, - structTreeLayer: this.structTreeLayer - }); + await this.annotationLayer.injectLinkAnnotations(Autolinker.processLinks(this)); } catch (ex) { console.error("#injectLinkAnnotations:", ex); error = ex; @@ -7815,8 +7808,9 @@ class PDFPageView extends BasePDFPageView { const outputScale = this.outputScale = new OutputScale(); this.#needsRestrictedScaling = outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim, this.capCanvasAreaFactor); if (this.#needsRestrictedScaling && this.enableDetailCanvas) { - outputScale.sx /= 10; - outputScale.sy /= 10; + const factor = this.enableOptimizedPartialRendering ? 4 : 2; + outputScale.sx /= factor; + outputScale.sy /= factor; } } cancelRendering({ @@ -8064,20 +8058,22 @@ class PDFPageView extends BasePDFPageView { }); await this.#renderDrawLayer(); this.drawLayer.setParent(canvasWrapper); - this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ - uiManager: annotationEditorUIManager, - pdfPage, - l10n, - structTreeLayer: this.structTreeLayer, - accessibilityManager: this._accessibilityManager, - annotationLayer: this.annotationLayer?.annotationLayer, - textLayer: this.textLayer, - drawLayer: this.drawLayer.getDrawLayer(), - onAppend: annotationEditorLayerDiv => { - this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); - } - }); - this.#renderAnnotationEditorLayer(); + if (this.annotationLayer || this.#annotationMode === AnnotationMode.DISABLE) { + this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ + uiManager: annotationEditorUIManager, + pdfPage, + l10n, + structTreeLayer: this.structTreeLayer, + accessibilityManager: this._accessibilityManager, + annotationLayer: this.annotationLayer?.annotationLayer, + textLayer: this.textLayer, + drawLayer: this.drawLayer.getDrawLayer(), + onAppend: annotationEditorLayerDiv => { + this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); + } + }); + this.#renderAnnotationEditorLayer(); + } }); if (pdfPage.isPureXfa) { if (!this.xfaLayer) { @@ -8217,7 +8213,7 @@ class PDFViewer { #textLayerMode = TextLayerMode.ENABLE; #viewerAlert = null; constructor(options) { - const viewerVersion = "5.4.272"; + const viewerVersion = "5.4.282"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } diff --git a/toolkit/components/pdfjs/content/web/viewer.css b/toolkit/components/pdfjs/content/web/viewer.css @@ -3186,6 +3186,13 @@ } } +.page:has(.annotationEditorLayer.nonEditing) + .annotationLayer + .editorAnnotation{ + position:absolute; + pointer-events:none; +} + #viewerContainer.pdfPresentationMode:fullscreen, .annotationEditorLayer.disabled{ .noAltTextBadge{ @@ -4635,6 +4642,10 @@ .structTree{ contain:strict; } + + &.detailView{ + image-rendering:pixelated; + } } } } diff --git a/toolkit/components/pdfjs/content/web/viewer.mjs b/toolkit/components/pdfjs/content/web/viewer.mjs @@ -21,8 +21,8 @@ */ /** - * pdfjsVersion = 5.4.272 - * pdfjsBuild = ec4f616d2 + * pdfjsVersion = 5.4.282 + * pdfjsBuild = 9d917b289 */ /******/ // The require scope /******/ var __webpack_require__ = {}; @@ -3724,6 +3724,8 @@ class CommentSidebar { currentTarget }) { if (currentTarget.classList.contains("selected")) { + currentTarget.classList.remove("selected"); + this.#popup._hide(); return; } const annotation = this.#elementsToAnnotations.get(currentTarget); @@ -9058,19 +9060,17 @@ class AnnotationLayerBuilder { const div = this.div = document.createElement("div"); div.className = "annotationLayer"; this.#onAppend?.(div); + this.#initAnnotationLayer(viewport, structTreeLayer); if (annotations.length === 0) { this.#annotations = annotations; - this.hide(true); + setLayerDimensions(this.div, viewport); return; } - this.#initAnnotationLayer(viewport, structTreeLayer); await this.annotationLayer.render({ annotations, imageResourcesPath: this.imageResourcesPath, renderForms: this.renderForms, - linkService: this.linkService, downloadManager: this.downloadManager, - annotationStorage: this.annotationStorage, enableComment: this.enableComment, enableScripting: this.enableScripting, hasJSActions, @@ -9095,12 +9095,14 @@ class AnnotationLayerBuilder { accessibilityManager: this._accessibilityManager, annotationCanvasMap: this._annotationCanvasMap, annotationEditorUIManager: this._annotationEditorUIManager, + annotationStorage: this.annotationStorage, page: this.pdfPage, viewport: viewport.clone({ dontFlip: true }), structTreeLayer, - commentManager: this.#commentManager + commentManager: this.#commentManager, + linkService: this.linkService }); } cancel() { @@ -9118,11 +9120,7 @@ class AnnotationLayerBuilder { hasEditableAnnotations() { return !!this.annotationLayer?.hasEditableAnnotations(); } - async injectLinkAnnotations({ - inferredLinks, - viewport, - structTreeLayer = null - }) { + async injectLinkAnnotations(inferredLinks) { if (this.#annotations === null) { throw new Error("`render` method must be called before `injectLinkAnnotations`."); } @@ -9134,11 +9132,7 @@ class AnnotationLayerBuilder { if (!newLinks.length) { return; } - if (!this.annotationLayer) { - this.#initAnnotationLayer(viewport, structTreeLayer); - setLayerDimensions(this.div, viewport); - } - await this.annotationLayer.addLinkAnnotations(newLinks, this.linkService); + await this.annotationLayer.addLinkAnnotations(newLinks); if (!this.#externalHide) { this.div.hidden = false; } @@ -9762,7 +9756,10 @@ class PDFPageDetailView extends BasePDFPageView { canvasWrapper.prepend(newCanvas); } }, hideUntilComplete); - canvas.setAttribute("aria-hidden", "true"); + canvas.ariaHidden = true; + if (this.enableOptimizedPartialRendering) { + canvas.className = "detailView"; + } const { width, height @@ -10809,11 +10806,7 @@ class PDFPageView extends BasePDFPageView { if (!this.annotationLayer) { return; } - await this.annotationLayer.injectLinkAnnotations({ - inferredLinks: Autolinker.processLinks(this), - viewport: this.viewport, - structTreeLayer: this.structTreeLayer - }); + await this.annotationLayer.injectLinkAnnotations(Autolinker.processLinks(this)); } catch (ex) { console.error("#injectLinkAnnotations:", ex); error = ex; @@ -11000,8 +10993,9 @@ class PDFPageView extends BasePDFPageView { const outputScale = this.outputScale = new OutputScale(); this.#needsRestrictedScaling = outputScale.limitCanvas(width, height, this.maxCanvasPixels, this.maxCanvasDim, this.capCanvasAreaFactor); if (this.#needsRestrictedScaling && this.enableDetailCanvas) { - outputScale.sx /= 10; - outputScale.sy /= 10; + const factor = this.enableOptimizedPartialRendering ? 4 : 2; + outputScale.sx /= factor; + outputScale.sy /= factor; } } cancelRendering({ @@ -11249,20 +11243,22 @@ class PDFPageView extends BasePDFPageView { }); await this.#renderDrawLayer(); this.drawLayer.setParent(canvasWrapper); - this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ - uiManager: annotationEditorUIManager, - pdfPage, - l10n, - structTreeLayer: this.structTreeLayer, - accessibilityManager: this._accessibilityManager, - annotationLayer: this.annotationLayer?.annotationLayer, - textLayer: this.textLayer, - drawLayer: this.drawLayer.getDrawLayer(), - onAppend: annotationEditorLayerDiv => { - this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); - } - }); - this.#renderAnnotationEditorLayer(); + if (this.annotationLayer || this.#annotationMode === AnnotationMode.DISABLE) { + this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ + uiManager: annotationEditorUIManager, + pdfPage, + l10n, + structTreeLayer: this.structTreeLayer, + accessibilityManager: this._accessibilityManager, + annotationLayer: this.annotationLayer?.annotationLayer, + textLayer: this.textLayer, + drawLayer: this.drawLayer.getDrawLayer(), + onAppend: annotationEditorLayerDiv => { + this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); + } + }); + this.#renderAnnotationEditorLayer(); + } }); if (pdfPage.isPureXfa) { if (!this.xfaLayer) { @@ -11402,7 +11398,7 @@ class PDFViewer { #textLayerMode = TextLayerMode.ENABLE; #viewerAlert = null; constructor(options) { - const viewerVersion = "5.4.272"; + const viewerVersion = "5.4.282"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } diff --git a/toolkit/components/pdfjs/moz.yaml b/toolkit/components/pdfjs/moz.yaml @@ -20,8 +20,8 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: ec4f616d2162bd112af83cc1d1b50ff50d2afb7a (2025-09-27T12:10:57Z). - revision: ec4f616d2162bd112af83cc1d1b50ff50d2afb7a + release: 9d917b289696ee9e6b90b249f251e90c7d060a2e (2025-10-01T17:29:17Z). + revision: 9d917b289696ee9e6b90b249f251e90c7d060a2e # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/