1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #10161 from Snuffleupagus/DataLoaded-onProgress

Ensure that `onProgress` is always called when the entire PDF file has been loaded, regardless of how it was fetched (issue 10160)
This commit is contained in:
Tim van der Meij 2018-10-20 15:22:05 +02:00 committed by GitHub
commit d21892933d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 9 deletions

View file

@ -1763,12 +1763,9 @@ class WorkerTransport {
fullReader.headersReady.then(() => {
// If stream or range are disabled, it's our only way to report
// loading progress.
if (!fullReader.isStreamingSupported ||
!fullReader.isRangeSupported) {
if (this._lastProgress) {
if (loadingTask.onProgress) {
loadingTask.onProgress(this._lastProgress);
}
if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) {
if (this._lastProgress && loadingTask.onProgress) {
loadingTask.onProgress(this._lastProgress);
}
fullReader.onProgress = (evt) => {
if (loadingTask.onProgress) {
@ -1866,6 +1863,14 @@ class WorkerTransport {
}, this);
messageHandler.on('DataLoaded', function(data) {
// For consistency: Ensure that progress is always reported when the
// entire PDF file has been loaded, regardless of how it was fetched.
if (loadingTask.onProgress) {
loadingTask.onProgress({
loaded: data.length,
total: data.length,
});
}
this.downloadInfoCapability.resolve(data);
}, this);