Commit Graph

15622 Commits

Author SHA1 Message Date
Tim van der Meij
75ac897284
Merge pull request #14857 from Snuffleupagus/rm-webViewerOpenFileViaURL
Inline the `webViewerOpenFileViaURL` function in  `webViewerInitialized`
2022-04-30 12:21:25 +02:00
Tim van der Meij
e5e2941d53
Merge pull request #14854 from Snuffleupagus/viewer-rm-button-classes
Remove redundant class names from the button DOM-elements
2022-04-30 12:18:16 +02:00
calixteman
b10b8dad7d
Merge pull request #14853 from calixteman/white_lines
Use integer coordinates when drawing images (bug 1264608, issue #3351)
2022-04-29 18:15:03 +02:00
Jonas Jenwald
9268924a15 Only define the webViewerFileInputChange/webViewerOpenFile variables in GENERIC builds
There's no point in having these variables defined (implicitly) as `undefined` in e.g. the Firefox PDF Viewer.
By defining them with `var` and using ESList ignores, rather than `let`, we can move them into the relevant pre-processor block instead. Note that since the entire viewer-code is placed, by Webpack, in a top-level closure these variables will thus *not* become globally accessible.
2022-04-29 18:07:56 +02:00
Jonas Jenwald
7cce41c26d Inline the webViewerOpenFileViaURL function in webViewerInitialized
Given that `webViewerOpenFileViaURL` only has a single call-site, and also isn't a particularly large/complex function, it doesn't seem necessary for this to be a separate function and hence it's simply inlined instead.

Also, changes the "no valid build-target was set"-case to throw unconditionally since the only way that it could ever be hit is if there are bugs in the `gulpfile`-code.
2022-04-29 18:07:52 +02:00
Calixte Denizet
624d8a8e3e Use integer coordinates when drawing images (bug 1264608, issue #3351)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1264608;
- it's only a partial fix for #3351;
- some tiled images have some spurious white lines between the tiles.
  When the current transform is applyed the corners of an image can have
  some non-integer coordinates leading to some extra transparency added
  to handle that. So with this patch the current transform is applied on the
  point and on the dimensions in order to have at the end only integer values.
2022-04-29 16:01:34 +02:00
Jonas Jenwald
24d5d5d761
Merge pull request #14856 from Snuffleupagus/rm-forceClamped
[api-minor] Remove the `forceClamped`-functionality in the Streams (issue 14849)
2022-04-29 15:19:17 +02:00
Jonas Jenwald
fbf6dee8ee [api-minor] Remove the forceClamped-functionality in the Streams (issue 14849)
As it turns out, most of the code-paths in the `PDFImage`-class won't actually pass the TypedArray (containing the image-data) to the `ColorSpace`-code. Hence we *generally* don't need to force the image-data to be a `Uint8ClampedArray`, and can just as well directly use a `Uint8Array` instead.

In the following cases we're returning the data without any `ColorSpace`-parsing, and the exact TypedArray used shouldn't matter:
 - b72a448327/src/core/image.js (L714)
 - b72a448327/src/core/image.js (L751)

In the following cases the image-data is only used *internally*, and again the exact TypedArray used shouldn't matter:
 - b72a448327/src/core/image.js (L762) with the actual image-data being defined (as `Uint8ClampedArray`) further below
 - b72a448327/src/core/image.js (L837)

*Please note:* This is tagged `api-minor` because it's API-observable, given that *some* image/mask-data will now be returned as `Uint8Array` rather than using `Uint8ClampedArray` unconditionally. However, that seems like a small price to pay to (slightly) reduce memory usage during image-conversion.
2022-04-29 14:46:30 +02:00
Jonas Jenwald
1e24fe97f2 Remove unnecessary CSS classes when specifying button icons
Currently we're using *both* ids and classes when specifying the button icons, which seems completely unnecessary and only serves to bloat the CSS code.
In general you always need to be careful about CSS specificity, but in these cases that should not actually be a problem.

Also, while not a button, this patch makes a similar simplification for the `pageNumber`-input.
2022-04-29 09:40:03 +02:00
Jonas Jenwald
4f69d66ab2 Remove redundant class names from the button DOM-elements
Note how in the `viewer.html` file we're specifying class names for most buttons, despite that not really being necessary. First of all, in many cases those class names are *identical* to the element-ids. Secondly, looking through the CSS rules they are only ever used when specifying button icons.
All-in-all, we should be able to simplify the HTML-code and use the element-ids in the CSS rules instead. Obviously ids have a higher CSS specificity than classes, but given how the old classes were being used that shouldn't be a problem here.

Also, the patch generalizes the styling for buttons (e.g. `viewBookmark`) that are *actually* link-elements.

Finally, while slightly unrelated, this patch also removes a little bit of duplication when specifying the border for `toolbarField`s.
2022-04-29 09:36:35 +02:00
Tim van der Meij
b72a448327
Merge pull request #14835 from Snuffleupagus/CSS-cleanup-separators
Clean-up some CSS rules for the various toolbar separators
2022-04-27 14:32:23 +02:00
Tim van der Meij
5ca9f9bf86
Merge pull request #14833 from Snuffleupagus/mozcentral-rm-openFile-buttons
Stop bundling the openFile-buttons in the MOZCENTRAL build
2022-04-27 14:27:46 +02:00
Jonas Jenwald
694cb311c0
Merge pull request #14848 from Snuffleupagus/issue-14847
Support destinations in NameTrees with encoded keys (issue 14847)
2022-04-27 12:15:48 +02:00
Jonas Jenwald
71370d012b Support destinations in NameTrees with encoded keys (issue 14847)
Initially I considered updating the `NameOrNumberTree`-implementation to handle encoded keys, however that quickly became somewhat messy (especially in the `NameOrNumberTree.get`-method) since only NameTrees using string-keys.
Hence the easiest solution, as far as I'm concerned, was thus to just update the `Catalog.destinations`-getter instead. Please note that in the referenced PDF document the `Catalog.destination`-method will thus fallback to fetch all destinations, which should be fine since this is the very first case of encoded keys that we've seen.

Also changes the `NameOrNumberTree.getAll`-method to prevent a possible run-time error, although we've so far not seen such a case, for any non-Array Kids-entries found in a NameTree/NumberTree.

Finally, to improve overall consistency and to hopefully prevent future bugs, the patch also updates a couple of other `NameTree` call-sites to correctly handle encoded keys. (Note that the `Catalog.attachments`-getter was already doing this.)
2022-04-27 11:19:55 +02:00
Jonas Jenwald
981cd5bbfc
Merge pull request #14836 from calixteman/fix_integration
Don't use pref 'browser.download.improvements_to_download_panel' in Firefox (#14822)
2022-04-25 15:23:44 +02:00
Calixte Denizet
314fd83bba Don't use pref 'browser.download.improvements_to_download_panel' in Firefox (#14822) 2022-04-25 15:05:43 +02:00
Jonas Jenwald
3c10c66cd3 Remove unused CSS rules for toolbar buttons with textButton-classes
Searching through all of the files in the `web/`-folder has no *other* hits for the "textButton" string. Hence it's clear that there are no DOM elements actually using this class, and it's thus dead code.
2022-04-25 14:55:32 +02:00
Jonas Jenwald
f9262d29fc Clean-up some CSS rules for the various toolbar separators
This re-factors the various toolbar separators to *explicitly* specify both their dimensions and margins. Also, for the `horizontalToolbarSeparator`-class we can just set the `background-color` rather than using `border-top`.

Note that the `splitToolbarButtonSeparator`-class currently sets a number of unnecessary CSS rules, since as mentioned by the Firefox Devtools both the `display`- and `z-index`-properties are being ignored because `float` is used.

Finally, there's also no need to set a `z-index` for some of the `:hover`-rules. It's possible that this *was* necessary before the re-design, since the buttons had borders then.
2022-04-25 14:53:12 +02:00
Jonas Jenwald
b04c373362 Stop bundling the openFile-buttons in the MOZCENTRAL build
Note how both of the openFile-buttons are always hidden during viewer initialization in the MOZCENTRAL build, i.e. the *built-in* Firefox PDF Viewer. Despite that we still include HTML, CSS, and JavaScript code for these buttons in the build.

This patch *reduces* the size of the `gulp mozcentral` output by `1679` bytes, which isn't a lot but still cannot hurt.
2022-04-25 11:35:17 +02:00
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