Remove an unnecessary PDFDocumentProperties.setFileSize call, relevant for the Firefox built-in viewer, and use the "normal" code-path in PDFViewerApplication.open instead

Since calling `getDocument` with a `PDFDataRangeTransport` argument will always unconditionally override a manually provided `length` argument, see a1a667809f/src/display/api.js (L390-L394), this patch should thus be safe.
This commit is contained in:
Jonas Jenwald 2019-07-21 11:38:17 +02:00
parent a1a667809f
commit 53a854bb0a

View File

@ -512,11 +512,7 @@ let PDFViewerApplication = {
} }
this.externalServices.initPassiveLoading({ this.externalServices.initPassiveLoading({
onOpenWithTransport(url, length, transport) { onOpenWithTransport(url, length, transport) {
PDFViewerApplication.open(url, { range: transport, }); PDFViewerApplication.open(url, { length, range: transport, });
if (length) {
PDFViewerApplication.pdfDocumentProperties.setFileSize(length);
}
}, },
onOpenWithData(data) { onOpenWithData(data) {
PDFViewerApplication.open(data); PDFViewerApplication.open(data);
@ -659,11 +655,13 @@ let PDFViewerApplication = {
} }
if (args) { if (args) {
for (let prop in args) { for (let key in args) {
if (prop === 'length') { const value = args[key];
this.pdfDocumentProperties.setFileSize(args[prop]);
if (key === 'length') {
this.pdfDocumentProperties.setFileSize(value);
} }
parameters[prop] = args[prop]; parameters[key] = value;
} }
} }