Commit Graph

18498 Commits

Author SHA1 Message Date
Calixte Denizet
7529c1e3dc [Editor] Fix the position of the free highlight toolbar 2024-01-30 15:40:33 +01:00
Jonas Jenwald
56dabe9390
Merge pull request #17596 from nicolo-ribaudo/fix-babel-plugin
Fix transform of unary expression in Babel plugin
2024-01-29 12:57:42 +01:00
Nicolò Ribaudo
a352f28785
Fix transform of unary expression in Babel plugin
All of our static evaluation & dead-code elimination transforms need to
happen in post-order, transforming inner nodes first. This is so that
in complex nested cases all transforms see the simplified version of
their inner nodes.

For example:
  async getNimbusExperimentData() {
    if (!PDFJSDev.test("GECKOVIEW")) { return null; }
    // other code
  }
-> [evaluation of PDFJSDev.*]
  async getNimbusExperimentData() {
    if (!false) { return null; }
    // other code
  }
-> [!false -> true]
  async getNimbusExperimentData() {
    if (true) { return null; }
    // other code
  }
-> [if (true) -> replace with the if branch]
  async getNimbusExperimentData() {
    return null;
    // other code
  }
-> [early return -> remove dead code]
  async getNimbusExperimentData() {
    return null;
    // other code
  }

This was done correctly in all cases except for our `UnaryExpression`
transform, which was happening in pre-order.
2024-01-29 11:53:17 +01:00
Jonas Jenwald
802f702695
Merge pull request #17593 from Snuffleupagus/debuggerSrc-AppOptions
Move the `debuggerSrc`-parameter into the `AppOptions`
2024-01-28 18:54:15 +01:00
Jonas Jenwald
eb36fd375c Move the debuggerSrc-parameter into the AppOptions
Having this parameter among a list of DOM-elements seems slightly strange now, however this is very old code hence the explanation for why this was done is for historical reasons (as is often the case).
Hence we can simply move this into `AppOptions` instead, which seems more appropriate overall.
2024-01-28 18:47:51 +01:00
Tim van der Meij
2e2127cbb5
Merge pull request #17592 from Snuffleupagus/viewer-generate-fileInput
[GENERIC viewer] Generate the `fileInput` DOM-element dynamically
2024-01-28 18:11:21 +01:00
Jonas Jenwald
f394031c1d [GENERIC viewer] Generate the fileInput DOM-element dynamically
Given that only the GENERIC viewer supports opening more than one PDF document, we can simplify things a tiny bit by instead generating the necessary DOM-element in JavaScript.
2024-01-28 16:51:28 +01:00
Tim van der Meij
32a5bb83d4
Merge pull request #17591 from Snuffleupagus/issue-17399
Re-enable the `should compress and save text` unit-test (issue 17399)
2024-01-28 14:47:52 +01:00
Jonas Jenwald
384291234d Re-enable the should compress and save text unit-test (issue 17399)
This unit-test is now failing in up to date versions of Node.js respectively Chromium-browsers, since `CompressionStream` no longer produces consistent data across all environments/browsers.
However logging the compressed TypedArray produced by `writeStream`, with Firefox respectively Chrome, and then feeding *both* of those TypedArray as input to `DecompressionStream` produced the same (correct) result in both browsers.

Hence the *exact* output of `CompressionStream` shouldn't matter, as long as we're able to successfully decompress it when the resulting PDF document is opened with the PDF.js library, and the unit-test is thus extended to check this.
2024-01-28 14:31:07 +01:00
Tim van der Meij
ab392584f3
Merge pull request #17590 from timvandermeij/updates
Update dependencies/translations to the most recent versions
2024-01-28 12:10:20 +01:00
Tim van der Meij
94309edc9a
Disable the "should compress and save text" unit test in Chrome too
Starting with Chrome 120.0.6099.109 (shipped with Puppeteer 21.8.0+) the
unit test fails in Chrome as well. The issue is tracked in #17399, but
for now we'll only run the unit test in Firefox so we can continue to
update Puppeteer while also still having a browser in which it runs,
until we figure out why the behavior of `CompressionStream` changed.
2024-01-27 20:34:30 +01:00
Tim van der Meij
f103f277ac
Update translations to the most recent versions 2024-01-27 19:13:06 +01:00
Tim van der Meij
f855a6dae8
Update dependencies to the most recent versions 2024-01-27 19:12:59 +01:00
Tim van der Meij
a6e0b0292e
Merge pull request #17588 from Snuffleupagus/DefaultExternalServices-lighten
Re-factor `DefaultExternalServices` into a regular class, without static methods
2024-01-27 14:13:49 +01:00
Jonas Jenwald
c6594b73a7 Stub out the getNimbusExperimentData method in "regular" MOZCENTRAL builds 2024-01-27 13:12:54 +01:00
Jonas Jenwald
5dd25b6e80 Re-factor DefaultExternalServices into a regular class, without static methods
The `DefaultExternalServices` code, which is used to provide build-specific functionality, is very old. This results in a pattern where we first initialize `PDFViewerApplication.externalServices` and then *override* it for the different builds.

By converting `DefaultExternalServices` into a "regular" class, and leveraging import maps, we can directly initialize the correct instance depending on the build.
2024-01-27 12:07:15 +01:00
Jonas Jenwald
d1080e785a Remove the createPreferences method from DefaultExternalServices
Given the simplicity of the `createPreferences` method, we can leverage import maps to directly initialize the correct `Preferences`-instance depending on the build.
2024-01-27 11:38:42 +01:00
Jonas Jenwald
1698991ae2 Remove the createDownloadManager method from DefaultExternalServices
Given the simplicity of the `createDownloadManager` method, we can leverage import maps to directly initialize the correct `DownloadManager`-instance depending on the build.
2024-01-27 11:38:36 +01:00
calixteman
d8f77e6b84
Merge pull request #17582 from calixteman/editor_highlight_thickness_tooltip
[Editor] Add a tooltip to the slider to set the thickness of free highlights
2024-01-26 19:20:08 +01:00
calixteman
e63fafd0fb
Merge pull request #17581 from calixteman/editor_highlight_cursor
[Editor] Change the cursors for highlighting (bug 1876588)
2024-01-26 18:52:29 +01:00
Jonas Jenwald
3192d37aa7
Merge pull request #17587 from Snuffleupagus/fix-FontInspector-textLayer-opacity
Fix the textLayer-opacity when using the FontInspector (PR 17533 follow-up)
2024-01-26 18:37:50 +01:00
Calixte Denizet
0432d1e8e6 [Editor] Add a tooltip to the slider to set the thickness of free highlights 2024-01-26 18:34:26 +01:00
Jonas Jenwald
fed3ef1743 Fix the textLayer-opacity when using the FontInspector (PR 17533 follow-up) 2024-01-26 18:31:38 +01:00
Calixte Denizet
f3bdbedf9b [Editor] Change the cursors for highlighting (bug 1876588) 2024-01-26 18:17:05 +01:00
calixteman
4ec43488ff
Merge pull request #17580 from calixteman/freetext_icon
[Editor] Change the icon to add a FreeText annotation (bug 1876564)
2024-01-25 18:20:20 +01:00
Calixte Denizet
01280d8e08 [Editor] Change the icon to add a FreeText annotation (bug 1876564) 2024-01-25 17:18:28 +01:00
calixteman
bf92360095
Merge pull request #17574 from calixteman/improve_bezier_bbox
Reduce memory use and improve perfs when computing the bounding box of a bezier curve (bug 1875547)
2024-01-25 10:07:48 +01:00
calixteman
2f4017e22b
Merge pull request #17578 from Snuffleupagus/css-vars-unreferenced
Fix unreferenced CSS variables (PR 17533 follow-up)
2024-01-25 10:04:37 +01:00
Jonas Jenwald
1cbcb89dac Fix unreferenced CSS variables (PR 17533 follow-up)
The latest mozilla-central update has test failures, because some CSS variables are not "properly" referenced; in particular:
 - Give `--hcm-highlight-selected-filter` a default value, of `none`, similar to the previously existing HCM filter.
 - Remove the `--mix-blend-mode` variable, since it's unused.
2024-01-25 09:43:20 +01:00
Calixte Denizet
7f2428a77e Reduce memory use and improve perfs when computing the bounding box of a bezier curve (bug 1875547)
It isn't really a fix for the mentioned bug but it slightly improve things.
In reducing the memory use, the time spent in the GC is reduced either.
The algorithm to compute the bounding box is the same as before but it has just
been rewritten to be more efficient.
2024-01-24 23:41:14 +01:00
calixteman
a5d4660a75
Merge pull request #17568 from calixteman/editor_free_highlight_thickness
[Editor] Add the possibility to change the thickness of a free highlight (bug 1876096)
2024-01-24 22:37:40 +01:00
Calixte Denizet
2b8ecf5688 [Editor] Add the possibility to change the thickness of a free highlight (bug 1876096) 2024-01-24 22:04:39 +01:00
calixteman
f81f9bb7d3
Merge pull request #17564 from calixteman/editor_update_ui_undo
[Editor] Update the parameters in the UI of the last selected editor when undoing/redoing
2024-01-24 21:52:54 +01:00
Calixte Denizet
d713df28c3 [Editor] Update the parameters in the UI of the last selected editor when undoing/redoing 2024-01-24 18:16:51 +01:00
Jonas Jenwald
ae62787080
Merge pull request #17563 from nicolo-ribaudo/build-step-remove-custom-webpack
Replace the webpack+acorn transform with a Babel plugin
2024-01-23 19:00:28 +01:00
Nicolò Ribaudo
f724ae98a1
Replace the webpack+acorn transform with a Babel plugin
This commit converts the pdfjsdev-loader transform into a Babel plugin,
to skip a AST->string->AST round-trip.

Before this commit, the webpack build process was:
1. Babel parses the code
2. Babel transforms the AST
3. Babel generates the code
4. Acorn parses the code
5. pdfjsdev-loader transforms the AST
6. @javascript-obfuscator/escodegen generates the code
7. Webpack parses the file
8. Webpack concatenates the files

After this commit, it is reduced to:
1. Babel parses the code
2. Babel transforms the AST
3. babel-plugin-pdfjs-preprocessor transforms the AST
4. Babel generates the code
5. Webpack parses the file
6. Webpack concatenates the files

This change improves the build time by ~25% (tested on MacBook Air M2):
- `gulp lib`: 3.4s to 2.6s
- `gulp dist`: 36s to 29s
- `gulp generic`: 5.5s to 4.0s
- `gulp mozcentral`: 4.7s to 3.2s

The new Babel plugin doesn't support the `saveComments` option of
pdfjsdev-loader, and it just always discards comments. Even though
pdfjsdev-loader supported multiple values for that option, it was
effectively ignored due to `acorn` dropping comments by default.
2024-01-23 16:00:59 +01:00
Nicolò Ribaudo
f5bb9bc21b
Rename preprocessor2.mjs to babel-plugin-pdfjs-preprocessor.mjs
This is in preparation for the next commit, which will convert
preprocessor2.mjs to a Babel plugin. The purpose of this commit
is to help git track the rename regardless of the large amount
of changes.
2024-01-23 13:13:43 +01:00
Jonas Jenwald
8b24722113
Merge pull request #17562 from Snuffleupagus/evaluator-more-async
Add more `async` code in the `PartialEvaluator`
2024-01-23 10:35:27 +01:00
Jonas Jenwald
fa583427ef Always export the "raw" /ToUnicode-data from PartialEvaluator.preEvaluateFont (PR 13354 follow-up)
This, ever so slightly, simplifies the implementation in the `PartialEvaluator.extractDataStructures`-method.
2024-01-22 13:06:32 +01:00
Jonas Jenwald
f21a30dfb4 Convert the PartialEvaluator.readToUnicode method to be async 2024-01-22 12:47:06 +01:00
Jonas Jenwald
f5c01188dc Convert the PartialEvaluator.extractDataStructures method to be async 2024-01-22 12:47:06 +01:00
Jonas Jenwald
cf0797dfbd Use await consistently in the PartialEvaluator.setGState method 2024-01-22 12:47:06 +01:00
Jonas Jenwald
1cc83c4fdc Use await consistently in the PartialEvaluator.buildFormXObject method 2024-01-22 12:47:06 +01:00
calixteman
bba831821d
Merge pull request #17558 from calixteman/bug1669097
Print correctly documents containing chars with an unicode greater than 0xFFFF (bug 1669097)
2024-01-22 12:23:06 +01:00
Calixte Denizet
06601fd90c Print correctly documents containing chars with an unicode greater than 0xFFFF (bug 1669097) 2024-01-22 10:48:00 +01:00
Tim van der Meij
49b2d9b5af
Merge pull request #17556 from Snuffleupagus/issue-17554
Ensure that `EvaluatorPreprocessor.opMap` has a null-prototype (issue 17554)
2024-01-21 20:58:09 +01:00
Tim van der Meij
1ed68933e5
Merge pull request #17555 from timvandermeij/gulpfile-exit-code
Don't ignore `test.mjs` child process exit codes in the Gulpfile
2024-01-21 20:34:22 +01:00
Tim van der Meij
d549c2ef4c
Merge pull request #17553 from Snuffleupagus/async-handleSetFont
Add more `async` code when loading fonts in the `PartialEvaluator`
2024-01-21 20:00:29 +01:00
Jonas Jenwald
d7e41d4cb6 Ensure that EvaluatorPreprocessor.opMap has a null-prototype (issue 17554)
This accidentally regressed in PR 16956, sorry about that!
2024-01-21 19:59:13 +01:00
Tim van der Meij
6dd77b3c14
Don't ignore test.mjs child process exit codes in the Gulpfile
In the Gulpfile only the exit codes of `test.mjs` child processes
erroneously aren't checked. This causes failures in `test.mjs` to be
logged but not propagated to the master process, which in turn causes
test runners such as GitHub Actions to succeed because they only
monitor the master process. This is easy to reproduce by throwing an
error at the top of `test.mjs` and running `gulp makeref` or `gulp
unittest`: the error is logged, but the task that spawned the child
process succeeds and the master process exits with exit code 0. This is
problematic because it can easily cause errors to go by unnoticed.

This commit fixes the issue by making sure that the `test.mjs`
invocations are handled in the same way as the other child processes
in the file, i.e., if the child process exits with a non-zero exit code
then the master process also exits with a non-zero exit code. After this
patch the error is still logged, but the task now also fails and the
master process exits with exit code 1 to properly signal failure.
2024-01-21 19:37:13 +01:00