Commit Graph

10193 Commits

Author SHA1 Message Date
Tim van der Meij
40b89e9ba4 Merge pull request #8949 from Snuffleupagus/ColorSpace-rm-instanceof-AlternateCS
Remove the `instanceof AlternateCS` check in `ColorSpace.parse` since it's dead code
2017-09-23 16:09:17 +02:00
Tim van der Meij
2aac994171 Merge pull request #8928 from mukulmishra18/decode-file-path
Fix #8907: Decode URL to get correct path in node_stream.
2017-09-23 14:44:58 +02:00
Jonas Jenwald
8a084aff0f Remove the instanceof AlternateCS check in ColorSpace.parse since it's dead code
Looking at `ColorSpace.parseToIR`, it will do one of the following things when called:
 1. Return a String.
 2. Return an Array.
 3. Throw a `FormatError`.
 4. In one case, return the result of *another* `ColorSpace.parseToIR` call.

However, under no circumstances will it ever return an `AlternateCS` instance.

Since it's often useful to understand why code, which has become unused, existed in the first place, let's grab a hard hat and a shovel and start digging through the history of this code :-)

The current condition was introduced in commit c198ec4323, in PR 794, but it was actually already obsolete by that time.
The preceeding `instanceof SeparationCS` condition predates commit a7278b7fbc, in PR 700.
That condition was originally introduced all the way back in commit 4e3f87b60c, in PR 692. However, it was made obsolete by commit 9dcefe1efc, which is included in the very same PR!

Hence we're left with the conclusion that not only has this code be unused for *almost* six years, it was basically never used at all save for a few refactoring commits that're part of PR 692.
2017-09-23 14:36:10 +02:00
Tim van der Meij
d7b37ae745 Merge pull request #8912 from timvandermeij/xml-parser
[api-minor] Replace `DOMParser` with `SimpleXMLParser`
2017-09-20 23:45:00 +02:00
Jonas Jenwald
abc864fca9 Merge pull request #8938 from brendandahl/bug1392647
Use font's default width even when 0. (bug 1392647)
2017-09-20 22:38:39 +02:00
Brendan Dahl
10ba292b46 Use font's default width even when 0.
Bug 1392647 has a PDF where the default width of the font
is 0. It draws some charcodes that don't have glyphs, but
we were wrongly using the 1000 default width for these
charcodes causing some text to be overlapping.
2017-09-20 11:38:30 -07:00
Tim van der Meij
2281061882
Enable metadata unit tests for Travis CI and Node.js 2017-09-19 23:09:07 +02:00
Tim van der Meij
d4309614f9
Replace DOMParser with SimpleXMLParser
The `DOMParser` is most likely overkill and may be less secure.
Moreover, it is not supported in Node.js environments.

This patch replaces the `DOMParser` with a simple XML parser. This
should be faster and gives us Node.js support for free. The simple XML
parser is a port of the one that existed in the examples folder with a
small regex fix to make the parsing work correctly.

The unit tests are extended for increased test coverage of the metadata
code. The new method `getAll` is provided so the example does not have
to access internal properties of the object anymore.
2017-09-19 23:09:07 +02:00
Jonas Jenwald
fbd6e47aaf Merge pull request #8901 from janpe2/ccitt-eofb-false
CCITTFaxStream problem when EndOfBlock is false
2017-09-19 22:23:15 +02:00
Tim van der Meij
bc9afdf3c4
Convert src/display/metadata.js to ES6 syntax 2017-09-19 22:13:59 +02:00
Jani Pehkonen
3d99b8d706 CCITTFaxStream problem when EndOfBlock is false 2017-09-19 22:19:40 +03:00
Mukul Mishra
e4c09c7cba Fix #8907: Decode URL to get correct path in node_stream. 2017-09-19 15:10:36 +05:30
Tim van der Meij
9c2e9dae26 Merge pull request #8921 from THausherr/patch-2
support tiff predictor for 16bit
2017-09-18 23:01:33 +02:00
Tilman Hausherr
d75a497a6b support tiff predictor for 16bit
(for issue #6289)
This does the same for 16 bit as the existing 8 bit tiff predictor code, an addition of the last word to this word.

The last two "& 0xFF" may or may not be needed, I see this isn't done in the 8 bit code, but I'm not a JS developer.
2017-09-18 22:24:25 +02:00
Jonas Jenwald
50bd4a5ac0 Update l10n files 2017-09-18 10:59:44 +02:00
Tim van der Meij
c84c23c4cb Merge pull request #8919 from Snuffleupagus/issue-8915
Ignore 'change' events that didn't originate in the viewer (issue 8915)
2017-09-17 15:21:53 +02:00
Jonas Jenwald
6c3856c841 Ignore 'change' events that didn't originate in the viewer (issue 8915)
Rather that registering a 'change' event listener on the `window`, which will thus (unnecessarily) fire in *a number* of other situations such as e.g. when the user changes the pageNumber or the current search term, we could/should just register it directly on the dynamically created `fileInput` DOM element instead.
I can see no really compelling reason why we actually need to listen for `file` changes on the `window` itself, and this way we're also able to keep the `fileInput` related code confined to one part of the code which should aid readability.
Furthermore, in custom deployments, there's less risk that we're going to interfere with "outside" code this way.

Finally, preprocessor guards were added to the `webViewerOpenFile` function, since that code doesn't make sense in e.g. the extension builds.
2017-09-17 11:34:21 +02:00
Jonas Jenwald
f01f0fdaa7 Merge pull request #8917 from timvandermeij/stamp-annotations
Implement support for stamp annotations
2017-09-17 10:19:14 +02:00
Tim van der Meij
400e4aae0e
Implement support for stamp annotations 2017-09-16 16:37:50 +02:00
Tim van der Meij
3be941d982 Merge pull request #8909 from Snuffleupagus/PDFFunction-isEvalSupported
Check `isEvalSupported`, and test that `eval` is actually supported, before attempting to use the `PostScriptCompiler` (issue 5573)
2017-09-16 16:11:03 +02:00
Tim van der Meij
27773f14d1 Merge pull request #8913 from Snuffleupagus/issue-8895
For /Filter entries containing `Name`s, ignore the /DecodeParms entry if it contains an Array (issue 8895)
2017-09-16 15:43:33 +02:00
Jonas Jenwald
eece66fa3e For /Filter entries containing Names, ignore the /DecodeParms entry if it contains an Array (issue 8895) 2017-09-15 23:02:16 +02:00
Jonas Jenwald
dc926ffc0f Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler (issue 5573)
Currently `PDFFunction` is implemented (basically) like a class with only `static` methods. Since it's used directly in a number of different `src/core/` files, attempting to pass in `isEvalSupported` would result in code that's *very* messy, not to mention difficult to maintain (since *every* single `PDFFunction` method call would need to include a `isEvalSupported` argument).

Rather than having to wait for a possible re-factoring of `PDFFunction` that would avoid the above problems by design, it probably makes sense to at least set `isEvalSupported` globally for `PDFFunction`.

Please note that there's one caveat with this solution: If `PDFJS.getDocument` is used to open multiple files simultaneously, with *different* `PDFJS.isEvalSupported` values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that `eval` is actually supported, it should be fine.

Fixes 5573.
2017-09-15 12:02:45 +02:00
Yury Delendik
d0d7046129 Merge pull request #8910 from mukulmishra18/include-credentials
Fix #8888: Change behaviour of fetch to make it compatible with XHR.
2017-09-14 14:29:59 -05:00
Mukul Mishra
ef7038fe34 Fix #8888: Change behaviour of fetch to make it compatible with XHR. 2017-09-14 23:53:06 +05:30
Tim van der Meij
31a34335a0 Merge pull request #8900 from Snuffleupagus/ref-test-SimpleLinkService
Use the `SimpleLinkService` when running "annotations" reference tests
2017-09-13 22:25:38 +02:00
Yury Delendik
25c49de048 Merge pull request #8904 from timvandermeij/svg-setattribute-stub
Provide a stub for `setAttribute` in order to use the SVG back-end with Node.js
2017-09-13 07:47:47 -05:00
Tim van der Meij
cc654fd38d
Provide a stub for setAttribute in order to use the SVG back-end with
Node.js

This patch fixes a regression from PR #8691 where we switched to using
`setAttribute` instead of `setAttributeNS` if no namespace is provided.
2017-09-12 23:23:41 +02:00
Jonas Jenwald
1ebbdc253a Use the SimpleLinkService when running "annotations" reference tests
Rather than (basically) duplicating the `SimpleLinkService` in `test/driver.js`, with potential test failuires if you forget to update the test mock, it seems much nicer to just re-use the viewer component.

Note that `SimpleLinkService` is already bundled into the `build/components/pdf_viewer.js` file. Hence we only need to expose it similar to the other viewer components in that file, and make sure that the `gulp components` command runs as part of the test-setup.
2017-09-12 15:24:46 +02:00
Jonas Jenwald
f2618eb2e4 Merge pull request #8808 from janpe2/issue8741
Fix color of image masks inside uncolored patterns
2017-09-12 14:27:56 +02:00
Jonas Jenwald
2916ed080d Merge pull request #8893 from timvandermeij/annotations-css-dedup
Combine the common styles and overrides for the annotation layer reference tests
2017-09-12 13:22:59 +02:00
Jonas Jenwald
ba21996576 Update l10n files 2017-09-11 11:43:12 +02:00
Tim van der Meij
23cbe294d5
Combine the common styles and overrides for the annotation layer
reference tests

This patch allows us to use the common styles as used by the viewer as a
baseline for the annotation layer reference tests. They are extended
with a small set of overrides to ensure that all elements are visible
during the test.

The overrides file now only contains the absolutely necessary rules to
make all elements visible and is therefore no longer an almost verbatim
copy of the common styles.
2017-09-10 18:18:56 +02:00
Tim van der Meij
3a84d582d3 Merge pull request #8891 from Snuffleupagus/es6-firefoxcom
ES6-ify the code in `web/firefoxcom.js`
2017-09-10 16:10:58 +02:00
Tim van der Meij
46481eb2bf Merge pull request #8892 from Snuffleupagus/es6-genericcom-genericl10n
Replace `var` with `let` in `web/genericcom` and `web/genericl10n`
2017-09-10 16:06:22 +02:00
Jonas Jenwald
1d78935f3e Replace var with let in web/genericcom and web/genericl10n 2017-09-10 13:09:26 +02:00
Jonas Jenwald
aaff3385ee ES6-ify the code in web/firefoxcom.js
These changes consists mainly of replacing `var` with `let`/`const`, and finally converting the `DownloadManager` to a proper class.
2017-09-10 12:51:33 +02:00
Tim van der Meij
320779e6ed Merge pull request #8691 from timvandermeij/square-circle-annotations
Implement support for square and circle annotations
2017-09-09 22:56:54 +02:00
Tim van der Meij
c04f9d6098
Implement reference tests for square and circle annotations 2017-09-09 21:36:28 +02:00
Tim van der Meij
44c116ac49
Implement support for circle annotations 2017-09-09 21:36:27 +02:00
Tim van der Meij
cace2e9047
Implement support for square annotations 2017-09-09 21:36:27 +02:00
Tim van der Meij
f7fd1db52f
Introduce DOMSVGFactory
This patch provides a new unit tested factory for creating SVG
containers and elements. This code is duplicated twice in the
codebase, but with upcoming changes this would need to be duplicated
even more. Moreover, consolidating this code in one factory allows
us to replace it easily for e.g., supporting Node.js. Therefore, move
this to a central place and update/ES6-ify the related code.

Finally, we replace `setAttributeNS` with `setAttribute` because no
namespace is provided.
2017-09-09 21:36:27 +02:00
Tim van der Meij
437e9cb056 Merge pull request #8865 from Snuffleupagus/hide-unsupported-LinkAnnotation
Hide unsupported `LinkAnnotation`s (issue 3897)
2017-09-09 19:07:43 +02:00
Tim van der Meij
e6d05be41a Merge pull request #8868 from Snuffleupagus/save-rotation
Store the rotation in the `ViewHistory`/`PDFHistory` (issue 5927)
2017-09-09 16:33:28 +02:00
Tim van der Meij
bd3f16bffd Merge pull request #8889 from Snuffleupagus/more-Number-isInteger
Replace `value === (value | 0)` checks with `Number.isInteger(value)`
2017-09-09 15:24:23 +02:00
Jonas Jenwald
30b7a0f093 Replace value === (value | 0) checks with Number.isInteger(value) in the web/ folder
Rather than doing what (at first) may seem like a fairly obscure comparison, using `Number.isInteger` will clearly indicate the intent of the code.
2017-09-09 14:12:52 +02:00
Jonas Jenwald
8686baede5 Replace value === (value | 0) checks with Number.isInteger(value) in the src/ folder
Rather than doing what (at first) may seem like a fairly obscure comparison, using `Number.isInteger` will clearly indicate the intent of the code.
2017-09-09 14:12:52 +02:00
Jonas Jenwald
e135c03123 Store the rotation in the PDFHistory 2017-09-09 11:27:05 +02:00
Jonas Jenwald
44d5138d0f Store the rotation in the ViewHistory (issue 5927) 2017-09-09 11:27:05 +02:00
Jonas Jenwald
5565a6f8bf Slightly refactor the pages rotation handling code in the viewer
This changes both `PDFViewer` and `PDFThumbnailViewer` to return early in the `pagesRotation` setters if the rotation doesn't change.
It also fixes an existing issue, in `PDFViewer`, that would cause errors if the rotation changes *before* the scale has been set to a non-default value.

Finally, in preparation for subsequent patches, it also refactors the rotation code in `web/app.js` to update the thumbnails and trigger rendering with the new `rotationchanging` event.
2017-09-09 11:27:05 +02:00