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

20694 commits

Author SHA1 Message Date
Jonas Jenwald
9cd5a9658a [api-minor] Move Type3-glyph compilation to the worker-thread
After PR 19731 the format of compiled Type3-glyphs is now simple enough that the compilation can be moved to the worker-thread, without introducing any significant additional complexity.
This allows us to, ever so slightly, simplify the implementation in `src/display/canvas.js` since the Type3 operatorLists will now directly include standard path-rendering operators (using the format introduced in PR 19689).

As part of these changes we also stop caching Type3 image masks since: we've not come across any cases where that actually helps, they're usually fairly small, and it simplifies the code.

Note that one "negative" change introduced in this patch is that we'll now compile Type3-glyphs *eagerly*, whereas previously we'd only do that lazily upon their first use.
However, this doesn't seem to impact performance in any noticeable way since the compilation is fast enough (way below 1 ms/glyph in my testing) and Type3-fonts are also limited to just 256 glyphs. Also, many (or most?) Type3-fonts don't even use image masks and are thus not affected by these changes.
2025-04-01 09:09:00 +02:00
calixteman
a4950c0b71
Merge pull request #19721 from calixteman/simplif_singular_decomposition
Simplify singularValueDecompose2dScale in order to make it using less memory
2025-03-31 12:53:17 +02:00
Jonas Jenwald
213830f44f Use, and re-name, the addLocallyCachedImageOps helper for global images too
This avoids having to "manually" set the image operators for globally cached images.
2025-03-31 10:57:04 +02:00
Jonas Jenwald
e0e59eaf01 Define the global cache-data once in buildPaintImageXObject
Currently we duplicate the same identical code three times, which seems both unnecessary and error prone.
2025-03-31 10:29:29 +02:00
Calixte Denizet
6e9fbd9420 Simplify singularValueDecompose2dScale in order to make it using less memory
In using the Firefox profiler (with JS allocations tracking) and wuppertal.pdf, I noticed
we were using a bit too much memory for a function which is supposed to just compute 2 numbers.
The memory used by itself isn't so important but having a too much objects lead to waste some time
to gc them.

So this patch aims to simplify it a bit.
2025-03-31 10:28:01 +02:00
Jonas Jenwald
e8b4ed2fde
Merge pull request #19743 from timvandermeij/integration-tests-freetext-isolate-part-3
Isolate the "basic operations" freetext editor integration tests
2025-03-31 09:27:26 +02:00
Tim van der Meij
ed08a6a988
Isolate the "basic operations" freetext editor integration tests
This commit reduces the number of freetext editor integration test suite
failures, in full isolation, from 5 to 0 by fixing the following issues
in the "basic operations" block:

- Most tests relied on the first test to enable freetext editing mode.
  For isolation we now do it explicitly in all tests.
- Most tests relied on the other tests having created editors. For
  isolation we now create the editors explicitly in the tests themselves.
- Most tests relied on previous tests for the editor numbering. For
  isolation we change the editor numbering to the one after initial
  document load. Since we can't have state (editors) from a previous
  test anymore we can remove various `clearAll` calls as well.
2025-03-30 18:52:19 +02:00
Tim van der Meij
f32254dbd4
Merge pull request #19742 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2025-03-30 18:04:07 +02:00
Tim van der Meij
040e9c7be4
Update translations to the most recent versions 2025-03-30 15:46:00 +02:00
Tim van der Meij
bb8fb74b72
Upgrade eslint-plugin-unicorn to version 58.0.0
This is a major version bump, but the changelog at
https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v58.0.0
doesn't indicate any breaking changes that should impact us.
2025-03-30 15:44:51 +02:00
Tim van der Meij
a6db2d9f47
Update dependencies to the most recent versions 2025-03-30 15:43:55 +02:00
Tim van der Meij
221956d8ba
Merge pull request #19741 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2025-03-30 15:33:32 +02:00
Tim van der Meij
7a1ff7f36c
Bump the stable version in pdfjs.config 2025-03-30 15:30:08 +02:00
Tim van der Meij
45cbe8bb0d
Merge pull request #19735 from Snuffleupagus/Type3WordSpacing
Apply char/word-spacing correctly for missing Type3-glyphs
2025-03-30 12:07:54 +02:00
Tim van der Meij
1ccc82beff
Merge pull request #19733 from Snuffleupagus/import-vite-ignore
[api-minor] Attempt to improve support for using the PDF.js builds with Vite
2025-03-30 11:58:20 +02:00
Tim van der Meij
97bf09b795
Merge pull request #19739 from Snuffleupagus/buildPaintImageXObject-fn-OPS
Reduce duplication when specifying the fn-operations in `buildPaintImageXObject`
2025-03-30 11:55:53 +02:00
Tim van der Meij
cb818ce0d3
Merge pull request #19720 from Snuffleupagus/_initializeViewerComponents-shorten
Shorten the `PDFViewerApplication._initializeViewerComponents` method
2025-03-30 11:52:19 +02:00
Tim van der Meij
9d237b9f96
Merge pull request #19737 from Snuffleupagus/TilingPattern-color-param
Simplify handling of the color-parameter in `TilingPattern` (PR 4824 follow-up)
2025-03-30 11:49:11 +02:00
Tim van der Meij
9e58bac43c
Merge pull request #19740 from Snuffleupagus/integration-test-properly-spelling
Spell "properly" in viewer integration-test names
2025-03-30 11:48:12 +02:00
Jonas Jenwald
5b7b94c078 Spell "properly" in viewer integration-test names 2025-03-29 16:35:22 +01:00
Jonas Jenwald
8e3a3387e0 Reduce duplication when specifying the fn-operations in buildPaintImageXObject
Currently we explicitly specify the fn-`OPS` both when adding entries to the operatorList and to the image-caches, and by using a temporary variable we can reduce a bit of duplication (similar to the existing args-handling).
2025-03-29 15:56:46 +01:00
Jonas Jenwald
09118670ca Simplify handling of the color-parameter in TilingPattern (PR 4824 follow-up)
The color-parameter is already available through `IR` (i.e. the internal representation), and after the changes in PR 4824 (which landed in 2014) we no longer need any special handling for it.
2025-03-29 13:02:13 +01:00
Jonas Jenwald
667645798f Apply char/word-spacing correctly for missing Type3-glyphs
In the included PDF document the Type3-font doesn't contain any glyph definition for "space", despite that character being referenced in the /Contents stream.
While missing Type3-glyphs obviously cannot be rendered, we still need to update the current canvas position such that any char/word-spacing is correctly applied.

The test-case was found at https://github.com/pdf-association/pdf-differences/tree/main/Type3WordSpacing
2025-03-29 00:12:08 +01:00
calixteman
dfa553dc11
Merge pull request #19734 from calixteman/bug1952563
[Editor] Add a border to the undo button in the snackbar in order to make a contrast (bug 1952563)
2025-03-28 22:03:22 +01:00
Calixte Denizet
bb2ef20420 [Editor] Add a border to the undo button in the snackbar in order to make a contrast (bug 1952563) 2025-03-28 21:42:57 +01:00
Jonas Jenwald
8bcc3664c9 [api-minor] Attempt to improve support for using the PDF.js builds with Vite
Similar to Webpack there's apparently other bundlers that will not leave `import`-calls alone unless magic comments are used.
Hence we extend the builder to also append `/* @vite-ignore */` comments to `import`-calls, in order to attempt to improve support for using the PDF.js builds together with Vite.

This patch also renames `__non_webpack_import__` to `__raw_import__` since the functionality is no longer bundler-specific.

***PLEASE NOTE:*** This patch is provided as-is, and it does *not* mean that the PDF.js project can/will provide official support for Vite.
2025-03-28 16:34:00 +01:00
Jonas Jenwald
34136d7775
Merge pull request #19731 from Snuffleupagus/Type3-Path2D-pre-transform
Pre-apply the transform when building the `Path2D` objects for Type3-fonts
2025-03-28 16:29:18 +01:00
Jonas Jenwald
f577271908 Simplify the compileType3Glyph function to just return the Path2D objects
Originally this function would "manually" invoke the rendering commands for Type3-glyphs, however that was changed some time ago:
 - Initial `Path2D` support was added in PR 14858, but the old code kept for Node.js compatibility.
 - Since PR 15951 we've been using a `Path2D` polyfill in Node.js environments.

Hence, after the previous commit, we can further simplify this function by *directly* returning/using the `Path2D` object when rendering Type3-glyphs; see also https://github.com/mozilla/pdf.js/pull/19731#discussion_r2018712695
While this won't improve performance significantly, when compared to the introduction of `Path2D`, it definately cannot hurt.
2025-03-28 15:20:43 +01:00
Jonas Jenwald
852b7e407a Pre-apply the transform when building the Path2D objects for Type3-fonts
Rather than updating the transform every time that we're painting a Type3-glyph, we can instead just compute the "final" coordinates during building of the `Path2D` objects.
2025-03-28 13:28:25 +01:00
calixteman
31ec357282
Merge pull request #19730 from calixteman/update_fluent
Update @fluent/dom to 0.10.1
2025-03-28 11:13:53 +01:00
Calixte Denizet
6ff1626cf3 Update @fluent/dom to 0.10.1 2025-03-28 09:39:02 +01:00
calixteman
3da8901f26
Merge pull request #19728 from calixteman/bug1956513
[Editor] Set an aria-description for an added signature (bug 1956513)
2025-03-27 21:31:02 +01:00
Jonas Jenwald
f23087ca7e
Merge pull request #19726 from Snuffleupagus/_setDefaultAppearance-bbox
Use `Util.rectBoundingBox` more in the annotation code (PR 19713 follow-up)
2025-03-27 21:30:01 +01:00
Calixte Denizet
7d8c64b2ff [Editor] Set an aria-description for an added signature (bug 1956513)
NVDA behaves differently depending if the user is hovering or focusing an added signature.
An aria-description is read in both cases while an aria-label is not.
2025-03-27 18:14:06 +01:00
Jonas Jenwald
29788eb0b8 Use Util.rectBoundingBox more in the annotation code (PR 19713 follow-up)
By changing the return format of the various `pointsCallback` functions we can use the `Util.rectBoundingBox` helper in the `MarkupAnnotation.prototype._setDefaultAppearance` method as well, thus shortening the code slightly.
2025-03-27 13:46:36 +01:00
calixteman
2da54ffb59
Merge pull request #19725 from calixteman/bug1956114
[Editor] in the signature UI, disable the description input if there is no signature (bug 1956114)
2025-03-27 13:36:32 +01:00
Calixte Denizet
62df96894d [Editor] in the signature UI, disable the description input if there is no signature (bug 1956114) 2025-03-26 23:02:13 +01:00
calixteman
828398f60f
Merge pull request #19722 from calixteman/bug1956110
[Editor] Fix the border color of a tab panel in HCM (bug 1956110)
2025-03-26 18:54:19 +01:00
Calixte Denizet
5c3c003931 [Editor] Fix the border color of a tab panel in HCM (bug 1956110)
And fix the color of the signature itself when its a drawing or if it comes
from an image.
2025-03-26 14:56:24 +01:00
Jonas Jenwald
c6b9338f6f
Merge pull request #19719 from Snuffleupagus/structTree-xref
Pass the `XRef`-instance explicitly to the `StructTreeRoot` class, and simplify the `StructElementNode.prototype.role` getter
2025-03-25 19:41:20 +01:00
Jonas Jenwald
74ab29544e
Merge pull request #19701 from Snuffleupagus/enableAutoLinking-true
[api-minor] Enable `enableAutoLinking` by default
2025-03-25 18:18:08 +01:00
Jonas Jenwald
22107145df
Merge pull request #19691 from Snuffleupagus/xfa-template-rm-reduce
Remove `Array.prototype.reduce` usage from the `src/core/xfa/template.js` file
2025-03-25 18:17:12 +01:00
Jonas Jenwald
532406427b Simplify the StructElementNode.prototype.role getter a tiny bit
Given that the `roleMap` only contains `Name`-strings, the lookup can be simplified thanks to modern JavaScript features.
2025-03-25 18:04:56 +01:00
Jonas Jenwald
3c93d63731 Pass the XRef-instance explicitly to the StructTreeRoot class
This avoids the current situation where we're accessing it through various dictionaries, since that's a somewhat brittle solution given that in the general case a `Dict`-instance may not have the `xref`-field set (see e.g. the empty-Dict).
2025-03-25 18:04:51 +01:00
calixteman
d4c7aaa9d3
Merge pull request #19702 from calixteman/issue19694
In the struct tree a kid can be a reference to an MCID entry (issue #19694)
2025-03-25 18:02:46 +01:00
Calixte Denizet
6146e5fee7 Optimize save-transform-constructPath-restore
The 4 operations can be replaced with just one in applying the transform to the points coordinates.
2025-03-25 15:31:45 +01:00
Calixte Denizet
dee80cb082 In the struct tree a kid can be a reference to an MCID entry (issue #19694) 2025-03-25 15:01:52 +01:00
Jonas Jenwald
8f7d6f4118 Shorten the PDFViewerApplication._initializeViewerComponents method
By tweaking a few local variable names we can shorten various viewer-component initialization code, and we can also reduce some duplication when assigning components to the `PDFViewerApplication`-scope.
2025-03-25 12:51:40 +01:00
calixteman
a8c77633a1
Merge pull request #19717 from calixteman/issue16287
Don't overwrite the global alpha when switching to smask mode (bug 1764587)
2025-03-25 10:08:36 +01:00
Calixte Denizet
1d0227af62 Don't overwrite the global alpha when switching to smask mode
It fixes #issue16287.
2025-03-24 21:35:09 +01:00