Skip to content

Commit 9b42ae9

Browse files
Merge pull request #13993 from Snuffleupagus/app-pdfHistory-init
Don't create `PDFViewerApplication.pdfHistory` when the browsing history is disabled
2 parents 4ddda41 + aa289b1 commit 9b42ae9

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

web/app.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,15 @@ const PDFViewerApplication = {
534534
});
535535
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
536536

537-
this.pdfHistory = new PDFHistory({
538-
linkService: pdfLinkService,
539-
eventBus,
540-
});
541-
pdfLinkService.setHistory(this.pdfHistory);
537+
// The browsing history is only enabled when the viewer is standalone,
538+
// i.e. not when it is embedded in a web page.
539+
if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
540+
this.pdfHistory = new PDFHistory({
541+
linkService: pdfLinkService,
542+
eventBus,
543+
});
544+
pdfLinkService.setHistory(this.pdfHistory);
545+
}
542546

543547
if (!this.supportsIntegratedFind) {
544548
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
@@ -1631,9 +1635,7 @@ const PDFViewerApplication = {
16311635
* @private
16321636
*/
16331637
_initializePdfHistory({ fingerprint, viewOnLoad, initialDest = null }) {
1634-
if (this.isViewerEmbedded || AppOptions.get("disableHistory")) {
1635-
// The browsing history is only enabled when the viewer is standalone,
1636-
// i.e. not when it is embedded in a web page.
1638+
if (!this.pdfHistory) {
16371639
return;
16381640
}
16391641
this.pdfHistory.initialize({
@@ -2456,7 +2458,7 @@ function webViewerHashchange(evt) {
24562458
}
24572459
if (!PDFViewerApplication.isInitialViewSet) {
24582460
PDFViewerApplication.initialBookmark = hash;
2459-
} else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
2461+
} else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
24602462
PDFViewerApplication.pdfLinkService.setHash(hash);
24612463
}
24622464
}

web/pdf_link_service.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,11 @@ class PDFLinkService {
380380
// See PDF reference, table 8.45 - Named action
381381
switch (action) {
382382
case "GoBack":
383-
if (this.pdfHistory) {
384-
this.pdfHistory.back();
385-
}
383+
this.pdfHistory?.back();
386384
break;
387385

388386
case "GoForward":
389-
if (this.pdfHistory) {
390-
this.pdfHistory.forward();
391-
}
387+
this.pdfHistory?.forward();
392388
break;
393389

394390
case "NextPage":

0 commit comments

Comments
 (0)