mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
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:
parent
50d026fbda
commit
7780fd5b98
4 changed files with 125 additions and 89 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue