Commit Graph

13117 Commits

Author SHA1 Message Date
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
Jonas Jenwald
01c1d87171 Remove CSS variables feature-testing from PDFSidebarResizer
CSS variables are now supported in all reasonably modern browsers, according to:
 - https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties#Browser_compatibility
 - https://caniuse.com/css-variables
2020-09-09 22:26:08 +02:00
Calixte Denizet
908e7ae5e4 Set the modification date to the current day when saving 2020-09-09 19:06:39 +02:00
Jonas Jenwald
c27dcf2b03 Ensure that the container div, on BaseViewer-instances, is absolutely positioned
The `getVisibleElements` helper function currently requires the viewerContainer to be absolutely positioned; possibly fixing this is tracked in issue 11626.

Without `position: absolute;` set, in the CSS, there's a number of things that won't work correctly such as e.g.
 - Determining which pages are currently visible, thus forcing all of them to render on load and increasing resource usage significantly; note https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#allthepages

 - Scrolling pages into view, by using the `BaseViewer.currentPageNumber` setter or similar.

Based on the number of opened issues over the years, the fact that `position: absolute;` is required has shown to be something that users can very easily overlook unless they follow e.g. the `simpleviewer` example to the letter.
Hence, to improve things until such a time that issue 11626 is fixed, we'll now refuse to initialize a `BaseViewer` instance unless the `container` has the required CSS set. (Forcibly setting `position: absolute;` on the viewerContainer element is bound to cause significantly more issues/confusion, hence the current approach of throwing an Error.)
2020-09-09 15:24:47 +02:00
Jonas Jenwald
2594f0c738 Revert "[PDFSidebarResizer] Refactor the clamping in _updateWidth"
This reverts commit 9e4552d792 for causing the sidebar to become too narrow when the entire viewer is resized.

**Steps to reproduce:**
 1. Load the viewer.
 2. Open the sidebar.
 3. Resize the sidebar, making it wider.
 4. Resize the entire viewer, i.e. the browser window, making it *narrower* than 400 pixels.

**Expected result:**
 The sidebar width is clamped at 200 pixels.

**Actual result:**
 The sidebar becomes too narrow.

The cause of this bug is, in hindsight, quite obvious since the `clamp` helper function implicitly assumes that the `min`/`max` arguments are correctly sorted. At viewer widths *below* 400 pixels, that assumption is broken which explains the bug.
2020-09-09 13:26:38 +02:00
Calixte Denizet
64a6efd95e Follow-up of pr #12344 2020-09-09 11:46:02 +02:00
Brendan Dahl
e51e9d1f33
Merge pull request #12345 from calixteman/save_btn
Don't try to save something for a button which is neither a checkbox nor a radio
2020-09-08 15:44:04 -07:00
calixteman
68b99c59ee
Save form data in XFA datasets when pdf is a mix of acroforms and xfa (#12344)
* Move display/xml_parser.js in shared to use it in worker

* Save form data in XFA datasets when pdf is a mix of acroforms and xfa

Co-authored-by: Brendan Dahl <brendan.dahl@gmail.com>
2020-09-08 15:13:52 -07:00
Tim van der Meij
622e2fbd3a
Merge pull request #12343 from Snuffleupagus/rm-old-Opera
Remove some code/comments relevant for old (pre-Chromium) versions of Opera
2020-09-08 23:11:31 +02:00
Calixte Denizet
7e5026dfc5 Don't try to save something for a button which is neither a checkbox nor a radio 2020-09-08 20:47:46 +02:00
Jonas Jenwald
7b1418368d Remove some code/comments relevant for old (pre-Chromium) versions of Opera 2020-09-08 12:54:51 +02:00
Tim van der Meij
ed47f77527
Merge pull request #12339 from Snuffleupagus/bug-1663390
Support broken /FitH destinations that are missing the "top" value (bug 1663390)
2020-09-07 22:37:07 +02:00
Jonas Jenwald
f78b348cff Support broken /FitH destinations that are missing the "top" value (bug 1663390)
See https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2095870
2020-09-07 10:28:55 +02:00
Tim van der Meij
20c891542b
Merge pull request #12269 from calixteman/highlight
Add support for missing appearances for hightlights, strikeout, squiggly and underline annotations.
2020-09-06 22:25:36 +02:00
Tim van der Meij
d488181423
Merge pull request #12336 from Snuffleupagus/rm-DOM-polyfills
Remove, manually implemented, DOM polyfills only necessary for IE 11 support
2020-09-06 19:18:19 +02:00
Jonas Jenwald
babeae9448 Remove, manually implemented, DOM polyfills only necessary for IE 11 support
Please refer to the following compatibility information:
 - https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove#Browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/add#Browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/remove#Browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/DOMTokenList/toggle#Browser_compatibility

Finally, for the `pushState`/`replaceState` polyfills, please refer to PRs 10461 and 11318 for additional details.
2020-09-06 18:24:17 +02:00
Calixte Denizet
65ecd981fe Add support for missing appearances for hightlights, strikeout, squiggly and underline annotations. 2020-09-06 15:40:15 +02:00
Tim van der Meij
50958c46f7
Merge pull request #12331 from Snuffleupagus/Promise-polyfill
[api-minor] Only support browsers/environments that have *basic* support for `Promise` natively
2020-09-06 14:19:55 +02:00
Tim van der Meij
83e1bbea6e
Merge pull request #12328 from Snuffleupagus/rm-web-IE
Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the `web/` folder
2020-09-06 14:15:49 +02:00
Tim van der Meij
b5ba3a3e00
Merge pull request #12329 from Snuffleupagus/css-variables-treeitem
Rename the `--outline-...` CSS variables to `--treeitem-...` instead (PR 11077 follow-up)
2020-09-06 14:01:44 +02:00
Tim van der Meij
26800aaa95
Merge pull request #12330 from Snuffleupagus/update-packages
Update packages and translations
2020-09-06 13:52:32 +02:00
Jonas Jenwald
449c7763d5 [api-minor] Only support browsers/environments that have *basic* support for Promise natively
Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise#Browser_compatibility and https://caniuse.com/#feat=promises, all even remotely modern browsers already support *basic* `Promise` functionality natively.

The only reason for keeping the `Promise` polyfill (at all) is to be able to support recent additions to the specification, such as e.g. `finally` and `allSettled`.
Note that this patch will, on its own, remove support for IE 11/Edge (non-Chromium based) in both the general PDF.js library and the default viewer.
2020-09-06 13:45:56 +02:00
Jonas Jenwald
6c8f1f7d6f Run gulp lint --fix, to account for changes in Prettier version 2.1.x 2020-09-06 12:23:59 +02:00
Jonas Jenwald
60c9556b66 Restore the "gets expected character types" test, in test/unit/pdf_find_utils_spec.js, to its intended formatting
This was "broken" by the introduction of Prettier, however a recent update (version `2.1.x`) will now correctly ignore these escape sequences.
2020-09-06 12:23:09 +02:00
Jonas Jenwald
54eeaba014 Update l10n files 2020-09-06 11:51:34 +02:00
Jonas Jenwald
0aef40f897 Update npm packages 2020-09-06 11:49:49 +02:00
Jonas Jenwald
cdeeec966d Rename the --outline-... CSS variables to --treeitem-... instead (PR 11077 follow-up)
Given that the outlineView/attachmentsView/layersView all share a common base-class and CSS rules, see PRs 12169 and 12170, the names of the CSS variables in question feels slightly strange now.
2020-09-05 23:06:44 +02:00
Jonas Jenwald
87b002c52f Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the web/ folder
This patch purposely starts small, by removing IE-specific code from various JS/CSS files in the `web/` folder.

There's obviously lots of potential for additional clean-up, especially the removal of no longer necessary polyfills in `src/shared/compatibility.js`, however that will require some care considering that certain polyfills may also be necessary for e.g. Node.js or the Chromium-extension as well.
Generally speaking, once we start removing polyfills it's probably a good idea to consult the compatibility information on https://developer.mozilla.org/ and also https://caniuse.com/ first. (Deciding on the lowest supported Chromium version, for the extension, would also seem like a good idea.)
2020-09-05 17:18:15 +02:00
Tim van der Meij
4caa14b4dc
Merge pull request #12326 from Snuffleupagus/bug-1661259
Revert "Download, rather than opening, PDF attachments in Firefox (bug 1661259, PR 12286 follow-up)"
2020-09-04 22:06:54 +02:00
Jonas Jenwald
a52e229ca6 Revert "Download, rather than opening, PDF attachments in Firefox (bug 1661259, PR 12286 follow-up)"
This reverts commit 2a0de0b66b.

I can no longer reproduce these issues locally, and if ad blockers are still interfering with this functionality we really ought to pursue a mozilla-central solution to the problem instead. (Also, I'm no longer getting an "Open with Firefox"-option in the "Open with"-dialog making the PDF attachments experience worse for all users.)
2020-09-04 12:07:34 +02:00
Tim van der Meij
05fede43f7
Merge pull request #12323 from timvandermeij/bump
Bump versions in `pdfjs.config`
2020-09-03 23:50:34 +02:00
Tim van der Meij
b30a34c98d
Bump versions in pdfjs.config 2020-09-03 23:43:50 +02:00
Tim van der Meij
3be9c65f04
Merge pull request #12321 from Snuffleupagus/BaseViewer-validate-viewer-option
Ensure that the `viewer` property, on `BaseViewer`-instances, is a valid div-element (issue 12320)
2020-09-03 22:11:23 +02:00
Jonas Jenwald
89f6bb0fc6 Ensure that the viewer property, on BaseViewer-instances, is a valid div-element (issue 12320)
This should help prevent future issues, caused by the user omitting the `viewer` option and/or providing an incorrect `container` option, when initializing a `BaseViewer`-instance.
2020-09-03 15:06:36 +02:00
Brendan Dahl
84da13b487
Merge pull request #12315 from emilio/more-resilient-print-callback
print: Make the firefox printing code able to fail and be re-invoked.
2020-09-02 14:13:36 -07:00
Emilio Cobos Álvarez
f4f4ec30f4
print: Make the firefox printing code able to fail and be re-invoked.
This fixes a set of issues described in Mozilla bug 1662426[1].

In particular, once the print callback fails once (because the printing
operation has been canceled in Gecko / replaced by a newer one, for example) it
can't be re-invoked.

This patch fixes it by properly cancelling the render task if it throws, or if
the print callback is called again while ongoing.

[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1662426
2020-09-02 22:56:21 +02:00