Use local variables more in PDFViewerApplication._initializeViewerComponents

This commit is contained in:
Jonas Jenwald 2023-05-28 12:30:11 +02:00
parent 60feb2d5b6
commit 0e604f8f42

View File

@ -447,7 +447,7 @@ const PDFViewerApplication = {
* @private * @private
*/ */
async _initializeViewerComponents() { async _initializeViewerComponents() {
const { appConfig, externalServices } = this; const { appConfig, externalServices, l10n } = this;
const eventBus = externalServices.isInAutomation const eventBus = externalServices.isInAutomation
? new AutomationEventBus() ? new AutomationEventBus()
@ -504,7 +504,7 @@ const PDFViewerApplication = {
} }
: null; : null;
this.pdfViewer = new PDFViewer({ const pdfViewer = new PDFViewer({
container, container,
viewer, viewer,
eventBus, eventBus,
@ -514,7 +514,7 @@ const PDFViewerApplication = {
findController, findController,
scriptingManager: scriptingManager:
AppOptions.get("enableScripting") && pdfScriptingManager, AppOptions.get("enableScripting") && pdfScriptingManager,
l10n: this.l10n, l10n,
textLayerMode: AppOptions.get("textLayerMode"), textLayerMode: AppOptions.get("textLayerMode"),
annotationMode: AppOptions.get("annotationMode"), annotationMode: AppOptions.get("annotationMode"),
annotationEditorMode, annotationEditorMode,
@ -526,9 +526,11 @@ const PDFViewerApplication = {
enablePermissions: AppOptions.get("enablePermissions"), enablePermissions: AppOptions.get("enablePermissions"),
pageColors, pageColors,
}); });
pdfRenderingQueue.setViewer(this.pdfViewer); this.pdfViewer = pdfViewer;
pdfLinkService.setViewer(this.pdfViewer);
pdfScriptingManager.setViewer(this.pdfViewer); pdfRenderingQueue.setViewer(pdfViewer);
pdfLinkService.setViewer(pdfViewer);
pdfScriptingManager.setViewer(pdfViewer);
if (appConfig.sidebar?.thumbnailView) { if (appConfig.sidebar?.thumbnailView) {
this.pdfThumbnailViewer = new PDFThumbnailViewer({ this.pdfThumbnailViewer = new PDFThumbnailViewer({
@ -536,7 +538,7 @@ const PDFViewerApplication = {
eventBus, eventBus,
renderingQueue: pdfRenderingQueue, renderingQueue: pdfRenderingQueue,
linkService: pdfLinkService, linkService: pdfLinkService,
l10n: this.l10n, l10n,
pageColors, pageColors,
}); });
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer); pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
@ -553,7 +555,7 @@ const PDFViewerApplication = {
} }
if (!this.supportsIntegratedFind && appConfig.findBar) { if (!this.supportsIntegratedFind && appConfig.findBar) {
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n); this.findBar = new PDFFindBar(appConfig.findBar, eventBus, l10n);
} }
if (appConfig.annotationEditorParams) { if (appConfig.annotationEditorParams) {
@ -574,10 +576,8 @@ const PDFViewerApplication = {
appConfig.documentProperties, appConfig.documentProperties,
this.overlayManager, this.overlayManager,
eventBus, eventBus,
this.l10n, l10n,
/* fileNameLookup = */ () => { /* fileNameLookup = */ () => this._docFilename
return this._docFilename;
}
); );
} }
@ -601,13 +601,13 @@ const PDFViewerApplication = {
this.toolbar = new Toolbar( this.toolbar = new Toolbar(
appConfig.toolbar, appConfig.toolbar,
eventBus, eventBus,
this.l10n, l10n,
await this._nimbusDataPromise, await this._nimbusDataPromise,
this.externalServices externalServices
); );
} }
} else { } else {
this.toolbar = new Toolbar(appConfig.toolbar, eventBus, this.l10n); this.toolbar = new Toolbar(appConfig.toolbar, eventBus, l10n);
} }
} }
@ -615,7 +615,7 @@ const PDFViewerApplication = {
this.secondaryToolbar = new SecondaryToolbar( this.secondaryToolbar = new SecondaryToolbar(
appConfig.secondaryToolbar, appConfig.secondaryToolbar,
eventBus, eventBus,
this.externalServices externalServices
); );
} }
@ -625,7 +625,7 @@ const PDFViewerApplication = {
) { ) {
this.pdfPresentationMode = new PDFPresentationMode({ this.pdfPresentationMode = new PDFPresentationMode({
container, container,
pdfViewer: this.pdfViewer, pdfViewer,
eventBus, eventBus,
}); });
} }
@ -634,7 +634,7 @@ const PDFViewerApplication = {
this.passwordPrompt = new PasswordPrompt( this.passwordPrompt = new PasswordPrompt(
appConfig.passwordOverlay, appConfig.passwordOverlay,
this.overlayManager, this.overlayManager,
this.l10n, l10n,
this.isViewerEmbedded this.isViewerEmbedded
); );
} }
@ -660,17 +660,17 @@ const PDFViewerApplication = {
this.pdfLayerViewer = new PDFLayerViewer({ this.pdfLayerViewer = new PDFLayerViewer({
container: appConfig.sidebar.layersView, container: appConfig.sidebar.layersView,
eventBus, eventBus,
l10n: this.l10n, l10n,
}); });
} }
if (appConfig.sidebar) { if (appConfig.sidebar) {
this.pdfSidebar = new PDFSidebar({ this.pdfSidebar = new PDFSidebar({
elements: appConfig.sidebar, elements: appConfig.sidebar,
pdfViewer: this.pdfViewer, pdfViewer,
pdfThumbnailViewer: this.pdfThumbnailViewer, pdfThumbnailViewer: this.pdfThumbnailViewer,
eventBus, eventBus,
l10n: this.l10n, l10n,
}); });
this.pdfSidebar.onToggled = this.forceRendering.bind(this); this.pdfSidebar.onToggled = this.forceRendering.bind(this);
} }