mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +02:00
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:
parent
f9c58115fc
commit
a7273c8efe
4 changed files with 49 additions and 8 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue