Don't create PDFViewerApplication.pdfHistory
when the browsing history is disabled
Similar to other viewer components, e.g. the `PDFFindBar` and `PDFPresentationMode`, there's no need to create a `PDFHistory`-instance when it's not going to be used.
This commit is contained in:
parent
8a79f13e5a
commit
aa289b17b6
10
web/app.js
10
web/app.js
@ -534,11 +534,15 @@ const PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
pdfRenderingQueue.setThumbnailViewer(this.pdfThumbnailViewer);
|
||||||
|
|
||||||
|
// The browsing history is only enabled when the viewer is standalone,
|
||||||
|
// i.e. not when it is embedded in a web page.
|
||||||
|
if (!this.isViewerEmbedded && !AppOptions.get("disableHistory")) {
|
||||||
this.pdfHistory = new PDFHistory({
|
this.pdfHistory = new PDFHistory({
|
||||||
linkService: pdfLinkService,
|
linkService: pdfLinkService,
|
||||||
eventBus,
|
eventBus,
|
||||||
});
|
});
|
||||||
pdfLinkService.setHistory(this.pdfHistory);
|
pdfLinkService.setHistory(this.pdfHistory);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.supportsIntegratedFind) {
|
if (!this.supportsIntegratedFind) {
|
||||||
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
this.findBar = new PDFFindBar(appConfig.findBar, eventBus, this.l10n);
|
||||||
@ -1631,9 +1635,7 @@ const PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_initializePdfHistory({ fingerprint, viewOnLoad, initialDest = null }) {
|
_initializePdfHistory({ fingerprint, viewOnLoad, initialDest = null }) {
|
||||||
if (this.isViewerEmbedded || AppOptions.get("disableHistory")) {
|
if (!this.pdfHistory) {
|
||||||
// The browsing history is only enabled when the viewer is standalone,
|
|
||||||
// i.e. not when it is embedded in a web page.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.pdfHistory.initialize({
|
this.pdfHistory.initialize({
|
||||||
@ -2456,7 +2458,7 @@ function webViewerHashchange(evt) {
|
|||||||
}
|
}
|
||||||
if (!PDFViewerApplication.isInitialViewSet) {
|
if (!PDFViewerApplication.isInitialViewSet) {
|
||||||
PDFViewerApplication.initialBookmark = hash;
|
PDFViewerApplication.initialBookmark = hash;
|
||||||
} else if (!PDFViewerApplication.pdfHistory.popStateInProgress) {
|
} else if (!PDFViewerApplication.pdfHistory?.popStateInProgress) {
|
||||||
PDFViewerApplication.pdfLinkService.setHash(hash);
|
PDFViewerApplication.pdfLinkService.setHash(hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,15 +380,11 @@ class PDFLinkService {
|
|||||||
// See PDF reference, table 8.45 - Named action
|
// See PDF reference, table 8.45 - Named action
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "GoBack":
|
case "GoBack":
|
||||||
if (this.pdfHistory) {
|
this.pdfHistory?.back();
|
||||||
this.pdfHistory.back();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "GoForward":
|
case "GoForward":
|
||||||
if (this.pdfHistory) {
|
this.pdfHistory?.forward();
|
||||||
this.pdfHistory.forward();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "NextPage":
|
case "NextPage":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user