1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Improve the loadingParams functionality in the API

- Move the definition of the `loadingParams` Object, to simplify the code.

 - Add a unit-test, since none existed and the viewer depends on this functionality.
This commit is contained in:
Jonas Jenwald 2024-05-24 09:18:19 +02:00
parent 08bf96865d
commit 06334c97ef
2 changed files with 22 additions and 10 deletions

View file

@ -386,11 +386,13 @@ function getDocument(src) {
const transportParams = {
disableFontFace,
fontExtraProperties,
enableXfa,
ownerDocument,
disableAutoFetch,
pdfBug,
styleElement,
loadingParams: {
disableAutoFetch,
enableXfa,
},
};
worker.promise
@ -2364,6 +2366,7 @@ class WorkerTransport {
ownerDocument: params.ownerDocument,
styleElement: params.styleElement,
});
this.loadingParams = params.loadingParams;
this._params = params;
this.canvasFactory = factory.canvasFactory;
@ -3095,14 +3098,6 @@ class WorkerTransport {
const refStr = ref.gen === 0 ? `${ref.num}R` : `${ref.num}R${ref.gen}`;
return this.#pageRefCache.get(refStr) ?? null;
}
get loadingParams() {
const { disableAutoFetch, enableXfa } = this._params;
return shadow(this, "loadingParams", {
disableAutoFetch,
enableXfa,
});
}
}
const INITIAL_DATA = Symbol("INITIAL_DATA");