Commit Graph

16746 Commits

Author SHA1 Message Date
Calixte Denizet
f80880ccaa Strip out a reserved operator (9) from CFF char strings (fixes issue #15784) 2022-12-16 15:17:46 +01:00
Jonas Jenwald
0c83bebf03
Merge pull request #15832 from Snuffleupagus/issue-15828
Attempt to expose `OnProgressParameters` in the TypeScript definitions (issue 15828)
2022-12-16 12:44:29 +01:00
Jonas Jenwald
0289038961 [GeckoView] Ignore the pageLayout, from the PDF document, to prevent issues
First of all, given the screen-sizes of most mobile phones using Spread modes is unlikely to be useful.
Secondly, and more importantly, since there's (currently) no UI available for the user to override a PDF document-specified Spread mode this would result in a bad UX otherwise.

Also, removes an outdated comment from the `apiPageLayoutToViewerModes` helper function.
2022-12-16 12:09:56 +01:00
Jonas Jenwald
b518d93b45
Merge pull request #15835 from Snuffleupagus/viewer-safe-element-access
Protect a few additional DOM element accesses in the viewer (PR 15831 follow-up)
2022-12-15 19:48:13 +01:00
Jonas Jenwald
4bd66a2150 Protect a few additional DOM element accesses in the viewer (PR 15831 follow-up)
A couple of cases that I missed during review, for code-paths that don't run by default in the viewer.
2022-12-15 18:48:10 +01:00
Jonas Jenwald
826c358b3a
Merge pull request #15834 from Snuffleupagus/issue-15833
Always parse the entire `startXRefQueue` in `XRef.readXRef` (issue 15833)
2022-12-15 16:48:14 +01:00
calixteman
0021d65dc0
Merge pull request #15831 from calixteman/android_viewer
[GV] Add a viewer for GeckoView
2022-12-15 15:45:26 +01:00
Jonas Jenwald
26135b0313 Always parse the entire startXRefQueue in XRef.readXRef (issue 15833)
Previously we'd abort all parsing if an Error was encountered, despite the fact that multiple `startXRefQueue`-entries may be available and that continued parsing could thus eventually be able to find usable data.

Note that in the referenced PDF document the `startxref`-operator, at the end of the file, points to a position in the middle of an arbitrary `stream` which is why things break.
2022-12-15 13:46:28 +01:00
Calixte Denizet
f19572c4cc [GV] Add a viewer for GeckoView 2022-12-15 13:39:48 +01:00
Jonas Jenwald
8587ce6afd
Merge pull request #15829 from calixteman/dont_remove_spinner
Don't remove the loading icon from the DOM when a page is resetted
2022-12-15 10:31:21 +01:00
Calixte Denizet
20037e9919 Don't remove the loading icon from the DOM when a page is resetted 2022-12-15 10:19:49 +01:00
Jonas Jenwald
0ef72044e2 Attempt to expose OnProgressParameters in the TypeScript definitions (issue 15828)
Hopefully this works, since as usual I don't really know anything about TypeScript...
2022-12-14 21:36:31 +01:00
Jonas Jenwald
506bbb7283
Merge pull request #15825 from Snuffleupagus/cancel-extraDelay
[api-minor] Allow specifying an extra-delay, in `RenderTask.cancel`, for worker-thread aborting of operatorList parsing
2022-12-14 19:26:39 +01:00
Jonas Jenwald
d90e62e806
Merge pull request #15824 from Snuffleupagus/annotationLayer-params
Handle possibly undefined parameters *once* per `AnnotationLayer.render` invocation
2022-12-14 15:16:56 +01:00
Jonas Jenwald
68f36d82d5
Merge pull request #15826 from Snuffleupagus/lazy-textHighlighter
Initialize the `TextHighlighter`-instance lazily in `PDFPageView`
2022-12-14 14:17:34 +01:00
Jonas Jenwald
8ac94d6519 Initialize the TextHighlighter-instance lazily in PDFPageView
Depending on e.g. the `textLayerMode` option it might not actually be necessary to always initialize this eagerly.
*Please note:* Unfortunately we cannot `shadow` a private field, hence why this is only made semi-"private".
2022-12-14 13:23:05 +01:00
Jonas Jenwald
5df341ed7e Make the various layer-render methods, in PDFPageView, properly private 2022-12-14 13:12:49 +01:00
Jonas Jenwald
91524d1a60 [api-minor] Allow specifying an extra-delay, in RenderTask.cancel, for worker-thread aborting of operatorList parsing
This is done to support upcoming viewer-changes, and in order to prevent third-party users from outright breaking things we'll simply ignore too large values.
2022-12-14 12:34:16 +01:00
Jonas Jenwald
dcf9ff2182 Handle possibly undefined parameters *once* per AnnotationLayer.render invocation
There's no reason to repeat this for every single annotation. Also, adds a couple of missing JSDoc-parameters.
2022-12-14 12:23:24 +01:00
calixteman
e182597cb1
Merge pull request #15822 from calixteman/15818
[JS] Run the named actions before running the format when the file is open (issue #15818)
2022-12-13 21:56:50 +01:00
Calixte Denizet
2ebf8745a2 [JS] Run the named actions before running the format when the file is open (issue #15818)
It's a follow-up of #14950: some format actions are ran when the document is open
but we must be sure we've everything ready for that, hence we have to run some
named actions before runnig the global format.
In playing with the form, I discovered that the blur event wasn't triggered when
JS called `setFocus` (because in such a case the mouse was never down). So I removed
the mouseState thing to just use the correct commitKey when blur is triggered by a
TAB key.
2022-12-13 21:12:32 +01:00
calixteman
2d596045d1
Merge pull request #15819 from calixteman/15815
[JS] Handle correctly choice widgets where the display and the export values are different (issue #15815)
2022-12-13 19:40:23 +01:00
Calixte Denizet
0c1ec946aa [JS] Handle correctly choice widgets where the display and the export values are different (issue #15815) 2022-12-13 19:08:26 +01:00
calixteman
64786b4c93
Merge pull request #15820 from calixteman/fix_visual_order
The annotation layer dimensions must be set before adding some elements (follow-up of #15770)
2022-12-13 15:54:47 +01:00
Calixte Denizet
1a397681fe The annotation layer dimensions must be set before adding some elements (follow-up of #15770)
In order to move the annotations in the DOM to have something which corresponds
to the visual order, we need to have their dimensions/positions which means that
the parent must have some dimensions.
2022-12-13 14:54:45 +01:00
Jonas Jenwald
0fdac9ba70
Merge pull request #15797 from Snuffleupagus/PageViewport-rawDims
[api-minor] Add a new `PageViewport`-getter to access the original, un-scaled, viewport dimensions
2022-12-12 11:12:38 +01:00
Jonas Jenwald
cafdc48147 [api-minor] Add a new PageViewport-getter to access the original, un-scaled, viewport dimensions
While reviewing recent patches, I couldn't help but noticing that we now have a lot of call-sites that manually access the `PageViewport.viewBox`-property.
Rather than repeating that verbatim all over the code-base, this patch adds a lazily computed and cached getter for this data instead.
2022-12-11 18:37:35 +01:00
Jonas Jenwald
8e11cf9b1c
Merge pull request #15806 from Snuffleupagus/AnnotationLayerBuilder-no-annotations
Don't attempt to re-create the `annotationLayer`, for pages without any annotations, on zooming and rotation
2022-12-11 18:32:24 +01:00
Jonas Jenwald
9b6d0d994d Remove the API-caching of annotation-data
This was essentially done only to compensate for the viewer calling `PDFPageProxy.getAnnotations` unconditionally on every annotationLayer-rendering invocation. With the previous patch that's no longer happening, and this API-caching should thus no longer be necessary.
2022-12-11 18:12:10 +01:00
Jonas Jenwald
8e56f072e0 Don't attempt to re-create the annotationLayer, for pages without any annotations, on zooming and rotation
For pages without any annotations, applies e.g. to the `tracemonkey.pdf` document, we'll repeatedly try to re-create the `annotationLayer` on every zoom and rotation operation.
The reason that this happens is because we don't insert the `annotationLayer`-div into the DOM unless there's annotations present on the page, which thus means that we miss the existing `annotationLayer`-caching present in the `PDFPageView` implementation.

This is a very old issue, and the easiest solution is to simply always insert an *empty* (and hidden) `annotationLayer`-div such that the existing code/caching starts working for the "no annotations" case as well.
Note that this is consistent with other layers, since e.g. the `textLayer` and/or `annotationEditorLayer` may be empty. Given that only a limited, by default ten, number of pages are ever active at once the additional DOM-elements shouldn't effect things negatively here.
2022-12-11 18:12:09 +01:00
calixteman
d9f13558d6
Merge pull request #15770 from calixteman/set_dims
Set the dimensions of the various layers at their creation
2022-12-11 17:32:29 +01:00
Tim van der Meij
6c2f34b6bb
Merge pull request #15805 from Snuffleupagus/XfaLayerBuilder-render-async
Change the `XfaLayerBuilder.render` method to be asynchronous
2022-12-11 14:02:45 +01:00
Jonas Jenwald
828efd9d00 Change the XfaLayerBuilder.render method to be asynchronous
This is consistent with the `render` methods of the other layers, and reduces overall indentation in the method.
Furthermore, don't "swallow" errors since the `PDFPageView._renderXfaLayer` method is already able to deal with that.
2022-12-11 13:08:23 +01:00
Jonas Jenwald
879a7432b5
Merge pull request #15800 from Snuffleupagus/AnnotationEditorLayerBuilder-destroy
[AnnotationEditorLayerBuilder] Inline the `destroy` code in the `cancel` method
2022-12-10 15:02:43 +01:00
Calixte Denizet
a989b5a879 Set the dimensions of the various layers at their creation
- Use a unique helper function in display/display_utils.js;
- Move those dimensions in css' side.
2022-12-10 14:35:06 +01:00
Jonas Jenwald
bed1a1baa1 [AnnotationEditorLayerBuilder] Inline the destroy code in the cancel method
It doesn't seem necessary to have a *separate* `destroy` method given that the `cancel` method always invokes it unconditionally.
In the `PDFPageView.reset` method we currently attempt to call `destroy` directly, however that'll never actually happen since either:
 - We're keeping the annotationEditorLayer, in which case we're just hiding the layer and nothing more (and the relevant branch is never entered).
 - We're removing the annotationEditorLayer, in which case the `PDFPageView.cancelRendering` method has already cancelled *and* nulled it (and there's thus nothing left to `destroy` here).

*Please note:* Hopefully I'm not overlooking something obvious here, since both reading through the code *and* also adding `console.log(this.annotationEditorLayer);` [before this line](9d4aadbf7a/web/pdf_page_view.js (L438)) suggests that it's indeed unnecessary.
2022-12-10 10:16:20 +01:00
Jonas Jenwald
9d4aadbf7a
Merge pull request #15796 from Snuffleupagus/issue-15795
Ensure that the various layers always get the correct initial size (issue 15795)
2022-12-09 17:26:35 +01:00
Jonas Jenwald
527258c316 Ensure that the various layers always get the correct initial size (issue 15795) 2022-12-09 14:30:12 +01:00
Jonas Jenwald
3155e2a63b
Merge pull request #15798 from Snuffleupagus/PresentationMode-spreadMode-hPadding
Fix page-switching for landscape documents with SpreadModes and PresentationMode (PR 14877 follow-up)
2022-12-09 14:19:09 +01:00
Jonas Jenwald
47ac706972 Fix page-switching for landscape documents with SpreadModes and PresentationMode (PR 14877 follow-up)
In PR 14877 I forgot to update the horizontal padding, used when computing the scale of the pages, for the case where SpreadModes and PresentationMode are being used together.

Steps to reproduce:
 1. Open the viewer with the default `tracemonkey.pdf` document.
 1. Enable any SpreadMode.
 2. Rotate the document *once*, either clockwise or counterclockwise.
 3. Enter PresentationMode.
 4. Try swithching page, e.g. by clicking on the document.

Expected result:
 The visible pages change as you click.

Actual result:
 The visible pages are "stuck" in the current view.
2022-12-09 14:09:56 +01:00
Jonas Jenwald
ba2fec9891
Merge pull request #15788 from Snuffleupagus/web-small-fixes
A few small viewer-related fixes
2022-12-08 18:05:37 +01:00
calixteman
baff5ad565
Merge pull request #15791 from calixteman/15789
[Editor] Take all the viewBox into account when computing the coordinates of an annotation in the page (fixes #15789)
2022-12-08 15:45:36 +01:00
Jonas Jenwald
d7d21f0d6e Change AnnotationEditorLayerBuilder.render to not access "private" API functionality
The `PDFPageProxy._pageIndex` property is a "private" one that shouldn't be accessed, since it could theoretically break tomorrow if we re-factor the relevant API code.

Also, try to clean-up and improve consistency in a couple of JSDoc comments.
2022-12-08 15:40:04 +01:00
Jonas Jenwald
6a5c1343f8 Stop trying to disable searching in PresentationMode
This change was made in PR 5552, however I cannot tell why we needed to disable searching in PresentationMode. Furthermore, with the changes in PR 13908 which effectively moved where this code is invoked, searching has now (accidentally) been working in PresentationMode in e.g. the Firefox PDF Viewer for well over a year.

So, let's just enable searching unconditionally in PresentationMode to simplify the code.
2022-12-08 15:33:57 +01:00
Calixte Denizet
4f0bfabe7a Take all the viewBox into account when computing the coordinates of an annotation in the page (fixes #15789) 2022-12-08 15:02:20 +01:00
calixteman
fe3df4dcb4
Merge pull request #15782 from calixteman/15780
[api-minor][Editor] Don't use the editor parent which can be null.
2022-12-08 14:27:42 +01:00
Calixte Denizet
b93bf9f654 [Editor] Don't use the editor parent which can be null.
An annotation editor layer can be destroyed when it's invisible, hence some
annotations can have a null parent but when printing/saving or when changing
font size, color, ... of all added annotations (when selected with ctrl+a) we
still need to have some parent properties especially the page dimensions, global
scale factor and global rotation angle.
This patch aims to remove all the references to the parent in the editor instances
except in some cases where an editor should obviously have one.
It fixes #15780.
2022-12-08 14:06:06 +01:00
Jonas Jenwald
c639063050
Merge pull request #15776 from Snuffleupagus/rm-createDownloadManager-options
Remove the unused `DefaultExternalServices.createDownloadManager` options (PR 12191 follow-up)
2022-12-07 10:31:15 +01:00
Jonas Jenwald
0ca92bf2a8
Merge pull request #15775 from Snuffleupagus/vars-all
Tighten the `vars`-argument for the ESLint `no-unused-vars` rule
2022-12-07 10:30:47 +01:00
calixteman
feb6f5951c
Merge pull request #15786 from calixteman/15780_bis
[Editor] Add a very basic and incomplete workaround for issue #15780
2022-12-06 19:11:33 +01:00