Commit Graph

12952 Commits

Author SHA1 Message Date
Tim van der Meij
120c5c2261
Merge pull request #12409 from Snuffleupagus/bug-1627030
Compute the `transformOrigin` correctly, for negative values, when rendering `AnnotationElement`s (bug 1627030)
2020-09-24 23:48:21 +02:00
Tim van der Meij
740e07cad4
Merge pull request #12414 from calixteman/bug_1666753
Need to reset the streams when printing
2020-09-24 22:57:00 +02:00
Calixte Denizet
5af352e65a Need to reset the streams when printing 2020-09-24 19:13:09 +02:00
Jonas Jenwald
fca53a8eb0 Compute the transformOrigin correctly, for negative values, when rendering AnnotationElements (bug 1627030)
This changes the `transformOrigin` calculations in `AnnotationElement._createContainer` and `PopupAnnotationElement.render`, to ensure that e.g. the clickable area of annotations and/or popups are both positioned correctly.

The problem occurs for *negative* values, since they're not negated correctly because of how the `transformOrigin` strings were build; see issue 12406 for a more in-depth explanation. Previously, for negative values, the `transformOrigin` strings would thus be ignored since they're not valid.
2020-09-24 10:28:29 +02:00
Tim van der Meij
139c8a8cb5
Merge pull request #12397 from Snuffleupagus/webpack-stream-update
Update the `webpack-stream` dependency (issue 11996)
2020-09-21 23:24:38 +02:00
Jonas Jenwald
3e9c489b8b Update the webpack-stream dependency (issue 11996)
Given that the long-standing `webpack-stream` issue 201 was recently fixed in PR 207, and a new version released, we should now finally be able to update the dependency.
However, depending on if/when `webpack-stream` gets support for Webpack 5 (which is currently in beta) we may still want remove our `webpack-stream` dependency.
2020-09-20 15:35:56 +02:00
Tim van der Meij
b8c856a53a
Merge pull request #12396 from Snuffleupagus/update-packages
Update packages and translations
2020-09-20 15:34:36 +02:00
Jonas Jenwald
fcfbc06a9c Update l10n files 2020-09-20 11:43:35 +02:00
Jonas Jenwald
4dcedeb98e Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2020-09-20 11:40:20 +02:00
Jonas Jenwald
36b8d5e72d Update npm packages 2020-09-20 11:34:24 +02:00
Tim van der Meij
c98046e5e3
Merge pull request #12393 from Snuffleupagus/issue-12392
Prevent errors if the `InkList` property, in InkAnnotations, is missing and/or not an Array (issue 12392)
2020-09-19 16:28:53 +02:00
Jonas Jenwald
2497e8eab9 Prevent errors if the InkList property, in InkAnnotations, is missing and/or not an Array (issue 12392)
To prevent a future bug, the `Vertices` property in PolylineAnnotations are handled the same way.
2020-09-19 15:34:32 +02:00
Tim van der Meij
26ae7ba2ad
Merge pull request #12387 from calixteman/fix_12386
Use the same kind of strings for radio values
2020-09-17 23:45:17 +02:00
Tim van der Meij
802b4c0850
Merge pull request #12388 from jsg2021/patch-1
Refactor the container/viewer checks in the BaseViewer constructor
2020-09-17 23:05:18 +02:00
Jonathan Grimes
d37a445369 Refactor the container/viewer checks in the BaseViewer constructor
The previous checks prevented specifying a container/viewer that was in another
document/window.
Fixes #12385
2020-09-17 20:29:10 +00:00
Calixte Denizet
d51e7e86ff Use the same kind of strings for radio values 2020-09-16 18:47:25 +02:00
Tim van der Meij
558d3870d3
Merge pull request #12369 from emilio/better-cancelation-follow-up
canvas: fix restore() with existing SMask groups and re-land #12363.
2020-09-15 23:19:17 +02:00
Tim van der Meij
374aad77c4
Merge pull request #12375 from Snuffleupagus/emptyDict-set
Ensure that the empty dictionary won't be accidentally modified, and slightly improve the "SaveDocument" handler in `src/core/worker.js`
2020-09-15 23:04:57 +02:00
Brendan Dahl
e73354a32d
Merge pull request #12377 from calixteman/fix_radio_saving
Set parent of radio annotation even if there is no 'V' field
2020-09-15 11:30:14 -07:00
Calixte Denizet
16dd5403c7 Set parent of radio annotation even if there is no 'V' field 2020-09-15 14:41:57 +02:00
Jonas Jenwald
ed4e7cd8a4 A couple of small improvements in the "SaveDocument" handler in src/core/worker.js
- Check that the "Info"-entry, in the XRef-trailer, is actually a dictionary before accessing it. This is similar to the `PDFDocument.documentInfo` method and follows the general principal of validating data carefully before accessing it, given how often PDF-software may create corrupt PDF files.

 - Slightly simplify the "XFA"-lookup, since there's no point in trying to fetch something from the empty dictionary.
2020-09-15 09:57:40 +02:00
Jonas Jenwald
a531c98cd2 Ensure that the empty dictionary won't be accidentally modified
Currently there's nothing that prevents modification of the `Dict.empty` primitive, which obviously needs to be *truly* empty to prevent any future (hard to find) bugs.
2020-09-15 09:29:00 +02:00
Tim van der Meij
b0c7a74a0c
Merge pull request #12361 from Snuffleupagus/_getSaveFieldResources
Ensure that all necessary /Font resources are included when saving a `WidgetAnnotation`-instance (issue 12294)
2020-09-15 00:09:31 +02:00
Tim van der Meij
9d7b1d89ca
Merge pull request #12370 from timvandermeij/annotation-reset
Implement resetting of created streams for annotations
2020-09-14 23:16:17 +02:00
Tim van der Meij
3ecd984758
Implement resetting of created streams for annotations 2020-09-14 23:08:50 +02:00
Brendan Dahl
1e11f871b6
Merge pull request #12374 from calixteman/escape_string
Replace \n and \r by \n and \r when saving a string
2020-09-14 11:25:04 -07:00
Calixte Denizet
0c8de5aaf9 Replace \n and \r by \n and \r when saving a string 2020-09-14 17:34:39 +02:00
Jonas Jenwald
c992b8e460 Ensure that all necessary /Font resources are included when saving a WidgetAnnotation-instance (issue 12294)
This patch contains a possible approach for fixing issue 12294, which compared to other PRs is purposely limited to the affected `WidgetAnnotation` code.

As mentioned elsewhere, considering that we're (at least for now) trying to fix *one specific* case, I think that we should avoid modifying the `Dict` primitive[1] and/or avoid a solution that (indirectly) modifies an existing `Dict`-instance[2].
This patch simply fixes the issue at hand, since that seems easiest for now, and I'd suggest that we worry about a more general approach if/when that actually becomes necessary.

Hence the solution implemented here, for `WidgetAnnotation`, is to simply use a combination of the local *and* AcroForm /DR resources during OperatorList-parsing to ensure that things work correctly regardless of where a particular /Font resource is found.
For saving of form-data, on the other hand, we want to avoid increasing the file-size unnecessarily and need to be smarter than just merging all of the available resources. To achive this, a new `WidgetAnnotation._getSaveFieldResources` method will when necessary produce a combined resources `Dict` with only the minimum amount of data from the AcroForm /DR resources included.

---
[1] You want to avoid anything that could cause the general `Dict` implementation to become slower, or more complex, just for handling an edge-case in my opinion.

[2] If an existing `Dict`-instance is modified unexpectedly, that could very easily lead to problems elsewhere since e.g. `Dict`-instances created during parsing are not expected to be changed.
2020-09-14 15:22:40 +02:00
Tim van der Meij
741ce4f7fc
Merge pull request #12372 from Snuffleupagus/skip-FBF-makeref
Skip failing FBF tests, when running `makeref`, in Firefox as well
2020-09-13 14:07:09 +02:00
Jonas Jenwald
18767445a4 Skip failing FBF tests, when running makeref, in Firefox as well
This will allow `makeref` to run "successfully" on the bots, since in the current state testing/makeref is just overall broken.
Obviously we still need to figure what's causing the intermittent failures, and fix them, but let's at least unblock things for now; see issue 12371.
2020-09-13 12:24:04 +02:00
Emilio Cobos Álvarez
bf8b1adf73 canvas: Properly restore all the remaining items in stateStack in endDrawing.
We were correctly finishing the SMask group but not restoring all the extra
transformations applied in stateStack, so if somebody ends up drawing to the
same context after canceling mid-draw we'd get artifacts.

This re-lands #12363 and fixes Mozilla bug 1664178[1].

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1664178
2020-09-12 16:37:54 +02:00
Emilio Cobos Álvarez
3a277f3ba5 canvas: restore() should reflect that smask groups are finished when stateStack is empty.
This fixes the issue that caused #12363 to get reverted, see #12367.
When we end the SMask group and stateStack.length is zero, nothing updates
this.current to reflect it.
2020-09-12 16:37:54 +02:00
Tim van der Meij
b058266a7a
Merge pull request #12368 from Snuffleupagus/revert-12363-better-cancelation
Revert "canvas: Properly restore all the remaining items in stateStack in endDrawing"
2020-09-12 16:32:24 +02:00
Jonas Jenwald
f43d1b316b
Revert "canvas: Properly restore all the remaining items in stateStack in endDrawing" 2020-09-12 16:15:33 +02:00
Tim van der Meij
cdac6f4e68
Merge pull request #12363 from emilio/better-cancelation
canvas: Properly restore all the remaining items in stateStack in endDrawing
2020-09-12 15:03:34 +02:00
Emilio Cobos Álvarez
ef1e9a1a3e
canvas: Properly restore all the remaining items in stateStack in endDrawing.
We were correctly finishing the SMask group but not restoring all the extra
transformations applied in stateStack, so if somebody ends up drawing to the
same context after canceling mid-draw we'd get artifacts.

This fixes Mozilla bug 1664178[1].

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1664178
2020-09-12 13:50:56 +02:00
Tim van der Meij
dfebe7b907
Merge pull request #12365 from Snuffleupagus/forbid-DecodeStream.length
Ensure that the `length` property won't be *accidentally* accessed on a `DecodeStream`-instance
2020-09-11 22:18:30 +02:00
Brendan Dahl
008eed0efe
Merge pull request #12364 from calixteman/really_fix_name_issue
Dict keys need to be escaped too when saving
2020-09-11 09:55:12 -07:00
Jonas Jenwald
a11b7341a1 Ensure that the length property won't be *accidentally* accessed on a DecodeStream-instance
For these streams, compared to `Stream` and `ChunkedStream`, there's no well defined concept of length and consequently no `length` getter.[1] However, attempting to access the non-existent `length` won't currently error, but just return `undefined`, which could thus easily lead to bugs elsewhere in the code-base.

---
[1] However, note that *all* stream implementations have an `isEmpty` getter which can be used instead.
2020-09-11 13:25:40 +02:00
Calixte Denizet
fc154590e8 Dict keys need to be escaped too when saving 2020-09-11 12:25:05 +02:00
Tim van der Meij
aef3fedc29
Merge pull request #12362 from Snuffleupagus/loadingBar-width
Let the loadingBar have the same width as the viewerContainer
2020-09-11 00:18:59 +02:00
Tim van der Meij
8cfcd7a488
Merge pull request #12360 from calixteman/12359
Reset cursor position when focus is out of text field
2020-09-10 23:11:35 +02:00
Jonas Jenwald
17a507016a Let the loadingBar have the same width as the viewerContainer
For years the loadingBar and sidebarContainer has had a slightly annoying and unfortunate dependency, since the loadingBar width follows the main toolbar width[1].
To prevent the loadingBar from obscuring part of the sidebarContainer, especially the buttons, the sidebarContainer is thus moved down when the loadingBar is visible. This has always annoyed me[2], since it means that the buttons in the sidebar may thus move vertically which seems bad from a UX perspective.

Now that CSS variables are available in all supported browsers[3] however, fixing the loadingBar/sidebarContainer overlap issues are finally easy. The solution is simply to let the sidebarContainer, when visible, control the loadingBar left position (right in RTL locales) in the same way that the viewerContainer is handled. Hence the sidebarContainer can now have a *consistent* vertical postition, without the loadingBar overlapping it.

---
[1] Obviously the right position (left in RTL locales) of the loadingBar is, potentially, reduced to account for a scrollbar.

[2] I've tried to fix this a few times, but it always seemed like more trouble than it's worth.

[3] https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties#Browser_compatibility
2020-09-10 17:16:24 +02:00
Brendan Dahl
865de9ab90
Merge pull request #12357 from calixteman/escape_name
PDF names need to be escaped when saving
2020-09-10 07:20:30 -07:00
Calixte Denizet
dc4eb71ff1 PDF names need to be escaped when saving 2020-09-10 16:08:13 +02:00
Calixte Denizet
44b24fcc29 Reset cursor position when focus is out of text field 2020-09-10 10:37:13 +02:00
Tim van der Meij
f9d56320f5
Merge pull request #12349 from calixteman/followup_12344
Follow-up of pr #12344
2020-09-09 23:40:53 +02:00
Tim van der Meij
eea97eabc8
Merge pull request #12356 from calixteman/no_future
Set the modification date to the current day when saving
2020-09-09 22:54:35 +02:00
Tim van der Meij
e8822e1912
Merge pull request #12352 from Snuffleupagus/sidebar-resizer-CSS-vars
Remove CSS variables feature-testing from `PDFSidebarResizer`
2020-09-09 22:41:29 +02:00
Tim van der Meij
82dede0458
Merge pull request #12354 from Snuffleupagus/BaseViewer-container-position-absolute
Ensure that the `container` div, on `BaseViewer`-instances, is absolutely positioned
2020-09-09 22:32:36 +02:00