Commit Graph

9012 Commits

Author SHA1 Message Date
Tim van der Meij
f4b2ad4ec2 Merge pull request #7505 from timvandermeij/travis-ci-update
Use the latest stable Node.js version on Travis CI and enable caching
2016-07-25 15:29:37 +02:00
Tim van der Meij
7bbc2f079a Use the latest stable Node.js version on Travis CI and enable caching 2016-07-25 15:17:30 +02:00
Jonas Jenwald
558a22cd02 Prevent errors when parsing Annotations with missing (or invalid) /Subtype entries (issue 7446)
Note that I used a separate warning message for this case, instead of utilizing the same one as in the unsupported subtype case, to more clearly indicate that the PDF file itself is to blame rather than PDF.js.

Fixes 7446.
2016-07-25 13:59:26 +02:00
Jonas Jenwald
b7cb44af88 Remove the previousPageNumber parameter from the pagechanging/pagechange` events, and stop dispatching the events if the input is out of bounds
This patch attempts to cleanup a couple of things:
 - Remove the `previousPageNumber` paramater. Prior to PR 7289, when the events were dispatched even when the active page didn't change, it made sense to be able to detect that in an event listener. However, now that's no longer the case, and furthermore other similar events (e.g. `scalechanging`/`scalechange`) don't include information about the previous state.

 - Don't dispatch the events when the value passed to `set currentPageNumber` is out of bounds. Given that the active page doesn't change in this case, again similar to PR 7289, I don't think that the events should actually be dispatched in this case.

 - Ensure that the value passed to `set currentPageNumber` is actually an integer, to avoid any issues (note how e.g. `set currentScale` has similar validation code).

Given that these changes could possibly affect the PDF.js `mochitest` integration tests in mozilla-central, in particular https://dxr.mozilla.org/mozilla-central/source/browser/extensions/pdfjs/test/browser_pdfjs_navigation.js, I ran the tests locally with this patch applied to ensure that they still pass.
2016-07-25 10:08:53 +02:00
Brendan Dahl
5678486802 Merge pull request #7347 from Snuffleupagus/evaluator-more-Ref_toString
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
2016-07-22 17:21:47 -07:00
Brendan Dahl
50d6e4f147 Merge pull request #7447 from Snuffleupagus/buildToUnicode-notdef
Ignore .notdef in the `differences` array when building a fallback `toUnicode` map in `PartialEvaluator_buildToUnicode` (issue 5256)
2016-07-22 14:33:32 -07:00
Jonas Jenwald
390c02a3e9 Attempt to cache fonts that are direct objects (i.e. Dicts), as opposed to Refs, to prevent re-rendering after cleanup from breaking (issue 7403 and issue 7402)
Fonts that are not referenced by `Ref`s are very uncommon in practice, but it can unfortunately happen. In this case, we're currently not caching them in the usual way, i.e. by `Ref`, which leads to failures when a page is rendered after `cleanup` has run.
The simplest solution would have been to remove the `font.translated` workaround, but since this would have meant loading these kind of fonts over and over, the patch attempts to be a bit clever about this situation.

Note that if we instead loaded fonts per *page*, instead of per document, this issue wouldn't have existed.
2016-07-21 16:04:07 +02:00
Jonas Jenwald
4fe891c5e7 Add a reduced test-case for issue 7403 2016-07-21 16:04:07 +02:00
Jonas Jenwald
2e9cd3ea64 Slightly refactor the fontRef handling in PartialEvaluator_loadFont (issue 7403 and issue 7402)
Originally, I was just going to change this code to use `Ref_toString` in a couple more places. When I started reading the code, I figured that it wouldn't hurt to clean up a couple of comments. While doing this, I noticed that the logic for the (rare) `isDict(fontRef)` case could do with a few improvements.

There should be no functional changes with this patch, but given the added reference checks, we will now avoid bogus `Ref`s when resolving font aliases. In practice, as issue 7403 shows, the current code can break certain PDF files even if it's very rare.

Note that the only thing that this patch will change, is the `font.loadedName` in the case where a `fontRef` is a reference *and* the font doesn't have a descriptor. Previously for `fontRef = Ref(4, 0)` we'd get `font.loadedName = 'g_d0_f4_0'`, and with this patch `font.loadedName = g_d0_f4R`, which is actually one character shorted in most cases. (Given that `Ref_toString` contains an optimization for the `gen === 0` case, which is by far the most common `gen` value.)

In the already existing fallback case, where the `fontName` is used to when creating the `font.loadedName`, we allow any alphanumeric character. Hence I don't see how (as mentioned above) e.g. `font.loadedName = g_d0_f4R` would be an issue here.
2016-07-21 16:03:33 +02:00
Tim van der Meij
10f9f11ec4 Merge pull request #7490 from Snuffleupagus/issue-7426
Don't map glyphs to the Lepcha Unicode block (issue 7426)
2016-07-21 14:39:19 +02:00
Jonas Jenwald
f297e4d17c [api-minor] Add a parameter to PDFPageProxy_getTextContent that controls whether PartialEvaluator_getTextContent will attempt to combine same line text items
From the discussion in issue 7445, it seems that there may be cases where an API consumer would want to get the text content as is, without combined text items.
2016-07-19 13:38:57 +02:00
Jonas Jenwald
9228a04061 Merge pull request #7493 from Snuffleupagus/issue-7492
Catch errors and continue parsing in `parseCMap` (issue 7492)
2016-07-19 10:31:26 +02:00
Jonas Jenwald
90d19de935 Catch errors and continue parsing in parseCMap (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.

The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.

Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.

Fixes 7492.
2016-07-18 16:39:56 +02:00
Tim van der Meij
0da97ad2a0 Merge pull request #7485 from Snuffleupagus/resetCurrentPageView
Ensure that we don't reset the current page view if the user inputs an invalid page number (PR 7289 follow-up)
2016-07-17 19:49:11 +02:00
Tim van der Meij
3ab68f2e06 Merge pull request #7489 from ka7/spelling
trivial spelling fixes
2016-07-17 19:40:17 +02:00
Jonas Jenwald
64783c8b6e Don't map glyphs to the Lepcha Unicode block (issue 7426)
In the PDF file in the issue, some of the glyphs end up being mapped to the Lepcha Unicode block; see https://en.wikipedia.org/wiki/Lepcha_(Unicode_block).
This didn't use to matter, but after HarfBuzz updates that improved support for Lepcha fonts, in particular https://bugzilla.mozilla.org/show_bug.cgi?id=1249861, some glyphs are now moved horizontally.
To avoid that, this patch adds the Lepcha block to the list of Unicode ranges that we skip when building the glyph mapping.

Fixes 7426.
2016-07-17 16:53:36 +02:00
klemens
6f03f62327 trivial spelling fixes 2016-07-17 14:33:41 +02:00
Jonas Jenwald
11381cdb0f Update l10n files 2016-07-15 11:48:37 +02:00
Jonas Jenwald
9f34700e0d Ensure that we don't reset the current page view if the user inputs an invalid page number (PR 7289 follow-up)
After PR 7289, we'll now reset the current page view in cases where I don't think we should. To avoid this, this patch ensures that we'll not modify the position when the page number is out-of-bounds.

**STR:**
1. Open http://mozilla.github.io/pdf.js/web/viewer.html#page=1&zoom=auto,-98,696
2. Enter an invalid number, e.g. `1000`, in the `pageNumber` input.

**ER:**
The current position in the document shouldn't change, since the page number wasn't valid.

**AR:**
The document resets to the top of the page `1`.
2016-07-14 12:46:33 +02:00
Tim van der Meij
1695893526 Merge pull request #7478 from PeterDaveHelloKitchen/image-optimize
optimize png images using zopflipng
2016-07-10 13:46:54 +02:00
Peter Dave Hello
625d637297 optimize png images using zopflipng 2016-07-10 17:49:16 +08:00
Tim van der Meij
223adf4656 Merge pull request #7481 from Snuffleupagus/firefox-addon-remove-compatibility
[Firefox addon] Remove compatibility.js
2016-07-09 20:45:46 +02:00
Tim van der Meij
bd562bb39c Merge pull request #7480 from Snuffleupagus/remove-MozBlobBuilder-fallback
Remove the obsolete `MozBlobBuilder` fallback from the `createBlob` utility function
2016-07-09 20:40:24 +02:00
Jonas Jenwald
a69e862bc4 [Firefox addon] Remove compatibility.js
This was added in PR 4865, but hasn't been necessary for quite some time now (and the minimum version is currently Firefox 38 for the addon).
2016-07-09 17:59:06 +02:00
Jonas Jenwald
8f4ec669d0 Remove the obsolete MozBlobBuilder fallback from the createBlob utility function
`MozBlobBuilder` has been obsolete since Firefox 14, so there's no reason to keep this code around anymore.
2016-07-09 16:37:05 +02:00
Tim van der Meij
43613f19f9 Merge pull request #7466 from Snuffleupagus/PDFViewerApplication-open-remove-fallback-args
Remove handling of fallback arguments from `PDFViewerApplication.open`
2016-07-09 15:51:25 +02:00
Tim van der Meij
d728651455 Merge pull request #7479 from Snuffleupagus/recoverGlyphName-warn-to-info
Change the `warn` to `info` in `recoverGlyphName` to reduce the console spam
2016-07-09 15:34:59 +02:00
Jonas Jenwald
51e46fa1a7 Change the warn to info in recoverGlyphName to reduce the console spam
After PR 7441, where `recoverGlyphName` is used a lot more than before, many PDF files will generate a lot of warnings the console. For normal usage, compared to debugging/development, this is probably more annoying than helpful.
2016-07-09 12:08:41 +02:00
Yury Delendik
bca1aebeac Merge pull request #7458 from Snuffleupagus/updateUIToolbar
Consolidate updating of various Toolbar state (e.g. page and scale) in one method in `PDFViewerApplication`
2016-07-08 12:34:39 -05:00
Yury Delendik
b87676078c Merge pull request #7455 from Snuffleupagus/issue-7448
Ensure that the necessary src/* dependencies are loaded before the viewer, when it's run with `gulp server` (issue 7448)
2016-07-08 12:34:09 -05:00
Tim van der Meij
b6826a46a8 Merge pull request #7453 from simoncpu/master
Expose the text widget's maximum length.
2016-07-07 01:03:40 +02:00
Tim van der Meij
10cd37cfb2 Merge pull request #7473 from Snuffleupagus/links-mxr-to-dxr
Update `mxr.mozilla.org` links to point to `dxr.mozilla.org` instead
2016-07-06 22:26:38 +02:00
Brendan Dahl
1f3f4a8dd7 Merge pull request #7441 from Snuffleupagus/issue-7439
Fallback to attempt to recover standard glyph names when amending the `charCodeToGlyphId` with entries from the `differences` array in `type1FontGlyphMapping` (issue 7439)
2016-07-06 13:02:21 -07:00
Jonas Jenwald
87229a086f Update mxr.mozilla.org links to point to dxr.mozilla.org instead
Given that MXR has been officially retired, see https://groups.google.com/forum/#!topic/mozilla.dev.platform/_k-ditFrne4, we've got a couple of links that are no longer working.
2016-07-06 11:42:16 +02:00
Tim van der Meij
b9e903808f Merge pull request #7467 from Snuffleupagus/getAttachments-unit-test
Add a `getAttachments` unit-test for a PDF file that actually contains attachments
2016-07-04 20:33:56 +02:00
Jonas Jenwald
72c1df726e Add a getAttachments unit-test for a PDF file that actually contains attachments 2016-07-02 13:13:30 +02:00
Jonas Jenwald
cb6a7e5503 Remove handling of fallback arguments from PDFViewerApplication.open
The method signature was improved in PR 6546, which was included in the `1.2.109` release from last November.
Hence I think that we should now be able to remove the fallback code for the old method signature. Note that this patch now throws an `Error` in `GENERIC` builds, to clearly indicate that the `open` callsite must be modified.
2016-07-02 11:31:32 +02:00
Yury Delendik
f082407ab4 Merge pull request #7463 from Snuffleupagus/fix-bug-1268749-fallout
Add back moz-specific fullscreen support code for ´MOZCENTRAL` builds (bug 1268749, PR 7273 follow-up)
2016-07-01 08:09:08 -05:00
Jonas Jenwald
2f127df97b Add back moz-specific fullscreen support code for ´MOZCENTRAL` builds (bug 1268749, PR 7273 follow-up)
In PR 7273, we simplified the `MOZCENTRAL` specific check for fullscreen support. Unfortunately I've just, by coincidence, found out about https://bugzilla.mozilla.org/show_bug.cgi?id=1268749, which disabled the unprefixed fullscreen support in release versions of Firefox. If we do nothing, this will lead to Presentation Mode being unavailable in future Firefox releases.

This patch should fix things for now, and I'm afraid that we'll need to uplift it to Firefox 49 as well.
2016-07-01 14:11:58 +02:00
Yury Delendik
3cba2cb258 Fixes SeaMonkey version 2016-06-29 17:54:11 -05:00
Brendan Dahl
e2e657e44f Merge pull request #7390 from Snuffleupagus/issue-7180
Add upper-case `I` as a possible space replacement fallback in `Font.spaceWidth` to improve text-selection (issue 7180)
2016-06-29 15:11:19 -07:00
Jonas Jenwald
dd0fe10a52 Consolidate updating of various Toolbar state (e.g. page and scale) in one method in PDFViewerApplication
With the changes in PR 7289, we no longer dispatch a 'pagechanging' event on load. Since most PDF documents open on the first page, this means that the `previous` and `firstPage` buttons are no longer correctly disabled.
To avoid this, this patch moves the code that updates various UI toolbar state into one method, which is then called on document initialization and from the various existing event handling functions.
2016-06-29 22:36:45 +02:00
Jonas Jenwald
4342993a3f Ensure that the necessary src/* dependencies are loaded before the viewer, when it's run with gulp server (issue 7448)
Fixes 7448.
2016-06-29 15:19:28 +02:00
Simon Cornelius P. Umacob
d872fc90b9 Expose the text widget's maximum length. 2016-06-29 17:04:33 +08:00
Jonas Jenwald
bdd58ab1d2 Ignore .notdef in the differences array when building a fallback toUnicode map in PartialEvaluator_buildToUnicode (issue 5256)
Fixes 5256.
2016-06-27 16:20:23 +02:00
Jonas Jenwald
7866109af9 Fallback to attempt to recover standard glyph names when amending the charCodeToGlyphId with entries from the differences array in type1FontGlyphMapping (issue 7439)
Fixes 7439.
2016-06-25 14:54:34 +02:00
Tim van der Meij
e908b71309 Merge pull request #7438 from Snuffleupagus/README-addon-compat
Update README.md to only guarantee Firefox addon compatibility with the current ESR version
2016-06-25 14:10:39 +02:00
Jonas Jenwald
3b9042034b Update README.md to only guarantee Firefox addon compatibility with the current ESR version
To reduced the amount of compatibility code that we need to maintain in the addon, I think that we should be more explicit about which Firefox versions we intend to support. In the future, this should allow us to more quickly remove old compatibility code.
Furthermore, this patch also tries to be more explicit about the addon support for Seamonkey, by defining it in terms of the underlying Firefox version.
2016-06-25 08:59:59 +02:00
Yury Delendik
671f33a324 Merge pull request #7427 from Snuffleupagus/fonts-skip-mapping-ideographic-space
Skip mapping of glyphs to Unicode "Ideographic space" (issue 7416)
2016-06-24 10:57:55 -05:00
Yury Delendik
546e22397e Merge pull request #7437 from Snuffleupagus/addon-seamonkey-compat
[Firefox addon] Feature detect `originAttributes` to make it Seamonkey 2.40 compatible
2016-06-24 10:25:49 -05:00