Commit Graph

3025 Commits

Author SHA1 Message Date
Jonas Jenwald
f85f579971 Reduce unnecessary duplication when cancelling annotationLayer/xfaLayer rendering
There's no good reason, as far as I can tell, to have `PDFPageView.reset` attempt to cancel `annotationLayer`/`xfaLayer` rendering in one special-case (this is mostly a leftover from older code). Previously cancelling was moved into the separate `PDFPageView.cancelRendering`-method, and by slightly tweaking the conditions there we're able to remove a bit of now unnecessary code from the `PDFPageView.reset`-method.
2021-07-23 14:30:34 +02:00
Jonas Jenwald
d22ffbbc0a [api-minor] XFA - Remove the xfaLayer from the DOM when resetting pages (bug 1721977, PR 13427 follow-up)
Originally the `xfaLayer` wasn't implemented in such a way that it supported being removed from the DOM when pages were evicted from the cache, however this limitation was lifted in PR 13427 and the `xfaLayer` should thus be handled similar to e.g. the `annotationLayer`.

In addition to removing the `xfaLayer` from the DOM, this patch *also* implements proper rendering/hiding-handling for it (mirroring the `annotationLayer`-code).

*Please note:* This patch is tagged API-minor just in case[1], since it changes the signatures of a couple of `PDFPageView`-methods to improve readability of the code.

---
[1] Although users are *hopefully* not directly accessing any of the affected methods, and are rather using e.g. `PDFViewer` in which case none of these changes will matter.
2021-07-23 13:44:13 +02:00
Calixte Denizet
b68d2100b4 XFA - SVG elements mustn't get any pointer events (bug 1721589)
- a rectangle can be defined after a field and so from a z-index pov, it's on top of the field, which means that the rectangle avoid to have some mouse events in the fields;
  - so this patch just disable pointer events for all elements under svg (included).
2021-07-22 18:47:29 +02:00
Jonas Jenwald
e5845739fd Enable XFA by default in the development viewer
Given that https://bugzilla.mozilla.org/show_bug.cgi?id=1720402 has just landed, enabling XFA in the development viewer probably cannot hurt now.
2021-07-16 14:16:33 +02:00
Jonas Jenwald
f376a3fbb1 Remove <meta> tag only necessary for IE-compatibility
Given that Internet Explorer is, since some time now, no longer supported in the PDF.js library this `<meta>` tag can also be removed (added in PR 6374).
2021-07-15 13:59:40 +02:00
Calixte Denizet
0b4bf5b645 XFA - Only the first page was printed (bug 1720159) 2021-07-12 20:53:21 +02:00
Calixte Denizet
ff49fa5247 XFA - Fix wrong vertical alignments 2021-07-11 19:46:20 +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
Tim van der Meij
62b5dc9eb7
Merge pull request #13696 from Snuffleupagus/issue-13689
[GENERIC viewer] Try to fixup "incomplete" language codes (issue 13689)
2021-07-09 23:01:19 +02:00
Tim van der Meij
a6d2e78b8a
Merge pull request #13690 from symtalha14/text-annotation-comb
Fixed text annotation comb input box
2021-07-09 22:58:50 +02:00
Calixte Denizet
ff77acb357 XFA - Move xfa layer on top of the others (follow-up of #13706) 2021-07-09 20:58:19 +02:00
Calixte Denizet
1b77888400 XFA - Keep xfa layer on top of the others (bug 1719629) 2021-07-09 18:18:22 +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
Jonas Jenwald
29fd39a16e [GENERIC viewer] Try to fixup "incomplete" language codes (issue 13689)
While I don't know if it's technically correct to even do this, it could provide a slightly better out-of-the-box behaviour in browsers that specify (from the PDF.js `l10n`-folder perspective) "incomplete" language codes.

Rather than immediately falling back to English, we'll use a white-list to try and re-write a "partial" language code to a (hopefully) suitable one that matches an existing `l10n`-folder. The disadvantage of this solution is that the list needs to be kept *manually* up-to-date with any changes in the `l10n`-folder, however new locales are added infrequently enough that this should be acceptable.

Fixes 13689 (assuming we actually want/care to do so, otherwise we should just WONTFIX the issue).
2021-07-08 12:54:58 +02:00
symtalha14
e34e2e0af6 Fixed text annotation input field 2021-07-07 23:41:49 +05:30
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
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
02c069481e
Merge pull request #13653 from calixteman/lineheight
XFA - Improve text layout
2021-07-05 13:32:42 +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
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
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
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
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
Tim van der Meij
82660296d6
Merge pull request #13600 from Snuffleupagus/scrollMatchIntoView-selectedLeft
Take the position of the `selected` element into account when scrolling matches (issue 13596)
2021-06-26 14:04:20 +02:00
Calixte Denizet
57b6746bab XFA - Take into account text position in caption 2021-06-24 10:25:41 +02:00
Brendan Dahl
ad28622595
Merge pull request #13622 from calixteman/no_stretch_lrtb
XFA - No container stretching with lr-tb layout
2021-06-23 15:06:21 -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
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
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
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
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
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
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
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
Jonas Jenwald
6dc5dd194f Remove the internal PDFScriptingManager._pageEventsReady boolean (PR 13074 follow-up)
With the introduction of `PDFScriptingManager._closeCapability` in PR 13074, the pre-existing `PDFScriptingManager._pageEventsReady` boolean essentially became redundant.
Given that you always want to avoid tracking closely related state *separately*, since it's easy to introduce subtle bugs that way, we should just remove `PDFScriptingManager._pageEventsReady` now.

Obviously I *should* have done this already back in PR 13074, sorry about the churn here!
2021-06-17 18:01:10 +02:00
Calixte Denizet
897a679723 XFA - Don't show outline on focused textfields 2021-06-11 09:25:14 +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
calixteman
63bde1fcfe
Merge pull request #13524 from calixteman/print_select
XFA - Don't print arrow in select
2021-06-09 16:56:39 +02:00
Calixte Denizet
82784e8e60 XFA - Don't print arrow in select 2021-06-09 16:45:49 +02:00
Jonas Jenwald
f716de7a2d [XFA] Use align-items: flex-start; to improve browser compatibility (issue 13518)
https://developer.mozilla.org/en-US/docs/Web/CSS/align-items#browser_compatibility
2021-06-09 08:20:12 +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