Merge pull request #19720 from Snuffleupagus/_initializeViewerComponents-shorten
Shorten the `PDFViewerApplication._initializeViewerComponents` method
This commit is contained in:
commit
cb818ce0d3
69
web/app.js
69
web/app.js
@ -396,38 +396,35 @@ const PDFViewerApplication = {
|
|||||||
this.eventBus = AppOptions.eventBus = eventBus;
|
this.eventBus = AppOptions.eventBus = eventBus;
|
||||||
mlManager?.setEventBus(eventBus, abortSignal);
|
mlManager?.setEventBus(eventBus, abortSignal);
|
||||||
|
|
||||||
this.overlayManager = new OverlayManager();
|
const overlayManager = (this.overlayManager = new OverlayManager());
|
||||||
|
|
||||||
const pdfRenderingQueue = new PDFRenderingQueue();
|
const renderingQueue = (this.pdfRenderingQueue = new PDFRenderingQueue());
|
||||||
pdfRenderingQueue.onIdle = this._cleanup.bind(this);
|
renderingQueue.onIdle = this._cleanup.bind(this);
|
||||||
this.pdfRenderingQueue = pdfRenderingQueue;
|
|
||||||
|
|
||||||
const pdfLinkService = new PDFLinkService({
|
const linkService = (this.pdfLinkService = new PDFLinkService({
|
||||||
eventBus,
|
eventBus,
|
||||||
externalLinkTarget: AppOptions.get("externalLinkTarget"),
|
externalLinkTarget: AppOptions.get("externalLinkTarget"),
|
||||||
externalLinkRel: AppOptions.get("externalLinkRel"),
|
externalLinkRel: AppOptions.get("externalLinkRel"),
|
||||||
ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom"),
|
ignoreDestinationZoom: AppOptions.get("ignoreDestinationZoom"),
|
||||||
});
|
}));
|
||||||
this.pdfLinkService = pdfLinkService;
|
|
||||||
|
|
||||||
const downloadManager = (this.downloadManager = new DownloadManager());
|
const downloadManager = (this.downloadManager = new DownloadManager());
|
||||||
|
|
||||||
const findController = new PDFFindController({
|
const findController = (this.findController = new PDFFindController({
|
||||||
linkService: pdfLinkService,
|
linkService,
|
||||||
eventBus,
|
eventBus,
|
||||||
updateMatchesCountOnProgress:
|
updateMatchesCountOnProgress:
|
||||||
typeof PDFJSDev === "undefined"
|
typeof PDFJSDev === "undefined"
|
||||||
? !window.isGECKOVIEW
|
? !window.isGECKOVIEW
|
||||||
: !PDFJSDev.test("GECKOVIEW"),
|
: !PDFJSDev.test("GECKOVIEW"),
|
||||||
});
|
}));
|
||||||
this.findController = findController;
|
|
||||||
|
|
||||||
const pdfScriptingManager = new PDFScriptingManager({
|
const pdfScriptingManager = (this.pdfScriptingManager =
|
||||||
eventBus,
|
new PDFScriptingManager({
|
||||||
externalServices,
|
eventBus,
|
||||||
docProperties: this._scriptingDocProperties.bind(this),
|
externalServices,
|
||||||
});
|
docProperties: this._scriptingDocProperties.bind(this),
|
||||||
this.pdfScriptingManager = pdfScriptingManager;
|
}));
|
||||||
|
|
||||||
const container = appConfig.mainContainer,
|
const container = appConfig.mainContainer,
|
||||||
viewer = appConfig.viewerContainer;
|
viewer = appConfig.viewerContainer;
|
||||||
@ -440,12 +437,13 @@ const PDFViewerApplication = {
|
|||||||
foreground: AppOptions.get("pageColorsForeground"),
|
foreground: AppOptions.get("pageColorsForeground"),
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
let altTextManager;
|
let altTextManager;
|
||||||
if (AppOptions.get("enableUpdatedAddImage")) {
|
if (AppOptions.get("enableUpdatedAddImage")) {
|
||||||
altTextManager = appConfig.newAltTextDialog
|
altTextManager = appConfig.newAltTextDialog
|
||||||
? new NewAltTextManager(
|
? new NewAltTextManager(
|
||||||
appConfig.newAltTextDialog,
|
appConfig.newAltTextDialog,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
eventBus
|
eventBus
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
@ -454,7 +452,7 @@ const PDFViewerApplication = {
|
|||||||
? new AltTextManager(
|
? new AltTextManager(
|
||||||
appConfig.altTextDialog,
|
appConfig.altTextDialog,
|
||||||
container,
|
container,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
eventBus
|
eventBus
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
@ -471,7 +469,7 @@ const PDFViewerApplication = {
|
|||||||
appConfig.editSignatureDialog,
|
appConfig.editSignatureDialog,
|
||||||
appConfig.annotationEditorParams?.editorSignatureAddSignature ||
|
appConfig.annotationEditorParams?.editorSignatureAddSignature ||
|
||||||
null,
|
null,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
l10n,
|
l10n,
|
||||||
externalServices.createSignatureStorage(eventBus, abortSignal),
|
externalServices.createSignatureStorage(eventBus, abortSignal),
|
||||||
eventBus
|
eventBus
|
||||||
@ -481,12 +479,12 @@ const PDFViewerApplication = {
|
|||||||
const enableHWA = AppOptions.get("enableHWA"),
|
const enableHWA = AppOptions.get("enableHWA"),
|
||||||
maxCanvasPixels = AppOptions.get("maxCanvasPixels"),
|
maxCanvasPixels = AppOptions.get("maxCanvasPixels"),
|
||||||
maxCanvasDim = AppOptions.get("maxCanvasDim");
|
maxCanvasDim = AppOptions.get("maxCanvasDim");
|
||||||
const pdfViewer = new PDFViewer({
|
const pdfViewer = (this.pdfViewer = new PDFViewer({
|
||||||
container,
|
container,
|
||||||
viewer,
|
viewer,
|
||||||
eventBus,
|
eventBus,
|
||||||
renderingQueue: pdfRenderingQueue,
|
renderingQueue,
|
||||||
linkService: pdfLinkService,
|
linkService,
|
||||||
downloadManager,
|
downloadManager,
|
||||||
altTextManager,
|
altTextManager,
|
||||||
signatureManager,
|
signatureManager,
|
||||||
@ -518,36 +516,35 @@ const PDFViewerApplication = {
|
|||||||
enableHWA,
|
enableHWA,
|
||||||
supportsPinchToZoom: this.supportsPinchToZoom,
|
supportsPinchToZoom: this.supportsPinchToZoom,
|
||||||
enableAutoLinking: AppOptions.get("enableAutoLinking"),
|
enableAutoLinking: AppOptions.get("enableAutoLinking"),
|
||||||
});
|
}));
|
||||||
this.pdfViewer = pdfViewer;
|
|
||||||
|
|
||||||
pdfRenderingQueue.setViewer(pdfViewer);
|
renderingQueue.setViewer(pdfViewer);
|
||||||
pdfLinkService.setViewer(pdfViewer);
|
linkService.setViewer(pdfViewer);
|
||||||
pdfScriptingManager.setViewer(pdfViewer);
|
pdfScriptingManager.setViewer(pdfViewer);
|
||||||
|
|
||||||
if (appConfig.sidebar?.thumbnailView) {
|
if (appConfig.sidebar?.thumbnailView) {
|
||||||
this.pdfThumbnailViewer = new PDFThumbnailViewer({
|
this.pdfThumbnailViewer = new PDFThumbnailViewer({
|
||||||
container: appConfig.sidebar.thumbnailView,
|
container: appConfig.sidebar.thumbnailView,
|
||||||
eventBus,
|
eventBus,
|
||||||
renderingQueue: pdfRenderingQueue,
|
renderingQueue,
|
||||||
linkService: pdfLinkService,
|
linkService,
|
||||||
maxCanvasPixels,
|
maxCanvasPixels,
|
||||||
maxCanvasDim,
|
maxCanvasDim,
|
||||||
pageColors,
|
pageColors,
|
||||||
abortSignal,
|
abortSignal,
|
||||||
enableHWA,
|
enableHWA,
|
||||||
});
|
});
|
||||||
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
renderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The browsing history is only enabled when the viewer is standalone,
|
// The browsing history is only enabled when the viewer is standalone,
|
||||||
// i.e. not when it is embedded in a web page.
|
// i.e. not when it is embedded in a web page.
|
||||||
if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
|
if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
|
||||||
this.pdfHistory = new PDFHistory({
|
this.pdfHistory = new PDFHistory({
|
||||||
linkService: pdfLinkService,
|
linkService,
|
||||||
eventBus,
|
eventBus,
|
||||||
});
|
});
|
||||||
pdfLinkService.setHistory(this.pdfHistory);
|
linkService.setHistory(this.pdfHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.supportsIntegratedFind && appConfig.findBar) {
|
if (!this.supportsIntegratedFind && appConfig.findBar) {
|
||||||
@ -578,7 +575,7 @@ const PDFViewerApplication = {
|
|||||||
if (mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) {
|
if (mlManager && appConfig.secondaryToolbar?.imageAltTextSettingsButton) {
|
||||||
this.imageAltTextSettings = new ImageAltTextSettings(
|
this.imageAltTextSettings = new ImageAltTextSettings(
|
||||||
appConfig.altTextSettingsDialog,
|
appConfig.altTextSettingsDialog,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
eventBus,
|
eventBus,
|
||||||
mlManager
|
mlManager
|
||||||
);
|
);
|
||||||
@ -587,7 +584,7 @@ const PDFViewerApplication = {
|
|||||||
if (appConfig.documentProperties) {
|
if (appConfig.documentProperties) {
|
||||||
this.pdfDocumentProperties = new PDFDocumentProperties(
|
this.pdfDocumentProperties = new PDFDocumentProperties(
|
||||||
appConfig.documentProperties,
|
appConfig.documentProperties,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
eventBus,
|
eventBus,
|
||||||
l10n,
|
l10n,
|
||||||
/* fileNameLookup = */ () => this._docFilename
|
/* fileNameLookup = */ () => this._docFilename
|
||||||
@ -653,7 +650,7 @@ const PDFViewerApplication = {
|
|||||||
if (appConfig.passwordOverlay) {
|
if (appConfig.passwordOverlay) {
|
||||||
this.passwordPrompt = new PasswordPrompt(
|
this.passwordPrompt = new PasswordPrompt(
|
||||||
appConfig.passwordOverlay,
|
appConfig.passwordOverlay,
|
||||||
this.overlayManager,
|
overlayManager,
|
||||||
this.isViewerEmbedded
|
this.isViewerEmbedded
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -663,7 +660,7 @@ const PDFViewerApplication = {
|
|||||||
container: appConfig.sidebar.outlineView,
|
container: appConfig.sidebar.outlineView,
|
||||||
eventBus,
|
eventBus,
|
||||||
l10n,
|
l10n,
|
||||||
linkService: pdfLinkService,
|
linkService,
|
||||||
downloadManager,
|
downloadManager,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user