mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Improve the handling getBaseStreams
, on the various Stream implementations
The way that `getBaseStreams` is currently handled has bothered me from time to time, especially how we're checking if the method exists before calling it. By adding a dummy `BaseStream.getBaseStreams` method, and having the call-sites simply check the return value, we can improve some of the relevant code. Note in particular how the `ObjectLoader._walk` method didn't actually check that the data in question is a Stream instance, and instead only checked the `currentNode` (which could be anything) for the existence of a `getBaseStreams` property.
This commit is contained in:
parent
67415bfabe
commit
67a1cfc1b1
3 changed files with 25 additions and 18 deletions
|
@ -108,18 +108,20 @@ class ObjectLoader {
|
|||
pendingRequests.push({ begin: ex.begin, end: ex.end });
|
||||
}
|
||||
}
|
||||
if (currentNode && currentNode.getBaseStreams) {
|
||||
if (isStream(currentNode)) {
|
||||
const baseStreams = currentNode.getBaseStreams();
|
||||
let foundMissingData = false;
|
||||
for (const stream of baseStreams) {
|
||||
if (stream.isDataLoaded) {
|
||||
continue;
|
||||
if (baseStreams) {
|
||||
let foundMissingData = false;
|
||||
for (const stream of baseStreams) {
|
||||
if (stream.isDataLoaded) {
|
||||
continue;
|
||||
}
|
||||
foundMissingData = true;
|
||||
pendingRequests.push({ begin: stream.start, end: stream.end });
|
||||
}
|
||||
if (foundMissingData) {
|
||||
nodesToRevisit.push(currentNode);
|
||||
}
|
||||
foundMissingData = true;
|
||||
pendingRequests.push({ begin: stream.start, end: stream.end });
|
||||
}
|
||||
if (foundMissingData) {
|
||||
nodesToRevisit.push(currentNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue