Commit Graph

11230 Commits

Author SHA1 Message Date
Tim van der Meij
a77ac5fa23
Merge pull request #10185 from Snuffleupagus/find-less-normalization
Reduce the number of redundant text normalization operations in `PDFFindController`
2018-10-28 13:31:15 +01:00
Tim van der Meij
ed4ac1bc67
Merge pull request #10162 from janpe2/svg-normalize-bbox
Normalize BBox of form XObjects in SVG back-end
2018-10-28 13:18:48 +01:00
Tim van der Meij
c76c9878be
Merge pull request #10188 from timvandermeij/download-button
Hide the beta version button on the website if there is only a stable version
2018-10-27 21:01:13 +02:00
Tim van der Meij
2b5bc6bcec
Hide the beta version button on the website if there is only a stable version 2018-10-27 20:57:01 +02:00
Tim van der Meij
31bff2d950
Merge pull request #10187 from timvandermeij/bump
Bump versions in `pdfjs.config`
2018-10-27 17:02:11 +02:00
Tim van der Meij
7c6c56214f
Bump versions in pdfjs.config 2018-10-27 16:55:23 +02:00
Jonas Jenwald
5dc12f9a6d Only normalize the search query once, in `PDFFindController, for every page being searched
For a short document, such as e.g. the `tracemonkey` file, this repeated normalization won't matter much, but for documents with a couple of thousand pages it seems completely unnecessary (and wasteful) to keep repeating the normalization whenever for every single page.
2018-10-27 11:44:24 +02:00
Jonas Jenwald
84ae4f9a5e Only normalize the text-content once, in PDFFindController, and not on every new search operation
Currently the text-content is normalized every time that a new search operation is started, which seems completely useless considering that the "raw" text-content is never used for anything.
For a short document, such as e.g. the `tracemonkey` file, this repeated normalization won't matter much, but for documents with a couple of thousand pages it seems completely unnecessary (and wasteful) to keep repeating the normalization whenever e.g. a new search operation starts.
2018-10-26 20:23:32 +02:00
Jonas Jenwald
12d8b52c49 Move the normalize helper function out of PDFFindController
In the event that multiple instances of `PDFFindController` ever exists simultaneously, they will all be able to share just one `normalize` function in this way. Furthermore, the regular expression is now created lazily rather than at class construction time.
2018-10-26 18:22:32 +02:00
Jonas Jenwald
64d75c32bf Ensure that matches are not scrolled into after the findbar has been closed (PR 10100 follow-up)
Despite all highlighted matches being removed in response to the 'findbarclose' event, there's a risk that a match could still be scrolled into view *after* the findbar has been closed[1].
Hence we need to ensure that long running searches, particularily those happening in large and/or slow loading documents[2], are ignored as well.

---
[1] The match is hidden, as expected, but the document could still scroll unexpectedly.
[2] Large documents loaded with `disableAutoFetch = true` and `disableStream = true` set are particularily susceptible to this issue.
2018-10-26 12:43:12 +02:00
Jonas Jenwald
27b21f2558 Add a _updateAllPages helper method to PDFFindController in order to reduce the amount of event dispatching
Given that dispatching the 'updatetextlayermatches' event with `pageIndex = -1` set is now used to target the textLayers of *all* pages, there's no need to send individual events to every single page during `_nextMatch`. Since there can be an arbitrary number of pages in a document, this small/simple optimization seems too easy to ignore.
2018-10-26 11:50:44 +02:00
Jonas Jenwald
d73a71fb90 Small clean-up of the search related methods in TextLayerBuilder
This patch does four things:
 - Change the search related methods in `TextLayerBuilder` to be "private", since there're only called from within the class itself now.
 - Use `const` for local variables not intended to change in the search related methods in `TextLayerBuilder`.
 - Finally, removes most `this.findController` checks since they are redundant. Note how both `this._convertMatches` and `this._renderMatches` are *only* ever called, from `this._updateMatches`, when `this.findController` is actually defined. Hence there's really no need to repeat those checks all over the place, especially with all the relevant methods now being marked as "private".
 - Always initialize the `this._pageMatchesLength` property with an empty array, to simplify the code in `TextLayerBuilder`.
2018-10-25 21:38:25 +02:00
Tim van der Meij
dc98bf76eb
Merge pull request #10179 from ThomasdenH/patch-1
Change splice to pop in annotation tests
2018-10-24 23:45:22 +02:00
Thomas den Hollander
b157d8b478
Change splice to pop in annotation tests
This line in the annotation tests subtracts an array from a number. This is because `splice(-1, 1)` returns a one-element array, while `pop()` returns only the element itself.
2018-10-24 13:08:08 +02:00
Tim van der Meij
f31f4bea4f
Merge pull request #10176 from timvandermeij/updates
Update translations and packages
2018-10-24 00:23:45 +02:00
Tim van der Meij
0abddde2c7
Update packages
Webpack is pinned because versions higher than this cause the viewer not
to work (see https://github.com/mozilla/pdf.js/pull/10170#issuecomment-431697032).

Node.js is pinned for Travis CI because version 11 requires that we
update to Gulp 4.
2018-10-24 00:09:39 +02:00
Tim van der Meij
c74c357157
Update translations 2018-10-23 23:32:42 +02:00
Jani Pehkonen
9cd5f94f03 Normalize the BBox of form XObjects on the /core side 2018-10-22 14:17:05 +03:00
Tim van der Meij
aa728aaf94
Merge pull request #10168 from Snuffleupagus/PDFDataRangeTransport-class
Convert `PDFDataRangeTransport` to an ES6 class
2018-10-21 15:49:24 +02:00
Jonas Jenwald
5bb7f4b615 Convert PDFDataRangeTransport to an ES6 class 2018-10-20 17:15:27 +02:00
Tim van der Meij
d21892933d
Merge pull request #10161 from Snuffleupagus/DataLoaded-onProgress
Ensure that `onProgress` is always called when the entire PDF file has been loaded, regardless of how it was fetched (issue 10160)
2018-10-20 15:22:05 +02:00
Tim van der Meij
e63e2ef85e
Merge pull request #10167 from Snuffleupagus/pdfjsLib-more-exports
Export `CMapCompressionType` and `PermissionFlag` on the `pdfjsLib` object (issue 10148, PR 10033 follow-up)
2018-10-20 15:14:56 +02:00
Jonas Jenwald
54f9883c51 Export CMapCompressionType and PermissionFlag on the pdfjsLib object (issue 10148, PR 10033 follow-up)
`CMapCompressionType` makes a lot of sense to export, for anyone attempting to implement a custom `CMapReaderFactory`; fixes 10148.

`PermissionFlag` likewise needs to be exported, since otherwise the result of the `getPermissions` API method becomes difficult to interpret; follow-up to 10033.
2018-10-20 11:38:00 +02:00
Tim van der Meij
a0bc5c2df0
Merge pull request #10166 from timvandermeij/bump
Bump version numbers for stable and beta releases
2018-10-19 23:08:23 +02:00
Tim van der Meij
af33399ac9
Bump version numbers for stable and beta releases 2018-10-19 23:03:19 +02:00
Jonas Jenwald
327f2eb588 Ensure that onProgress is always called when the entire PDF file has been loaded, regardless of how it was fetched (issue 10160)
*Please note:* I'm totally fine with this patch being rejected, and the issue closed as WONTFIX; however these changes should address the issue if that's desired.

From a conceptual point of view, reporting loading progress doesn't really make a lot of sense for PDF files opened by passing raw binary data directly to `getDocument` (since obviously *all* data was loaded).
This is compared to PDF files loaded via e.g. `XMLHttpRequest` or the Fetch API, where the entire PDF file isn't available from the start and knowing the loading progress makes total sense.

However I can certainly see why the current API could be considered inconsistent, which isn't great, since a registered `onProgress` callback will never be called for certain `getDocument` calls.
The simplest solution to this inconsistency thus seem to be to ensure that `onProgress` is always called when handling the `DataLoaded` message, since that will *always* be dispatched[1] from the worker-thread.

---
[1] Note that this isn't guaranteed to happen, since setting `disableAutoFetch = true` often prevents the *entire* file from ever loading. However, this isn't relevant for the issue at hand, and is a well-known consequence of using `disableAutoFetch = true`; note how the default viewer even has a specialized code-path for hiding the loadingBar.
2018-10-16 13:51:12 +02:00
Tim van der Meij
ecbdc508f7
Merge pull request #10155 from kevin51jiang/build-button
Add Build Status Button
2018-10-14 14:51:37 +02:00
Kevin Jiang
c4ac6ad431
Add Build Status Button
Add build Status button so that it's easy to see if pdf.js passed tests or not.
2018-10-13 18:26:48 -04:00
Tim van der Meij
e41c50c3c5
Merge pull request #10152 from Snuffleupagus/classList-toggle
Add support for `classList.toggle` with the, optional, "force" parameter
2018-10-12 23:28:53 +02:00
Jonas Jenwald
ea4db64f41 Convert some occurrences, in the /web folder, of classList.{add, remove} to classList.toggle with the "force" parameter 2018-10-12 15:41:11 +02:00
Jonas Jenwald
4cde844ffe Add a DOMTokenList.toggle polyfill for the second, optional, "force" parameter
This is based on the polyfill available at https://developer.mozilla.org/en-US/docs/Web/API/Element/classList#Polyfill
2018-10-12 15:41:09 +02:00
Tim van der Meij
06c6503ba0
Merge pull request #10150 from Snuffleupagus/linkService-pagesCount
Add missing `pagesCount` getter to `IPDFLinkService` and `SimpleLinkService`
2018-10-11 22:37:34 +02:00
Jonas Jenwald
df8d9f45f9 Add missing pagesCount getter to IPDFLinkService and SimpleLinkService 2018-10-11 10:29:15 +02:00
Tim van der Meij
9e9426c354
Merge pull request #10143 from Snuffleupagus/getMainThreadWorkerMessageHandler-catch-errors
Ensure that `getMainThreadWorkerMessageHandler` won't accidentally break `getDocument` (PR 10139 follow-up)
2018-10-11 00:05:01 +02:00
Tim van der Meij
6f30cbb478
Merge pull request #10140 from Snuffleupagus/rm-pdfjsFilePath
Combine the `pdfjsFilePath` and fallback `workerSrc` handling in `src/display/api.js`
2018-10-10 00:18:38 +02:00
Jonas Jenwald
0e2c6047e4 Ensure that getMainThreadWorkerMessageHandler won't accidentally break getDocument (PR 10139 follow-up)
*This should have been part of PR 10139.*

In the event that a user has attempted to manually load the worker file on the main-thread, but somehow failed to do that correctly, there's a possibility that `getMainThreadWorkerMessageHandler` could throw. Considering how/where that helper function is being called, an error could still prevent `PDFDocumentLoadingTask` from completing (regardless if it's being resolved/rejected).
2018-10-09 15:44:31 +02:00
Jonas Jenwald
21c8dd4842 Combine the pdfjsFilePath and fallback workerSrc handling in src/display/api.js
With the way that the `getWorkerSrc()` helper function is implemented now, there's no longer a particularly strong reason for keeping the global `pdfjsFilePath` variable around.
With this patch the fallback `workerSrc` will thus, assuming is wasn't already set, be set to the "pdfjsFilePath" which simplifies the `getWorkerSrc()` function and reduces the amount of global state.

Finally, the global `workerSrc` variable was renamed to prevent shadowing.
2018-10-09 13:47:48 +02:00
Tim van der Meij
f45e46d7ad
Merge pull request #10133 from kevinleedrum/fix-content-length
Set returnValues.suggestedLength to Content-Length if integer
2018-10-09 00:05:57 +02:00
Kevin Lee Drum
4cf10ac79d set returnValues.suggestedLength to Content-Length if integer 2018-10-07 13:26:29 -04:00
Tim van der Meij
b2e7d0c89b
Merge pull request #10139 from Snuffleupagus/issue-10135
Ensure that the `PDFDocumentLoadingTask` is rejected when "setting up fake worker" failed (issue 10135)
2018-10-07 15:54:50 +02:00
Jonas Jenwald
755c6edc5e Ensure that the PDFDocumentLoadingTask is rejected when "setting up fake worker" failed (issue 10135)
This should, hopefully, cover all the possible ways[1] in which "fake workers" are loaded. Given the different code-paths, adding unit-tests might not be that simple.
Note that in order to make this work, the various `fakeWorkerFilesLoader` functions were converted to return `Promises`.

---
[1] Unfortunately there's lots of them, for various build targets and configurations.
2018-10-06 13:18:51 +02:00
Tim van der Meij
d4469da22b
Merge pull request #10138 from Snuffleupagus/toolbar-pageScaleValue
Ensure that `Toolbar.setPageScale` always sets the `pageScaleValue` property to a valid value
2018-10-05 22:41:59 +02:00
Tim van der Meij
3c6d0a8c44
Merge pull request #10136 from Snuffleupagus/toolbar-signature
Remove the unused `mainContainer` parameter from the `Toolbar` constructor
2018-10-05 22:38:38 +02:00
Jonas Jenwald
a4d4364f5d Ensure that Toolbar.setPageScale always sets the pageScaleValue property to a valid value
Rather than having every invocation of `Toolbar._updateUIState` compute a valid `pageScaleValue`, it seems easier to simply ensure that it happens when the value is actually updated.
2018-10-05 12:13:48 +02:00
Jonas Jenwald
5d421964e5 Remove the unused mainContainer parameter from the Toolbar constructor
Looking at the history of this code, this parameter has never been used.
I'm guessing that most likely the code in `web/toolbar.js` began life as a copy of `web/secondary_toolbar.js`, which would probably explain why that parameter exists.
2018-10-05 10:17:37 +02:00
Tim van der Meij
ff2df9c5b6
Merge pull request #10117 from leblanc-simon/ink-annotation-support
Add support of Ink annotation
2018-10-04 23:39:41 +02:00
Tim van der Meij
5da53ee98f
Merge pull request #10128 from Snuffleupagus/find-controller-enable
Make `PDFFindController` less confusing to use, by allowing searching to start when `setDocument` is called
2018-10-04 23:12:50 +02:00
Jonas Jenwald
2ed3591b22 Make PDFFindController less confusing to use, by allowing searching to start when setDocument is called
*This patch is based on something that I noticed while working on PR 10126.*

The recent re-factoring of `PDFFindController` brought many improvements, among those the fact that access to `BaseViewer` is no longer required. However, with these changes there's one thing which now strikes me as not particularly user-friendly[1]: The fact that in order for searching to actually work, `PDFFindController.setDocument` must be called *and* a 'pagesinit' event must be dispatched (from somewhere).

For all other viewer components, calling the `setDocument` method[2] is enough in order for the component to actually be usable.
The `PDFFindController` thus stands out quite a bit, and it also becomes difficult to work with in any sort of custom implementation. For example: Imagine someone trying to use `PDFFindController` separately from the viewer[3], which *should* now be relatively simple given the re-factoring, and thus having to (somehow) figure out that they'll also need to manually dispatch a 'pagesinit' event for searching to work.

Note that the above even affects the unit-tests, where an out-of-place 'pagesinit' event is being used.
To attempt to address these problems, I'm thus suggesting that *only* `setDocument` should be used to indicate that searching may start. For the default viewer and/or the viewer components, `BaseViewer.setDocument` will now call `PDFFindController.setDocument` when the document is ready, thus requiring no outside configuration anymore[4]. For custom implementation, and the unit-tests, it's now as simple as just calling `PDFFindController.setDocument` to allow searching to start.

---
[1] I should have caught this during review of PR 10099, but unfortunately it's sometimes not until you actually work with the code in question that things like these become clear.

[2] Assuming, obviously, that the viewer component in question actually implements such a method :-)

[3] There's even a very recent issue, filed by someone trying to do just that.

[4] Short of providing a `PDFFindController` instance when creating a `BaseViewer` instance, of course.
2018-10-04 10:28:50 +02:00
Tim van der Meij
8411a7da28
Merge pull request #10126 from Snuffleupagus/find-fixes
[Regression] Restore the ability to start searching before a document has loaded, and ignore searches for previously opened documents (PR 10099 follow-up)
2018-10-04 00:09:26 +02:00
Jonas Jenwald
6be4921eaf Make the clearing of find highlights, when closing the findbar, asynchronous
Since searching itself is an asynchronous operation, removal of highlights needs to be asynchronous too since otherwise there's a risk that the events happen in the wrong order and find highlights thus remain visible.

Also, this patch will now ensure that only 'findbarclose' events for the *current* document is handled since other ones doesn't really matter. Note in particular that when no document is loaded text-layers are, obviously, not present and subsequently it's unnecessary to attempt to hide non-existent find highlights.
2018-10-03 10:47:14 +02:00