Re-factor PDFDocumentProperties such that it's properly reset when a new PDF file is opened (issue 8371)

This patch contains the following improvements:
 - Only fetch the various document properties *once* per PDF file opened, and cache the result (in a frozen object).
 - Always update the *entire* dialog at once, to prevent inconsistent UI state (issue 8371).
 - Ensure that the dialog, and all its internal properties, are reset when `PDFViewerApplication.close` is called.
 - Inline, and re-factor, the `getProperties` method in `open`, since that's the only call-site.
 - Always overwrite the fileSize with the value obtained from `pdfDocument.getDownloadInfo`, to ensure that it's correct.
 - ES6-ify the code that's touched in this patch.

Fixes 8371.
This commit is contained in:
Jonas Jenwald 2017-05-05 14:04:08 +02:00
parent 50d026fbda
commit 7780fd5b98
4 changed files with 125 additions and 89 deletions

View file

@ -561,6 +561,7 @@ var PDFViewerApplication = {
this.pdfThumbnailViewer.setDocument(null);
this.pdfViewer.setDocument(null);
this.pdfLinkService.setDocument(null, null);
this.pdfDocumentProperties.setDocument(null, null);
}
this.store = null;
this.isInitialViewSet = false;
@ -847,8 +848,6 @@ var PDFViewerApplication = {
this.pdfDocument = pdfDocument;
this.pdfDocumentProperties.setDocumentAndUrl(pdfDocument, this.url);
var downloadedPromise = pdfDocument.getDownloadInfo().then(function() {
self.downloadComplete = true;
self.loadingBar.hide();
@ -869,6 +868,7 @@ var PDFViewerApplication = {
baseDocumentUrl = location.href.split('#')[0];
}
this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
this.pdfDocumentProperties.setDocument(pdfDocument, this.url);
var pdfViewer = this.pdfViewer;
pdfViewer.currentScale = scale;