Commit Graph

12796 Commits

Author SHA1 Message Date
Takashi Tamura
4ac62d8787 Fix the type of PDFDocumentLoadingTask.destroy. 2020-08-07 16:10:19 +09:00
Tim van der Meij
8c162f57f7
Merge pull request #12175 from calixteman/textfield
Support textfield and choice widgets for printing
2020-08-07 00:20:29 +02:00
Tim van der Meij
1f79c9834d
Merge pull request #12169 from Snuffleupagus/BaseTreeViewer-2
Extract common methods from `PDFOutlineViewer`/`PDFAttachmentViewer` into a new abstract `BaseTreeViewer` class
2020-08-06 23:14:11 +02:00
Tim van der Meij
b99b3b6ab7
Merge pull request #12179 from Snuffleupagus/Object.fromEntries
Add support for `Object.fromEntries`
2020-08-06 22:55:34 +02:00
Calixte Denizet
1747d259f9 Support textfield and choice widgets for printing 2020-08-06 14:45:23 +02:00
Jonas Jenwald
16fa9dc4ea Add support for Object.fromEntries
This provides a simpler way of creating an `Object` from e.g. a `Map`, without having to manually iterate over it.
Please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries
2020-08-06 14:39:51 +02:00
Tim van der Meij
95e102c07b
Merge pull request #12173 from Snuffleupagus/render-annotationStorage
[api-minor] Fix the `annotationStorage` parameter in `PDFPageProxy.render`
2020-08-05 23:30:50 +02:00
Jonas Jenwald
54fc7058e4 Re-factor the "outlineloaded"/"attachmentsloaded" event handlers in PDFSidebar
With recent changes, these event handlers are now essentially identical. Hence a new helper function is added, to reduce unnecessary duplication (will also be helpful with upcoming changes).
2020-08-05 23:08:06 +02:00
Jonas Jenwald
6e9da55a39 Extract common methods from PDFOutlineViewer/PDFAttachmentViewer into a new abstract BaseTreeViewer class
These two classes are unsurprisingly quite similar, and with upcoming changes[1] the amount of (essentially) duplicated code will increase even further.

Notable changes:
 - Collect shared functionality in the `BaseTreeViewer` class, reducing both current and future code-duplication.
 - Reduce unnecessary duplication in the CSS rules, which will be particularly useful with upcoming changes.
 - Tweak the attachmentsView to use links, rather than buttons, to simplify (primarily) the CSS rules.

---
[1] Once API support for "Optional Content" lands, I've got more-or-less finished patches to add viewer support as well.
2020-08-05 23:08:06 +02:00
Jonas Jenwald
a6c1ef82ae Update BaseViewer.createAnnotationLayerBuilder, and PDFPageView, to accurately reflect IPDFAnnotationLayerFactory (PR 12147 follow-up) 2020-08-05 23:02:30 +02:00
Jonas Jenwald
5e44b241b2 [api-minor] Fix the annotationStorage parameter in PDFPageProxy.render
While the parameter name (clearly) suggests that an `AnnotationStorage`-instance is expected, looking at the only call-sites that include the parameter (i.e. the `PDFPrintServiceFactory` instances) it actually contains just a normal Object.

Hence it seems much more reasonable to actually pass a valid `AnnotationStorage`-instance, as the name suggests, and simply have `PDFPageProxy.render` do the `annotationStorage.getAll()` call. (Since we cannot send an `AnnotationStorage`-instance as-is to the worker-thread, given the "structured clone algorithm".)
2020-08-05 23:02:30 +02:00
Tim van der Meij
a289eb8325
Merge pull request #12174 from Snuffleupagus/AppOptions-printResolution
Do the `AppOptions.get("printResolution")` lookup once in `web/app.js `, when initializing `PDFPrintServiceFactory`-instances, rather than for every printed page
2020-08-05 22:47:37 +02:00
Tim van der Meij
66d5345dea
Merge pull request #12172 from tamuratak/fix_typedarray
Fix the type definition of TypedArray. (PR 12156 follow-up)
2020-08-05 22:39:10 +02:00
Jonas Jenwald
97d796e372 Do the AppOptions.get("printResolution") lookup once in web/app.js, when initializing PDFPrintServiceFactory-instances, rather than for every printed page
There's really no point in repeating these lookups over and over, since the value should be constant for the duration of one print invocation anyway.
2020-08-05 13:34:09 +02:00
Takashi Tamura
a0f0ab78f3 Fix the type definition of TypedArray. 2020-08-05 17:01:08 +09:00
Tim van der Meij
63e33a5895
Merge pull request #12168 from Snuffleupagus/fix-types
Fix the `gulp types` task to run on Windows, and place the TypeScript definitions correctly in `pdfjs-dist`
2020-08-05 00:26:11 +02:00
Tim van der Meij
02bcc25b9f
Merge pull request #12171 from Snuffleupagus/unittest-shall_fail_rendering
Attempt to reduce intermittent failures in the "multiple render() on the same canvas" unit-test
2020-08-05 00:02:39 +02:00
Tim van der Meij
85982c45dc
Merge pull request #12163 from Snuffleupagus/improve-PDFAttachmentViewer-render
Re-factor the dispatching of "attachmentsloaded" events, when the PDF document contains no "regular" attachments
2020-08-04 23:59:20 +02:00
Jonas Jenwald
fb85c2dc6d Fix the gulp types task to run on Windows, and place the TypeScript definitions correctly in pdfjs-dist
- Fix the `gulp types` task to run on Windows. Currently this fails, and the solution was to "borrow" the same formatting as used in the `gulp jsdoc` task.

 - Place the TypeScript definitions in their own `types` directory, when building `pdfjs-dist`. These should *not* be cluttering the main `build` directory, especially since the generated TypeScript definitions consists of *multiple folders*. (Only if the TypeScript definitions would be concatenated into *a single file*, would placing them directly in `pdfjs-dist/build` be acceptable.)
2020-08-04 23:50:04 +02:00
Tim van der Meij
71f8e1f538
Merge pull request #12156 from timvandermeij/types-followup
Improve the types generation and API documentation (PR 12102 follow-up)
2020-08-04 23:40:44 +02:00
Tim van der Meij
56ca027c08
Improve consistency for the API documentation comments
Over time we used multiple different formats for JSDoc comments. This
commit standardizes those formats to the one we used most often.

Moreover, this removes the example in the outline endpoint documentation
since it now has a proper type definition and it didn't render correctly
in JSDoc.
2020-08-04 23:27:22 +02:00
Tim van der Meij
ba4a07ce07
Fix incorrect types in the API documentation 2020-08-04 23:19:59 +02:00
Tim van der Meij
3116216e1d
Improve the API documentation for PDFDocumentLoadingTask
This commit:
- formats the documentation block according to the standards;
- replaces the callback definitions with the `function` type (we have
  that for other definitions already and the callback type was not
  rendered correctly by JSDoc);
- synchronizes the type documentation and the class documentation;
- fixes the documentation by making it easier to read and making sure
  that all optional properties are indicated as such;
- uses the `@link` tag to indicate links to other code.

The `typestest` still passes and JSDoc now renders this class correctly.
2020-08-04 23:17:24 +02:00
Tim van der Meij
7e759c6e2b
Improve the typestest target in the Gulpfile
This commit:
- moves the preparation work to a new `typestest-pre` target similar to
  how the other targets work;
- moves the `TYPESTEST_DIR` definition to the top of the file like we
  did for all other directory variables;
- renames the `TYPES_BUILD_DIR` variable to `TYPES_DIR` since it's
  shorter and the naming scheme then corresponds to the other directory
  variables;
- switches to `const`/template strings in the types targets where needed;
- converts the `if (err !== null)` check to `if (err)` similar to other
  targets.
2020-08-04 23:17:20 +02:00
Jonas Jenwald
13e44c0776 Attempt to reduce intermittent failures in the "multiple render() on the same canvas" unit-test
This patch should *hopefully* remove the intermittent unit-test failure, by using the *same* `optionalContentConfigPromise` for both `renderTask`s and thus get more predictable timing behaviour.
2020-08-04 22:31:24 +02:00
Brendan Dahl
9989879458
Merge pull request #12095 from brendandahl/oc
Add support for optional marked content.
2020-08-04 12:00:20 -07:00
Brendan Dahl
ac494a2278 Add support for optional marked content.
Add a new method to the API to get the optional content configuration. Add
a new render task param that accepts the above configuration.
For now, the optional content is not controllable by the user in
the viewer, but renders with the default configuration in the PDF.

All of the test files added exhibit different uses of optional content.

Fixes #269.

Fix test to work with optional content.

- Change the stopAtErrors test to ensure the operator list has something,
  instead of asserting the exact number of operators.
2020-08-04 09:26:55 -07:00
Tim van der Meij
e68ac05f18
Merge pull request #12160 from tamuratak/worker_options
Use typedef to define the type of GlobalWorkerOptions (PR 12102 follow-up)
2020-08-03 22:55:49 +02:00
Tim van der Meij
0b75701012
Merge pull request #12157 from tamuratak/fix_svggraphics
Fix the type of SVGGraphics (PR 12102 follow-up)
2020-08-03 22:52:10 +02:00
Tim van der Meij
adc7645a44
Merge pull request #12161 from tamuratak/exported_func
Add types to functions exported as API in src/pdf.js (PR 12102 follow-up)
2020-08-03 22:43:50 +02:00
Tim van der Meij
82fece76df
Merge pull request #12162 from tamuratak/viewbox
Tweak for the type of PageViewportParameters.viewBox (PR 12102 follow-up)
2020-08-03 22:35:28 +02:00
Jonas Jenwald
0b65d4cacd Re-factor the dispatching of "attachmentsloaded" events, when the PDF document contains no "regular" attachments
Since the attachment fetching/parsing is already asynchronous, possibly delaying the dispatching of an "attachmentsloaded" event should thus not be a problem in general.
Note that in some cases, i.e. PDF documents with no "regular" attachments and only FileAttachment annotations, we'll thus no longer dispatch an "attachmentsloaded" event when `attachmentsCount === 0` and instead wait for the FileAttachment parsing to finish. (The use of a timeout still guarantees that an "attachmentsloaded" event is *eventually* dispatched though.)

This patch *considerably* simplifies the "attachmentsloaded" event handler, in `PDFSidebar`, since the details are now abstracted away from the consumer.

Finally, add a check in `_appendAttachment` to ensure (indirectly) that the FileAttachment annotation is actually relevant for the active document.
2020-08-03 14:23:44 +02:00
Takashi Tamura
923ba27f1f Tweak for the type of PageViewportParameters.viewBox 2020-08-03 20:42:42 +09:00
Takashi Tamura
bc4648c0a6 Add types to functions exported as API in src/pdf.js. 2020-08-03 19:19:48 +09:00
Jonas Jenwald
24d8933023 Use a DocumentFragment when building the attachmentsView in PDFAttachmentViewer.render
This approach is already used in other parts of the code-base, see e.g. `PDFOutlineViewer`, and has the advantage of only invalidating the DOM once rather than for every attachment item.
2020-08-03 12:11:46 +02:00
Takashi Tamura
f6fd8e9e7f Use typedef to define the type of GlobalWorkerOptions. 2020-08-03 19:06:28 +09:00
Takashi Tamura
d72bbecee2 Fix the type of SVGGraphics. 2020-08-03 09:58:19 +09:00
Tim van der Meij
00a8b42e67
Merge pull request #12102 from ineiti/add_types_annotations
Add types annotations
2020-08-02 16:45:37 +02:00
Tim van der Meij
5a66c56eca
Merge pull request #12108 from calixteman/radio
Add support for radios printing
2020-08-02 14:47:46 +02:00
Tim van der Meij
277a92d278
Merge pull request #12153 from timvandermeij/jasmine
Unit test improvements
2020-08-01 21:59:28 +02:00
Tim van der Meij
c53e403049
Update Jasmine to version 3.6.1
This is possible now that most intermittent unit test failures have been
resolved by other patches. There is only one remaining, but it's very
rare and doesn't have to block this update anymore.
2020-08-01 21:12:26 +02:00
Tim van der Meij
b789a0e216
Log the total number of tests and the random seed in the test runner
This might make debugging intermittent failures a bit easier in the
future because it allows us to spot unexpected differences in the number
of tests being run and allows us to run the tests locally in the same
order in case of intermittent failures.
2020-08-01 21:09:01 +02:00
Tim van der Meij
662ac5548f
Log suite start failures in the test runner 2020-08-01 21:02:20 +02:00
Tim van der Meij
c19d76f9b8
Use a for...of loop in the specDone handler in the test reporter
Moreover, remove a left-over reference to `test.py` since that was
ported to JavaScript a long time ago.
2020-08-01 20:50:30 +02:00
Tim van der Meij
252f2ba529
Merge pull request #12151 from Snuffleupagus/revert-12131-issue-8271
Revert "[api-minor] Allow loading pdf fonts into another document."
2020-08-01 15:06:40 +02:00
Jonas Jenwald
05baa4c89f
Revert "[api-minor] Allow loading pdf fonts into another document." 2020-08-01 12:52:39 +02:00
Tim van der Meij
173b92a873
Merge pull request #12131 from jsg2021/issue-8271
[api-minor] Allow loading pdf fonts into another document.
2020-08-01 01:13:41 +02:00
Tim van der Meij
0c2cef8024
Merge pull request #12148 from timvandermeij/revert
Revert "Populate the find field with the search query when URL has #search hash"
2020-08-01 00:53:51 +02:00
Tim van der Meij
81ae565d8a
Revert "Populate the find field with the search query when URL has #search hash"
This reverts commit 50f73092e1. This
causes an inconsistency with the integrated find bar that should be
discussed more before moving on with this (refer to PR #12141).
2020-08-01 00:41:56 +02:00
Tim van der Meij
0d20a2b7b4
Merge pull request #12144 from Snuffleupagus/uncaught-promise-AbortException
Prevent `Uncaught (in promise) AbortException` when running the unit-tests
2020-08-01 00:22:10 +02:00