Commit Graph

8314 Commits

Author SHA1 Message Date
Jonas Jenwald
1b50932eaa Don't show thumbnails until the canvas to image conversion is done (issue 6442) 2015-09-12 12:05:40 +02:00
Tim van der Meij
09768405b8 Merge pull request #6441 from Snuffleupagus/pr-6299-follow-up
Misc. follow-up fixes to PR 6299 (Convert canvas thumbnails to PNG)
2015-09-12 00:23:00 +02:00
Jonas Jenwald
d7a90d83de Delete, and clear, the image in PDFThumbnailView_reset
*Follow-up to PR 6299.*
2015-09-11 14:12:58 +02:00
Jonas Jenwald
555c7925a0 Prevent setImage from failing to display small thumbnails, by adding a missing canvas to image conversion
*Follow-up to PR 6299.*
2015-09-11 14:12:57 +02:00
Jonas Jenwald
ebce928149 Extract the conversion from canvas to image into a helper function in PDFThumbnailView
*Follow-up to PR 6299.*

This patch reduces unnecessary code duplication for the `canvas` to `image` conversion. It also does a bit of re-ordering (and adds new lines) in `_getPageDrawContext`, since that function currently is a bit hard to read.
2015-09-11 14:12:48 +02:00
Tim van der Meij
dffb2efe9e Merge pull request #6299 from zinking/6035_png_thumb_nail
Convert canvas thumbnails to PNG
2015-09-10 23:54:27 +02:00
Tim van der Meij
12b0b9744b Merge pull request #6427 from Snuffleupagus/slightly-more-robust-get-fingerprint
Make `get fingerprint` slightly more robust against corrupt PDF files
2015-09-10 22:07:44 +02:00
Tim van der Meij
b360fd104b Merge pull request #6420 from Snuffleupagus/pr-4922-test
Add a reduced test-case for PR 4922
2015-09-10 21:54:45 +02:00
Tim van der Meij
767bad8d4a Merge pull request #6433 from Snuffleupagus/stringToPDFString-unit-tests
Add unit-tests for `stringToPDFString`
2015-09-10 21:27:26 +02:00
Jonas Jenwald
c043a6e3a3 Replace the unavailable linked test-case for issue 3205 with a reduced test-case 2015-09-10 16:59:30 +02:00
Jonas Jenwald
7f7025247a Replace the unavailable linked test-case for issue 4436 with a reduced test-case
Issue 4436 actually contains enough information to create a reduced test-case, which this patch uses to replace a currently unavailable linked test.
2015-09-10 13:01:20 +02:00
Jonas Jenwald
c5c8b239e9 Add unit-tests for stringToPDFString
The other day I was looking as the utilily function `stringToPDFString`, and I noticed that it didn't have any unit-tests. This patch fixes that.
2015-09-10 12:25:40 +02:00
Yury Delendik
f1652cb8b7 Merge pull request #6431 from Snuffleupagus/issue-6416
Add a utility function, for the viewer, that removes `null` (\x00) characters (issue 6416)
2015-09-09 17:08:45 -05:00
Brendan Dahl
ded4f317b8 Merge pull request #6425 from Snuffleupagus/issue-6410
Only choose a (3, 1) cmap table for TrueType fonts that have an encoding specified (issue 6410)
2015-09-09 14:57:38 -07:00
Jonas Jenwald
b7d1bed463 Add a utility function, for the viewer, that removes null (\x00) characters (issue 6416)
Since some browsers render `null` characters, and others don't, this patch adds a way to remove them to prevent display issues in the viewer UI.

Given that documents may contain very long outlines, I've added a utility function to avoid creating a lot of unnecessary `RegExp` objects.
To avoid any future issues, this utility function is used for both the outline and the attachments.

Fixes 6416.
2015-09-09 23:49:03 +02:00
Jonas Jenwald
5853553455 Make get fingerprint slightly more robust against corrupt PDF files
This patch adjusts `get fingerprint` to also check that the `/ID` entry contains (non-empty) strings, to prevent more possible failures when loading corrupt PDF files (follow-up to PR 5602).

Note that I've not actually encountered such a PDF file in the wild. However given that `stringToBytes` will assert that the input is a string, and that we'll thus fail to load a document unless `get fingerprint` succeeds, making this more robust seems like a good idea to me.
2015-09-08 13:42:53 +02:00
Jonas Jenwald
29a1cdb6a6 Only choose a (3, 1) cmap table for TrueType fonts that have an encoding specified (issue 6410)
For (1, 0) cmaps, we have two different codepaths depending on whether the font has/hasn't got an encoding. But with (3, 1) cmaps we don't have a good fallback when the encoding is missing, hence this patch changes `readCmapTable` to only choose a (3, 1) cmap table if the font is non-symbolic *and* an encoding exists. Without this, we'll not be able to successfully create a working glyph map for some TrueType fonts with (3, 1) cmap tables.

Fixes 6410.
2015-09-07 16:56:05 +02:00
Jonas Jenwald
3daae40425 Merge pull request #6423 from Rob--W/issue-6422-toc-triangles
Add mirrored triangle (TOC item icon)
2015-09-07 11:45:05 +02:00
Rob Wu
9f80060a18 Add mirrored triangle (TOC item icon) 2015-09-06 15:35:58 +02:00
Rob Wu
1936851038 Merge pull request #6421 from Snuffleupagus/outline-CSS-tweaks
Adjust the `min-width` of outline items and use more consistent `border-radius` (PR 6242 follow-up)
2015-09-06 15:24:11 +02:00
Jonas Jenwald
da1b9df74a Adjust the min-width of outline items and use more consistent border-radius (PR 6242 follow-up)
Prior to PR 6242, the width of all outline items was set such that their right (or left, in RTL locales) edges lined up vertically. In my opinion that looked more consistent, therefore this patch adjusts the CSS to make sure that this will be the case again.

The patch also makes the `border-radius` values of outline items a bit more consistent.
2015-09-06 13:01:30 +02:00
Jonas Jenwald
59548921d1 For documents with different page sizes, ensure that the correct page becomes visible on load when e.g. the 'page' hash parameter was provided (bug 1191279, issue 6393)
This issue is actually, in a sense, "caused" by the fact that the API/viewer supports partial loading/rendering. Previously when the *entire* document was always fetched before rendering begun, we knew all page sizes in advance and this issue didn't exist.

Now we use the size of *one* page in order to set the initial size of every page, until we've fetched the pages and thus know their correct sizes.
This means that during loading the size of the pages can change, which may cause the initial position to become scrolled out of view.

The most naive solution to this problem would perhaps be to delay setting the initial position on load for all documents, until all pages are fetched. However I think that would be a *really* bad idea, since doing so would make the initial rendering slower and make it feel sluggish for most documents.

Since there is generally no way of knowing if a document has different sized pages prior to loading it, we can only check once the pages are available.
Hence this patch, which treats documents with different sized pages as a special case, by re-applying the initial position when all pages have become available.
2015-09-06 12:09:22 +02:00
Jonas Jenwald
de6a74f58d Add a reduced test-case for PR 4922 2015-09-05 12:51:05 +02:00
Fabian Lange
063ca95f5f Remove TryCatch in canvas fill
As verified by @Rob--W, the evenodd fill rule works correctly in all supported browsers. This now allows optimization by JS engines.

This fixes #5458
2015-09-05 11:10:51 +02:00
Brendan Dahl
238e16feeb Merge pull request #6407 from Snuffleupagus/bug-1200096
Fallback in `readCmapTable`, instead of using `error`, for TrueType fonts with unsupported cmap formats (bug 1200096)
2015-09-04 18:10:34 -07:00
Tim van der Meij
2a0e0787c3 Merge pull request #6414 from Snuffleupagus/issue-6413
Ensure that the clipping path is reset when the state is restored (issue 6413)
2015-09-04 17:53:16 +02:00
Tim van der Meij
52dc7f3983 Merge pull request #6417 from Snuffleupagus/XRef-linked-load-tests
Add (linked) `load` tests for PR 1976 and 4606
2015-09-04 17:21:59 +02:00
Jonas Jenwald
e16fc486a4 Add (linked) ´load` tests for PR 1976 and 4606
Adds a couple of `load` tests for the `XRef` parsing part of the code-base, see PR 1976 and 4606.
2015-09-04 13:19:32 +02:00
awang
161def7f4e Convert canvas thumbnails to PNG #6299 2015-09-04 09:58:47 +08:00
Jonas Jenwald
b4ade44ab9 Add a reduced test-case for issue 6413 2015-09-03 22:29:12 +02:00
Jonas Jenwald
cfd5a64df5 Ensure that the clipping path is reset when the state is restored (issue 6413)
According to the specification, see `NOTE 2` in http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3882161, it appears that we should ensure that the clipping path is reset when the restore (`Q`) operator is encountered.

Fixes 6413.
2015-09-03 17:35:32 +02:00
Jonas Jenwald
b1d148a4aa Remove Parser_fetchIfRef since it's obsolete
This code was added in PR 1214, but was made obsolete by PRs 1488/1493. Prior to the latter ones, `Dict_get` retured the raw objects. However, afterwards (and currently) `Dict_get` now resolves indirect objects, which makes `Parser_fetchIfRef` redundant.

*Potential risks with this patch:*
This patch passes all tests locally, but there's a *small* possibility that it could break some weird PDF files.
In the current code, wrapping `Dict_get` inside `Parser_fetchIfRef` will potentially mean two back-to-back call of `XRef_fetch`, if a reference points directly to another reference. I'm not sure if this can actually happen in practice, and I'd think that if that were the case we'd already have run into it elsewhere in the code-base, given that `Parser` is the only place where we try to "double" resolve references.
2015-09-02 23:11:00 +02:00
Jonas Jenwald
0fb31a4a9e Fallback in readCmapTable, instead of using error, for TrueType fonts with unsupported cmap formats (bug 1200096)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1200096.

The problematic font has a `format 2` cmap, which we've never supported properly. Prior to PR 2606, we were able to fallback to a working state, despite not having proper support for that cmap format.

Obviously the best/correct solution would be to implement actual support for more cmap formats[1]. However, I'm hoping that a simple patch will be OK for now, given that:
 - `format 2` cmaps seem to be quite rare in practice, since this has been broken for 2.5 years before anyone noticed.
 - Having a simple patch will make potential uplifts a lot easier.

[1] See the specification at https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
2015-09-01 14:01:19 +02:00
Tim van der Meij
0020f33873 Merge pull request #6357 from Snuffleupagus/bidi-result
Avoid more allocations for RTL text in bidi.js
2015-09-01 00:44:33 +02:00
Tim van der Meij
8a27b8d8f5 Merge pull request #6405 from Snuffleupagus/pr-4731-load-test
Add a (linked) `load` test for PR 4731
2015-09-01 00:21:04 +02:00
Jonas Jenwald
09b825d1be Add a (linked) load test for PR 4731
Re: PR 4731.
Since the URL points to the Internet Archive, I think that adding a linked test-case should be OK. (Also, it's difficult to create reduced, or even `unit`, tests that accurately captures the brokenness of real-world PDF files.)

*Please note:* Since this is a `load` test, `makeref`ing won't be needed.
2015-08-31 17:15:41 +02:00
Tim van der Meij
8f1b0657c0 Merge pull request #6402 from DavidPrevot/reproducible
Set TZ=UTC before calls to zip
2015-08-31 16:32:04 +02:00
Tim van der Meij
678b662720 Merge pull request #6399 from Snuffleupagus/vertical-text-taro
Slightly improved test coverage for vertical text
2015-08-31 16:27:21 +02:00
Tim van der Meij
61459c7e30 Merge pull request #6403 from Snuffleupagus/issue-6113-test
Add a reduced test-case for issue 6113
2015-08-31 15:51:47 +02:00
Yury Delendik
943efea876 Merge pull request #6404 from Snuffleupagus/linearization-unit-tests
Add unit-tests for Linearization dictionary parsing (PR 5023 follow-up)
2015-08-31 07:38:55 -05:00
Tim van der Meij
b42b894570 Merge pull request #6386 from Snuffleupagus/Parser_makeFilter-warn-on-empty-stream
Add a warning when we encounter an empty stream in `Parser_makeFilter`
2015-08-30 23:14:22 +02:00
Tim van der Meij
f518bbcc7c Merge pull request #6401 from Snuffleupagus/paintXObject-subtype-PS-unit-test
Add a unit-test for skipping `paintXObject` if `Subtype === PS` (PR 4861)
2015-08-30 23:03:32 +02:00
Tim van der Meij
b3c00f2dfb Merge pull request #6395 from Snuffleupagus/issue-1419-enable-test
Fix typo in `test_manifest.json` that prevents test-case `issue1419.pdf` from running
2015-08-30 22:53:51 +02:00
Jonas Jenwald
0edb520a10 Add unit-tests for Linearization dictionary parsing (PR 5023 follow-up)
This should *really* have been part of 5023, but better late than never I suppose.
2015-08-30 14:06:11 +02:00
Jonas Jenwald
ba9fcce8eb Add a reduced test-case for issue 6113
As promised in PR 6125, here's a reduced test-case that should (hopefully) avoid the intermittent failure of the previous one.
2015-08-30 01:23:52 +02:00
Dhole
de83de0a58 Set TZ=UTC before calls to zip
This change allows to make the package build reproducible.

Bug-Debian: https://bugs.debian.org/793127
2015-08-29 14:52:19 -04:00
Jonas Jenwald
0dde08554d Add a unit-test for skipping paintXObject if Subtype === PS (PR 4861) 2015-08-29 20:43:22 +02:00
Jonas Jenwald
3ae49e15b3 Slightly improved test coverage for vertical text
Our current test coverage for vertical text is somewhat lacking, as evident from e.g. issue 6387. That regression could easily have been avoided if the `taro` test-case would have been an `eq` test, as well as an `text` test.
2015-08-29 15:54:32 +02:00
Jonas Jenwald
593ea00ecb Fix typo in test_manifest.json that prevents test-case issue1419.pdf from running
Currently we only attempt to test the *first* page, since `lastPage == 1`, but given that it's subsequently skipped we end up not testing anything.

*Note:* I've verified that the *second* page actually contains the kind of Colour space that the test was intended to check for.
2015-08-28 16:35:10 +02:00
Rob Wu
c6ba5ea42e Merge pull request #6390 from Snuffleupagus/rename-treeitem-assets
Switch `expanded/collapsed` in the names of the `treeitem-*` assets
2015-08-27 23:41:01 +02:00