Brendan Dahl
2067bccf09
Merge pull request #13314 from brendandahl/color-theme
...
For mozcentral use Firefox color theme instead of system theme.
2021-04-29 09:30:56 -07:00
Brendan Dahl
2c713f9cb5
For mozcentral use Firefox color theme instead of system theme.
...
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1701691
2021-04-28 15:03:45 -07:00
Jonas Jenwald
4d36659c38
Don't try to insert a structTree in a removed page (PR 13171 follow-up)
...
Given that both the textLayer rendering *and* the structTree parsing is asynchronous, it's possible that we'll attempt to insert the structTree in a removed page. While there's thankfully no outright breakage caused by this, it will nonetheless lead to errors being printed in the console and we should obviously avoid this.
To reproduce this bug (without the patch), open http://localhost:8888/web/viewer.html?file=/test/pdfs/pdf.pdf#disableStream=true&disableAutoFetch=true and scroll *very quickly* through the document and notice the following error being (intermittently) printed in the console:
```
Uncaught (in promise) TypeError: can't access property "appendChild", this.canvas is undefined
```
2021-04-28 14:45:56 +02:00
Jonas Jenwald
2ac4ad3111
Let ChunkedStream
extend Stream
, rather than BaseStream
directly
...
Looking at the `ChunkedStream` implementation, it's basically a "regular" `Stream` but with added functionality in order to deal with fetching/loading of missing data.
Hence, by letting `ChunkedStream` extend `Stream`, we can remove some duplicate methods from the `ChunkedStream` class.
2021-04-28 14:05:25 +02:00
Jonas Jenwald
fb0775525e
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.
2021-04-28 13:44:47 +02:00
Jonas Jenwald
67a1cfc1b1
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.
2021-04-28 13:44:47 +02:00
Jonas Jenwald
67415bfabe
Add an abstract base-class, which all the various Stream implementations inherit from
...
By having an abstract base-class, it becomes a lot clearer exactly which methods/getters are expected to exist on all Stream instances.
Furthermore, since a number of the methods are *identical* for all Stream implementations, this reduces unnecessary code duplication in the `Stream`, `DecodeStream`, and `ChunkedStream` classes.
For e.g. `gulp mozcentral`, the *built* `pdf.worker.js` files decreases from `1 619 329` to `1 616 115` bytes with this patch-series.
2021-04-28 13:44:45 +02:00
Jonas Jenwald
6151b4ecac
Convert src/core/stream.js
to use standard classes
2021-04-28 13:44:10 +02:00
Jonas Jenwald
29cf415a69
Enable the no-var
rule in the src/core/stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
b11f012e52
Convert src/core/decode_stream.js
to use standard classes
2021-04-28 10:16:51 +02:00
Jonas Jenwald
8ce2cae4a7
Enable the no-var
rule in the src/core/decode_stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
30a22a168d
Move the DecodeStream
and StreamsSequenceStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
213e1c389c
Convert src/core/flate_stream.js
to use standard classes
2021-04-28 10:16:51 +02:00
Jonas Jenwald
aa1deaf93c
Enable the no-var
rule in the src/core/flate_stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
1e5bf352a5
Move the FlateStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
40c342ec6c
Convert src/core/predictor_stream.js
to use standard classes
2021-04-28 10:16:51 +02:00
Jonas Jenwald
b08f9a8182
Enable the no-var
rule in the src/core/predictor_stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
66d9d83dcb
Move the PredictorStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
e938c05edb
Convert src/core/decrypt_stream.js
to use standard classes
2021-04-28 10:16:51 +02:00
Jonas Jenwald
a9476e7dd0
Enable the no-var
rule in the src/core/decrypt_stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
28b0809e60
Move the DecryptStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
cdb583b764
Convert src/core/ascii_85_stream.js
to use standard classes
2021-04-28 10:16:51 +02:00
Jonas Jenwald
f6c7a65202
Enable the no-var
rule in the src/core/ascii_85_stream.js
file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
3294d4d5a3
Move the Ascii85Stream
from src/core/stream.js
and into its own file
2021-04-28 10:16:51 +02:00
Jonas Jenwald
d2227a7d10
Convert src/core/ascii_hex_stream.js
to use standard classes
2021-04-28 10:16:50 +02:00
Jonas Jenwald
59591f8788
Enable the no-var
rule in the src/core/ascii_hex_stream.js
file
2021-04-28 10:16:50 +02:00
Jonas Jenwald
d63df04854
Move the AsciiHexStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:50 +02:00
Jonas Jenwald
704514c7cd
Convert src/core/run_length_stream.js
to use standard classes
2021-04-28 10:16:50 +02:00
Jonas Jenwald
66b898eb58
Enable the no-var
rule in the src/core/run_length_stream.js
file
2021-04-28 10:16:50 +02:00
Jonas Jenwald
342b0c1bbc
Move the RunLengthStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:50 +02:00
Jonas Jenwald
1f0685cee6
Convert src/core/lzw_stream.js
to use standard classes
2021-04-28 10:16:50 +02:00
Jonas Jenwald
1f9b134c6a
Enable the no-var
rule in the src/core/src/core/lzw_stream.js
file
2021-04-28 10:16:50 +02:00
Jonas Jenwald
6c1a321500
Move the LZWStream
from src/core/stream.js
and into its own file
2021-04-28 10:16:50 +02:00
Brendan Dahl
d10da907da
Fix position of highlighted all text. ( #13306 )
...
Adds a new integration test to ensure we don't
regress this again.
2021-04-28 10:15:31 +02:00
Tim van der Meij
0acd801b1e
Merge pull request #13305 from timvandermeij/annotation-polygon-polyline-no-appearance-stream
...
Implement rendering polyline/polygon annotations without appearance stream
2021-04-27 20:03:35 +02:00
Tim van der Meij
fae183b7cc
Merge pull request #13304 from Snuffleupagus/src-core-classes
...
Convert more code in `src/core/` to use standard classes
2021-04-27 19:37:09 +02:00
Tim van der Meij
60ab15427f
Implement rendering polyline/polygon annotations without appearance stream
2021-04-27 19:02:20 +02:00
Jonas Jenwald
0ecb42f4d7
Convert src/core/jpx_stream.js
to use standard classes
2021-04-27 13:29:09 +02:00
Jonas Jenwald
c51ef1f21f
Convert src/core/jbig2_stream.js
to use standard classes
2021-04-27 13:29:09 +02:00
Jonas Jenwald
d9c1bf96b6
Convert src/core/jpeg_stream.js
to use standard classes
2021-04-27 13:29:09 +02:00
Jonas Jenwald
0ca63f94b4
Convert src/core/ccitt_stream.js
to use standard classes
2021-04-27 13:29:09 +02:00
Jonas Jenwald
8ff213871b
Convert src/core/ccitt.js
to use standard classes
...
Given that we're using modules, meaning that only explicitly `export`ed things are visible to the outside, it's no longer necessary to wrap all of the code in a closure.
2021-04-27 13:29:09 +02:00
Tim van der Meij
ca668587c6
Merge pull request #13300 from Snuffleupagus/canvas-class
...
Convert the code in `src/display/canvas.js` to use standard classes
2021-04-27 13:19:36 +02:00
Jonas Jenwald
6f4394fcd8
Support InkAnnotation
s without appearance streams (issue 13298) ( #13301 )
...
For now, we keep things purposely simple by using straight lines (rather than curves); please see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2096579
2021-04-27 11:49:03 +02:00
Jonas Jenwald
e6601f4582
Convert the code in src/display/canvas.js
to use standard classes
...
This gets rid of *a lot* of boilerplate that stems from our old way of simulating classes, and it actually reduces the filesize noticeably.
For e.g. `gulp mozcentral`, the *built* `pdf.js` files decreases from `318 404` to `314 722` bytes (~1 percent) with this patch.
2021-04-26 22:10:38 +02:00
Tim van der Meij
72be684c10
Merge pull request #13294 from timvandermeij/src-no-var
...
Enable the `no-var` linting rule in `src/core/{cmap,image,worker}.js`
2021-04-25 17:44:13 +02:00
Tim van der Meij
270e56dae8
Enable the no-var
linting rule in src/core/image.js
...
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/image.js b/src/core/image.js
index 35c06b8ab..e718b9937 100644
--- a/src/core/image.js
+++ b/src/core/image.js
@@ -97,7 +97,7 @@ class PDFImage {
if (isName(filter)) {
switch (filter.name) {
case "JPXDecode":
- var jpxImage = new JpxImage();
+ const jpxImage = new JpxImage();
jpxImage.parseImageProperties(image.stream);
image.stream.reset();
```
2021-04-25 17:40:00 +02:00
Tim van der Meij
16efd09c9f
Enable the no-var
linting rule in src/core/worker.js
...
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/worker.js b/src/core/worker.js
index aec9c1d39..f88691622 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -300,7 +300,7 @@ class WorkerMessageHandler {
cachedChunks = [];
};
const readPromise = new Promise(function (resolve, reject) {
- var readChunk = function ({ value, done }) {
+ const readChunk = function ({ value, done }) {
try {
ensureNotTerminated();
if (done) {
```
2021-04-25 17:40:00 +02:00
Tim van der Meij
85659b4cf0
Enable the no-var
linting rule in src/core/cmap.js
...
This is done automatically with `gulp lint --fix` and the following
manual changes:
```diff
diff --git a/src/core/cmap.js b/src/core/cmap.js
index 850275a19..8794726dd 100644
--- a/src/core/cmap.js
+++ b/src/core/cmap.js
@@ -519,8 +519,8 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
readHexNumber(num, size) {
let last;
- let stack = this.tmpBuf,
- sp = 0;
+ const stack = this.tmpBuf;
+ let sp = 0;
do {
const b = this.readByte();
if (b < 0) {
@@ -603,7 +603,6 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
const ucs2DataSize = 1;
const subitemsCount = stream.readNumber();
- var i;
switch (type) {
case 0: // codespacerange
stream.readHex(start, dataSize);
@@ -614,7 +613,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
hexToInt(start, dataSize),
hexToInt(end, dataSize)
);
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(end, dataSize);
stream.readHexNumber(start, dataSize);
addHex(start, end, dataSize);
@@ -633,7 +632,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
addHex(end, start, dataSize);
stream.readNumber(); // code
// undefined range, skipping
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(end, dataSize);
stream.readHexNumber(start, dataSize);
addHex(start, end, dataSize);
@@ -647,7 +646,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
stream.readHex(char, dataSize);
code = stream.readNumber();
cMap.mapOne(hexToInt(char, dataSize), code);
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(char, dataSize);
if (!sequence) {
stream.readHexNumber(tmp, dataSize);
@@ -667,7 +666,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
hexToInt(end, dataSize),
code
);
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(end, dataSize);
if (!sequence) {
stream.readHexNumber(start, dataSize);
@@ -692,7 +691,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
hexToInt(char, ucs2DataSize),
hexToStr(charCode, dataSize)
);
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(char, ucs2DataSize);
if (!sequence) {
stream.readHexNumber(tmp, ucs2DataSize);
@@ -717,7 +716,7 @@ const BinaryCMapReader = (function BinaryCMapReaderClosure() {
hexToInt(end, ucs2DataSize),
hexToStr(charCode, dataSize)
);
- for (i = 1; i < subitemsCount; i++) {
+ for (let i = 1; i < subitemsCount; i++) {
incHex(end, ucs2DataSize);
if (!sequence) {
stream.readHexNumber(start, ucs2DataSize);
```
2021-04-25 17:40:00 +02:00
Tim van der Meij
2e9c2ab3b8
Merge pull request #13297 from Snuffleupagus/webpack-example-minification-warning
...
Add a note about minification to the webpack-example README (issue 13290)
2021-04-25 17:38:32 +02:00