[Firefox] Ensure that loading progress is reported, and the loadingBar updated, when disableRange=true is set

With PR 10675 having fixed the completely broken `disableRange=true` setting in the Firefox version of PDF.js, I couldn't help but noticing that loading progress is never reported properly in that case.
Currently loading progress is only reported for the `rangeProgress` chrome-event, which obviously isn't dispatched with `disableRange=true` set. However, the `progressiveRead` chrome-event includes loading progress as well, but this information isn't being used in any way.
Furthermore, the `PDFDataRangeTransport.onDataProgress` method wasn't able to handle "complete" loading information, and neither was `PDFDataTransportStream._onProgress` since that method would only ever attempt to report it through a RangeReader (which won't exist when `disableRange=true` is set).
This commit is contained in:
Jonas Jenwald 2019-04-06 11:04:44 +02:00
parent b161050df4
commit f0a28b3c0d
3 changed files with 15 additions and 5 deletions

View file

@ -515,6 +515,7 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
* Abstract class to support range requests file loading.
* @param {number} length
* @param {Uint8Array} initialData
* @param {boolean} progressiveDone
*/
class PDFDataRangeTransport {
constructor(length, initialData, progressiveDone = false) {
@ -551,10 +552,10 @@ class PDFDataRangeTransport {
}
}
onDataProgress(loaded) {
onDataProgress(loaded, total) {
this._readyCapability.promise.then(() => {
for (const listener of this._progressListeners) {
listener(loaded);
listener(loaded, total);
}
});
}