commit 5c91a7fca3b13088861b62385d20e3d08a57c049
parent 5096c7c9bba153ee864c194652329f946491e4d7
Author: Calixte Denizet <calixte.denizet@gmail.com>
Date: Tue, 4 Nov 2025 13:18:10 +0000
Bug 1997795 - Update PDF.js to new version 0a2680bca627243d157e18a52189cc19b635993e r=pdfjs-reviewers,marco
Differential Revision: https://phabricator.services.mozilla.com/D271189
Diffstat:
6 files changed, 192 insertions(+), 105 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.385
- * pdfjsBuild = 7fc5706e1
+ * pdfjsVersion = 5.4.396
+ * pdfjsBuild = 0a2680bca
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -2158,6 +2158,54 @@ function bindEvents(obj, element, names) {
element.addEventListener(name, obj[name].bind(obj));
}
}
+class CurrentPointers {
+ static #pointerId = NaN;
+ static #pointerIds = null;
+ static #moveTimestamp = NaN;
+ static #pointerType = null;
+ static initializeAndAddPointerId(pointerId) {
+ (CurrentPointers.#pointerIds ||= new Set()).add(pointerId);
+ }
+ static setPointer(pointerType, pointerId) {
+ CurrentPointers.#pointerId ||= pointerId;
+ CurrentPointers.#pointerType ??= pointerType;
+ }
+ static setTimeStamp(timeStamp) {
+ CurrentPointers.#moveTimestamp = timeStamp;
+ }
+ static isSamePointerId(pointerId) {
+ return CurrentPointers.#pointerId === pointerId;
+ }
+ static isSamePointerIdOrRemove(pointerId) {
+ if (CurrentPointers.#pointerId === pointerId) {
+ return true;
+ }
+ CurrentPointers.#pointerIds?.delete(pointerId);
+ return false;
+ }
+ static isSamePointerType(pointerType) {
+ return CurrentPointers.#pointerType === pointerType;
+ }
+ static isInitializedAndDifferentPointerType(pointerType) {
+ return CurrentPointers.#pointerType !== null && !CurrentPointers.isSamePointerType(pointerType);
+ }
+ static isSameTimeStamp(timeStamp) {
+ return CurrentPointers.#moveTimestamp === timeStamp;
+ }
+ static isUsingMultiplePointers() {
+ return CurrentPointers.#pointerIds?.size >= 1;
+ }
+ static clearPointerType() {
+ CurrentPointers.#pointerType = null;
+ }
+ static clearPointerIds() {
+ CurrentPointers.#pointerId = NaN;
+ CurrentPointers.#pointerIds = null;
+ }
+ static clearTimeStamp() {
+ CurrentPointers.#moveTimestamp = NaN;
+ }
+}
class IdManager {
#id = 0;
get id() {
@@ -13035,7 +13083,7 @@ function getDocument(src = {}) {
}
const docParams = {
docId,
- apiVersion: "5.4.385",
+ apiVersion: "5.4.396",
data,
password,
disableAutoFetch,
@@ -14615,8 +14663,8 @@ class InternalRenderTask {
}
}
}
-const version = "5.4.385";
-const build = "7fc5706e1";
+const version = "5.4.396";
+const build = "0a2680bca";
;// ./src/display/editor/color_picker.js
@@ -20603,6 +20651,7 @@ class HighlightEditor extends AnnotationEditor {
+
class DrawingOptions {
#svgProperties = Object.create(null);
updateProperty(name, value) {
@@ -20649,10 +20698,6 @@ class DrawingEditor extends AnnotationEditor {
static #currentDraw = null;
static #currentDrawingAC = null;
static #currentDrawingOptions = null;
- static #currentPointerId = NaN;
- static #currentPointerType = null;
- static #currentPointerIds = null;
- static #currentMoveTimestamp = NaN;
static _INNER_MARGIN = 3;
constructor(params) {
super(params);
@@ -21031,7 +21076,7 @@ class DrawingEditor extends AnnotationEditor {
pointerId,
pointerType
} = event;
- if (DrawingEditor.#currentPointerType && DrawingEditor.#currentPointerType !== pointerType) {
+ if (CurrentPointers.isInitializedAndDifferentPointerType(pointerType)) {
return;
}
const {
@@ -21045,31 +21090,26 @@ class DrawingEditor extends AnnotationEditor {
} = target.getBoundingClientRect();
const ac = DrawingEditor.#currentDrawingAC = new AbortController();
const signal = parent.combinedSignal(ac);
- DrawingEditor.#currentPointerId ||= pointerId;
- DrawingEditor.#currentPointerType ??= pointerType;
+ CurrentPointers.setPointer(pointerType, pointerId);
window.addEventListener("pointerup", e => {
- if (DrawingEditor.#currentPointerId === e.pointerId) {
+ if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {
this._endDraw(e);
- } else {
- DrawingEditor.#currentPointerIds?.delete(e.pointerId);
}
}, {
signal
});
window.addEventListener("pointercancel", e => {
- if (DrawingEditor.#currentPointerId === e.pointerId) {
+ if (CurrentPointers.isSamePointerIdOrRemove(e.pointerId)) {
this._currentParent.endDrawingSession();
- } else {
- DrawingEditor.#currentPointerIds?.delete(e.pointerId);
}
}, {
signal
});
window.addEventListener("pointerdown", e => {
- if (DrawingEditor.#currentPointerType !== e.pointerType) {
+ if (!CurrentPointers.isSamePointerType(e.pointerType)) {
return;
}
- (DrawingEditor.#currentPointerIds ||= new Set()).add(e.pointerId);
+ CurrentPointers.initializeAndAddPointerId(e.pointerId);
if (DrawingEditor.#currentDraw.isCancellable()) {
DrawingEditor.#currentDraw.removeLastElement();
if (DrawingEditor.#currentDraw.isEmpty()) {
@@ -21090,7 +21130,7 @@ class DrawingEditor extends AnnotationEditor {
signal
});
target.addEventListener("touchmove", e => {
- if (e.timeStamp === DrawingEditor.#currentMoveTimestamp) {
+ if (CurrentPointers.isSameTimeStamp(e.timeStamp)) {
stopEvent(e);
}
}, {
@@ -21111,7 +21151,7 @@ class DrawingEditor extends AnnotationEditor {
} = parent.drawLayer.draw(this._mergeSVGProperties(DrawingEditor.#currentDrawingOptions.toSVGProperties(), DrawingEditor.#currentDraw.defaultSVGProperties), true, false));
}
static _drawMove(event) {
- DrawingEditor.#currentMoveTimestamp = -1;
+ CurrentPointers.isSameTimeStamp(event.timeStamp);
if (!DrawingEditor.#currentDraw) {
return;
}
@@ -21120,15 +21160,15 @@ class DrawingEditor extends AnnotationEditor {
offsetY,
pointerId
} = event;
- if (DrawingEditor.#currentPointerId !== pointerId) {
+ if (!CurrentPointers.isSamePointerId(pointerId)) {
return;
}
- if (DrawingEditor.#currentPointerIds?.size >= 1) {
+ if (CurrentPointers.isUsingMultiplePointers()) {
this._endDraw(event);
return;
}
this._currentParent.drawLayer.updateProperties(this._currentDrawId, DrawingEditor.#currentDraw.add(offsetX, offsetY));
- DrawingEditor.#currentMoveTimestamp = event.timeStamp;
+ CurrentPointers.setTimeStamp(event.timeStamp);
stopEvent(event);
}
static _cleanup(all) {
@@ -21137,14 +21177,13 @@ class DrawingEditor extends AnnotationEditor {
this._currentParent = null;
DrawingEditor.#currentDraw = null;
DrawingEditor.#currentDrawingOptions = null;
- DrawingEditor.#currentPointerType = null;
- DrawingEditor.#currentMoveTimestamp = NaN;
+ CurrentPointers.clearPointerType();
+ CurrentPointers.clearTimeStamp();
}
if (DrawingEditor.#currentDrawingAC) {
DrawingEditor.#currentDrawingAC.abort();
DrawingEditor.#currentDrawingAC = null;
- DrawingEditor.#currentPointerId = NaN;
- DrawingEditor.#currentPointerIds = null;
+ CurrentPointers.clearPointerIds();
}
}
static _endDraw(event) {
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.385
- * pdfjsBuild = 7fc5706e1
+ * pdfjsVersion = 5.4.396
+ * pdfjsBuild = 0a2680bca
*/
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.385
- * pdfjsBuild = 7fc5706e1
+ * pdfjsVersion = 5.4.396
+ * pdfjsBuild = 0a2680bca
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -37587,7 +37587,7 @@ class StructElementNode {
if (!isName(fileStream.dict.get("Subtype"), "application/mathml+xml")) {
continue;
}
- return fileStream.getString();
+ return stringToUTF8String(fileStream.getString());
}
const A = this.dict.get("A");
if (A instanceof Dict) {
@@ -56626,40 +56626,6 @@ class PDFDocument {
return isSignature && isInvisible;
});
}
- #collectSignatureCertificates(fields, collectedSignatureCertificates, visited = new RefSet()) {
- if (!Array.isArray(fields)) {
- return;
- }
- for (let field of fields) {
- if (field instanceof Ref) {
- if (visited.has(field)) {
- continue;
- }
- visited.put(field);
- }
- field = this.xref.fetchIfRef(field);
- if (!(field instanceof Dict)) {
- continue;
- }
- if (field.has("Kids")) {
- this.#collectSignatureCertificates(field.get("Kids"), collectedSignatureCertificates, visited);
- continue;
- }
- const isSignature = isName(field.get("FT"), "Sig");
- if (!isSignature) {
- continue;
- }
- const value = field.get("V");
- if (!(value instanceof Dict)) {
- continue;
- }
- const subFilter = value.get("SubFilter");
- if (!(subFilter instanceof Name)) {
- continue;
- }
- collectedSignatureCertificates.add(subFilter.name);
- }
- }
get _xfaStreams() {
const {
acroForm
@@ -56906,13 +56872,6 @@ class PDFDocument {
formInfo.hasXfa = Array.isArray(xfa) && xfa.length > 0 || xfa instanceof BaseStream && !xfa.isEmpty;
const sigFlags = acroForm.get("SigFlags");
const hasSignatures = !!(sigFlags & 0x1);
- if (hasSignatures) {
- const collectedSignatureCertificates = new Set();
- this.#collectSignatureCertificates(fields, collectedSignatureCertificates);
- if (collectedSignatureCertificates.size > 0) {
- formInfo.collectedSignatureCertificates = Array.from(collectedSignatureCertificates);
- }
- }
const hasOnlyDocumentSignatures = hasSignatures && this.#hasOnlyDocumentSignatures(fields);
formInfo.hasAcroForm = hasFields && !hasOnlyDocumentSignatures;
formInfo.hasSignatures = hasSignatures;
@@ -56940,7 +56899,6 @@ class PDFDocument {
IsCollectionPresent: !!catalog.collection,
IsSignaturesPresent: formInfo.hasSignatures
};
- docInfo.collectedSignatureCertificates = formInfo.collectedSignatureCertificates ?? null;
let infoDict;
try {
infoDict = xref.trailer.get("Info");
@@ -58449,7 +58407,7 @@ class WorkerMessageHandler {
docId,
apiVersion
} = docParams;
- const workerVersion = "5.4.385";
+ const workerVersion = "5.4.396";
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.385
- * pdfjsBuild = 7fc5706e1
+ * pdfjsVersion = 5.4.396
+ * pdfjsBuild = 0a2680bca
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -1462,6 +1462,7 @@ class BaseExternalServices {
updateFindMatchesCount(data) {}
initPassiveLoading() {}
reportTelemetry(data) {}
+ reportText(data) {}
async createL10n() {
throw new Error("Not implemented: createL10n");
}
@@ -2209,6 +2210,9 @@ class ExternalServices extends BaseExternalServices {
reportTelemetry(data) {
FirefoxCom.request("reportTelemetry", data);
}
+ reportText(data) {
+ FirefoxCom.request("reportText", data);
+ }
updateEditorStates(data) {
FirefoxCom.request("updateEditorStates", data);
}
@@ -5718,6 +5722,51 @@ class PDFScriptingManager {
}
}
+;// ./web/pdf_text_extractor.js
+class PdfTextExtractor {
+ #pdfViewer;
+ #externalServices;
+ #textPromise;
+ #pendingRequests = new Set();
+ constructor(externalServices) {
+ this.#externalServices = externalServices;
+ window.addEventListener("requestTextContent", ({
+ detail
+ }) => {
+ this.extractTextContent(detail.requestId);
+ });
+ }
+ setViewer(pdfViewer) {
+ this.#pdfViewer = pdfViewer;
+ if (this.#pdfViewer && this.#pendingRequests.size) {
+ for (const pendingRequest of this.#pendingRequests) {
+ this.extractTextContent(pendingRequest);
+ }
+ this.#pendingRequests.clear();
+ }
+ }
+ async extractTextContent(requestId) {
+ if (!this.#pdfViewer) {
+ this.#pendingRequests.add(requestId);
+ return;
+ }
+ if (!this.#textPromise) {
+ const textPromise = this.#textPromise = this.#pdfViewer.getAllText();
+ textPromise.then(() => {
+ setTimeout(() => {
+ if (this.#textPromise === textPromise) {
+ this.#textPromise = null;
+ }
+ }, 5000);
+ });
+ }
+ this.#externalServices.reportText({
+ text: await this.#textPromise,
+ requestId
+ });
+ }
+}
+
;// ./web/annotation_editor_layer_builder.js
@@ -6671,10 +6720,7 @@ class MathMLSanitizer {
name: "maction",
namespace: MathMLNamespace
}],
- attributes: ["dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "scriptlevel", "encoding", "display", "linethickness", "intent", "arg", "form", "fence", "separator", "lspace", "rspace", "stretchy", "symmetric", "maxsize", "minsize", "largeop", "movablelimits", "width", "height", "depth", "voffset", "accent", "accentunder", "columnspan", "rowspan"].map(name => ({
- name,
- namespace: MathMLNamespace
- })),
+ attributes: ["dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "scriptlevel", "encoding", "display", "linethickness", "intent", "arg", "form", "fence", "separator", "lspace", "rspace", "stretchy", "symmetric", "maxsize", "minsize", "largeop", "movablelimits", "width", "height", "depth", "voffset", "accent", "accentunder", "columnspan", "rowspan"],
comments: false
}) : null);
}
@@ -8254,7 +8300,7 @@ class PDFViewer {
#textLayerMode = TextLayerMode.ENABLE;
#viewerAlert = null;
constructor(options) {
- const viewerVersion = "5.4.385";
+ const viewerVersion = "5.4.396";
if (version !== viewerVersion) {
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
}
@@ -9972,6 +10018,7 @@ class ViewHistory {
+
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
const ViewOnLoad = {
UNKNOWN: -1,
@@ -9994,6 +10041,7 @@ const PDFViewerApplication = {
pdfPresentationMode: null,
pdfDocumentProperties: null,
pdfLinkService: null,
+ pdfTextExtractor: null,
pdfHistory: null,
pdfSidebar: null,
pdfOutlineViewer: null,
@@ -10074,6 +10122,7 @@ const PDFViewerApplication = {
AppOptions.set("externalLinkTarget", LinkTarget.TOP);
}
await this._initializeViewerComponents();
+ this.pdfTextExtractor = new PdfTextExtractor(this.externalServices);
this.bindEvents();
this.bindWindowEvents();
this._initializedCapability.settled = true;
@@ -10571,6 +10620,7 @@ const PDFViewerApplication = {
this.pdfViewer.setDocument(null);
this.pdfLinkService.setDocument(null);
this.pdfDocumentProperties?.setDocument(null);
+ this.pdfTextExtractor?.setViewer(null);
}
this.pdfLinkService.externalLinkEnabled = true;
this.store = null;
@@ -10761,6 +10811,7 @@ const PDFViewerApplication = {
this.pdfDocumentProperties?.setDocument(pdfDocument);
const pdfViewer = this.pdfViewer;
pdfViewer.setDocument(pdfDocument);
+ this.pdfTextExtractor.setViewer(pdfViewer);
const {
firstPagePromise,
onePageRendered,
@@ -10959,12 +11010,6 @@ const PDFViewerApplication = {
if (pdfDocument !== this.pdfDocument) {
return;
}
- if (info.collectedSignatureCertificates) {
- this.externalServices.reportTelemetry({
- type: "signatureCertificates",
- data: info.collectedSignatureCertificates
- });
- }
this.documentInfo = info;
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;
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.385
- * pdfjsBuild = 7fc5706e1
+ * pdfjsVersion = 5.4.396
+ * pdfjsBuild = 0a2680bca
*/
/******/ // The require scope
/******/ var __webpack_require__ = {};
@@ -1462,6 +1462,7 @@ class BaseExternalServices {
updateFindMatchesCount(data) {}
initPassiveLoading() {}
reportTelemetry(data) {}
+ reportText(data) {}
async createL10n() {
throw new Error("Not implemented: createL10n");
}
@@ -2174,6 +2175,9 @@ class ExternalServices extends BaseExternalServices {
reportTelemetry(data) {
FirefoxCom.request("reportTelemetry", data);
}
+ reportText(data) {
+ FirefoxCom.request("reportText", data);
+ }
updateEditorStates(data) {
FirefoxCom.request("updateEditorStates", data);
}
@@ -8378,6 +8382,51 @@ class PDFSidebar {
}
}
+;// ./web/pdf_text_extractor.js
+class PdfTextExtractor {
+ #pdfViewer;
+ #externalServices;
+ #textPromise;
+ #pendingRequests = new Set();
+ constructor(externalServices) {
+ this.#externalServices = externalServices;
+ window.addEventListener("requestTextContent", ({
+ detail
+ }) => {
+ this.extractTextContent(detail.requestId);
+ });
+ }
+ setViewer(pdfViewer) {
+ this.#pdfViewer = pdfViewer;
+ if (this.#pdfViewer && this.#pendingRequests.size) {
+ for (const pendingRequest of this.#pendingRequests) {
+ this.extractTextContent(pendingRequest);
+ }
+ this.#pendingRequests.clear();
+ }
+ }
+ async extractTextContent(requestId) {
+ if (!this.#pdfViewer) {
+ this.#pendingRequests.add(requestId);
+ return;
+ }
+ if (!this.#textPromise) {
+ const textPromise = this.#textPromise = this.#pdfViewer.getAllText();
+ textPromise.then(() => {
+ setTimeout(() => {
+ if (this.#textPromise === textPromise) {
+ this.#textPromise = null;
+ }
+ }, 5000);
+ });
+ }
+ this.#externalServices.reportText({
+ text: await this.#textPromise,
+ requestId
+ });
+ }
+}
+
;// ./web/pdf_thumbnail_view.js
@@ -9856,10 +9905,7 @@ class MathMLSanitizer {
name: "maction",
namespace: MathMLNamespace
}],
- attributes: ["dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "scriptlevel", "encoding", "display", "linethickness", "intent", "arg", "form", "fence", "separator", "lspace", "rspace", "stretchy", "symmetric", "maxsize", "minsize", "largeop", "movablelimits", "width", "height", "depth", "voffset", "accent", "accentunder", "columnspan", "rowspan"].map(name => ({
- name,
- namespace: MathMLNamespace
- })),
+ attributes: ["dir", "displaystyle", "mathbackground", "mathcolor", "mathsize", "scriptlevel", "encoding", "display", "linethickness", "intent", "arg", "form", "fence", "separator", "lspace", "rspace", "stretchy", "symmetric", "maxsize", "minsize", "largeop", "movablelimits", "width", "height", "depth", "voffset", "accent", "accentunder", "columnspan", "rowspan"],
comments: false
}) : null);
}
@@ -11439,7 +11485,7 @@ class PDFViewer {
#textLayerMode = TextLayerMode.ENABLE;
#viewerAlert = null;
constructor(options) {
- const viewerVersion = "5.4.385";
+ const viewerVersion = "5.4.396";
if (version !== viewerVersion) {
throw new Error(`The API version "${version}" does not match the Viewer version "${viewerVersion}".`);
}
@@ -14609,6 +14655,7 @@ class ViewHistory {
+
const FORCE_PAGES_LOADED_TIMEOUT = 10000;
const ViewOnLoad = {
UNKNOWN: -1,
@@ -14631,6 +14678,7 @@ const PDFViewerApplication = {
pdfPresentationMode: null,
pdfDocumentProperties: null,
pdfLinkService: null,
+ pdfTextExtractor: null,
pdfHistory: null,
pdfSidebar: null,
pdfOutlineViewer: null,
@@ -14711,6 +14759,7 @@ const PDFViewerApplication = {
AppOptions.set("externalLinkTarget", LinkTarget.TOP);
}
await this._initializeViewerComponents();
+ this.pdfTextExtractor = new PdfTextExtractor(this.externalServices);
this.bindEvents();
this.bindWindowEvents();
this._initializedCapability.settled = true;
@@ -15207,6 +15256,7 @@ const PDFViewerApplication = {
this.pdfViewer.setDocument(null);
this.pdfLinkService.setDocument(null);
this.pdfDocumentProperties?.setDocument(null);
+ this.pdfTextExtractor?.setViewer(null);
}
this.pdfLinkService.externalLinkEnabled = true;
this.store = null;
@@ -15397,6 +15447,7 @@ const PDFViewerApplication = {
this.pdfDocumentProperties?.setDocument(pdfDocument);
const pdfViewer = this.pdfViewer;
pdfViewer.setDocument(pdfDocument);
+ this.pdfTextExtractor.setViewer(pdfViewer);
const {
firstPagePromise,
onePageRendered,
@@ -15595,12 +15646,6 @@ const PDFViewerApplication = {
if (pdfDocument !== this.pdfDocument) {
return;
}
- if (info.collectedSignatureCertificates) {
- this.externalServices.reportTelemetry({
- type: "signatureCertificates",
- data: info.collectedSignatureCertificates
- });
- }
this.documentInfo = info;
this.metadata = metadata;
this._contentDispositionFilename ??= contentDispositionFilename;
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: 7fc5706e16ad76e04b66257882764caa2c9db7bd (2025-10-29T20:09:52Z).
- revision: 7fc5706e16ad76e04b66257882764caa2c9db7bd
+ release: 0a2680bca627243d157e18a52189cc19b635993e (2025-11-02T12:14:45Z).
+ revision: 0a2680bca627243d157e18a52189cc19b635993e
# The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/