Commit Graph

15444 Commits

Author SHA1 Message Date
Tim van der Meij
90c5e9882b
Merge pull request #14669 from Snuffleupagus/padding-inline
Replace `dir`-dependent `padding-left`/`padding-right`/`text-align` with logical properties
2022-03-13 20:51:07 +01:00
Tim van der Meij
dd4af1c60d
Merge pull request #14665 from Snuffleupagus/Preferences-private
Convert the `BasePreferences` class to use private fields
2022-03-13 20:45:29 +01:00
Tim van der Meij
48f49ff9f4
Merge pull request #14668 from Snuffleupagus/rm-addLinkAttributes-warn
Remove the `addLinkAttributes` warnings in the Annotation/XFA-layers (PR 14092 follow-up)
2022-03-13 20:40:22 +01:00
Tim van der Meij
f410403c4b
Merge pull request #14667 from Snuffleupagus/fieldObjects-test-Node
Enable the "gets fieldObjects" unit-test in Node.js (PR 14409 follow-up)
2022-03-13 20:39:01 +01:00
Jonas Jenwald
331f4e72de Replace dir-dependent padding-left/padding-right/text-align with logical properties
*Please note:* This is small first step in what will, time permitting, become a series of patches to simplify/modernize the viewer CSS.

Rather than having to *manually* specify ltr/rtl-specific padding-values in the CSS, we can use logical padding instead (and similar for text-align).
These logical properties depend on, among other things, the direction of the HTML document which we *always* specify in the viewer.

Note that a number of logical CSS properties are new enough that we'll need to use PostCSS plugins, however the ones in this patch are natively supported in all browsers that we currently support:
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/text-align#browser_compatibility
2022-03-13 14:36:11 +01:00
Jonas Jenwald
0c349c701f Remove the addLinkAttributes warnings in the Annotation/XFA-layers (PR 14092 follow-up)
These warnings have now been present in three releases, see PR 14092, hence it should (hopefully) be fine to remove them now.
2022-03-13 11:38:56 +01:00
Jonas Jenwald
fb345ee184 Enable the "gets fieldObjects" unit-test in Node.js (PR 14409 follow-up)
Apparently this unit-test works in Node.js now, hence it's *possible* that the reason it didn't work previously is that there were bugs in our old `structuredClone` polyfill.
2022-03-13 10:40:57 +01:00
Jonas Jenwald
3274972768 Revert Preferences to their previous values, when writing to storage failed
This patch fixes an old inconsistency, when using `BasePreferences.{reset, set}`, where the internal Preference values would be kept even if writing them to storage failed.
2022-03-12 17:25:45 +01:00
Jonas Jenwald
25d7420035 Convert the BasePreferences class to use private fields
Given that none of these fields were ever intended to be accessed directly from the *outside*, since that will lead to inconsistent/broken state, we can use modern ECMAScript features to ensure that they are indeed private.
2022-03-12 14:34:57 +01:00
Tim van der Meij
9e4aaf18f7
Merge pull request #14661 from tiziodcaio/gh_actions
Update Checkout to version 3
2022-03-11 21:11:18 +01:00
Tim van der Meij
790735eaf1
Merge pull request #14658 from Snuffleupagus/api-validate-cMapUrl-standardFontDataUrl
Validate the `cMapUrl`/`standardFontDataUrl` parameters in `getDocument`
2022-03-11 21:09:58 +01:00
Tim van der Meij
bcf453cf14
Merge pull request #14656 from Snuffleupagus/mv-isSameOrigin
Move the `isSameOrigin` helper function
2022-03-11 21:08:49 +01:00
Tim van der Meij
0d265a30ed
Merge pull request #14654 from Snuffleupagus/TestReporter-send-fetch
Replace XMLHttpRequest usage with the Fetch API in `send` (in `test/unit/testreporter.js`)
2022-03-11 21:05:36 +01:00
Jonas Jenwald
4318bc8f86
Merge pull request #14554 from Snuffleupagus/issue-14526
Try to improve a11y for the "button groups" in the SecondaryToolbar/Sidebar (issue 14526)
2022-03-11 20:46:47 +01:00
tiziodcaio
1a380b5736
Update Checkout to version 3
Uses node 16 as default
2022-03-11 14:35:06 +01:00
Jonas Jenwald
1b6e1eac92
Merge pull request #14620 from Snuffleupagus/Firefox-getStrings
Bug 1757527 - Slightly reduce (repeated) message passing overhead when localizing the PDF Viewer
2022-03-11 11:36:51 +01:00
Jonas Jenwald
a60b98412f Validate the cMapUrl/standardFontDataUrl parameters in getDocument
These changes make sense for two reasons:
 - Given that the parameters are potentially passed to the worker-thread, depending on the `useWorkerFetch` parameter, we need to prevent errors if the user provides values that aren't clonable.
 - By ensuring that the default values are indeed `null`, we'll trigger main-thread fetching (of CMaps and Standard fonts) as intended in the `PartialEvaluator` and thus potentially provide better Error messages.
2022-03-10 16:33:10 +01:00
Jonas Jenwald
537ed37835 Move the isSameOrigin helper function
This function is currently placed in the `src/shared/util.js` file, which means that the code is duplicated in both of the *built* `pdf.js` and `pdf.worker.js` files. Furthermore, it only has a single call-site which is also specific to the `GENERIC`-build of the PDF.js library.

Hence this helper function is instead moved into the `src/display/api.js` file, in such a way that it's conditionally defined but still can be unit-tested.
2022-03-10 13:51:09 +01:00
Jonas Jenwald
e08e3f4d37 Replace XMLHttpRequest usage with the Fetch API in send (in test/unit/testreporter.js)
Besides converting the `send` function to use the Fetch API, this patch also changes the method to return a `Promise` to get rid of the callback function. (Although, currently there's no call-site passing in a callback function.)
2022-03-10 12:55:08 +01:00
Jonas Jenwald
48c64c6c8d Bug 1757527 - Slightly reduce (repeated) message passing overhead when localizing the PDF Viewer 2022-03-10 10:20:34 +01:00
Tim van der Meij
ee39499a5a
Merge pull request #14651 from Snuffleupagus/Driver-inlineImages-fetch
Replace XMLHttpRequest usage with the Fetch API in `inlineImages` (in `test/driver.js`)
2022-03-09 20:47:38 +01:00
Tim van der Meij
fee1bc68e9
Merge pull request #14642 from Snuffleupagus/Driver-send-fetch
Replace XMLHttpRequest usage with the Fetch API in `Driver._send`
2022-03-09 20:43:12 +01:00
Tim van der Meij
e85bb0b599
Merge pull request #14645 from Snuffleupagus/Node-DOMMatrix-polyfill
[api-minor] Remove the, in `legacy` builds, bundled `DOMMatrix` polyfill
2022-03-09 20:38:26 +01:00
Tim van der Meij
55a931e454
Merge pull request #14648 from Snuffleupagus/PDFDocument-stream
Simplify the `PDFDocument` constructor
2022-03-09 20:36:49 +01:00
Tim van der Meij
23d1abee0b
Merge pull request #14640 from Snuffleupagus/update-TypeScript
Update TypeScript to version `4.6.2` and work-around stricter type checks
2022-03-09 20:35:24 +01:00
Jonas Jenwald
b3f4758183 Replace XMLHttpRequest usage with the Fetch API in inlineImages (in test/driver.js)
This is the final part in a series of patches that try to re-implement PR 14287 in smaller steps.

Besides converting `inlineImages` to use the Fetch API, this patch also combines the `inlineImages` and `resolveImages` functions since they are always used together.
2022-03-09 11:32:51 +01:00
Jonas Jenwald
6a78f20b17 Simplify the PDFDocument constructor
Originally the code in the `src/`-folder was shared between the main/worker-threads, and back then it probably made sense that the `PDFDocument` constructor accepted different arguments.
However, for many years we've not been passing anything *except* Streams to `PDFDocument` and we should thus be able to slightly simplify that code. Note that for e.g. unit-tests of this code, using either a `NullStream` or a `StringStream` works just fine.
2022-03-08 17:13:47 +01:00
Jonas Jenwald
157a71d404 [api-minor] Remove the, in legacy builds, bundled DOMMatrix polyfill
According to the MDN compatibility data, see https://developer.mozilla.org/en-US/docs/Web/API/DOMMatrix/DOMMatrix#browser_compatibility, all browsers that we support have native `DOMMatrix` implementations (since quite some time too).

Hence Node.js is the only environment that lack `DOMMatrix` support, which probably isn't that surprising given that it's browser functionality.
While the `DOMMatrix` polyfill isn't that large, it nonetheless seems completely unnecessary to bundle it in the `legacy` builds when it's not needed in browsers. However, we can avoid that by simply listing `dommatrix` as a dependency for the `pdfjs-dist` library.
2022-03-08 10:29:11 +01:00
Jonas Jenwald
19c2cc8689 Replace XMLHttpRequest usage with the Fetch API in Driver._send
This is another part in a series of patches that try to re-implement PR 14287 in smaller steps.

Besides converting `Driver._send` to use the Fetch API, this also changes the method to return a `Promise` to get rid of the callback function.
Please note that I *purposely* try to maintain the existing behaviour of re-sending the data on failure/unexpected response, including how/where the old callback function was invoked.
2022-03-07 16:00:52 +01:00
Jonas Jenwald
6f600befdd Update TypeScript to version 4.6.2 and work-around stricter type checks
I'm guessing that we're now running into the class-related improvements mentioned in https://devblogs.microsoft.com/typescript/announcing-typescript-4-6/#target-es2022
To unblock this update, and any future ones, this patch simply tweaks the JSDocs to get `gulp typestest` to run without errors.
2022-03-07 11:55:17 +01:00
Tim van der Meij
3e593cfc1d
Merge pull request #14636 from Snuffleupagus/Driver-quit-fetch
Replace XMLHttpRequest usage with the Fetch API in `Driver._quit`
2022-03-06 18:26:55 +01:00
Jonas Jenwald
d65169d754 Try to improve a11y for the "button groups" in the SecondaryToolbar/Sidebar (issue 14526)
*Please note:* I don't really know anything about a11y, hence it's possible that this patch either doesn't work correctly or at least isn't a complete solution.

In both the SecondaryToolbar and the Sidebar we have "button groups" that functionally acts essentially like radio-buttons. Based on skimming through [this MDN article](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/radio_role) it thus appears that we should tag them as such, using `role="radiogroup"` and `role="radio"`, and then utilize the `aria-checked` attribute to indicate to a11y software which button is currently active.
2022-03-06 16:54:27 +01:00
Jonas Jenwald
c1f73b140f
Merge pull request #14637 from timvandermeij/web-private
Use proper private methods in `web/{pdf_cursor_tools,pdf_find_bar,secondary_toolbar}.js`
2022-03-06 16:47:33 +01:00
Tim van der Meij
a00308d5f3
Merge pull request #14638 from Snuffleupagus/reftest-analyzer-fetch
Replace XMLHttpRequest usage with the Fetch API in the reftest-analyzer
2022-03-06 16:37:31 +01:00
Tim van der Meij
6500aafd00
Use proper private methods in web/secondary_toolbar.js 2022-03-06 16:07:25 +01:00
Tim van der Meij
f33769db2d
Use proper private methods in web/pdf_find_bar.js 2022-03-06 16:07:07 +01:00
Tim van der Meij
a1d106dc5d
Use proper private methods in web/pdf_cursor_tools.js 2022-03-06 16:06:53 +01:00
Jonas Jenwald
90445679e8 Replace XMLHttpRequest usage with the Fetch API in the reftest-analyzer 2022-03-06 16:02:34 +01:00
Jonas Jenwald
65d5974192 Replace XMLHttpRequest usage with the Fetch API in Driver._quit
This is another step in what'll hopefully become a series of patches to implement PR 14287 in smaller steps.
2022-03-06 15:36:48 +01:00
Tim van der Meij
3ac2053d97
Merge pull request #14635 from Snuffleupagus/loadStyles-fetch
Replace XMLHttpRequest usage with the Fetch API in `loadStyles` (in `test/driver.js`)
2022-03-06 15:24:40 +01:00
Jonas Jenwald
62e0939ce2 Replace XMLHttpRequest usage with the Fetch API in loadStyles (in test/driver.js)
This is another small step in what'll hopefully become a series of patches to implement PR 14287 in smaller steps.
2022-03-06 13:57:42 +01:00
Tim van der Meij
f8f0f19642
Merge pull request #14633 from Snuffleupagus/update-packages
Update packages and translations
2022-03-06 13:34:17 +01:00
Tim van der Meij
7d53a40c91
Merge pull request #14634 from Snuffleupagus/Driver-run-fetch
Replace XMLHttpRequest usage with the Fetch API in `Driver.run`
2022-03-06 13:32:17 +01:00
Jonas Jenwald
151b140eac Replace XMLHttpRequest usage with the Fetch API in Driver.run
This is a first step in what'll hopefully become a series of patches to implement PR 14287 in smaller steps.
2022-03-06 12:47:12 +01:00
Jonas Jenwald
114d5e68af Update l10n files 2022-03-06 10:45:24 +01:00
Jonas Jenwald
b875f13b4f Update npm packages 2022-03-06 10:45:23 +01:00
Tim van der Meij
5242c38af5
Merge pull request #14628 from Snuffleupagus/issue-14626
When `stopAtErrors` is set, throw rather than warn when exceeding `maxImageSize` (issue 14626)
2022-03-05 13:09:36 +01:00
Tim van der Meij
5d12ac576b
Merge pull request #14631 from Snuffleupagus/typedef-fixes
Fix a couple of small typos in JSDoc `typedef` comments
2022-03-05 13:06:53 +01:00
Brendan Dahl
3b6d6893d9
Merge pull request #14629 from Snuffleupagus/issue-14618
Compute the loca table `endOffset`, of the "first" glyph, correctly (issue 14618)
2022-03-04 16:43:17 -08:00
Jonas Jenwald
939e6f0c4c Fix a couple of small typos in JSDoc typedef comments
While this doesn't affect the official API documentation, these cases should nonetheless be fixed.
2022-03-04 12:11:52 +01:00