Skip to content

Commit

Permalink
Slightly re-factor the transportFactory initialization in `getDocum…
Browse files Browse the repository at this point in the history
…ent`

Given that the `WorkerTransport`-constructor will access all possible factory-instances, let's ensure that the `transportFactory`-object always has a consistent shape regardless of other options.

Also, since `useWorkerFetch` is always true in MOZCENTRAL builds we never need to create `CMapReaderFactory`/`StandardFontDataFactory`-instances there.
  • Loading branch information
Snuffleupagus committed Sep 26, 2024
1 parent a128378 commit a989244
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,17 @@ function getDocument(src = {}) {
const transportFactory = {
canvasFactory: new CanvasFactory({ ownerDocument, enableHWA }),
filterFactory: new FilterFactory({ docId, ownerDocument }),
cMapReaderFactory:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
useWorkerFetch
? null
: new CMapReaderFactory({ baseUrl: cMapUrl, isCompressed: cMapPacked }),
standardFontDataFactory:
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
useWorkerFetch
? null
: new StandardFontDataFactory({ baseUrl: standardFontDataUrl }),
};
if (!useWorkerFetch) {
transportFactory.cMapReaderFactory = new CMapReaderFactory({
baseUrl: cMapUrl,
isCompressed: cMapPacked,
});
transportFactory.standardFontDataFactory = new StandardFontDataFactory({
baseUrl: standardFontDataUrl,
});
}

if (!worker) {
const workerParams = {
Expand Down

0 comments on commit a989244

Please sign in to comment.