Commit Graph

16370 Commits

Author SHA1 Message Date
Jonas Jenwald
bc13a277ce Relax the /Pages dictionary /Count check for corrupt documents (issue 9105)
After PR 14311, and follow-up patches, we no longer require that the /Count entry (in the /Pages dictionary) is either present or even valid in order to parse/render a PDF document.
Hence it seems strange to keep this requirement for *corrupt* PDF documents, when trying to find a usable `trailer` in the `XRef.indexObjects` method.
2022-10-19 12:28:25 +02:00
Jonas Jenwald
782d098baf
Merge pull request #15589 from Snuffleupagus/issue-15577
Fallback and try a *previous* generation if all else fails in `XRef.indexObjects` (issue 15577)
2022-10-19 09:44:18 +02:00
Jonas Jenwald
de99f99a01 Fallback and try a *previous* generation if all else fails in XRef.indexObjects (issue 15577)
When we fail to find a usable PDF document `trailer` *and* there were errors during parsing, try and fallback to a *previous* generation as a last resort during fetching of uncompressed references.
*Please note:* This will not affect "normal" PDF documents, with valid /XRef data, and even most *corrupt* documents should be completely unaffected by these changes.
2022-10-18 20:24:01 +02:00
calixteman
9355b72931
Merge pull request #15583 from calixteman/15582
[Editor] Commit the current editor before setting the new viewport
2022-10-17 12:56:21 +02:00
Calixte Denizet
6fb694658e [Editor] Commit the current editor before setting the new viewport 2022-10-17 11:58:29 +02:00
Tim van der Meij
54c97d295f
Merge pull request #15580 from Snuffleupagus/update-packages
Update packages and translations
2022-10-16 13:25:40 +02:00
Tim van der Meij
8bf56078c5
Merge pull request #15579 from Snuffleupagus/sidebar-notification-position
Tweak the vertical position of the sidebar notification icon
2022-10-16 13:21:11 +02:00
Jonas Jenwald
db215fe289 Update l10n files 2022-10-16 09:39:00 +02:00
Jonas Jenwald
7bd484ebd3 Update npm packages 2022-10-16 09:38:58 +02:00
Jonas Jenwald
0983ebb257 Tweak the vertical position of the sidebar notification icon
Given that the new sidebar icon is slightly shorter than the old one, it cannot hurt to ever so slightly tweak the vertical position of the notification icon.

(While the patch also changes the CSS rule used for the horizontal position, this is a no-op and was done to improve consistency between the two values.)
2022-10-15 22:19:24 +02:00
calixteman
e0cf25d109
Merge pull request #15578 from calixteman/15571
[Editor] Ink editors must have their dimensions in percents after having been resized
2022-10-15 20:59:24 +02:00
Calixte Denizet
9e2bc8853f [Editor] Ink editors must have their dimensions in percents after having been resized 2022-10-15 19:59:10 +02:00
Tim van der Meij
06599f487f
Merge pull request #15576 from Snuffleupagus/version
Re-factor the PDF version parsing in the worker-thread
2022-10-15 13:03:43 +02:00
Tim van der Meij
2508792f29
Merge pull request #15572 from Snuffleupagus/simpleFontToUnicode-refactor
Slightly re-factor `PartialEvaluator._simpleFontToUnicode`
2022-10-15 12:31:27 +02:00
Jonas Jenwald
d470010293 Re-factor the PDF version parsing in the worker-thread
Part of this is very old code, and back when support for parsing the catalog-version was added things became less clear (in my opinion).
Hence this patch tries to improve things, by e.g. validating the header- and catalog-version separately.
2022-10-15 12:06:39 +02:00
Jonas Jenwald
951564d697
Merge pull request #15575 from Snuffleupagus/startCleanup-destroyed
Don't trigger worker-thread cleanup when destruction has already started
2022-10-14 17:08:25 +02:00
Jonas Jenwald
a576ea216f Don't trigger worker-thread cleanup when destruction has already started
Note how we're currently skipping all main-thread cleanup when document destruction has started, but for some reason we're still dispatching the "Cleanup" message.
This seems like a simple oversight, since destruction will already invoke the `BasePdfManager.cleanup` method (on the worker-thread) to fully clear-out all caches.
2022-10-14 16:43:49 +02:00
Jonas Jenwald
9f5fd075e7
Merge pull request #15574 from calixteman/bug1795263
Use all the current transform as key when caching some image for masks used with pattern fill (bug 1795263, #15573)
2022-10-14 15:12:52 +02:00
Calixte Denizet
556513a6e7 Use all the current transform as key when caching some image for masks used with pattern fill (bug 1795263, #15573) 2022-10-14 14:37:58 +02:00
Jonas Jenwald
15d4d80d45
Merge pull request #15563 from Snuffleupagus/issue-15559
Take the /CIDToGIDMap into account when getting the glyph mapping for CFF fonts (issue 15559)
2022-10-14 09:13:41 +02:00
Jonas Jenwald
d5036d7bfe
Merge pull request #15569 from Snuffleupagus/rm-worker-GetOperatorList-UnsupportedFeature
[api-minor] Stop sending "UnsupportedFeature" from the worker-thread GetOperatorList-handling
2022-10-14 09:12:10 +02:00
calixteman
09d077dc25
Merge pull request #15570 from calixteman/15568
[JS] Take into account all the required fields for some computations
2022-10-13 21:57:35 +02:00
Jonas Jenwald
fa47d4b9b1 Slightly re-factor PartialEvaluator._simpleFontToUnicode
Given the sheer number of heuristics added to this method over the years, moving the *valid* unicode found case to the top should improve readability of the code.
2022-10-13 21:42:57 +02:00
Calixte Denizet
e756bb69e4 [JS] Take into account all the required fields for some computations
- Fix Field::getArray in order to collect only the fields which have a value;
- Fix AFSimple_Calculate:
  * allow to have a string with a list of field names as argument;
  * since a field can be non-terminal, use Field::getArray to collect
    the field under it and then apply the calculation on all the descendants.
2022-10-13 18:33:12 +02:00
Jonas Jenwald
f2f0a1e871 [api-minor] Stop sending "UnsupportedFeature" from the worker-thread GetOperatorList-handling
This code was added all the way back in PR 6698, almost seven years ago, for backwards compatibility reasons. At this point in time, it seems that we can remove that since:
 - We have more fine-grained "UnsupportedFeature" reporting elsewhere in the worker-thread code nowadays.
 - The GetOperatorList-handling is now using `ReadableStream`s, which means that errors are being forwarded to the main-thread anyway.
 - We're also no longer displaying a notification-bar, in the *built-in* Firefox PDF Viewer, for any of these "UnsupportedFeature" messages.
2022-10-13 11:46:17 +02:00
Jonas Jenwald
858d941ff8 Take the /CIDToGIDMap into account when getting the glyph mapping for CFF fonts (issue 15559)
*Please note:* I don't really know what I'm doing here, however the patch appears to fix the referenced issue when comparing the rendering with Adobe Reader (with the caveat that I don't speak the language in question).
2022-10-13 10:02:25 +02:00
calixteman
c6cc7c6e6a
Merge pull request #15567 from calixteman/bug1794717
[Editor] Change the caret cursor into the arrow one only when a text editor isn't empty (bug 1794717)
2022-10-12 10:51:46 +02:00
Calixte Denizet
bc51571a00 [Editor] Change the caret cursor into the arrow one only when a text editor isn't empty (bug 1794717)
When a text editor is empty, clicking outside will create a new editor, hence it makes sense
to keep a caret cursor.
2022-10-12 10:05:34 +02:00
Jonas Jenwald
c42f58c235
Merge pull request #15565 from Snuffleupagus/issue-15564
[GENERIC viewer] Ensure that the we register the `editorTypes` for each `AnnotationEditorUIManager`-instance (issue 15564)
2022-10-12 09:26:14 +02:00
Jonas Jenwald
00c3bc3aab [GENERIC viewer] Ensure that the we register the editorTypes for each AnnotationEditorUIManager-instance (issue 15564)
When a new PDF document is opened in the GENERIC viewer we (obviously) create a new `AnnotationEditorUIManager`-instance, since those are document-specific, and thus we need to ensure that we actually register the `editorTypes` for each one.
2022-10-12 09:02:23 +02:00
Jonas Jenwald
21c2d0c7b0
Merge pull request #15562 from Snuffleupagus/checkHeader-prefix
Slightly re-factor the version fetching in `PDFDocument.checkHeader`
2022-10-11 15:27:41 +02:00
Jonas Jenwald
5bc6f964db Slightly re-factor the version fetching in PDFDocument.checkHeader
Note how after having found the "%PDF-" prefix we then read both the prefix and the version in the loop, only to then remove the prefix at the end.
It seems better to instead advance the stream position past the "%PDF-" prefix, and then read only the version data.

Finally the loop-condition can also be simplified slightly, to further clean-up some very old code.
2022-10-11 13:15:01 +02:00
calixteman
348665934e
Merge pull request #15558 from Snuffleupagus/issue-15557
Ensure that `Page.getOperatorList` handles Annotation parsing errors correctly (issue 15557, bug 1794351)
2022-10-10 11:29:33 +02:00
Jonas Jenwald
081e897588 Ensure that Page.getOperatorList handles Annotation parsing errors correctly (issue 15557)
*Fixes a regression from PR 15246, sorry about that!*

The return value of all `Annotation.getOperatorList` methods was changed in PR 15246, however I missed updating the error code-path in `Page.getOperatorList` which thus breaks all operatorList-parsing for pages with corrupt Annotations.
2022-10-10 09:48:01 +02:00
Tim van der Meij
dff444d441
Merge pull request #15555 from Snuffleupagus/improve-GetDocRequest
Clean-up the data that we're sending with "GetDocRequest"
2022-10-09 14:10:44 +02:00
Tim van der Meij
bf6e287572
Merge pull request #15552 from Snuffleupagus/simplify-dropdownToolbarButton
Simplify the `dropdownToolbarButton`-select width computation
2022-10-09 13:37:15 +02:00
Tim van der Meij
229d21b50d
Merge pull request #15553 from Snuffleupagus/rm-CMapCompressionType-STREAM
Remove the unused `CMapCompressionType.STREAM` value
2022-10-09 13:33:54 +02:00
Jonas Jenwald
8a4f6aca97 Stop using the source-object when sending "GetDocRequest"
Looking at the code on the worker-thread, there doesn't appear to be any particular reason for placing *some* of the properties in a `source`-object when sending them with "GetDocRequest".
As is often the case the explanation for this structure is rather "for historical reasons", since originally we simply sent the `source`-object as-is. Doing that was obviously a bad idea, for a couple of reasons:
 - It makes it less clear what is/isn't actually needed on the worker-thread.
 - Sending unused properties will unnecessarily increase memory usage.
 - The `source`-object may contain unclonable data, which would break the library.
2022-10-09 12:45:24 +02:00
Jonas Jenwald
c84b717773 Group the evaluatorOptions on the main-thread, when sending "GetDocRequest"
Rather than sending all of these parameters individually and then grouping them together on the worker-thread, we can simply handle that in the API instead.
2022-10-09 12:31:03 +02:00
Jonas Jenwald
447915af9d Stop sending the unused source.url property in "GetDocRequest"
It seems that this property became *effectively* unused already in PR 8617, however we missed removing it as part of the clean-up in PR 10376.
2022-10-09 12:30:46 +02:00
Jonas Jenwald
30f968fd7f
Merge pull request #15554 from Snuffleupagus/rm-deprecated-constants
[api-major] Remove some deprecated constants
2022-10-09 09:16:11 +02:00
Jonas Jenwald
484e81ef6e [api-major] Remove some deprecated constants
All of the these constants have been deprecated for a while, and with the upcoming *major* version this seems like a good time to remove them.
For the string-constants we can simply remove them, but the number-constants are left commented out since we don't want to re-number the list to prevent third-party breakage.
2022-10-08 18:13:53 +02:00
Jonas Jenwald
4cc98de6d7 Remove the unused CMapCompressionType.STREAM value
This was added in PR 8064, over five years ago, for a possible future CMap file-format that was never implemented.
2022-10-08 17:10:05 +02:00
Jonas Jenwald
4f5f362d60 Remove unnecessary size attribute from the pageNumber-input
This attribute is overridden by the explicit `width` that's specified in the CSS rules, hence we can remove one more small piece of very old code; see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#size
2022-10-08 12:34:13 +02:00
Jonas Jenwald
450be1ad3e Simplify the dropdownToolbarButton-select width computation
The way that we set the width of the `dropdownToolbarButton`-select is very old, and despite some improvements over the years this is still somewhat hacky.
In particular, note how we're assigning the select-element a larger width than its containing `dropdownToolbarButton`-element. This was done to prevent displaying *two* separate icons, i.e. the native and the PDF.js one, since it's the only way to handle this in older browsers (particularly Internet Explorer).

Given the currently supported browsers, there's however a better solution available: use `appearance: none;` to disable native styling of the select-element. [According to MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/appearance#browser_compatibility), this is supported in all reasonably modern browsers.
This way we're able to simplify both the CSS rules and the JS-code that's used to adjust the `dropdownToolbarButton` width in a localization aware way.
2022-10-07 18:19:10 +02:00
calixteman
3dc9b427b9
Merge pull request #15549 from calixteman/padding_inline
[XFA] Add some padding inline in selects
2022-10-07 03:49:14 -10:00
calixteman
b27753aa3d
Merge pull request #15548 from calixteman/simplify_remainder
Simplify the way to compute the remainder modulo 3 in PDF20Hash function
2022-10-07 03:48:41 -10:00
Calixte Denizet
24757e32d1 [XFA] Add some padding inline in selects
Because of https://bugzilla.mozilla.org/show_bug.cgi?id=1582545, the padding-inline is by default 0.
0 is not really enough because of the outline, so just set it to 2px (it was 4px before the patch)
in order to have something visually correct.
2022-10-07 15:11:58 +02:00
Jonas Jenwald
9931295bea
Merge pull request #15547 from Snuffleupagus/rm-Util-apply3dTransform
Remove the unused `Util.apply3dTransform` method
2022-10-07 15:03:19 +02:00
Calixte Denizet
c0e165bf97 Simplify the way to compute the remainder modulo 3 in PDF20Hash function
I noticed the 256 % 3 (which is equal to 1) so I slighty simplify the code.
The sum of the 16 Uint8 doesn't exceed 2^12, hence we can just take the
sum modulo 3.
2022-10-07 14:43:31 +02:00