commit 120f91ec1720a778340b67cd849eb637c453f05b
parent 2d38cd5bd7d7958137dd5b4f97aef2f7185a0eb1
Author: Calixte Denizet <calixte.denizet@gmail.com>
Date: Wed, 8 Oct 2025 16:34:21 +0000
Bug 1993268 - Update PDF.js to new version 8ba18075f2655361795a34930ea6cd4f7ac891c8 r=pdfjs-reviewers,marco
Differential Revision: https://phabricator.services.mozilla.com/D267975
Diffstat:
7 files changed, 89 insertions(+), 50 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.305
- * pdfjsBuild = f4104326f
+ * pdfjsVersion = 5.4.315
+ * pdfjsBuild = 8ba18075f
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -3688,7 +3688,7 @@ class AnnotationEditorUIManager {
setSelected(editor) {
this.updateToolbar({
mode: editor.mode,
- editId: editor.id
+ editId: editor.uid
});
this.#currentDrawingSession?.commitOrRemove();
for (const ed of this.#selectedEditors) {
@@ -6082,6 +6082,7 @@ class AnnotationEditor {
} else {
this._uiManager.removeEditor(this);
}
+ this.hideCommentPopup();
if (this.#moveInDOMTimeout) {
clearTimeout(this.#moveInDOMTimeout);
this.#moveInDOMTimeout = null;
@@ -6097,6 +6098,8 @@ class AnnotationEditor {
this.parent = null;
this.#touchManager?.destroy();
this.#touchManager = null;
+ this.#fakeAnnotation?.remove();
+ this.#fakeAnnotation = null;
}
get isResizable() {
return false;
@@ -6285,8 +6288,11 @@ class AnnotationEditor {
}
this._editToolbar?.hide();
this.#altText?.toggleAltTextBadge(true);
+ this.hideCommentPopup();
+ }
+ hideCommentPopup() {
if (this.hasComment) {
- this._uiManager.toggleComment(this, false, false);
+ this._uiManager.toggleComment(null);
}
}
updateParams(type, value) {}
@@ -6309,7 +6315,7 @@ class AnnotationEditor {
this.enterInEditMode();
this.parent.updateToolbar({
mode: this.constructor._editorType,
- editId: this.id
+ editId: this.uid
});
}
getElementForAltText() {
@@ -12788,7 +12794,7 @@ function getDocument(src = {}) {
}
const docParams = {
docId,
- apiVersion: "5.4.305",
+ apiVersion: "5.4.315",
data,
password,
disableAutoFetch,
@@ -14365,8 +14371,8 @@ class InternalRenderTask {
}
}
}
-const version = "5.4.305";
-const build = "f4104326f";
+const version = "5.4.315";
+const build = "8ba18075f";
;// ./src/display/editor/color_picker.js
@@ -14839,7 +14845,7 @@ class AnnotationElement {
this._fieldObjects = parameters.fieldObjects;
this.parent = parameters.parent;
if (isRenderable) {
- this.container = this._createContainer(ignoreBorder);
+ this.contentElement = this.container = this._createContainer(ignoreBorder);
}
if (createQuadrilaterals) {
this._createQuadrilaterals();
@@ -15566,6 +15572,7 @@ class LinkAnnotationElement extends AnnotationElement {
}
this.container.classList.add("linkAnnotation");
if (isBound) {
+ this.contentElement = link;
this.container.append(link);
}
return this.container;
@@ -15948,6 +15955,7 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
element.hidden = true;
}
GetElementsByNameSet.add(element);
+ this.contentElement = element;
element.setAttribute("data-element-id", id);
element.disabled = this.data.readOnly;
element.name = this.data.fieldName;
@@ -17279,7 +17287,7 @@ class FreeTextAnnotationElement extends AnnotationElement {
render() {
this.container.classList.add("freeTextAnnotation");
if (this.textContent) {
- const content = document.createElement("div");
+ const content = this.contentElement = document.createElement("div");
content.classList.add("annotationTextContent");
content.setAttribute("role", "comment");
for (const line of this.textContent) {
@@ -17826,7 +17834,10 @@ class AnnotationLayer {
return this.#editableAnnotations.size > 0;
}
async #appendElement(element, id, popupElements) {
- const contentElement = element.firstChild || element;
+ const {
+ contentElement,
+ container
+ } = element;
const annotationId = contentElement.id = `${AnnotationPrefix}${id}`;
const ariaAttributes = await this.#structTreeLayer?.getAriaAttributes(annotationId);
if (ariaAttributes) {
@@ -17835,12 +17846,21 @@ class AnnotationLayer {
}
}
if (popupElements) {
- popupElements.at(-1).container.after(element);
+ popupElements.at(-1).container.after(container);
} else {
- this.div.append(element);
- this.#accessibilityManager?.moveElementInDOM(this.div, element, contentElement, false);
+ this.#moveElementInDOM(container, contentElement);
}
}
+ #moveElementInDOM(container, contentElement) {
+ this.div.append(container);
+ this.#accessibilityManager?.moveElementInDOM(this.div, container, contentElement, false, node => node.nodeName === "SECTION", (prevNode, node) => {
+ if (prevNode.nextElementSibling.nodeName === "BUTTON") {
+ prevNode.nextElementSibling.after(node);
+ } else {
+ prevNode.after(node);
+ }
+ });
+ }
async render(params) {
const {
annotations
@@ -17897,7 +17917,7 @@ class AnnotationLayer {
if (data.hidden) {
rendered.style.visibility = "hidden";
}
- await this.#appendElement(rendered, data.id, elementParams.elements);
+ await this.#appendElement(element, data.id, elementParams.elements);
element.extraPopupElement?.popup?.renderCommentButton();
if (element._isEditable) {
this.#editableAnnotations.set(element.data.id, element);
@@ -17921,8 +17941,8 @@ class AnnotationLayer {
if (!element.isRenderable) {
continue;
}
- const rendered = element.render();
- await this.#appendElement(rendered, data.id, null);
+ element.render();
+ await this.#appendElement(element, data.id, null);
}
}
update({
@@ -17999,12 +18019,25 @@ class AnnotationLayer {
linkService: this.#linkService,
annotationStorage: this.#annotationStorage
});
- const htmlElement = element.render();
- div.append(htmlElement);
- this.#accessibilityManager?.moveElementInDOM(div, htmlElement, htmlElement, false);
+ const rendered = element.render();
+ rendered.id = `${AnnotationPrefix}${id}`;
+ this.#moveElementInDOM(rendered, rendered);
element.createOrUpdatePopup();
return element;
}
+ togglePointerEvents(enabled = false) {
+ this.div.classList.toggle("disabled", !enabled);
+ }
+ updateFakeAnnotations(editors) {
+ if (editors.length === 0) {
+ return;
+ }
+ window.requestAnimationFrame(() => setTimeout(() => {
+ for (const editor of editors) {
+ editor.updateFakeAnnotationElement(this);
+ }
+ }, 10));
+ }
static get _defaultBorderStyle() {
return shadow(this, "_defaultBorderStyle", Object.freeze({
width: 1,
@@ -23582,7 +23615,7 @@ class AnnotationEditorLayer {
this.div.classList.toggle("disabled", !enabled);
}
toggleAnnotationLayerPointerEvents(enabled = false) {
- this.#annotationLayer?.div.classList.toggle("disabled", !enabled);
+ this.#annotationLayer?.togglePointerEvents(enabled);
}
get #allEditorsIterator() {
return this.#editors.size !== 0 ? this.#editors.values() : this.#uiManager.getEditors(this.pageIndex);
@@ -23680,13 +23713,14 @@ class AnnotationEditorLayer {
});
}
const annotationLayer = this.#annotationLayer;
+ const needFakeAnnotation = [];
if (annotationLayer) {
const changedAnnotations = new Map();
const resetAnnotations = new Map();
for (const editor of this.#allEditorsIterator) {
editor.disableEditing();
if (!editor.annotationElementId) {
- editor.updateFakeAnnotationElement(annotationLayer);
+ needFakeAnnotation.push(editor);
continue;
}
if (editor.serialize() !== null) {
@@ -23738,6 +23772,7 @@ class AnnotationEditorLayer {
}
this.disableTextSelection();
this.toggleAnnotationLayerPointerEvents(true);
+ annotationLayer?.updateFakeAnnotations(needFakeAnnotation);
this.#isDisabling = false;
}
getEditableAnnotation(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.305
- * pdfjsBuild = f4104326f
+ * pdfjsVersion = 5.4.315
+ * pdfjsBuild = 8ba18075f
*/
var __webpack_exports__ = {};
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.305
- * pdfjsBuild = f4104326f
+ * pdfjsVersion = 5.4.315
+ * pdfjsBuild = 8ba18075f
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -58126,7 +58126,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
- const workerVersion = "5.4.305";
+ const workerVersion = "5.4.315";
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.mjs b/toolkit/components/pdfjs/content/web/viewer-geckoview.mjs
@@ -21,8 +21,8 @@
*/
/**
- * pdfjsVersion = 5.4.305
- * pdfjsBuild = f4104326f
+ * pdfjsVersion = 5.4.315
+ * pdfjsBuild = 8ba18075f
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -3290,6 +3290,7 @@ class CommentPopup {
}
});
this.#editor.comment = null;
+ this.#editor.focus();
this.destroy();
});
del.addEventListener("contextmenu", noContextMenu);
@@ -6940,20 +6941,21 @@ class TextAccessibilityManager {
const parent = child.parentNode;
return parent?.classList.contains("markedContent") ? parent.id : null;
}
- moveElementInDOM(container, element, contentElement, isRemovable) {
+ moveElementInDOM(container, element, contentElement, isRemovable, filter, inserter) {
const id = this.addPointerInTextLayer(contentElement, isRemovable);
if (!container.hasChildNodes()) {
container.append(element);
return id;
}
- const children = Array.from(container.childNodes).filter(node => node !== element);
+ const children = Array.from(container.childNodes).filter(node => node !== element && (!filter || filter(node)));
if (children.length === 0) {
return id;
}
- const elementToCompare = contentElement || element;
- const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
+ const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
if (index === 0) {
children[0].before(element);
+ } else if (inserter) {
+ inserter(children[index - 1], element);
} else {
children[index - 1].after(element);
}
@@ -8213,7 +8215,7 @@ class PDFViewer {
#textLayerMode = TextLayerMode.ENABLE;
#viewerAlert = null;
constructor(options) {
- const viewerVersion = "5.4.305";
+ const viewerVersion = "5.4.315";
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.html b/toolkit/components/pdfjs/content/web/viewer.html
@@ -182,9 +182,9 @@ See https://github.com/adobe-type-tools/cmap-resources
</span>
</div>
<div id="toolbarViewerRight" class="toolbarHorizontalGroup">
- <div id="editorModeButtons" class="toolbarHorizontalGroup" role="radiogroup">
+ <div id="editorModeButtons" class="toolbarHorizontalGroup">
<div id="editorComment" class="toolbarButtonWithContainer" hidden="true">
- <button id="editorCommentButton" class="toolbarButton" type="button" tabindex="0" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorCommentParamsToolbar" data-l10n-id="pdfjs-editor-comment-button">
+ <button id="editorCommentButton" class="toolbarButton" type="button" tabindex="0" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorCommentParamsToolbar" data-l10n-id="pdfjs-editor-comment-button">
<span data-l10n-id="pdfjs-editor-comment-button-label"></span>
</button>
<div class="editorParamsToolbar hidden menu" id="editorCommentParamsToolbar">
@@ -206,7 +206,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<div id="editorSignature" class="toolbarButtonWithContainer" hidden="true">
- <button id="editorSignatureButton" class="toolbarButton" type="button" tabindex="0" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorSignatureParamsToolbar" data-l10n-id="pdfjs-editor-signature-button">
+ <button id="editorSignatureButton" class="toolbarButton" type="button" tabindex="0" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorSignatureParamsToolbar" data-l10n-id="pdfjs-editor-signature-button">
<span data-l10n-id="pdfjs-editor-signature-button-label"></span>
</button>
<div class="editorParamsToolbar hidden doorHangerRight menu" id="editorSignatureParamsToolbar">
@@ -218,7 +218,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<div id="editorHighlight" class="toolbarButtonWithContainer">
- <button id="editorHighlightButton" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorHighlightParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-highlight-button">
+ <button id="editorHighlightButton" class="toolbarButton" type="button" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorHighlightParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-highlight-button">
<span data-l10n-id="pdfjs-editor-highlight-button-label"></span>
</button>
<div class="editorParamsToolbar hidden doorHangerRight" id="editorHighlightParamsToolbar">
@@ -243,7 +243,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<div id="editorFreeText" class="toolbarButtonWithContainer">
- <button id="editorFreeTextButton" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorFreeTextParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-free-text-button">
+ <button id="editorFreeTextButton" class="toolbarButton" type="button" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorFreeTextParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-free-text-button">
<span data-l10n-id="pdfjs-editor-free-text-button-label"></span>
</button>
<div class="editorParamsToolbar hidden doorHangerRight" id="editorFreeTextParamsToolbar">
@@ -260,7 +260,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<div id="editorInk" class="toolbarButtonWithContainer">
- <button id="editorInkButton" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorInkParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-ink-button">
+ <button id="editorInkButton" class="toolbarButton" type="button" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorInkParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-ink-button">
<span data-l10n-id="pdfjs-editor-ink-button-label"></span>
</button>
<div class="editorParamsToolbar hidden doorHangerRight" id="editorInkParamsToolbar">
@@ -281,7 +281,7 @@ See https://github.com/adobe-type-tools/cmap-resources
</div>
</div>
<div id="editorStamp" class="toolbarButtonWithContainer">
- <button id="editorStampButton" class="toolbarButton" type="button" disabled="disabled" role="radio" aria-expanded="false" aria-haspopup="true" aria-controls="editorStampParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-stamp-button">
+ <button id="editorStampButton" class="toolbarButton" type="button" disabled="disabled" aria-expanded="false" aria-haspopup="true" aria-controls="editorStampParamsToolbar" tabindex="0" data-l10n-id="pdfjs-editor-stamp-button">
<span data-l10n-id="pdfjs-editor-stamp-button-label"></span>
</button>
<div class="editorParamsToolbar hidden doorHangerRight menu" id="editorStampParamsToolbar">
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.305
- * pdfjsBuild = f4104326f
+ * pdfjsVersion = 5.4.315
+ * pdfjsBuild = 8ba18075f
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -4137,6 +4137,7 @@ class CommentPopup {
}
});
this.#editor.comment = null;
+ this.#editor.focus();
this.destroy();
});
del.addEventListener("contextmenu", noContextMenu);
@@ -10125,20 +10126,21 @@ class TextAccessibilityManager {
const parent = child.parentNode;
return parent?.classList.contains("markedContent") ? parent.id : null;
}
- moveElementInDOM(container, element, contentElement, isRemovable) {
+ moveElementInDOM(container, element, contentElement, isRemovable, filter, inserter) {
const id = this.addPointerInTextLayer(contentElement, isRemovable);
if (!container.hasChildNodes()) {
container.append(element);
return id;
}
- const children = Array.from(container.childNodes).filter(node => node !== element);
+ const children = Array.from(container.childNodes).filter(node => node !== element && (!filter || filter(node)));
if (children.length === 0) {
return id;
}
- const elementToCompare = contentElement || element;
- const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(elementToCompare, node) < 0);
+ const index = binarySearchFirstItem(children, node => TextAccessibilityManager.#compareElementPositions(element, node) < 0);
if (index === 0) {
children[0].before(element);
+ } else if (inserter) {
+ inserter(children[index - 1], element);
} else {
children[index - 1].after(element);
}
@@ -11398,7 +11400,7 @@ class PDFViewer {
#textLayerMode = TextLayerMode.ENABLE;
#viewerAlert = null;
constructor(options) {
- const viewerVersion = "5.4.305";
+ const viewerVersion = "5.4.315";
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: f4104326f3aa6d09e95e446af179772b2231d739 (2025-10-05T18:24:02Z).
- revision: f4104326f3aa6d09e95e446af179772b2231d739
+ release: 8ba18075f2655361795a34930ea6cd4f7ac891c8 (2025-10-08T14:55:01Z).
+ revision: 8ba18075f2655361795a34930ea6cd4f7ac891c8
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/