Commit Graph

14960 Commits

Author SHA1 Message Date
Jonas Jenwald
822856e044 Update l10n files 2021-10-31 09:56:41 +01:00
Jonas Jenwald
48896adc27 Enable the ESLint no-unused-private-class-members rule
Given that we're now using private `class` fields/methods, enabling this new ESLint rule should help avoid adding dead code.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-unused-private-class-members
2021-10-31 09:52:07 +01:00
Jonas Jenwald
a8abdfb3bb Update npm packages 2021-10-31 09:38:18 +01:00
calixteman
2d8b6fda8f
Merge pull request #14207 from janekotovich/forms_version_popup
JS - Avoid a popup to ask for specific version of Acrobat
2021-10-30 05:45:31 -07:00
Tim van der Meij
ec1633c33c
Merge pull request #14201 from Snuffleupagus/bug-1219400
Use the correct border-style for Annotations, when a dash array is specified (bug 1219400)
2021-10-30 12:39:46 +02:00
Tim van der Meij
317e4dd146
Merge pull request #14204 from Snuffleupagus/rm-shadowViewer
Remove the `shadowViewer` used with Page scrolling
2021-10-30 12:37:30 +02:00
calixteman
2c0bbaf208
Merge pull request #14153 from catherinemds/xfa-link
Fix XFA links (bug 1735738)
2021-10-29 11:06:00 -07:00
Catherine
db0b3cda8b XFA - Fix xfaLink class to make links work (bug 1735738)
There were some links not working in some XFA files,I realized that the anchor tag that contains the link has an inline display and couldn't receive any height, solved this by adding a "position: absolute". Tested with two different files in Firefox Nightly and Chrome and now all links are working perfectly fine. Added reftest to avoid future regressions
2021-10-29 11:39:33 -04:00
Jane-Kotovich
12f89d2ab1 JS - Avoid a popup to ask for specific version of Acrobat
Embedded JS in PDF keep throwing alert reagdring specific version of Acrobat (Spanish and version 5.0 or greater).
This happens because:
- JS in pdf is enabled
- PDF contains some unsupported features (e.g. XFA)
Alert come when app.formVersion = undefined || app.formVersion < 5.0
In pdf.js we were using FORM_VERSION = undefined. After researching based on https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/pdfs/acrobatsdk_jsapiref.pdf\#G4.1993509 and Acrobat DC we decided to go with the larger number to avoid unnecessary popups.
Through investigation we realise that VIEWER_VERSION should have same value - a number.
Due to all that, we implemented 21.00720099 as a value for both FORMS_VERSION and VIEWER_VERSION
2021-10-29 23:09:59 +10:00
Jonas Jenwald
c18df2c61f Remove the shadowViewer used with Page scrolling
The only reason for using a `DocumentFragment` in the first place, originally added in PR 8724, was to prevent errors in the `PDFPageView`-constructor. However, we should be able to simply make its `container`-option *optional* instead, since it's not being used for anything else in the class.

Note that pre-rendering still works correctly in my testing, and given that the `BaseViewer` keeps references to all `PDFPageView`-instances (via its `_pages` Array) it also shouldn't be possible to "lose" any pages/canvases this way.
2021-10-28 13:48:15 +02:00
Tim van der Meij
0e7614df7f
Merge pull request #14180 from Snuffleupagus/bug-1627427
Handle ranges that "overflow" the last byte in `CMap.mapBfRange` (bug 1627427)
2021-10-27 20:06:09 +02:00
Tim van der Meij
6f3700b393
Merge pull request #14191 from Snuffleupagus/viewer-empty-pageLabels
Ignore pageLabels, in the viewer, when they're all empty
2021-10-27 20:01:45 +02:00
Tim van der Meij
f3a0a506c0
Merge pull request #14192 from Snuffleupagus/pr-14158-followup
[Regression] Prevent breaking errors when opening a new document in the GENERIC viewer (PR 14158 follow-up)
2021-10-27 19:58:25 +02:00
Jonas Jenwald
884caf602e Use the correct border-style for Annotations, when a dash array is specified (bug 1219400)
Even though we cannot use the dash array in the display layer, at least ensure that we use the correct border-style.
2021-10-27 13:20:21 +02:00
calixteman
74bc6d2625
Merge pull request #14189 from janekotovich/security_handler
[api-minor] Implement securityHandler in the scripting API (bug 1731578)
2021-10-27 03:40:16 -07:00
calixteman
f40bbe838e
Merge pull request #14199 from calixteman/it
Avoid to display download panel during integration tests
2021-10-27 03:20:17 -07:00
Calixte Denizet
a24322fdab Avoid to display download panel during integration tests
- it could be the cause of the failures in #14189;
  - and the patch in firefox to enable the pref landed very recently:
  https://hg.mozilla.org/mozilla-central/rev/3de56e38f3c87f33a1e7849701edb3c62bc472a5
2021-10-27 11:43:30 +02:00
Jonas Jenwald
390ddd9241
Merge pull request #14181 from PinRathod/simpleviewer_to_async
Converted simpleviewer.js to await/async
2021-10-26 20:31:04 +02:00
PinRathod
4c463c6099 Converted simpleviewer.js to await/async 2021-10-26 22:42:08 +05:30
Jane-Kotovich
91fc643ff9 [api-minor] Implement securityHandler in the scripting API (bug 1731578) 2021-10-26 23:42:04 +10:00
Jonas Jenwald
66c26d70d4 Ignore pageLabels, in the viewer, when they're all empty
Unfortunately there exist PDF documents where all pageLabels are empty strings, see e.g. http://www.cs.cornell.edu/~ragarwal/pubs/blk-switch.pdf (taken from an old issue), which result in the pageNumber-input being completely blank. That doesn't seem very helpful, and this patch simply extends the approach used to ignore pageLabels that are identical to standard page numbering.
2021-10-25 16:11:04 +02:00
Jonas Jenwald
2c779a8fbe [Regression] Prevent breaking errors when opening a new document in the GENERIC viewer (PR 14158 follow-up)
In the GENERIC viewer, e.g. when dragging-and-dropping a new PDF document which automatically opens the outline, there can now be breaking errors in the `{BaseViewer, PDFThumbnailViewer}.#getScrollAhead` methods since there's no visible pages/thumbs during loading; sorry about the breakage!
2021-10-25 14:27:24 +02:00
Jonas Jenwald
c85cd80b1b Remove unnecessary pageLabel length-check in the viewer
Given how the pageLabel array is defined, see 1ab9a6e36e/src/core/catalog.js (L627), it shouldn't be necessary to check the length in the viewer.
2021-10-25 13:25:34 +02:00
Jonas Jenwald
aa1b78684f Handle ranges that "overflow" the last byte in CMap.mapBfRange (bug 1627427) 2021-10-24 13:48:38 +02:00
Tim van der Meij
1ab9a6e36e
Merge pull request #14158 from Snuffleupagus/preRender-doc-limits
Improve pre-rendering at the start/end of the document
2021-10-24 13:43:02 +02:00
Jonas Jenwald
3dc738c4c8 Slightly simplify the isThumbnailViewEnabled check in PDFRenderingQueue.renderHighestPriority 2021-10-23 19:59:14 +02:00
Jonas Jenwald
91692a20d1 Skip the first/last visible pages pre-rendering page layouts with "holes" (PR 14131 follow-up)
This was a stupid oversight on my part, since the first/last visible pages have obviously already been rendered at the point when we're checking for any potential "holes" in the page layout.
While this will obviously not have any measurable effect on performance, we should nonetheless avoid doing completely unnecessary checks here.
2021-10-23 19:15:37 +02:00
Jonas Jenwald
24b7fb20ef Improve pre-rendering at the start/end of the document
This is a very old "issue", which has existed since essentially forever, and it affects all of the available scrollModes. However, in the recently added Page-mode it's particularily noticeable since we use a *simulated* scroll direction there.

When deciding what page(s) to pre-render, we only consider the current scroll direction. This works well in most cases, but can break down at the start/end of the document by trying to pre-render a page *outside* of the existing ones. To improve this, we'll thus *force* the scroll direction at the start/end of the document.

*Steps to reproduce:*

 0. Open the viewer, e.g. https://mozilla.github.io/pdf.js/web/viewer.html
 1. Enable vertical scrolling.
 2. Press the <kbd>End</kbd> key.
 3. Open the devtools and, using the DOM Inspector, notice how page 13 is *not* being pre-rendered.
2021-10-23 19:15:37 +02:00
Tim van der Meij
0aaa4e3dbe
Merge pull request #14156 from Snuffleupagus/escodegen-fork
Add support for modern ECMAScript `class` features
2021-10-23 19:12:44 +02:00
Tim van der Meij
e5d35a380a
Merge pull request #14178 from Snuffleupagus/update-browserslist
Update the `browserslist` database
2021-10-23 19:09:52 +02:00
Jonas Jenwald
2c27f54e4e Update the browserslist database
Following https://github.com/browserslist/browserslist#browsers-data-updating, since very recently warnings started to appear when running various gulp-tasks.
2021-10-23 10:07:18 +02:00
Jonas Jenwald
52372b9378
Merge pull request #14175 from brendandahl/smask-v2
Use a new method for handling soft masks.
2021-10-23 09:27:18 +02:00
Brendan Dahl
82681ea20c Track the clipping box and bounding box of the path.
This allows us to compose much smaller regions of soft
mask making them much faster. This should also allow
for further optimizations in the pattern code.

For example locally I see issue #6573 go from 55s
to 5s with this change.

Fixes #6573
2021-10-22 13:41:29 -07:00
Brendan Dahl
2d1f9ff7a3 Use a new method for handling soft masks.
The old method of handling soft masks had a number of issues where the temporary
drawing canvas and the suspended main canvas could get out of sync
(e.g. mismatched save/restores or clip state) or we could end up compositing at
the wrong time. A good example of things getting out sync is the reduced test
case in #9017.

To fix this I've changed two big things:

1) Duplicate all the needed graphics state from the temporary canvas to the
suspended main canvas. This ensure the canvases stay in sync so that when we
switch back to the main canvas the graphics state stack is the same
(e.g. transforms, clip paths).

2) Immediately composite after each drawing operation. This ensures that if
there's an active clip region that we'll still be able to composite the correct
portions of the canvas. Note: This solution could be avoided by using
getImageData and putImageData since those ignore clipping region, but this is
very very slow. Note2: I also think the old way of only compositing at the end
of the soft mask is incorrect and can lead to wrong colors if drawing over the
same region, but in practice this doesn't seem to matter much.

Fixes: #5781
Fixes: #5853
Fixes: #7267
Fixes: #7891
Fixes: #8403
Fixes: #8624
Fixes: #12798
Fixes: #13891
Fixes: #9017 (reduced test case)
Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1703683
2021-10-22 13:41:21 -07:00
Jonas Jenwald
7216511fbf Convert TempImageFactory to a class, using static fields/methods
Please refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields
2021-10-22 22:01:19 +02:00
Jonas Jenwald
89785a23f3 Convert Metadata to use private class fields
Please refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields
2021-10-22 22:01:19 +02:00
Jonas Jenwald
00f8fab8a5 Add support for modern ECMAScript class features
With ESLint 8 we should now finally be able to start using modern `class` features, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields and https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_class_fields

However, while both ESLint and Acorn now support this, it unfortunately turns out that Escodegen (which we use during building) still lack the necessary support. Looking at https://github.com/estools/escodegen there's not been any updates since last year, and there's also open PRs adding support for these new `class` features.

To avoid blocking usage of these `class` features in the PDF.js code-base, in particular *private* fields/methods, this patch thus proposes that we (hopefully temporarily) switch to an `escodegen` fork that has the necessary support; please see https://www.npmjs.com/package/@javascript-obfuscator/escodegen

While I have no reason to doubt the security of the `escodegen` fork, this patch nonetheless pins the version number. Furthermore, I've also diffed the output of the two `.js`-files in this forked package against the original files without finding anything that looks immediately "dangerous".
2021-10-22 22:01:17 +02:00
Tim van der Meij
38e5360533
Merge pull request #14162 from brendandahl/indent-stepper
Indent the stepper on save/restore.
2021-10-22 21:17:36 +02:00
Tim van der Meij
11f030d301
Merge pull request #14171 from Snuffleupagus/issue-14170
Prevent run-time errors in Node.js versions with `URL.createObjectURL` support (issue 14170)
2021-10-22 21:07:19 +02:00
Brendan Dahl
2e56369f79 Indent the stepper on save/restore.
Makes it easier to debug and visualize the graphics
state changes in the debugger.
2021-10-22 10:30:32 -07:00
Jonas Jenwald
e788665a26
Merge pull request #14167 from stbensonimoh/convert-pdf-viewer-to-async-await
Convert examples/image_decoders/jpeg_viewer.js to await/async #14123
2021-10-22 12:58:43 +02:00
Benson Imoh,ST
f263c860bd
Convert examples/image_decoders/jpeg_viewer.js to await/async #14123 2021-10-22 11:50:24 +01:00
Jonas Jenwald
e4e44121d2
Merge pull request #14174 from Snuffleupagus/PushButton-double-border
Prevent double-rendering borders for PushButton-annotations (PR 14083 follow-up)
2021-10-21 15:29:19 +02:00
Jonas Jenwald
044197808a Prevent double-rendering borders for PushButton-annotations (PR 14083 follow-up)
With ResetForm-action support added in PR 14083, there's a regression in the `issue12716` test-case. More specifically the border around the "Clear Form"-link is now rendered *twice*, once in the canvas via the appearance-stream and once in the annotationLayer via the border-data.
This looks slightly weird, and was most likely not intended, which is why this patch suggests that we ignore the border in the annotationLayer when an appearance-stream exists.
2021-10-21 13:31:16 +02:00
Jonas Jenwald
ff9d2b2ab1 Prevent run-time errors in Node.js versions with URL.createObjectURL support (issue 14170)
Apparently Node.js has added *global* `URL.createObjectURL` support, but not done the same thing for `Blob`. Hence we also need to check for the availability of `Blob` in the `createObjectURL` helper function, and it's probably a good idea to also update `examples/node/pdf2svg.js` to work-around this until these changes reach an official PDF.js release.
2021-10-21 10:32:44 +02:00
Jonas Jenwald
7c9e5781fe
Merge pull request #14159 from stbensonimoh/convert-example-to-async-await
Convert examples/node/pdf2svg.js to await/async #14125
2021-10-21 10:30:02 +02:00
Benson Imoh,ST
0643ccb68b
Convert examples/node/pdf2svg.js to await/async #14125 2021-10-20 21:51:58 +01:00
Tim van der Meij
382be22c11
Merge pull request #14160 from Snuffleupagus/pr-13770-followup
Fix pattern handling regression in `SVGGraphics` (PR 13770 follow-up)
2021-10-19 19:31:18 +02:00
Tim van der Meij
ce86f9dfdd
Merge pull request #14155 from mozilla/revert-13314-color-theme
Revert "For mozcentral use Firefox color theme instead of system theme." since `-moz-toolbar-prefers-color-scheme` was removed
2021-10-19 19:29:20 +02:00
Tim van der Meij
0fe358f7d6
Merge pull request #14154 from Snuffleupagus/update-packages
Update packages and translations
2021-10-19 19:26:08 +02:00