Commit Graph

14875 Commits

Author SHA1 Message Date
Jonas Jenwald
b23b8d8a5d
Merge pull request #14074 from Snuffleupagus/issue-14046
[api-minor] Add basic support for RTL text-content in PopupAnnotations (issue 14046)
2021-09-25 12:37:44 +02:00
Tim van der Meij
36dc93fe5d
Merge pull request #14065 from Snuffleupagus/fewer-EXPORT_DATA_PROPERTIES
[api-minor] Stop exporting, by default, a few additional Font properties (PR 11777 follow-up)
2021-09-25 12:25:56 +02:00
Tim van der Meij
ee34572fd0
Merge pull request #14070 from Snuffleupagus/MessageHandler-local-vars
Some small readability improvements in the `MessageHandler` code
2021-09-25 12:22:17 +02:00
Tim van der Meij
07558c158d
Merge pull request #14069 from Snuffleupagus/deprecate-OPS-paintJpegXObject
Mark the `paintJpegXObject` operator as deprecated (PR 11601 follow-up)
2021-09-25 12:15:33 +02:00
Jonas Jenwald
1dcd2f0cd3 [api-minor] Add basic support for RTL text-content in PopupAnnotations (issue 14046)
In order to implement this, we utilize the existing `bidi` function to infer the text-direction of /T and /Contents entries. While this may not be perfect in cases where one PopupAnnotation mixes LTR and RTL languages, it should work well enough in most cases.
To avoid having to add *two new* properties in lots of annotations, supplementing the existing `title`/`contents`-properties, this patch instead re-factors the existing code such that the properties are replaced by Objects (containing `str` and `dir`).

*Please note:* In order avoid breaking existing third-party implementations, `GENERIC`-builds of the PDF.js library will still provide the old `title`/`contents`-properties on annotations returned by `PDFPageProxy.getAnnotations`.
2021-09-25 09:18:58 +02:00
calixteman
104e049338
Merge pull request #14073 from calixteman/bindItems
XFA - Bind items when there's a bindItems entry
2021-09-24 09:01:52 -07:00
calixteman
e4d62db9e3
Merge pull request #14072 from calixteman/issue14071
XFA - Create a new page in case of overflow
2021-09-24 09:01:29 -07:00
Calixte Denizet
97c1e076a1 XFA - Bind items when there's a bindItems entry
- In the pdf in issue #14071, some select fields don't contain any values;
  - the corresponding node has a bindItems and a bind elements and _bindItems function was just not called.
2021-09-24 16:08:58 +02:00
Calixte Denizet
cd73e282eb XFA - Create a new page in case of overflow
- it aims to fix #14071;
  - a subform is overflowing and the the target in case of overflow is itself. In this case we must create a new page.
2021-09-24 14:57:55 +02:00
Jonas Jenwald
890a6c1108 Some small readability improvements in the MessageHandler code
In particular the `_processStreamMessage`-method is a bit cumbersome to read, given the way that the current streamController/streamSink is accessed, which we can improve with a couple of local variables.
2021-09-24 13:07:20 +02:00
Jonas Jenwald
7d56fb4cbf Mark the paintJpegXObject operator as deprecated (PR 11601 follow-up)
After PR 11601, the `paintJpegXObject` operator is no longer used for anything. While I don't think we can just remove it, and essentially leave a "hole" in the `OPS` structure, we should at least mark it as explicitly unused to aid readability/maintainability of the code.
2021-09-24 12:47:28 +02:00
Brendan Dahl
c3ca78fdf8
Merge pull request #14042 from serdnab/doc-info-color
Fix dialogs with forced colors (bug 1722984)
2021-09-23 18:03:04 -07:00
Brendan Dahl
d370a281c4
Merge pull request #14067 from calixteman/1732344
Don't save anything in XFA entry if no XFA! (bug 1732344)
2021-09-23 15:07:00 -07:00
Jonas Jenwald
02aa107b21
Merge pull request #14068 from kjenova/master
Fix typo "_annotatationMode" => "_annotationMode"
2021-09-23 21:22:51 +02:00
Jonas Jenwald
f38b3ce523
Merge pull request #14066 from Snuffleupagus/XFAF-viewer-warning
Print a special warning message, in the viewer, for XFA Foreground documents
2021-09-23 21:05:33 +02:00
Calixte Denizet
4b0538d07a Don't save anything in XFA entry if no XFA! (bug 1732344)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1732344
  - rename some variables to have a more clear code;
  - and last but no least, add a unit test to test saving.
2021-09-23 19:51:23 +02:00
kjenova
d1e3900a3d
Fix typo "_annotatationMode" => "_annotationMode" 2021-09-23 18:42:33 +02:00
Jonas Jenwald
fd1f0f647f Print a special warning message, in the viewer, for XFA Foreground documents
Currently XFAF documents use the same warning message as in the XFA *disabled* case, which is neither helpful nor correct.
2021-09-23 15:02:24 +02:00
Jonas Jenwald
c914e9f0a6
Merge pull request #14023 from Snuffleupagus/AnnotationLayer-getElementsByName
Re-factor `document.getElementsByName` lookups in the AnnotationLayer (issue 14003)
2021-09-23 14:05:55 +02:00
Calixte Denizet
386acf5bdd Integration test for PR #14023 2021-09-23 13:05:18 +02:00
Jonas Jenwald
6cba5509f2 Re-factor document.getElementsByName lookups in the AnnotationLayer (issue 14003)
This replaces direct `document.getElementsByName` lookups with a helper method which:
 - Lets the AnnotationLayer use the data returned by the `PDFDocumentProxy.getFieldObjects` API-method, such that we can directly lookup only the necessary DOM elements.
 - Fallback to using `document.getElementsByName` as before, such that e.g. the standalone viewer components still work.

Finally, to fix the problems reported in issue 14003, regardless of the code-path we now also enforce that the DOM elements found were actually created by the AnnotationLayer code.
With these changes we'll thus be able to update form elements on all visible pages just as before, but we'll additionally update the AnnotationStorage for not-yet-rendered elements thus fixing a pre-existing bug.
2021-09-23 13:05:18 +02:00
Jonas Jenwald
9acfe486d4 Fallback to font name matching, when checking for serif fonts (issue 13845)
In order to handle fonts that specify completely bogus /Flags-entries, fallback to font name matching to determine if the font is a serif one.
2021-09-23 01:11:57 +02:00
Jonas Jenwald
e027748627 [api-minor] Stop exporting, by default, a few additional Font properties (PR 11777 follow-up)
*This is similar to the "isSymbolicFont"-property, which is no longer exported by default after PR 11777.*

Both "isMonospace" and "isSerifFont" are internal properties, used during font parsing and building of the glyph mapping on the worker-thread.
However both of these properties are completely unused on the main-thread and/or in the API, and accessing them they will now require setting the `fontExtraProperties`-option when calling `getDocument`.
2021-09-23 00:44:43 +02:00
Tim van der Meij
8dc22f40c7
Merge pull request #14063 from Snuffleupagus/disablePreferences-warning
[GENERIC viewer] Warn about AppOptions being overridden by Preferences during loading
2021-09-22 22:33:40 +02:00
Tim van der Meij
1bef4e596c
Merge pull request #14058 from Snuffleupagus/EventBus-data
[api-minor] Change `EventBus.dispatch` to only support *one* data-argument
2021-09-22 22:26:32 +02:00
Tim van der Meij
5254676ef3
Merge pull request #14055 from Snuffleupagus/PDF_TO_CSS_UNITS
Add `PDF_TO_CSS_UNITS` to the `PixelsPerInch`-structure
2021-09-22 22:24:51 +02:00
Jonas Jenwald
96b38f6cbd [GENERIC viewer] Warn about AppOptions being overridden by Preferences during loading
Currently any AppOptions set using e.g. the "webviewerloaded" event listener can/will by default be overridden when the Preferences are read.
To avoid that happening the "disablePreferences"-option can be used, however unless it's been explicitly set all non-default AppOptions will be silently ignored. This patch thus attempts to improve the current situation somewhat, for third-party implementations, by logging a warning in the console when this happens.
2021-09-22 15:43:26 +02:00
Jonas Jenwald
af748050c0 [api-minor] Change EventBus.dispatch to only support *one* data-argument
This is consistent with how the `EventBus` has *always* been used internally in the viewer, and allows a slight simplification of the relevant code.
2021-09-22 12:21:33 +02:00
Jonas Jenwald
6381158855
Merge pull request #14056 from Snuffleupagus/bug-1731240
Correctly validate URLs in XFA documents (bug 1731240)
2021-09-21 21:37:19 +02:00
Jonas Jenwald
81a1c1cef7 Correctly validate URLs in XFA documents (bug 1731240)
With this patch we'll ensure that only valid absolute URLs can be used in XFA documents, similar to the existing validation done for "regular" PDF documents.
Furthermore, we'll also attempt to add a default protocol (i.e. `http`) to URLs beginning with "www." in XFA documents as well; this on its own is enough to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1731240
2021-09-21 21:21:01 +02:00
Jonas Jenwald
3e550f392a Add PDF_TO_CSS_UNITS to the PixelsPerInch-structure
Rather than re-computing this value in a number of different places throughout the code-base[1], we can expose this in the API via the existing `PixelsPerInch`-structure instead.
There's also been feature requests asking for the old `CSS_UNITS` viewer constant to be made accessible, such that it could be used in third-party implementations.

I suppose that it could be argued that it's somewhat confusing to place a unitless property in `PixelsPerInch`, however given that the `PDF_TO_CSS_UNITS`-property is defined strictly in terms of the existing properties this is hopefully deemed reasonable.

---
[1] These include:
 - The viewer, with the `CSS_UNITS` name.
 - The reference-tests.
 - The display-layer, when rendering images; see PR 13991.
2021-09-20 13:20:09 +02:00
Tim van der Meij
580bfad628
Merge pull request #14053 from Snuffleupagus/BaseViewer-zoom-in/out
Move the zoomIn/zoomOut functionality into `BaseViewer` (PR 14038 follow-up)
2021-09-19 13:19:42 +02:00
Tim van der Meij
c7dd99da76
Merge pull request #14050 from Snuffleupagus/issue-14048
Tweak how fonts with an /Encoding are handled in `adjustToUnicode` (issue 14048, PR 13277 follow-up)
2021-09-19 12:42:43 +02:00
Tim van der Meij
92be4645a9
Merge pull request #14052 from Snuffleupagus/update-packages
Update packages and translations
2021-09-19 12:30:42 +02:00
Jonas Jenwald
d9f9fa4f1c Move the zoomIn/zoomOut functionality into BaseViewer (PR 14038 follow-up)
Given the simplicity of this functionality, we can move it from the default viewer and into the `BaseViewer` class instead. This way, it's possible to support more scripting functionality in the standalone viewer components; please see PR 14038.

Please note that I purposely went with `increaseScale`/`decreaseScale`-method names, rather than using "zoom", to better match the existing `currentScale`/`currentScaleValue` getters/setters that's being used in the `BaseViewer` class.
2021-09-19 11:54:57 +02:00
Jonas Jenwald
32ad677f9c Update l10n files 2021-09-19 09:43:15 +02:00
Jonas Jenwald
a09d7797fb Update the eslint-plugin-unicorn package to the latest version
Please refer to https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v36.0.0
2021-09-19 09:39:56 +02:00
Jonas Jenwald
57734b11f6 Update the es-module-shims package to the latest version
Please refer to https://github.com/guybedford/es-module-shims/blob/main/CHANGELOG.md
2021-09-19 09:33:05 +02:00
Jonas Jenwald
8679bb7aab Update npm packages 2021-09-19 09:31:42 +02:00
Jonas Jenwald
8ea27ce157 Tweak how fonts with an /Encoding are handled in adjustToUnicode (issue 14048, PR 13277 follow-up)
Currently we only exclude /Encoding entries that also contains a /Differences array, which is the cause of the text-selection problem in the referenced issue.
In order to address this we'll now also exclude /Encoding entries that contain one of the predefined *named* encodings, and no longer require that it also contains a /Differences array.

*Please note:* This patch cases a small "regression" in the `bug1130815-text` test-case, however this is actually an improvement when compared with Adobe Reader and PDFium (in Google Chrome).
2021-09-18 22:44:25 +02:00
Tim van der Meij
83d3bb43f4
Merge pull request #14041 from Snuffleupagus/issue-9367
Support cmaps with only CID characters, when building the ToUnicode-map (issue 9367)
2021-09-18 16:47:06 +02:00
Jonas Jenwald
20eb6ca2ec
Merge pull request #14044 from calixteman/bug1719148
Annotations - Avoid empty value in text field when storage contains something for it (bug 1719148)
2021-09-18 16:31:45 +02:00
Tim van der Meij
2375318a70
Merge pull request #14005 from Snuffleupagus/issue-13997
[GENERIC viewer] Always show the Download-buttons, to allow saving of forms (issue 13997)
2021-09-18 16:31:15 +02:00
Jonas Jenwald
6634afd646
Merge pull request #14045 from calixteman/noise
XFA - Only warn about the wrong xfa type when there is an xfa thing
2021-09-18 16:13:20 +02:00
Tim van der Meij
c870fb489e
Merge pull request #14013 from Snuffleupagus/api-unittest-instanceof
Improve the API unit-tests, and try to expose more API-functionality in the TypeScript definitions
2021-09-18 16:08:19 +02:00
Tim van der Meij
213f3d4cbf
Merge pull request #14043 from Snuffleupagus/AutomationEventBus
Re-factor the `EventBus` and `isInAutomation` handling (PR 11655 follow-up)
2021-09-18 16:02:55 +02:00
Calixte Denizet
2fc10727c5 XFA - Only warn about the wrong xfa type when there is an xfa thing 2021-09-18 15:44:05 +02:00
calixteman
ffa2572bdf
Merge pull request #14038 from calixteman/saveas
JS - Implement few possibilities with app.execMenuItem (bug 1724399)
2021-09-18 15:33:03 +02:00
calixteman
f30e862a72
Merge pull request #14040 from calixteman/14039
JS - Avoid the Stay/Leave popup when clicking on a button with a JS action
2021-09-18 15:31:49 +02:00
Calixte Denizet
eb762ad624 Annotations - Avoid empty value in text field when storage contains something for it (bug 1719148)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1719148;
  - JS can set a property for a non-rendered annotation using the annotationStorage but the other unset default properties must be used when the annotation is finally rendered;
  - so this patch just adds the properties already set in the annotationStorage to the default value.
2021-09-18 15:08:22 +02:00