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

20672 commits

Author SHA1 Message Date
Jonas Jenwald
9217d253aa
Merge pull request #19771 from Snuffleupagus/canvas-shorter-CanvasExtraState
Change how (most) fields are initialized in the `CanvasExtraState` class
2025-04-05 18:46:24 +02:00
Jonas Jenwald
7cfb1be650
Merge pull request #19758 from Snuffleupagus/OperatorList-setOptions
Initialize the `isOffscreenCanvasSupported` option, in the `OperatorList` class, once per document
2025-04-05 18:45:55 +02:00
Jonas Jenwald
a70f42339e
Merge pull request #19756 from Snuffleupagus/canvas-unconditional-ctx-filter
Use `ctx.filter` unconditionally in the `src/display/canvas.js` file
2025-04-05 18:45:19 +02:00
Jonas Jenwald
010b6ad886 Change how (most) fields are initialized in the CanvasExtraState class
The majority of the class fields don't depend on any parameters, hence we can re-factor and shorten by this using modern JavaScript features.
2025-04-05 15:03:06 +02:00
Jonas Jenwald
624d8a418e Remove "unnecessary" inline function names in the src/display/canvas.js file
This is ever so slightly shorter, which cannot hurt.
2025-04-05 14:59:04 +02:00
calixteman
7eef7dfc78
Merge pull request #19763 from calixteman/simplify_updaterect
Replace UpdateRectMinMax by getAxialAlignedBoundingBox
2025-04-04 21:33:05 +02:00
Jonas Jenwald
a6934a4dd5
Merge pull request #19768 from Snuffleupagus/writer-infoMap
Pass the /Info-strings as a `Map` to the `src/core/writer.js` code
2025-04-04 20:53:55 +02:00
Calixte Denizet
e7a951547d Replace UpdateRectMinMax by getAxialAlignedBoundingBox
and don't use array destructuring because it induces a memory and perf penalties.
2025-04-04 19:57:55 +02:00
Jonas Jenwald
dad6febc39 Pass the /Info-strings as a Map to the src/core/writer.js code
We want to iterate through the data in the `computeMD5` function, and `Map`s have "nicer" support for that than generic objects.
(Somewhat recently `Map` performance was improved in Firefox, however this also isn't really performance sensitive code.)
2025-04-04 13:36:13 +02:00
Jonas Jenwald
0bde69c7bf
Merge pull request #19767 from Snuffleupagus/issue-19761
Attempt to get bundlers to leave Emscripten Compiler generated `URL`s alone (issue 19761)
2025-04-04 12:30:15 +02:00
Jonas Jenwald
20e06c4bb5 Attempt to get bundlers to leave Emscripten Compiler generated URLs alone (issue 19761)
Note that we load all wasm-files manually, however the Emscripten Compiler (emcc) unfortunately generates `URL`s for fallback wasm-file loading.
In the PDF.js build-scripts we work-around that by using suitable Webpack-options, however that apparently doesn't work when third-party users re-bundle our code and we thus try to work-around this by adding "ignore comments" to these `URL`s (similar to how we handle `import`-statements).
2025-04-04 11:45:54 +02:00
Jonas Jenwald
bd06061e85
Merge pull request #19766 from Snuffleupagus/version-5.2
Bump library version to `5.2`
2025-04-04 08:58:16 +02:00
Jonas Jenwald
bd418de6b0 Bump library version to 5.2 2025-04-04 08:54:06 +02:00
Jonas Jenwald
16c876569f
Merge pull request #19760 from Snuffleupagus/OperatorList-transfers-bitmap
Also transfer `ImageBitmap`s for image masks and inline images
2025-04-03 20:10:27 +02:00
Jonas Jenwald
8c5fb7979f Also transfer ImageBitmaps for image masks and inline images
Currently we're only transferring TypedArrays, however there's no reason (as far as I can tell) to not also transfer `ImageBitmap`s in these cases.
2025-04-03 18:50:39 +02:00
calixteman
ff2d95a9b6
Merge pull request #19752 from calixteman/simplify_updateRectMinMax
Simplify updateRectMinMax in order to use slightly less memory
2025-04-03 18:25:30 +02:00
Calixte Denizet
41bed561f0 Simplify updateRectMinMax in order to use slightly less memory 2025-04-03 17:06:58 +02:00
Jonas Jenwald
4a6c47489e Initialize the isOffscreenCanvasSupported option, in the OperatorList class, once per document
Currently we're setting this option for each small inline image, which seems unnecessary since it should suffice to do that once per document.
2025-04-03 14:00:07 +02:00
Jonas Jenwald
0c78b46184 Use ctx.filter unconditionally in the src/display/canvas.js file
It seems that the `@napi-rs/canvas` dependency has *basic* canvas-filter support, whereas the "old" `canvas` dependency didn't, hence we no longer need the Node.js-specific checks in the `src/display/canvas.js` file.

Note that I've successfully tested the [`pdf2png` example](https://github.com/mozilla/pdf.js/tree/master/examples/node/pdf2png) with this patch applied and things appear to work as before.
2025-04-03 12:30:29 +02:00
Jonas Jenwald
a45f961a1c
Merge pull request #19751 from Snuffleupagus/applyTransform-in-place
Change `Util.applyTransform` to use the point-argument as an in/out parameter
2025-04-02 20:47:21 +02:00
calixteman
b7437376f1
Merge pull request #19732 from calixteman/rm_useless_beginpath
Remove few useless beginPaths
2025-04-02 13:46:05 +02:00
Jonas Jenwald
4262603b06 Re-name the Util.applyTransformToBezierInPlace method
Given that all `Util.apply...` methods are now using in/out parameters, we can slightly shorten the name of this one.
2025-04-01 23:03:50 +02:00
Jonas Jenwald
c852e877d8 Change Util.applyInverseTransform to use the point-argument as an in/out parameter
This will help reduce the total number of Array allocations, which cannot hurt.
2025-04-01 23:03:44 +02:00
Jonas Jenwald
fa643bb22f Change Util.applyTransform to use the point-argument as an in/out parameter
This will help reduce the total number of Array allocations, which cannot hurt, and also allows us to remove the `Util.applyTransformInPlace` method.
2025-04-01 23:03:36 +02:00
Jonas Jenwald
e5fbf52405
Merge pull request #19736 from Snuffleupagus/compileType3Glyph-worker
[api-minor] Move Type3-glyph compilation to the worker-thread
2025-04-01 19:40:30 +02:00
Jonas Jenwald
b33522a208
Merge pull request #19746 from Snuffleupagus/evaluator-img-cache-tweaks
Reduce some code duplication when handling globally cached images
2025-04-01 19:15:10 +02:00
calixteman
25693dc0ee
Merge pull request #19712 from calixteman/optimize_save_construct
Optimize save-transform-constructPath-restore
2025-04-01 18:20:59 +02:00
Calixte Denizet
a35443ff45 Remove few useless beginPaths.
The ctx current path is no more changed since we use some Path2D when we want to fill/stroke them.
It makes calling ctx.beginPath useless.
2025-04-01 16:02:38 +02:00
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