Commit Graph

14456 Commits

Author SHA1 Message Date
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
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
calixteman
3264d409dd
Merge pull request #13576 from calixteman/really_fix_text_stuff
XFA - When no fonts in the pdf just use font size as width when measuring text
2021-06-17 17:47:18 +02: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
calixteman
326226df45
Merge pull request #13575 from calixteman/fixlast
XFA - Fix reftest for xfa_issue13500
2021-06-17 15:56:27 +02:00
Calixte Denizet
226c228c2a XFA - Fix reftest for xfa_issue13500 2021-06-17 15:48:13 +02:00
calixteman
b300aba078
Merge pull request #13560 from calixteman/xfa_font_widths
XFA - Add the possibily to layout and measure text
2021-06-17 15:05:57 +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
Brendan Dahl
d6deb95f11
Merge pull request #13565 from brendandahl/fix-pattern-mask
Fix how patterns are applied to image mask objects.
2021-06-16 20:07:57 -07:00
Brendan Dahl
5efaaa0fea Fix how patterns are applied to image mask objects.
Note, this only really fixes Radial/Axial shading patterns with masks.
I'm guessing tiling patterns and mesh patterns would also be broken
if applied like the test pdf. Hopefully I'll have some time to make
test cases for the other shadings.

Fixes #13372
2021-06-16 20:06:41 -07: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
Brendan Dahl
f9a0568f96
Merge pull request #13554 from calixteman/layout3
XFA - Add support for overflow element
2021-06-15 09:16:19 -07:00
Jonas Jenwald
697c58e6e8
Merge pull request #13563 from Snuffleupagus/eslint-plugin-json
Add basic linting of JSON files using `eslint-plugin-json`
2021-06-15 12:38:42 +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
1cfaf07b82 Add basic linting of JSON files using eslint-plugin-json
By adding basic linting of JSON files, we can ensure that they're actually valid and prevent e.g. test-failures caused by *accidental* errors when editing the `test/test_manifest.json` file (something that I've done *many* times myself).

For now this simply uses the `recommended` configuration, but we can obviously tweak this later if/when needed. Please find additional information at https://github.com/azeemba/eslint-plugin-json
2021-06-15 12:19: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
calixteman
246d565e3b
Merge pull request #13559 from calixteman/maxlength
XFA - Handle maxChars property for text fields
2021-06-14 14:21:04 +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