Commit Graph

17365 Commits

Author SHA1 Message Date
Jonas Jenwald
8c4821ceda [api-minor] Slightly shorten the marked-content ids used in the textLayer
Generally we try to keep the ids that we create short, hence we can slightly shorten the "static" parts of them.
2023-05-18 22:32:10 +02:00
Jonas Jenwald
04de155aaa Slightly shorten the loadedName-ids used with font-substitutions
Generally we try to keep the ids that we create short, hence we can slightly shorten the "static" part of them.
2023-05-18 22:27:11 +02:00
Jonas Jenwald
3be66f59d6
Merge pull request #16440 from Snuffleupagus/more-modern-JS
Introduce even more modern JavaScript features in the code-base
2023-05-18 20:56:00 +02:00
calixteman
e8537e4d30
Merge pull request #16439 from calixteman/issue14755
Flush the current chunk when the font changed because of a restore op (issue #14755)
2023-05-18 20:10:31 +02:00
Calixte Denizet
3091e70aad Flush the current chunk when the font changed because of a restore op (issue #14755) 2023-05-18 19:37:16 +02:00
Jonas Jenwald
e8030752f3 Introduce even more modern JavaScript features in the code-base
After PR 12563 we're now free to use e.g. logical OR assignment, nullish coalescing, and optional chaining in the entire code-base.
2023-05-18 18:55:41 +02:00
calixteman
a24d5b629e
Merge pull request #16438 from mozilla/loc_note_openinapp
Add a localization note to explain that 'Open in app' strings are for mobile (bug 1833858)
2023-05-18 17:27:39 +02:00
Marco Castelluccio
77f8fd91ec Add a localization note to explain that 'Open in app' strings are for mobile (bug 1833858) 2023-05-18 16:43:12 +02:00
Jonas Jenwald
356f3cf285
Merge pull request #16437 from Snuffleupagus/loadFont-simpler-fontID
Simplify the `fontID` handling in `PartialEvaluator.loadFont`
2023-05-18 13:36:00 +02:00
Jonas Jenwald
4355e76c60 Simplify the fontID handling in PartialEvaluator.loadFont
The `fontID` handling is quite old and predates the use of the `idFactory` to generate a unique id for each font, hence we can simplify this code a little bit.
2023-05-18 13:09:08 +02:00
Tim van der Meij
ac8032628b
Merge pull request #16424 from Snuffleupagus/core-optional-chaining
Introduce more optional chaining in the `src/core/` folder
2023-05-18 12:40:08 +02:00
calixteman
839be801a0
Merge pull request #16433 from calixteman/bug1825002
For text widgets, get the text from the AP stream instead of from the format callback (bug 1825002)
2023-05-17 16:48:59 +02:00
Calixte Denizet
177036e6ae For text widgets, get the text from the AP stream instead of from the format callback (bug 1825002)
When fixing bug 1766987, I thought the field formatted value came from
the result of the format callback: I was wrong. The format callback is ran
but the value is unused (maybe it's useful to set some global vars... or
it's just a bug in Acrobat). Anyway the value to display is the one rendered
in the AP stream.
The field value setter has been simplified and that fixes issue #16409.
2023-05-17 14:07:28 +02:00
Jonas Jenwald
46bbabbd5d
Merge pull request #16434 from Snuffleupagus/issue-16432
Attempt to fallback to a default font, for non-available ones, in more cases (issue 16432)
2023-05-17 12:30:08 +02:00
Jonas Jenwald
bfb374dbf6 Attempt to fallback to a default font, for non-available ones, in more cases (issue 16432)
This essentially extends PR 11218 to also apply when looking up the final font-reference, via the XRef-table, fails because the font isn't available.

This patch also changes `PartialEvaluator.fallbackFontDict` to simply use "Helvetica" as the default font-name, since that seems generally reasonable given the now existing font-substitution code.
2023-05-17 11:41:08 +02:00
calixteman
5ae353cf4d
Merge pull request #16431 from calixteman/warn_missing_os_font
Warn when pdf.js can't load an OS font
2023-05-16 15:25:16 +02:00
Calixte Denizet
385f275ad9 Warn when pdf.js can't load an OS font 2023-05-16 14:58:38 +02:00
Jonas Jenwald
95ab2b8b17
Merge pull request #16430 from Snuffleupagus/npm-lockfile-version-3
Update `package-lock.json` to lockfileVersion=3
2023-05-16 10:14:00 +02:00
Jonas Jenwald
cc46d303e9 Update package-lock.json to lockfileVersion=3
This reduces the size of the `package-lock.json` file a lot, and given that we recently updated the minimum supported Node.js version to 18 this shouldn't be a problem; please also see
 - https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json#lockfileversion
 - https://docs.npmjs.com/cli/v9/using-npm/config?v=true#lockfile-version
2023-05-16 09:50:57 +02:00
calixteman
2c0478ecb2
Merge pull request #16426 from calixteman/generate_fallback_one_time
For non-embedded fonts, don't generate the fallback several times
2023-05-15 21:25:29 +02:00
Calixte Denizet
4e8dd54e8e For non-embedded fonts, don't generate the fallback several times 2023-05-15 20:02:45 +02:00
calixteman
107874fcd4
Merge pull request #16420 from calixteman/simplify_subst
Simplify the code to generate font substitution information
2023-05-15 19:58:53 +02:00
Calixte Denizet
b264e0301a Simplify the code to generate font substitution information 2023-05-15 19:17:52 +02:00
calixteman
5f91d39f13
Merge pull request #16425 from calixteman/gv_nimbus
[GeckoView] Add a Nimbus experiment for the toolbar (bug 1833093)
2023-05-15 18:26:28 +02:00
Calixte Denizet
4ed512ab2c [GeckoView] Add a Nimbus experiment for the toolbar (bug 1833093) 2023-05-15 17:18:14 +02:00
Jonas Jenwald
1b4a7c5965 Introduce more optional chaining in the src/core/ folder
After PR 12563 we're now free to use optional chaining in the worker-thread as well. (This patch also fixes one previously "missed" case in the `web/` folder.)

For the MOZCENTRAL build-target this patch reduces the total bundle-size by `1.6` kilobytes.
2023-05-15 12:38:28 +02:00
Jonas Jenwald
c20c1b3362
Merge pull request #16422 from Snuffleupagus/getFontSubstitution-css-tests
Check the `css` property in the `getFontSubstitution` unit-tests
2023-05-15 10:09:17 +02:00
Jonas Jenwald
cb1a10e358 Check the css property in the getFontSubstitution unit-tests
Given that the `css` property isn't constant, since it contains document/font ids, we cannot just check it directly. However, we can make use of regular expressions to ensure that the format is generally correct.
2023-05-14 19:11:35 +02:00
calixteman
4101128c09
Merge pull request #16421 from calixteman/font_subst_test
Add tests for the font substitution
2023-05-14 18:23:12 +02:00
Calixte Denizet
89140fcd98 Add tests for the font substitution 2023-05-14 18:07:03 +02:00
Jonas Jenwald
9cbc2c389f
Merge pull request #16418 from Snuffleupagus/jasmine-5
Update `jasmine` to version 5
2023-05-14 14:03:46 +02:00
Jonas Jenwald
95ac708fbd Update jasmine to version 5
Despite this being a *major* version increase, it doesn't appear to require any updates in our test-suites.
Note in particular that the minimum supported browsers/environments were updated, however this isn't a problem given our recent support-changes in the PDF.js library.

Please find additional details at https://github.com/jasmine/jasmine/blob/main/release_notes/5.0.0.md
2023-05-14 13:04:08 +02:00
Tim van der Meij
693092c980
Merge pull request #16415 from Snuffleupagus/no-useless-promise-resolve-reject
Enable the `unicorn/no-useless-promise-resolve-reject` ESLint plugin rule
2023-05-14 12:41:11 +02:00
Tim van der Meij
521bea4f8f
Merge pull request #16417 from Snuffleupagus/update-packages
Update packages and translations
2023-05-14 12:40:22 +02:00
calixteman
202496a7ca
Merge pull request #16416 from calixteman/use_local_font_2
For missing font, use a local font if it exists even if there's no standard substitution
2023-05-14 12:27:55 +02:00
Jonas Jenwald
62f47588b4 Update l10n files 2023-05-14 10:15:01 +02:00
Jonas Jenwald
d25994e85d Update npm packages 2023-05-14 10:12:06 +02:00
Calixte Denizet
d4b70ec306 For missing font, use a local font if it exists even if there's no standard substitution
If the font foo is missing we just try lo load local(foo) and maybe
we'll be lucky.
2023-05-13 21:54:27 +02:00
Jonas Jenwald
8fbd6755eb Enable the unicorn/no-useless-promise-resolve-reject ESLint plugin rule
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-promise-resolve-reject.md

Note that this patch also re-sorts the existing `unicorn`-rules in proper alphabetical order.
2023-05-13 11:30:25 +02:00
Tim van der Meij
e738e15aa3
Merge pull request #16413 from Snuffleupagus/PDFSidebar-inline-resizing
Move the sidebar-resizing handling into the `PDFSidebar` class
2023-05-12 10:15:35 +02:00
Tim van der Meij
a5336d9d79
Merge pull request #16401 from Snuffleupagus/Safari-15.4
[api-minor] Update the minimum supported Safari version to 15.4
2023-05-12 10:11:53 +02:00
Jonas Jenwald
8f3940fbf3 Move the sidebar-resizing handling into the PDFSidebar class
Originally the `PDFSidebarResizer` class was slightly larger, since the code used to contain e.g. feature testing for older (and no longer supported) browsers.
Given that there's some amount of overlap, when it comes to what DOM-elements and state that these classes need, it now seems reasonable to simply move the sidebar-resizing into the `PDFSidebar` class.

For the MOZCENTRAL build-target this patch reduces the size of the *built* `web/viewer.js` file by just over `1.1` kilobytes.
2023-05-12 10:00:12 +02:00
Jonas Jenwald
9417a37c71
Merge pull request #16410 from Snuffleupagus/toggleExpandedBtn
Reduce some duplication when toggling "expanded" buttons in the viewer toolbars
2023-05-11 13:10:39 +02:00
Jonas Jenwald
0305b04e26 Add the "aria-controls" attribute to the editor-toolbar buttons
Similar to other toolbar/secondaryToolbar buttons that open toolbars or dialogs, it seems reasonable to use "aria-controls" for the editor-toolbar buttons as well.
2023-05-11 12:04:16 +02:00
Jonas Jenwald
362be760e3 Reduce some duplication when toggling "expanded" buttons in the viewer toolbars
This is very similar to PR 16281, but for buttons that use the "aria-expanded" attribute.
2023-05-11 12:04:14 +02:00
calixteman
d520754bcf
Merge pull request #16408 from calixteman/local_font_cache
Add a cache to avoid to load several times a local font
2023-05-10 20:41:51 +02:00
Calixte Denizet
cfb908c999 Add a cache to avoid to load several times a local font
On my computer, it takes few tenths of a second to load a local font.
Since a font can be used several times in a document, the cache will
improve performances.
2023-05-10 20:01:21 +02:00
calixteman
2d2f7b315e
Merge pull request #16363 from calixteman/use_local_font
[api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039)
2023-05-10 14:19:05 +02:00
Calixte Denizet
53134c0c0b [api-minor] Use a local font or fallback on an embedded one (if it exists) for non-embedded fonts (bug 1766039)
- Replace FoxitSans with LiberationSans: LiberationSans is already there (for XFA) and we can use
it as a good replacement of FoxitSans.
- For now we just try to substitue standard fonts, the strategy is the following:
  * we try to find a font locally from a hardcoded list;
  * if it fails then we use Liberation as fallback (only for Helvetica for the moment);
  * else we just fallback on the system serif/sansserif/monospace font.
2023-05-10 14:10:23 +02:00
calixteman
1a2e787e47
Merge pull request #16392 from calixteman/compress
Compress the data when saving annotions
2023-05-09 17:26:46 +02:00