Avoid dispatching range requests to fetch PDF data that's already loaded with streaming (PR 10675 follow-up)

*Please note:* This patch purposely ignores `src/display/network.js`, since its support for progressive reading depends on the non-standard `moz-chunked-arraybuffer` responseType which is currently in the process of being removed.
This commit is contained in:
Jonas Jenwald 2019-03-27 17:54:05 +01:00
parent f9c58115fc
commit a7273c8efe
4 changed files with 49 additions and 8 deletions

View file

@ -42,6 +42,10 @@ class PDFFetchStream {
this._rangeRequestReaders = [];
}
get _progressiveDataLength() {
return (this._fullRequestReader ? this._fullRequestReader._loaded : 0);
}
getFullReader() {
assert(!this._fullRequestReader);
this._fullRequestReader = new PDFFetchStreamReader(this);
@ -49,6 +53,9 @@ class PDFFetchStream {
}
getRangeReader(begin, end) {
if (end <= this._progressiveDataLength) {
return null;
}
let reader = new PDFFetchStreamRangeReader(this, begin, end);
this._rangeRequestReaders.push(reader);
return reader;