mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-28 18:07:21 +02:00
Remove the unused IPDFStreamRangeReader.prototype.isStreamingSupported getter
This getter was only invoked from `src/display/network.js` and `src/core/chunked_stream.js`, however in both cases it's hardcoded to `false` and thus isn't actually needed. This originated in PR 6879, close to a decade ago, for a potential TODO which was never implemented and it ought to be OK to just simplify this now.
This commit is contained in:
parent
62d5408cf0
commit
987265720e
@ -283,19 +283,15 @@ class ChunkedStreamManager {
|
|||||||
|
|
||||||
sendRequest(begin, end) {
|
sendRequest(begin, end) {
|
||||||
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
|
const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
|
||||||
if (!rangeReader.isStreamingSupported) {
|
rangeReader.onProgress = this.onProgress.bind(this);
|
||||||
rangeReader.onProgress = this.onProgress.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
let chunks = [],
|
let chunks = [];
|
||||||
loaded = 0;
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const readChunk = ({ value, done }) => {
|
const readChunk = ({ value, done }) => {
|
||||||
try {
|
try {
|
||||||
if (done) {
|
if (done) {
|
||||||
const chunkData = arrayBuffersToBytes(chunks);
|
resolve(arrayBuffersToBytes(chunks));
|
||||||
chunks = null;
|
chunks = null;
|
||||||
resolve(chunkData);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
@ -304,12 +300,6 @@ class ChunkedStreamManager {
|
|||||||
"readChunk (sendRequest) - expected an ArrayBuffer."
|
"readChunk (sendRequest) - expected an ArrayBuffer."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
loaded += value.byteLength;
|
|
||||||
|
|
||||||
if (rangeReader.isStreamingSupported) {
|
|
||||||
this.onProgress({ loaded });
|
|
||||||
}
|
|
||||||
|
|
||||||
chunks.push(value);
|
chunks.push(value);
|
||||||
rangeReader.read().then(readChunk, reject);
|
rangeReader.read().then(readChunk, reject);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@ -114,10 +114,6 @@ class PDFWorkerStreamRangeReader {
|
|||||||
this._reader = readableStream.getReader();
|
this._reader = readableStream.getReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
const { value, done } = await this._reader.read();
|
const { value, done } = await this._reader.read();
|
||||||
if (done) {
|
if (done) {
|
||||||
|
|||||||
@ -209,7 +209,6 @@ class PDFFetchStreamRangeReader {
|
|||||||
const source = stream.source;
|
const source = stream.source;
|
||||||
this._withCredentials = source.withCredentials || false;
|
this._withCredentials = source.withCredentials || false;
|
||||||
this._readCapability = Promise.withResolvers();
|
this._readCapability = Promise.withResolvers();
|
||||||
this._isStreamingSupported = !source.disableStream;
|
|
||||||
|
|
||||||
this._abortController = new AbortController();
|
this._abortController = new AbortController();
|
||||||
// Always create a copy of the headers.
|
// Always create a copy of the headers.
|
||||||
@ -240,10 +239,6 @@ class PDFFetchStreamRangeReader {
|
|||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return this._isStreamingSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
await this._readCapability.promise;
|
await this._readCapability.promise;
|
||||||
const { value, done } = await this._reader.read();
|
const { value, done } = await this._reader.read();
|
||||||
|
|||||||
@ -413,13 +413,7 @@ class PDFNetworkStreamRangeRequestReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onProgress(evt) {
|
_onProgress(evt) {
|
||||||
if (!this.isStreamingSupported) {
|
this.onProgress?.({ loaded: evt.loaded });
|
||||||
this.onProgress?.({ loaded: evt.loaded });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
|
|||||||
@ -208,8 +208,6 @@ class PDFNodeStreamFsRangeReader {
|
|||||||
constructor(stream, begin, end) {
|
constructor(stream, begin, end) {
|
||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
this._loaded = 0;
|
this._loaded = 0;
|
||||||
const source = stream.source;
|
|
||||||
this._isStreamingSupported = !source.disableStream;
|
|
||||||
|
|
||||||
const url = stream.url;
|
const url = stream.url;
|
||||||
const fs = process.getBuiltinModule("fs");
|
const fs = process.getBuiltinModule("fs");
|
||||||
@ -228,10 +226,6 @@ class PDFNodeStreamFsRangeReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return this._isStreamingSupported;
|
|
||||||
}
|
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
await this._readCapability.promise;
|
await this._readCapability.promise;
|
||||||
const { value, done } = await this._reader.read();
|
const { value, done } = await this._reader.read();
|
||||||
|
|||||||
@ -287,10 +287,6 @@ class PDFDataTransportStreamRangeReader {
|
|||||||
this._stream._removeRangeReader(this);
|
this._stream._removeRangeReader(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
if (this._queuedChunk) {
|
if (this._queuedChunk) {
|
||||||
const chunk = this._queuedChunk;
|
const chunk = this._queuedChunk;
|
||||||
|
|||||||
@ -145,14 +145,6 @@ class IPDFStreamRangeReader {
|
|||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets ability of the stream to progressively load binary data.
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
get isStreamingSupported() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests a chunk of the binary data. The method returns the promise, which
|
* Requests a chunk of the binary data. The method returns the promise, which
|
||||||
* is resolved into object with properties "value" and "done". If the done
|
* is resolved into object with properties "value" and "done". If the done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user