diff --git a/taskcluster/kinds/fetch/toolchains.yml b/taskcluster/kinds/fetch/toolchains.yml --- a/taskcluster/kinds/fetch/toolchains.yml +++ b/taskcluster/kinds/fetch/toolchains.yml @@ -673,11 +673,11 @@ mozilla-pdf.js: description: Mozilla pdf.js Github repo fetch: type: git repo: https://github.com/mozilla/pdf.js - revision: d64f334f98d4b7f1c2e09a731a63b68629c946f9 + revision: e3fd62d7267ff28b291d503ff93f0ad0bda96cc8 xmlstarlet-1.6.1: description: xmlstarlet for Android Performance Tests fetch: type: static-url diff --git a/toolkit/components/pdfjs/content/build/pdf.mjs b/toolkit/components/pdfjs/content/build/pdf.mjs --- a/toolkit/components/pdfjs/content/build/pdf.mjs +++ b/toolkit/components/pdfjs/content/build/pdf.mjs @@ -1656,12 +1656,19 @@ #toolbar = null; #colorPicker = null; #editor; #buttons = null; #altText = null; + static #l10nRemove = null; constructor(editor) { this.#editor = editor; + EditorToolbar.#l10nRemove ||= Object.freeze({ + freetext: "pdfjs-editor-remove-freetext-button", + highlight: "pdfjs-editor-remove-highlight-button", + ink: "pdfjs-editor-remove-ink-button", + stamp: "pdfjs-editor-remove-stamp-button" + }); } render() { const editToolbar = this.#toolbar = document.createElement("div"); editToolbar.className = "editToolbar"; editToolbar.setAttribute("role", "toolbar"); @@ -1685,10 +1692,13 @@ style.top = `calc(${100 * position[1]}% + var(--editor-toolbar-vert-offset))`; } this.#addDeleteButton(); return editToolbar; } + get div() { + return this.#toolbar; + } static #pointerDown(e) { e.stopPropagation(); } #focusIn(e) { this.#editor._focusEventsAllowed = false; @@ -1721,19 +1731,23 @@ show() { this.#toolbar.classList.remove("hidden"); this.#altText?.shown(); } #addDeleteButton() { + const { + editorType, + _uiManager + } = this.#editor; const button = document.createElement("button"); button.className = "delete"; button.tabIndex = 0; - button.setAttribute("data-l10n-id", `pdfjs-editor-remove-${this.#editor.editorType}-button`); + button.setAttribute("data-l10n-id", EditorToolbar.#l10nRemove[editorType]); this.#addListenersToElement(button); button.addEventListener("click", e => { - this.#editor._uiManager.delete(); + _uiManager.delete(); }, { - signal: this.#editor._uiManager._signal + signal: _uiManager._signal }); this.#buttons.append(button); } get #divider() { const divider = document.createElement("div"); @@ -3731,12 +3745,11 @@ let tooltip = this.#altTextTooltip; if (!tooltip) { this.#altTextTooltip = tooltip = document.createElement("span"); tooltip.className = "tooltip"; tooltip.setAttribute("role", "tooltip"); - const id = tooltip.id = `alt-text-tooltip-${this.#editor.id}`; - button.setAttribute("aria-describedby", id); + tooltip.id = `alt-text-tooltip-${this.#editor.id}`; const DELAY_TO_SHOW_TOOLTIP = 100; const signal = this.#editor._uiManager._signal; signal.addEventListener("abort", () => { clearTimeout(this.#altTextTooltipTimeout); this.#altTextTooltipTimeout = null; @@ -4413,10 +4426,18 @@ } this._editToolbar.remove(); this._editToolbar = null; this.#altText?.destroy(); } + addContainer(container) { + const editToolbarDiv = this._editToolbar?.div; + if (editToolbarDiv) { + editToolbarDiv.before(container); + } else { + this.div.append(container); + } + } getClientDimensions() { return this.div.getBoundingClientRect(); } async addAltTextButton() { if (this.#altText) { @@ -9705,11 +9726,11 @@ worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams); task._worker = worker; } const docParams = { docId, - apiVersion: "4.6.58", + apiVersion: "4.6.101", data, password, disableAutoFetch, rangeChunkSize, length, @@ -11374,12 +11395,12 @@ this.callback(); } } } } -const version = "4.6.58"; -const build = "a41cd3838"; +const version = "4.6.101"; +const build = "e3fd62d72"; ;// CONCATENATED MODULE: ./src/shared/scripting_utils.js function makeColorComp(n) { return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0"); } @@ -13875,11 +13896,11 @@ isRenderable: true, ignoreBorder: true }); this.containerClassName = "inkAnnotation"; this.svgElementName = "svg:polyline"; - this.annotationEditorType = AnnotationEditorType.INK; + this.annotationEditorType = this.data.it === "InkHighlight" ? AnnotationEditorType.HIGHLIGHT : AnnotationEditorType.INK; } render() { this.container.classList.add(this.containerClassName); const { data: { @@ -13912,10 +13933,13 @@ this._createPopup(); } svg.append(polyline); } this.container.append(svg); + if (this._isEditable) { + this._editOnDoubleClick(); + } return this.container; } getElementsToTriggerPopup() { return this.#polylines; } @@ -13928,16 +13952,18 @@ super(parameters, { isRenderable: true, ignoreBorder: true, createQuadrilaterals: true }); + this.annotationEditorType = AnnotationEditorType.HIGHLIGHT; } render() { if (!this.data.popupRef && this.hasPopupData) { this._createPopup(); } this.container.classList.add("highlightAnnotation"); + this._editOnDoubleClick(); return this.container; } } class UnderlineAnnotationElement extends AnnotationElement { constructor(parameters) { @@ -13994,10 +14020,11 @@ ignoreBorder: true }); } render() { this.container.classList.add("stampAnnotation"); + this.container.setAttribute("role", "img"); if (!this.data.popupRef && this.hasPopupData) { this._createPopup(); } return this.container; } @@ -14064,32 +14091,41 @@ } class AnnotationLayer { #accessibilityManager = null; #annotationCanvasMap = null; #editableAnnotations = new Map(); + #structTreeLayer = null; constructor({ div, accessibilityManager, annotationCanvasMap, annotationEditorUIManager, page, - viewport + viewport, + structTreeLayer }) { this.div = div; this.#accessibilityManager = accessibilityManager; this.#annotationCanvasMap = annotationCanvasMap; + this.#structTreeLayer = structTreeLayer || null; this.page = page; this.viewport = viewport; this.zIndex = 0; this._annotationEditorUIManager = annotationEditorUIManager; } hasEditableAnnotations() { return this.#editableAnnotations.size > 0; } - #appendElement(element, id) { + async #appendElement(element, id) { const contentElement = element.firstChild || element; - contentElement.id = `${AnnotationPrefix}${id}`; + const annotationId = contentElement.id = `${AnnotationPrefix}${id}`; + const ariaAttributes = await this.#structTreeLayer?.getAriaAttributes(annotationId); + if (ariaAttributes) { + for (const [key, value] of ariaAttributes) { + contentElement.setAttribute(key, value); + } + } this.div.append(element); this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false); } async render(params) { const { @@ -14148,11 +14184,11 @@ } const rendered = element.render(); if (data.hidden) { rendered.style.visibility = "hidden"; } - this.#appendElement(rendered, data.id); + await this.#appendElement(rendered, data.id); if (element._isEditable) { this.#editableAnnotations.set(element.data.id, element); this._annotationEditorUIManager?.renderAnnotationElement(element); } } @@ -15641,10 +15677,11 @@ + class HighlightEditor extends AnnotationEditor { #anchorNode = null; #anchorOffset = 0; #boxes; #clipPathId = null; @@ -15653,10 +15690,11 @@ #focusNode = null; #focusOffset = 0; #highlightDiv = null; #highlightOutlines = null; #id = null; + #initialData = null; #isFreeHighlight = false; #lastPoint = null; #opacity; #outlineId = null; #text = ""; @@ -15697,11 +15735,11 @@ this._isDraggable = false; if (params.highlightId > -1) { this.#isFreeHighlight = true; this.#createFreeOutlines(params); this.#addToDrawLayer(); - } else { + } else if (this.#boxes) { this.#anchorNode = params.anchorNode; this.#anchorOffset = params.anchorOffset; this.#focusNode = params.focusNode; this.#focusOffset = params.focusOffset; this.#createOutlines(); @@ -15841,19 +15879,22 @@ } get propertiesToUpdate() { return [[AnnotationEditorParamsType.HIGHLIGHT_COLOR, this.color || HighlightEditor._defaultColor], [AnnotationEditorParamsType.HIGHLIGHT_THICKNESS, this.#thickness || HighlightEditor._defaultThickness], [AnnotationEditorParamsType.HIGHLIGHT_FREE, this.#isFreeHighlight]]; } #updateColor(color) { - const setColor = col => { + const setColorAndOpacity = (col, opa) => { this.color = col; this.parent?.drawLayer.changeColor(this.#id, col); this.#colorPicker?.updateColor(col); + this.#opacity = opa; + this.parent?.drawLayer.changeOpacity(this.#id, opa); }; const savedColor = this.color; + const savedOpacity = this.#opacity; this.addCommands({ - cmd: setColor.bind(this, color), - undo: setColor.bind(this, savedColor), + cmd: setColorAndOpacity.bind(this, color, HighlightEditor._defaultOpacity), + undo: setColorAndOpacity.bind(this, savedColor, savedOpacity), post: this._uiManager.updateUI.bind(this._uiManager, this), mustExec: true, type: AnnotationEditorParamsType.HIGHLIGHT_COLOR, overwriteIfSameType: true, keepUndo: true @@ -15912,11 +15953,13 @@ } getRect(tx, ty) { return super.getRect(tx, ty, this.#getRotation()); } onceAdded() { - this.parent.addUndoableEditor(this); + if (!this.annotationElementId) { + this.parent.addUndoableEditor(this); + } this.div.focus(); } remove() { this.#cleanDrawLayer(); this._reportTelemetry({ @@ -16221,40 +16264,139 @@ this._freeHighlightId = -1; this._freeHighlight = null; this._freeHighlightClipId = ""; } static deserialize(data, parent, uiManager) { - const editor = super.deserialize(data, parent, uiManager); - const { - rect: [blX, blY, trX, trY], + let initialData = null; + if (data instanceof HighlightAnnotationElement) { + const { + data: { + quadPoints, + rect, + rotation, + id, + color, + opacity + }, + parent: { + page: { + pageNumber + } + } + } = data; + initialData = data = { + annotationType: AnnotationEditorType.HIGHLIGHT, + color: Array.from(color), + opacity, + quadPoints, + boxes: null, + pageIndex: pageNumber - 1, + rect: rect.slice(0), + rotation, + id, + deleted: false + }; + } else if (data instanceof InkAnnotationElement) { + const { + data: { + inkLists, + rect, + rotation, + id, + color, + borderStyle: { + rawWidth: thickness + } + }, + parent: { + page: { + pageNumber + } + } + } = data; + initialData = data = { + annotationType: AnnotationEditorType.HIGHLIGHT, + color: Array.from(color), + thickness, + inkLists, + boxes: null, + pageIndex: pageNumber - 1, + rect: rect.slice(0), + rotation, + id, + deleted: false + }; + } + const { color, - quadPoints + quadPoints, + inkLists, + opacity } = data; + const editor = super.deserialize(data, parent, uiManager); editor.color = Util.makeHexColor(...color); - editor.#opacity = data.opacity; + editor.#opacity = opacity || 1; + if (inkLists) { + editor.#thickness = data.thickness; + } + editor.annotationElementId = data.id || null; + editor.#initialData = initialData; const [pageWidth, pageHeight] = editor.pageDimensions; - editor.width = (trX - blX) / pageWidth; - editor.height = (trY - blY) / pageHeight; - const boxes = editor.#boxes = []; - for (let i = 0; i < quadPoints.length; i += 8) { - boxes.push({ - x: (quadPoints[4] - trX) / pageWidth, - y: (trY - (1 - quadPoints[i + 5])) / pageHeight, - width: (quadPoints[i + 2] - quadPoints[i]) / pageWidth, - height: (quadPoints[i + 5] - quadPoints[i + 1]) / pageHeight - }); - } - editor.#createOutlines(); + const [pageX, pageY] = editor.pageTranslation; + if (quadPoints) { + const boxes = editor.#boxes = []; + for (let i = 0; i < quadPoints.length; i += 8) { + boxes.push({ + x: (quadPoints[i] - pageX) / pageWidth, + y: 1 - (quadPoints[i + 1] - pageY) / pageHeight, + width: (quadPoints[i + 2] - quadPoints[i]) / pageWidth, + height: (quadPoints[i + 1] - quadPoints[i + 5]) / pageHeight + }); + } + editor.#createOutlines(); + editor.#addToDrawLayer(); + editor.rotate(editor.rotation); + } else if (inkLists) { + editor.#isFreeHighlight = true; + const points = inkLists[0]; + const point = { + x: points[0] - pageX, + y: pageHeight - (points[1] - pageY) + }; + const outliner = new FreeOutliner(point, [0, 0, pageWidth, pageHeight], 1, editor.#thickness / 2, true, 0.001); + for (let i = 0, ii = points.length; i < ii; i += 2) { + point.x = points[i] - pageX; + point.y = pageHeight - (points[i + 1] - pageY); + outliner.add(point); + } + const { + id, + clipPathId + } = parent.drawLayer.highlight(outliner, editor.color, editor._defaultOpacity, true); + editor.#createFreeOutlines({ + highlightOutlines: outliner.getOutlines(), + highlightId: id, + clipPathId + }); + editor.#addToDrawLayer(); + } return editor; } serialize(isForCopying = false) { if (this.isEmpty() || isForCopying) { return null; } + if (this.deleted) { + return { + pageIndex: this.pageIndex, + id: this.annotationElementId, + deleted: true + }; + } const rect = this.getRect(0, 0); const color = AnnotationEditor._colorManager.convert(this.color); - return { + const serialized = { annotationType: AnnotationEditorType.HIGHLIGHT, color, opacity: this.#opacity, thickness: this.#thickness, quadPoints: this.#serializeBoxes(), @@ -16262,10 +16404,27 @@ pageIndex: this.pageIndex, rect, rotation: this.#getRotation(), structTreeParentId: this._structTreeParentId }; + if (this.annotationElementId && !this.#hasElementChanged(serialized)) { + return null; + } + serialized.id = this.annotationElementId; + return serialized; + } + #hasElementChanged(serialized) { + const { + color + } = this.#initialData; + return serialized.color.some((c, i) => c !== color[i]); + } + renderAnnotationElement(annotation) { + annotation.updateEdited({ + rect: this.getRect(0, 0) + }); + return null; } static canCreateNewEmptyEditor() { return false; } } @@ -17353,10 +17512,11 @@ baseX = this.x; baseY = this.y; } super.render(); this.div.hidden = true; + this.div.setAttribute("role", "figure"); this.addAltTextButton(); if (this.#bitmap) { this.#createCanvas(); } else { this.#getBitmap(); @@ -17387,11 +17547,12 @@ } const [parentWidth, parentHeight] = this.parentDimensions; this.setDims(width * parentWidth / pageWidth, height * parentHeight / pageHeight); this._uiManager.enableWaiting(false); const canvas = this.#canvas = document.createElement("canvas"); - div.append(canvas); + canvas.setAttribute("role", "img"); + this.addContainer(canvas); if (!this._uiManager.useNewAltTextWhenAddingImage || !this._uiManager.useNewAltTextFlow) { div.hidden = false; } this.#drawBitmap(width, height); this.#createObserver(); @@ -17855,12 +18016,13 @@ continue; } editor = changedAnnotations.get(id); if (editor) { this.#uiManager.addChangedExistingAnnotation(editor); - editor.renderAnnotationElement(editable); - editor.show(false); + if (editor.renderAnnotationElement(editable)) { + editor.show(false); + } } editable.show(); } } this.#cleanup(); @@ -18443,10 +18605,13 @@ this.#mapping.get(id).classList.add(className); } removeClass(id, className) { this.#mapping.get(id).classList.remove(className); } + getSVGRoot(id) { + return this.#mapping.get(id); + } remove(id) { if (this.#parent === null) { return; } this.#mapping.get(id).remove(); @@ -18472,12 +18637,12 @@ -const pdfjsVersion = "4.6.58"; -const pdfjsBuild = "a41cd3838"; +const pdfjsVersion = "4.6.101"; +const pdfjsBuild = "e3fd62d72"; var __webpack_exports__AbortException = __webpack_exports__.AbortException; var __webpack_exports__AnnotationEditorLayer = __webpack_exports__.AnnotationEditorLayer; var __webpack_exports__AnnotationEditorParamsType = __webpack_exports__.AnnotationEditorParamsType; var __webpack_exports__AnnotationEditorType = __webpack_exports__.AnnotationEditorType; diff --git a/toolkit/components/pdfjs/content/build/pdf.scripting.mjs b/toolkit/components/pdfjs/content/build/pdf.scripting.mjs --- a/toolkit/components/pdfjs/content/build/pdf.scripting.mjs +++ b/toolkit/components/pdfjs/content/build/pdf.scripting.mjs @@ -4005,10 +4005,10 @@ }; } ;// CONCATENATED MODULE: ./src/pdf.scripting.js -const pdfjsVersion = "4.6.58"; -const pdfjsBuild = "a41cd3838"; +const pdfjsVersion = "4.6.101"; +const pdfjsBuild = "e3fd62d72"; globalThis.pdfjsScripting = { initSandbox: initSandbox }; diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.mjs b/toolkit/components/pdfjs/content/build/pdf.worker.mjs --- a/toolkit/components/pdfjs/content/build/pdf.worker.mjs +++ b/toolkit/components/pdfjs/content/build/pdf.worker.mjs @@ -49987,10 +49987,14 @@ } this.data.actions = collectActions(xref, dict, AnnotationActionEventType); this.data.fieldName = this._constructFieldName(dict); this.data.pageIndex = params.pageIndex; } + const it = dict.get("IT"); + if (it instanceof Name) { + this.data.it = it.name; + } this._isOffscreenCanvasSupported = params.evaluatorOptions.isOffscreenCanvasSupported; this._fallbackFontDict = null; this._needAppearances = false; } _hasFlag(flags, flag) { @@ -50354,10 +50358,11 @@ } } class AnnotationBorderStyle { constructor() { this.width = 1; + this.rawWidth = 1; this.style = AnnotationBorderStyleType.SOLID; this.dashArray = [3]; this.horizontalCornerRadius = 0; this.verticalCornerRadius = 0; } @@ -50366,10 +50371,11 @@ this.width = 0; return; } if (typeof width === "number") { if (width > 0) { + this.rawWidth = width; const maxWidth = (rect[2] - rect[0]) / 2; const maxHeight = (rect[3] - rect[1]) / 2; if (maxWidth > 0 && maxHeight > 0 && (width > maxWidth || width > maxHeight)) { warn(`AnnotationBorderStyle.setWidth - ignoring width: ${width}`); width = 1; @@ -52356,10 +52362,13 @@ dict, xref } = params; this.data.annotationType = AnnotationType.INK; this.data.inkLists = []; + this.data.isEditable = !this.data.noHTML && this.data.it === "InkHighlight"; + this.data.noHTML = false; + this.data.opacity = dict.get("CA") || 1; const rawInkLists = dict.getArray("InkList"); if (!Array.isArray(rawInkLists)) { return; } for (let i = 0, ii = rawInkLists.length; i < ii; ++i) { @@ -52551,10 +52560,13 @@ const { dict, xref } = params; this.data.annotationType = AnnotationType.HIGHLIGHT; + this.data.isEditable = !this.data.noHTML; + this.data.noHTML = false; + this.data.opacity = dict.get("CA") || 1; const quadPoints = this.data.quadPoints = getQuadPoints(dict, null); if (quadPoints) { const resources = this.appearance?.dict.get("Resources"); if (!this.appearance || !resources?.has("ExtGState")) { if (this.appearance) { @@ -52577,23 +52589,25 @@ this.data.popupRef = null; } } static createNewDict(annotation, xref, { apRef, - ap + ap, + oldAnnotation }) { const { color, opacity, rect, rotation, user, quadPoints } = annotation; - const highlight = new Dict(xref); + const highlight = oldAnnotation || new Dict(xref); highlight.set("Type", Name.get("Annot")); highlight.set("Subtype", Name.get("Highlight")); + highlight.set(oldAnnotation ? "M" : "CreationDate", `D:${getModificationDate()}`); highlight.set("CreationDate", `D:${getModificationDate()}`); highlight.set("Rect", rect); highlight.set("F", 4); highlight.set("Border", [0, 0, 0]); highlight.set("Rotate", rotation); @@ -55774,11 +55788,11 @@ const verbosity = getVerbosityLevel(); const { docId, apiVersion } = docParams; - const workerVersion = "4.6.58"; + const workerVersion = "4.6.101"; if (apiVersion !== workerVersion) { throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); } const workerHandlerName = docId + "_worker"; let handler = new MessageHandler(workerHandlerName, docId, port); @@ -56338,10 +56352,10 @@ WorkerMessageHandler.initializeFromPort(self); } ;// CONCATENATED MODULE: ./src/pdf.worker.js -const pdfjsVersion = "4.6.58"; -const pdfjsBuild = "a41cd3838"; +const pdfjsVersion = "4.6.101"; +const pdfjsBuild = "e3fd62d72"; var __webpack_exports__WorkerMessageHandler = __webpack_exports__.WorkerMessageHandler; export { __webpack_exports__WorkerMessageHandler as WorkerMessageHandler }; diff --git a/toolkit/components/pdfjs/content/web/images/altText_spinner.svg b/toolkit/components/pdfjs/content/web/images/altText_spinner.svg --- a/toolkit/components/pdfjs/content/web/images/altText_spinner.svg +++ b/toolkit/components/pdfjs/content/web/images/altText_spinner.svg @@ -1,16 +1,30 @@ - + - - + + + + + diff --git a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs --- a/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs +++ b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs @@ -2384,11 +2384,11 @@ } const passwordIncorrect = this.#reason === PasswordResponses.INCORRECT_PASSWORD; if (!this._isViewerEmbedded || passwordIncorrect) { this.input.focus(); } - this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`); + this.label.setAttribute("data-l10n-id", passwordIncorrect ? "pdfjs-password-invalid" : "pdfjs-password-label"); } async close() { if (this.overlayManager.active === this.dialog) { this.overlayManager.close(this.dialog); } @@ -4513,11 +4513,11 @@ this.annotationLayer = null; this.div = null; this._cancelled = false; this._eventBus = linkService.eventBus; } - async render(viewport, intent = "display") { + async render(viewport, options, intent = "display") { if (this.div) { if (this._cancelled || !this.annotationLayer) { return; } this.annotationLayer.update({ @@ -4546,11 +4546,12 @@ annotationCanvasMap: this._annotationCanvasMap, annotationEditorUIManager: this._annotationEditorUIManager, page: this.pdfPage, viewport: viewport.clone({ dontFlip: true - }) + }), + structTreeLayer: options?.structTreeLayer || null }); await this.annotationLayer.render({ annotations, imageResourcesPath: this.imageResourcesPath, renderForms: this.renderForms, @@ -4685,21 +4686,40 @@ Formula: null, Artifact: null }; const HEADING_PATTERN = /^H(\d+)$/; class StructTreeLayerBuilder { - #treeDom = undefined; - get renderingDone() { - return this.#treeDom !== undefined; - } - render(structTree) { - if (this.#treeDom !== undefined) { - return this.#treeDom; - } - const treeDom = this.#walk(structTree); - treeDom?.classList.add("structTree"); - return this.#treeDom = treeDom; + #promise; + #treeDom = null; + #treePromise; + #elementAttributes = new Map(); + constructor(pdfPage) { + this.#promise = pdfPage.getStructTree(); + } + async render() { + if (this.#treePromise) { + return this.#treePromise; + } + const { + promise, + resolve, + reject + } = Promise.withResolvers(); + this.#treePromise = promise; + try { + this.#treeDom = this.#walk(await this.#promise); + } catch (ex) { + reject(ex); + } + this.#promise = null; + this.#treeDom?.classList.add("structTree"); + resolve(this.#treeDom); + return promise; + } + async getAriaAttributes(annotationId) { + await this.render(); + return this.#elementAttributes.get(annotationId); } hide() { if (this.#treeDom && !this.#treeDom.hidden) { this.#treeDom.hidden = true; } @@ -4714,11 +4734,26 @@ alt, id, lang } = structElement; if (alt !== undefined) { - htmlElement.setAttribute("aria-label", removeNullCharacters(alt)); + let added = false; + const label = removeNullCharacters(alt); + for (const child of structElement.children) { + if (child.type === "annotation") { + let attrs = this.#elementAttributes.get(child.id); + if (!attrs) { + attrs = new Map(); + this.#elementAttributes.set(child.id, attrs); + } + attrs.set("aria-label", label); + added = true; + } + } + if (!added) { + htmlElement.setAttribute("aria-label", label); + } } if (id !== undefined) { htmlElement.setAttribute("aria-owns", id); } if (lang !== undefined) { @@ -5465,11 +5500,13 @@ }); } async #renderAnnotationLayer() { let error = null; try { - await this.annotationLayer.render(this.viewport, "display"); + await this.annotationLayer.render(this.viewport, { + structTreeLayer: this.structTreeLayer + }, "display"); } catch (ex) { console.error(`#renderAnnotationLayer: "${ex}".`); error = ex; } finally { this.#dispatchLayerRendered("annotationlayerrendered", error); @@ -5531,16 +5568,14 @@ } async #renderStructTreeLayer() { if (!this.textLayer) { return; } - this.structTreeLayer ||= new StructTreeLayerBuilder(); - const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null); - const treeDom = this.structTreeLayer?.render(tree); - if (treeDom) { + const treeDom = await this.structTreeLayer?.render(); + if (treeDom && this.canvas && treeDom.parentNode !== this.canvas) { this.l10n.pause(); - this.canvas?.append(treeDom); + this.canvas.append(treeDom); this.l10n.resume(); } this.structTreeLayer?.show(); } async #buildXfaTextContentItems(textDivs) { @@ -5746,18 +5781,18 @@ this.resume = null; if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) { this.textLayer.cancel(); this.textLayer = null; } - if (this.structTreeLayer && !this.textLayer) { - this.structTreeLayer = null; - } if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) { this.annotationLayer.cancel(); this.annotationLayer = null; this._annotationCanvasMap = null; } + if (this.structTreeLayer && !(this.textLayer || this.annotationLayer)) { + this.structTreeLayer = null; + } if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) { if (this.drawLayer) { this.drawLayer.cancel(); this.drawLayer = null; } @@ -5985,10 +6020,13 @@ const renderTask = this.renderTask = pdfPage.render(renderContext); renderTask.onContinue = renderContinueCallback; const resultPromise = renderTask.promise.then(async () => { showCanvas?.(true); await this.#finishRenderTask(renderTask); + if (this.textLayer || this.annotationLayer) { + this.structTreeLayer ||= new StructTreeLayerBuilder(pdfPage); + } this.#renderTextLayer(); if (this.annotationLayer) { await this.#renderAnnotationLayer(); } const { @@ -6000,24 +6038,22 @@ this.drawLayer ||= new DrawLayerBuilder({ pageIndex: this.id }); await this.#renderDrawLayer(); this.drawLayer.setParent(canvasWrapper); - if (!this.annotationEditorLayer) { - this.annotationEditorLayer = new AnnotationEditorLayerBuilder({ - uiManager: annotationEditorUIManager, - pdfPage, - l10n, - accessibilityManager: this._accessibilityManager, - annotationLayer: this.annotationLayer?.annotationLayer, - textLayer: this.textLayer, - drawLayer: this.drawLayer.getDrawLayer(), - onAppend: annotationEditorLayerDiv => { - this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); - } - }); - } + this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ + uiManager: annotationEditorUIManager, + pdfPage, + l10n, + accessibilityManager: this._accessibilityManager, + annotationLayer: this.annotationLayer?.annotationLayer, + textLayer: this.textLayer, + drawLayer: this.drawLayer.getDrawLayer(), + onAppend: annotationEditorLayerDiv => { + this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); + } + }); this.#renderAnnotationEditorLayer(); }, error => { if (!(error instanceof RenderingCancelledException)) { showCanvas?.(true); } @@ -6153,11 +6189,11 @@ #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); #scrollModePageState = null; #scaleTimeoutId = null; #textLayerMode = TextLayerMode.ENABLE; constructor(options) { - const viewerVersion = "4.6.58"; + const viewerVersion = "4.6.101"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } this.container = options.container; this.viewer = options.viewer || options.container.firstElementChild; @@ -9779,12 +9815,12 @@ ;// CONCATENATED MODULE: ./web/viewer-geckoview.js -const pdfjsVersion = "4.6.58"; -const pdfjsBuild = "a41cd3838"; +const pdfjsVersion = "4.6.101"; +const pdfjsBuild = "e3fd62d72"; const AppConstants = null; window.PDFViewerApplication = PDFViewerApplication; window.PDFViewerApplicationConstants = AppConstants; window.PDFViewerApplicationOptions = AppOptions; function getViewerConfiguration() { diff --git a/toolkit/components/pdfjs/content/web/viewer.mjs b/toolkit/components/pdfjs/content/web/viewer.mjs --- a/toolkit/components/pdfjs/content/web/viewer.mjs +++ b/toolkit/components/pdfjs/content/web/viewer.mjs @@ -2072,10 +2072,11 @@ #downloadModel; #downloadModelDescription; #eventBus; #firstTime = false; #guessedAltText; + #hasAI = false; #isEditing = null; #imagePreview; #imageData; #isAILoading = false; #wasAILoading = false; @@ -2143,20 +2144,20 @@ this.#toggleGuessAltText(checked, false); }); textarea.addEventListener("focus", () => { this.#wasAILoading = this.#isAILoading; this.#toggleLoading(false); + this.#toggleTitleAndDisclaimer(); }); textarea.addEventListener("blur", () => { - if (textarea.value) { - return; - } - this.#toggleLoading(this.#wasAILoading); + if (!textarea.value) { + this.#toggleLoading(this.#wasAILoading); + } + this.#toggleTitleAndDisclaimer(); }); textarea.addEventListener("input", () => { - this.#toggleTitle(); - this.#toggleDisclaimer(); + this.#toggleTitleAndDisclaimer(); }); eventBus._on("enableguessalttext", ({ value }) => { this.#toggleGuessAltText(value, false); @@ -2182,18 +2183,10 @@ if (!this.#uiManager) { return; } this.#dialog.classList.toggle("error", value); } - #toggleTitle() { - const isEditing = this.#isAILoading || !!this.#textarea.value; - if (this.#isEditing === isEditing) { - return; - } - this.#isEditing = isEditing; - this.#title.setAttribute("data-l10n-id", `pdfjs-editor-new-alt-text-dialog-${isEditing ? "edit" : "add"}-label`); - } async #toggleGuessAltText(value, isInitial = false) { if (!this.#uiManager) { return; } this.#dialog.classList.toggle("aiDisabled", !value); @@ -2207,28 +2200,34 @@ } this.#mlGuessAltText(isInitial); } else { this.#toggleLoading(false); this.#isAILoading = false; - this.#toggleTitle(); - this.#toggleDisclaimer(); + this.#toggleTitleAndDisclaimer(); } } #toggleNotNow() { this.#notNowButton.classList.toggle("hidden", !this.#firstTime); this.#cancelButton.classList.toggle("hidden", this.#firstTime); } #toggleAI(value) { + if (!this.#uiManager || this.#hasAI === value) { + return; + } + this.#hasAI = value; this.#dialog.classList.toggle("noAi", !value); - this.#toggleTitle(); - } - #toggleDisclaimer(value = null) { - if (!this.#uiManager) { - return; - } - const hidden = value === null ? !this.#guessedAltText || this.#guessedAltText !== this.#textarea.value : !value; - this.#disclaimer.classList.toggle("hidden", hidden); + this.#toggleTitleAndDisclaimer(); + } + #toggleTitleAndDisclaimer() { + const visible = this.#isAILoading || this.#guessedAltText && this.#guessedAltText === this.#textarea.value; + this.#disclaimer.hidden = !visible; + const isEditing = this.#isAILoading || !!this.#textarea.value; + if (this.#isEditing === isEditing) { + return; + } + this.#isEditing = isEditing; + this.#title.setAttribute("data-l10n-id", isEditing ? "pdfjs-editor-new-alt-text-dialog-edit-label" : "pdfjs-editor-new-alt-text-dialog-add-label"); } async #mlGuessAltText(isInitial) { if (this.#isAILoading) { return; } @@ -2239,17 +2238,14 @@ return; } this.#guessedAltText = this.#currentEditor.guessedAltText; if (this.#previousAltText === null && this.#guessedAltText) { this.#addAltText(this.#guessedAltText); - this.#toggleDisclaimer(); - this.#toggleTitle(); return; } this.#toggleLoading(true); - this.#toggleTitle(); - this.#toggleDisclaimer(true); + this.#toggleTitleAndDisclaimer(); let hasError = false; try { const altText = await this.#currentEditor.mlGuessAltText(this.#imageData, false); if (altText) { this.#guessedAltText = altText; @@ -2261,21 +2257,21 @@ } catch (e) { console.error(e); hasError = true; } this.#toggleLoading(false); + this.#toggleTitleAndDisclaimer(); if (hasError && this.#uiManager) { this.#toggleError(true); - this.#toggleTitle(); - this.#toggleDisclaimer(); } } #addAltText(altText) { if (!this.#uiManager || this.#textarea.value) { return; } this.#textarea.value = altText; + this.#toggleTitleAndDisclaimer(); } #setProgress() { this.#downloadModel.classList.toggle("hidden", false); const callback = async ({ detail: { @@ -3210,11 +3206,11 @@ } const passwordIncorrect = this.#reason === PasswordResponses.INCORRECT_PASSWORD; if (!this._isViewerEmbedded || passwordIncorrect) { this.input.focus(); } - this.label.setAttribute("data-l10n-id", `pdfjs-password-${passwordIncorrect ? "invalid" : "label"}`); + this.label.setAttribute("data-l10n-id", passwordIncorrect ? "pdfjs-password-invalid" : "pdfjs-password-label"); } async close() { if (this.overlayManager.active === this.dialog) { this.overlayManager.close(this.dialog); } @@ -3643,19 +3639,18 @@ } ;// CONCATENATED MODULE: ./web/pdf_document_properties.js -const DEFAULT_FIELD_CONTENT = "-"; const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"]; const US_PAGE_NAMES = { - "8.5x11": "letter", - "8.5x14": "legal" + "8.5x11": "pdfjs-document-properties-page-size-name-letter", + "8.5x14": "pdfjs-document-properties-page-size-name-legal" }; const METRIC_PAGE_NAMES = { - "297x420": "a-three", - "210x297": "a-four" + "297x420": "pdfjs-document-properties-page-size-name-a-three", + "210x297": "pdfjs-document-properties-page-size-name-a-four" }; function getPageName(size, isPortrait, pageNames) { const width = isPortrait ? size.width : size.height; const height = isPortrait ? size.height : size.width; return pageNames[`${width}x${height}`]; @@ -3679,11 +3674,10 @@ this._currentPageNumber = evt.pageNumber; }); eventBus._on("rotationchanging", evt => { this._pagesRotation = evt.pagesRotation; }); - this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage()); } async open() { await Promise.all([this.overlayManager.open(this.dialog), this._dataAvailableCapability.promise]); const currentPageNumber = this._currentPageNumber; const pagesRotation = this._pagesRotation; @@ -3732,11 +3726,11 @@ this.overlayManager.close(this.dialog); } setDocument(pdfDocument) { if (this.pdfDocument) { this.#reset(); - this.#updateUI(true); + this.#updateUI(); } if (!pdfDocument) { return; } this.pdfDocument = pdfDocument; @@ -3747,32 +3741,23 @@ this.#fieldData = null; this._dataAvailableCapability = Promise.withResolvers(); this._currentPageNumber = 1; this._pagesRotation = 0; } - #updateUI(reset = false) { - if (reset || !this.#fieldData) { - for (const id in this.fields) { - this.fields[id].textContent = DEFAULT_FIELD_CONTENT; - } - return; - } - if (this.overlayManager.active !== this.dialog) { + #updateUI() { + if (this.#fieldData && this.overlayManager.active !== this.dialog) { return; } for (const id in this.fields) { - const content = this.#fieldData[id]; - this.fields[id].textContent = content || content === 0 ? content : DEFAULT_FIELD_CONTENT; - } - } - #getL10nStr(id, args = null) { - return this.l10n.get(`pdfjs-document-properties-${id}`, args); + const content = this.#fieldData?.[id]; + this.fields[id].textContent = content || content === 0 ? content : "-"; + } } async #parseFileSize(b = 0) { const kb = b / 1024, mb = kb / 1024; - return kb ? this.#getL10nStr(`size-${mb >= 1 ? "mb" : "kb"}`, { + return kb ? this.l10n.get(mb >= 1 ? "pdfjs-document-properties-size-mb" : "pdfjs-document-properties-size-kb", { mb, kb, b }) : undefined; } @@ -3784,32 +3769,33 @@ pageSizeInches = { width: pageSizeInches.height, height: pageSizeInches.width }; } - const isPortrait = isPortraitOrientation(pageSizeInches); + const isPortrait = isPortraitOrientation(pageSizeInches), + nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage()); let sizeInches = { width: Math.round(pageSizeInches.width * 100) / 100, height: Math.round(pageSizeInches.height * 100) / 100 }; let sizeMillimeters = { width: Math.round(pageSizeInches.width * 25.4 * 10) / 10, height: Math.round(pageSizeInches.height * 25.4 * 10) / 10 }; - let rawName = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES); - if (!rawName && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) { + let nameId = getPageName(sizeInches, isPortrait, US_PAGE_NAMES) || getPageName(sizeMillimeters, isPortrait, METRIC_PAGE_NAMES); + if (!nameId && !(Number.isInteger(sizeMillimeters.width) && Number.isInteger(sizeMillimeters.height))) { const exactMillimeters = { width: pageSizeInches.width * 25.4, height: pageSizeInches.height * 25.4 }; const intMillimeters = { width: Math.round(sizeMillimeters.width), height: Math.round(sizeMillimeters.height) }; if (Math.abs(exactMillimeters.width - intMillimeters.width) < 0.1 && Math.abs(exactMillimeters.height - intMillimeters.height) < 0.1) { - rawName = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES); - if (rawName) { + nameId = getPageName(intMillimeters, isPortrait, METRIC_PAGE_NAMES); + if (nameId) { sizeInches = { width: Math.round(intMillimeters.width / 25.4 * 100) / 100, height: Math.round(intMillimeters.height / 25.4 * 100) / 100 }; sizeMillimeters = intMillimeters; @@ -3817,27 +3803,27 @@ } } const [{ width, height - }, unit, name, orientation] = await Promise.all([this._isNonMetricLocale ? sizeInches : sizeMillimeters, this.#getL10nStr(`page-size-unit-${this._isNonMetricLocale ? "inches" : "millimeters"}`), rawName && this.#getL10nStr(`page-size-name-${rawName}`), this.#getL10nStr(`page-size-orientation-${isPortrait ? "portrait" : "landscape"}`)]); - return this.#getL10nStr(`page-size-dimension-${name ? "name-" : ""}string`, { + }, unit, name, orientation] = await Promise.all([nonMetric ? sizeInches : sizeMillimeters, this.l10n.get(nonMetric ? "pdfjs-document-properties-page-size-unit-inches" : "pdfjs-document-properties-page-size-unit-millimeters"), nameId && this.l10n.get(nameId), this.l10n.get(isPortrait ? "pdfjs-document-properties-page-size-orientation-portrait" : "pdfjs-document-properties-page-size-orientation-landscape")]); + return this.l10n.get(name ? "pdfjs-document-properties-page-size-dimension-name-string" : "pdfjs-document-properties-page-size-dimension-string", { width, height, unit, name, orientation }); } async #parseDate(inputDate) { const dateObj = PDFDateString.toDateObject(inputDate); - return dateObj ? this.#getL10nStr("date-time-string", { + return dateObj ? this.l10n.get("pdfjs-document-properties-date-time-string", { dateObj }) : undefined; } #parseLinearization(isLinearized) { - return this.#getL10nStr(`linearized-${isLinearized ? "yes" : "no"}`); + return this.l10n.get(isLinearized ? "pdfjs-document-properties-linearized-yes" : "pdfjs-document-properties-linearized-no"); } } ;// CONCATENATED MODULE: ./web/pdf_find_utils.js const CharacterType = { @@ -4734,11 +4720,11 @@ case FindState.NOT_FOUND: findMsgId = "pdfjs-find-not-found"; status = "notFound"; break; case FindState.WRAPPED: - findMsgId = `pdfjs-find-reached-${previous ? "top" : "bottom"}`; + findMsgId = previous ? "pdfjs-find-reached-top" : "pdfjs-find-reached-bottom"; break; } findField.setAttribute("data-status", status); findField.setAttribute("aria-invalid", state === FindState.NOT_FOUND); findMsg.setAttribute("data-status", status); @@ -4757,11 +4743,11 @@ const { findResultsCount } = this; if (total > 0) { const limit = MATCHES_COUNT_LIMIT; - findResultsCount.setAttribute("data-l10n-id", `pdfjs-find-match-count${total > limit ? "-limit" : ""}`); + findResultsCount.setAttribute("data-l10n-id", total > limit ? "pdfjs-find-match-count-limit" : "pdfjs-find-match-count"); findResultsCount.setAttribute("data-l10n-args", JSON.stringify({ limit, current, total })); @@ -7632,11 +7618,11 @@ this.annotationLayer = null; this.div = null; this._cancelled = false; this._eventBus = linkService.eventBus; } - async render(viewport, intent = "display") { + async render(viewport, options, intent = "display") { if (this.div) { if (this._cancelled || !this.annotationLayer) { return; } this.annotationLayer.update({ @@ -7665,11 +7651,12 @@ annotationCanvasMap: this._annotationCanvasMap, annotationEditorUIManager: this._annotationEditorUIManager, page: this.pdfPage, viewport: viewport.clone({ dontFlip: true - }) + }), + structTreeLayer: options?.structTreeLayer || null }); await this.annotationLayer.render({ annotations, imageResourcesPath: this.imageResourcesPath, renderForms: this.renderForms, @@ -7804,21 +7791,40 @@ Formula: null, Artifact: null }; const HEADING_PATTERN = /^H(\d+)$/; class StructTreeLayerBuilder { - #treeDom = undefined; - get renderingDone() { - return this.#treeDom !== undefined; - } - render(structTree) { - if (this.#treeDom !== undefined) { - return this.#treeDom; - } - const treeDom = this.#walk(structTree); - treeDom?.classList.add("structTree"); - return this.#treeDom = treeDom; + #promise; + #treeDom = null; + #treePromise; + #elementAttributes = new Map(); + constructor(pdfPage) { + this.#promise = pdfPage.getStructTree(); + } + async render() { + if (this.#treePromise) { + return this.#treePromise; + } + const { + promise, + resolve, + reject + } = Promise.withResolvers(); + this.#treePromise = promise; + try { + this.#treeDom = this.#walk(await this.#promise); + } catch (ex) { + reject(ex); + } + this.#promise = null; + this.#treeDom?.classList.add("structTree"); + resolve(this.#treeDom); + return promise; + } + async getAriaAttributes(annotationId) { + await this.render(); + return this.#elementAttributes.get(annotationId); } hide() { if (this.#treeDom && !this.#treeDom.hidden) { this.#treeDom.hidden = true; } @@ -7833,11 +7839,26 @@ alt, id, lang } = structElement; if (alt !== undefined) { - htmlElement.setAttribute("aria-label", removeNullCharacters(alt)); + let added = false; + const label = removeNullCharacters(alt); + for (const child of structElement.children) { + if (child.type === "annotation") { + let attrs = this.#elementAttributes.get(child.id); + if (!attrs) { + attrs = new Map(); + this.#elementAttributes.set(child.id, attrs); + } + attrs.set("aria-label", label); + added = true; + } + } + if (!added) { + htmlElement.setAttribute("aria-label", label); + } } if (id !== undefined) { htmlElement.setAttribute("aria-owns", id); } if (lang !== undefined) { @@ -8584,11 +8605,13 @@ }); } async #renderAnnotationLayer() { let error = null; try { - await this.annotationLayer.render(this.viewport, "display"); + await this.annotationLayer.render(this.viewport, { + structTreeLayer: this.structTreeLayer + }, "display"); } catch (ex) { console.error(`#renderAnnotationLayer: "${ex}".`); error = ex; } finally { this.#dispatchLayerRendered("annotationlayerrendered", error); @@ -8650,16 +8673,14 @@ } async #renderStructTreeLayer() { if (!this.textLayer) { return; } - this.structTreeLayer ||= new StructTreeLayerBuilder(); - const tree = await (!this.structTreeLayer.renderingDone ? this.pdfPage.getStructTree() : null); - const treeDom = this.structTreeLayer?.render(tree); - if (treeDom) { + const treeDom = await this.structTreeLayer?.render(); + if (treeDom && this.canvas && treeDom.parentNode !== this.canvas) { this.l10n.pause(); - this.canvas?.append(treeDom); + this.canvas.append(treeDom); this.l10n.resume(); } this.structTreeLayer?.show(); } async #buildXfaTextContentItems(textDivs) { @@ -8865,18 +8886,18 @@ this.resume = null; if (this.textLayer && (!keepTextLayer || !this.textLayer.div)) { this.textLayer.cancel(); this.textLayer = null; } - if (this.structTreeLayer && !this.textLayer) { - this.structTreeLayer = null; - } if (this.annotationLayer && (!keepAnnotationLayer || !this.annotationLayer.div)) { this.annotationLayer.cancel(); this.annotationLayer = null; this._annotationCanvasMap = null; } + if (this.structTreeLayer && !(this.textLayer || this.annotationLayer)) { + this.structTreeLayer = null; + } if (this.annotationEditorLayer && (!keepAnnotationEditorLayer || !this.annotationEditorLayer.div)) { if (this.drawLayer) { this.drawLayer.cancel(); this.drawLayer = null; } @@ -9104,10 +9125,13 @@ const renderTask = this.renderTask = pdfPage.render(renderContext); renderTask.onContinue = renderContinueCallback; const resultPromise = renderTask.promise.then(async () => { showCanvas?.(true); await this.#finishRenderTask(renderTask); + if (this.textLayer || this.annotationLayer) { + this.structTreeLayer ||= new StructTreeLayerBuilder(pdfPage); + } this.#renderTextLayer(); if (this.annotationLayer) { await this.#renderAnnotationLayer(); } const { @@ -9119,24 +9143,22 @@ this.drawLayer ||= new DrawLayerBuilder({ pageIndex: this.id }); await this.#renderDrawLayer(); this.drawLayer.setParent(canvasWrapper); - if (!this.annotationEditorLayer) { - this.annotationEditorLayer = new AnnotationEditorLayerBuilder({ - uiManager: annotationEditorUIManager, - pdfPage, - l10n, - accessibilityManager: this._accessibilityManager, - annotationLayer: this.annotationLayer?.annotationLayer, - textLayer: this.textLayer, - drawLayer: this.drawLayer.getDrawLayer(), - onAppend: annotationEditorLayerDiv => { - this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); - } - }); - } + this.annotationEditorLayer ||= new AnnotationEditorLayerBuilder({ + uiManager: annotationEditorUIManager, + pdfPage, + l10n, + accessibilityManager: this._accessibilityManager, + annotationLayer: this.annotationLayer?.annotationLayer, + textLayer: this.textLayer, + drawLayer: this.drawLayer.getDrawLayer(), + onAppend: annotationEditorLayerDiv => { + this.#addLayer(annotationEditorLayerDiv, "annotationEditorLayer"); + } + }); this.#renderAnnotationEditorLayer(); }, error => { if (!(error instanceof RenderingCancelledException)) { showCanvas?.(true); } @@ -9272,11 +9294,11 @@ #resizeObserver = new ResizeObserver(this.#resizeObserverCallback.bind(this)); #scrollModePageState = null; #scaleTimeoutId = null; #textLayerMode = TextLayerMode.ENABLE; constructor(options) { - const viewerVersion = "4.6.58"; + const viewerVersion = "4.6.101"; if (version !== viewerVersion) { throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`); } this.container = options.container; this.viewer = options.viewer || options.container.firstElementChild; @@ -13448,12 +13470,12 @@ ;// CONCATENATED MODULE: ./web/viewer.js -const pdfjsVersion = "4.6.58"; -const pdfjsBuild = "a41cd3838"; +const pdfjsVersion = "4.6.101"; +const pdfjsBuild = "e3fd62d72"; const AppConstants = null; window.PDFViewerApplication = PDFViewerApplication; window.PDFViewerApplicationConstants = AppConstants; window.PDFViewerApplicationOptions = AppOptions; function getViewerConfiguration() { diff --git a/toolkit/components/pdfjs/moz.yaml b/toolkit/components/pdfjs/moz.yaml --- a/toolkit/components/pdfjs/moz.yaml +++ b/toolkit/components/pdfjs/moz.yaml @@ -18,12 +18,12 @@ # Usually different from repository url url: https://github.com/mozilla/pdf.js # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: a41cd38387d09244c2a0c2405765efc8b3e9bce5 (2024-08-28T20:18:21Z). - revision: a41cd38387d09244c2a0c2405765efc8b3e9bce5 + release: e3fd62d7267ff28b291d503ff93f0ad0bda96cc8 (2024-09-04T13:44:05Z). + revision: e3fd62d7267ff28b291d503ff93f0ad0bda96cc8 # The package's license, where possible using the mnemonic from # https://spdx.org/licenses/ # Multiple licenses can be specified (as a YAML list) # A "LICENSE" file must exist containing the full license text