Commit Graph

15603 Commits

Author SHA1 Message Date
Tim van der Meij
2be19e828f
Merge pull request #14831 from Snuffleupagus/incrementCachedImageMaskCount
Add a helper function for incrementing the `count` of cached ImageMasks
2022-04-24 11:47:07 +02:00
Tim van der Meij
41065d7825
Merge pull request #14829 from Snuffleupagus/rm-print-CSS
Remove unnecessary `print` CSS rules
2022-04-24 11:21:34 +02:00
Jonas Jenwald
e18edf38db Add a helper function for incrementing the count of cached ImageMasks
While working on PR 14825, I couldn't help noticing that the code to increment the `count` for cached ImageMasks was repeated multiple times. Hence it makes sense, as far as I'm concerned, to move this into a helper function instead.
2022-04-24 11:10:02 +02:00
Jonas Jenwald
925a7bc58a Remove unnecessary print CSS rules
These rules became unnecessary with PR 7697, over five years ago, since printing is now done from a `printContainer`-element rather than "directly" using the viewer.

Note how the *entire* `outerContainer`, which contains all of the DOM elements that were being manually hidden, is now being hidden during printing. Furthermore, note also how the print-canvases/images and their containers are using custom CSS-classes[1] rather than re-using the ones from the viewer.

---
[1] See the `printedPage` respectively `xfaPrintedPage` classes.
2022-04-23 14:32:00 +02:00
Tim van der Meij
752dee5caa
Merge pull request #14825 from Snuffleupagus/issue-14824
Ensure that worker-thread image caching doesn't break optional content (issue 14824)
2022-04-23 13:19:56 +02:00
Tim van der Meij
f9e54d9226
Merge pull request #14823 from Snuffleupagus/issue-14821
Ignore invalid /Encoding-entries when parsing fonts (issue 14821)
2022-04-23 13:19:26 +02:00
Tim van der Meij
18dd2866f7
Merge pull request #14827 from Snuffleupagus/toolbar-margin
Simplify setting of spacing at the left/right edges of the toolbar(s)
2022-04-23 13:11:16 +02:00
Tim van der Meij
1921c4612d
Merge pull request #14828 from Snuffleupagus/viewer-more-for-of
Use more `for...of` loops in the viewer
2022-04-23 13:09:32 +02:00
Jonas Jenwald
7e57469683 Use more for...of loops in the viewer
Note that the arrays that we're looping over here are by definition *dense*, hence there's no point in checking if each element actually exists first.
2022-04-23 12:48:54 +02:00
Jonas Jenwald
33ed743c48 Simplify setting of spacing at the left/right edges of the toolbar(s)
Rather than modifying the leading/trailing `margin` on the actual toolbar buttons, to achieve appropriate spacing at the left/right edges of the toolbar(s), it seems much more appropriate (and simpler) to just specify an explicit `padding` for the relevant toolbar containers.

Also, for toolbar buttons placed in `splitToolbarButton`-classes we can reduce some complexity around setting the `margin` (since it should always be zero now).

With these changes, we're thus able to get rid of a couple more `!important`-rules.
2022-04-22 18:15:28 +02:00
Jonas Jenwald
6c229dffb1 Ensure that worker-thread image caching doesn't break optional content (issue 14824)
Currently we only insert optionalContent-data into the operatorList the first time that an image is parsed, which will (in hindsight) obviously cause problems for cached images.
Hence we also need to insert the optionalContent-data in the various worker-thread image caches, such that it can be accessed in the fast-paths that are used to skip re-parsing of images.

In order to reduce the amount of repeated code, this patch also adds a new `OperatorList`-method that takes care of inserting the necessary data in the operatorList.
2022-04-22 14:49:16 +02:00
Jonas Jenwald
e723da7261 Ignore invalid /Encoding-entries when parsing fonts (issue 14821)
In the referenced PDF document the fonts have /Encoding-entries that are Streams (containing completely bogus data), which are thus obviously not valid here.
Hence, only when `ignoreErrors` is set, we'll now ignore these corrupt /Encoding-entries and fallback to the existing code to try and infer a usable encoding.

Given that this is *clearly* a case of corrupt PDF documents, there's no guarantee that this will "fix" all such cases, however it's the best that we do here and shouldn't really be worse than ignoring an entire font.
2022-04-22 11:49:03 +02:00
Tim van der Meij
f39219cd45
Merge pull request #14815 from Snuffleupagus/issue-14814
Ignore non-Stream /SMask-entries when parsing images (issue 14814)
2022-04-22 11:39:13 +02:00
Tim van der Meij
7ba71f56b4
Merge pull request #14818 from Sea-n/master
Use correct case for JavaScript
2022-04-22 11:31:55 +02:00
Tim van der Meij
ec28f0aa47
Merge pull request #14817 from Snuffleupagus/more-CSS-cleanup
Some more, small, CSS clean-up
2022-04-22 11:30:32 +02:00
Sean Wei
6bf978404e Use correct case for JavaScript 2022-04-21 23:56:28 +08:00
Jonas Jenwald
0f7e3213a1 Some more, small, CSS clean-up
- Remove a redundant `margin-top` rule for the `.dropdownToolbarButton`. After the (somewhat) recent UI-refresh all buttons now use `margin: 2px 1px;`, which renders the override unnecessary (and getting rid of an `!important`-rule can't hurt).

 - Combine two `.toggled::before` rules, since they're identical.
2022-04-21 15:41:30 +02:00
Jonas Jenwald
39d1bdde09 Ignore non-Stream /SMask-entries when parsing images (issue 14814)
This is similar to the pre-existing check used in the /Mask-case below, to handle *corrupt* PDF documents that include non-Stream /SMask-entries in images; please refer to the PDF specification:
https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=216

*Please note:* Adobe Reader also fails to render the image on the second page, and displays an error message.
2022-04-21 12:14:08 +02:00
Tim van der Meij
452a98b0e0
Merge pull request #14810 from Snuffleupagus/mozcentral-rm-errorWrapper-CSS
Stop bundling `errorWrapper` CSS rules in the MOZCENTRAL build
2022-04-20 19:50:57 +02:00
Tim van der Meij
5e8b2e5d25
Merge pull request #14794 from Snuffleupagus/BaseViewer-update-isInPresentationMode
Remove the PresentationMode special-case from `BaseViewer.update`
2022-04-20 19:46:53 +02:00
Jonas Jenwald
1d803451c3 Stop bundling errorWrapper CSS rules in the MOZCENTRAL build
Note that both the `errorWrapper` HTML and JavaScript code is being ignored in the MOZCENTRAL build, i.e. the *built-in* Firefox PDF Viewer, however the CSS rules are still being included.
That seems totally unnecessary, and while we currently don't have full build-target support in the CSS pre-processor we can actually improve things quite easily anyway. By (ab)using the existing CSS pre-processor, which will remove any non-Firefox CSS rules for the MOZCENTRAL build, it's possible to easily stop bundling any CSS rules by using comments that include a `-webkit`-string.

*Please note:* To easily test that this doesn't break the `errorWrapper` in GENERIC builds, try running e.g. `PDFViewerApplication._otherError("test");` in the web-console.
2022-04-20 14:35:09 +02:00
Jonas Jenwald
c91d2ac15a Remove the PresentationMode special-case from BaseViewer.update
This special-case was added because the original PresentationMode-implementation used some CSS-tricks to hide everything except the current page. With the changes in PR 14112, which added a PAGE scroll-mode, many of the old PresentationMode-specific hacks could thus be removed from both the JS and CSS code.

This patch is yet another (small) clean-up step, to reduce the number of PresentationMode special-cases used throughout the `BaseViewer`. Note in particular that `BaseViewer.update` now works just fine in PresentationMode[1], and that we only need to ensure that the active page won't *accidentally* change because of the PresentationMode-specific zooming that occurs during page-switching.

---
[1] In the event that we ever want to try and support spread-modes in PresentationMode, which I'm really not keen on doing since documents with varying page sizes will be annoying to handle, these changes would be necessary as well.
2022-04-20 12:17:00 +02:00
Tim van der Meij
9a8fa3201f
Merge pull request #14803 from Snuffleupagus/issue-14802
Add support for the /Catalog Base-URI when resolving URLs (issue 14802)
2022-04-19 21:41:24 +02:00
Tim van der Meij
c58ff7c301
Merge pull request #14801 from Snuffleupagus/findbar-simplify-button-styling
[GENERIC viewer] Simplify the styling of the previous/next findbar buttons
2022-04-19 21:29:41 +02:00
Tim van der Meij
5032e357d4
Merge pull request #14793 from Snuffleupagus/ensurePageViewVisible-spreads
Simplify spread-mode handling for the PAGE scroll-mode
2022-04-19 21:25:59 +02:00
Tim van der Meij
a115d17b43
Merge pull request #14795 from Snuffleupagus/CSS-reduce-duplication
Reduce more duplication in the CSS
2022-04-19 21:19:05 +02:00
Tim van der Meij
b34fb94c68
Merge pull request #14792 from Snuffleupagus/update-packages
Update packages and translations
2022-04-19 21:17:28 +02:00
Tim van der Meij
5f6ca2224e
Merge pull request #14790 from Snuffleupagus/rm-print-CSS
Remove some outdated CSS rules related to printing
2022-04-19 21:14:42 +02:00
Tim van der Meij
cf320f8fa3
Merge pull request #14788 from Snuffleupagus/debugger-separate-css
Move the `PDFBug`-related CSS from `viewer.css` and into its own file
2022-04-19 21:13:16 +02:00
Jonas Jenwald
5bc7339c1b Add support for the /Catalog Base-URI when resolving URLs (issue 14802)
As far as I can tell, this is actually the very first time that we've seen a PDF document with a Base-URI specified in the /Catalog; please refer to the specification:
https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2097122

To simplify the overall implementation, this new parameter is accessed via the existing `BasePdfManager.docBaseUrl`-getter and will thus override any user-specified `docBaseUrl` API-parameter.
2022-04-19 17:14:52 +02:00
Jonas Jenwald
fb90ef7b28 [GENERIC viewer] Simplify the styling of the previous/next findbar buttons
The styling of the previous/next-buttons and the findInput, with the elements being "glued" together, was supposed to mimic the styling used in the Firefox *browser* findbar. However, after the most recent re-styling of the Firefox browser UI these elements are now visually separated.
Hence it makes sense, as far as I'm concerned, to try and follow this styling for the findbar used in the GENERIC viewer. One benefit of doing this is that we get more consistent styling, since the buttons now look/behave identically in both the main toolbar and the findbar. Additionally this also simplifies the CSS a bit, since a lot of the existing findbar-specific rules can be removed.
2022-04-19 14:12:30 +02:00
Jonas Jenwald
32ae0e4867
Merge pull request #14799 from calixteman/12306-followup
Fix clipping issue with pattern (follow-up of #14797)
2022-04-18 13:17:17 +02:00
Calixte Denizet
c2aa03e194 Fix clipping issue with pattern (follow-up of #14797) 2022-04-18 12:41:14 +02:00
Jonas Jenwald
5bbed400f2
Merge pull request #14797 from calixteman/12306
Don't clip when the clip path is empty (issue #12306)
2022-04-18 11:18:32 +02:00
Jonas Jenwald
f82879205e
Merge pull request #14796 from calixteman/minmax
[api-minor] Simplify min/max computations in constructPath (bug 1135277)
2022-04-18 11:15:23 +02:00
Calixte Denizet
3d74d2c6cb Don't clip when the clip path is empty (issue #12306) 2022-04-18 10:33:44 +02:00
Calixte Denizet
4b7691baf6 Simplify min/max computations in constructPath (bug 1135277)
- most of the time the current transform is a scaling one (modulo translation),
  hence it's possible to avoid to apply the transform on each bbox and then apply
  it a posteriori;
- compute the bbox when it's possible in the worker.
2022-04-17 17:25:54 +02:00
Jonas Jenwald
1ea9740fdb Reduce more duplication in the CSS
This patch combines a couple of different CSS rules, thus reducing the overall size of the file.
2022-04-17 14:03:01 +02:00
calixteman
379125c37f
Merge pull request #14777 from calixteman/mask_perf
[api-minor] Improve performances with image masks (bug 857031)
2022-04-17 12:37:23 +02:00
Jonas Jenwald
03ec7a22f2 Simplify spread-mode handling for the PAGE scroll-mode
The spread-mode code in `BaseViewer.#ensurePageViewVisible`-method was initially copied from the `BaseViewer._updateSpreadMode`-method, which means that it's slightly more complicated than actually necessary.
In particular, in the PAGE scroll-mode there can only be *one* spread active at a time and we thus don't need to handle insertion of multiple spread-divs.
2022-04-17 10:58:14 +02:00
Jonas Jenwald
0c086467a9 Update l10n files 2022-04-17 10:25:20 +02:00
Jonas Jenwald
c727fde767 Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2022-04-17 10:23:09 +02:00
Jonas Jenwald
bb6bb137cf Remove the web-streams-polyfill Babel-exclusion in gulpfile.js (PR 14560 follow-up)
Given that we're no longer, after PR 14560, bundling the `web-streams-polyfill`-code in the `legacy`-builds we shouldn't need to exclude it from Babel now.
2022-04-17 10:16:50 +02:00
Jonas Jenwald
49d1121f3c Update npm packages 2022-04-17 10:15:10 +02:00
Calixte Denizet
f62d961dfe Improve performances with image masks (bug 857031)
- it's the second part of the fix for https://bugzilla.mozilla.org/show_bug.cgi?id=857031;
- some image masks can be used several times but at different positions;
- an image need to be pre-process before to be rendered:
  * rescale it;
  * use the fill color/pattern.
- the two operations above are time consuming so we can cache the generated canvas;
- the cache key is based on the current transform matrix (without the translation part)
  and the current fill color when it isn't a pattern.
- the rendering of the pdf in the above bug is really faster than without this patch.
2022-04-16 20:48:39 +02:00
Jonas Jenwald
d7fd8d3883 Remove some outdated CSS rules related to printing
Given that no HTML element has used the `loadingBox`-id for many years, we obviously don't need to try and hide a non-existent element during printing.
Furthermore, we also shouldn't need to change the `overflow`-value for the `viewerContainer`-element during printing. Originally, many years ago now, we printed "directly" using the viewer and then this apparently made sense.
2022-04-16 16:03:17 +02:00
Jonas Jenwald
7023bac8d3 Move the PDFBug-related CSS from viewer.css and into its own file
Given that none of these CSS rules are used at all, unless debugging is enabled, it seems completely unnecessary to load them *unconditionally* for all users.[1]

Note that if *both* the `textLayer` and `pdfBug` debugging hash-parameters are specified simultaneously, we'll now load the `PDFBug`-file *twice* (since the code is simpler that way). However, given first of all that none of this is enabled by default and secondly that using those parameters together isn't helpful[2], potentially loading that file twice is hopefully not an issue.

For the `gulp mozcentral` target, the size of the *built* `viewer.css` file is reduced `> 3%` with this patch.

---
[1] For the Firefox built-in PDF Viewer, in order to even be able to access the `PDFBug` functionality, you need to first of all set `pdfjs.pdfBugEnabled = true` manually in `about:config`. Secondly, you then also need to append the `pdfBug=...` hash-parameter to the URL when *initially* loading the document.

[2] Note how the `textLayer`-settings are already, since essentially forever, overriding the highlighting-features of the "FontInspector"-tab.
2022-04-16 14:16:39 +02:00
Tim van der Meij
b73a6cc213
Merge pull request #14785 from Snuffleupagus/core-js-structuredClone-transfers
Update `core-js` to allow removing a `structuredClone` work-around
2022-04-16 12:36:44 +02:00
calixteman
681a9b8927
Merge pull request #14784 from calixteman/intersect
Improve performance of shared/utils.js::intersect (bug 1135277)
2022-04-15 22:38:19 +02:00
Calixte Denizet
7501fe6f30 Improve performance of shared/utils.js::intersect
- avoid to call normalizeRect which clones the rectangles: it's useless
  and time consuming;
- in profiling the pdf in bug 1135277, the time spent in intersect drops
  from ~1s to ~30ms.
2022-04-15 22:24:26 +02:00