Commit Graph

2509 Commits

Author SHA1 Message Date
Jonas Jenwald
705d1cfad3 Remove useless assignment of availableSpace in the src/core/xfa/template.js file (issue 13829, 13835) 2021-08-03 10:58:57 +02:00
Tim van der Meij
10a1db6980
Merge pull request #13824 from Snuffleupagus/issue-13823
When no "V" entry exists, let the fieldValue fallback to the "DV" entry (issue 13823)
2021-07-30 22:48:38 +02:00
Jonas Jenwald
ff71be793d When no "V" entry exists, let the fieldValue fallback to the "DV" entry (issue 13823) 2021-07-30 16:17:42 +02:00
Calixte Denizet
7bb5331087 XFA - Avoid an error when an exdata is a string (bug 1723114) 2021-07-30 14:43:53 +02:00
Brendan Dahl
4ad5c5d52a
Merge pull request #13808 from brendandahl/pattern-cache-v2
Improve caching of shading patterns. (bug 1721949)
2021-07-28 11:17:16 -07:00
Brendan Dahl
c836e1f0fb Improve caching of shading patterns. (bug 1721949)
The PDF in bug 1721949 uses many unique pattern objects
that references the same shading many times. This caused
a new canvas pattern to be created and cached many times
driving up memory use.

To fix, I've changed the cache in the worker to key off the
shading object and instead send the shading and matrix
separately. While that worked well to fix the above bug,
there could be PDFs that use many shading that could
cause memory issues, so I've also added a LRU cache
on the main thread for canvas patterns. This should prevent
memory use from getting too high.
2021-07-28 10:29:20 -07:00
Calixte Denizet
4a4591bd2c XFA - Fix font scale factors (bug 1720888)
- All the scale factors in for the substitution font were wrong because of different glyph positions between Liberation and the other ones:
    - regenerate all the factors
  - Text may have polish chars for example and in this case the glyph widths were wrong:
    - treat substitution font as a composite one
    - add a map glyphIndex to unicode for Liberation in order to generate width array for cid font
2021-07-28 19:10:42 +02:00
Calixte Denizet
92f4cc52a6 XFA - Add a transparent blue background on all text fields for consistency 2021-07-28 14:47:29 +02:00
Calixte Denizet
76d882b560 XFA - Fix auto-sized fields (bug 1722030)
- In order to better compute text fields size, use line height with no gaps (and consequently guessed height for text are slightly better in general).
  - Fix default background color in fields.
2021-07-28 09:43:15 +02:00
Tim van der Meij
336a74a0e5
Merge pull request #13796 from Snuffleupagus/issue-13794
Allow `StreamsSequenceStream.readBlock` to skip sub-streams with errors (issue 13794)
2021-07-27 22:25:58 +02:00
Calixte Denizet
bd6f55186d XFA - Get the full value when binding and not only the 1st line (bug 1718725) 2021-07-27 20:25:33 +02:00
Calixte Denizet
959120e6c9 XFA - Elements created outside of XML must have all their properties (bug 1722029)
- an Image element was created, attached to its parent but the $globalData property was not set and that led to an error.
  - the pdf in bug 1722029 has 27 rendered rows (checked in Acrobat) when only one was displayed: this patch some binding issues around the occur element.
2021-07-26 19:38:52 +02:00
Jonas Jenwald
885e7a8aa4 Allow StreamsSequenceStream.readBlock to skip sub-streams with errors (issue 13794)
This patch makes use of the existing `ignoreErrors` option, thus allowing a page to continue parsing/rendering even if (some of) its sub-streams are corrupt. Obviously this may cause *part* of a page to be broken/missing, however it should be better than (potentially) rendering nothing.
Also, to the best of my knowledge, this is the first bug of its kind that we've encountered.

To avoid having to pass in a bunch of, for a `BaseStream`-instance, mostly unrelated parameters when initializing a `StreamsSequenceStream`-instance, I settled on utilizing a callback function instead to allow conditional Error-suppression.
Note that the `StreamsSequenceStream`-class is a *special* stream-implementation that we only use when the `/Contents`-entry, in the `/Page`-dictionary, consists of an Array with streams.
2021-07-26 16:42:50 +02:00
Jonas Jenwald
833f27c677 Disable a LGTM warning, again (PR 13787 follow-up)
Apparently I didn't put one of the disable comments on the *correct* line, since I didn't read the instructions carefully enough, so let's try again.

Note that, most unfortunately, disabling of warnings isn't applied until *after* a patch has been merged.
2021-07-25 10:32:40 +02:00
Tim van der Meij
41a2b5c809
Merge pull request #13787 from Snuffleupagus/lgtm-fix-warnings
Fix (most) LGTM warnings
2021-07-24 15:20:07 +02:00
Tim van der Meij
7b6767d415
Merge pull request #13784 from Snuffleupagus/issue-13783
When parsing corrupt documents, avoid inserting obviously broken data in the XRef-table (issue 13783)
2021-07-24 14:37:39 +02:00
Tim van der Meij
687cfcecd4
Merge pull request #13786 from Snuffleupagus/rm-more-src-core-closures
Remove a couple of small closures in `src/core/` code
2021-07-24 14:26:57 +02:00
Jonas Jenwald
70bac87fed Fix (most) LGTM warnings
Most of the warnings we don't really care about, and those are simply white-listed using inline comments; however two cases prompted actual code changes:

 - In `src/display/pattern_helper.js` the branch in question is indeed unreachable, and should thus be safe to remove. (This code originated in PR 4192, which is now over seven years ago.)

 - In `test/test.js`, the function in question indeed doesn't accept any arguments. (The patch also re-formats a string just above, which didn't seem worthy of a separated patch.)

This now leaves only *one* warning in the LGTM report, however that one is a false positive that we'll need to report upstream.
2021-07-24 14:23:59 +02:00
Tim van der Meij
9854b85dc1
Merge pull request #13775 from Snuffleupagus/Dict-merge-refactor
Remove some duplication in the `Dict.merge` method
2021-07-24 14:21:41 +02:00
Jonas Jenwald
ebbbc973a5 Remove the closure used with the PostScriptToken class
This patch uses the same approach as used in lots of other parts of the code-base, which thus *slightly* reduces the size of this code.
2021-07-24 13:05:46 +02:00
Jonas Jenwald
81009d42cf Remove the closure used with the PostScriptStack class
This patch uses the same approach as used in lots of other parts of the code-base, which thus *slightly* reduces the size of this code.
2021-07-24 12:59:53 +02:00
Jonas Jenwald
b82c802dff When parsing corrupt documents, avoid inserting obviously broken data in the XRef-table (issue 13783)
In cases where even the very *first* attempt at reading from an object will throw, simply ignoring such objects will help improve rendering of *some* corrupt documents.
Note that this will lead to more parsing in some cases, but considering that this only applies to *corrupt* documents that shouldn't be a big deal.
2021-07-23 18:10:53 +02:00
Jonas Jenwald
51f0a81085
Merge pull request #13770 from brendandahl/cache-pattern
Improve performance of reused patterns.
2021-07-23 10:43:23 +02:00
Brendan Dahl
da1af02ac8 Improve performance of reused patterns.
Bug 1721218 has a shading pattern that was used thousands of times.
To improve performance of this PDF:
 - add a cache for patterns in the evaluator and only send the IR form once
   to the main thread (this also makes caching in canvas easier)
 - cache the created canvas radial/axial patterns
 - for shading fill radial/axial use the pattern directly instead of creating temporary
   canvas
2021-07-22 16:47:40 -07:00
Calixte Denizet
a51c4a3a0f XFA - A field without an ui must provide a default one (bug 1718245) 2021-07-22 20:31:25 +02:00
Jonas Jenwald
e1ee3835cd Remove some duplication in the Dict.merge method
Currently the `!mergeSubDicts` code-path is essentially just duplicated code, which we can easily avoid by simply moving that check. (This may lead to ever so slightly more parsing for this case, but the difference ought to be negligible in practice.)
2021-07-22 14:01:43 +02:00
Jonas Jenwald
2cf90cd9ad
Merge pull request #13766 from Snuffleupagus/issue-13751
XFA - Handle `startIndex` correctly in the `Template.$toHTML` method (issue 13751)
2021-07-21 18:58:29 +02:00
Calixte Denizet
5555114bb3 XFA - Remove namespace from nodes under xfa:data node
- in real life some xfa contains xml like <xfa:data><xfa:Foo><xfa:Bar>...</xfa:data>
    since there are no Foo or Bar in the xfa namespace the JS representation are empty
    and that leads to errors.
  - so the idea is to make all nodes under xfa:data namespace agnostic which means
    that ns are removed from nodes in the parser but only xfa:data descendants.
2021-07-21 17:11:31 +02:00
Jonas Jenwald
7d1c19f8bd XFA - Handle startIndex correctly in the Template.$toHTML method (issue 13751)
*Please note:* The PDF document in issue 13751 is *dynamically* created (in e.g. Adobe Reader), with pages added when certain buttons are clicked, hence this patch simply fixes the breaking error and nothing more.

It looks like the current code contains a little bit too much copy-and-paste from the *similar* `index` branch above, since we cannot set the `startIndex` to a negative value. Note how it's being used to initialize the loop-variable, which is then used to lookup values in an Array and accessing the `-1`th element of an Array obviously makes no sense.
2021-07-21 16:17:13 +02:00
Jonas Jenwald
6c9b6bc599
Merge pull request #13764 from Snuffleupagus/issue-13748
XFA - Add a missing method to `XFAAttribute`, to prevent breaking errors (issue 13748)
2021-07-20 18:55:23 +02:00
Jonas Jenwald
c2fe493abe XFA - Add a missing method to XFAAttribute, to prevent breaking errors (issue 13748)
*This is yet another case where I've got no idea if the patch is correct, but it does at least fix a breaking error :-)*

Note how in the [`Binder._bindValue` method](683ce66a48/src/core/xfa/bind.js (L92-L93)), we're assuming that if a `data`-value exists then it'll also be possible to actually access it. For the `XFAAttribute`-implementation however, the second method is missing and that's what causes the breaking errors in issue 13748.

Please note that another possible way of "fixing" the error wouldn't been to simply change the exists-check to return `false`, and I could see that being a preferred solution.
However, the reason for submitting the current patch is that we get *fewer* warnings about Nodes with mis-matched types this way.
2021-07-20 17:41:05 +02:00
Calixte Denizet
1d07ef597e XFA - Must use bindItems element even if there is no direct binding (bug 1720907) 2021-07-20 17:07:32 +02:00
Jonas Jenwald
cf7978d507 XFA - Prevent breaking errors in Binder, when searchNode doesn't return data (issue 13756)
As can be seen in the code (see below), the `searchNode` helper function will return `null` in some cases and all of its call-sites should protect against that before attempting to access the returned data.
While only one of these changes were necessary to fix the breaking errors in issue 13756, in order to prevent future bugs I've added similar defensive code throughout this file.

 - 07955fa1d3/src/core/xfa/som.js (L169)
 - 07955fa1d3/src/core/xfa/som.js (L239)
 - 07955fa1d3/src/core/xfa/som.js (L254)
2021-07-19 18:07:07 +02:00
Tim van der Meij
07955fa1d3
Merge pull request #13735 from Snuffleupagus/bug-1720411
Ensure that the field value, for checkboxes, refers to an existing appearance state (bug 1720411)
2021-07-18 13:48:34 +02:00
Tim van der Meij
668c58d68d
Merge pull request #13746 from Snuffleupagus/getOperatorList-intent
[api-minor] Add `intent` support to the `PDFPageProxy.getOperatorList` method (issue 13704)
2021-07-18 13:28:08 +02:00
Jonas Jenwald
481af097b4 Convert PDFFunction to a standard class with static methods
For e.g. `gulp mozcentral`, the *built* `pdf.worker.js` file decreases from `1 837 608` to `1 834 907` bytes with this patch-series.
The improvement comes first of all from less overall indentation in `PDFFunction`, and secondly from the removal of (now) unnecessary indirection in the code.
2021-07-17 16:46:57 +02:00
Jonas Jenwald
d35fe3e796 Remove the IR (internal representation) part of the PDFFunction parsing
*This follows the exact same princial as PR 12083, but for the `PDFFunction` parsing instead.*

Given that the IR format is completely unused now, all that the current code does is add a bunch of unnecessary indirection/overhead to the handling of PDF-functions.
2021-07-17 16:44:58 +02:00
Jonas Jenwald
03cf28bf17 [api-minor] Add intent support to the PDFPageProxy.getOperatorList method (issue 13704)
With this patch, the `PDFPageProxy.getOperatorList` method will now return `PDFOperatorList`-instances that also include Annotation-operatorLists (when those exist). Hence this closes a small, but potentially confusing, gap between the `render` and `getOperatorList` methods.

Previously we've been somewhat reluctant to do this, as explained below, but given that there's actual use-cases where it's required probably means that we'll *have* to implement it now.
Since we still need the ability to separate "normal" rendering operations from direct `getOperatorList` calls in the worker-thread, this API-change unfortunately causes the *internal* renderingIntent to become a bit "messy" which is indeed unfortunate (note the `"oplist-"` strings in various spots). As-is I suppose that it's not all that bad, but we may want to consider changing the *internal* renderingIntent to e.g. a bitfield in the future.

Besides fixing issue 13704, this patch would also be necessary if someone ever tries to implement e.g. issue 10165 (since currently `PDFPageProxy.getOperatorList` doesn't include Annotation-operatorLists).

*Please note:* This patch is *also* tagged "api-minor" for a second reason, which is that we're now including the Annotation-id in the `beginAnnotation` argument. The reason for this is to allow correlating the Annotation-data returned by `PDFPageProxy.getAnnotations`, with its corresponding operatorList-data (for those Annotations that have it).
2021-07-16 17:16:30 +02:00
Jonas Jenwald
da808aeab3 Ensure that the field value, for checkboxes, refers to an existing appearance state (bug 1720411)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1720411
2021-07-16 13:11:48 +02:00
calixteman
4b2e0d0d01
Merge pull request #13732 from calixteman/rect
XFA - A rectangle must have the width of its parent but without inner margins
2021-07-15 22:30:25 +02:00
Jonas Jenwald
3838c4e27c Re-factor the handling of *empty* Name-instances (PR 13612 follow-up)
When working on PR 13612, I mostly prioritized a simple solution that didn't require touching a lot of code. However, while working on PR 13735 I started to realize that the static `Name.empty` construction really wasn't a good idea.

In particular, having a special `Name`-instance where the `name`-property isn't actually a String is confusing (to put it mildly) and can easily lead to issues elsewhere. The only reason for not simply allowing the `name`-property to be an *empty* string, in PR 13612, was to avoid having to touch a lot of existing code. However, it turns out that this is only limited to a few methods in the `PartialEvaluator` and a few of the `BaseLocalCache`-implementations, all of which can be easily re-factored to handle *empty* `Name`-instances.

All-in-all, I think that this patch is even an *overall* improvement since we're now validating (what should always be) `Name`-data better in the `PartialEvaluator`.
This is what I ought to have done from the start, sorry about the code churn here!
2021-07-15 12:00:42 +02:00
Calixte Denizet
019699acfb XFA - Cannot print fields with no names
- it was not possible to print pdf file in issue #13500.
2021-07-14 17:38:35 +02:00
Calixte Denizet
5081167e7f XFA - A rectangle must have the width of its parent but without inner margins
- it aims to fix #13584;
  - to avoid bad rendering because of clipping just set overflow to visible on SVG element.
2021-07-14 16:46:13 +02:00
Calixte Denizet
dd55e76f5d XFA - Avoid to have containers not pushed in the html
- it aims to fix issue #13668.
2021-07-12 21:34:58 +02:00
calixteman
140c2bc563
Revert "XFA - Avoid to have containers not pushed in the html" 2021-07-12 09:46:38 +02:00
calixteman
b6445ddc08
Merge pull request #13716 from calixteman/layout7
XFA - Avoid to have containers not pushed in the html
2021-07-12 09:31:27 +02:00
Calixte Denizet
9bbc194846 XFA - Support assist element 2021-07-11 21:01:18 +02:00
Calixte Denizet
fccc6c2242 XFA - Avoid to have containers not pushed in the html
- it aims to fix issue #13668.
2021-07-11 19:14:44 +02:00
Calixte Denizet
690b5d1941 XFA - Use fake MyriadPro as a fallback for missing fonts
- aims to fix #13597.
2021-07-11 13:52:13 +02:00
calixteman
d416b23898
Merge pull request #13705 from calixteman/lineheight3
XFA - Fix text positions (bug 1718741)
2021-07-10 14:19:03 +02:00
Jonas Jenwald
700b79a305 XFA - Always compute the transformed BBox values in checkDimensions (PR 13691 follow-up)
This way we ensure that these BBox values are *always* defined as expected for every `case`-block, and we also don't need to duplicate the lookup in multiple places. (Also, the patch removes a couple of unnecessary line-breaks in existing comments.)

Fixes https://github.com/mozilla/pdf.js/pull/13691#pullrequestreview-702356627, which was flagged by LGTM.
2021-07-10 11:24:05 +02:00
calixteman
a4f60fc417
Merge pull request #13708 from calixteman/xfa_tab
XFA - Add support for traversal and traverse element
2021-07-09 21:59:50 +02:00
Calixte Denizet
ccac125623 XFA - Add support for traversal and traverse element
- For now, just implement the "next" target in using tabindex attribute of html elements.
2021-07-09 20:50:25 +02:00
calixteman
caaf77375f
Merge pull request #13703 from eltociear/patch-4
XFA - Fix typo in factory.js
2021-07-09 20:12:55 +02:00
Calixte Denizet
58e1f51688 XFA - Fix text positions (bug 1718741)
- font line height is taken into account by acrobat when it isn't with masterpdfeditor: I extracted a font from a pdf, modified some ascent/descent properties thanks to ttx and the reinjected the font in the pdf: only Acrobat is taken it into account. So in this patch, line heights for some substituted fonts are added.
  - it seems that Acrobat is using a line height of 1.2 when the line height in the font is not enough (it's the only way I found to fix correctly bug 1718741).
   - don't use flex in wrapper container (which was causing an horizontal overflow in the above bug).
   - consequently, the above fixes introduced a lot of small regressions, so in order to see real improvements on reftests, I fixed the regressions in this patch:
     - replace margin by padding in some case where padding is a part of a container dimensions;
     - remove some flex display: some containers are wrongly sized when rendered;
     - set letter-spacing to 0.01px: it helps to be sure that text is not broken because of not enough width in Firefox.
2021-07-09 18:11:12 +02:00
Ikko Ashimine
dba30eac7b
XFA - Fix typo in factory.js
occured -> occurred
2021-07-09 21:51:37 +09:00
Calixte Denizet
ad195e0f05 XFA - Scale correctly images 2021-07-08 20:28:49 +02:00
calixteman
c33bf0b5e8
Merge pull request #13692 from calixteman/bind_global
XFA - Correctly bind global data (bug 1718725)
2021-07-08 12:42:22 +02:00
Jonas Jenwald
df6107714a XFA - remove unnecessary check in the handleBreak function (PR 13687 follow-up)
With the changes in PR 13687 we're now checking if `target` is defined *twice* in a row, which shouldn't be necessary :-)

(I noticed this when glancing at the unofficial LGTM results; maybe we should re-evalute the decision to not integrate that into the CI.)
2021-07-07 23:22:29 +02:00
calixteman
fbd2f28618
Merge pull request #13693 from calixteman/textfields
XFA - Enable disabled fields (bug 1719464)
2021-07-07 21:43:21 +02:00
Calixte Denizet
d9a776caf8 XFA - Enable disabled fields (bug 1719464)
- it's a workaround in waiting for JS implementation to let the use fill manually some fields.
2021-07-07 19:11:36 +02:00
Calixte Denizet
8a06df9253 XFA - Handle correctly nested containers with lr-tb layout (bug 1718670)
- and avoid to push a field with no dimensions when we have some available space in width in a parent.
2021-07-07 18:54:32 +02:00
Calixte Denizet
778800a53a XFA - Correctly bind global data (bug 1718725) 2021-07-07 17:36:56 +02:00
Jonas Jenwald
37d2808977 Merge the supplemental font data files used with XFA documents
When XFA support was added, the size of the *built* `pdf.worker.js` file increased quite a bit. Hence I think that it makes sense to, where easily possible, do what we can to (slightly) reduce the size of the PDF.js library.

The supplemental font data files (added for XFA rendering), containing rescale-factors respectively widths, seem like an excellent candidate here since they're not particularly large in either line-count or file sizes.
In this patch these files are instead merged into a *single* file per font, rather than four different ones, and even with these changes the resulting source files don't become all that large.[1]

For e.g. the `gulp mozcentral` build, this reduces the size of the *built* `pdf.worker.js` file by more than `3 kB`. Given the overall simplicity of the patch, that kind of size decrease definitely seem worthwhile to me.

---
[1] Especially when compared to truly large files such as e.g. `glyphlist.js`, `metrics.js`, and `unicode.js`.
2021-07-07 11:56:34 +02:00
Calixte Denizet
0486d24e36 XFA - Don't fail xfa loading because of a JS subexpression in SOM expressions
- Fix for one pdf in bug 1717668 (PDFIUM-292-0.pdf).
2021-07-07 10:47:53 +02:00
Calixte Denizet
c47f0f0f40 XFA - Default background in rectangle is white
- Fix a typo in order to open the pdf in issue #13679
  - After fixing the fill default color there wer some regressions because of z-index
    and when fixing z-index there were some regressions because of borders
  - So fix the borders rendering.
2021-07-06 21:17:20 +02:00
Calixte Denizet
5f76b6370c XFA - Layout correctly a subform with row layout (bug 1718740)
- Fix issues with subformSet elements which are not a real container.
2021-07-06 14:11:25 +02:00
calixteman
ba2d685166
Merge pull request #13673 from calixteman/images2
XFA - An image can be a stream in the pdf (bug 1718521)
2021-07-06 09:53:29 +02:00
calixteman
b9e84ba70e
Merge pull request #13665 from calixteman/reserve
XFA - Fix indentation for justified paragraph
2021-07-05 15:45:59 +02:00
Calixte Denizet
5cdee80c8e XFA - An image can be a stream in the pdf (bug 1718521) - hrefs can be found in catalog > Names > XFAImages 2021-07-05 14:06:23 +02:00
calixteman
02c069481e
Merge pull request #13653 from calixteman/lineheight
XFA - Improve text layout
2021-07-05 13:32:42 +02:00
calixteman
783cbc1793
Revert "XFA - An image can be a stream in the pdf (bug 1718521)" 2021-07-05 12:47:14 +02:00
calixteman
b370d4714f
Merge pull request #13654 from calixteman/images
XFA - An image can be a stream in the pdf (bug 1718521)
2021-07-05 12:04:34 +02:00
Jonas Jenwald
819be0e78b Fix the remaining ESLint operator-assignment errors 2021-07-04 15:23:56 +02:00
Jonas Jenwald
901b24e8af Enable the ESLint operator-assignment rule
This patch was generated automatically, using the `gulp lint --fix` command.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/operator-assignment
2021-07-04 12:57:45 +02:00
Jonas Jenwald
de80590157
Merge pull request #13662 from calixteman/no_arial
XFA - Don't use system font when a font is not embeded but there is a substitution
2021-07-04 11:35:50 +02:00
Calixte Denizet
9b5574d3ef XFA - Fix indentation for justified paragraph
- and ceil the reserve for a caption to avoid to split it;
  - both issues are present in the pdf in issue #13633.
2021-07-03 18:07:01 +02:00
Calixte Denizet
5744dd773d XFA - Don't use system font when a font is not embeded but there is a substitution
- always use a font coming from pdf.js when there is one: this way we don't use a system font which could looks wrong.
2021-07-03 15:13:56 +02:00
Jonas Jenwald
661c60ecc9 [api-minor] Support accessing both the original and modified PDF fingerprint
The PDF.js API has only ever supported accessing the original file ID, however the second one that (should) exist in *modified* documents have thus far been completely inaccessible through the API.
That seems like a simple oversight, caused e.g. by the viewer not needing it, since it really shouldn't hurt to provide API-users with the ability to check if a PDF document has been modified since its creation.[1]

Please refer to https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G13.2261661 for additional information.

For an example of how to update existing code to use the new API, please see the changes in the `web/app.js` file included in this patch.

*Please note:* While I'm not sure if we'll ever be able to remove the old `PDFDocumentProxy.fingerprint` getter, given that it's existed since "forever", that probably isn't a big deal given that it's now limited to only `GENERIC`-builds.

---
[1] Although this obviously depends on the PDF software following the specification, by updating the second file ID as intended.
2021-07-03 13:56:33 +02:00
Jonas Jenwald
909ff8e29f Replace instanceof Object with typeof checks
Using `instanceof Object` is generally problematic, since it's not guaranteed to always do the right thing for all Objects.
(I stumbled upon this while working on another patch, when I noticed that the `outlineView` was broken with workers disabled.)
2021-07-03 11:30:46 +02:00
Calixte Denizet
f16828be49 XFA - An image can be a stream in the pdf (bug 1718521)
- hrefs can be found in catalog > Names > XFAImages
2021-07-02 20:34:10 +02:00
Calixte Denizet
f7d3b22480 XFA - Improve text layout
- support paragraph margins, line height, letter spacing, ...
  - compute missing dimensions from fields based almost on the dimensions of caption contents.
2021-07-02 17:53:32 +02:00
calixteman
d80651e572
Merge pull request #13598 from calixteman/dhl
XFA - Remove empty pages
2021-06-30 20:43:07 +02:00
calixteman
a8a5c5f10b
Merge pull request #13648 from calixteman/xfa_bg
XFA - Don't fill when the fill element is not visible (bug 1718735)
2021-06-30 18:12:13 +02:00
Calixte Denizet
08e08d5852 XFA - Don't fill when the fill element is not visible (bug 1718735) 2021-06-30 17:14:08 +02:00
Calixte Denizet
ff440d13e7 XFA - Remove empty pages
- it aims to fix #13583;
  - fix the switch to breakBefore target;
  - force the layout of an unsplittable element on an empty page;
  - don't fail when there is horizontal overflow (except in lr-tb);
  - handle correctly overflow in the same content area (bug 1717805, bug 1717668);
  - fix a typo in radial gradient first argument.
2021-06-30 16:32:27 +02:00
Tim van der Meij
6307349e31
Merge pull request #13640 from Snuffleupagus/issue-6759
Add non-PRODUCTION/TESTING overflow `assert`s to various string helper-functions (issue 6759)
2021-06-29 21:22:34 +02:00
calixteman
f35e4cc9ab
Merge pull request #13645 from calixteman/bug1718241
XFA - Choice list has no selected value by default (bug 1718241)
2021-06-28 23:46:59 +02:00
calixteman
04dc902933
Merge pull request #13644 from calixteman/xfa_missing_fonts
XFA - Support non-embedded fonts without a Widths entry
2021-06-28 23:46:09 +02:00
Calixte Denizet
70bb672dcd XFA - Support non-embedded fonts without a Widths entry
- some pdf use some fonts which are not embedded or they don't have any width array or don't have any css info (e.g. for standard fonts or Arial).
  - so add widths arrays for Liberation fonts in order to compute the ones for other fonts in using scale factors array.
2021-06-28 23:05:08 +02:00
Calixte Denizet
1de133a7c9 XFA - Choice list has no selected value by default 2021-06-28 22:10:26 +02:00
Calixte Denizet
71d17b0cc4 XFA - Implement aspect property on image element
- it aims to fix issue #13634;
  - move some img-related functions in test/drivers.js in order to have images in xfa reftests.
2021-06-28 20:43:39 +02:00
Calixte Denizet
b261446981 XFA - Fix width of a container with lr-tb layout (bug 1718037) 2021-06-28 17:47:04 +02:00
calixteman
03dff1c5f5
Merge pull request #13639 from calixteman/old_break
XFA - Replace deprecated break element (bug 1718053)
2021-06-28 17:44:03 +02:00
Calixte Denizet
677332aa7b XFA - Remove quotes of font name in xhtml 2021-06-27 18:05:12 +02:00
Jonas Jenwald
273d8cb746 Add non-PRODUCTION/TESTING overflow asserts to various string helper-functions (issue 6759) 2021-06-27 16:06:30 +02:00
Calixte Denizet
257de0e8c5 XFA - Replace deprecated break element (bug 1718053)
- the break element has been deprecated in XFA 2.4 but some old documents can use it, so replace it with one (or more) of its possible substitutions:
    - breakBefore;
    - breakAfter;
    - overflow.
2021-06-27 15:03:00 +02:00
Tim van der Meij
d7f8a0e9b9
Merge pull request #13628 from Snuffleupagus/issue-13626
Check that TrueType (3, 0) cmap tables, for symbolic fonts, are sorted correctly (issue 13626)
2021-06-26 14:17:11 +02:00
Calixte Denizet
429ffdcd2f XFA - Save filled data in the pdf when downloading the file (Bug 1716288)
- when binding (after parsing) we get a map between some template nodes and some data nodes;
  - so set user data in input handlers in using data node uids in the annotation storage;
  - to save the form, just put the value we have in the storage in the correct data nodes, serialize the xml as a string and then write the string at the end of the pdf using src/core/writer.js;
  - fix few bugs around data bindings:
    - the "Off" issue in Bug 1716980.
2021-06-25 18:57:01 +02:00
Jonas Jenwald
50edd5da63 Suppress OTS warnings about the caretOffset in the hhea-table
- https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hhea.html
 - https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6head.html
2021-06-25 17:02:02 +02:00
Jonas Jenwald
185be678ec Check that TrueType (3, 0) cmap tables, for symbolic fonts, are sorted correctly (issue 13626)
According to a comment in `readCmapTable`, we're assuming that the cmap tables (when more than one exist) are sorted in ascending order. If that's not the case, keep checking the following cmap tables in order to fix the referenced issue.
2021-06-25 16:56:00 +02:00
Brendan Dahl
d7fdb72a3f
Merge pull request #13619 from calixteman/bg
XFA - Add back empty subforms (which can have a background)
2021-06-23 16:21:28 -07:00
Brendan Dahl
f4f00a9bc6
Merge pull request #13618 from calixteman/bind_root
XFA - Always bind root subform on root data
2021-06-23 13:14:12 -07:00
Tim van der Meij
ad4b2ce021
Merge pull request #13612 from Snuffleupagus/issue-13610
Support corrupt documents with *empty* `Name`-entries (issue 13610)
2021-06-23 21:49:02 +02:00
Calixte Denizet
b836616667 XFA - Always bind root subform on root data
- it partially fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1717805 (on the data side at least but there is still a layout issue).
2021-06-23 20:46:41 +02:00
Calixte Denizet
f168998d93 XFA - Add back empty subforms (which can have a background) 2021-06-23 19:42:36 +02:00
Calixte Denizet
e82446fa5a XFA - Get line height from the font
- when the CSS line-height property is set to 'normal' then the value depends of the user agent. So use a line height based on the font itself and if for any reasons this value is not available use 1.2 as default.
  - it's a partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1717681.
2021-06-23 14:11:10 +02:00
Jonas Jenwald
6467907318 Support corrupt documents with *empty* Name-entries (issue 13610)
Apparently some really bad PDF software can create documents with *empty* `Name`-entries, which we thus need to somehow deal with.
While I don't know if this patch is necessarily the best solution, it should at least ensure that the *empty* `Name`-instance cannot accidentally match a proper `Name`-instance (and it doesn't require changes to a lot of existing code).[1]

---
[1] I briefly considered using a `Symbol` rather than an Object, but quickly decided against that since the former one [is not clonable](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types) and `Name`-instances may be sent to the API.
2021-06-22 16:55:44 +02:00
Calixte Denizet
aca102a35e XFA - Add margins if needed after having layout some text 2021-06-22 10:36:01 +02:00
calixteman
b886b6c995
Merge pull request #13604 from calixteman/xfa_proto_propr
XFA - A prototype can have a property which needs itself to resolve a proto
2021-06-22 09:58:29 +02:00
calixteman
e84b3bbf6e
Merge pull request #13592 from calixteman/xfa_print_only
XFA - Don't display print-only elements
2021-06-21 21:02:53 +02:00
Calixte Denizet
72c32b3498 XFA - A prototype can have a property which needs itself to resolve a proto 2021-06-21 17:26:29 +02:00
calixteman
56a75f8b26 Revert "Revert "XFA - Fix the way to select page on breaking"" - and fix the error which caused the backout: add an $extra property when creating html. - switch to next content area when breaking on page area. 2021-06-21 17:07:31 +02:00
calixteman
a9385bbb52
Revert "XFA - Fix the way to select page on breaking" 2021-06-21 15:45:04 +02:00
calixteman
da19997781
Merge pull request #13573 from calixteman/bug1716838
XFA - Fix the way to select page on breaking
2021-06-21 15:06:03 +02:00
Calixte Denizet
7aea8faa34 XFA - Fix the way to select page on breaking
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716838.
  - some fonts in the pdf in the bug where bold when they shouldn't so write the font properties in the html to avoid to use some wrong inherited ones.
2021-06-21 12:45:23 +02:00
calixteman
34acf29403
Merge pull request #13593 from calixteman/xfa_rect_border
XFA - Don't display invisible rectangle borders
2021-06-21 12:24:23 +02:00
Calixte Denizet
d99a7c070f XFA - Don't display print-only elements
- partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716980.
2021-06-21 10:08:10 +02:00
Calixte Denizet
7cb92a64b1 XFA - Add support for access property
- it's a partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716816.
2021-06-21 09:56:28 +02:00
calixteman
2e6d3d6b00
Merge pull request #13591 from calixteman/xfa_default_font
XFA - Match font family correctly
2021-06-21 09:28:59 +02:00
Calixte Denizet
d76f11a0ce XFA - Don't display invisible rectangle borders
- partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716980.
2021-06-20 15:45:58 +02:00
Calixte Denizet
7cdbc98716 XFA - Match font family correctly
- partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716980;
  - some pdf can contain an invalid font family (e.g. 'Windings 3') so in this case remove the space;
  - the font family in typeface attribute doesn't always match the one defined in the FontDescriptor dictionary.
2021-06-20 15:16:28 +02:00
Jonas Jenwald
c4334dcfe7 Allow using the standard font data for non-Type1 fonts (issue 13585, PR 12726 follow-up)
Given that we're not imposing any font-type restrictions[1] in the non-/FontDescriptor case, it's not really clear to me why we'd actually need to do that in the general case.
Please note that there's some *expected* movement, all of which should be improvements, in the `fips197.pdf` file with this patch.

---
[1] With the exception of Type3-fonts, of course.
2021-06-20 11:13:49 +02:00
Jonas Jenwald
d9ed14a2f5 Set the default value of useSystemFonts correctly, depending on disableFontFace, in the API (PR 13516 follow-up)
*Sorry about the churn here, since the change that I made in PR 13516 was not very smart.*

With the current code, it's now *impossible* for a user to actually control the `useSystemFonts` option manually. To prevent outright breakage we obviously still need to default to setting `useSystemFonts = false` when `disableFontFace === true`, however that should be possible for an API consumer to override.
2021-06-19 13:53:13 +02:00
Brendan Dahl
5d251a3a3e
Merge pull request #13566 from calixteman/layout4
XFA - Fix layout issues
2021-06-17 13:23:28 -07:00
Calixte Denizet
e65b41f891 XFA - When no fonts in the pdf just use font size as width when measuring text 2021-06-17 16:50:56 +02:00
Calixte Denizet
df08b1548b XFA - Fix layout issues
- PR #13554 is buggy, so this patch aims to fix bugs.
  - check if a component fits into its parent in taking into account the parent layout.
  - introduce method isSplittable for template nodes to know if a component can be splitted in case of overflow.
2021-06-17 16:09:22 +02:00
Calixte Denizet
226c228c2a XFA - Fix reftest for xfa_issue13500 2021-06-17 15:48:13 +02:00
Calixte Denizet
8eeb7ab4a3 XFA - Add the possibily to layout and measure text
- some containers doesn't always have their 2 dimensions and those dimensions re based on contents;
  - so in order to measure text, we must get the glyph widths (for the xfa fonts) before starting the layout;
  - implement a word-wrap algorithm;
  - handle font change during text layout.
2021-06-17 14:17:02 +02:00
calixteman
335d4cb2fc
Merge pull request #13570 from calixteman/xfa_field
XFA - By default a text ui has only one line when in a field element
2021-06-17 09:09:59 +02:00
Calixte Denizet
793a0156ce XFA - By default a text ui has only one line when in a field element
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716809.
2021-06-16 20:18:29 +02:00
calixteman
473322298f
Merge pull request #13569 from calixteman/visibility
XFA - Container wrapper must take the visibility of the wrapped content
2021-06-16 18:55:44 +02:00
Calixte Denizet
143d190a61 XFA - Container wrapper must take the visibility of the wrapped content 2021-06-16 17:29:02 +02:00
Jonas Jenwald
7fa61c062c
Merge pull request #13393 from Snuffleupagus/adjustToUnicode-hasIncludedToUnicodeMap
Tweak `adjustToUnicode` to allow extending a built-in /ToUnicode map
2021-06-16 17:06:17 +02:00
Calixte Denizet
0ea5792c86 XFA - Add support for overflow element
- and fix few bugs:
    - avoid infinite loop when layout the document;
    - avoid confusion between break and layout failure;
    - don't add margin width in tb layout when getting available space.
2021-06-15 12:32:01 +02:00
Jonas Jenwald
229a49b9b9 Re-factor the fallbackToUnicode functionality (PR 9192 follow-up)
Rather than having to create and check a *separate* `ToUnicodeMap` to handle these cases, we can simply use the `fallbackToUnicode`-data (when it exists) to directly supplement *missing* /ToUnicode entires in the regular `ToUnicodeMap` instead.
2021-06-14 15:05:14 +02:00
Jonas Jenwald
7190bc23a8 Remove unnecessary in checks of Arrays, when building the charCodeToGlyphId for TrueType fonts
Note that all standard Encodings have the same length (i.e. `256` elements) and that missing entries are always represented by empty strings, hence why a separate exists-check isn't necessary in the `baseEncoding` case.
2021-06-14 15:05:14 +02:00
Jonas Jenwald
edc38de37a Convert PartialEvaluator.buildToUnicode to an async method
This removes the need to *manually* wrap all return values in a Promise.
2021-06-14 15:05:14 +02:00
Jonas Jenwald
3660aaac85 Tweak adjustToUnicode to allow extending a built-in /ToUnicode map
*This is somewhat similiar to the recent changes, in PR 13277, for fonts with an /Encoding entry.*

Currently we're *completely* ignoring the `builtInEncoding`, from the font data itself, for fonts which have a built-in /ToUnicode map.
While it (obviously) doesn't seem like a good idea in general to simply overwrite existing built-in /ToUnicode entries, it should however not hurt to use the `builtInEncoding` to supplement *missing* /ToUnicode entires.
2021-06-14 15:05:14 +02:00
Calixte Denizet
d89c429d78 XFA - Handle maxChars property for text fields
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716294.
2021-06-14 13:07:06 +02:00
Calixte Denizet
150fa3d96e XFA - Fix error when creating a new data node
- fix for issue #13556;
  - value in a field can be empty.
2021-06-14 11:33:08 +02:00
Calixte Denizet
088db47849 XFA - Value in field can be html 2021-06-13 19:50:28 +02:00
calixteman
96c103462a
Merge pull request #13548 from calixteman/default_fill
XFA - Default fill color for rectangle is transparent
2021-06-13 14:11:22 +02:00
Brendan Dahl
5a4e06af2d
Merge pull request #13547 from calixteman/cerfa
XFA - Handle correctly subformSet
2021-06-11 13:09:43 -07:00
Calixte Denizet
694b14c047 XFA - Default fill color for rectangle is transparent 2021-06-11 18:03:19 +02:00
Calixte Denizet
d1e945998b XFA - Handle correctly subformSet
- it aims to avoid to loop forever when opening pdf in #13213;
  - the idea is to consider subformSet as inexistent when running in the tree. So if we've subformA > subformSet > subformB then subformB will be visited as a direct child of subformA.
2021-06-11 17:49:17 +02:00
Calixte Denizet
da4916e3c1 XFA - Center vertically radio without caption
- and fix intent value which is used to name the radio button group.
2021-06-11 13:24:45 +02:00
Calixte Denizet
367d1ad137 XFA - Return html element for the different possible value
- it aims to fix #13536.
2021-06-11 11:51:54 +02:00
Brendan Dahl
a3b0596cf2
Merge pull request #13534 from calixteman/missing_page
XFA - Flush contents when breakBefore target is 'auto'
2021-06-10 13:17:20 -07:00
Calixte Denizet
d7d53e7c6c XFA - Flush contents when breakBefore target is 'auto'
- some page can be missed in the final document because of that (see pdf in the test case which has 4 pages (when only 3 are rendered right now)
2021-06-10 17:15:08 +02:00
Calixte Denizet
58633ab9fd XFA - Give all the available space to the caption in case of checkButton
- a checkbox or radio doesn't have to be rescaled when the container is large so give the extra space to the caption to avoid some word wrapping.
  - when the caption is on the right, then put ui on the left as first element and so remove flex:row-reverse stuff.
2021-06-10 15:30:23 +02:00
Calixte Denizet
3bd936709c XFA - Handle caption with inline placement as left one
- it's just a temporary workaround to unblock release in Firefox.
2021-06-09 22:13:48 +02:00
Brendan Dahl
d333af7848
Merge pull request #13527 from calixteman/bind_inf_loop
XFA - Avoid infinite loop when creating some nodes in data
2021-06-09 12:37:29 -07:00
Brendan Dahl
aa2712744d
Merge pull request #13502 from calixteman/contentarea
XFA - contentarea must be on top of the other containers in a pageArea
2021-06-09 12:36:21 -07:00
Jonas Jenwald
69477bfb06 Always use standard font data, with disableFontFace set in the API (PR 12726 follow-up)
We must force-fetch standard font data, when `disableFontFace = true` is set in the API, since otherwise rendering in e.g. the viewer is still broken (same as before PR 12726 landed).

*Please note:* We still need to also load standard font data for patterns and/or some text-rendering modes, however that will require larger changes so I figured that it cannot hurt to submit *this* patch right now.
2021-06-09 21:21:02 +02:00
Calixte Denizet
cddc1d869d XFA - Avoid infinite loop when creating some nodes in data 2021-06-09 19:07:59 +02:00
Jonas Jenwald
a01c599247 Cache the "raw" standard font data in the worker-thread (PR 12726 follow-up)
*This implementation is basically a copy of the pre-existing `builtInCMapCache` implementation.*

For some, badly generated, PDF documents it's possible that we'll end up having to fetch the *same* standard font data over and over (which is obviously inefficient).
While not common, it's certainly possible that a PDF document uses *custom* font names where the actual font then references one of the standard fonts; see e.g. issue 11399 for one such example.

Note that I did suggest adding worker-thread caching of standard font data in PR 12726, however it wasn't deemed necessary at the time. Now that we have a real-world example that benefit from caching, I think that we should simply implement this now.
2021-06-09 18:27:51 +02:00
calixteman
6d88d8cdaa
Merge pull request #13517 from calixteman/liberation
XFA - Add Liberation-Sans font as a substitution for some missing fonts
2021-06-09 18:19:07 +02:00
Calixte Denizet
34a2fa72c7 XFA - Add Liberation-Sans font as a substitution for some missing fonts
- Some js files contain scale factors for each glyph in order to rescale Liberation to have a final font with the correct width.
  - A lot of XFA have some containers where their dimensions are based on their text content, so using default font from browser can lead to an almost unreadable pdf.
2021-06-09 16:55:45 +02:00
Calixte Denizet
fd1110adb4 Add the possibility to rescale each glyph in a font
- a lot of xfa files are using Myriad pro or Arial fonts without embedding them and some containers have some dimensions based on those font metrics. So not having the exact same font leads to a wrong display.
  - since it's pretty hard to find a replacement font with the exact same metrics, this patch gives the possibility to read glyf table, rescale each glyph and then write a new table.
  - so once PR #12726 is merged we could rescale for example Helvetica to replace Myriad Pro.
2021-06-09 16:01:13 +02:00
Calixte Denizet
1f6345b6c2 XFA - Display rectangle, line and arc 2021-06-09 15:34:31 +02:00
Calixte Denizet
1486608f32 XFA - contentarea must be on top of the other containers in a pageArea 2021-06-09 15:29:29 +02:00
Jonas Jenwald
d995f90183 Fetch binary CMap data in the worker-thread, when useWorkerFetch is set
This patch uses the new option added in PR 12726 to *also* allow fetching binary CMap data directly in the worker-thread in browsers.
Given that these changes remove the need to transfer data between threads for the default (browser) use-case, we can also revert the changes in PR 11118 since that simplifies the overall implementation.
2021-06-08 21:51:07 +02:00
Calixte Denizet
cfa727474e XFA - Fix layout issues (again)
- some elements weren't displayed because their rotation angle was not taken into account;
  - fix box model (XFA concept):
    - remove use of outline;
    - position correctly border which isn't part of box dimensions;
    - fix margins issues (see issue #13474).
  - move border on button instead of having it on wrapping div;
2021-06-08 17:42:53 +02:00
Jonas Jenwald
e7dc822e74
Merge pull request #12726 from brendandahl/standard-fonts
[api-minor] Include and use the 14 standard font files.
2021-06-08 10:09:40 +02:00
Brendan Dahl
4c1dd47e65 Include and use the 14 standard fonts files. 2021-06-07 11:10:11 -07:00
Calixte Denizet
5dc7f4ade8 XFA - CDATA can be xml so parse it when required 2021-06-07 10:38:39 +02:00
Calixte Denizet
112645ea3d XFA - Don't bind a form node with an empty value when the data node doesn't exist 2021-06-06 17:59:01 +02:00
Tim van der Meij
2b63d97b9d
Merge pull request #13461 from Snuffleupagus/issue-6605
Improve text-selection for Type3 fonts with empty /FontBBox-entries (issue 6605)
2021-06-06 14:37:52 +02:00
Jonas Jenwald
1dd01b8506
Merge pull request #13494 from brendandahl/stepper-show-text
Add more info for showText operator in stepper.
2021-06-05 08:37:11 +02:00
Jonas Jenwald
eefc94ceb7 Ensure that we fully load Type3 fonts in PartialEvaluator.getTextContent
This is necessary now, since with the previous patch the /FontBBox potentially depends on the contents of the /CharProcs-streams.
Note that if `getOperatorList` is called *before* `getTextContent`, this patch doesn't matter since the font is already fully loaded/parsed. However, for e.g. the `text` test-cases this is necessary to ensure correct reference images.
2021-06-05 08:09:29 +02:00
Jonas Jenwald
20770cb06a Improve text-selection for Type3 fonts with empty /FontBBox-entries (issue 6605)
For Type3 fonts where the /CharProcs-streams of the individual glyph starts with a `d1` operator, we can use that to build a fallback bounding box for the font and thus improve text-selection in some cases.
2021-06-05 08:09:29 +02:00
Brendan Dahl
6255c2a8f3
Merge pull request #13376 from calixteman/6132
Replace command with not enough args by an endchar in CFF font
2021-06-04 14:00:51 -07:00
Brendan Dahl
17f1857556 Add more info for showText operator in stepper.
Adds a table that shows original char code, font char code, and unicode.
2021-06-04 13:58:05 -07:00
Jonas Jenwald
75113e4517 Initialize HTMLResult.{FAILURE, EMPTY} lazily
While these objects aren't exactly that big and/or complex, they are nonetheless *only* necessary for XFA documents.
However, currently these objects are initialized *eagerly* for all PDF documents. By using the same pattern as elsewhere in the code-base, it's very easy to make these lazily initialized; so let's just do that instead :-)
2021-06-04 21:01:14 +02:00
Calixte Denizet
11573ddd16 XFA - Implement usehref support
- attribute 'use' was already implemented but not usehref
  - in general, usehref should make reference to current document
  - add support for SOM expressions in use and usehref to search a node.
  - get prototype for all nodes if any.
2021-06-04 14:57:05 +02:00
Calixte Denizet
f61f80a5a3 XFA - Use native radio and checkbox buttons
- Remove current stuff which relies on some system fonts to avoid bad rendering.
2021-06-01 21:25:38 +02:00
Jonas Jenwald
3456ed271b
Merge pull request #13378 from calixteman/10544
Replace terminal null char by a endchar command in CFF charstrings to make OTS happy
2021-06-01 16:04:09 +02:00
Jonas Jenwald
e3bde56311 Ensure that the old/new options are correctly combined in PartialEvaluator.clone 2021-05-31 12:14:53 +02:00
calixteman
8c53bf8647
Merge pull request #13437 from calixteman/xfa_mv_root
XFA - Move the fake HTML representation of XFA from the worker to the main thread
2021-05-31 10:14:15 +02:00
Ikko Ashimine
c66289f1fc
Fix typo in template.js
refering -> referring
2021-05-31 01:02:07 +09:00
Tim van der Meij
a0ce3cb3b4
Merge pull request #13448 from Snuffleupagus/_setDefaultAppearance-alpha
Support strokeAlpha/fillAlpha when creating a fallback appearance stream (issue 6810)
2021-05-28 23:39:36 +02:00
Tim van der Meij
5e5641b147
Merge pull request #13457 from Snuffleupagus/issue-13242
Work-around for HighlightAnnotations without a top-level /ExtGState-entry (issue 13242)
2021-05-28 23:38:39 +02:00
Tim van der Meij
0d56b1c365
Merge pull request #13443 from Snuffleupagus/charsCache
Re-factor the `charsCache` on `Font`-instances
2021-05-28 21:29:57 +02:00
Brendan Dahl
a6484c9861
Merge pull request #13427 from calixteman/xfa_storage
XFA - Add a storage to save fields values
2021-05-28 12:10:08 -07:00
Jonas Jenwald
707a9e3b02 Work-around for HighlightAnnotations without a top-level /ExtGState-entry (issue 13242)
For HighlightAnnotations with a built-in appearance stream, we still rely on it to specify the opacity correctly via a suitable blend mode. However, if the Annotation-drawing operators are placed *within* a /XObject of the /Form-type, the /ExtGState won't apply to the final rendering and the result is that the highlighting obscures the underlying text.

The more *correct* and general solution would likely be to somehow modify the implementation in `src/display/canvas.js`, to special-case handling of /Form-type /XObjects when rendering Annotations. Since we can very easily work-around this problem for now by using the "no appearance stream" code-path, doing *something* here ought to be preferable.

This patch is (obviously) merely a work-around, but given that the referenced issue is (as far as I know) the first case we've seen of this problem a simple solution will hopefully suffice for now.
2021-05-28 13:49:27 +02:00
calixteman
e499521b78
Merge pull request #13456 from calixteman/clazz
Replace clazz by classNames
2021-05-28 12:18:27 +02:00
Calixte Denizet
f35176a32e Replace clazz by classNames 2021-05-28 11:17:38 +02:00
Calixte Denizet
1b0006093d Italic angle is defined clockwise in CSS when it's counterclockwise in PDF 2021-05-28 11:06:11 +02:00
Jonas Jenwald
52c13326cd Support Annotations, without appearance streams, with bogus /Rect-entries (issue 13447)
This extends PR 13106 to apply not only to empty /Rect-entries, but also to bogus /Rect-entries for various Annotation-types.
2021-05-27 16:23:21 +02:00
Jonas Jenwald
a6447f2ca2 Support strokeAlpha/fillAlpha when creating a fallback appearance stream (issue 6810)
This fixes the colours, by respecting the strokeAlpha/fillAlpha-values, for a couple of Annotations in the PDF document from issue 13447.[1]

---
[1] Some of the annotations still won't render at all, when compared with Adobe Reader, but that could/should probably be handled separately.
2021-05-27 16:23:18 +02:00
calixteman
f587d5998e
Merge pull request #13445 from calixteman/ps_name
Fix Postscript name in font to avoid bug when saving in pdf
2021-05-27 13:52:47 +02:00
Calixte Denizet
0c698346b8 Fix Postscript name in font to avoid bug when saving in pdf
- for xfa rendering, fonts are loaded and used in html;
  - when printed and saved in pdf, on linux, Firefox uses cairo backend
  - when subsetting a font, cairo uses the font postscript name and when this one is empty that leads to a bug
    (the append at 63f0d62684/src/cairo-cff-subset.c (L2049) is failing because of null length)
  - so this patch adds a postscript name to the font to make cairo happy.
2021-05-27 12:45:40 +02:00
Jonas Jenwald
8b1d01816b Re-factor the charsCache on Font-instances
Currently `charsCache` is initialized *lazily*, which considering that it just contains a simple `Object` doesn't seem entirely necessary. This first of all forces us to do repeated exists-checks in the `Font.charsToGlyphs` method, and secondly the similar/related `glyphCache` is already initialized eagerly.

Furthermore, this patch also does a bit of clean-up in the `Font.charsToGlyphs` method since this code is quite old.
2021-05-26 13:13:44 +02:00
Tim van der Meij
3da9f077be
Merge pull request #13435 from Snuffleupagus/eslint-no-array-push-push
Enable the `unicorn/no-array-push-push` ESLint plugin rule
2021-05-25 21:10:01 +02:00
Calixte Denizet
45c3f00a27 XFA - Move the fake HTML representation of XFA from the worker to the main thread
- the only goal of this patch is to be able to get synchronously the fake html when printing from firefox:
    - in order to print we need to inject some html in beforeprint callback but we cannot block in waiting for all the pages.
  - from a memory point of view: it doesn't change anything since the fake HTML is deleted in the worker;
  - this way we don't break any assumptions.
2021-05-25 19:33:07 +02:00
Calixte Denizet
9478d2f064 XFA - Add a storage to save fields values - this is required to be able to print (or save) a document. Some pages can be unloaded (because pdf.js is lazy) and this storage will help to save their data in order to resuse them when printing or just when displaying a page again. 2021-05-25 19:25:09 +02:00
Calixte Denizet
7cebdbd58c XFA - Fix lot of layout issues
- I thought it was possible to rely on browser layout engine to handle layout stuff but it isn't possible
    - mainly because when a contentArea overflows, we must continue to layout in the next contentArea
    - when no more contentArea is available then we must go to the next page...
    - we must handle breakBefore and breakAfter which allows to "break" the layout to go to the next container
  - Sometimes some containers don't provide their dimensions so we must compute them in order to know where to put
    them in their parents but to compute those dimensions we need to layout the container itself...
  - See top of file layout.js for more explanations about layout.
  - fix few bugs in other places I met during my work on layout.
2021-05-25 17:51:36 +02:00
Jonas Jenwald
ec3bcadf56 Enable the unicorn/no-array-push-push ESLint plugin rule
There's generally speaking no need to use multiple consecutive `Array.prototype.push()` calls, since that method accepts multiple arguments, and this ESLint rule helps enforce that pattern.

Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-push-push.md for additional information.
2021-05-25 13:54:46 +02:00
Calixte Denizet
209ac5ca57 XFA - Don't display images with a href 2021-05-22 15:09:43 +02:00
calixteman
0df1a56619
Merge pull request #13417 from Snuffleupagus/xfa-URL-clone
[XFA] Send URLs as strings, rather than objects (issue 1773)
2021-05-22 14:31:59 +02:00
Tim van der Meij
de680d7777
Merge pull request #13381 from Snuffleupagus/buildFontPaths-ignoreErrors
Handle errors gracefully, in PartialEvaluator.buildFontPaths, when glyph path building fails
2021-05-22 13:06:31 +02:00
Jonas Jenwald
53a70244d0 Use the stringToBytes helper function in more places
Rather than manually reimplementing, more-or-less, this functionality in a few spots we can simply use the existing helper function instead.
2021-05-22 12:23:09 +02:00
Jonas Jenwald
ba13bd8c2d [XFA] Send URLs as strings, rather than objects (issue 1773)
Given that `URL`s aren't supported by the structured clone algorithm, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, the document in issue 1773 will cause the browser to throw `DataCloneError: The object could not be cloned.`-errors and nothing will render.
To fix this, we'll instead simply send the stringified version of the `URL` to prevent these errors from occuring.
2021-05-22 11:58:53 +02:00
Jonas Jenwald
c4429bc3f2 Do the isType3Font-check *once*, rather than repeating it, in PartialEvaluator.translateFont
*This is a small piece of clean-up that I happened to notice while browsing the code.*
2021-05-22 11:46:37 +02:00
Jonas Jenwald
68350378c0 Handle errors gracefully, in PartialEvaluator.buildFontPaths, when glyph path building fails
The building of glyph paths, in the `FontRendererFactory`, can fail in various ways for corrupt font data. However, we're currently not attempting to handle any such errors in the evaluator, which means that a single broken glyph *can* prevent an entire page from rendering.

To address this we simply have to pass along, and check, the existing `ignoreErrors` option in `PartialEvaluator.buildFontPaths` similar to the rest of the `PartialEvaluator` code.
2021-05-22 11:46:31 +02:00
Tim van der Meij
b2ffebe978
Merge pull request #13416 from calixteman/xfa_config
XFA - Fix wrong function name
2021-05-21 20:33:35 +02:00
Calixte Denizet
8a8879aed2 XFA - Fix wrong function name 2021-05-21 20:25:26 +02:00
Tim van der Meij
d1d9b9043d
Merge pull request #13415 from Snuffleupagus/getDestination-out-of-order
Improve handling of named destinations in out-of-order NameTrees (PR 10274 follow-up)
2021-05-21 20:15:09 +02:00
Jonas Jenwald
8d5689387b Improve handling of named destinations in out-of-order NameTrees (PR 10274 follow-up)
According to the specification, see https://web.archive.org/web/20210404042322if_/https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2384179, the keys of a NameTree/NumberTree should be ordered.
For corrupt PDF files, which violate this assumption, it's thus possible that trying to lookup a single entry fails.

Previously, in PR 10274, we implemented a fallback that only applies to the "bottom" node of a NameTree/NumberTree, which in general might not actually help for sufficiently corrupt NameTree/NumberTree data.
Instead we remove the current *limited* fallback from `NameOrNumberTree.get`, and defer to the call-site to handle this case explicitly e.g. by using `NameOrNumberTree.getAll` for data where that makes sense. For well-formed documents, these changes should *not* lead to any additional data fetching/parsing.

Finally, as part of these changes, the validation of named destination data is improved in the `Catalog` and a new unit-test is also added.
2021-05-21 15:48:37 +02:00
Jonas Jenwald
1a8d05fdcf Remove some, with Prettier 2.3.0, unnecessary // prettier-ignore comments
To get the maximum benefit from something like Prettier, you obviously don't want to disable the automatic formatting unless absolutely necessary. When we added Prettier there were a number of cases, mostly involving larger Arrays, which required disabling of the automatic formatting for overall readability and/or to not break inline comments.

With changes in Prettier version `2.3.0`, see [the release notes](https://prettier.io/blog/2021/05/09/2.3.0.html#concise-formatting-of-number-only-arrays-10106httpsgithubcomprettierprettierpull10106-10160httpsgithubcomprettierprettierpull10160-by-thorn0httpsgithubcomthorn0), there's now better formatting support for Arrays containing only numbers. Hence we can now remove a number of `// prettier-ignore` comments, and thus get the benefit of automatic formatting in (slightly) more of the code-base.
2021-05-19 11:36:03 +02:00
calixteman
faf6b10939
Merge pull request #13394 from calixteman/xml_parser
Handle PI with no value in xml parser
2021-05-18 11:14:48 +02:00
Calixte Denizet
4544ebf38a Handle PI with no value in xml parser
- an XML PI contains a target and optionally some content (see https://en.wikipedia.org/wiki/Processing_Instruction)
  - the parser expected to always have some content and so it could lead to wrong parsing.
2021-05-18 10:22:18 +02:00
Brendan Dahl
239d0097fa
Merge pull request #13390 from calixteman/opentype_and_xfa
XFA - Don't move glyphes in private area with non-truetype fonts
2021-05-17 12:39:10 -07:00
Brendan Dahl
46c2eeb19a
Merge pull request #13389 from calixteman/width_in_cff
Get any width (if one is present) in CFF parser
2021-05-17 09:13:45 -07:00
Brendan Dahl
17e9cfcd2a
Merge pull request #13328 from calixteman/js_display1
JS - Add support for display property
2021-05-17 08:47:13 -07:00
Calixte Denizet
a74d19262a XFA - Don't move glyphes in private area with non-truetype fonts
- it has been done in PR #13146 but only for truetype fonts.
2021-05-17 16:52:39 +02:00
Calixte Denizet
d394188835 Get any width (if one is present) in CFF parser
- in charstring specs at page 21 (section 4.2): "Also, it may appear in the charstring as the difference from nominalWidthX" so the number we've on the stack doesn't have to be positive.
  - currently this bug has probably no visible effect
  - but when the font is loaded to be used with XFA, then the rendering is incorrect.
2021-05-17 14:17:08 +02:00
Jonas Jenwald
718f7bf7e1 Fix a few *safe* ESLint no-var failures in src/core/evaluator.js (13371 follow-up)
As can be seen in PR 13371, some of the `no-var` changes in the `PartialEvaluator.{getOperatorList, getTextContent}` methods caused errors in `gulp server`-mode.
However, there's a handful of instances of `var` in other methods which should be completely *safe* to convert since there's no strange scope-issues present in that code.
2021-05-16 15:22:43 +02:00
Tim van der Meij
a5c74f53c1
Merge pull request #13386 from timvandermeij/src-core-bidi-no-var
Enable the `no-var` linting rule in `src/core/bidi.js`
2021-05-16 15:02:18 +02:00
Tim van der Meij
b8a5e797c5
Enable the no-var linting rule in src/core/bidi.js
This is done automatically with `gulp lint --fix` and the following
manual changes:

```diff
diff --git a/src/core/bidi.js b/src/core/bidi.js
index e9e0a7217..32691c0c6 100644
--- a/src/core/bidi.js
+++ b/src/core/bidi.js
@@ -82,7 +82,8 @@ function isEven(i) {
 }

 function findUnequal(arr, start, value) {
-  for (var j = start, jj = arr.length; j < jj; ++j) {
+  let j, jj;
+  for (j = start, jj = arr.length; j < jj; ++j) {
     if (arr[j] !== value) {
       return j;
     }
@@ -251,15 +252,14 @@ function bidi(str, startLevel, vertical) {
   for (i = 0; i < strLength; ++i) {
     if (types[i] === "EN") {
       // do before
-      var j;
-      for (j = i - 1; j >= 0; --j) {
+      for (let j = i - 1; j >= 0; --j) {
         if (types[j] !== "ET") {
           break;
         }
         types[j] = "EN";
       }
       // do after
-      for (j = i + 1; j < strLength; ++j) {
+      for (let j = i + 1; j < strLength; ++j) {
         if (types[j] !== "ET") {
           break;
         }
```
2021-05-16 14:14:26 +02:00
Jonas Jenwald
3cfa316d40 Convert src/core/operator_list.js to use standard classes
With modern JavaScript modules, where only *explicitly* exported properties are visible to the outside, the `QueueOptimizerClosure` should no longer be necessary.

Furthermore, to reduce the possibility of `NullOptimizer` and `QueueOptimizer` getting out of sync (note e.g. the inconsistency fixed in PR 10784), we now let the latter extend the former one.
2021-05-16 13:39:54 +02:00
Jonas Jenwald
8943bcd3c3 Account for formatting changes in Prettier version 2.3.0
With the exception of one tweaked `eslint-disable` comment, in `web/generic_scripting.js`, this patch was generated automatically using `gulp lint --fix`.

Please find additional information at:
 - https://github.com/prettier/prettier/releases/tag/2.3.0
 - https://prettier.io/blog/2021/05/09/2.3.0.html
2021-05-16 11:44:05 +02:00
Tim van der Meij
d2e7161f2c
Merge pull request #13377 from Snuffleupagus/pattern-class
Re-factor and convert the code in `src/core/pattern.js` to use standard classes
2021-05-14 22:23:44 +02:00
Jonas Jenwald
ebe3ee4f25 Modernize the Shadings structure, in src/core/pattern.js, to use standard classes
This patch replaces the old structure with a abstract base-class, which the new RadialAxial/Mesh-shading classes then inherit from.[1]
The old `MeshClosure` can now be removed, since it's not necessary any more, and most of the functions inside of it are now instead methods on the new `MeshShading` class. This is particularly nice, in my opinion, since we previously were *manually* passing around a reference to the current `Mesh`-instance.

---
[1] If we want/need to, in the future, split e.g. the Mesh-handling into multiple classes that should now be easy to do.
2021-05-14 21:44:41 +02:00
Jonas Jenwald
6acb2db4be Convert src/core/pattern.js to use standard classes
Note that this patch only covers `Pattern` and `MeshStreamReader`, since the `Shadings`-implementation required additional re-factoring.
2021-05-14 21:42:21 +02:00
Calixte Denizet
f92e1fa160 Replace terminal null char by a endchar command in CFF charstrings to make OTS happy 2021-05-14 18:34:51 +02:00
Jonas Jenwald
612b43852b Remove unused properties from the Shadings-implementations in src/core/pattern.js
Neither the `type` or the `cs` properties are used outside of the "constructors", and we can thus remove them.[1]
Note that a lot of this code is very old, and that it actually predates the main/worker-thread split before which the *same* file was used on both the main- *and* worker-threads.

---
[1] On the main-thread, a similar `type` property was removed in PR 12591.
2021-05-14 16:11:48 +02:00
Calixte Denizet
1a2cea21a5 Replace command with not enough args by an endchar in CFF font
- Right now, a glyph with an erroneous outline is replaced by an empty glyph
    if the error is far enough from the start there's likely something to render
    so the idea is to replace a command with args by an endchar when no args are
    on the stack: this way OTS is likely happy (no remaining args on stack) and we
    can draw something which is likely better than nothing.
2021-05-14 13:45:45 +02:00
Jonas Jenwald
4248f0745c Improve the Page.content and Page.getContentStream methods
First of all, by using `Dict.getArray` in the `Page.content` getter we remove the need to manually iterate through and fetch the sub-streams (when they exist) in the `Page.getContentStream` method.
Secondly, we can simplify the code in `Page.{getOperatorList, extractTextContent}` by letting `Page.getContentStream` ensure that `content` is available and returning a Promise instead.
2021-05-14 11:47:34 +02:00
Jonas Jenwald
70113131de Inline the data lookup in the Dict.getArray method
Similar to the `get`/`getAsync` methods, this should be a *tiny* bit more efficient which cannot hurt considering that `getArray` is now used a lot more than when initially added.
2021-05-14 11:24:27 +02:00
Jonas Jenwald
75208d36c2 Revert "Fix the remaining no-var failures, which couldn't be handled automatically, in the src/core/evaluator.js file" (PR 13344 follow-up)
This reverts commit 0ef9b5aafc, since it cases a lot of warnings (see below) *locally* with e.g. the document from issue 9627.
Strangely enough, this only occurs with `gulp server`-mode and the actual builds are apparently fine. It seems that this *may* be some unfortunate interaction with the old Babel-plugin that's used together with SystemJS.

```
Warning: getTextContent - ignoring ExtGState: "FormatError: ExtGState should be a dictionary.".
```

Rather than taking the risk that this could actually cover a more serious bug, and since I cannot immediately figure out what's wrong, it thus seem safest to revert this for now and we can (carefully) revisit this once SystemJS has been removed (see PR 12563).
2021-05-13 11:19:46 +02:00
Tim van der Meij
ba99e54c66
Merge pull request #13361 from brendandahl/patterns-fixes
Fix several issues with radial/axial shadings and tiling patterns.
2021-05-12 20:27:37 +02:00
Jonas Jenwald
757636d519 Convert the remaining functions in src/core/primitives.js to use standard classes
This patch was tested using the PDF file from issue 2618, i.e. https://bug570667.bugzilla-attachments.gnome.org/attachment.cgi?id=226471, with the following manifest file:
```
[
    {  "id": "issue2618",
       "file": "../web/pdfs/issue2618.pdf",
       "md5": "",
       "rounds": 50,
       "type": "eq"
    }
]
```

which gave the following results when comparing this patch against the `master` branch:
```
-- Grouped By browser, stat --
browser | stat         | Count | Baseline(ms) | Current(ms) | +/- |   %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | --- | ---- | -------------
firefox | Overall      |    50 |         3417 |        3426 |   9 | 0.27 |
firefox | Page Request |    50 |            1 |           1 |   0 | 5.41 |
firefox | Rendering    |    50 |         3416 |        3426 |   9 | 0.27 |
```

Based on these results, there's no significant performance regression from using standard classes and this patch should thus be OK.
2021-05-12 09:36:28 +02:00
Brendan Dahl
ac44afa70e Fix several issues with radial/axial shadings and tiling patterns.
Previously, we set the base transformation and pattern matrix
directly to the main rendering ctx of the page, however doing this
caused the current transform to be lost. This would cause issues
with things like shear missing so the pattern was misaligned or when
stroke was used the scale of the line width or dash would be wrong.
Instead we should leave the current transform and use setTransfrom
on the pattern so it is applied correctly. For axial and radial shadings I had
to create a temporary canvas to draw the shading so I could in turn
use setTransform.

Fixes: #13325, #6769, #7847, #11018, #11597, #11473

The following already in the corpus are improved:
issue8078-page1
issue1877-page1
2021-05-11 16:32:24 -07:00
Jonas Jenwald
6eef69de22 Export the "raw" toUnicode-data from PartialEvaluator.preEvaluateFont
Compared to other data-structures, such as e.g. `Dict`s, we're purposely *not* caching Streams on the `XRef`-instance.[1]
The, somewhat unfortunate, effect of Streams not being cached is that repeatedly getting the *same* Stream-data requires re-parsing/re-initializing of a bunch of data; see `XRef.fetch` and related methods.

For the font-parsing in particular we're currently fetching the `toUnicode`-data, which is very often a Stream, in `PartialEvaluator.preEvaluateFont` and then *again* in `PartialEvaluator.extractDataStructures` soon afterwards.
By instead letting `PartialEvaluator.preEvaluateFont` export the "raw" `toUnicode`-data, we can avoid *some* unnecessary re-parsing/re-initializing when handling fonts.
*Please note:* In this particular case, given that `PartialEvaluator.preEvaluateFont` only accesses the "raw" `toUnicode` data, exporting a Stream should be safe.

---
[1] The reasons for this include:
 - Streams, especially `DecodeStream`-instances, can become *very* large once read. Hence caching them really isn't a good idea simply because of the (potential) memory impact of doing so.

 - Attempting to read from the *same* Stream-instance more than once won't work, unless it's `reset` in between, since using any method such as e.g. `getBytes` always starts at the current data position.

 - Given that parsing, even in the worker-thread, is now fairly asynchronous it's generally impossible to assert that any one Stream-instance isn't being accessed "concurrently" by e.g. different `getOperatorList` calls. Hence `reset`-ing a cached Stream-instance isn't going to work in the general case.
2021-05-08 12:04:13 +02:00
Jonas Jenwald
13fb1654dc Export the firstChar/lastChar-data from PartialEvaluator.preEvaluateFont
Rather than re-fetching/re-parsing these properties immediately in `PartialEvaluator.translateFont`, we can simply export them instead. (Obviously the effect will be really tiny, but there is less parsing overall this way.)
2021-05-08 12:02:49 +02:00
Jonas Jenwald
8a1cb82aee Ensure that the Widths array is parsed correctly in PartialEvaluator.preEvaluateFont
*Please note:* While I don't have a document that this patches fixes, the current code is however not entirely correct as far as I can tell.

Looking at how the `Widths` array is parsed in `PartialEvaluator.extractWidths`, it's clear that the implementation in `PartialEvaluator.preEvaluateFont` is a bit too simplistic. In particular, by only wrapping the data into a TypedArray, there's no attempt to handle *indirect* objects which could potentially lead to colliding `hash`es being computed.
2021-05-07 21:23:44 +02:00
Jonas Jenwald
30b2739adf Ensure that composite/non-composite fonts won't get the same hash in PartialEvaluator.preEvaluateFont
To hopefully help prevent any future bugs, make sure that composite/non-composite fonts cannot accidentally get matching `hash`es. Given the differences between those font types, that's very unlikely to be useful or even correct in general.
2021-05-07 21:22:37 +02:00
Jonas Jenwald
fc59a5f709 Take the W array into account when computing the hash, in PartialEvaluator.preEvaluateFont, for composite fonts (issue 13343)
Without this some *composite* fonts may incorrectly end up with matching `hash`es, thus breaking rendering since we'll not actually try to load/parse some of the fonts.

*Please note:* Given that the document, in the referenced issue, doesn't embed *any* of its fonts there's no guarantee that it renders correctly in all configurations even with this patch.
2021-05-07 21:22:36 +02:00
Tim van der Meij
a3632c0f38
Merge pull request #13344 from Snuffleupagus/evaluator-no-var
Enable the `no-var` rule in the `src/core/evaluator.js` file
2021-05-07 21:02:46 +02:00
Tim van der Meij
5248d0a77d
Merge pull request #13338 from Snuffleupagus/images-class
Convert the `src/core/{jbig2, jpg, jpx}.js` files to use standard classes
2021-05-07 20:59:58 +02:00
Calixte Denizet
af125cd299 JS - Add support for display property
- in annotation_layer, move common properties treatment in a common method instead having duplicated code in each widget.
2021-05-06 11:15:38 +02:00
Jonas Jenwald
0ef9b5aafc Fix the remaining no-var failures, which couldn't be handled automatically, in the src/core/evaluator.js file
The only *slight* complication here were some of the `switch`-cases, in `getOperatorList`/`getTextContent`, where the parsing is done asynchronously.
However, those cases are easy to deal with by wrapping the code within its own block; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch#block-scope_variables_within_switch_statements
2021-05-06 10:21:05 +02:00
Jonas Jenwald
f93c3b9aa7 Enable the no-var rule in the src/core/evaluator.js file
These changes were made automatically, using `gulp lint --fix`.
2021-05-06 09:39:21 +02:00
Jonas Jenwald
0a32ad3e42 Remove unnecessary closure in the src/core/font_renderer.js file
With modern JavaScript modules, where you explicitly list the properties that should be exported, it's no longer necessary to wrap *all* of the code within one file into a top-level closure.[1]

This patch reduces the size, of even the *built* `pdf.worker.js` file, since there's now a lot less unnecessary whitespace.

---
[1] For files which contain *different* functionality, some closures may however still make sense in order to separate the code.
It might be possible to remove some of those cases later, e.g. once private class fields becomes generally available/usable in browsers.
2021-05-05 22:35:52 +02:00
Tim van der Meij
afb8c4fd25
Merge pull request #13327 from Snuffleupagus/split-fonts
Split the functionality in `src/core/fonts.js` into multiple files, and use standard classes
2021-05-05 20:16:24 +02:00
Jonas Jenwald
ce14171cf0 Convert src/core/jpx.js to use standard classes
*Please note:* Ignoring whitespace-only changes is probably necessary in order to review this.
2021-05-05 14:02:21 +02:00
Jonas Jenwald
cb65b762eb Fix the remaining no-var failures, which couldn't be handled automatically, in the src/core/jpx.js file 2021-05-05 14:02:21 +02:00
Jonas Jenwald
a273599a12 Enable the no-var rule in the src/core/jpx.js file
These changes were made automatically, using `gulp lint --fix`.
2021-05-05 14:02:21 +02:00