Commit Graph

14415 Commits

Author SHA1 Message Date
Calixte Denizet
1b77888400 XFA - Keep xfa layer on top of the others (bug 1719629) 2021-07-09 18:18:22 +02:00
calixteman
0afc785c7d
Merge pull request #13700 from calixteman/image_scale
XFA - Scale correctly images
2021-07-09 15:34:47 +02: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
418880d473
Merge pull request #13694 from Snuffleupagus/handleBreak-rm-extra-target
XFA - remove unnecessary check in the `handleBreak` function (PR 13687 follow-up)
2021-07-08 09:58:29 +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
calixteman
36cfb15668
Merge pull request #13691 from calixteman/layout6
XFA - Handle correctly nested containers with lr-tb layout (bug 1718670)
2021-07-07 19:17:58 +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
b2b7806cab
Merge pull request #13649 from Snuffleupagus/xfa-merge-supplemental-font-data
Merge the supplemental font data files used with XFA documents
2021-07-07 15:07:17 +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
calixteman
1eb9a3e9eb
Merge pull request #13687 from calixteman/failing_som
XFA - Don't fail xfa loading because of a JS subexpression in SOM expressions
2021-07-07 11:50:26 +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
Jonas Jenwald
05ebb6329b
Merge pull request #13683 from brendandahl/mask-fixes
Fix transformations when painting image masks and tiling patterns.
2021-07-07 10:24:01 +02:00
Brendan Dahl
a52c0c6988 Fix transformations when painting image masks and tiling patterns.
Previously, when we filled image masks we didn't copy over the current transformation,
this caused patterns to be misaligned when painted. Now we create a temporary
canvas with the mask and have the transform copied over and offset it relative to
where the mask would be painted. We also weren't properly offsetting tiling patterns.
This isn't usually noticeable since patters repeat, but in the case of #13561 the pattern
is only drawn once and has to be in the correct position to line up with the mask image.

These fixes broke #11473, but highlighted that we were drawing that correctly by
accident and not correctly handling negative bounding boxes on tiling patterns.

Fixes #6297,  #13561, #13441

Partially fixes #1344 (still blurry but boxes are in correct position now)
2021-07-06 17:29:32 -07:00
Brendan Dahl
a0aff125dd
Merge pull request #13684 from calixteman/typo
XFA - Default background in rectangle is white
2021-07-06 14:02:37 -07: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
calixteman
90d196a080
Merge pull request #13680 from calixteman/layout5
XFA - Layout correctly a subform with row layout (bug 1718740)
2021-07-06 15:40:55 +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
Jonas Jenwald
b3de26f514
Merge pull request #13675 from Snuffleupagus/driver-image-src-last
[test/driver.js] Ensure that Image `src` is set *after* the callbacks in `resolveImages`
2021-07-06 11:10:04 +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
Jonas Jenwald
f6ce449fea [test/driver.js] Ensure that Image src is set *after* the callbacks in resolveImages
*While I cannot guarantee that this will fix the recent intermittents, this patch really shouldn't hurt.*

By setting the Image `src` first, there's a small possibility that the Image is loaded *before* we've had a change to attach the `onload`/`onerror` callbacks which may cause the Promise to remain in a pending state.
Note that prior to PR 13641 we didn't correctly await all image resources to actually load, which could explain the very recent intermittent test-failures.
2021-07-05 16:28:59 +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
fcd4c8151c
Merge pull request #13672 from mozilla/revert-13654-images
Revert "XFA - An image can be a stream in the pdf (bug 1718521)"
2021-07-05 12:47:35 +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
Tim van der Meij
62808cb3c2
Merge pull request #13666 from Snuffleupagus/eslint-operator-assignment
Enable the ESLint `operator-assignment` rule
2021-07-04 18:05:12 +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
Tim van der Meij
5c7cd6fb4f
Merge pull request #13661 from Snuffleupagus/fingerprints
[api-minor] Support accessing both the original and modified PDF fingerprint
2021-07-03 18:59:11 +02:00
Tim van der Meij
f979aae6fe
Merge pull request #13664 from Snuffleupagus/rm-package-version
Remove the `version` field from the `package.json` file
2021-07-03 18:50:07 +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
Jonas Jenwald
e4adde3462 Remove the version field from the package.json file
According to https://docs.npmjs.com/cli/v7/configuring-npm/package-json#version, the "version" field is not required[1]:
> If you don't plan to publish your package, the name and version fields are optional.

Hence it shouldn't be necessary to have a "dummy" `version` field in the `package.json` file, and it seems quite unfortunate to have an essentially meaningless entry in that file.[2]
Furthermore, I'd even go as far as suggesting that it's actually doing more harm than good in practice, since it's not uncommon for people to open issues where they simply quote the `package.json`-entry when filling out the ISSUE_TEMPLATE thus causing confusion as to which *exact* version is actually used.

Unless I'm misremembering, I believe that the only reason for adding the `version` field was that is was necessary in order for things to work back when testing was run on Travis.
Now we're using GitHub Actions instead, where things seem to work just find even without a `version` field; hence why I think it makes sense to remove this.

---
[1] Please note that this patch doesn't affect the `pdfjs-dist` package, since the `package.json` file used there is created in `gulpfile.js` during building.

[2] Trying to, automatically, update the `version` field on *every* commit really doesn't seem worth it to me.
2021-07-03 16:46:28 +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
Tim van der Meij
f9d506cf50
Merge pull request #13658 from Snuffleupagus/cloneValue
Don't attempt to structure clone unsupported types with workers disabled
2021-07-03 13:01:46 +02:00
Tim van der Meij
227d0b0dac
Merge pull request #13657 from Snuffleupagus/rm-instanceof-Object
Replace `instanceof Object` with `typeof` checks
2021-07-03 12:54:34 +02:00
Jonas Jenwald
bdf6f733bf Don't attempt to structure clone unsupported types with workers disabled
Please refer to https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm

Based on that information, and manually testing our code, the implementation in `cloneValue` has the following shortcomings:
 - Attempting to clone `function`s is only prevented when they're part of an Object, but is currently allowed when they occur standalone.
 - Cloning of `Symbol`s is currently not prevented, which it should be since the native structured clone algorithm throws.
 - Any disallowed types should be checked first, to reduce the risk of future changes accidentally allowing something that shouldn't be supported.
2021-07-03 11: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