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

@ -422,6 +422,16 @@ function normalizeWheelEventDelta(evt) {
return delta;
}
function cloneObj(obj) {
var result = {};
for (var i in obj) {
if (Object.prototype.hasOwnProperty.call(obj, i)) {
result[i] = obj[i];
}
}
return result;
}
/**
* Promise that is resolved when DOM window becomes visible.
*/
@ -582,6 +592,7 @@ export {
MAX_AUTO_SCALE,
SCROLLBAR_PADDING,
VERTICAL_PADDING,
cloneObj,
RendererType,
mozL10n,
EventBus,