Commit Graph

15703 Commits

Author SHA1 Message Date
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
Jonas Jenwald
1a7921dbf0 Compute the loca table endOffset, of the "first" glyph, correctly (issue 14618)
When there are *multiple* empty glyphs at the start of the data, ensure that the "first" glyph gets a correct `endOffset` to avoid skipping it during parsing in the `sanitizeGlyph` function.
2022-03-03 14:22:45 +01:00
Jonas Jenwald
d0d5c596fb When stopAtErrors is set, throw rather than warn when exceeding maxImageSize (issue 14626)
The situation described in issue 14626 seems like a fairly special case, and it thus seem reasonable that we simply follow the same pattern as elsewhere in the `PartialEvaluator` when the `stopAtErrors` API-option is being used.
2022-03-03 13:11:29 +01:00
Tim van der Meij
234aa9a50e
Merge pull request #14624 from Snuffleupagus/viewer-fallback-cleanup
Simplify the `fallback`-logic in the default viewer
2022-03-02 20:54:03 +01:00
Tim van der Meij
038c832719
Merge pull request #14623 from Snuffleupagus/viewer-deprecated-cleanup
Remove some deprecated code from the viewer
2022-03-02 20:46:27 +01:00
Tim van der Meij
636fc05843
Merge pull request #14617 from Snuffleupagus/rm-webkit-outer-spin-button
Remove the `-webkit-outer-spin-button` CSS rule
2022-03-02 20:40:37 +01:00
Tim van der Meij
b18cbaac39
Merge pull request #14615 from Snuffleupagus/rm-webkit-overflow-scrolling
Remove the `-webkit-overflow-scrolling: touch;` CSS rules (PR 4516 follow-up)
2022-03-02 20:39:21 +01:00
Brendan Dahl
85ff7b117e
Merge pull request #14536 from calixteman/thin_line
Fix some issues with lineWidth < 1 after transform (bug 1753075, bug 1743245, bug 1710019)
2022-03-02 09:46:15 -08:00
Jonas Jenwald
6d2863f80a Simplify the fallback-logic in the default viewer
After [bug 1705327](https://bugzilla.mozilla.org/show_bug.cgi?id=1705327) the `ChromeActions.fallback`-method is now just a stub[1], since the fallback bar was removed.
Hence there's no good reason, as far as I can tell, to keep this code in the viewer itself when it's completely unused.

---
[1] See https://searchfox.org/mozilla-central/rev/292d17c13daa61016fd082e2337297091d53a015/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#575-581
2022-03-02 13:30:45 +01:00
Jonas Jenwald
38d30f3be5 Remove the deprecated PDFFindController.executeCommand method
This *partially* reverts commit fa8c0ef616, since it's now been included in two official releases.
2022-03-02 11:23:14 +01:00
Jonas Jenwald
f2c9a6bc24 Revert "[GENERIC viewer] Add fallback logic for the old PDFPageView.update method signature"
This reverts commit 8466204384, since it's now been included in three official releases.
2022-03-02 11:15:18 +01:00
Jonas Jenwald
fdd06fa393 Remove the -webkit-outer-spin-button CSS rule
Unfortunately simply using `appearance: textfield;`, or even `-webkit-appearance: textfield;`, doesn't actually hide the "spinner" in number-input elements in e.g. Google Chrome.
Hence we need to use a work-around with the `-webkit-inner-spin-button` rule, however in our CSS code we also have `-webkit-outer-spin-button` currently. According to both [the MDN compatibility data](https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-outer-spin-button#browser_compatibility) and also manual testing in Google Chrome Beta 99, the `-webkit-outer-spin-button` rule is no longer necessary and we can thus clean-up the CSS a tiny bit.
2022-02-28 12:16:32 +01:00
Jonas Jenwald
047a971093 Remove the -webkit-overflow-scrolling: touch; CSS rules (PR 4516 follow-up)
This was added in PR 4516 specifically for Safari on iOS devices, but according to MDN it should no longer be necessary now; see https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-overflow-scrolling#browser_compatibility

According to the MDN compatibility data, this CSS feature:
 - Was never implemented anywhere *except* for Safari on iOS.
 - Was never standardized and thus never existed in an *unprefixed* version.
 - Has now been removed, starting with Safari version 13.

Given that [the FAQ](https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support) already lists Safari as "Mostly" supported, and that the default viewer is written primarily for Mozilla Firefox, it ought to be fine to remove these CSS rules now.
2022-02-27 22:09:19 +01:00
Tim van der Meij
2cc98dcdaa
Merge pull request #14614 from timvandermeij/bump
Bump versions in `pdfjs.config`
2022-02-27 19:29:51 +01:00
Tim van der Meij
dc7368ff5c
Bump versions in pdfjs.config 2022-02-27 19:24:24 +01:00
Tim van der Meij
399a0ec603
Merge pull request #14612 from Snuffleupagus/caniuse-lite
Add the `caniuse-lite` package
2022-02-27 15:29:09 +01:00
Tim van der Meij
a0c9c1e0cc
Merge pull request #14611 from Snuffleupagus/rm-Promise-docs
Remove the JSDocs "External: Promise"-page, since `Promise`s are now a standard feature
2022-02-27 15:27:38 +01:00
Jonas Jenwald
896255e7bf Add the caniuse-lite package
Since the Autoprefixer plugin indirectly depends on this, it seems like a good idea to add this as a direct dependency in the PDF.js project to hopefully avoid having to manually update `caniuse-lite` in the future; see https://github.com/browserslist/browserslist#browsers-data-updating

Also, slightly tweaks the Autoprefixer config for GENERIC-builds of the PDF.js library; note that this change doesn't affect the contents of the *built* `web/viewer.js` file.
2022-02-27 11:39:33 +01:00
Jonas Jenwald
ab55071568 Remove the JSDocs "External: Promise"-page, since Promises are now a standard feature
The "External: Promise"-page in the JSDocs pre-dates the introduction of `Promise`s, as a generally available standard JS feature, by a number of years. Hence it now longer seems necessary, as far as I can tell, to include this "special" page in the documentation.

Also, while unrelated to the rest of the patch, updates the `test/`-folder description in the documentation.
2022-02-26 23:53:11 +01:00
calixteman
046ff07ee3
Merge pull request #14610 from Snuffleupagus/jpx-resetContextProbabilities
[JPEG 2000] Add support for resetContextProbabilities (bug 1731483)
2022-02-26 18:26:39 +01:00
Jonas Jenwald
46840c5650
Merge pull request #14602 from Snuffleupagus/rm-isString
Re-factor the `PDFDocument.documentInfo` method, and remove the `isString` helper function
2022-02-26 17:28:08 +01:00
Jonas Jenwald
99cd24ce3e Remove the isString helper function
The call-sites are replaced by direct `typeof`-checks instead, which removes unnecessary function calls. Note that in the `src/`-folder we already had more `typeof`-cases than `isString`-calls.
2022-02-26 16:33:41 +01:00
Jonas Jenwald
6bd4e0f5af Re-factor the PDFDocument.documentInfo method
This removes the `DocumentInfoValidators` structure, and thus (slightly) simplifies the code overall. With these changes we only have to iterate through, and validate, the actually available Dictionary entries.
2022-02-26 16:33:21 +01:00
Tim van der Meij
620174a23c
Merge pull request #14606 from Snuffleupagus/standard-FullscreenAPI
Only support the standard, unprefixed, Fullscreen API in the default viewer
2022-02-26 15:49:15 +01:00
Tim van der Meij
f782f5e5bb
Merge pull request #14607 from Snuffleupagus/wrapReason-unreachable
Simplify the `wrapReason` helper function
2022-02-26 15:37:29 +01:00
Tim van der Meij
cf7ce0aa7e
Merge pull request #14600 from Snuffleupagus/getPageIndex-more-validation
[api-minor] Add validation for the  `PDFDocumentProxy.getPageIndex` method
2022-02-26 15:30:00 +01:00
Tim van der Meij
0808376a72
Merge pull request #14599 from Snuffleupagus/Cmd-Name-validate-arg
Ensure that `Cmd`/`Name` is only initialized with string arguments
2022-02-26 15:25:00 +01:00
Jeff Muizelaar
9b9609a6d8 [JPEG 2000] Add support for resetContextProbabilities (bug 1731483) 2022-02-26 13:05:23 +01:00
Jonas Jenwald
4157d771c0
Merge pull request #14609 from brendandahl/misc-reftest
Improvements to the reftest analyzer.
2022-02-26 10:43:36 +01:00
Jonas Jenwald
e7787ee838
Merge pull request #14608 from brendandahl/no-close
Don't close window from test driver.
2022-02-26 10:42:45 +01:00
Brendan Dahl
c5404bee0e Improvements to the reftest analyzer.
- Scroll the selected reference into view (makes it easier to tell which pdf you're looking at)
- Show the keyboard shortcuts (easier for new people)
- Keep the test/ref controls visible (if you scroll you can now tell if you're looking at a test or ref)
2022-02-25 13:23:19 -08:00
Brendan Dahl
a969440af8 Don't close window from test driver.
Sometimes I get a "Unable to find target with id XXX closeTarget..." error
when running tests which happens when test.js tries to close all the
open pages. I haven't been able to fully verify since this is intermittent,
but I think this is coming from us closing the window in driver.js and also
trying to close it in test.js.
2022-02-25 09:55:52 -08:00
Calixte Denizet
46369e4aa5 Fix some issues with lineWidth < 1 after transform (bug 1753075, bug 1743245, bug 1710019)
- it aims to fix:
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1753075;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1743245;
   - https://bugzilla.mozilla.org/show_bug.cgi?id=1710019;
   - issue #13211;
   - issue #14521.
 - previously we were trying to adjust lineWidth to have something correct after the current transform is applied but this approach was not correct because finally the pixel is rescaled with the same factors in both directions.
  And sometimes those factors must be different (see bug 1753075).
 - So the idea of this patch is to apply a scale matrix to the current transform just before setting lineWidth and stroking. This scale matrix is computed in order to ensure that after transform, a pixel will have its two thickness greater than 1.
2022-02-25 18:37:34 +01:00
Jonas Jenwald
28fc8248f0 Simplify the wrapReason helper function
All call-sites that use `wrapReason` should be passing a (possibly cloned) `Error` to the helper function, hence we shouldn't need to have a fallback code-path for any other data.
Note that for the `cancel`/`error` methods on Streams, since PR 11115 we've been asserting that the argument is in fact an `Error` as intended.
When calling `wrapReason` from *rejected* Promises, we should also be guaranteed that an `Error` is provided thanks to the ESLint rules `no-throw-literal` and `prefer-promise-reject-errors`.
2022-02-25 18:31:12 +01:00
Jonas Jenwald
9d773c1499 Only support the standard, unprefixed, Fullscreen API in the default viewer
At this point in time, after recent rounds of clean-up, the `webkit`-prefixed Fullscreen API is the only remaining *browser-specific* compatibility hack in the `web/`-folder JavaScript code.

The standard, and thus unprefixed, Fullscreen API has been supported for *over three years* in both Mozilla Firefox and Google Chrome. [According to MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#browser_compatibility), the unprefixed Fullscreen API has been available since:
 - Mozilla Firefox 64, released on 2018-12-11; see https://wiki.mozilla.org/Release_Management/Calendar#Past_branch_dates
 - Google Chrome 71, released on 2018-12-04; see https://en.wikipedia.org/wiki/Google_Chrome_version_history

Hence *only* Safari now requires using a prefixed Fullscreen API, and it's thus (significantly) lagging behind other browsers in this regard.
Considering that the default viewer is written *specifically* to be the UI for the Firefox PDF Viewer, and that we ask users to not just use it as-is[1], I think that we should only support the standard Fullscreen API now.
Furthermore, note also that the FAQ already lists Safari as "Mostly" supported; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support

---
[1] Note e.g. http://mozilla.github.io/pdf.js/getting_started/#introduction
> The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. *However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.*
2022-02-25 16:06:28 +01:00
Jonas Jenwald
cadc4d2f61 Replace all "private" methods in PDFPresentationMode with proper ones
Now that the there's ECMAScript support for properly private methods on `class`es, we can use that instead and thus remove all of the `@private` JSDocs comments.
2022-02-25 14:49:12 +01:00
Jonas Jenwald
b753271ca6
Merge pull request #14605 from Snuffleupagus/font-test-atob-btoa
Simplify the `decodeFontData`/`encodeFontData` font-test helper functions
2022-02-25 11:50:03 +01:00
Jonas Jenwald
f4e78d9b38 Simplify the decodeFontData/encodeFontData font-test helper functions
We can (and in my opinion should) use the standard `atob`/`btoa` functions, rather than manually re-implementing this functionality for the font-tests.
2022-02-25 11:40:03 +01:00
Jonas Jenwald
889b761f22
Merge pull request #14545 from brendandahl/output-scale
Generate test images at different output scales.
2022-02-24 21:56:54 +01:00
Brendan Dahl
f5c3abb8f7 Generate test images at different output scales.
This will default to generating test images at the device pixel
ratio of the machine the tests are created on unless the
test explicitly defines and output scale using the
`outputScale` setting. This makes the test look visually
like they would on the machine they are running on. It
also allows us to test different output scales.
2022-02-24 11:27:41 -08:00
Jonas Jenwald
172d007598 [api-minor] Add validation for the PDFDocumentProxy.getPageIndex method
Currently we'll happily attempt to send any argument passed to this method over to the worker-thread, without doing any sort of validation.
That could obviously be quite bad, since there's first of all no protection against sending unclonable data. Secondly, it's also possible to pass data that will cause the `Ref.get` call in the worker-thread to fail immediately.

In order to address all of these issues, we'll now properly validate the argument passed to `PDFDocumentProxy.getPageIndex` and when necessary reject already on the main-thread instead.
2022-02-24 12:01:51 +01:00
Jonas Jenwald
2be8036eb7 [api-minor] Reduce duplication in the "gets non-existent page" unit-test 2022-02-24 11:25:21 +01:00