From fb0775525e62c0bc46bc2eea03f1df129b5ed1f9 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 27 Apr 2021 22:35:53 +0200 Subject: [PATCH] Stop special-casing the `dict` parameter in the `Jbig2Stream`/`JpegStream`/`JpxStream` constructors For all of the other `DecodeStream`s we're not passing in a `Dict`-instance manually, but instead get it from the `stream`-parameter. Hence there's no particularly good reason, as far as I can tell, to not do the same thing in `Jbig2Stream`/`JpegStream`/`JpxStream` as well. --- src/core/jbig2_stream.js | 4 ++-- src/core/jpeg_stream.js | 4 ++-- src/core/jpx_stream.js | 4 ++-- src/core/parser.js | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/core/jbig2_stream.js b/src/core/jbig2_stream.js index dda50f6d6..172ea6aa0 100644 --- a/src/core/jbig2_stream.js +++ b/src/core/jbig2_stream.js @@ -23,12 +23,12 @@ import { shadow } from "../shared/util.js"; * the stream behaves like all the other DecodeStreams. */ class Jbig2Stream extends DecodeStream { - constructor(stream, maybeLength, dict, params) { + constructor(stream, maybeLength, params) { super(maybeLength); this.stream = stream; + this.dict = stream.dict; this.maybeLength = maybeLength; - this.dict = dict; this.params = params; } diff --git a/src/core/jpeg_stream.js b/src/core/jpeg_stream.js index cd026f3dc..e8a0be588 100644 --- a/src/core/jpeg_stream.js +++ b/src/core/jpeg_stream.js @@ -23,7 +23,7 @@ import { shadow } from "../shared/util.js"; * like all the other DecodeStreams. */ class JpegStream extends DecodeStream { - constructor(stream, maybeLength, dict, params) { + constructor(stream, maybeLength, params) { // Some images may contain 'junk' before the SOI (start-of-image) marker. // Note: this seems to mainly affect inline images. let ch; @@ -37,8 +37,8 @@ class JpegStream extends DecodeStream { super(maybeLength); this.stream = stream; + this.dict = stream.dict; this.maybeLength = maybeLength; - this.dict = dict; this.params = params; } diff --git a/src/core/jpx_stream.js b/src/core/jpx_stream.js index b9d904384..82f0e5286 100644 --- a/src/core/jpx_stream.js +++ b/src/core/jpx_stream.js @@ -22,12 +22,12 @@ import { shadow } from "../shared/util.js"; * the stream behaves like all the other DecodeStreams. */ class JpxStream extends DecodeStream { - constructor(stream, maybeLength, dict, params) { + constructor(stream, maybeLength, params) { super(maybeLength); this.stream = stream; + this.dict = stream.dict; this.maybeLength = maybeLength; - this.dict = dict; this.params = params; } diff --git a/src/core/parser.js b/src/core/parser.js index 24b5cabf5..ca56a09f7 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -765,11 +765,11 @@ class Parser { } if (name === "DCTDecode" || name === "DCT") { xrefStreamStats[StreamType.DCT] = true; - return new JpegStream(stream, maybeLength, stream.dict, params); + return new JpegStream(stream, maybeLength, params); } if (name === "JPXDecode" || name === "JPX") { xrefStreamStats[StreamType.JPX] = true; - return new JpxStream(stream, maybeLength, stream.dict, params); + return new JpxStream(stream, maybeLength, params); } if (name === "ASCII85Decode" || name === "A85") { xrefStreamStats[StreamType.A85] = true; @@ -789,7 +789,7 @@ class Parser { } if (name === "JBIG2Decode") { xrefStreamStats[StreamType.JBIG] = true; - return new Jbig2Stream(stream, maybeLength, stream.dict, params); + return new Jbig2Stream(stream, maybeLength, params); } warn(`Filter "${name}" is not supported.`); return stream;