Commit Graph

14481 Commits

Author SHA1 Message Date
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
Calixte Denizet
1d0e83e1bd XFA - No container stretching with lr-tb layout 2021-06-23 22:03:07 +02:00
Tim van der Meij
f74562b19c
Merge pull request #13613 from Snuffleupagus/xfa-printing-tweaks
[api-minor] Slightly tweak/improve various code related to XFA-printing
2021-06-23 21:56:29 +02: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
Tim van der Meij
c115be27b6
Merge pull request #13617 from Snuffleupagus/reset-externalLinkEnabled
Reset the `IPDFLinkService.externalLinkEnabled` property on document closing
2021-06-23 21:42:27 +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
calixteman
2bae399422
Merge pull request #13614 from calixteman/line_height
XFA - Get line height from the font
2021-06-23 14:57:27 +02:00
Jonas Jenwald
d959cb824d Reset the IPDFLinkService.externalLinkEnabled property on document closing
Given that this property is only used with password protected documents, and is consequently document-specific rather than viewer-specific, ensure that `IPDFLinkService.externalLinkEnabled` is actually being reset by `PDFViewerApplication.close`.

To make things less confusing/inconsistent, remove the *undocumented* `externalLinkEnabled` property from the `PDFLinkService` constructor and force it to always be manually set when needed.
2021-06-23 14:12:33 +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
87be43c193 [api-minor] Add a new getXfaPageViewport helper function to support printing
This patch provides an overall simpler *and* more consistent way of handling the `viewport` parameter during printing of XFA forms, since it's now again guaranteed to always be an instance of `PageViewport`.
Furthermore, for anyone attempting to e.g. implement custom printing of XFA forms this probably cannot hurt either.
2021-06-23 08:17:58 +02:00
Jonas Jenwald
45c1390c42 Switch the order of the "display"/"print" intent handling in XfaLayerBuilder.render
Given that the "print"-intent is special, and that we should always fallback to the "display"-intent, let's ensure that the code actually reflects that.
Also, ensure that the method always returns a `Promise` since that's what the documentation says.
2021-06-23 08:17:58 +02:00
Jonas Jenwald
eb94d71b71 Move the getXfaHtmlForPrinting helper function to its own file (PR 13411 follow-up)
The `web/ui_utils.js` file should be usable from basically anywhere in the `web/`-folder, hence it should ideally not have any dependecies on its own and particularily *not* onces that pull in entire (large) factories.
2021-06-23 08:17:58 +02:00
Jonas Jenwald
9441245320
Merge pull request #13606 from Snuffleupagus/issue-13605
Correctly align the `textLayer` content with horizontal/spread scrolling modes (issue 13605)
2021-06-22 18:53:10 +02:00
calixteman
b1c9d8c78d
Merge pull request #13594 from calixteman/xfa_add_margin
XFA - Add margins if needed after having layout some text
2021-06-22 17:47:18 +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
Jonas Jenwald
6163cd015b
Merge pull request #13609 from Snuffleupagus/xfaLayer-text-align
Correctly align the `xfaLayer` content with horizontal scrolling/spread modes
2021-06-22 14:54:21 +02:00
Jonas Jenwald
d301ec7d42 Correctly align the xfaLayer content with horizontal scrolling/spread modes
This extends the approach in PRs 12848 and 13606 to also apply to the `xfaLayer`, since otherwise XFA forms will be similarly broken in most non-default scroll/spread modes.
2021-06-22 13:31:48 +02:00
Calixte Denizet
aca102a35e XFA - Add margins if needed after having layout some text 2021-06-22 10:36:01 +02:00
Jonas Jenwald
eb755d098e
Merge pull request #13608 from mozilla/dependabot/npm_and_yarn/color-string-1.5.5
Bump color-string from 1.5.3 to 1.5.5
2021-06-22 10:08:19 +02:00
dependabot[bot]
f40c59c7b4
Bump color-string from 1.5.3 to 1.5.5
Bumps [color-string](https://github.com/Qix-/color-string) from 1.5.3 to 1.5.5.
- [Release notes](https://github.com/Qix-/color-string/releases)
- [Changelog](https://github.com/Qix-/color-string/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Qix-/color-string/commits/1.5.5)

---
updated-dependencies:
- dependency-name: color-string
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-22 07:59:39 +00: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
calixteman
fbf5f8487d
Merge pull request #13603 from calixteman/revert
Revert "Revert "XFA - Fix the way to select page on breaking""
2021-06-21 19:11:44 +02:00
Jonas Jenwald
daa563ae81 Correctly align the textLayer content with horizontal/spread scrolling modes (issue 13605)
This is *very* similar to PR 12848, however for this `textLayer`-case it appears to only be an issue in documents with marked content.
2021-06-21 18:59:59 +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
277f351291
Merge pull request #13601 from mozilla/revert-13573-bug1716838
Revert "XFA - Fix the way to select page on breaking"
2021-06-21 15:45:22 +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
Jonas Jenwald
b42120bdb0 Take the position of the selected element into account when scrolling matches (issue 13596)
Note that as far as I can tell, this is *not* a regression but rather a bug which has existed since basically "forever".

**In order to reproduce this easily:**
 - Open the viewer.
 - Set the zoom level to `400%`,
 - Search for "expression".

The problem here is that when scrolling matches into view, we're scrolling to the start of the *containing* `textLayer` element rather than the start of the highlighted match itself.[1] When the entire width (or at least most) of the page is visible in the viewer, that doesn't really matter though which is likely why this bug has gone unnoticed for so long.[2]
Given that the highlighted match can be placed anywhere, e.g. even at the very end, within its `textLayer` element it's quite easy to see why the current implementation becomes a problem at higher zoom levels. All of this is then *further* exacerbated by `PDFFindController.scrollMatchIntoView` using a negative left offset, to ensure that the current match has some (visible) context available once scrolled into view.

In order to address this long-standing bug, we'll determine the (left) offset of the `selected` match and use that to modify the final position scrolled to in `PDFFindController.scrollMatchIntoView` such that the match is visible regardless of zoom level.

---
[1] Unfortunately we cannot directly scroll to the `selected` match, since it's not absolutely positioned and changing that would cause other bugs/regressions (note recent patches in that area).

[2] I did actually stumble upon this problem a little while ago, while working on PR 13482, but forgot to look into this again until I saw the new issue.
2021-06-21 11:49:33 +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
calixteman
223b60f4e8
Merge pull request #13595 from calixteman/xfa_readonly
XFA - Add support for access property
2021-06-21 09:58:54 +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
Tim van der Meij
bdfcdd6f83
Merge pull request #13589 from Snuffleupagus/issue-13585
Allow using the standard font data for non-Type1 fonts (issue 13585, PR 12726 follow-up)
2021-06-20 12:31:39 +02:00
Tim van der Meij
adafb2c82a
Merge pull request #13590 from Snuffleupagus/issue-8558
Stop encoding the value in the `DOMElement.setAttribute` method (issue 8558)
2021-06-20 12:27:13 +02:00
Jonas Jenwald
2ffc921163 Stop encoding the value in the DOMElement.setAttribute method (issue 8558)
This patch is an attempt at closing an old, and seemingly trivial, issue and the SVG-files created by the `pdf2svg.js` examples still appear to work just fine when opened in browsers (tested with Firefox Nightly and Google Chrome Beta).
2021-06-20 11:55:24 +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
Tim van der Meij
94ca66f528
Merge pull request #13588 from Snuffleupagus/viewer-component-types
Add a (basic) TypeScript definitions for the viewer components (issue 13267)
2021-06-19 19:02:08 +02:00
Tim van der Meij
b9e8a3ce47
Merge pull request #13587 from Snuffleupagus/useSystemFonts-default
Set the default value of `useSystemFonts` correctly, depending on `disableFontFace`, in the API (PR 13516 follow-up)
2021-06-19 18:55:17 +02:00
Jonas Jenwald
fdf2c59b8f Add a (basic) TypeScript definitions for the viewer components (issue 13267)
Please note that while the `gulp types`/`gulp typestest` tasks (obviously) still work with this patch, I've got no idea if the output is first of all even useable and secondly if it's actually useful in practice.
However, in the interest of closing some (seemingly simple) issues, I suppose that this probably shouldn't hurt (and we'd need TypeScript users to help improve things here).
2021-06-19 16:24:34 +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
Tim van der Meij
248efb16a7
Merge pull request #13577 from Snuffleupagus/rm-PDFScriptingManager._pageEventsReady
Remove the internal `PDFScriptingManager._pageEventsReady` boolean (PR 13074 follow-up)
2021-06-18 21:06:00 +02:00
Brendan Dahl
5d251a3a3e
Merge pull request #13566 from calixteman/layout4
XFA - Fix layout issues
2021-06-17 13:23:28 -07:00
Jonas Jenwald
5db7a3cc88 Ensure that PDFScriptingManager.setDocument handles failure when initializing the scripting-factory
This way, we'll immediately clean-up in exactly the same way as the other failure code-paths in the `PDFScriptingManager.setDocument` method.
2021-06-17 18:42:15 +02:00