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

3490 commits

Author SHA1 Message Date
calixteman
12c4119cbd
Merge pull request #17946 from calixteman/openjpeg
[api-minor] Add a jpx decoder based on OpenJPEG 2.5.2
2024-04-16 13:41:58 +02:00
Calixte Denizet
2e83cfbbc1 [api-minor] Add a jpx decoder based on OpenJPEG 2.5.2
The decoder is compiled in WASM:
https://github.com/mozilla/pdf.js.openjpeg

Fixes #17289, #17061, #16485, #13051, #6365, #4648, #12213.
2024-04-16 12:54:36 +02:00
Tim van der Meij
0e612fbb7d
Fix the "must check that a field has the correct value when a choice is changed" scripting integration test
We should not wait for an arbitrary amount of time, which can easily
cause intermittent failures, but wait for a value change instead. Note
that this patch mirrors the approach we already use in other scripting
integration tests that also check for a value change; see e.g. the
"must check that a field has the correct formatted value" test.
2024-04-15 15:56:39 +02:00
Tim van der Meij
1008a53362
Merge pull request #17938 from timvandermeij/rimraf-test
Remove the `rimraf` dependency in favor of the built-in Node.js `fs.rmSync` in the test folder
2024-04-15 14:21:56 +02:00
Tim van der Meij
2e9bd496ce
Fix the "must check that invisible fields are made visible" scripting integration test
We should not wait for an arbitrary amount of time, which can easily
cause intermittent failures, but wait for a property value change
instead. Note that this patch mirrors the approach we already use in
other scripting integration tests that also check for a visibility
change; see e.g. the "must show a text field and then make in invisible
when content is removed" test.
2024-04-14 18:53:09 +02:00
Tim van der Meij
a562c41e12
Remove the rimraf dependency in favor of the built-in Node.js fs.rmSync in the test folder
In Node.js 14.14.0 the `fs.rmSync` function was added that removes files
and directories. The `recursive` option is used to remove directories
and their contents, making it a drop-in replacement for the `rimraf`
dependency we use.

Given that PDF.js now requires Node.js 18+ we can be sure that this
option is available, so we can safely remove `rimraf` and reduce the
number of project dependencies in the test folder.

This commit also gets rid of the indirection via the `removeDirSync`
test helper function by simply calling `fs.rmSync` directly.

Co-authored-by: Wojciech Maj <kontakt@wojtekmaj.pl>
2024-04-14 16:41:59 +02:00
Tim van der Meij
2d885e2862
Merge pull request #17930 from calixteman/issue17929
Remove the tag for missing font subset when trying to find a substitution
2024-04-12 13:27:32 +02:00
Calixte Denizet
52ea2333b3 Remove the tag for missing font subset when trying to find a substitution
Fixes #17929.
2024-04-11 20:34:28 +02:00
Tim van der Meij
253a7333d8
Fix the "must highlight text in the right position" integration test
This commit implements the following improvements for the test:

- Replace the hardcoded highlight padding with a dynamic calculation. It
  turns out that the amount of padding can differ per system, possibly
  due to e.g. local (font) settings, which could cause the test to fail.
  The test now no longer implicitly depends on the environment.
- Remove the page offset subtraction. It's only needed for one assertion,
  and we can simply add the page offset there once.
- Improve the "magic" numbers in the test. The number 5 is removed now
  that the padding calculation made it obsolete, the number 28 is changed
  to 30 because that's the actual value in the PDF data and the number 4
  is explained a bit more to state that the space also counts as a glyph.
- Annotate the steps and checks to improve readability of the test and
  to explain why certain calculations have to be performed.
2024-04-11 13:42:08 +02:00
Tim van der Meij
d70caca3e2
Merge pull request #17915 from timvandermeij/lint-waitfortimeout
Implement a linting rule to discourage using `waitForTimeout` for new usages
2024-04-11 12:19:36 +02:00
calixteman
77ee914bd6
Merge pull request #17882 from calixteman/bug1889122
Use the string value of the field when calling the Format callback (bug 1889122)
2024-04-10 09:40:54 +02:00
Calixte Denizet
b643c0fcfb Use the string value of the field when calling the Format callback (bug 1889122) 2024-04-09 22:52:11 +02:00
Tim van der Meij
d4633ba478
Implement a linting rule to discourage using waitForTimeout for new tests
The `waitForTimeout` function should not be used anymore and only exists
for old usages that have to be rewritten, but there was nothing in place
to signal this. This commit therefore implements a linting rule, specific
to the integration tests, to make it clear that this function should no
longer be used. We exclude the old usages from it because we are already
tracking those in #17656 (so this patch is mostly to not make the scope
of that issue bigger).
2024-04-09 16:12:15 +02:00
Calixte Denizet
41aaa083df Don't render annotations with a null dimension
Fixes #17906.
2024-04-09 16:03:49 +02:00
Tim van der Meij
30b65ca067
Merge pull request #17907 from calixteman/fix_draw_ink
[Editor] Don't add an already added editor (bug 1890367)
2024-04-08 20:44:21 +02:00
Tim van der Meij
fb21c4261d
Merge pull request #17890 from timvandermeij/font-tests-callbacks
Modernize the TTX driver code
2024-04-08 20:12:08 +02:00
Calixte Denizet
976ee96aa8 [Editor] Don't add an already added editor (bug 1890367) 2024-04-08 19:50:55 +02:00
Tim van der Meij
d01a0bd0c8
Fix annotation border style parsing by handling empty dash arrays
The PDF specification states that empty dash arrays, i.e. arrays with
zero elements, are in fact valid. In that case the dash array simply
corresponds to a solid, unbroken line. However, this case was erroneously
being flagged as invalid and therefore the annotation was not drawn
because its width was set to zero. This commit fixes the issue by
allowing dash arrays to have a length of zero.
2024-04-08 16:34:27 +02:00
Tim van der Meij
ac03d7054d
Convert the TTX driver code to promises
This commit removes the final callbacks in this code by switching to a
promises-based interface, overall simplifying the code. Moreover, we
document why we write to files on disk and modernize the code using e.g.
template strings.
2024-04-05 13:34:54 +02:00
Tim van der Meij
64065141b6
Remove the timeout logic from the TTX driver code
The original `test.py` code, see
c2376e5cea/test/test.py,
did not have any timeout logic for TTX, but it got introduced when
`test.py` was ported from Python to JavaScript as `test.js` in
c2376e5cea (diff-a561630bb56b82342bc66697aee2ad96efddcbc9d150665abd6fb7ecb7c0ab2f).

However, I don't think we've ever actually seen TTX timing out.
Moreover, back then we used a very old version of TTX and ran the font
tests on the bots (where a hanging process would block other jobs and
would require a manual action to fix), so this code was most likely
only included defensively.

Fortunately, nowadays it should not be necessary anymore because we use
the most recent version of TTX (which either returns the result or
errors out, but isn't known to hang on inputs) and we run the font tests
on GitHub Actions which doesn't block other jobs anymore and also
automatically times the job out for us in the unlikely event that a hang
would ever occur.

In short, we can safely remove this logic to simplify the code and to get
rid of a callback.
2024-04-05 12:49:26 +02:00
Calixte Denizet
54110de109 [Editor] Remove the mark from the highlight element and set its role to mark (bug 1889623)
Set aria-label to the highlighted text, this way the focus frame is exactly set
on the highlight element and the higlighted text is read.
2024-04-04 18:06:05 +02:00
Calixte Denizet
3f2f98336e Update the current stride before composing when decoding a text region
Fixes #17871.

We do something similar to:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/pdfium/core/fxcodec/jbig2/JBig2_TrdProc.cpp;l=373-379;drc=24c6be6924df3ff585bb63f6aed4e2c81e791fb2
2024-04-03 18:44:50 +02:00
Calixte Denizet
8f5d907a52 Don't translate char codes when platform,encoding isn't (3,0) 2024-04-03 16:08:11 +02:00
Tim van der Meij
2e5282928f
Merge pull request #17854 from Snuffleupagus/rm-PromiseCapability
[api-minor] Replace the `PromiseCapability` with  `Promise.withResolvers()`
2024-04-02 15:21:43 +02:00
Jonas Jenwald
e4d0e84802 [api-minor] Replace the PromiseCapability with Promise.withResolvers()
This replaces our custom `PromiseCapability`-class with the new native `Promise.withResolvers()` functionality, which does *almost* the same thing[1]; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers

The only difference is that `PromiseCapability` also had a `settled`-getter, which was however not widely used and the call-sites can either be removed or re-factored to avoid it. In particular:
 - In `src/display/api.js` we can tweak the `PDFObjects`-class to use a "special" initial data-value and just compare against that, in order to replace the `settled`-state.
 - In `web/app.js` we change the only case to manually track the `settled`-state, which should hopefully be OK given how this is being used.
 - In `web/pdf_outline_viewer.js` we can remove the `settled`-checks, since the code should work just fine without it. The only thing that could potentially happen is that we try to `resolve` a Promise multiple times, which is however *not* a problem since the value of a Promise cannot be changed once fulfilled or rejected.
 - In `web/pdf_viewer.js` we can remove the `settled`-checks, since the code should work fine without them:
     - For the `_onePageRenderedCapability` case the `settled`-check is used in a `EventBus`-listener which is *removed* on its first (valid) invocation.
     - For the `_pagesCapability` case the `settled`-check is used in a print-related helper that works just fine with "only" the other checks.
 - In `test/unit/api_spec.js` we can change the few relevant cases to manually track the `settled`-state, since this is both simple and *test-only* code.

---
[1] In browsers/environments that lack native support, note [the compatibility data](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility), it'll be polyfilled via the `core-js` library (but only in `legacy` builds).
2024-04-01 11:42:37 +02:00
Jonas Jenwald
3d2eb36e27
Merge pull request #17858 from Snuffleupagus/issue-17848
Ensure that Mesh /Shadings have non-zero width/height (issue 17848)
2024-03-30 21:59:58 +01:00
Jonas Jenwald
07a8836ab2 Ensure that Mesh /Shadings have non-zero width/height (issue 17848) 2024-03-29 22:58:25 +01:00
Calixte Denizet
136c1faa7f Display outlines even if one has no title
Fixes #17856.
2024-03-29 21:30:24 +01:00
Tim van der Meij
55db43966e
Merge pull request #17847 from Snuffleupagus/issue-17846
Add better support for /Launch actions with /FileSpec dictionaries (issue 17846)
2024-03-28 13:03:01 +01:00
Calixte Denizet
2dbd7acc41 [Editor] Correctly handle lines when pasting some text in a freetext 2024-03-27 17:48:43 +01:00
Jonas Jenwald
0d039937f9 Add better support for /Launch actions with /FileSpec dictionaries (issue 17846) 2024-03-26 20:15:48 +01:00
Calixte Denizet
d5a0e557c2 [Editor] Fix undoing an editor deletion (bug 1886959)
The original bug was because the parent was null when trying to show
an highlight annotation which led to an exception.
That led me to think about having some null/non-null parent when removing
an editor: it's a mess especially if a destroyed parent is still attached
to an editor. Consequently, this patch always sets the parent to null when
deleting the editor.
2024-03-25 14:17:40 +01:00
Calixte Denizet
918b500ca5 Avoid wrong scrolling when calling zoomReset
The goal of this patch is to fix the test:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/test/browser_pdfjs_zoom.js

It's a regression due to #17790.
2024-03-21 16:04:36 +01:00
calixteman
ae60221b0e
Merge pull request #17814 from calixteman/bug1886427
[Editor] Make sure the text in the mark has null dimensions to avoid to see a meaningless rectangle in voiceover (bug 1886427)
2024-03-20 16:23:10 +01:00
Calixte Denizet
3ac52ac359 [Editor] Make sure the text in the mark has null dimensions to avoid to see a meaningless rectangle in voiceover (bug 1886427) 2024-03-20 15:25:13 +01:00
Tim van der Meij
9673a6d344
Merge pull request #17811 from calixteman/simplify_copy_paste_test
Simplify the copy & paste integration test
2024-03-20 14:09:25 +01:00
Calixte Denizet
f6b215144d Simplify the copy & paste integration test 2024-03-19 22:29:59 +01:00
Calixte Denizet
a3873e4c68 Don't hide the editor layer when rotating (follow-up of #17802)
Before the patch in #17802, the layer was made visible when calling updateMode
after the rotation angle was set.
2024-03-19 18:36:55 +01:00
Calixte Denizet
1b00511301 [Editor] Make the text layer focusable before the editors (bug 1881746)
Keep the different layers in a constant order to avoid the use of a z-index
and a tab-index.
2024-03-19 16:14:55 +01:00
Jonas Jenwald
0022310b9c
Merge pull request #17706 from Snuffleupagus/Node-Fetch-API
[api-minor] Use the Fetch API, when supported, to load PDF documents in Node.js environments
2024-03-19 11:04:28 +01:00
calixteman
a142c8c945
Merge pull request #17802 from calixteman/fix_tests
[Editor] Fix the rect used to click in some freetext integration tests
2024-03-19 10:50:34 +01:00
Calixte Denizet
5437199c95 [Editor] Fix the rect used to click in some freetext integration tests
And avoid to uselessly set the pointer listeners in the annotation editor layer.
2024-03-18 10:29:32 +01:00
calixteman
10305bf181
Merge pull request #17795 from calixteman/issue17794
Don't render corrupted inlined images
2024-03-18 10:18:44 +01:00
Calixte Denizet
65d618635c When zooming the scrollbar can disappear and then no scrollend is triggered 2024-03-15 15:37:06 +01:00
Calixte Denizet
9c3471dd01 Don't render corrupted inlined images
Fixes #17794.
2024-03-15 15:33:18 +01:00
Jonas Jenwald
30e69956db
Merge pull request #17694 from Snuffleupagus/validate-defaultOptions
Add better validation for the "PREFERENCE" kind `AppOptions`
2024-03-12 18:24:37 +01:00
Calixte Denizet
b4267cd294 [Editor] Add a floating button close to the selected text to highlight it (bug 1867742)
For now keep this feature behind a pref in order to make some experiments before
deciding to enable it.
2024-03-12 15:06:46 +01:00
Jonas Jenwald
3c78ff5fb0 [api-minor] Implement basic support for OptionalContent Usage dicts (issue 5764, bug 1826783)
The following are some highlights of this patch:
 - In the Worker we only extract a *subset* of the potential contents of the `Usage` dictionary, to avoid having to implement/test a bunch of code that'd be completely unused in the viewer.

 - In order to still allow the user to *manually* override the default visible layers in the viewer, the viewable/printable state is purposely *not* enforced during initialization in the `OptionalContentConfig` constructor.

 - Printing will now always use the *default* visible layers, rather than using the same state as the viewer (as was the case previously).
   This ensures that the printing-output will correctly take the `Usage` dictionary into account, and in practice toggling of visible layers rarely seem to be necessary except in the viewer itself (if at all).[1]

---
[1] In the unlikely case that it'd ever be deemed necessary to support fine-grained control of optional content visibility during printing, some new (additional) UI would likely be needed to support that case.
2024-03-12 13:18:15 +01:00
calixteman
fb9e438442
Merge pull request #17781 from calixteman/stamp_altext_button_cp
[Editor] Make sure the alt-text button is there when pasting an image from an other tab
2024-03-07 21:44:53 +01:00
Calixte Denizet
0f8dda1af0 [Editor] Make sure the alt-text button is there when pasting an image from an other tab 2024-03-07 18:24:34 +01:00