Commit Graph

13198 Commits

Author SHA1 Message Date
Tim van der Meij
7be4a14d87
Move documentation of the render methods to the AnnotationElement class
Not only does this reduce boilerplate since the documentation is the
same for all annotation classes, it also wasn't correct for the
annotation types that support quadpoints since they return an array of
section elements instead of a single one.
2020-12-05 20:16:40 +01:00
Tim van der Meij
cb422a80b0
Move quadrilateral rendering logic into a method on the AnnotationElement class
Doing so avoids some code duplication.
2020-12-05 20:07:17 +01:00
Tim van der Meij
0273080031
Move quadrilateral creation logic to the constructor of the AnnotationElement class
Using an object for the various constructor options makes extensions
easier and makes the code self-documenting.
2020-12-05 20:01:07 +01:00
Tim van der Meij
54ca67d628
Merge pull request #12693 from Snuffleupagus/mv-ColorConverters
[Regression] Prevent the *built* `pdf.scripting.js`/`pdf.sandbox.js` files from accidentally including most of the main-thread code (PR 12631 follow-up)
2020-12-04 20:49:39 +01:00
Jonas Jenwald
155c17c99a [Regression] Prevent the *built* pdf.scripting.js/pdf.sandbox.js files from accidentally including most of the main-thread code (PR 12631 follow-up)
*This is a recent regression, which I stumbled upon while working on cleaning-up the gulpfile related to `pdf.sandbox.js` building.*

By placing the `ColorConverters` functionality in the `src/display/display_utils.js` file, you end up including a *significant* chunk of the `pdf.js` file in the built `pdf.scripting.js`/`pdf.sandbox.js` files.
Given that I cannot imagine that this was actually intended, since it inflates the built files with unnecessary/unused code, this moves `ColorConverters` to a new file instead (thus breaking the dependencies).

To hopefully reduce the risk future bugs, along these lines, a big comment is also placed at the top of the new file.
Finally, the `ColorConverters` is converted to a class with static methods, since this felt slightly cleaner overall.
2020-12-04 14:17:26 +01:00
calixteman
c1f41df4ad
Merge pull request #12685 from calixteman/12684
Fix issue #12684: replace bitwise ORs by ORs
2020-12-03 14:45:56 +01:00
Calixte Denizet
d4f4b43d29 Fix issue #12684: replace bitwise ORs by ORs 2020-12-02 23:02:11 +01:00
Tim van der Meij
a618b02e62
Merge pull request #12682 from Snuffleupagus/findbar-notFound
[Generic viewer] Re-factor how the `notFound` appearance is set on the "findInput" in the `PDFFindBar`
2020-12-02 22:00:41 +01:00
Tim van der Meij
7a60824f2e
Merge pull request #12681 from Snuffleupagus/pr-8808-update-test
Update the link for the "pr8808" test-case (issue 12680)
2020-12-02 21:53:24 +01:00
Tim van der Meij
7325382db3
Merge pull request #12679 from Snuffleupagus/pr-12666-followup
Fix the `treeitem-expanded`/`treeitem-collapsed` images in dark-mode (PR 12666 follow-up)
2020-12-02 21:51:02 +01:00
Jonas Jenwald
313ee28436 [Generic viewer] Re-factor how the notFound appearance is set on the "findInput" in the PDFFindBar
Rather than having two slightly different ways of setting the pending/notFound appearance on the "findInput", we can simply use "data-status" in both cases since they're obviously mutually exclusive.
2020-12-02 15:23:20 +01:00
Jonas Jenwald
dc84c8a02a Update the link for the "pr8808" test-case (issue 12680)
This seems like a very minor issue, since in general we can't really help if domains are blocked from certain networks, however in this particular case I suppose that using the Internet Archive should work.
2020-12-02 15:06:09 +01:00
Jonas Jenwald
488a81a7bc Fix the treeitem-expanded/treeitem-collapsed images in dark-mode (PR 12666 follow-up)
I completely missed updating these in PR 12666; sorry about that!
2020-12-02 11:48:32 +01:00
Brendan Dahl
956fcab967
Merge pull request #12631 from calixteman/app
JS -- Implement app object
2020-12-01 16:50:16 -08:00
Tim van der Meij
db6b67c072
Merge pull request #12673 from calixteman/split
Split underline, strikeout, squiggly annotions div into multiple divs
2020-12-01 23:45:13 +01:00
Tim van der Meij
b43b5caf83
Merge pull request #12666 from Snuffleupagus/rm-dark-images
Use the same SVG images, in the default viewer, regardless of the CSS theme
2020-12-01 23:31:20 +01:00
Calixte Denizet
830070ca41 Split underline, strikeout, squiggly annotions div into multiple divs
* Follow up of #12505
 * Fix bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1679696
2020-12-01 16:04:48 +01:00
Jonas Jenwald
f2ec546cbb Use the same SVG images, in the default viewer, regardless of the CSS theme
As mentioned in https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support, PDF.js version `2.6.347` is the last release with IE 11/Edge support.
Hence we should now be able to reduce unnecessary duplication in the default viewer image resources, note the files in the `web/images/` folder with a `-dark` suffix, by using only *one* SVG-image for each icon and letting the `background-color` depend on the CSS theme instead.

For the `gulp mozcentral` build-target, the resulting `web/images/` folder is reduced from `43 997` to `28 566` bytes (~35 percent).

*Please note:* I don't really know if this implementation is necessarily the *best* solution, but it seems to work well enough in e.g. Firefox Nightly and Google Chrome Beta as far as my testing goes.
2020-12-01 11:45:09 +01:00
Tim van der Meij
43550be484
Merge pull request #12665 from Snuffleupagus/update-packages
Update packages and translations
2020-11-29 15:35:43 +01:00
Jonas Jenwald
c42029489e Run gulp lint --fix, to account for changes in Prettier version 2.2.1
Please refer to https://github.com/prettier/prettier/blob/master/CHANGELOG.md#221 for additional details.
2020-11-29 10:01:46 +01:00
Jonas Jenwald
cd2e6d803a Update l10n files 2020-11-29 09:50:36 +01:00
Jonas Jenwald
58f865404c Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2020-11-29 09:47:33 +01:00
Jonas Jenwald
e15c63abc7 Update npm packages 2020-11-29 09:43:20 +01:00
Tim van der Meij
e072f1db6b
Merge pull request #12652 from calixteman/quickjs_followup
Add a README about quickjs-eval.js file (build and license)
2020-11-25 21:58:03 +01:00
Tim van der Meij
256068556d
Merge pull request #12662 from Snuffleupagus/issue-12402
Check the top-level /Pages dictionary when finding the trailer in `XRef.indexObjects` (issue 12402)
2020-11-25 21:54:41 +01:00
Tim van der Meij
1bde38af38
Merge pull request #12655 from calixteman/12654
Parenthesis in names are not escaped when saving
2020-11-25 21:51:17 +01:00
Tim van der Meij
672e2f1832
Merge pull request #12656 from mozilla/dependabot/npm_and_yarn/highlight.js-9.18.5
Bump highlight.js from 9.13.1 to 9.18.5
2020-11-25 21:28:45 +01:00
Jonas Jenwald
8a132f584d Check the top-level /Pages dictionary when finding the trailer in XRef.indexObjects (issue 12402)
In addition to the existing /Root and /Pages validation, also check that the /Pages-entry actually is a dictionary and that it has a valid /Count-entry.
This way we can avoid picking a trailer candidate which e.g. the `Catalog.numPages` getter will just end up rejecting, thus breaking PDF document loading completely.
2020-11-25 15:14:53 +01:00
Calixte Denizet
18b525de2e Parenthesis in names are not escaped when saving 2020-11-25 12:28:12 +01:00
dependabot[bot]
b6fdade6c6
Bump highlight.js from 9.13.1 to 9.18.5
Bumps [highlight.js](https://github.com/highlightjs/highlight.js) from 9.13.1 to 9.18.5.
- [Release notes](https://github.com/highlightjs/highlight.js/releases)
- [Changelog](https://github.com/highlightjs/highlight.js/blob/9.18.5/CHANGES.md)
- [Commits](https://github.com/highlightjs/highlight.js/compare/9.13.1...9.18.5)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-24 23:29:33 +00:00
Calixte Denizet
8413a5865a Add a README about quickjs-eval.js file (build and license) 2020-11-24 13:54:04 +01:00
Tim van der Meij
b1d3b6eb12
Merge pull request #12647 from timvandermeij/update-puppeteer
Update Puppeteer to version 5.5.0
2020-11-22 16:07:32 +01:00
Tim van der Meij
a936f1f70c
Update Puppeteer to version 5.5.0 2020-11-22 14:26:49 +01:00
Tim van der Meij
d88d47d621
Merge pull request #12645 from Snuffleupagus/async-PDFDocumentProperties-open
Convert the `PDFDocumentProperties.open` method to be async
2020-11-21 14:42:48 +01:00
Jonas Jenwald
4615815cc7 Convert the PDFDocumentProperties.open method to be async
By using `await`, rather than chaining promises, this method becomes more compact and slightly easier to reason about (at least in my opinion).
2020-11-21 13:54:36 +01:00
Tim van der Meij
d3f7959689
Merge pull request #12642 from Snuffleupagus/api-getMetadata-contentLength
[api-minor] Add "contentLength" to the information returned by the `getMetadata` method
2020-11-20 21:24:33 +01:00
Calixte Denizet
283aac4c53 JS -- Implement app object
* https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf
 * Add color, fullscreen objects + few constants.
2020-11-20 15:46:52 +01:00
Jonas Jenwald
01d12b465c [api-minor] Add "contentLength" to the information returned by the getMetadata method
Given that we already include the "Content-Disposition"-header filename, when it exists, it shouldn't hurt to also include the information from the "Content-Length"-header.
For PDF documents opened via a URL, which should be a very common way for the PDF.js library to be used, this will[1] thus provide a way of getting the PDF filesize without having to wait for the `getDownloadInfo`-promise to resolve[2].

With these API improvements, we can also simplify the filesize handling in the `PDFDocumentProperties` class.

---
[1] Assuming that the server is correctly configured, of course.

[2] Since that's not *guaranteed* to happen in general, with e.g. `disableAutoFetch = true` set.
2020-11-20 15:30:36 +01:00
Brendan Dahl
c88e805870
Merge pull request #12604 from calixteman/quickjs
JS -- Add a sandbox based on quickjs
2020-11-19 08:40:21 -08:00
Brendan Dahl
4ba28de260
Merge pull request #12567 from calixteman/hidden
[api-minor] JS -- hidden annotations must be built in case a script show them
2020-11-19 08:35:47 -08:00
Calixte Denizet
c7974e9996 JS -- Add a sandbox based on quickjs
* quickjs-eval.js has been generated using https://github.com/mozilla/pdf.js.quickjs/
 * lazy load of sandbox code
 * Rewrite tests to use the sandbox
 * Add a task `watch-sandbox` which update bundle pdf.sandbox.js on change in the sandbox code
2020-11-19 13:40:46 +01:00
Tim van der Meij
d3936ac9d2
Merge pull request #12636 from Snuffleupagus/AppOptions-setAll
Add an `AppOptions.setAll` method, and use it in `PDFViewerApplication._readPreferences`
2020-11-18 21:16:09 +01:00
Jonas Jenwald
cc861c34e9 Add an AppOptions.setAll method, and use it in PDFViewerApplication._readPreferences
Given that it's generally faster to call *one* function and have it loop through an object, rather than looping through an object and calling a function for every iteration, this patch will reduce the total time spent in `PDFViewerApplication._readPreferences` ever so slightly.
Also, over time we've been adding more and more preferences, rather than removing them, so using the new `AppOptions.setAll` method should be generally beneficial as well.

While the effect of these changes is quite small, it does reduces the time it takes for the preferences to be fully initialized. Given the amount of asynchronous code during viewer initialization, every bit of time that we can save should thus help.
Especially considering the recently added `viewerCssTheme` preference, which needs to be read very early to reduce the risk of the viewer UI "flashing" visibly as the theme changes, I figured that a couple of small patches reducing the time spend reading preferences cannot hurt.
2020-11-18 12:10:21 +01:00
Jonas Jenwald
4886a7cf69 Skip Promise.all in PDFViewerApplication._parseHashParameters unless actually necessary
Given that only two debugging hash parameters (i.e. `disableWorker` and `pdfBug`) will make this method asynchronous, we can avoid what's most of the time is an unnecessary `Promise.all` invocation.
2020-11-18 11:45:18 +01:00
Tim van der Meij
a06f487bd4
Merge pull request #12630 from Snuffleupagus/BasePreferences-less-async
Reduce, now unnecessary, asynchronicity in the `BasePreferences` constructor
2020-11-17 00:07:06 +01:00
Tim van der Meij
eda730af65
Merge pull request #12625 from Snuffleupagus/viewerCssTheme-option
Add a new preference, `viewerCssTheme`, to allow forcing the use of the light/dark viewer CSS themes (issue 12290)
2020-11-17 00:00:38 +01:00
Jonas Jenwald
40a4d53fb3 Add a new preference, viewerCssTheme, to allow forcing the use of the light/dark viewer CSS themes (issue 12290)
While this does work pretty well in my quick testing, it's *very much* a hack since as far as I can tell there's no support in the CSS specification for using e.g. a CSS variable to override a `@media (prefers-color-scheme: dark) {...}` block.

The solution implemented here is thus to *edit* the viewer CSS, by either removing the entire `@media ...` block in light-mode or by ensuring that its rules become *unconditionally* applied in dark-mode.
To simplify the overall implementation, since all of this does seem like somewhat of an edge-case, the `viewerCssTheme` preference will *only* be read during viewer initialization. (Similar to many other existing preferences, a reload is thus required when changing it.)
2020-11-16 21:13:13 +01:00
Brendan Dahl
f39d87bff1
Merge pull request #12569 from calixteman/events
JS -- Fix events dispatchment and add tests
2020-11-16 10:26:29 -08:00
Jonas Jenwald
7adcb90a2d Reduce, now unnecessary, asynchronicity in the BasePreferences constructor
Originally the default preferences were defined in a JSON-file checked into the repository, which was loaded using SystemJS in development mode.
Over the years a number of changes have been made to this code, most notably:
 - The preferences JSON-file is now generated automatically, during building, from the `AppOptions` abstraction.
 - All SystemJS usage has been removed from the development viewer.

Hence the default preferences are now available *synchronously* even in the development viewer, and it's thus no longer necessary to defer to the microtask queue (since `getDefaultPreferences` is async) just to get the default preferences.

While the effect of these changes is quite small, it *does* reduces the time it takes for the preferences to be fully initialized. Given the amount of asynchronous code during viewer initialization, every bit of time that we can save should thus help.
2020-11-16 14:19:54 +01:00
Tim van der Meij
ed27fc6c52
Merge pull request #12624 from Snuffleupagus/update-packages
Update packages and translations
2020-11-15 23:20:40 +01:00