Commit Graph

13739 Commits

Author SHA1 Message Date
Jonas Jenwald
75a6b2fa13
Improve handling of *linked* test-cases for the unit/integration suites (#13160)
- Actually support *linked* test-cases in the integration-tests (in the same way as the unit-tests).

 - Add a new `"type": "other"`-kind to the test-manifest, to support *linked* test-cases in the unit/integration-tests without requiring the PDF document in question to also be a reference-test.
2021-03-30 13:24:04 +02:00
Tim van der Meij
1a2cdaffc5
Merge pull request #13152 from calixteman/13130
Skip extra objects in object stream in using offsets
2021-03-28 15:11:55 +02:00
Tim van der Meij
34542d814f
Merge pull request #13155 from Snuffleupagus/rotation-normalization
Move rotation normalization from `PDFViewerApplication` and into `BaseViewer`
2021-03-28 15:05:07 +02:00
Jonas Jenwald
19c2dfbb96 Move rotation normalization from PDFViewerApplication and into BaseViewer
The rotation handling that's currently living in `PDFViewerApplication` is *very* old, and pre-dates the introduction of the viewer components by years.
As can be seen in the `BaseViewer.pagesRotation` setter, we're not actually normalizing the rotation as intended and instead rely on the caller to handle that correctly. This is first of all inconsistent, given how other setters are implemented, and secondly it could also lead to the rotation being set to a value outside of the `[0, 360)`-range.

Finally, for improved consistency the rotation handling in `PageViewport` is updated similarly. Please note that this case, it's *not* changing the pre-existing logic.
2021-03-28 14:19:58 +02:00
Tim van der Meij
68e0db735b
Merge pull request #13154 from calixteman/update_quickjs
Update quickjs to revision b5e62895c619d4ffc75c9d822c8d85f1ece77e5b
2021-03-28 14:11:58 +02:00
Calixte Denizet
9296ee6986 Skip extra objects in object stream in using offsets 2021-03-28 13:03:05 +02:00
Calixte Denizet
a256948b30 Update quickjs to revision b5e62895c619d4ffc75c9d822c8d85f1ece77e5b 2021-03-28 12:43:46 +02:00
Tim van der Meij
ba76dd4000
Merge pull request #13056 from Snuffleupagus/Doc-WillClose
Dispatch a "Doc/WillClose" event, when scripting is enabled, when closing the document
2021-03-26 22:00:40 +01:00
Tim van der Meij
69c88d119d
Merge pull request #13138 from Snuffleupagus/PDFHistory-pushPage-dest
[PDFHistory] Correctly simulate an internal destination in the `pushPage`-method (PR 12493 follow-up)
2021-03-26 21:57:51 +01:00
Tim van der Meij
5bb163424b
Merge pull request #13144 from Snuffleupagus/GrabToPan-matches
[GrabToPan] Use `Element.matches()` rather than prefixed `...matchesSelector` versions
2021-03-26 21:47:32 +01:00
Jonas Jenwald
b11b7aaa38 [GrabToPan] Use Element.matches() rather than prefixed ...matchesSelector versions
At this point in time all of the browsers that PDF.js support now implements, with some margin based on the version numbers, `Element.matches()` according to the following compatibility information:
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#browser_compatibility
 - https://caniuse.com/matchesselector
2021-03-26 21:37:51 +01:00
Tim van der Meij
ebd2dfbae0
Merge pull request #13145 from emilio/print-oversized
print: Improve rendering of oversized pages.
2021-03-26 21:33:52 +01:00
Tim van der Meij
0b6b8ef42b
Merge pull request #13140 from Snuffleupagus/GrabToPan-cleanup
[GrabToPan] Remove more IE-specific code, and remove *unconditional* browser sniffing
2021-03-26 21:28:12 +01:00
calixteman
81c602c61c
Set CFF header to 4 when writing it because it contains 4 elements (#13149) 2021-03-26 18:23:18 +01:00
Emilio Cobos Álvarez
81c7f905bc print: Improve rendering of oversized pages.
This improves and simplifies #13102 in order to make printing of test-cases
like the one in bug 1698414 (where the real page is bigger than the target
page) much better, see incoming screenshots.

The reason why we need to stop setting .style.width / .style.height is to get
the right auto-sizing behavior in both axes. This shouldn't change behavior as
long as the print resolution is >= the CSS resolution, which seems like a
reasonable assumption.

If you try to print with a lower resolution than CSS, then instead of an
stretched canvas, you'd get a centered CSS-quality canvas, which seems
sensible. This could maybe be fixed with some CSS hackery (some combination of
min / max and viewport units perhaps?), but I think it's more trouble than it's
worth.
2021-03-26 16:07:49 +01:00
Jonas Jenwald
34184a89f9 Remove *unconditional* browser sniffing in web/grab_to_pan.js
According to https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#browser_compatibility, and manual testing in an up-to-date version of Google Chrome, the *unconditional* browser sniffing in `web/grab_to_pan.js` is no longer necessary.
In particular, this code is definitely not necessary in MOZCENTRAL-builds.
2021-03-25 16:08:16 +01:00
Jonas Jenwald
3c3cbe78ae Remove the remaining IE-specific checks from web/grab_to_pan.js (PR 12328 follow-up)
Given that all versions of Internet Explorer are now *explicitly* unsupported, we can remove some more dead code in this file.
2021-03-25 16:08:12 +01:00
calixteman
63471bcbbe
XFA - Convert some template properties into CSS ones (#13082)
- implement few positioning properties: position, width, height, anchor;
  - implement font element;
  - implement fill element (used by font) and its children (linear, radial, ...);
  - font property is inherited from ancestor container (see https://www.pdfa.org/wp-content/uploads/2020/07/XFA-3_3.pdf#page=43) so let CSS handles that stuff;
  - in order to reduce the number of properties to set, only set non default properties and put the default in CSS;
  - set a background to some containers to be able to see them (will be removed in a future commit).
2021-03-25 13:02:39 +01:00
Jonas Jenwald
a10f87c7ea [PDFHistory] Correctly simulate an internal destination in the pushPage-method (PR 12493 follow-up)
The intention, in PR 12493, was that the page we're adding to the browser history should behave as if it were a "regular" internal destination (to properly convey user intent).
Unfortunately, since I didn't consider all the edge-cases correctly, it ended up behaving like a URL-hash instead which obviously wasn't intended. Note that currently this isn't a problem, however it can become an issue (in some cases) with upcoming re-factoring around `PDFHistory` and OpenAction support[1].

---
[1] I've started working on fixing the following TODO, which will require a couple of smaller tweaks here and there: 9d0ce6e79f/web/app.js (L1680-L1681)
2021-03-25 12:24:28 +01:00
Jonas Jenwald
685a60055e [PDFHistory] Reduce unnecessary duplication, by introducing a helper-method for validating pageNumbers 2021-03-24 22:01:53 +01:00
Tim van der Meij
9d0ce6e79f
Merge pull request #13128 from Snuffleupagus/BasePreferences-loops
Re-factor how the `BasePreferences.prefs`-property is initialized; remove some *indirect* loops
2021-03-24 20:47:45 +01:00
Tim van der Meij
0ff92fb9c8
Merge pull request #13135 from eltociear/patch-1
Fix typo in pdf_history.js
2021-03-24 20:42:05 +01:00
Ikko Ashimine
0de15d59b8
Fix typo in pdf_history.js
occuring -> occurring
2021-03-24 23:18:40 +09:00
Jonas Jenwald
be52183211 Remove some *indirect* loops in the BasePreferences.getAll-method
In the `getAll`-method, we can have just one *explicit* loop rather than two indirect ones via the old `Object.assign`-call.

Also, changes the `get`-method to be slightly more compact (while keeping the logic intact).
2021-03-22 14:38:05 +01:00
Jonas Jenwald
4b27f58625 Re-factor how the BasePreferences.prefs-property is initialized
Looking at this now, I cannot understand why we'd need to initialize `this.prefs` with all of the values from `this.defaults`.
Not only does this *indirectly* require one extra loop, via the `Object.assign`-call, but it also means that in GENERIC-builds changes to default-preference values might not be picked-up unless the the existing user-prefs are cleared (if the user had *manually* set prefs previously).
2021-03-22 14:37:56 +01:00
Tim van der Meij
d426ffdad9
Merge pull request #13125 from Snuffleupagus/BaseViewer-enableXfa
Don't provide the `enableXfa` parameter to the `BaseViewer` constructor, and avoid the fallback bar with `enableXfa = true` set (PR 13069 follow-up)
2021-03-21 13:50:30 +01:00
Tim van der Meij
8e736e4f98
Merge pull request #13126 from Snuffleupagus/update-packages
Update packages and translations
2021-03-21 13:48:00 +01:00
Jonas Jenwald
eeda2215d7 Remove redundant done-callback functions from unit-tests which are async
For unit-tests which are asynchronous, using a `done`-callback is redundant and future Jasmine versions will stop supporting that pattern.
2021-03-21 11:33:39 +01:00
Jonas Jenwald
4814e23310 Add (temporary) Swedish localizations for the page_landmark/loading strings (PR 13118 follow-up)
I'm adding these temporary l10n strings, so that I don't have to stare at a bunch of warning messages in the web-console when using the development viewer.
2021-03-21 11:12:20 +01:00
Jonas Jenwald
36e79edfaf Update l10n files 2021-03-21 11:12:18 +01:00
Jonas Jenwald
3eb7a6b66f Update npm packages 2021-03-21 11:00:02 +01:00
Jonas Jenwald
35a088ffc1 Don't provide the enableXfa parameter to the BaseViewer constructor, and avoid the fallback bar with enableXfa = true set (PR 13069 follow-up)
Given that the `enableXfa` parameter must to be passed to the API/Worker, and thus included in the `getDocument` call, it's not necessary to include it when initializing the `PDFViewer`-instance used in the default viewer. (Also, in `AppOptions`, the parameter is clearly marked with `OptionKind.API`.)

Furthermore, we probably don't want to display the fallback bar (in Firefox) for XFA documents when `enableXfa = true` is set.
2021-03-21 10:52:01 +01:00
Tim van der Meij
c6b44d1516
Merge pull request #13117 from Snuffleupagus/defaultPreferences-builds
Re-factor the default preferences generation to support build targets (PR 10548)
2021-03-20 18:40:29 +01:00
Tim van der Meij
39b485f69f
Merge pull request #13124 from Snuffleupagus/animationStarted-Node
Tweak the pre-processor condition, for Node.js environments, in the `animationStarted` helper (issue 13057)
2021-03-20 18:18:32 +01:00
Jonas Jenwald
71e61c3533 Tweak the pre-processor condition, for Node.js environments, in the animationStarted helper (issue 13057)
While it's still not entirely clear if this would've prevented the issue as reported, given that the particular use-case reported apparently no longer applies, this small change really cannot hurt in general *and* it won't effect "regular" viewer builds in any way.
2021-03-20 13:34:38 +01:00
Jonas Jenwald
7bcfabc43c Fix an edge-case related to compatibility-values in various AppOptions-methods
Given how the compatibility-values are being handled, it's not actually possible to override a *truthy* default-value with a *falsy* compatibility-value.
This is a simple oversight on my part, and with modern ECMAScript features this is very easy to support.
2021-03-20 13:12:09 +01:00
Jonas Jenwald
18bc59eb34 [Chromium extension] Remove the special handling of the "disableTelemetry" preference
With the changes made in the previous patch, we can now list "disableTelemetry" in the `AppOptions` only for the `CHROME`-builds and thus remove the special-casing in the `checkChromePreferencesFile` helper function.
2021-03-20 13:12:09 +01:00
Jonas Jenwald
b48dc06148 [gulpfile] Move common functionality, in buildLib and buildDefaultPreferences, to a helper function
Currently there's a lot of duplication in the `buildLib` and `buildDefaultPreferences` functions, which seem quite unfortunate. Hence this patch extracts the common functionality in a new `buildLibHelper` function instead.
2021-03-20 13:12:09 +01:00
Jonas Jenwald
56e1d7746a Re-factor the default preferences generation to support build targets (PR 10548)
Originally the default preferences where simply placed in a JSON-file, checked into the repository, which over time became impractical, annoying, and error-prone to maintain; please see PR 10548.
While that improved the overall situation a fair bit, it however inherited one quite unfortunate property of the old JSON-based solution[1]: It's still not possible for *different* build targets to specify their *own* default preference values.

With some preferences, such as e.g. `enableScripting`, it's not inconceivable that you'd want to (at least) support build-specific default preference values. Currently that's not really possible, which is why this PR re-factors the default preferences generation to support this.

---
[1] This fact isn't really clear from the `AppOptions` implementation, unless you're familiar with the `gulpfile.js` code, which could lead to some confusion for those new to this part of the code-base.
2021-03-20 11:50:48 +01:00
Tim van der Meij
d775616fd4
Merge pull request #13118 from brendandahl/page-aria
Add landmark region and aria-label for each page.
2021-03-19 23:17:55 +01:00
Tim van der Meij
8269ddbd16
Merge pull request #13105 from Snuffleupagus/BasePdfManager-parseDocBaseUrl
Improve memory usage around the `BasePdfManager.docBaseUrl` parameter (PR 7689 follow-up)
2021-03-19 23:03:20 +01:00
Tim van der Meij
e7e0ecf9c8
Merge pull request #13113 from Snuffleupagus/scripting-PresentationMode-events
Ignore some *scripting* events which don't make sense in PresentationMode
2021-03-19 22:52:15 +01:00
Tim van der Meij
92d3a93897
Merge pull request #13116 from Snuffleupagus/enableScripting-true
Enable scripting by default in the viewer (PR 13053 follow-up)
2021-03-19 22:48:57 +01:00
Tim van der Meij
8a820ac151
Merge pull request #13120 from Snuffleupagus/enablePrintAutoRotate-true
Rotate landscape pages, during printing, by default in the viewer (`enablePrintAutoRotate = true`)
2021-03-19 22:45:56 +01:00
Brendan Dahl
9fb0f3b0da Add landmark region and aria-label for each page.
Allows screen readers to jump landmarks and announce
the page. Since landmarks must have content, I also added
aria labels for the loading images.
2021-03-19 14:13:51 -07:00
Jonas Jenwald
1fa5ce7f48 Ignore some *scripting* events which don't make sense in PresentationMode
A number of the currently supported *scripting* events only make sense in the "normal" viewer mode, and not when PresentationMode is active. For example:
 - Changing the zoom-level will outright break rendering in PresentationMode, since it relies on "page-fit" being used.
 - Focusing a particular (AcroForm) element won't work, and could break keyboard navigation, since forms should not be editable in PresentationMode (see issue 12232).
2021-03-19 13:54:21 +01:00
Jonas Jenwald
30c06849d8 Rotate landscape pages, during printing, by default in the viewer (enablePrintAutoRotate = true)
While this will perhaps not be perfect for *every* PDF document with mixed page orientation, based on the large number of bugs/issues seen over the years I'm however pretty convinced that it'll be an overall improvement in a majority of cases.

In order to improve things further, we'd probably need Firefox to support e.g. `@page` such that the viewer can provide better information to the print engine.
2021-03-19 12:39:37 +01:00
Jonas Jenwald
1de466896d Remove one loop from BaseViewer.getPagesOverview
Currently, with `enablePrintAutoRotate = true` set, we're forced to loop through all the pages *twice* when checking for any landscape pages.
This seems completely unnecessary now, and using only *one* loop should be marginally more efficient in general.
2021-03-19 12:38:46 +01:00
Jonas Jenwald
3ce94a9f6d Change how landscape pages are rotated, for printing, with enablePrintAutoRotate = true set
Currently landscape pages are rotated *clockwise*, which for most documents feel wrong since holding the printed pages at their *left* edge causes the landscape pages to be viewed "upside down".
In general, since most documents are LTR ones, it feels more appropriate to instead rotate landscape pages *counterclockwise* for printing.
2021-03-19 12:37:57 +01:00
Jonas Jenwald
57e7557235
Actually reset the PDFPageProxy._xfaPromise property as intended (PR 13069 follow-up) (#13119)
Similar to the existing `annotationsPromise` and `_jsActionsPromise` properties, the new `_xfaPromise` should obviously also be reset, since otherwise you might end up holding onto a lot of data for pages that are no longer active.

(That caching wasn't present in the original version of PR 13069, which is why I didn't spot it until now.)
2021-03-19 11:31:54 +01:00