Commit Graph

16816 Commits

Author SHA1 Message Date
Calixte Denizet
409c8b344f [GV] Remove print stuff because window.print isn't implemented (bug 1808668) 2023-01-05 13:02:29 +01:00
calixteman
7da591048c
Merge pull request #15892 from calixteman/fix_autoprint
[JS] UserActivation must be enabled before running document actions
2023-01-04 21:50:29 +01:00
Calixte Denizet
dea2471e96 [JS] UserActivation must be enabled before running document actions
else auto-print is broken (it's a regression from patch #15822).
2023-01-04 21:26:36 +01:00
Jonas Jenwald
1e1a2fce49
Merge pull request #15891 from Snuffleupagus/accumulateTicks
Reduce duplication in the `accumulateWheelTicks`/`accumulateTouchTicks` methods (PR 15886 follow-up)
2023-01-04 19:30:47 +01:00
Jonas Jenwald
66a3aa28fd Reduce duplication in the accumulateWheelTicks/accumulateTouchTicks methods (PR 15886 follow-up)
It just occurred to me that we can reduce some duplication by having the, virtually identical, `accumulateWheelTicks`/`accumulateTouchTicks` methods use a common helper instead that takes advantage of [bracket notation](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics#bracket_notation).
2023-01-04 18:19:39 +01:00
calixteman
4faf927030
Merge pull request #15886 from calixteman/pinch_to_zoom
[api-minor] Add the pinch-to-zoom feature (bug 1677933)
2023-01-04 17:20:29 +01:00
Calixte Denizet
d6b7a1f034 [api-minor] Add the pinch-to-zoom feature (bug 1677933) 2023-01-04 16:00:46 +01:00
Jonas Jenwald
da1365a309
Merge pull request #15885 from Snuffleupagus/font-update-type-subtype
Update the `type`/`subtype` at the end of font parsing
2023-01-02 17:18:05 +01:00
Jonas Jenwald
6bdbb5c5ca Update the type/subtype at the end of font parsing
This fixes a warning reported by CodeQL, and should also make general sense given that we parse the font-data to determine the *actual* `type`/`subtype` rather than trusting the PDF document.
2023-01-02 16:21:48 +01:00
Jonas Jenwald
42aa08563b
Merge pull request #15880 from Snuffleupagus/rm-docStats
[api-minor] Remove the `PDFDocumentProxy.stats` getter (PR 15758 follow-up)
2023-01-02 16:03:53 +01:00
Jonas Jenwald
1ba6e9437c
Merge pull request #15884 from Snuffleupagus/enable-defaultZoomDelay
Enable the `defaultZoomDelay` option/preference unconditionally, and other (small) improvements
2023-01-02 15:38:29 +01:00
Calixte Denizet
685b5866e4 Remove shadow around each pages (fix issue #15836) 2023-01-02 14:58:53 +01:00
Jonas Jenwald
9089e75cce Validate the options before adding the ResizeObserver in the PDFViewer constructor (PR 15830 follow-up)
In the GENERIC viewer, it doesn't make sense to register the `ResizeObserver` if the `container`/`viewer` options are not valid.
2023-01-02 14:52:00 +01:00
Jonas Jenwald
0860a5b168 Ensure that a document is loaded in PDFViewer.{increaseScale, decreaseScale} (PR 14053 follow-up)
This was always "wrong", since these methods (just like all the zoom-related ones) don't make sense unless there's an active document.
2023-01-02 14:05:33 +01:00
Jonas Jenwald
9f50b0af37 Enable the defaultZoomDelay option/preference unconditionally (PR 15812 follow-up)
This option/preference was disabled in GENERIC builds, see PR 15812, to avoid landing it *just before* a new release. Hence it should be fine to enable this now.
2023-01-02 14:00:16 +01:00
calixteman
e7cea29ad4
Merge pull request #15883 from calixteman/infinite_loop_search_diacritic
Avoid an infinite loop when searching for a single diacritic
2023-01-02 13:13:32 +01:00
Calixte Denizet
69c88477a9 Avoid an infinite loop when searching for a single diacritic 2023-01-02 12:27:07 +01:00
Jonas Jenwald
1a69d537c1 [api-minor] Limit the PDFDocumentLoadingTask.onUnsupportedFeature functionality to GENERIC builds (PR 15758 follow-up)
This was deprecated in PR 15758 but it's unfortunately quite difficult to tell if third-party users are depending on this, e.g. to implement custom error reporting, and if so to what extent.
However, thanks to the pre-processor we can limit *most* of this code to GENERIC builds which still seem like a worthwhile change.

These changes reduce the bundle size of the Firefox PDF Viewer by 3.8 kB in total.
2023-01-01 17:53:12 +01:00
Jonas Jenwald
0c1fb4e740 [api-minor] Remove the PDFDocumentProxy.stats getter (PR 15758 follow-up)
This was deprecated in PR 15758 and given that it's quite unlikely that any third-party users are relying on this functionality, since it was only ever added to support telemetry reporting in the Firefox PDF Viewer, it should hopefully be fine to remove this fairly quickly.

These changes reduce the bundle size of the Firefox PDF Viewer by 4.5 kB in total.
2023-01-01 17:06:47 +01:00
Jonas Jenwald
2c57a4232c [api-minor] Improve the useWorkerFetch default value checks
Given that the Fetch API only supports the http/https protocols, worker-thread fetching of CMaps and Standard-fonts may thus fail in certain cases. To improve the default behaviour we'll now also check that the `cMapUrl` and `standardFontDataUrl` options are appropriate, except in Firefox where this should always work.
2023-01-01 14:48:28 +01:00
Tim van der Meij
1e3e2defe4
Merge pull request #15878 from timvandermeij/bump
Bump versions in `pdfjs.config`
2023-01-01 14:44:41 +01:00
Tim van der Meij
195846a716
Bump versions in pdfjs.config 2023-01-01 14:35:58 +01:00
Tim van der Meij
3fd2a35482
Merge pull request #15874 from Snuffleupagus/progressBar-decouple-colors
Decouple the loadingBar `background-color` from the rest of the viewer
2022-12-31 15:14:59 +01:00
Jonas Jenwald
c791e01bfc
Merge pull request #15875 from Snuffleupagus/viewer-name-consistency
Improve name consistency in the viewer (PR 15812 follow-up)
2022-12-29 11:52:25 +01:00
Jonas Jenwald
88432a0e3f Improve name consistency in the viewer (PR 15812 follow-up)
This tweaks a few name that originated in PR 15812, to improve overall consistency:
 - Use the `drawingDelay` parameter-name in all methods that accept a delay.
 - Use the `postponeDrawing` variable-name in all relevant methods.
2022-12-28 13:26:01 +01:00
Jonas Jenwald
c2d17cac34 [GeckoView] Remove the progressBar CSS variables, since they're unused
Given that there's no loadingBar element present in the GeckoView-viewer, we shouldn't need CSS variables for it.
2022-12-28 12:14:22 +01:00
Jonas Jenwald
49c09eda9b Decouple the loadingBar background-color from the rest of the viewer
With upcoming background changes elsewhere in the viewer, this should be helpful in separating the styling of the loadingBar. These changes also means that both the "regular" and the "indeterminate" loadingBar now uses the same `background-color` value.

Also, shortens the related CSS variables a little bit since that can't hurt.
2022-12-28 12:07:39 +01:00
Jonas Jenwald
35ca6ab319
Merge pull request #15867 from Snuffleupagus/loadingIcon-toggle
Only display the loadingIcons when rendering is currently running
2022-12-27 13:51:20 +01:00
Jonas Jenwald
4224984525 Only display the pageNumber-loadingIcon when rendering is currently running
*This makes the same kind of changes as in the previous patch, but for the pageNumber-loadingIcon in the main toolbar.*

To display the pageNumber-loadingIcon when rendering starts, if the page is the most visible one, we'll utilize the existing "pagerender" event.
To toggle the pageNumber-loadingIcon as the user moves through the document we'll now instead utilize the "pagechanging" event, which should actually be slightly more efficient overall[1]. Note how we'd, in the old code, only consider the most visible page anyway when toggling the pageNumber-loadingIcon.

---
[1] Even in a PDF document as relatively short/simple as `tracemonkey.pdf`, scrolling through the entire document can easily trigger the "updateviewarea" event more than a thousand times.
2022-12-27 13:28:39 +01:00
Jonas Jenwald
a578571f59 Only display the page-loadingIcon when rendering is currently running
Given that we only render one page at a time, this will lead to only *one* page-loadingIcon being displayed at a time even if multiple pages are visible in the viewer. However, this will make it clearer which page is the currently parsing/rendering one.

To simplify toggling of the page-loadingIcon visibility, the existing `PDFPageView.renderingState` is changed into a getter/setter-pair with the latter also handling the page-loadingIcon state.
An additional benefit of these changes is that the `PDFViewer` no longer needs to handling toggling of page-loadingIcon visibility during rendering, since there can only ever be *one* page rendering.
Finally, this may also simplify future changes w.r.t. page-loadingIcon visibility toggling (using e.g. a show-timeout).
2022-12-27 13:28:39 +01:00
Jonas Jenwald
3110d1f29a
Merge pull request #15869 from Snuffleupagus/_abortOperatorList-clearTimeout
Always abort a pending `streamReader` cancel timeout in `PDFPageProxy._abortOperatorList` (PR 15825 follow-up)
2022-12-27 13:26:43 +01:00
Jonas Jenwald
1dce95613a
Merge pull request #15870 from Snuffleupagus/rm-PDFPageProxy-getJSActions-caching
Remove `PDFPageProxy.getJSActions` caching, since it's unused, in the API
2022-12-27 13:25:24 +01:00
Jonas Jenwald
ec6ad91bb7
Merge pull request #15872 from Snuffleupagus/PDFPageView-setDimensions-regression
[Regression] Ensure that documents with varying page sizes are initialized correctly (PR 15812 follow-up)
2022-12-27 13:24:06 +01:00
Jonas Jenwald
05169efec1 [Regression] Ensure that documents with varying page sizes are initialized correctly (PR 15812 follow-up)
The rotation-caching added in PR 15812 completely breaks initialization of PDF documents with varying page sizes, causing all pages to wrongly get the same size; see e.g. `sizes.pdf` from the test-suite.
To fix that without having to e.g. add a new parameter, which feels error prone, this patch changes the `PDFPageView.#setDimensions` method to completely ignore the rotation-caching until the `setPdfPage`-method has been called.
2022-12-27 12:14:42 +01:00
Jonas Jenwald
841abb53e6 Remove PDFPageProxy.getJSActions caching, since it's unused, in the API
Note how, in the scripting initialization in the viewer, we only ever invoke `PDFPageProxy.getJSActions` *once* per page in order to improve overall performance; see a575aa13b9/web/pdf_scripting_manager.js (L372-L375)

Hence it really shouldn't be necessary to cache its result in the API, especially when that is done *manually* rather than using something like `shadow`.
2022-12-27 10:39:33 +01:00
Jonas Jenwald
ae24dbd064 Always abort a pending streamReader cancel timeout in PDFPageProxy._abortOperatorList (PR 15825 follow-up)
When we're destroying a `PDFPageProxy`-instance, during full document destruction, we'll force-abort any worker-thread parsing of operatorLists. Hence we should make sure that any pending cancel timeout is always aborted, since a later `PDFPageProxy._abortOperatorList` call should always "replace" a previous one.

*Please note:* Technically this was always wrong, but with the changes in PR 15825 it became *ever so slightly* easier to trigger this thanks to the potentially longer timeout.
2022-12-27 10:19:39 +01:00
calixteman
a575aa13b9
Merge pull request #15862 from calixteman/layers_zindex
Set a z-index for the different layers within a page (fixes #15861)
2022-12-26 23:14:21 +01:00
Calixte Denizet
c677b167b6 Set a z-index for the different layers within a page (fixes #15861)
Each layer has an absolute position, hence it induces the creation of
some stacking contexts (see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).
Thanks to this feature, we don't have to worry about the z-index used in
the annotation layer and how form elements interact with the other layers.
2022-12-26 22:55:08 +01:00
calixteman
e49dd525b0
Merge pull request #15812 from calixteman/refactor_zoom
Only redraw after zooming is finished (bug 1661253)
2022-12-26 19:44:03 +01:00
Calixte Denizet
663007a5c7 Only redraw after zooming is finished (bug 1661253)
Right now, the visible pages are redrawn for each scale change.
Consequently, zooming with mouse wheel or in pinching can be pretty janky
(even on a desktop machine but with a hdpi screen).
So the main idea in this patch is to draw the visible pages only once zooming
is finished.
2022-12-26 18:13:17 +01:00
Jonas Jenwald
31da2fad51
Merge pull request #15864 from Snuffleupagus/update-packages
Update packages and translations
2022-12-25 13:53:28 +01:00
Jonas Jenwald
3b02d23ce2 Update l10n files 2022-12-25 12:59:37 +01:00
Jonas Jenwald
492ce090bd Update npm packages 2022-12-25 12:59:34 +01:00
Jonas Jenwald
8aed0c3613
Merge pull request #15854 from Snuffleupagus/issue-15803
Re-factor searching for incomplete objects in `XRef.indexObjects` (issue 15803)
2022-12-24 10:23:39 +01:00
Jonas Jenwald
869807406d
Merge pull request #15860 from Snuffleupagus/loadingIcon-last
Ensure that the `loadingIconDiv` is always visible (PR 15829 follow-up)
2022-12-23 11:45:27 +01:00
Jonas Jenwald
d042a3ca76 Ensure that the loadingIconDiv is always visible (PR 15829 follow-up)
After the changes in PR 15829 the `loadingIconDiv` is no longer always visible when it should be, specifically in the case where we cancel and re-render a partially parsed/rendered page.
To reproduce this, try opening https://github.com/mozilla/pdf.js/files/1522715/wuppertal_2012.pdf in the viewer and change the zoom level while rendering is ongoing. In this case the `loadingIconDiv` doesn't actually become visible, despite being present in the DOM, since it's no longer at the end of the page-div.

I don't know to what extent this renders PR 15829 "pointless", however we're not repeatedly re-creating and re-inserting the `loadingIconDiv` but rather just *move* the existing element in the DOM.
2022-12-22 12:34:32 +01:00
Jonas Jenwald
a749f6cc14
Merge pull request #15852 from Snuffleupagus/layerProperties-followup
A couple of small viewer fixes (PR 15811 and 15831 follow-up)
2022-12-19 23:09:26 +01:00
Jonas Jenwald
2fcf8bb5be Re-factor searching for incomplete objects in XRef.indexObjects (issue 15803)
When trying to find incomplete objects, i.e. those missing the "endobj"-string at the end, there's unfortunately a number of possible operators that we need to check for. Otherwise we could miss e.g. the "trailer" at the end of a corrupt PDF document, which is why the referenced document didn't work.

Currently we do all searching on the "raw" bytes of the PDF document, for efficiency, however this doesn't really work when we need to check for *multiple* potential command-strings. To keep the complexity manageable we'll instead use regular expressions here, but we can at least avoid creating lots of substrings thanks to the `RegExp.lastIndex` property; which is well supported across browsers according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex#browser_compatibility

Note that this repeated regular expression usage could perhaps be slightly less efficient than the old code, however this method is only invoked for corrupt PDF documents.
2022-12-19 23:01:09 +01:00
Jonas Jenwald
f3d7f2e64f Fix the loadingBar initialization in the "mobile-viewer" example (PR 15831 follow-up)
Given that the `ProgressBar`-constructor was updated, we need to update the "mobile-viewer" example as well; this is yet another thing I missed during review.
2022-12-19 01:20:06 +01:00
Jonas Jenwald
e8c7278337 Improve the linkService handling in the DEFAULT_LAYER_PROPERTIES (PR 15811 follow-up)
We'll no longer import the `SimpleLinkService` dependency unconditionally in the file, since it's only used in COMPONENTS-builds.
Furthermore, for the COMPONENTS-builds, we'll create a `SimpleLinkService`-instance only for those layers that actually need it.
2022-12-19 01:04:04 +01:00