Commit Graph

9186 Commits

Author SHA1 Message Date
Brendan Dahl
15e1ae4e3f Merge pull request #7639 from Snuffleupagus/bug-1252420
Replace empty CharStrings with '.notdef' in `Type1Font_wrap` to prevent OTS from rejecting the font (bug 1252420)
2016-09-20 11:56:47 -07:00
Jonas Jenwald
9e927ded93 Update l10n files 2016-09-20 12:51:52 +02:00
Tim van der Meij
c0e82dbc38 Merge pull request #7642 from Rob--W/crx-type-from-content-disposition-header
Deduct file type from content-disposition if needed
2016-09-19 01:20:58 +02:00
Tim van der Meij
ab1b4cec5d Merge pull request #7640 from timvandermeij/interactive-forms-rm-global
Interactive forms: remove global PDFJS usage
2016-09-19 01:02:44 +02:00
Tim van der Meij
2da2c45889 Interactive forms: remove global PDFJS usage 2016-09-19 00:12:42 +02:00
Tim van der Meij
2d287c867e Merge pull request #7645 from Snuffleupagus/TextWidgetAnnotation-double-rendering
Prevent rendering `TextWidgetAnnotation`s in both the `core`/`display` layer (issue 7643)
2016-09-18 22:49:32 +02:00
Jonas Jenwald
170871ab3d Prevent rendering TextWidgetAnnotations in both the core/display layer (issue 7643) 2016-09-18 15:42:22 +02:00
Rob Wu
ae74e1bbd6 Deduct file type from content-disposition
A user encountered a response that looks like:

URL: some gibberish
Headers:

    Content-Type: application/octet-stream
    Content-Disposition: attachment; filename="something.pdf"

In the Chrome extension, the "attachment" content disposition is almost
always ignored (i.e. the PDF Viewer will try to view it anyway). So we
need to fall back to the Content-Disposition header if the URL check is
inconclusive.
2016-09-17 22:34:18 -07:00
Tim van der Meij
f062695d62 Merge pull request #7633 from timvandermeij/interactive-forms-tx-flags
Text widget annotations: support read-only/multiline fields and improve testing
2016-09-17 17:19:47 +02:00
Tim van der Meij
dbea302a6e Text widget annotations: do not render on canvas as well
If interactive forms are enabled, then the display layer takes care of
rendering the form elements. There is no need to draw them on the canvas
as well. This also leads to issues when values are prefilled, because
the text fields are transparent, so the contents that have been rendered
onto the canvas will be visible too.

We address this issue by passing the `renderInteractiveForms` parameter
to the render task and handling it when the page is rendered (i.e., when
the canvas is rendered).
2016-09-17 15:24:48 +02:00
Tim van der Meij
adf0972ca5 Text widget annotations: improve unit and reference tests
This patch improves the unit tests by testing the support for read-only
and multiline fields. Moreover, we add a reference test to ensure that
the text widgets are not only rendered, but also that their contents are
styled properly.

Finally, we perform minor improvements in `src/core/annotation.js`, for
example adding missing comments.
2016-09-17 15:24:48 +02:00
Tim van der Meij
f6965fadc0 Text widget annotations: support multiline and read-only fields
Moreover, this patch provides us with a framework for handling field
flags in general for all types of widget annotations.
2016-09-17 15:24:47 +02:00
Jonas Jenwald
aadcbe98c8 Replace empty CharStrings with '.notdef' in Type1Font_wrap to prevent OTS from rejecting the font (bug 1252420)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1252420.
2016-09-17 14:39:10 +02:00
Jonas Jenwald
4acd31f51e Merge pull request #7550 from Snuffleupagus/Type1-toUnicode-builtInEncoding-fallback
For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
2016-09-16 17:51:55 +02:00
Brendan Dahl
834a7ff329 Merge pull request #7636 from yurydelendik/rm-refresh
Drops unneeded HTTP refresh header for the extension.
2016-09-15 10:01:11 -07:00
Yury Delendik
503bf45eca Drops unneeded HTTP refresh header for the extension.
Some sites doing that by mistake. Aligning the extension functionality with behavior of other browsers/plugins..
2016-09-15 09:12:16 -05:00
Tim van der Meij
26da2d57ce Merge pull request #7632 from Snuffleupagus/more-efficient-expandTextDivs
[EnhanceTextSelection] Make `expandTextDivs` more efficient by updating all styles at once instead of piecewise
2016-09-15 16:01:07 +02:00
Tim van der Meij
3b94ecf563 Merge pull request #7634 from Snuffleupagus/remove-mozDash
Remove the deprecated `mozDash`/`mozDashOffset` canvas 2D context methods
2016-09-15 14:10:31 +02:00
Jonas Jenwald
8eaa2cbce3 Remove the deprecated mozDash/mozDashOffset canvas 2D context methods
According to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility) the standard versions of these methods have been supported since Firefox 27, which was released over two and a half years ago. (See the dates in https://wiki.mozilla.org/RapidRelease/Calendar#Past_branch_dates)

Furthermore the non-standard properties are now in the process of being removed, please see https://groups.google.com/forum/#!topic/mozilla.dev.platform/UIudMABegcY.
Hence I don't think that we need to keep the old `moz` prefixed ones as fallback any more.
2016-09-15 10:05:40 +02:00
Jonas Jenwald
cb5f9df0c8 [EnhanceTextSelection] Make expandTextDivs more efficient by updating all styles at once instead of piecewise
I intended to provide proper benchmarking results here, as outlined in https://github.com/mozilla/pdf.js/wiki/Benchmarking-your-changes, but after wasting a couple of hours over the weekend getting weird results I gave up.
It appears that there's a lot of, i.e. way too much, variance between subsequent runs of `text` tests for the results to be meaningful.
(Previously I've only benchmarked `eq` tests, so I don't know if the `text` tests has never worked well or if it's a newer problem. For reference, please see the results of back-to-back benchmark runs on the current `master` with a *very* simple manifest file: [link here].)

Instead I used `console.time/timeEnd` in `appendText` and `expandTextDivs` to be able to compare the performance with/without the patch. The entire viewer was (skip-cache) reloaded between measurements, and the result are available here: [link here].
Given the troubles I've had with benchmarking, I've not yet computed any statistics on the results (e.g. mean, variance, confidence intervals, and so on).
However, just by looking at the data I think it's safe to say that this patch first of all doesn't seem to regress the current performance. Secondly it certainly looks *very* likely that this patch actually improves the performance, especially for the one-glyph-per-text-div case (cf. issue 7224).

Re: issue 7584.
2016-09-14 21:19:28 +02:00
Jonas Jenwald
a7c35025fe Merge pull request #7629 from timvandermeij/interactive-form-unit-tests
Text widget annotations: implement unit testing and sanitize data values
2016-09-13 16:52:30 +02:00
Tim van der Meij
323e86c442 Text widget annotations: implement unit testing and sanitize data values 2016-09-13 14:57:11 +02:00
Tim van der Meij
4d1592883d Merge pull request #7626 from yashsriv/lint-fix-url-polyfill
Fix lint warnings in URL polyfill
2016-09-12 21:15:47 +02:00
Yash Srivastav
4e428c7675
Fix lint warnings in URL polyfill 2016-09-12 20:34:51 +05:30
Tim van der Meij
03588ccbf7 Merge pull request #7623 from Snuffleupagus/jpx-error
Change `src/core/jpx.js` to use the `error` utility function instead of using `throw new Error`
2016-09-12 15:34:05 +02:00
Jonas Jenwald
230b1e3275 Merge pull request #7624 from Snuffleupagus/yury-fake-cloning
Adding "proper" message port for fake worker.
2016-09-12 12:41:33 +02:00
Yury Delendik
160b176109 Adding "proper" message port for fake worker. 2016-09-12 11:17:10 +02:00
Jonas Jenwald
f620f61887 Change src/core/jpx.js to use the error utility function instead of using throw new Error
Note that in `parseCodestream` I purposly left the `throw new Error` instances inside of the `try` block, since we don't want to throw any `Errors` while in recovery mode.
Finally somewhat unrelated to the rest of the patch, but I moved the `doNotRecover` variable declaration outside of the `try` block to avoid variable hoisting given that it's accessed inside the `catch` block.
2016-09-12 11:05:43 +02:00
Tim van der Meij
6b05cfd1b8 Merge pull request #7622 from timvandermeij/interactive-forms-text
Text widget annotations: implement maximum length and text alignment
2016-09-11 21:42:22 +02:00
Jonas Jenwald
325f7afcca For embedded Type1 fonts without included ToUnicode/Encoding data, attempt to improve text selection by using the builtInEncoding to amend the toUnicode map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.

Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
2016-09-11 20:54:10 +02:00
Tim van der Meij
be485f59ab Text widget annotations: implement maximum length and text alignment
Moreover, we refactor the code a bit to extract code that is shared
between the two branches and we only apply text alignment (and create
the array) when it is actually defined, since it's optional and left is
already the default.
2016-09-11 20:49:00 +02:00
Tim van der Meij
bf6f5d1cc9 Merge pull request #7621 from Snuffleupagus/more-symbolic-fonts-without-included-encoding-tests
Add a couple more, mostly `text`, reference tests for non-embedded symbolic fonts without included encoding information
2016-09-11 20:44:30 +02:00
Jonas Jenwald
ae2cc9119b Add a couple more, mostly text, reference tests for non-embedded symbolic fonts without included encoding information
I've started to look into how we can fix issue 7580, but quickly became worried that fixing it could easily mean that we'd trade one fixed PDF file for a multitude of broken ones.

Hence I started going through the history of the code that choose the fallback encoding, and noticed that it has been changed a number of times over the years to deal with various cases of weirdness/errors in non-embedded fonts.
To my relief it turned out that almost all the PRs, please see a possibly incomplete [list here], that changed this code actually included `eq` test-cases.

However, in one case it appears that a PR missed to add a test-case. Furthermore since the fallback encoding may also be the only source for creating a `toUnicode` map, changing the encoding could possibly regress only the text-selection despite a PDF file still rendering correctly.
Therefore, this PR adds one new `eq` test, and also a number of additional `text` tests for PDF files already present in the test-suite.

Note that it's obviously possible that there's a certain overlap between the added tests, but I'd be *a whole lot* more concerned with causing regressions.
2016-09-11 16:38:39 +02:00
Jonas Jenwald
1fae435e88 Merge pull request #7546 from Snuffleupagus/issue-7544
Don't duplicate the first entry in the `charCodeToGlyphId` map for CIDFontType2 fonts with a `CIDToGIDMap` that already mapped the first entry to a non-zero `glyphId` (issue 7544)
2016-09-11 15:20:36 +02:00
Jeremy Press
e68f4f855f fixing 7590 by delaying div shrink after mouse up 2016-09-09 13:55:19 -07:00
Jonas Jenwald
0b75f63c03 Don't duplicate the first entry in the charCodeToGlyphId map for CIDFontType2 fonts with a CIDToGIDMap that already mapped the first entry to a non-zero glyphId (issue 7544)
Fixes 7544.
2016-09-09 22:33:41 +02:00
Tim van der Meij
b112f9f9f4 Merge pull request #7600 from Snuffleupagus/issue-7598
Check that Type1C fonts does not actually contain OpenType font files (issue 7598)
2016-09-09 22:02:58 +02:00
Tim van der Meij
22c7ff494a Merge pull request #7609 from Snuffleupagus/enhanceTextSelection-pref-hack
Add a `enhanceTextSelection` preference
2016-09-09 16:38:45 +02:00
Tim van der Meij
23a0264a15 Merge pull request #7619 from Snuffleupagus/SecondaryToolbar-setMaxHeight-events
Only update the `max-height` of the `SecondaryToolbar` when it's actually visible
2016-09-09 16:07:51 +02:00
Jonas Jenwald
be8a69a52c Ensure that we provide the source parameter when dispatching the button click events in SecondaryToolbar (PR 7313 follow-up) 2016-09-09 08:16:10 +02:00
Jonas Jenwald
6e126b31dc Only update the max-height of the SecondaryToolbar when it's actually visible
There's really no good reason to attempt to adjust the `max-height` of the `SecondaryToolbar` when it's not visible, so let's not do that anymore.
Also, we can listen for the `resize` event in `SecondaryToolbar`, to avoid having to manually call the `max-height` adjust function from various event handlers in `app.js`. Please note that by always adjusting the `max-height` when the toolbar is opened we no longer need the `localized` event, since it was mainly used to set a correct inital `max-height` value.
2016-09-09 08:16:09 +02:00
Jonas Jenwald
e12c48b73f Add a enhanceTextSelection preference
Please note that this is a hack, but I think that it should be OK for now to atleast get the preference landed. Refer to the code comment for further information.

Re: issue 7584 and PR 7586.
2016-09-08 10:22:01 +02:00
Jonas Jenwald
ca61ccc533 Merge pull request #7602 from timvandermeij/interactive-forms
Render interactive form (AcroForm) text widget annotations
2016-09-08 10:13:27 +02:00
Tim van der Meij
e281ce7c73 Enable regression testing for interactive forms 2016-09-07 16:50:44 +02:00
Tim van der Meij
e686db250c Render interactive form (AcroForm) text widget annotations
This patch is the first step towards implementing support for
interactive forms (AcroForms). It makes it possible to render text
widget annotations exactly like Adobe Reader/Acrobat.

Everything we implement for AcroForms is disabled by default using a
preference, mainly because it is not ready to use yet, but has to
implemented in many steps to avoid complexity. The preference allows us
to work with the code while not exposing the behavior by default. Mainly
storing entered values and printing them is still absent, which would be
minimal requirements for enabling this by default.
2016-09-07 15:37:28 +02:00
Jonas Jenwald
8dbb5a7c4a Merge pull request #7596 from timvandermeij/widget-annotation-cleanup
Improve the structure for widget annotations
2016-09-06 13:46:31 +02:00
Jonas Jenwald
44b75c01a1 Check that Type1C fonts does not actually contain OpenType font files (issue 7598)
This patch is yet another instalment in the (never ending) series of patches for PDF files that specify completely incorrect Type/Subtype for its fonts. In this case Type1/Type1C, when in fact OpenType would have been correct.

Fixes 7598.
2016-09-06 10:13:11 +02:00
Tim van der Meij
576f742047 Improve the structure for widget annotations
Currently, we only support text widget annotations (field type 'Tx')
partially. However, the current code does not make this entirely clear
and does not provide a warning when an unsupported field type is
encountered, making it harder to determine why rendering fails.

Moreover, in the display layer we make no distinction between the
various types of widget annotations, causing the code for text widget
annotations to also be executed for other types of widget annotations in
a fallback situation.

This patch improves the structure of the widget annotation code. In the
core layer, we use the same structure we use for non-widget annotations
in the factory and provide a clear warning when an unsupported type is
encountered. In the display layer, we do the same and split the
`WidgetAnnotationElement` class into two classes, namely
`TextWidgetAnnotationElement` for text widget annotations and
`WidgetAnnotationElement` for other unsupported annotations as a
fallback. From this it clear that we only support text widget
annotations and nothing else.
2016-09-06 00:26:05 +02:00
Tim van der Meij
b26af7ee24 Merge pull request #7595 from Snuffleupagus/api-reject-with-Error
In `display/api.js` ensure that we always reject with an `Error` in `JpegDecode`, and adjust a couple of other rejection sites as well
2016-09-05 17:14:44 +02:00
Jonas Jenwald
37998076c9 In display/api.js ensure that we always reject with an Error in JpegDecode, and adjust a couple of other rejection sites as well
In the case where the document was destroyed, we were rejecting the `Promise` in `JpegDecode` with a string instead of an `Error`. The patch also brings the wording more inline with other such rejections.

Use the `isInt` utility function when validating the `pageNumber` parameter in `WorkerTransport_getPage`, to make it more obvious what's actually happening. There's also a couple more unit-tests added, to ensure that we always fail in the expected way.

Finally, we can simplify the rejection handling in `WorkerTransport_getPageIndexByRef` somewhat. (Note that the only reason for using `catch` here is that since the promise is rejected on the worker side, the `reason` becomes a string instead of an `Error` which is why we "re-reject" on the display side.)
2016-09-05 16:35:32 +02:00