Commit Graph

10467 Commits

Author SHA1 Message Date
Jonas Jenwald
ae65c66133
Merge pull request #9330 from timvandermeij/custom-style
Remove the `CustomStyle` class
2017-12-31 15:24:21 +01:00
Tim van der Meij
d36c46b2c9
Remove the CustomStyle class
It is only used in a few places to handle prefixing style properties if
necessary. However, we used it only for `transform`, `transformOrigin`
and `borderRadius`, which according to Can I Use are supported natively
(unprefixed) in the browsers that PDF.js 2.0 supports. Therefore, we can
remove this class, which should help performance too since this avoids
extra function calls in parts of the code that are called often.
2017-12-31 14:22:11 +01:00
Jonas Jenwald
3f88bfcda6
Merge pull request #9329 from timvandermeij/gulp-util
Stop using the deprecated `gulp-util` module
2017-12-31 12:42:59 +01:00
Tim van der Meij
d688b8ea31
Stop using the deprecated gulp-util module
The `gulp-util` module is now deprecated and authors are asked to stop
using it (refer to https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 for
more information).

PDF.js does not rely on it that much, fortunately, so it's relatively
easy for us to remove the dependency. This patch does that by making the
following changes:

- Require `gulp-zip` version 4.1.0 or higher since they already removed
  their `gulp-util` dependency in that version.
- Replace `gulp-util.log` with the `fancylog` module as recommended in
  the article above.
- Replace `gulp-util.File` with the `Vinyl` module as recommended in the
  article above.

The only change I had to make for Vinyl is removing the `base` and `cwd`
lines since they may not be empty strings anymore. This way we fall back
to the defaults Vinyl provides, which for us doesn't matter since we
move the file afterwards anyway. Moreover, I used `vfs` for `vinyl-fs`
in the `Gulpfile` to avoid confusion with `vinyl` (which is also how the
documentation names the variable).

This is all we can do on our side; the other modules that still use
`gulp-util` must be updated upstream.
2017-12-30 20:13:52 +01:00
Tim van der Meij
4cc0f8c721
Merge pull request #9325 from Snuffleupagus/decodeACSuccessive-less-blur
Adjust `decodeACSuccessive` in src/core/jpg.js to improve the rendering quality of (progressive) JPEG images
2017-12-30 19:26:07 +01:00
Jonas Jenwald
c5700211d6 Adjust decodeACSuccessive in src/core/jpg.js to improve the rendering quality of (progressive) JPEG images
I've been looking into the remaining point in 8637 about blurry images, to see if we could perhaps improve the rendering quality slightly there. After quite a bit of debugging, it seems that the issue is limited to certain progressive JPEG images.

As mentioned previously, I've got no detailed knowledge of the JPEG format, but this patch does seem to improve things quite a bit for the images in question.
Squinting at https://searchfox.org/mozilla-central/rev/6c33dde6ca02b389c52e8db3d22494df8b916f33/media/libjpeg/jdphuff.c#492-639, it seems reasonable that we should take the sign of the data into account. Furthermore, looking at the specification in https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=118, the "F.2.4.3 Decoding the binary decision sequence for non-zero DC differences and AC coefficients" section even contains a description of this (even though I cannot claim to really understand the details).
2017-12-30 15:24:09 +01:00
Jonas Jenwald
d6eed132e5 Correct the indentation in the switch statement in decodeACSuccessive in src/core/jpg.js 2017-12-30 15:22:30 +01:00
Tim van der Meij
18d82d9c54
Merge pull request #9287 from himanish-star/PDFjs-compatible-Librejs
PDFjs now compatible with Librejs
2017-12-30 14:00:25 +01:00
Tim van der Meij
ad0dc7e89a
Merge pull request #9327 from Snuffleupagus/JpegStream-DeviceGray-length
Avoid truncating JPEG images with DeviceGray ColourSpaces when using the `src/core/jpg.js` built-in decoder
2017-12-29 22:31:35 +01:00
Jonas Jenwald
8c4b7d0439 Avoid truncating JPEG images with DeviceGray ColourSpaces when using the src/core/jpg.js built-in decoder
The bug that this patch fixes is limited to the built-in JPEG decoder, and was unearthed by PR 9260. The underlying issue has existed since PR 6984, where the contents of this patch ought to have been included (if it weren't for the fact that we had no *easy* way to test `src/core/jpg.js` back then).

*Please note:* The slight movement in the reference test is a result of using the `src/core/jpg.js` decoder, rather than the native browser one.
2017-12-29 18:44:07 +01:00
Tim van der Meij
25bbff4692
Merge pull request #9320 from Snuffleupagus/pr-9095-followup
Avoid rendering errors by passing in the `webGLContext` when creating a new `CanvasGraphics` in `getColorN_Pattern` (PR 9095 follow-up)
2017-12-28 23:17:30 +01:00
Tim van der Meij
5c2cd369d2
Merge pull request #9321 from Snuffleupagus/rm-IE-linkAnnotation-hack
Remove the `background` compatibility hacks for `linkAnnotation` in old versions of IE
2017-12-28 00:08:12 +01:00
Jonas Jenwald
ec21bd9626
Merge pull request #9314 from timvandermeij/encodings
Implement unit tests for the encodings and fix missing items
2017-12-27 22:02:38 +01:00
Jonas Jenwald
03b0c76b7f Remove the background compatibility hacks for linkAnnotation in old versions of IE
With PDF.js version `2.0` we'll no longer support IE 9 and 10, hence these hacks can now be removed.
2017-12-27 14:16:28 +01:00
Jonas Jenwald
06605abbc2 Avoid rendering errors by passing in the webGLContext when creating a new CanvasGraphics in getColorN_Pattern (PR 9095 follow-up)
This was an oversight in PR 9095, which unfortunately breaks rendering in some PDF files (e.g. the one from issue 6737).

It thus appears that we don't have any test-coverage for this code-path, and given the relative complexity of the PDF files affected by this bug I wasn't able to easily create a reduced test-case.
*Please note:* The linked test-case included in this patch is currently *not* rendered correctly (that'd be the PR 6606), but it at least gives us some test-coverage here.
2017-12-27 13:50:53 +01:00
Tim van der Meij
fe30d4d468
Merge pull request #9313 from Snuffleupagus/issue-9291
Add a fallback for non-embedded LucidaSans-Demi fonts (issue 9291)
2017-12-24 20:06:38 +01:00
Tim van der Meij
c7af2db2ec
Implement unit tests for the encodings and fix missing items
Initially I just implemented the unit tests, but quickly found that they
were failing my expectation of having a size of 256 items. Some of them
did contain 256 items and some did not. I looked up various resources
and figured that they indeed all need to have 256 items. One of the good
resources is https://github.com/davidben/poppler/blob/master/poppler/FontEncodingTables.cc

Aside from some missing `notdef` (empty string) entries at the end of
the arrays, which I assume causes issues since it may cause
out-of-bounds array access which in JavaScript gives `undefined`, there
was a `notdef` entry missing in the `MacExpertEncoding`, causing the
entries after that to be shifted. This fix for this is similar to the
one in #8589.

The unit tests verify that, for known encoding names, the return value
is not only an array, but that it is also of the right length and
contains only strings.
2017-12-24 18:14:40 +01:00
Jonas Jenwald
d4cd44fd16 Add a fallback for non-embedded LucidaSans-Demi fonts (issue 9291)
The PDF file in the issue uses a number of *embedded* versions of Lucida fonts, but for some reason does *not* embed the LucidaSans-Demi font. According to https://en.wikipedia.org/wiki/Lucida#Usages that one should be bold, so we can at least improve rendering here (even though it won't look perfect).

Fixes 9291.
2017-12-24 17:36:58 +01:00
Tim van der Meij
1d4651b2e4
Merge pull request #9311 from timvandermeij/unit-test-network-utils
Implement unit tests for the network utility code
2017-12-23 19:36:24 +01:00
Tim van der Meij
957e2d420d
Implement unit tests for the network utility code
This should provide 100% coverage for the file.
2017-12-23 19:24:11 +01:00
Tim van der Meij
404cba878c
Merge pull request #9303 from Snuffleupagus/rm-pdfInfo-encrypted
[api-major] Remove the unused `encrypted` property from the `pdfInfo` object sent from the worker via the `GetDoc` message
2017-12-22 21:38:52 +01:00
Jonas Jenwald
e58f2f513a [api-major] Remove the unused encrypted property from the pdfInfo object sent from the worker via the GetDoc message
I recall being confused as to the purpose of the `encrypted` property all the way back when working on PR 4750.

Looking at the history, this property was added in PR 1698 when password support was added to the API/viewer. However, its only purpose seem to have been to facilitate the addition of a `isEncrypted` function in the API. That function never, as far as I can tell, saw any use and was unceremoniously removed in PR 4144.

Since we want to avoid sending all non-essential data early during initial document loading (e.g. PR 4750), it seems correct to get rid of the `encrypted` property. Especially since it hasn't even been exposed in the API for over three years, with no complaints that I'm aware of.

Finally note that the `encrypt` property on the `XRef` instance isn't tied to the code that's being removed here. Given that we're calling `PDFDocument.parse` during `createDocumentHandler` in the worker which, via `PDFDocument.setup`, calls `XRef.parse` where the `Encrypt` data (if it exists) is always parsed.
2017-12-21 13:10:23 +01:00
Tim van der Meij
e081a708c3
Merge pull request #9294 from Snuffleupagus/rm-more-polyfills
Remove even more polyfills for old, and now unsupported, browsers
2017-12-20 22:15:47 +01:00
Jonas Jenwald
9ff3c6f99d Remove the document.readyState polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 15:05:19 +01:00
Jonas Jenwald
6af45052c5 Remove the input.type polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 15:05:15 +01:00
Jonas Jenwald
cf88b7b212 Remove the ImageData.set polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 15:05:14 +01:00
Jonas Jenwald
363e517acf Remove the HTMLElement.dataset polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 14:50:18 +01:00
Jonas Jenwald
4880200cd4 Remove the XMLHttpRequest.response polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 14:48:43 +01:00
Jonas Jenwald
8266cc18e7 Remove the webkitURL polyfill
This is only relevant for browsers that we don't intend to support with PDF.js version `2.0`.
2017-12-19 14:46:04 +01:00
Soumya Himanish Mohapatra
95ad956f68 PDFjs now compatible with Librejs 2017-12-19 15:13:50 +05:30
Tim van der Meij
8ae3fd49f9
Merge pull request #9288 from Snuffleupagus/issue-9105-2
Handle PDF files with missing 'endobj' operators, by searching for the "obj" string rather than "endobj" in `XRef.indexObjects` (issue 9105)
2017-12-18 23:05:38 +01:00
Jonas Jenwald
1dc54ddb40 Handle PDF files with missing 'endobj' operators, by searching for the "obj" string rather than "endobj" in XRef.indexObjects (issue 9105)
This patch refactors the searching for 'endobj', to try and find the next occurance of "obj" and then check if it was in fact an 'endobj' and continue searching otherwise.
This approach is used to avoid having to first find 'endobj', and then re-check the entire contents of the object and having to run (potentially expensive) regular expressions on arbitrary long strings.

Fixes 9105.
2017-12-18 13:17:45 +01:00
Tim van der Meij
6bbe91079b
Merge pull request #9272 from nveenjain/fix/8846
Replaced occurence of `throw new Error` with `unreachable`
2017-12-15 22:11:32 +01:00
Jonas Jenwald
6515b91118
Merge pull request #9276 from mozilla/loca-fix
Fix loca table when offsets aren't in ascending order.
2017-12-15 20:59:42 +01:00
Brendan Dahl
9b51cea724 Fix loca table when offsets aren't in ascending order. 2017-12-15 11:20:28 -06:00
Naveen Jain
1135674647 Replaced occurence of throw new Error with unreachable where applicable 2017-12-14 12:58:50 +05:30
Tim van der Meij
546cd2b67c
Merge pull request #9271 from Snuffleupagus/bug-1424938
Handle broken, Ghostscript generated, Metadata that contains HTML character names (bug 1424938)
2017-12-13 22:49:41 +01:00
Jonas Jenwald
ad5ed37059 Handle broken, Ghostscript generated, Metadata that contains HTML character names (bug 1424938)
Please note that while this could be considered a regression in user-facing behaviour, I'm not convinced that it's really a regression as such since prior to PR 8912 the Metadata would fail to parse (with an XML error) and thus be ignored when setting the viewer title.
With the refactored Metadata parsing we're now able to parse this, which uncovered issues with a subset of broken Ghostscript Metadata that uses HTML character names.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1424938
2017-12-13 14:32:47 +01:00
Jonas Jenwald
b327633ad6
Merge pull request #9267 from himanish-star/visibility-of-placeholder-text
Improve visibility of the findInput placeholder in Chrome
2017-12-12 19:03:01 +01:00
Soumya Himanish Mohapatra
b28962df1e Improve visibility of the findInput placeholder in Chrome 2017-12-12 15:34:51 +05:30
Tim van der Meij
6ac9e1c5ed
Merge pull request #9249 from MichaelDeBoey/worker-loader-requires-webpack
'worker-loader' requires 'webpack' as peerDependency
2017-12-10 16:57:10 +01:00
Tim van der Meij
095c63cc25
Merge pull request #9260 from Snuffleupagus/rm-JpegStream.getBytes
Attempt to remove the special `JpegStream.getBytes` method and utilize the regular `DecodeStream` one instead
2017-12-10 16:50:50 +01:00
Tim van der Meij
af14620b75
Merge pull request #9256 from timvandermeij/log2
Use native `Math` functions in the custom `log2` function
2017-12-10 16:43:53 +01:00
Tim van der Meij
c35bbd11b0
Use native Math functions in the custom log2 function
It is quite confusing that the custom function is called `log2` while it
actually returns the ceiling value and handles zero and negative values
differently than the native function.

To resolve this, we add a comment that explains these differences and
make the function use the native `Math` functions internally instead of
using our own custom logic. To verify that the function does what we
expect, we add unit tests.

All browsers except for IE support `Math.log2` for quite a long time
already (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2).
For IE, we use the core-js polyfill.

According to the microbenchmark at https://jsperf.com/log2-pdfjs/1,
using the native functions should also be faster, in my testing almost
six times as fast.
2017-12-10 16:35:17 +01:00
Jonas Jenwald
84de1e9a92 Attempt to remove the special JpegStream.getBytes method and utilize the regular DecodeStream one instead
Note that no other image stream implements a special `getBytes` method, which makes `JpegStream` look somewhat odd.

I'm actually not sure what purpose this methods serves, since I successfully ran all tests locally with it commented out. Furhermore, I also ran tests with an added `if (length && length !== this.bufferLength) { throw new Error('length mismatch'); }` check, and didn't get a single test failure in that case either.

Looking at the history, it seems that this code originated back in PR 4528, but as far as I can tell there's no mention in either commit messages nor PR comments of why it was necessary to add a "special" `getBytes` function for the `JpegStream`.
My assumption is that there's a good reason why this method was added, e.g. to address a *specific* regression in one of the reference tests. However, I did check out commit 58f697f977 locally and ran tests with this method commented out, and there didn't seem to be any image-related failures in that case either!?

Hence I'm suggesting that we attempt to simplify this code slightly be removing this special `getBytes` method. However, please note that there's perhaps a *small* risk of regressions in an edge-case where we currently have insufficient test-coverage.
2017-12-10 13:31:08 +01:00
Jonas Jenwald
371ca51402
Merge pull request #9207 from Standard8/use-mozilla-recommended
Switch to using mozilla/recommended configuration for extensions/firefox.
2017-12-08 21:06:49 +01:00
Mark Banner
63c6157bdf Switch to using mozilla/recommended configuration for extensions/firefox. 2017-12-08 18:58:48 +00:00
Brendan Dahl
af1d80d45e
Merge pull request #9230 from Snuffleupagus/issue-9195
Add basic support for non-embedded Calibri fonts (issue 9195)
2017-12-08 10:15:43 -08:00
Jonas Jenwald
a5e3261b48
Merge pull request #9062 from mozilla/no_high
Move char codes from high surrogate pair range into private use.
2017-12-08 12:31:22 +01:00
Michaël De Boey
e3324d45bc
'worker-loader' requires 'webpack' as peerDependency 2017-12-07 23:10:12 +01:00