mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-05 01:31:00 +02:00
Merge pull request #21371 from Snuffleupagus/BaseStream-clone-fix
Improve the `BaseStream.prototype.clone` implementations
This commit is contained in:
commit
065ea625dd
@ -135,6 +135,10 @@ class BaseStream {
|
||||
unreachable("Abstract method `makeSubStream` called");
|
||||
}
|
||||
|
||||
clone() {
|
||||
unreachable("Abstract method `clone` called");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array | null}
|
||||
*/
|
||||
|
||||
@ -178,21 +178,16 @@ class DecodeStream extends BaseStream {
|
||||
return new Stream(this.buffer, start, length, dict);
|
||||
}
|
||||
|
||||
getBaseStreams() {
|
||||
return this.stream ? this.stream.getBaseStreams() : null;
|
||||
}
|
||||
|
||||
clone() {
|
||||
// Make sure it has been fully read.
|
||||
while (!this.eof) {
|
||||
this.readBlock();
|
||||
}
|
||||
return new Stream(
|
||||
this.buffer,
|
||||
this.start,
|
||||
this.end - this.start,
|
||||
this.dict.clone()
|
||||
);
|
||||
return new Stream(this.buffer, 0, this.bufferLength, this.dict?.clone());
|
||||
}
|
||||
|
||||
getBaseStreams() {
|
||||
return this.stream ? this.stream.getBaseStreams() : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,8 +88,8 @@ class Stream extends BaseStream {
|
||||
return new Stream(
|
||||
this.bytes.buffer,
|
||||
this.start,
|
||||
this.end - this.start,
|
||||
this.dict.clone()
|
||||
this.length,
|
||||
this.dict?.clone()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user