Commit Graph

12862 Commits

Author SHA1 Message Date
Tim van der Meij
36e149800e
Unconditionally set the field value for choice widgets in the annotation storage
This commit makes the following improvements:

- The code is similar to the other interactive form widgets now, with a
  clear note for the only difference.
- Calling `getOrCreateValue` unconditionally ensures that choice widgets
  always have a value in the annotation storage. Previously we only
  inserted a value in the annotation storage when an option matched or
  when a selection was changed. However, this causes breakage when
  saving/printing because comboboxes, which we don't fully support yet
  but are rendered, might not have a value in storage at all. Their
  field value might not match any option since it allows the user to
  enter a custom value.
- Calling `getOrCreateValue` unconditionally ensures that forms with
  choice widgets no longer always trigger a warning when the user
  navigates away from the page. This fixes
  https://github.com/mozilla/pdf.js/pull/12241#discussion_r474279654
2020-08-22 16:01:33 +02:00
Jonas Jenwald
a8de614a9f Also enable renderInteractiveForms by default in the viewer components (PR 12201 follow-up)
Given that `renderInteractiveForms` is now enabled by default in "full" viewer, it seems reasonable to enable it by default in the viewer components as well.
Especially considering that it's simple to disable, when creating the affected components, for anyone implementing their own viewer.
2020-08-22 14:24:04 +02:00
Tim van der Meij
5fed7112a2
Use the export value instead of the display value for choice widget option selection
The export value is used when the document is saved, so it should also
be used when the document is opened to determine which choice widget
option is selected. The display value is, as the name implies, only to
be used for viewer display purposes and not for other logic.

This makes sure that in the document from #12233 the "Favourite colour"
choice widget is correctly initialized with "Red" instead of "Black"
because the field value is equal to the export value (always the case),
but not the display value (not always the case). Moreover, saving now
also correctly uses the export value and not the display value.
2020-08-22 14:11:41 +02:00
Tim van der Meij
37c5660394
Merge pull request #12260 from utopianknight/replace-menuArrow-icon
Replace menu dropdown icon
2020-08-22 13:28:41 +02:00
utopianknight
43a439643d Replaced menu dropdown icon 2020-08-22 12:10:51 +04:00
Tim van der Meij
1ff578cbd4
Merge pull request #12244 from yangjiang3973/fix-webpack
fix webpack config problem caused by breaking changes of worker-loader
2020-08-21 23:46:29 +02:00
Tim van der Meij
909c5af5ed
Merge pull request #12256 from escapewindow/12241-followup
#12241 followup - move event listener to PDFViewerApplication.load
2020-08-21 23:28:37 +02:00
Tim van der Meij
3c790936c1
Merge pull request #12247 from timvandermeij/acroform-choice-null
Improve the field value parsing for choice widgets to handle `null` values
2020-08-21 23:17:20 +02:00
Aki Sasaki
b1423336c3 #12241 followup - move event listener to PDFViewerApplication.load 2020-08-21 09:53:39 -07:00
Brendan Dahl
0d5ef5dd0a
Merge pull request #12248 from brendandahl/pdf-save-as
Support file save triggered from the Firefox integrated version.
2020-08-20 18:11:29 -07:00
Brendan Dahl
8023175103 Support file save triggered from the Firefox integrated version.
Related to https://bugzilla.mozilla.org/show_bug.cgi?id=1659753

This allows Firefox trigger a "save" event from ctrl/cmd+s or the "Save
Page As" context menu, which in turn lets pdf.js generate a new PDF if
there is form data to save.

I also now use `sourceEventType` on downloads so Firefox can determine if
it should launch the "open with" dialog or "save as" dialog.
2020-08-20 18:05:08 -07:00
Brendan Dahl
10f61b8c96
Merge pull request #12241 from escapewindow/prevent-default
confirm if leaving a modified form without saving
2020-08-20 17:56:59 -07:00
Aki Sasaki
83365a3756 confirm if leaving a modified form without saving 2020-08-20 17:23:06 -07:00
Tim van der Meij
2e95d08f12
Merge pull request #12251 from DesWurstes/master
Return the query with the findcontrolstate
2020-08-21 00:08:02 +02:00
Tim van der Meij
164be97dfc
Merge pull request #12250 from Snuffleupagus/dropdownToolbarButton-adjustWidth
Update the zoom dropdown width calculation to work better in locales with long zoom-strings (PR 11077 follow-up)
2020-08-20 22:41:36 +02:00
DesWurstes
72f48ee089 Return the query with the findcontrols 2020-08-20 11:18:43 +01:00
Jonas Jenwald
2683f44b40 Update the zoom dropdown width calculation to work better in locales with long zoom-strings (PR 11077 follow-up)
With the changes in PR 11077, the zoom dropdown now looks "squashed" in locales with longer than average zoom-strings[1]. The reason is that the zoom-value and the dropdown-icon are too close together, which doesn't look good in affected locales.

To fix this, the following changes are made:
 - Increase the calculated dropdown width, in `Toolbar._adjustScaleWidth`, to account for the much wider icon (7 px -> 16 px) and the increased padding.
 - Move the dropdown-icon *slightly* outwards, and also *slightly* reduce the left (right in RTL locales) padding of the dropdown-contents.
 - Finally, remove the right (left in RTL locales) padding to reduce the chance of the *default* browser dropdown-icon being visible.

---
[1] This affects e.g. the `de` and `nl` locales, but there's probably other examples as well.
2020-08-20 09:57:42 +02:00
Tim van der Meij
12c20772ac
Improve the field value parsing for choice widgets to handle null values
The specification states that the field value is `null` if no item is
selected and we didn't handle this case properly. Even though this did
not break the rendering because we always convert the value to an array
and the `includes` check in the display layer would simply not match,
the field value would be `[null]` which is not expected and strange from
an API perspective.

This commit fixes that by ensuring that we return an empty array in
case the field value is `null`. The API therefore still always gives an
array for the field value, but now the code is more specific so that the
value is either an empty array or an array of strings.
2020-08-19 23:27:50 +02:00
Tim van der Meij
3ca037af78
Combine the choice widget field value unit tests into one parametrized unit test
This commit follows the same pattern as another unit test in this file
and both reduces existing and future code duplication (since the next
commit will extend this test with an additional input).
2020-08-19 23:27:24 +02:00
Tim van der Meij
965d20db2a
Merge pull request #11077 from utopianknight/modern-look
Implement Photon design for the viewer
2020-08-19 22:53:11 +02:00
utopianknight
c0b671d91b Photon Design 2020-08-19 14:21:13 +04:00
IanJiang0817
dee0c29f6f fix webpack config problem caused by breaking changes of worker-loader 2020-08-19 17:02:16 +08:00
Tim van der Meij
b52b36f6a5
Merge pull request #12230 from timvandermeij/reference-test-print
Implement reference testing for printing
2020-08-18 13:11:18 +02:00
Tim van der Meij
483efedc66
Include reference tests for text/choice/button widget printing 2020-08-18 12:36:33 +02:00
Tim van der Meij
8ccf09d5dd
Implement reference testing for printing
This commit includes support for rendering pages in printing mode,
which, when combined with annotation storage data, is useful for testing
if form data is correctly rendered onto the printed canvas.
2020-08-18 12:36:33 +02:00
Tim van der Meij
37e9c97cec
Merge pull request #12229 from brendandahl/ann-event
Dispatch event when annotations have finished rendering.
2020-08-17 23:43:04 +02:00
Brendan Dahl
7bba4931ad Dispatch event when annotations have finished rendering.
This is needed for some smoke tests in mozilla central for testing forms
in pdf.js.

Note: AnnotationLayerBuilder.render() doesn't really need to be async, but
we're talking of making the annotation's render functions async, so this
will make that switch easier.
2020-08-17 14:29:24 -07:00
Tim van der Meij
ebb903e506
Merge pull request #12227 from Snuffleupagus/dist-more-es5
Include `image_decoders-es5`/`minified-es5` in the `pdfjs-dist` library (issue 12220)
2020-08-17 19:30:26 +02:00
Jonas Jenwald
e079c180c3 Include minified-es5 in the pdfjs-dist library (issue 12220)
Note that this will increase the run-time of `gulp dist` and `gulp dist-install`, but that's unavoidable given that there's now additional building happening.
2020-08-17 15:18:14 +02:00
Jonas Jenwald
1cf660ba73 Add a image_decoders-es5 gulp task, and include it in the pdfjs-dist library 2020-08-17 14:59:50 +02:00
Tim van der Meij
628a1ee04e
Merge pull request #12219 from Snuffleupagus/handleTransferFunction
Add (basic) support for transfer functions to Images (issue 6931, bug 1149713)
2020-08-17 13:26:19 +02:00
Jonas Jenwald
1058f16605 Add (basic) support for transfer functions to Images (issue 6931, bug 1149713)
This is *similar* to the existing transfer function support for SMasks, but extended to simple image data.
Please note that the extra amount of data now being sent to the worker-thread, for affected /ExtGState entries, is limited to *at most* 4 `Uint8Array`s each with a length of 256 elements.

Refer to https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G9.1658137 for additional details.
2020-08-17 10:34:12 +02:00
Jonas Jenwald
9d3e046a4f Don't cache /ExtGState entries that contain fonts (PR 12087 follow-up)
I completely overlooked the fact that `PartialEvaluator.handleSetFont` also updates the current `state`, which means that currently we're not actually handling font data correctly for cached /ExtGState data. (Thankfully, using /ExtGState to set a font is somewhat rare in practice.)
2020-08-17 08:17:25 +02:00
Tim van der Meij
192afb87e3
Merge pull request #12203 from staktrace/zoomfix
Bug 1392361 - Fix zooming sensitivity on macOS
2020-08-16 22:36:37 +02:00
Tim van der Meij
9be177d2de
Merge pull request #12210 from Snuffleupagus/minified-keep-names
Keep the original class/function names when minifying code (issue 12209)
2020-08-16 22:19:30 +02:00
Tim van der Meij
66bbe82cc5
Merge pull request #12212 from staktrace/touchfix
Bug 1643508 - Disable touch-based pinch zooming on pdf.js.
2020-08-16 22:12:02 +02:00
Brendan Dahl
67c361b2f4
Merge pull request #12211 from Snuffleupagus/_saveInProgress-reset
Wait until saving has finished before resetting `PDFViewerApplication._saveInProgress` (PR 12137 follow-up)
2020-08-13 08:38:47 -07:00
Kartikaya Gupta
c6e5686b6a Bug 1643508 - Disable touch-based pinch zooming on pdf.js.
Currently using a touchscreen with pdf.js doesn't work so well. In Firefox,
with apz.allow_zooming = false (default on current release/beta), it does a
reflow zoom which makes the UI elements bigger. And with apz.allow_zooming = true
(default on current Firefox nightly), or in Chrome, it does a smooth pinch-zoom
but that also scales up the entire UI. Neither of these is a particularly good
experience, so this patch just disables any multi-touch gestures. Touch-based
panning (which involves a single touch point) is left unaffected.
2020-08-13 09:22:30 -04:00
Jonas Jenwald
b26d736809 Ensure that the "DocException" message handler, in the API, will always either error or warn (depending on the build) if a valid Error isn't found
Having this present would have made debugging issues 11941 and 12209 so much quicker and easier.
2020-08-13 13:17:30 +02:00
Jonas Jenwald
22cb59e7d0 Wait until saving has finished before resetting PDFViewerApplication._saveInProgress (PR 12137 follow-up)
I obviously missed this during review, but currently `PDFViewerApplication._saveInProgress` is reset *synchronously* in `PDFViewerApplication.save`.
That was probably not intended, since it essentially renders the `PDFViewerApplication._saveInProgress` check pointless given that the actual saving is an *asynchronous* operation.
2020-08-13 13:00:29 +02:00
Jonas Jenwald
ea5581b70a Keep the original class/function names when minifying code (issue 12209)
While this will obviously increase the size of the output of `gulp minified`/`gulp minified-es5` *slightly*, the resulting files are still a lot smaller than the non-minified builds.

See https://github.com/terser/terser#minify-options for information about various Terser options.
2020-08-13 11:27:58 +02:00
Brendan Dahl
e50cb4c9d5
Merge pull request #12201 from brendandahl/enable-forms
Enable renderInteractiveForms by default.
2020-08-12 15:20:52 -07:00
Kartikaya Gupta
213676b5e8 Bug 1392361 - Fix zooming sensitivity on macOS
The original code would get a long sequence of miniscule "tick" values while
pinch-zooming, and each tick value would cause a 1.1x zoom. So even the smallest
pinch gesture on a trackpad would cause high amounts of zoom. This patch
accumulates the wheel deltas until they reach an integer threshold (with a
tweak of the scaling factor to make it feel more natural) at which point it
triggers the zoom based on the integer component of the accumulated delta. The
fractional part is retained in the accumulator.
2020-08-12 17:18:50 -04:00
Brendan Dahl
da62be0685 Enable renderInteractiveForms by default. 2020-08-12 10:28:27 -07:00
Brendan Dahl
7edc5cb79f
Merge pull request #12137 from calixteman/save
Add support for saving forms
2020-08-12 07:56:05 -07:00
Calixte Denizet
1a6816ba98 Add support for saving forms 2020-08-12 10:32:59 +02:00
Tim van der Meij
3380f2a7fc
Merge pull request #12191 from Snuffleupagus/rm-AppOptions-disableCreateObjectURL
Remove the `disableCreateObjectURL` option from `web/app_options.js`
2020-08-12 00:08:27 +02:00
Tim van der Meij
ac654db089
Merge pull request #12193 from Snuffleupagus/printContainer-canvas-direction
Set `direction: ltr;` on the canvases used during printing (bug 1335712)
2020-08-11 23:52:12 +02:00
Tim van der Meij
57c988853b
Merge pull request #12192 from Snuffleupagus/misc-AnnotationStorage-improvements
A couple of (small) tweaks of the `AnnotationStorage` (PR 12173 follow-up)
2020-08-11 23:46:13 +02:00
Brendan Dahl
7fb01f9f2a
Merge pull request #12186 from brendandahl/loca-2
Fix bad truetype loca tables.
2020-08-10 20:34:19 -07:00