Commit Graph

11240 Commits

Author SHA1 Message Date
Tim van der Meij
bb5f261c58
Merge pull request #10201 from Snuffleupagus/find-less-updatePage
Reduce the number of redundant `updatetextlayermatches` events dispatched when calculating matches in `PDFFindController`
2018-10-31 22:29:40 +01:00
Jonas Jenwald
f23dba1c10 Change canvasInRendering to a WeakSet instead of a WeakMap
Note how nowhere in the code `canvasInRendering.get()` is ever called, and that this structure is really only used to store references to `<canvas>` DOM elements.
The reason for this being a `WeakMap` is probably because at the time we weren't using `core-js` polyfills yet, and since there already existed a manually implemented `WeakMap` polyfill it was probably simpler to use that.
2018-10-31 18:15:23 +01:00
Jonas Jenwald
f77b463339 Attempt to clean-up/restore pending rendering operations on RenderTask.cancel (issue 10200)
Please note that, given the lack of a runnable example, I'm not totally sure if this first of all is enough to *completely* address the issue as filed and second of all if we actually want this new behaviour.
2018-10-31 16:22:17 +01:00
Jonas Jenwald
014b7a3147 Reduce the number of redundant updatetextlayermatches events dispatched when calculating matches in PDFFindController
Currently `PDFFindController._calculateMatch` is (indirectly) dispatching an `updatetextlayermatches` event for every *single* page of the document. For short documents, such as the `tracemonkey` file, this probably doesn't matter too much, but for documents with a couple of thousand pages it seems unfortunate.

It shouldn't be necessary, in general, to dispatch `updatetextlayermatches` events here, since that's already being taken care of in `PDFFindController._updateMatch` which is always called when a match has been found.
However, when `highlightAll` is set we still need to ensure that pages which finished rendered *before* searching begun are updated correctly.
2018-10-31 16:05:12 +01:00
Tim van der Meij
42b7bb4751
Merge pull request #10190 from Snuffleupagus/_getCurrentVisiblePage
Add a helper method for `_getVisiblePages`, in `BaseViewer`, for the case where only a single page is displayed in the viewer
2018-10-29 23:19:32 +01:00
Tim van der Meij
74b5d0b022
Merge pull request #10196 from Snuffleupagus/findbarclose-findagain-highlightAll
[Regression] Ensure that "Highlight All" is propagated to all pages for 'findagain' events where the findbar was previously closed (PR 10100 follow-up)
2018-10-29 23:12:37 +01:00
Jonas Jenwald
96abb4bbe7 [Regression] Ensure that "Highlight All" is propagated to all pages for 'findagain' events where the findbar was previously closed (PR 10100 follow-up)
**STR:**
1. Open the default viewer, with the `tracemonkey` file.
2. Open the findbar, and search for "trace".
3. Enable the "Highlight All" option.
4. Close the findbar.
5. Re-open the findbar, and click on the "findNext" button.
6. Scroll down to the *second* page of the document.

**ER:**
Since "Highlight All" is active, all matches on the *second* page should be highlighted.

**AR:**
No matches are highlighted on the *second* page.
2018-10-29 19:50:29 +01:00
Jonas Jenwald
2a79bcbe45 Add a helper method for _getVisiblePages, in BaseViewer, for the case where only a single page is displayed in the viewer
This is relevant for e.g. `PDFSinglePageViewer`, and `PDFViewer` with Presentation Mode active.
By moving this code to a helper method in `BaseViewer`, it's thus possible to reduce the amount of duplicate code that currently needed in `PDFViewer` and `PDFSinglePageViewer`.
2018-10-28 14:59:31 +01:00
Tim van der Meij
991a574c60
Merge pull request #10184 from Snuffleupagus/findbarclose-abort
Ensure that matches are not scrolled into after the findbar has been closed (PR 10100 follow-up)
2018-10-28 14:01:03 +01:00
Tim van der Meij
04ce2afd4a
Merge pull request #10182 from Snuffleupagus/TextLayerBuilder-rm-findController-checks
Small clean-up of the search related methods in `TextLayerBuilder`
2018-10-28 13:45:01 +01:00
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