Commit Graph

12565 Commits

Author SHA1 Message Date
Jonas Jenwald
603a9e3ea3 Update npm packages 2020-06-13 10:36:11 +02:00
Tim van der Meij
c809f00b3b
Merge pull request #11997 from Snuffleupagus/nullish-coalescing
Add basic support for the nullish coalescing operator `??`
2020-06-13 00:07:32 +02:00
Tim van der Meij
d75a068212
Merge pull request #11969 from emalysz/11961-unsupported-feature-telemetry-error
For #11961: collect telemetry on all unique unsupported features that…
2020-06-13 00:04:05 +02:00
Jonas Jenwald
b4ae958ca4 Add basic support for the nullish coalescing operator ??
For now we need to use a Babel-plugin, since Webpack 4.x doesn't seem to support it yet. (Most likely we'll have to update to Webpack 5, once that becomes available, in order for this to be directly supported. This is thus also blocked on removing the `webpack-stream` package.)

While the `??` operator will thus always be transpiled by Babel, even in modern builds, simply supporting it for development purposes seems like a step in the right direction.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator
2020-06-12 15:16:54 +02:00
Emma Malysz
05fe9c85b6 For #11961: collect telemetry on all unique unsupported features that trigger fallback error.
This expands upon the telemetry we are collecting that shows the fallback error.
2020-06-11 15:12:51 -07:00
Tim van der Meij
973936f469
Merge pull request #11993 from Snuffleupagus/OperatorList-dependencies-set
Change the `dependencies` property, on `OperatorList` instances, from an Object to a Set
2020-06-11 23:43:10 +02:00
Tim van der Meij
63a7aaa6f6
Merge pull request #11992 from Snuffleupagus/preprocessor-rm-HTML-comment-trailing-whitespace
Prevent the (old) preprocessor from appending trailing whitespace when removing closing HTML comments
2020-06-11 23:40:39 +02:00
Jonas Jenwald
10f31bb46d Change the dependencies property, on OperatorList instances, from an Object to a Set
Since this is completely internal functionality, and furthermore limited to the worker-thread, this change should thus not have any observable effect for e.g. an API-user.
2020-06-11 16:27:13 +02:00
Jonas Jenwald
02a1d0f6c5 Remove the unused intent/pageIndex properties from OperatorList instances (PR 11069 follow-up)
Apparently I completely overlooked the fact that with the changes in PR 11069 these properties became *completely* unused, and consequently they thus ought to be removed.
2020-06-11 16:05:38 +02:00
Jonas Jenwald
85a67456ed Prevent the (old) preprocessor from appending trailing whitespace when removing closing HTML comments
This can currently be seen in the *built* `web/viewer.html` file, at the line containing "  <script src="viewer.js"></script>  ".
2020-06-11 12:15:18 +02:00
Tim van der Meij
c9934de87c
Merge pull request #11987 from Snuffleupagus/svg-paintImageXObject-GlobalImageCache
Update `SVGGraphics` to account for globally cached images (PR 11912 follow-up)
2020-06-10 23:37:45 +02:00
Jonas Jenwald
00d45fce33 Update SVGGraphics to account for globally cached images (PR 11912 follow-up)
Since there's (essentially) no tests for the SVG-backend, these changes didn't make in into PR 11912 when the code in the `src/display/canvas.js` file was modified.
2020-06-10 15:31:26 +02:00
Tim van der Meij
a327f386ff
Merge pull request #11985 from Snuffleupagus/rm-isEmptyObj
Convert some `Object`s to `Map`s in `ChunkedStreamManager`, and move the `isEmptyObj` helper function to the test utils
2020-06-10 00:01:14 +02:00
Jonas Jenwald
88fdb482b0 Move the isEmptyObj helper function from src/shared/util.js to test/unit/test_utils.js
Since this helper function is no longer used anywhere in the main code-base, but only in a couple of unit-tests, it's thus being moved to a more appropriate spot.

Finally, the implementation of `isEmptyObj` is also tweaked slightly by removing the manual loop.
2020-06-09 17:50:16 +02:00
Jonas Jenwald
159e13c4e4 Convert the ChunkedStreamManager.promisesByRequest property to a Map
Compared to regular `Object`s, `Map`s have a number of advantageous properties: Of particular importance in this case is the built-in iteration support, and that determining if the structure is empty is easy.
2020-06-09 17:50:14 +02:00
Jonas Jenwald
dda7a5d1b7 Convert the ChunkedStreamManager.requestsByChunk property to a Map
Compared to regular `Object`s, `Map`s have a number of advantageous properties: Of particular importance in this case is the built-in iteration support, and that determining if the structure is empty is easy.
2020-06-09 17:50:11 +02:00
Jonas Jenwald
17e23ffb33 Convert the ChunkedStreamManager.chunksNeededByRequest property to a Map (containing Sets)
Compared to regular `Object`s, `Map`s (and `Set`s) have a number of advantageous properties: Of particular importance in this case is the built-in iteration support, and that determining if the structure is empty is easy.
2020-06-09 17:49:53 +02:00
Tim van der Meij
a4fa4554d6
Merge pull request #11977 from timvandermeij/refset
Convert the `RefSet` primitive to a proper class and use a `Set` internally
2020-06-07 23:15:35 +02:00
Tim van der Meij
4c2e056796
Convert the RefSet primitive to a proper class and use a Set internally
The `RefSet` primitive predates ES6, so that most likely explains why an
object is used internally to track the entries. However, nowadays we can
use built-in JavaScript sets for this purpose. Built-in types are often
more efficient/optimized and using it makes the code a bit more clear
since we don't have to assign `true` to keys anymore just to indicate
their presence.
2020-06-07 19:01:29 +02:00
Tim van der Meij
4c36dadfe2
Merge pull request #11978 from timvandermeij/unit-test-primitives
Improve unit test coverage for primitives
2020-06-07 18:58:17 +02:00
Tim van der Meij
550a38f1ba
Improve unit test coverage for primitives
This commit includes unit tests for:

- `isEOF`
- `isStream`
- `Ref`'s string representation and caching
- `Dict`'s XRef assignment
2020-06-07 17:31:40 +02:00
Tim van der Meij
4cfeda31fa
Merge pull request #11976 from Snuffleupagus/rm-dead-network-code
Remove unused methods from `NetworkManager`, in `src/display/network.js`
2020-06-07 17:27:06 +02:00
Jonas Jenwald
466d10f6fc Remove unused methods from NetworkManager, in src/display/network.js
Both of the removed methods were added in PR 2719, however they are no longer used:
 - It appears that `hasPendingRequests` was never used at all, even from the beginning.
 - The only general PDF.js library usage of `abortAllRequests` was removed in PR 6879, which is now four years ago. (Originally the Firefox-specific network implementation, see https://searchfox.org/mozilla-central/source/browser/extensions/pdfjs/content/PdfJsNetwork.jsm, was shared with the `src/display/network.js` file and *there* this method is used. However, since all of the Firefox-specific code now lives directly in mozilla-central, that's not relevant for the removal in this patch.)
2020-06-07 16:03:32 +02:00
Tim van der Meij
2bd0690fdd
Convert var to const/let in test/unit_primitives_spec.js 2020-06-07 15:04:24 +02:00
Tim van der Meij
c97200ff59
Merge pull request #11974 from Snuffleupagus/sendImgData
A couple of small image caching/sending improvements
2020-06-07 13:53:26 +02:00
Tim van der Meij
b779507370
Merge pull request #11963 from tamuratak/srgb_conv
Avoid calling Math.pow if possible.
2020-06-07 13:09:41 +02:00
Jonas Jenwald
df7d8c74ca Extract the actual sending of image data from the PartialEvaluator.buildPaintImageXObject method
After PRs 10727 and 11912, the code responsible for sending the decoded image data to the main-thread has now become a fair bit more involved the previously.
To reduce the amount of duplication here, the actual code responsible for sending the data is thus extracted into a new helper method instead.
2020-06-07 12:01:51 +02:00
Jonas Jenwald
aff0d56326 Remove an unnecessary RefSetCache.prototype.has() call from GlobalImageCache.getData
We can simply attempt to get the data *directly*, and instead check the result, rather than first checking if it exists.
2020-06-07 11:56:04 +02:00
Takashi Tamura
7acb112ca9 Optimization:
Avoid calling Math.pow if possible when calculating the transfer
function of the CalRGB color space since calling Math.pow is expensive.

If the value of color is larger than the threshold, 0.99554525,
the final result of the transform is larger that 254.5
since ((1 + 0.055) * 0.99554525 ** (1 / 2.4) - 0.055) * 255 === 254.50000003134699
2020-06-07 13:17:18 +09:00
Tim van der Meij
039307f88c
Merge pull request #11972 from Snuffleupagus/ChunkedStream-loadedChunks-Set
Change the `loadedChunks` property, on `ChunkedStream` instances, from an Array to a Set
2020-06-06 00:12:14 +02:00
Tim van der Meij
891c706aa8
Merge pull request #11953 from emalysz/11838-fallback-after-click
For #11838: trigger fallback bar after user clicks in pdf
2020-06-06 00:03:19 +02:00
Jonas Jenwald
b7272a34eb Change the loadedChunks property, on ChunkedStream instances, from an Array to a Set
In the old code the use of an Array meant that we had to *manually* track the `numChunksLoaded` property, given that simply using the Array `length` wouldn't have worked since there's no guarantee that the data is loaded in order when e.g. range requests are in use.

Tracking closely related state *separately* in this manner never seem like a good idea, and we can now instead utilize a Set to avoid that.
2020-06-05 15:03:06 +02:00
Tim van der Meij
7aa1b2d418
Merge pull request #11964 from aplum/fix-webpack-import
Fix pdfjs-dist/webpack causing errors with certain configs
2020-06-04 23:56:49 +02:00
Tim van der Meij
ad261a2da4
Merge pull request #11967 from havocbcn/jpg-rgb
Do not transform jpeg RGB components
2020-06-04 23:53:45 +02:00
Carlos Rodríguez
802aa14a99 Jpeg encoded with RGB -instead of YCbCr- write the components index as "RGB" in ASCII to say it so
On ISO/IEC 10918-6:2013 (E), section 6.1: (http://www.itu.int/rec/T-REC-T.872-201206-I/en)

"Images encoded with three components are assumed to be RGB data encoded as YCbCr unless the image contains an APP14 marker segment as specified in 6.5.3, in which case the colour encoding is considered either RGB or YCbCr according to the application data of the APP14 marker segment"

But common jpeg libraries consider RGB too if components index are ASCII R (0x52), G (0x47) and B (0x42): https://stackoverflow.com/questions/50798014/determining-color-space-for-jpeg/50861048

Issue #11931
2020-06-04 15:08:47 +02:00
Emma Malysz
6e9d158a98 For #11838: trigger fallback bar after user clicks in pdf 2020-06-03 14:03:46 -07:00
Alex Plumley
3b9031f6a3 Fix pdfjs-dist/webpack causing errors with certain configs
Using `require.resolve("worker-loader")` to check if `worker-loader` is installed causes webpack to include `worker-loader` in the output bundle, which is not the intended effect. Aside from increasing the bundle size unnecessarily, it also causes errors for webpack configs with targets that don't have node's built-in modules.

These errors can be fixed by configuring webpack `externals` to exclude `worker-loader`, but it's more difficult to figure out this solution than to figure out that `worker-loader` needs to be installed (even without this explicit error message).

To solve this, the explicit check for `worker-loader` has been removed. An alternative solution would be to use webpack's `resolveWeak`. Documentation has also been added in `examples/webpack` to help users.
2020-06-03 14:50:41 -04:00
Tim van der Meij
96ad60f116
Merge pull request #11958 from Snuffleupagus/rm-getOpenActionDestination
[api-minor] Remove the deprecated `PDFDocumentProxy.getOpenActionDestination` method (PR 11644 follow-up)
2020-06-02 23:51:55 +02:00
Jonas Jenwald
64378fc366 [api-minor] Remove the deprecated PDFDocumentProxy.getOpenActionDestination method (PR 11644 follow-up)
This method has been printing a `deprecated` warning in two releases, hence it should hopefully be safe to remove now.
2020-06-02 12:28:00 +02:00
Tim van der Meij
8fc1126b5a
Merge pull request #11948 from timvandermeij/bump
Bump versions in `pdfjs.config` and update the getting started page of the website for the new release
2020-06-01 12:51:06 +02:00
Tim van der Meij
a98b81f8ae
Bump versions in pdfjs.config and update the getting started page of the website for the new release 2020-06-01 12:45:04 +02:00
Tim van der Meij
0974d60523
Merge pull request #11947 from Snuffleupagus/GlobalImageCache-assert-not-inline
Ensure that that we don't attempt to cache *inline* images in the `GlobalImageCache` (PR 11912 follow-up)
2020-06-01 11:39:40 +02:00
Jonas Jenwald
af815e417d Ensure that that we don't attempt to cache *inline* images in the GlobalImageCache (PR 11912 follow-up)
Since *inline* images, i.e. those defined inside of `/Contents` streams, are by their very definition page-specific it thus seem like a good idea to actually enforce that they won't accidentally end up in the `GlobalImageCache`.
2020-06-01 01:00:30 +02:00
Tim van der Meij
5879710327
Merge pull request #11945 from Snuffleupagus/update-packages
Update packages and translations
2020-05-30 14:24:25 +02:00
Jonas Jenwald
f2cbd5de42 Update l10n files 2020-05-30 11:01:34 +02:00
Jonas Jenwald
da482310ee Update npm packages 2020-05-30 10:58:10 +02:00
Tim van der Meij
878619956b
Merge pull request #11943 from Snuffleupagus/cleanup-preprocessCSS
Remove unused code from the `external/builder/builder.js` file
2020-05-29 23:52:25 +02:00
Jonas Jenwald
d7dee0ea1c Remove the hasPrefixedFirefox functionality from the external/builder/builder.js file
This functionality has been completely unused ever since PR 9566 (two years ago).
2020-05-29 17:18:16 +02:00
Jonas Jenwald
ce234ab3c7 Remove the deprecatedInMozcentral functionality from the external/builder/builder.js file
This functionality has been completely unused ever since PR 9629 (two years ago).
2020-05-29 17:14:38 +02:00
Tim van der Meij
fe5689705d
Merge pull request #11930 from Snuffleupagus/LocalImageCache
Improve the *local* image caching in `PartialEvaluator.getOperatorList`
2020-05-28 00:12:37 +02:00