Commit Graph

15560 Commits

Author SHA1 Message Date
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
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
Jonas Jenwald
b996e107c3 Update core-js to allow removing a structuredClone work-around
Because of a bug in previous `core-js` versions, which caused an Error to be thrown if its `structuredClone` polyfill was called with an *explicit* `null`/`undefined` transfer-parameter, the `LoopbackPort`-class contained a work-around.
In the latest `core-js` version this has been fixed, and we can thus simplify our code ever so slightly; please see https://github.com/zloirock/core-js/releases/tag/v3.22.0
2022-04-15 22:12:02 +02:00
Jonas Jenwald
fffce7910e
Merge pull request #14722 from Rob--W/scripting-manager-mousedown-grab-to-pan-conflict
PDFScriptingManager: Bind mousedown listener with capture=true
2022-04-15 11:59:18 +02:00
Tim van der Meij
3f5c31e203
Merge pull request #14780 from Snuffleupagus/rm-CSS-viewport-scale-factor
Replace the `--viewport-scale-factor` CSS variable
2022-04-14 21:12:29 +02:00
Tim van der Meij
c4a9fd635e
Merge pull request #14773 from Snuffleupagus/rm-dropdownToolbarButton-styling
Remove some `dropdownToolbarButton`-related CSS rules
2022-04-14 21:02:57 +02:00
Tim van der Meij
5ca26bcc05
Merge pull request #14772 from Snuffleupagus/rm-unneeded-CSS
Remove/simplify some CSS rules
2022-04-14 20:57:04 +02:00
Tim van der Meij
e9aedf2d91
Merge pull request #14771 from Snuffleupagus/dialog-backdrop-rm-user-select
Simplify the `dialog::backdrop` CSS rules (PR 14710 follow-up)
2022-04-14 20:54:22 +02:00
Tim van der Meij
97377085c1
Merge pull request #14770 from Snuffleupagus/sidebarContainer-transitionend
Always remove the `sidebarMoving` CSS class when the sidebar is closed
2022-04-14 20:47:49 +02:00
Tim van der Meij
c4336808fe
Merge pull request #14769 from Snuffleupagus/cleanup-media-840px
Remove unnecessary `@media` CSS rules (PR 8993 follow-up)
2022-04-14 20:41:59 +02:00
Jonas Jenwald
e67cd7fae0 Replace the --viewport-scale-factor CSS variable
This CSS variable is only used together with the `annotationCanvasMap`-functionality in the canvas-code, however its value can be *trivially* computed by using the older `--zoom-factor` CSS variable together with the `PixelsPerInch`-structure.
Rather than having *two different* CSS variables that are this closely linked, it seems better to simplify things by using just one CSS variable instead.
2022-04-14 12:43:57 +02:00
Jonas Jenwald
11b30c974e Remove some dropdownToolbarButton-related CSS rules
According to the CSS, there should be a visible "divider" after the "Page Width" zoom-option. However, this is being ignored in both Mozilla Firefox[1] and Google Chrome hence the rule is effectively useless now.
Furthermore, the "custom" zoom-option is already being `hidden` using the attribute (in the HTML code) and there should thus be no reason to duplicate this in the CSS as well.

---
[1] Support for *detailed* styling of `<select>`-elements was removed as part of the E10s project.
2022-04-12 16:05:23 +02:00
Jonas Jenwald
3752b8975b Reduce (some) duplication in the CSS rules for the sidebarViews
With just a couple of exceptions, for the `thumbnailView`, all of the sidebarViews share the same basic styling which thus allows for some simplification.
2022-04-12 13:51:50 +02:00
Jonas Jenwald
f788035a58 Remove unnecessary min-width CSS rules
- For the findbar/secondaryToolbar case, the `min-width` rule doesn't really make sense since it's way too small to be useful. Furthermore, the findbar is already specifying its own `min-width` and the secondaryToolbar will (thanks to its buttons) receive a correct/useful width.

 - The pageNumber-input already has an *explicit* `width` set, hence setting the `min-width` rule as well is completely unnecessary.

 - The treeItem-links are supposed to *compute* their `min-width`, and the static value was only added as a fallback for older browsers without `calc()` support.
2022-04-12 13:51:45 +02:00
Jonas Jenwald
93c5c6e5e9 Use background-color rather than background in a few CSS rules
In a couple of spots, mostly related to the debugging tools, we're unnecessarily using a somewhat "complex" `background`-format only to specify a solid color. This can be simplified by using `background-color` instead, and the patch also removes a `color`-rule that's being ignored anyway.
2022-04-12 12:41:34 +02:00
Jonas Jenwald
3aed103ce8 Simplify the dialog::backdrop CSS rules (PR 14710 follow-up)
After the changes in https://bugzilla.mozilla.org/show_bug.cgi?id=1761839, we no longer need this CSS work-around to prevent the entire `<dialog>` contents from becoming selected when the backdrop is clicked.
2022-04-12 12:41:29 +02:00
Jonas Jenwald
0fbe5832ab Always remove the sidebarMoving CSS class when the sidebar is closed
When the viewer becomes narrow enough that the sidebar is overlaying the document, which means that the `viewerContainer` is not moving when opening/closing the sidebar, we're currently not removing the `sidebarMoving` CSS class as intended.
While this doesn't cause any *visible* issues, it's nonetheless wrong and should be fixed.
2022-04-11 19:46:10 +02:00
Jonas Jenwald
0a83538e64 Remove unnecessary @media CSS rules (PR 8993 follow-up)
With the changes in PR 8993, a number of the `@media`-related CSS rules became unnecessary. However, it appears that some of these rule were *accidentally* left behind despite being unused now.
Note that previously, when opening the sidebar shifted the position of the main toolbar, we had to take both the sidebar opened *and* closed cases into account in these `@media` rules.
2022-04-11 10:08:48 +02:00
Tim van der Meij
143ba30bef
Merge pull request #14767 from Snuffleupagus/fileInput-refactor
[GENERIC viewer] Re-factor the `fileInput` initialization
2022-04-10 15:07:08 +02:00
Tim van der Meij
8f26e70cf1
Merge pull request #14765 from Snuffleupagus/requestFullscreen-Promise
Simplify handling of `requestFullscreen` errors in `PDFPresentationMode`
2022-04-10 15:01:08 +02:00
Tim van der Meij
cdb3481d6c
Merge pull request #14764 from apeltop/correct-typos
Correct typos
2022-04-10 14:55:08 +02:00
Jonas Jenwald
07ac5c337f [GENERIC viewer] Remove some, now unnecessary, checks used with fileInput
According to the MDN compatibility data, see below, all of these features have been supported for years and years in all browsers. Looking closely at the data, the most likely reason for adding these checks in the first place was for IE 9 compatibility (since we originally "supported" that browser).

 - https://developer.mozilla.org/en-US/docs/Web/API/File#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/FileReader#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/FileList#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/Blob#browser_compatibility
2022-04-10 12:50:35 +02:00
calixteman
2c135b02e0
Merge pull request #14766 from calixteman/mask2
Improve performance of applyMaskImageData
2022-04-09 22:48:28 +02:00
Calixte Denizet
687c9a8710 Improve performance of applyMaskImageData
- write some uint32 instead of uint8 to avoid the check before clamping;
- unroll the loop to write data in the buffer
- but keep a loop for the last element of a line: it likely doesn't hurt
  that much since it's executed only for one time for each line;
- I tested on a macbook with an Apple chip, and on Firefox nightly the new
  code is almost 3.5x faster than before (~1.8x with Chrome).
2022-04-09 22:19:02 +02:00
Jonas Jenwald
5390d2b377 [GENERIC viewer] Re-factor the fileInput initialization
*This is yet another installment in a never-ending series of patches that attempt to simplify and improve old code.*

The `fileInput`-element is used to support the "Open file"-button in the `GENERIC` viewer, however this is very old code.
Rather than creating the element dynamically in JavaScript, we can simply define it conditionally in the HTML code thanks to the pre-processor. Furthermore, the `fileInput`-element currently has a number of unnecessary CSS rules, since the element is *purposely* never made visibly.

Note that with these changes, the `fileInput`-element will now *always* have `display: none;` set. This shouldn't matter, since we can still trigger the `click`-event of the element just fine (via JavaScript) and this patch has been successfully tested in both Mozilla Firefox and Google Chrome.
2022-04-09 21:21:18 +02:00
calixteman
08e1abe68e
Merge pull request #14754 from calixteman/smask
Improve performance with image masks (bug 857031)
2022-04-09 20:04:51 +02:00
Calixte Denizet
040fcae5ab Improve performance with image masks (bug 857031)
- it aims to partially fix performance issue reported: https://bugzilla.mozilla.org/show_bug.cgi?id=857031;
- the idea is too avoid to use byte arrays but use ImageBitmap which are a way faster to draw:
  * an ImageBitmap is Transferable which means that it can be built in the worker instead of in the main thread:
    - this is achieved in using an OffscreenCanvas when it's available, there is a bug to enable them
      for pdf.js: https://bugzilla.mozilla.org/show_bug.cgi?id=1763330;
    - or in using createImageBitmap: in Firefox a task is sent to the main thread to build the bitmap so
      it's slightly slower than using an OffscreenCanvas.
  * it's transfered from the worker to the main thread by "reference";
  * the byte buffers used to create the image data have a very short lifetime and ergo the memory used is globally
    less than before.
- Use the localImageCache for the mask;
- Fix the pdf issue4436r.pdf: it was expected to have a binary stream for the image;
- Move the singlePixel trick from operator_list to image: this way we can use this trick even if it isn't in a set
  as defined in operator_list.
2022-04-09 18:26:26 +02:00
Jonas Jenwald
bde6d9ffba Re-factor how PDFPresentationMode, internally, tracks the current PresentationModeState
With the changes in the previous patch, we can simplify the state-tracking by using the `PresentationModeState`-values directly in the `PDFPresentationMode` class.
2022-04-09 12:20:11 +02:00
Jonas Jenwald
8d61b7c088 Simplify handling of requestFullscreen errors in PDFPresentationMode
Since quite some time the `Element.requestFullscreen()` method has been returning a Promise, see https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#return_value
Hence we can utilize that to detect failures to enter fullscreen-mode, and remove our old `setTimeout`-based hacks that were used for this purpose.

According to the MDN compatibility data, see https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#browser_compatibility, all browsers that we support have implemented this functionality. (Note that after PR 14606, we no longer support PresentationMode in Safari.)
2022-04-09 12:12:50 +02:00
apeltop
a97dd26389 Correct typos 2022-04-09 09:43:18 +09:00
Tim van der Meij
2b673a6941
Merge pull request #14750 from Snuffleupagus/rm-_getCurrentVisiblePage
Remove the `BaseViewer._getCurrentVisiblePage` helper method
2022-04-08 20:05:51 +02:00
Tim van der Meij
106b69a101
Merge pull request #14751 from Snuffleupagus/isLittleEndian-isEvalSupported
Re-factor the `isLittleEndian`/`isEvalSupported` caching
2022-04-08 20:02:23 +02:00
Jonas Jenwald
497c0610cd
Merge pull request #14761 from Snuffleupagus/viewer-more-optional-chaining
Use a bit more optional chaining in the viewer
2022-04-07 16:44:08 +02:00
Jonas Jenwald
bb25b6dec5 Use a bit more optional chaining in the viewer 2022-04-07 16:20:41 +02:00
Jonas Jenwald
a919959d83 Slightly simplify the Catalog._readMarkInfo method
We don't need to first check if the Dictionary contains the key, since trying to get a non-existent key simply returns `undefined` and we're already ensuring that the value is a boolean.
Furthermore, we shouldn't need to worry about the `Object.prototype` containing enumerable properties since the checks (in `src/core/worker.js`) done for `Array.prototype` *indirectly* also cover `Object`s. (Keep in mind that an `Array` is just a special kind of `Object` in JavaScript.)
2022-04-05 16:37:51 +02:00
Jonas Jenwald
1dc4713a0b Re-factor the isLittleEndian/isEvalSupported caching
This functionality is very old, hence we should be able to improve the caching a little bit with modern JavaScript features.
2022-04-05 16:01:01 +02:00
Jonas Jenwald
55838303c7 Tweak the pdfOpenParams parameter, in the "updateviewarea" event, in PresentationMode
The `pdfOpenParams` parameter has never really made sense in PresentationMode, since e.g. the zoom-value doesn't (generally) agree with the value chosen by the user prior to entering PresentationMode.
This has never mattered all that much, since the `viewBookmark`-button isn't visible in PresentationMode (nor is any other toolbar button for that matter). However, in the `PDFHistory`-implementation we're currently forced to handle this case specifically since we don't want to populate the browser history with nonsensical state.
Hence it makes overall sense, as far as I'm concerned, to tweak the "updateviewarea" event to include a *simplified* `pdfOpenParams` parameter when PresentationMode is active. Given that the `viewer components` don't include PresentationMode functionality, this change thus shouldn't matter for third-party users.
2022-04-05 14:13:20 +02:00
Jonas Jenwald
5ef294b3a7 Remove the BaseViewer._getCurrentVisiblePage helper method
This method was originally added specifically to work-around bugs/issues related to PresentationMode in Google Chrome. Note that prior to PR 14112 we were using some CSS hacks to only show the current page in PresentationMode, and that could lead to the `getVisibleElements` function not always finding the correct elements.
However, after the changes in PR 14112 we're now using the Page-scrolling mode in PresentationMode and consequently there'll only be *a single* page visible at a time. Hence then `BaseViewer._getCurrentVisiblePage` helper method should no longer be needed, and when testing (locally) in Google Chrome everything seems to work correctly now.
2022-04-05 13:32:09 +02:00
Jonas Jenwald
27e738dff9
Merge pull request #14663 from Snuffleupagus/issue-14525
[GENERIC viewer] Try to improve a11y, for search results, in the findbar (issue 14525)
2022-04-04 19:10:55 +02:00
calixteman
45553d60f8
Merge pull request #14739 from calixteman/14685_fw
Refactor some xfa*** getters in document.js
2022-04-03 21:14:17 +02:00
Calixte Denizet
f4fcb59a5e Refactor some xfa*** getters in document.js
- it's a follow-up of PR #14735.
2022-04-03 20:38:12 +02:00
Tim van der Meij
3e50e578c2
Merge pull request #14745 from Snuffleupagus/debugger-module
Convert `web/debugger.js` to a *basic* module
2022-04-03 14:51:51 +02:00
Tim van der Meij
94e51f9883
Merge pull request #14744 from timvandermeij/updates
Update GitHub Actions workflow steps/dependencies/translations to the most recent versions
2022-04-03 14:44:36 +02:00
Jonas Jenwald
8fa73dbfab Convert web/debugger.js to a *basic* module
The various functionality in `web/debugger.js` is currently *indirectly* added to the global scope, since that's how `var` works when it's used outside of any functions/closures.
Given how this functionality is being accessed/used, not just in the viewer but also in the API and textLayer, simply converting the entire file to a module isn't trivial[1]. However, we can at least export the `PDFBug`-part properly and then `import` that dynamically in the viewer.
Also, to improve the code a little bit, we're now *explicitly* exporting the necessary functionality globally.

According to MDN, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility, all the browsers that we now support have dynamic `imports` implementations.

---
[1] We could probably pass around references to the necessary functionality, but given how this is being used I'm just not sure it's worth the effort. Also, adding *official* support for these viewer-specific debugging tools in the API feels both unnecessary and unfortunate.
2022-04-03 14:30:26 +02:00
Tim van der Meij
312595eb47
Update translations to the most recent versions 2022-04-02 19:43:34 +02:00