Commit Graph

15245 Commits

Author SHA1 Message Date
Jonas Jenwald
00bd549e82 Update the year in the license_header files
This also includes a couple of files that are included as-is in the `pdfjs-dist` library.
2022-01-27 19:24:31 +01:00
Jonas Jenwald
a69adf0382
Merge pull request #14500 from calixteman/14497
Take into account all rotations before comparing glyph positions
2022-01-26 18:04:57 +01:00
Calixte Denizet
3a7004ca25 Take into account all rotations before comparing glyph positions
- it aims to fix #14497;
 - previously, only rotations with an angle 0, 90, 180 or 270 were taken into account;
 - so generalize to any angle but keep the fast path for 0, 90, ... because they're likely more common than anything else.
2022-01-26 17:19:00 +01:00
Jonas Jenwald
5c3b245958
Merge pull request #14495 from emilio/ctrl-wheel
web: Read WheelEvent.deltaMode before deltas.
2022-01-25 19:55:32 +01:00
Emilio Cobos Álvarez
2f8a0638a6
web: Read WheelEvent.deltaMode before deltas.
So that Firefox doesn't switch to pixel mode for compat with other
browsers.

This should fix https://github.com/mozilla/pdf.js/issues/14476, in terms
of restoring the previous behavior.

We probably want to change the pixel-based scrolling code to not scroll
so much (the deltaMode stuff normalizes to +/-1 tick for each wheel
event, perhaps the pixel-based value should do the same).
2022-01-25 18:57:49 +01:00
Jonas Jenwald
583c39b859
Merge pull request #14490 from Snuffleupagus/getCharUnicodeCategory-cache
Add a (global) cache to the `getCharUnicodeCategory` function
2022-01-25 10:04:32 +01:00
Jonas Jenwald
8836593b9e Add a (global) cache to the getCharUnicodeCategory function
Given that the regular expression has already become more complex (after the initial patch adding it), it seems to me that it probably cannot hurt to add a global cache to reduce unnecessary re-parsing.
Obviously the `Glyph`-instances are being cached *per* font, however in most documents multiple fonts are being used and in practice there's very often a fair amount of overlap between the /ToUnicode-data in different fonts[1].

Consider for example loading and rendering the entire `tracemonkey.pdf` document (from the test-suite), which isn't a particularily large document. In that case the `getCharUnicodeCategory` function is being called a total of `601` times, however there's only `106` *unique* unicode-chars being checked.

*Please note:* In practice I suppose that this won't have a *huge* effect on overall performance, however given the relative simplicity of this patch I figured that it'd not hurt to submit it for review.

---
[1] Consider e.g. how there's usually different fonts used for regular, bold, respectively italic text.
2022-01-25 09:59:34 +01:00
Tim van der Meij
ede26bfe4a
Merge pull request #14479 from Snuffleupagus/update-packages
Update packages and translations
2022-01-24 19:43:29 +01:00
calixteman
9367d54009
Merge pull request #14483 from calixteman/200B
Remove the invisible format marks from the text chunks
2022-01-24 17:52:06 +01:00
calixteman
414a4d873a
Merge pull request #14489 from calixteman/14488
Fix scripting test related to keystroke event
2022-01-24 17:43:25 +01:00
Calixte Denizet
880ac6037c Fix scripting test related to keystroke event 2022-01-24 17:04:50 +01:00
calixteman
b280dff1c5
Merge pull request #14487 from Snuffleupagus/rm-out
Remove the `out.pdf` file (PR 14430 follow-up)
2022-01-24 15:31:57 +01:00
Jonas Jenwald
2f14723bf3 Remove the out.pdf file (PR 14430 follow-up)
It looks like this file was commited accidentally, since it contains *one* page from the default `tracemonkey` document.
2022-01-24 14:55:34 +01:00
Calixte Denizet
e1d3a3b414 Remove the invisible format marks from the text chunks
- it aims to fix issue #9186.
2022-01-24 13:47:24 +01:00
calixteman
88236e1163
Merge pull request #14430 from calixteman/beforeinput
[JS] Use beforeinput event to trigger a keystroke event in the sandbox
2022-01-23 20:42:33 +01:00
Calixte Denizet
6ac296e48e [JS] Use beforeinput event to trigger a keystroke event in the sandbox
- it aims to fix issue #14307;
 - this event has been added recently in Firefox and we can now use it;
 - fix few bugs in aform.js or in annotation_layer.js;
 - add some integration tests to test keystroke events (see `AFSpecial_Keystroke`);
 - make dispatchEvent in the quickjs sandbox async.
2022-01-23 19:53:01 +01:00
Jonas Jenwald
4f03f2a3a7 Update l10n files 2022-01-23 11:00:06 +01:00
Jonas Jenwald
1ed27965d1 Update npm packages 2022-01-23 10:58:15 +01:00
Tim van der Meij
23b6fde9fc
Merge pull request #14464 from Snuffleupagus/issue-14462
Support Type1 font files with incomplete /CharStrings definitions (issue 14462)
2022-01-19 20:38:46 +01:00
calixteman
b0231cc887
Merge pull request #14456 from calixteman/1749563
Font renderer - get int8 instead of uint8 in composite glyphes (bug 1749563)
2022-01-19 01:20:49 -08:00
Calixte Denizet
74f25d2755 Font renderer - get int8 instead of uint8 in composite glyphes (bug 1749563)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1749563;
 - use some helper functions to get (u|i)int** values in buffer: it helps to have a clearer code;
 - in composite glyphes the translations values with a transformations are signed so consequently get some int8 instead of uint8;
 - add few TODOs.
2022-01-18 22:06:23 +01:00
Jonas Jenwald
a13ae5d97d Support Type1 font files with incomplete /CharStrings definitions (issue 14462)
Please refer to https://www.pdfa.org/norm-refs/Type1Fonts.pdf#page=15 for the expected format for the /CharStrings entries.
In the referenced PDF document the /CharStrings are missing the expected end-token, which causes us to swallow the start of the next glyph name.
2022-01-17 18:55:22 +01:00
Tim van der Meij
f955b0e20c
Merge pull request #14457 from timvandermeij/unicode-test
Implement a unit test for `getCharUnicodeCategory` in `src/core/unicode.js` (PR 14428 follow-up)
2022-01-16 15:40:26 +01:00
Tim van der Meij
e08fd5e389
Implement a unit test for getCharUnicodeCategory in src/core/unicode.js (PR 14428 follow-up)
Given that the other functions in this file are already covered by unit
tests, we should also cover this newly added function.
2022-01-16 15:18:05 +01:00
Jonas Jenwald
749a3fa699
Merge pull request #14455 from Snuffleupagus/refactor-evaluator-normalizeWhitespace
Make the `normalizeWhitespace` handling, in the `PartialEvaluator`, more efficient (PR 14428 follow-up)
2022-01-16 09:25:03 +01:00
Jonas Jenwald
ba37d600d7 Make the normalizeWhitespace handling, in the PartialEvaluator, more efficient (PR 14428 follow-up)
After the changes in PR 14428 we can *directly*, and more efficiently, handle whitespace conversion in `PartialEvaluator.getTextContent` when the `normalizeWhitespace` option is being used.
This way we no longer need a separate helper function for this, and can avoid having to (again) iterate through the text and checking each character. Finally, this also removes the need for using a regular expression on e.g. all non-ASCII text.
2022-01-16 08:29:21 +01:00
calixteman
da953f4b64
Merge pull request #14428 from calixteman/typo
Use the correct dimension to know if we have to add an EOL in vertical mode
2022-01-15 12:47:10 -08:00
Calixte Denizet
9dae421a0d Handle all the whitespaces the same way when creating text chunks 2022-01-15 21:44:00 +01:00
Tim van der Meij
922dac035c
Merge pull request #14448 from Snuffleupagus/Type3-circular-refs
Prevent circular references in Type3 fonts
2022-01-15 14:11:47 +01:00
Tim van der Meij
a72d188599
Merge pull request #14439 from Snuffleupagus/issue-14438
Ignore Annotations with empty /Rect-entries in the display-layer (issue 14438)
2022-01-15 14:11:25 +01:00
Tim van der Meij
78f160b656
Merge pull request #14453 from Snuffleupagus/viewer-documenterror
Dispatch a "documenterror" event in `PDFViewerApplication._documentError` (issue 14451)
2022-01-15 14:00:16 +01:00
Tim van der Meij
c0d2932faf
Merge pull request #14454 from Snuffleupagus/util-more-unreachable
Replace some `assert` usage with `unreachable` in the `src/shared/util.js` file
2022-01-15 13:52:10 +01:00
Tim van der Meij
625f829842
Merge pull request #14446 from Snuffleupagus/issue-14435
Expose even more API-functionality in the TypeScript definitions (issue 14435, PR 14013 follow-up)
2022-01-15 13:46:11 +01:00
Jonas Jenwald
0e1b93bf20 Replace some assert usage with unreachable in the src/shared/util.js file
Inlining the checks should be a *tiny bit* more efficient, since it avoids have to make *unconditional* function calls in these fairly commonly used helper functions.
2022-01-15 13:01:25 +01:00
Jonas Jenwald
bf8a58e5e3 Dispatch a "documenterror" event in PDFViewerApplication._documentError (issue 14451)
*Please note:* This is a tentative patch, since I don't know if this is deemed important enough to fix.

The new event could be seen as a *supplement* to the existing "documentinit" and "documentloaded" events, but for the case when a PDF document fails to load.
To make the "documenterror" event generally useful, it'll include both the localized error message as well as the original reason for the error (when that exists).
2022-01-15 11:55:44 +01:00
Jonas Jenwald
e0032811cd
Merge pull request #14450 from Snuffleupagus/issue-14449
Add (basic) UTF-8 support in the `stringToPDFString` helper function (issue 14449)
2022-01-14 20:55:13 +01:00
Jonas Jenwald
12d8f0b64d Re-factor the stringToPDFString helper function for UTF-16 strings
This patch changes the function to instead utilize the `TextDecoder` for both kinds of UTF-16 BOM strings.
2022-01-14 20:38:40 +01:00
Jonas Jenwald
76444888fb Add (basic) UTF-8 support in the stringToPDFString helper function (issue 14449)
This patch implements this by looking for the UTF-8 BOM, i.e. `\xEF\xBB\xBF`, in order to determine the encoding.[1]
The actual conversion is done using the `TextDecoder` interface, which should be available in all environments/browsers that we support; please see https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder#browser_compatibility

---
[1] Assuming that everything lacking a UTF-16 BOM would have to be UTF-8 encoded really doesn't seem correct.
2022-01-14 18:57:07 +01:00
Jonas Jenwald
4c55563574 Add an additional test-case for circular references in Type3 fonts
The PDF document in this patch already worked *without* the previous patch, but I wanted to improve our test-coverage for the Type3-parsing.

The attached PDF document was also found in https://github.com/pdf-association/safedocs/tree/main/Miscellaneous%20Targeted%20Test%20PDFs
2022-01-13 17:59:57 +01:00
Jonas Jenwald
53d4ee7990 Prevent circular references in Type3 fonts
In corrupt PDF documents Type3 fonts may introduce circular dependencies, thus resulting in the affected font(s) never loading and parsing/rendering never completing.
Note that I've not seen any real-world examples of this kind of font corruption, but the attached PDF document was rather found in https://github.com/pdf-association/safedocs/tree/main/Miscellaneous%20Targeted%20Test%20PDFs

*Please note:* That repository contains a number of reduced test-cases that are specifically intended to test interoperability (between PDF viewer) and parsing/rendering for various kinds of strange/corrupt PDF documents.
Some of the test-cases found there may thus not make sense to try and "fix" upfront, in my opinion, unless the problems are also found in real-world PDF documents.
2022-01-13 17:58:37 +01:00
Jonas Jenwald
b9849e38b8 Expose even more API-functionality in the TypeScript definitions (issue 14435, PR 14013 follow-up)
While `PageViewport` apparently makes sense in TypeScript environments, given that it's being returned by the `PDFPageProxy.getViewport`-method in the API, we really don't want to extend the *public* API by simply exporting the class directly in `src/pdf.js` since it should never be called/initialized manually.
Hence we follow the same pattern as in PR 14013, and also extend the API unit-tests to ensure that `PDFPageProxy.getViewport` always returns a `PageViewport`-instance as expected.
2022-01-13 12:05:40 +01:00
Tim van der Meij
ea57ef116e
Merge pull request #14443 from Snuffleupagus/issue-14442
Prevent run-time errors in `BaseViewer` when it's falling back to `SimpleLinkService` (issue 14442, PR 14295 follow-up)
2022-01-12 20:09:14 +01:00
Jonas Jenwald
8286066372 Prevent run-time errors in BaseViewer when it's falling back to SimpleLinkService (issue 14442, PR 14295 follow-up) 2022-01-12 17:04:51 +01:00
Jonas Jenwald
08d88a0235 Ignore Annotations with empty /Rect-entries in the display-layer (issue 14438)
This prevents the `BaseSVGFactory.create`-method from throwing, and thus preventing any remaining Annotations (on the page) from rendering in corrupt documents.
2022-01-11 13:54:35 +01:00
Tim van der Meij
236c8d4786
Merge pull request #14432 from Snuffleupagus/update-packages
Update packages and translations
2022-01-09 15:13:53 +01:00
Jonas Jenwald
365538a383 Update l10n files 2022-01-09 11:32:34 +01:00
Jonas Jenwald
457ff0d54a Update Jasmine to version 4
For the unit-tests that were updated in this patch, note that I settled on simply using `toEqual` comparisons rather than updating the custom matchers (since those don't seem necessary any more).

Please refer to the following resources for additional information:
 - https://github.com/jasmine/jasmine/blob/main/release_notes/4.0.0.md
 - https://github.com/jasmine/jasmine-npm/blob/main/release_notes/4.0.0.md
 - https://jasmine.github.io/tutorials/upgrading_to_Jasmine_4.0
2022-01-09 11:32:34 +01:00
Jonas Jenwald
38e574f1d5 Update npm packages 2022-01-09 10:49:21 +01:00
Tim van der Meij
8ac0ccc227
Merge pull request #14424 from Snuffleupagus/mv-addLinkAttributes
[api-minor] Move `addLinkAttributes`, `LinkTarget`, and `removeNullCharacters` into the viewer (PR 14092 follow-up)
2022-01-08 13:19:11 +01:00
Tim van der Meij
8cf0a8c357
Merge pull request #14423 from Snuffleupagus/rm-getViewerConfiguration-eventBus
Remove the `eventBus` parameter from `getViewerConfiguration`
2022-01-08 13:02:02 +01:00