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

19718 commits

Author SHA1 Message Date
Jonas Jenwald
e9a319be2c
Merge pull request #18649 from Snuffleupagus/resizers-fluent
[Editor] Utilize Fluent "better" when localizing the resizer DOM-elements
2024-08-27 14:58:59 +02:00
Jonas Jenwald
ac75a05cd4 [Editor] Utilize Fluent "better" when localizing the resizer DOM-elements
Currently we manually localize and update the DOM-elements of the editor-resizers, and it seems nicer to utilize Fluent for that task.
This can be achieved by updating the l10n-strings to directly target the `aria-label` and then just setting the `data-l10n-id` on the DOM-elements.
2024-08-26 21:32:02 +02:00
calixteman
b58c24ab09
Merge pull request #18650 from calixteman/bug1914480
[Editor] Add a missing parameter in the telemetry for the new alt text flow (bug 1914480)
2024-08-26 15:33:41 +02:00
Rob Wu
1d545382a3 [CRX] Remove obsolete extension API calls
These work arounds are no longer relevant to the latest Chrome versions.
2024-08-25 22:03:38 +02:00
Rob Wu
683b511f20 [CRX] Remove obsolete manifest features
In preparation for migrating the Chrome extension to Manifest Version 3,
this patch removes parts of the manifest that are obsolete and/or
unsupported in MV3.

Remove ftp mentions: ftp was dropped from 6 years ago, in Chrome 59.

Remove file_browser_handlers: does not work on Chrome OS according to
https://github.com/mozilla/pdf.js/issues/14161 . MV3 replacement needs
a different manifest key and logic, which will be added later.

Remove content_security_policy: MV3 does not support unsafe-eval CSP,
and PDF.js does not require it. This may result in a mild performance
degradation in PDFs that contain PostScript.

Remove page_action logic: When this logic was originally introduced,
Chrome showed page action buttons in the address bar, which enabled
the extension to display the button on specific PDF viewer tabs only.
In Chrome 49 (2016), pageActions were dropped from the address bar and
put in an UI area that is hidden by default. The user can pin the button
to be unconditionally visible on the toolbar, which is distracting.
Because the UX is no longer serving the original needs, this patch
removes page_action from the manifest.
2024-08-25 20:34:03 +02:00
Calixte Denizet
e8763a08ab [Editor] Add a missing parameter in the telemetry for the new alt text flow (bug 1914480) 2024-08-25 17:33:42 +02:00
Tim van der Meij
54eead78ab
Upgrade Puppeteer to version 23.1.1
This major version contains three breaking changes that impact us:

- The `product` option has been renamed to the more suitable `browser`.
- The `page.screenshot()` API returns a `Uint8Array` instead of a
  `Buffer`, but since `pngjs` requires a `Buffer` object we need to do
  the conversion using `Buffer.from()` before passing data to `pngjs`.
- The browser configuration should be set using a configuration file
  instead of environment variables. Note that as a bonus this allows us
  to remove the `cross-env` dependency since that was only used to set
  the Puppeteer environment variable equally for all operating systems.

For more information about the changes between the old and new Puppeteer
versions refer to https://github.com/puppeteer/puppeteer/releases.
2024-08-25 12:49:20 +02:00
Tim van der Meij
cd99be0aa5
Merge pull request #18638 from Snuffleupagus/PDFDocumentProperties-l10n-functions
Utilize Fluent to format numbers and dates in `PDFDocumentProperties`/`AnnotationLayer`
2024-08-25 12:44:15 +02:00
Tim van der Meij
de365b69fa
Merge pull request #18648 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-08-25 12:39:52 +02:00
Jonas Jenwald
6ce9f97943 Utilize Fluent to format dates in the AnnotationLayer
The `AnnotationLayer` may not display correctly formatted data in PopupAnnotations, especially in the GENERIC viewer, since it's using native methods[1] that depend on the *browser* locale instead of the viewer locale as intended.
With Fluent we're able to improve things since it's got built-in support for formatting dates. Not only does this simplify the JavaScript code slightly, but it also gives the localizer more fine-grained control of the desired output.

Please find additional information here:
 - https://projectfluent.org/fluent/guide/builtins.html
 - https://projectfluent.org/fluent/guide/functions.html

---

[1] `toLocaleDateString`, and `toLocaleTimeString`.
2024-08-25 12:11:02 +02:00
Jonas Jenwald
d96558836e Utilize Fluent to format numbers and dates in PDFDocumentProperties
The `PDFDocumentProperties` dialog may not display correctly formatted data, especially in the GENERIC viewer, since it's using native methods[1] that depend on the *browser* locale instead of the viewer locale as intended.
At the time when this dialog was introduced that was probably all we could easily do, but with Fluent we're able to improve things since it's got built-in support for formatting numbers and dates. Not only does this simplify the JavaScript code, but it also gives the localizer more fine-grained control of the desired output.

Please find additional information here:
 - https://projectfluent.org/fluent/guide/builtins.html
 - https://projectfluent.org/fluent/guide/functions.html

---

[1] `toLocaleString`, `toLocaleDateString`, and `toLocaleTimeString`.
2024-08-25 12:11:02 +02:00
Tim van der Meij
bf778b04a8
Update translations to the most recent versions 2024-08-25 11:40:42 +02:00
Tim van der Meij
c26aac013e
Fix vulnerability in the micromatch dependency
This patch is generated automatically using `npm audit fix` and fixes
CVE-2024-4067 (see https://github.com/advisories/GHSA-952p-6rrq-rcjv),
bringing the vulnerability count back to zero.
2024-08-25 11:39:06 +02:00
Tim van der Meij
5d31fda876
Update dependencies to the most recent versions 2024-08-25 11:38:00 +02:00
Tim van der Meij
037c181af6
Merge pull request #18644 from Snuffleupagus/PDFPrintService-unconditional-toBlob
Use `HTMLCanvasElement.toBlob()` unconditionally in `PDFPrintService`
2024-08-23 20:37:46 +02:00
Tim van der Meij
f11baea3e3
Merge pull request #18643 from Snuffleupagus/l10n-translateOnce
Introduce a `L10n`-method to translate an element once, and use that in `PDFLayerViewer`
2024-08-23 20:36:01 +02:00
Tim van der Meij
f025cecace
Merge pull request #18636 from Snuffleupagus/PDFDocumentProperties-#getL10nStr
Introduce a helper method for fetching l10n-data in `PDFDocumentProperties`
2024-08-23 20:13:19 +02:00
Tim van der Meij
5f7637b9ea
Merge pull request #18635 from calixteman/avoid_print_dialog
Don't show the print dialog when printing in some integration tests
2024-08-23 20:08:04 +02:00
Jonas Jenwald
6a1b1ae6a4 Revoke the blob-URLs used during printing in PDFPrintService 2024-08-23 18:39:28 +02:00
Jonas Jenwald
502a429e3e Use HTMLCanvasElement.toBlob() unconditionally in PDFPrintService
The fallback is very old code, and according to the MDN compatibility data `HTMLCanvasElement.toBlob()` should be available in all browsers that we support now: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#browser_compatibility
2024-08-23 18:29:42 +02:00
Jonas Jenwald
584fef5823
Merge pull request #18646 from Snuffleupagus/issue-18645
Support an odd number of digits in hexadecimal strings (issue 18645)
2024-08-23 18:24:19 +02:00
Jonas Jenwald
8728f7f134 Support an odd number of digits in hexadecimal strings (issue 18645)
See https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G6.1840792
2024-08-23 16:31:43 +02:00
Jonas Jenwald
fabbe544ab Introduce a L10n-method to translate an element once, and use that in PDFLayerViewer
Currently we *manually* fetch the "pdfjs-additional-layers" string and update the DOM-element, which was needed since we want to avoid triggering a bunch of otherwise unnecessary translation when appending the entire layer-tree to the DOM.
By introducing a new helper method in the `L10n`-class we can avoid this, and instead use a "data-l10n-id" attribute on the element (as most other viewer code does nowadays).
2024-08-23 12:31:55 +02:00
Jonas Jenwald
2c34b64415 Introduce a helper method for fetching l10n-data in PDFDocumentProperties
Given the length of the l10n-strings we can slightly reduce verbosity, and thus overall code-size, by introducing a helper method for fetching l10n-data.

While testing this I stumbled upon an issue in the `L10n`-class, where an optional chaining operator was placed incorrectly since the underlying method always return an Array; see 48e2a62ed4/fluent-dom/src/localization.js (L38-L77)
2024-08-21 15:07:46 +02:00
Jonas Jenwald
908f453384
Merge pull request #18627 from richard-smith-preservica/rcs/send-page-dict-requests-in-parallel
Send fetch requests for all page dict lookups in parallel
2024-08-21 13:58:03 +02:00
Richard Smith (smir)
a67b9aec6c Send fetch requests for all page dict lookups in parallel
- When adding page dict candidates to the lookup tree, also initiate fetching them from xref, so if they are not yet loaded at all, the XHR will be sent
 - Only at the top level - assume that if there is a /Pages tree, it is sensibly structured and the number of requests won't be too bad
- We can then await on the cached Promise without making the requests pipeline
- This has a significant performance improvement for load-on-demand (i.e. with auto-fetch turned off) when a PDF has a large number of pages in the top level /Pages collection, and those pages are spread through a file, so every candidate needs to be fetched separately
 - PDFs with many pages where each page is a big image and all the pages are at the top level are quite a common output for digitisation programmes
- I would have liked to do something like "if it's the top level collection and page count = number of kids, then just fetch that page without traversing the tree" but unfortunately I agree with comments on #8088 that there is no good general solution to allow for /Pages nodes with empty /Kids arrays
2024-08-21 11:08:14 +01:00
Calixte Denizet
b0c239a200 Don't show the print dialog when printing in some integration tests 2024-08-20 22:24:08 +01:00
Tim van der Meij
e0fc1a341a
Merge pull request #18628 from Snuffleupagus/issue-18208
Use standard glyph mapping for non-embedded and non-composite Calibri fonts (issue 18208)
2024-08-19 20:26:56 +02:00
Jonas Jenwald
6dd31183be Use standard glyph mapping for non-embedded and non-composite Calibri fonts (issue 18208)
Given that we handle non-embedded Calibri fonts as "mapped to standard font", we really ought to be able to use the same glyph mapping as for an actual standard font.
Note that this actually improves consistency in the code, given how we already handle such fonts if they happen to be of the `CIDFontType2` type; see b47c7eca83/src/core/fonts.js (L1186-L1190)
2024-08-19 19:10:35 +02:00
Tim van der Meij
88ea60dcde
Merge pull request #18624 from timvandermeij/intermittent-scripting-siblings
Fix the "must check that a value is correctly updated on a field and its siblings" scripting integration test
2024-08-19 19:04:34 +02:00
Tim van der Meij
79dce534f5
Merge pull request #18623 from timvandermeij/uimanager-test
[Editor] Move setting `window.uiManager` back to the test code
2024-08-19 19:04:11 +02:00
Tim van der Meij
5cc77d3ebd
Fix the "must check that a value is correctly updated on a field and its siblings" scripting integration test
This integration test fails intermittently because we cache the initial
total value to be able to compare it to the new total value at the end
of the test to check that it's different before doing the assertions.
However, this doesn't work as expected because the second `clearInput`
call triggers an intermediate total value calculation because it clicks
on another input field and that triggers a sandbox event.

This results in the `waitForFunction` calls always resolving immediately
and since we don't use other means of waiting until the calculation is
done (using e.g. `waitForSandboxTrip`) we basically rely on the time
between the final click and the assertions to be enough for the sandbox
to do its work. If it's is not done in that time, we do the assertions
with older values and that makes the test fail.

This commit fixes the issue by simply waiting for the total value to be
what we expect it to be. This requires less code, is more consistent
with the other integration tests and removes the possibility of doing
assertions against older values.
2024-08-18 19:24:51 +02:00
Tim van der Meij
db06011032
[Editor] Move setting window.uiManager back to the test code
In PR #18574 setting `window.uiManager` was moved into the `src` folder
to avoid intermittent integration test failures because at the time we
lacked a way to register event listeners early (before PDF.js loads).
However, in PR #18617 this functionality got introduced, so we can now
use the new way of setting up the event bus in the tests to move this
back to the `test` folder again and to reduce the amount of test-only
code in the main codebase as discussed in PR #18574.

Partially reverts e037c5711d.
2024-08-18 15:45:42 +02:00
Tim van der Meij
b47c7eca83
Merge pull request #18617 from calixteman/early_event_handler
Set the event handlers in the integration tests before any event is triggered
2024-08-18 15:10:23 +02:00
Calixte Denizet
5e4948062c Set the event handlers in the integration tests before any event is triggered
The function evaluateOnNewDocument in Puppeteer allow us to execute some js before the pdf.js one
is loaded.
It allows us to stub some setters before there are used and then set some event handlers very soon.
2024-08-18 09:57:43 +01:00
Tim van der Meij
f7d3add994
Merge pull request #18615 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-08-16 19:02:39 +02:00
Tim van der Meij
0aada51568
Update translations to the most recent versions 2024-08-15 19:52:03 +02:00
Tim van der Meij
f6c2860195
Fix the repository URLs in the importl10n script
We introduced quite a few new strings recently, but during the last few
rounds of updates we didn't see new translations updates becoming
available. I only just now recalled the announcement that Mozilla is
moving from Mercurial to Git, and indeed the Mercurial page at
https://hg.mozilla.org/l10n-central hasn't been updated since July
anymore and that's were we used to pull our translations from.

This commit fixes the issue by changing the URLs to the Mozilla Git
repositories hosted on GitHub instead.
2024-08-15 19:51:48 +02:00
Tim van der Meij
44f7e3c002
Fix vulnerability in the axios dependency
This patch is generated automatically using `npm audit fix` and fixes
CVE-2024-39338 (see https://github.com/advisories/GHSA-8hc4-vh64-cxmj),
bringing the vulnerability count back to zero.
2024-08-15 19:37:05 +02:00
Tim van der Meij
140dd3c99f
Update dependencies to the most recent versions 2024-08-15 19:34:02 +02:00
Tim van der Meij
d8d9cff715
Merge pull request #18612 from Snuffleupagus/_parseHashParams-shorten
Shorten the `PDFViewerApplication._parseHashParams` method
2024-08-15 18:39:35 +02:00
Tim van der Meij
73bae55c5d
Merge pull request #18613 from calixteman/enable_tests
Enable disabled integration tests for Firefox
2024-08-15 18:35:10 +02:00
Calixte Denizet
75e52360ad Enable disabled integration tests for Firefox 2024-08-15 13:11:31 +01:00
Jonas Jenwald
ee7441d5bc Shorten the PDFViewerApplication._parseHashParams method
The way that the debugging hash-parameter parsing is implemented leads to a lot of boilerplate code in this method, since *most* of the cases are very similar.[1]
With just a few exceptions most of the options can be handled automatically, by defining an appropriate checker for each option.

---

[1] With the recent introduction of TESTING-only options the size of this method increased a fair bit.
2024-08-15 13:50:35 +02:00
calixteman
b60261e39a
Merge pull request #18611 from calixteman/fix_telemetry
Fix the telemetry for the new alt-text flow
2024-08-15 12:46:55 +01:00
Jonas Jenwald
17f387b460
Merge pull request #18610 from Snuffleupagus/bug-report-version-description
Link to official releases and the demo viewer in the bug report template
2024-08-15 13:31:05 +02:00
Calixte Denizet
9bd00859d3 Fix the telemetry for the new alt-text flow 2024-08-15 11:29:00 +01:00
Jonas Jenwald
4caa309fda Link to official releases and the demo viewer in the bug report template
Hopefully this might lead to *more* users actually testing the latest version before reporting a bug.
2024-08-15 09:25:21 +02:00
Tim van der Meij
8446d3ac03
Merge pull request #18605 from Snuffleupagus/issue-18196
Handle the "switchannotationeditorparams" event in the editor-code (issue 18196)
2024-08-13 19:42:20 +02:00
Jonas Jenwald
9e0c6ef476 Handle the "switchannotationeditorparams" event in the editor-code (issue 18196)
The problem seems to be caused by the browser trying to "restore" editing input-elements, in the various toolbars, to their previous values when the tab is re-opened.

Hence the simplest solution appears to be to move the event handling into the editor-code, which is also less code overall, since the listener thus won't be registered early enough for the problem to appear.
2024-08-13 15:29:55 +02:00