Commit Graph

15801 Commits

Author SHA1 Message Date
Tim van der Meij
135b9fbcfb
Merge pull request #14994 from Snuffleupagus/parseJbig2-conditional
Conditionally bundle `gulp image_decoders`-specific code in `src/core/jbig2.js` (PR 9729 follow-up)
2022-06-06 12:28:53 +02:00
calixteman
1816b5e926
Merge pull request #14993 from Snuffleupagus/editor-AnnotationStorage-hash
[editor] Update the `AnnotationStorage.hash`-getter to support editing
2022-06-05 18:48:29 +02:00
Jonas Jenwald
e82ad79eb9 Conditionally bundle gulp image_decoders-specific code in src/core/jbig2.js (PR 9729 follow-up)
This method/function was added only for the `gulp image_decoders`-builds, and is completely unused elsewhere (e.g. in the Firefox PDF Viewer).
While this only reduces the size of the *built* `pdf.worker.js` file by a little over 1 kB, it can't hurt to remove completely unused code from the "normal" builds.
2022-06-05 15:38:28 +02:00
Jonas Jenwald
51c47acb41 [editor] Update the AnnotationStorage.hash-getter to support editing
While calling `JSON.stringify(...)` on a class-instance obviously "works" (as in it doesn't throw), since it's really just an Object, it doesn't really make much sense in the context of the `AnnotationStorage.hash`-getter.

Also, access the *inverse* Viewport-transform correctly in `FreeTextEditor.serialize` to prevent errors being thrown when that method is invoked.

Finally, slightly updates the `AnnotationStorage.serializable`-getter to improve consistency within the class.
2022-06-05 14:05:44 +02:00
Jonas Jenwald
87fdb0eb42
Merge pull request #14992 from Snuffleupagus/issue-14990
Lookup image-data correctly in `paintImageMaskXObjectGroup` (issue 14990)
2022-06-05 13:29:56 +02:00
Jonas Jenwald
59dd4ea2b0 Lookup image-data correctly in paintImageMaskXObjectGroup (issue 14990)
*This fixes a regression from PR 14754.*

We didn't lookup the image-data correctly, with the result that we tried to render some ImageMasks using a string rather than the intended TypedArray. To make matters worse, this code-path was apparently not *properly* covered by existing test-cases.
2022-06-05 12:39:23 +02:00
calixteman
193a28431c
Merge pull request #14991 from Snuffleupagus/editor-XFA-disable
[editor] Disable the editor-buttons in XFA documents
2022-06-05 12:03:05 +02:00
Tim van der Meij
37f7995dde
Merge pull request #14984 from Snuffleupagus/dialog-polyfill-CSS
Bundle the `<dialog>` polyfill-CSS in the GENERIC `legacy/`-viewer (PR 14710 follow-up)
2022-06-05 11:18:18 +02:00
Jonas Jenwald
d34e7fff01 [editor] Disable the editor-buttons in XFA documents
Given the differences between XFA documents and "normal" PDF documents, we don't support editing of the former ones. Hence, when a XFA-document is opened, we temporarily disable the editor-buttons.
2022-06-05 10:00:08 +02:00
Jonas Jenwald
9b22483e00
Merge pull request #14985 from Snuffleupagus/editor-FreeText-followup
[editor] A couple of small FreeText-related fixes (PR 14976 follow-up)
2022-06-04 23:23:52 +02:00
Jonas Jenwald
a25d92fb17
Merge pull request #14988 from Snuffleupagus/rm-singlefile-comment
Remove mention of `gulp singlefile`-command from `examples/node/getinfo.js`
2022-06-04 23:20:29 +02:00
Jonas Jenwald
dd58671589 Remove mention of gulp singlefile-command from examples/node/getinfo.js
This comment should've been removed in PR 9385, but better late than never I suppose.
2022-06-04 23:10:58 +02:00
Jonas Jenwald
51bf928061 [editor] A couple of small FreeText-related fixes (PR 14976 follow-up)
- Ensure that the modified-warning won't be displayed, when navigating away from the viewer, if the user has added custom Annotations and then *removed all* of them.
 - Ensure that the *initial* editor-buttons state, i.e. the `toggled`-class, is correctly displayed in the toolbar when then viewer loads.
 - Tweak the CSS-classes for the editor-buttons, such that they use the correct focus/hover-rules (similar to the sidebar-buttons).
 - Remove a no longer accurate comment from the `BaseViewer.annotationEditorMode`-setter.
 - Address a couple of *smaller* outstanding review comments, including some re-formatting changes, from PR 14976.
2022-06-04 21:48:11 +02:00
calixteman
c8ef87197c
Merge pull request #14976 from calixteman/editor1
[editor] Add a FreeText editor (#14970)
2022-06-04 19:02:20 +02:00
Calixte Denizet
be1aa11986 [edition] Add a FreeText editor (#14970)
- add a basic UI to edit some text in a pdf;
- an editor can be moved, suppressed, cut, copied, pasted, selected;
- add an undo/redo manager.
2022-06-04 18:20:11 +02:00
Jonas Jenwald
bb8f5ec20b Bundle the <dialog> polyfill-CSS in the GENERIC legacy/-viewer (PR 14710 follow-up)
In PR 14710 we only included the JavaScript-part of the polyfill, however we probably need to include the CSS as well to reduce the risk of problems in older browsers.

With the recent CSS-related improvements in the `preprocess`-function we could probably have included this conditionally in the `viewer.css` file. However, considering that the `<dialog>` polyfill-code is only invoked when actually needed it seemed most appropriate/correct to lazy-load the polyfill-CSS as well.
2022-06-04 18:11:35 +02:00
Jonas Jenwald
1953967681
Merge pull request #14980 from Snuffleupagus/preprocessCSS-comments-2
Handle CSS-comments better in the preprocess-function (PR 14963 follow-up)
2022-06-02 16:52:48 +02:00
Jonas Jenwald
397f2e63d0 Handle CSS-comments better in the preprocess-function (PR 14963 follow-up)
This fixes another oversight, please see the updated tests.
2022-06-02 16:06:47 +02:00
Jonas Jenwald
1ac33c960d
Merge pull request #14968 from Snuffleupagus/api-release-data
A small memory-usage improvement for PDF documents opened from TypedArray-data
2022-05-29 18:35:12 +02:00
Jonas Jenwald
7e852851fd A small memory-usage improvement for PDF documents opened from TypedArray-data
This patch contains a small optimization specifically for the case when `getDocument` is called with TypedArray-data. In that case we'll still hold onto that data, which could obviously be large, even after the "GetDocRequest"-message has been sent to the worker-thread.

In practice this will most likely not affect memory usage in any noticeable way, since the application calling `getDocument` will probably also be keeping a reference to the TypedArray-data. However, it seems like a good idea to ensure that the PDF.js API *itself* won't unnecessarily keep this data alive.
2022-05-29 16:37:18 +02:00
Tim van der Meij
3fdf2ba4e3
Merge pull request #14583 from calixteman/buttons
[Annotations] Show buttons even if they've no actions
2022-05-29 14:13:11 +02:00
Tim van der Meij
839fb002eb
Merge pull request #14967 from Snuffleupagus/update-packages
Update packages and translations
2022-05-29 14:03:37 +02:00
Tim van der Meij
a0eca3e34f
Merge pull request #14962 from Snuffleupagus/sidebar-more-visibleView
Improve the `PDFSidebar` implementation
2022-05-29 13:43:54 +02:00
Tim van der Meij
a43a30bb7b
Merge pull request #14964 from Snuffleupagus/onOpenWithData-contentDispositionFilename
Ensure that the `contentDispositionFilename` is always respected, when setting the document title (PR 13014 follow-up)
2022-05-29 13:26:23 +02:00
Tim van der Meij
3e67d97f81
Merge pull request #14963 from Snuffleupagus/preprocessCSS-comments
Handle CSS-comments correctly in the `preprocess`-function (PR 14886 follow-up)
2022-05-29 13:22:22 +02:00
Jonas Jenwald
0d3a5d7a9e
Merge pull request #14966 from tamuratak/use_globalthis
Use globalThis for webpack's output.globalObject instead of this
2022-05-29 11:31:15 +02:00
Jonas Jenwald
db029e17b3 Update l10n files 2022-05-29 09:48:14 +02:00
Jonas Jenwald
a7d2d8d929 Update npm packages 2022-05-29 09:37:24 +02:00
Takashi Tamura
10932e3f9d Use globalThis for webpack's output.globalObject instead of this. Close #14915.
That allows us to import pdfjs-dist/build/pdf.js dynamically from modules.

- https://webpack.js.org/configuration/output/#outputglobalobject
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis
2022-05-29 11:28:17 +09:00
Calixte Denizet
66b513fc00 [Annotations] Show buttons even if they've no actions
- it's a regression from PR #14247:
 - before the PR, the button was rendered on the canvas whatever its status was;
 - after the PR, the button image has been moved in an other canvas so when the button is not renderable
   (because it has no actions) then the image is not added the HTML element.
- the buttons in the pdf in bug 1737260 or in the pdf in #14308 were not visible
- make the button always renderable but don't add the link element if it's useless.
2022-05-28 23:50:50 +02:00
calixteman
9bdf27e8e0
Merge pull request #14936 from calixteman/input_font_size
Set the text fields font size based on their height
2022-05-28 18:32:45 +02:00
Calixte Denizet
9d82106d20 Set the text fields font size based on their height
- right now we're using the font size from the pdf itself but we use an other font
  in the annotation layer. So this size doesn't really make sense and leads to bad
  rendering (see pdf in #14928);
- use a sans-serif font for the fields containing text (fix issue #14736);
- remove useless padding in text-based fields (fix issue #14301);
- text fields allow/disallow scrolling bars (see bit 24 in Ff entry), so use this
  value to hide/show scrollbars in annotation layer.
2022-05-28 18:00:39 +02:00
calixteman
5b3fdee5f5
Merge pull request #14965 from calixteman/1771477
Support Hangul syllables when searching some text (bug 1771477)
2022-05-28 17:52:27 +02:00
Calixte Denizet
c7afce4210 Support Hangul syllables when searching some text (bug 1771477)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1771477;
- hangul contains some syllables which are decomposed when using NFD, hence
  the text must be correctly shifted in case it contains some of them.
2022-05-28 16:50:03 +02:00
Jonas Jenwald
d80035b716
Merge pull request #14959 from Snuffleupagus/pageColors-thumbnails
Support custom `pageColors` in the thumbnails (PR 14874)
2022-05-28 15:46:06 +02:00
Jonas Jenwald
0599ce77ff Ensure that the contentDispositionFilename is always respected, when setting the document title (PR 13014 follow-up)
Currently, when range-requests and/or streaming are not supported or for documents opened from `data`-URLs, we'll manually set the `contentDispositionFilename` (assuming it exists and is valid) from the `onOpenWithData`-callback in `PDFViewerApplication.initPassiveLoading`.
However, because of a small oversight in `PDFViewerApplication._initializeMetadata`, this *cached* `contentDispositionFilename` would be ignored and we'd only attempt to use the one returned by `PDFDocumentProxy.getMetadata` in the API (which in the cases outlined above will always be empty).

Also, to ensure that the document properties dialog always displays the *correct* fileName we'll now lookup it using the same exact method as in the viewer itself (via a new callback-function).
2022-05-28 12:39:49 +02:00
Jonas Jenwald
65fe0130f4 Handle CSS-comments correctly in the preprocess-function (PR 14886 follow-up)
I overlooked this in PR 14886, sorry about that!
2022-05-28 08:41:25 +02:00
Jonas Jenwald
c0e7a454a1 Convert the PDFSidebar class to use private methods 2022-05-27 11:36:01 +02:00
Jonas Jenwald
d289da76a7 Re-factor the PDFSidebar.{setInitialView, switchView} methods (PR 10502 follow-up)
This removes the internal `_switchView`-method, since looking at all of this again it feels simpler to instead track the initial event dispatching.
2022-05-27 11:33:01 +02:00
Jonas Jenwald
13fda7caeb Remove the view-specific getters in the PDFSidebar class
With the exception of `isThumbnailViewVisible`, these getters are completely unused. Generally speaking, using the `visibleView`-getter directly works just as well and seems (at least to me) to be overall preferable considering how our classes are usually implemented.
2022-05-26 14:27:51 +02:00
Tim van der Meij
e6a0a953e8
Merge pull request #14957 from Snuffleupagus/docStyle
Introduce a viewer constant for `document.documentElement.style`
2022-05-26 13:04:05 +02:00
Jonas Jenwald
9871761949 Support custom pageColors in the thumbnails (PR 14874)
Currently, when non-standard `pageColors` are specified, the thumbnails will look inconsistent depending on how they're created.
The thumbnails that are created by downsizing the *page* canvases will obviously use the `pageColors` as intended, however the thumbnails which are rendered *directly* will always use the default colors.
2022-05-26 10:07:27 +02:00
Jonas Jenwald
ca244d9bca Introduce a viewer constant for document.documentElement.style
Over time, as we've been introducing JavaScript code to modify CSS variables, we've been adding shorthand properties to various classes to reduce unnecessary repetition when accessing the document-styles.
Rather than repeating this in multiple places, it seems overall simpler to just introduce a constant and re-use that throughout the viewer instead.
2022-05-25 09:55:54 +02:00
Jonas Jenwald
5b02c685d6
Merge pull request #14955 from Snuffleupagus/issue-14953
Skip bogus `d1` operators in Type3-glyphs (issue 14953)
2022-05-24 13:45:34 +02:00
Jonas Jenwald
5a2899c57e Skip bogus d1 operators in Type3-glyphs (issue 14953)
In the `src/display/canvas.js` code the `d1` operator will be used to set the clipping region, and it obviously cannot be empty since that prevents the Type3-glyph from rendering.

Also, the patch removes an outdated comment; refer to PR 12718.
2022-05-24 12:20:31 +02:00
calixteman
61012b931c
Merge pull request #14950 from calixteman/1766987
[JS] Format all the fields if any when the document is open (bug 1766987)
2022-05-22 16:56:53 +02:00
Calixte Denizet
9407adc416 [JS] Format all the fields if any when the document is open (bug 1766987)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1766987.
2022-05-22 15:50:42 +02:00
Jonas Jenwald
8fcdad022b
Merge pull request #14948 from Pldi23/drag&drop_not_work_from_mail
Set 'dropEffect' based on 'effectAllowed' for drag-and-drop in the viewer (issue 14942)
2022-05-22 15:34:15 +02:00
Dmitry_Platonov
55da67e9aa Set 'dropEffect' based on 'effectAllowed' for drag-and-drop in the viewer (issue 14942). See https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed 2022-05-22 14:57:55 +02:00
Tim van der Meij
42a6217427
Merge pull request #14926 from Snuffleupagus/rm-sourceEventType
Remove the `sourceEventType` from the viewer (bug 1757771 follow-up)
2022-05-21 12:34:54 +02:00