1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00
Commit graph

18903 commits

Author SHA1 Message Date
Jonas Jenwald
9418ed19e7 [api-minor] Remove the, now unused, pdfjsLibPromise global
This global was only introduced to work-around problems caused by the GENERIC PDF.js build using top level await. Since that was removed in the previous commit, this global is now dead code.
2024-05-07 18:21:56 +02:00
Jonas Jenwald
2643570364 [api-minor] Re-factor how Node.js packages/polyfills are loaded (issue 17245)
*Please note:* This removes top level await from the GENERIC builds of the PDF.js library.

Despite top level await being supported in all modern browsers/environments, note [the MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#browser_compatibility), it seems that many frameworks and build-tools unfortunately have trouble with it.
Hence, in order to reduce the influx of support requests regarding top level await it thus seems that we'll have to try and fix this.

Given that top level await is only needed for Node.js environments, to load packages/polyfills, we re-factor things to limit the asynchronicity to that environment.
The "best" solution, with the least likelihood of causing future problems, would probably be to await the load of Node.js packages/polyfills e.g. at the top of the `getDocument`-function. Unfortunately that doesn't work though, since that's a *synchronous* function that we cannot change without breaking "the world".

Hence we instead await the load of Node.js packages/polyfills together with the `PDFWorker` initialization, since that's the *first point* of asynchronicity during initialization/loading of a PDF document. The reason that this works is that the Node.js packages/polyfills are only needed during fetching of the PDF document respectively during rendering, neither of which can happen *until* the worker has been initialized.
Hopefully this won't cause any future problems, since looking at the history of the PDF.js project I don't believe that we've (thus far) ever needed a Node.js dependency at an earlier point.
This new pattern for accessing Node.js packages/polyfills will also require some care during development *and* importantly reviewing, to ensure that no new top level await is added in the main code-base.
2024-05-06 23:20:03 +02:00
Jonas Jenwald
b6765403a1
Merge pull request #18026 from Snuffleupagus/validate-more-getArray
Validate even more dictionary properties
2024-05-06 22:09:42 +02:00
Tim van der Meij
14e87469db
Merge pull request #18041 from timvandermeij/integration-tests-timeout-freetext
Remove most `waitForTimeout` usage from the freetext editor integration tests
2024-05-06 20:00:03 +02:00
calixteman
30d0e3a0ba
Merge pull request #18044 from calixteman/bug1894849
Avoid to aria-hide the structure tree (bug 1894849)
2024-05-06 19:56:59 +02:00
Tim van der Meij
bb743389aa
Use waitForSelector instead of waitForFunction for focus checks
This commit replaces `waitForFunction` calls that use
`document.activeElement` to wait for an element to get focus by simpler
`waitForSelector` expressions that use the `:focus` selector. Note that
we already use this in other tests, so this improves consistency too.
2024-05-06 19:35:37 +02:00
Tim van der Meij
5c5c107ec5
Remove most waitForTimeout usage from the freetext editor integration tests
This commit replaces a `waitForTimeout` occurrence with an equivalent
`waitForSelector` expression, and removes two other `waitForTimeout`
occurrences that are obsolete because we already wait for an observable
event to trigger or class change to happen.

Note that the other `waitForTimeout` occurrences in this file are either
part of #17931 or remain until we find a good way to ensure that nothing
happened (because currently there is nothing we can await there).
2024-05-06 19:35:37 +02:00
Tim van der Meij
d79aaee62a
Merge pull request #18009 from nicolo-ribaudo/pin-node-21
Pin GitHub actions to Node.js 21
2024-05-06 14:47:56 +02:00
Jonas Jenwald
9b41bfc374 Introduce helper functions for parsing /Matrix and /BBox arrays 2024-05-03 22:37:50 +02:00
Jonas Jenwald
52f7ff155d Validate even more dictionary properties
This checks primarily Arrays, but also some other properties, that we'll end up sending (sometimes indirectly) to the main-thread.
2024-05-03 22:37:14 +02:00
Calixte Denizet
7742c3eb63 Avoid to aria-hide the structure tree (bug 1894849)
If one ancestor of the structure tree has the attribute aria-hidden
then it's invisible for screen readers.
2024-05-03 14:39:43 +02:00
Jonas Jenwald
1b811ac113
Merge pull request #18034 from Snuffleupagus/FileSpec-filename-stripPath
[api-minor] Improve the `FileSpec` implementation
2024-05-03 09:03:17 +02:00
Jonas Jenwald
a790f2df5d [api-minor] Remove the unused onlyStripPath option from the getFilenameFromUrl helper function 2024-05-03 08:29:41 +02:00
Jonas Jenwald
c419c8333b
Merge pull request #18037 from Snuffleupagus/validate-more-widths
Add even more validation of width-data (PR 18017 follow-up)
2024-05-02 14:41:02 +02:00
Tim van der Meij
2f7a4d555a
Merge pull request #18033 from Snuffleupagus/version-4.3
Bump library version to `4.3`
2024-05-02 14:38:54 +02:00
Jonas Jenwald
6c05f8b381 Add even more validation of width-data (PR 18017 follow-up)
I missed this case in PR 18017, sorry about that.
2024-05-02 11:24:15 +02:00
calixteman
33732ff2cb
Merge pull request #18035 from calixteman/rm_max_group_size
Remove the limit used to decided if a group canvas must be upscaled or not
2024-05-01 20:14:28 +02:00
Jonas Jenwald
2b69fb76ac [api-minor] Improve the FileSpec implementation
- Check that the `filename` is actually a string, before parsing it further.
 - Use proper "shadowing" in the `filename` getter.
 - Add a bit more validation of the data in `pickPlatformItem`.
 - Last, but not least, return both the original `filename` and the (path stripped) variant needed in the display-layer and viewer.
2024-05-01 18:02:05 +02:00
Calixte Denizet
5c771628de Remove the limit used to decided if a group canvas must be upscaled or not
It fixes issues #14982 and #14724.
The main problem of upscaling a canvas is that it can induces some pixelation
(see issue #14724). So this patch is just removing the limit and as a side
effect it fixes issue #14982.
As far as I can tell, in looking different profiles (especially some memory profile)
in using the Firefox profiler, I don't see any noticeable difference in term of
memory use.
2024-05-01 18:01:54 +02:00
Jonas Jenwald
16dbf5dcfd
Merge pull request #18031 from Snuffleupagus/issue-18030
[api-minor] Expose the /Desc-attribute of file attachments in the viewer (issue 18030)
2024-05-01 17:53:22 +02:00
Jonas Jenwald
3ff93ede07 Bump library version to 4.3 2024-05-01 17:00:14 +02:00
calixteman
96ce111e0c
Merge pull request #18029 from calixteman/simplify_smask
[api-minor] Remove the use of (get/put)ImageData when drawing SMasks (bug 1874013)
2024-05-01 16:12:43 +02:00
Calixte Denizet
82989e6790 [api-minor] Remove the use of (get/put)ImageData when drawing SMasks (bug 1874013)
and implement then in using some SVG filters and composition.
Composing in using destination-in in order to multiply RGB components by
the alpha from the mask isn't perfect: it'd be a way better to natively have
alpha masks support, it induces some small rounding errors and consequently
computed RGB are approximatively correct.
In term of performance, it's a real improvement, for example, the pdf in
issue #17779 is now rendered in few seconds.
There are still some room for improvement, but overall it should be a way
better.
2024-05-01 15:40:44 +02:00
Jonas Jenwald
bf4e36d1b5 [api-minor] Expose the /Desc-attribute of file attachments in the viewer (issue 18030)
In the viewer this will be displayed in the `title` of the hyperlink, which is probably the best we can do here given how the viewer is implemented.
2024-05-01 09:02:11 +02:00
Tim van der Meij
77e2182b8e
Merge pull request #18019 from Aditi-1400/safari-zoom-fix
Fix rendering problem when zooming on Safari
2024-04-30 14:50:46 +02:00
Tim van der Meij
716ac7eae8
Merge pull request #18024 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-04-30 13:58:36 +02:00
Tim van der Meij
9dcb2b3844
Update translations to the most recent versions 2024-04-29 19:57:19 +02:00
Tim van der Meij
9872de1415
Upgrade postcss-discard-comments to version 7.0.0
This is a major version bump, but the changelog at
https://github.com/cssnano/cssnano/releases/tag/cssnano%407.0.0
doesn't indicate any breaking changes that should impact us.
2024-04-29 19:55:38 +02:00
Tim van der Meij
89f41e527d
Update dependencies to the most recent versions 2024-04-29 19:52:37 +02:00
Tim van der Meij
1241758605
Merge pull request #18023 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2024-04-29 19:33:55 +02:00
Tim van der Meij
a6271e47b2
Bump the stable version in pdfjs.config 2024-04-29 19:30:03 +02:00
Tim van der Meij
49b388101a
Merge pull request #18001 from Snuffleupagus/api-pageRefCache
[api-minor] Move the page reference/number caching into the API
2024-04-29 19:10:06 +02:00
Jonas Jenwald
150964dd6d Remove unnecessary check from PDFLinkService.goToDestination (PR 17984 follow-up)
After the changes in PR 17984 this code can no longer be reached, since the destination is now validated on the worker-thread.
2024-04-29 18:54:09 +02:00
Jonas Jenwald
f6cd03955b [api-minor] Move the page reference/number caching into the API
Rather than having to handle this *manually* throughout the viewer, this functionality can instead be moved into the API which simplifies the code slightly.
2024-04-29 18:54:06 +02:00
Jonas Jenwald
fa69d9a3bc Inline the helper method in PDFLinkService.goToDestination
We no longer need the helper method to *potentially* call itself once data is available, and can instead take full advantage of async/await by inlining the code.
2024-04-29 18:52:12 +02:00
Tim van der Meij
3052e99f65
Merge pull request #18013 from Snuffleupagus/SimpleLinkService-extends-PDFLinkService
Re-factor `SimpleLinkService` to extend `PDFLinkService`
2024-04-29 18:41:53 +02:00
Jonas Jenwald
2b2ade7883
Merge pull request #18018 from Snuffleupagus/CompiledFont-tweak-caching
Reduce code-duplication when caching data in `CompiledFont.getPathJs`
2024-04-29 17:39:35 +02:00
Jonas Jenwald
627fe2d826
Merge pull request #18017 from Snuffleupagus/validate-widths
Add more validation of width-data
2024-04-29 14:17:23 +02:00
Aditi
04580168a2 Fix rendering problem when zooming on Safari 2024-04-29 17:32:06 +05:30
Jonas Jenwald
85ff8f34e2 Reduce code-duplication when caching data in CompiledFont.getPathJs 2024-04-29 13:18:31 +02:00
Jonas Jenwald
d411a072a4 Add more validation of width-data
The current `PartialEvaluator.extractWidths` implementation only contains *partial* validation of the width-data.
2024-04-29 10:51:16 +02:00
Jonas Jenwald
234067e745
Merge pull request #18014 from Snuffleupagus/validate-font-properties
Validate additional font-dictionary properties
2024-04-29 10:01:48 +02:00
Jonas Jenwald
08eb0566f7 Validate additional font-dictionary properties 2024-04-29 08:21:28 +02:00
calixteman
85e64b5c16
Merge pull request #18015 from calixteman/rm_eval_font_loader
Simplify the way to pass the glyph drawing instructions from the worker to the main thread
2024-04-28 23:27:47 +02:00
Jonas Jenwald
8c3d571939 Re-factor SimpleLinkService to extend PDFLinkService
Rather than having to maintain a dummy `IPDFLinkService` implementation, we can simply let it extend the primary `PDFLinkService` class instead.
Note how *some* methods already checked for an active PDF document, and those checks only needed to be used consistently throughout `PDFLinkService` in order for this to work.
2024-04-28 10:18:41 +02:00
Calixte Denizet
551e63901c Simplify the way to pass the glyph drawing instructions from the worker to the main thread
and remove the use of eval in the font loader.
2024-04-27 21:28:31 +02:00
Nicolò Ribaudo
e561a4af3c
Pin GitHub actions to Node.js 21
Node.js 22 was just released, and it seems like it's not compatible
with the `canvas` package. This commit pins the version on GitHub
actions to Node.js 21 as a temporary workaround.

This commit should be reverted once
https://github.com/Automattic/node-canvas/issues/2377
is fixed.
2024-04-26 19:23:16 +02:00
calixteman
90d4b9c2c0
Merge pull request #17868 from calixteman/interpolate_flag
Always enable smoothing when rendering downscaled image
2024-04-24 20:16:01 +02:00
Calixte Denizet
b511878ba7 Always enable smoothing when rendering downscaled image
and rely on the Interpolate flag only when the image is upscaled.
Fixes #16273.
2024-04-24 18:33:21 +02:00
calixteman
d1f494d68c
Merge pull request #17986 from calixteman/fix_struct_tree
Allow to insert several annotations under the same parent in the structure tree
2024-04-24 18:32:00 +02:00