Commit Graph

46 Commits

Author SHA1 Message Date
Jonas Jenwald
c750514903 Simplify extractText in web/pdf_find_controller.js
Currently this method first uses a loop to build a temporary array to hold Promises, which are then resolved from a recursive helper function once the textContent is fetched for each page.

To me, this is unncessarily complicated, since we can do everything within one loop by simply chaining the asynchronous calls to retrieve the textContent. (Note that this guarantees that the textContent of the pages is still fetched sequentially.)
2017-05-10 14:09:15 +02:00
Jonas Jenwald
f27b5013e2 Replace unnecessary bind(this) statements with arrow functions in web/ files
By using `let`, which is block-scoped, instead of `var` in a couple of places we're able to get rid of additional `bind` calls.
2017-05-04 17:13:09 +02:00
Jonas Jenwald
b0a4f6de8f Use createPromiseCapability in /web files
In various viewer files, there's a number of cases where we basically duplicate the functionality of `createPromiseCapability` manually.
As far as I can tell, a couple of these cases have existed for a very long time, and notable even before the `createPromiseCapability` utility function existed.

Also, since we can write ES6 code now, the patch also replaces a couple of `bind` usages with arrow functions in code that's touched in the patch.
2017-04-16 12:45:24 +02:00
Yury Delendik
8e681ce3e2 Change amd to cjs path in ES6 modules 2017-04-14 10:32:36 -05:00
Jonas Jenwald
3b35c15d42 Convert the files in the /web folder to ES6 modules
Note that as discussed on IRC, this makes the viewer slightly slower to load *only* in `gulp server` mode, however the difference seem slight enough that I think it will be fine.
2017-04-09 11:55:48 +02:00
Jonas Jenwald
4046d67fde Enable the no-else-return ESLint rule
Using `else` after `return` is not necessary, and can often lead to unnecessarily cluttered code. By using the `no-else-return` rule in ESLint we can avoid this pattern, see http://eslint.org/docs/rules/no-else-return.
2017-01-09 20:27:39 +01:00
Jonas Jenwald
076e25f1ca Prevent destinations with bad left/top values from scrolling the wrong page into view (bug 874482)
There are PDF generators which create destinations with e.g. too large top values, which cause the wrong page to be scrolled into view because the offset becomes negative.
By ignoring negative offsets, we can prevent this issue, and get a similar behaviour as in Adobe Reader.

However, since we're also using `PDFViewer_scrollPageIntoView` in more cases than just when links (in the document/outline) are clicked, the patch adds a way to allow the caller to opt-out of this behaviour.
In e.g. the following situations, I think that we still want to be able to allow negative offsets: when restoring a position from the `ViewHistory`, when the `viewBookmark` button is used to obtain a link to the current position, or when maintaining the current position on zooming.

Rather than adding another parameter to `PDFViewer_scrollPageIntoView`, I've changed the signature to take an parameter object instead. To maintain backwards compatibility, I've added fallback code enclosed in a `GENERIC` preprocessor tag.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=874482.
2016-08-07 16:20:18 +02:00
Yury Delendik
5aefce6ba6 Merge pull request #5579 from jazzy-em/master
Added multiple term search functionality (with default phrase search)
2016-05-27 14:23:26 -05:00
jazzy-em
0a347ec04d Added multiple term search functionality (with default phrase search) 2016-05-26 18:24:58 +05:00
Tim van der Meij
6a7012aaca Remove unused variables
These have been found using `gulp lint` in combination with the `unused:
true` parameter for JSHint. Unfortunately there are too many false
positives to enable this feature, but now that most globals have been
removed because of the conversion to UMD the results are much more
useful than before.
2016-05-11 16:11:13 +02:00
Yury Delendik
3e6e294fd4 Refactors PDFFindBar and FirefoxCom find events. 2016-04-28 07:11:40 -05:00
Yury Delendik
81fc46e666 Refactors FindController dependencies. 2016-04-24 08:25:55 -05:00
Yury Delendik
006e8fb59d Introduces UMD headers to the web/ folder. 2016-04-13 10:09:48 -05:00
Yury Delendik
1e3e14e6b2 Exposes all functional members via lib exports and use them in viewer. 2016-04-07 13:46:07 -05:00
Jonas Jenwald
e7d039dbce Ensure that PDFFindController_reset actually resets *all* state (issue 7034)
To reduce code duplication, the initialization code now uses the `reset` method.
Also, this patch moves `charactersToNormalize` out of `PDFFindController`, since it seemed better suited to be a "constant".
2016-02-26 18:35:17 +01:00
Yury Delendik
2edf2792dc Replaces literal {} created lookup tables with Object.create 2016-01-28 12:18:38 -06:00
Jonas Jenwald
6dfe53b976 [api-minor] Add a parameter to PDFPageProxy_getTextContent that enables replacing of all whitespace with standard spaces in the textLayer (issue 6612)
This patch goes a bit further than issue 6612 requires, and replaces all kinds of whitespace with standard spaces.

When testing this locally, it actually seemed to slightly improve two existing test-cases (`tracemonkey-text` and `taro-text`).

Fixes 6612.
2015-11-25 17:28:40 +01:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Yury Delendik
b8b922196c Moves match counter from find UI to the controller. 2015-10-30 11:20:29 -05:00
Andy Parisi
17fe0b1470 Added find match counter 2015-10-30 10:21:26 -05:00
Jonas Jenwald
9fc8e1ea25 Fix a regression, from PR 5356, that breaks all scrolling in PresentationMode
*This regressed in PR 5356.*

Rather than just backing out the offending code, this patch restores scrolling in PresentationMode by making the `overflow: hidden;` check optional and letting the callers that need it (e.g. `PDFFindController`) opt-in to use it.
2015-10-13 16:27:50 +02:00
Tim van der Meij
a033b4bf3d Merge pull request #5769 from dumyan/findcontroller-nbsp
nbsp normalization
2015-02-28 14:50:25 +01:00
Damjan Velickovski
29290f3277 added nbsp normalization 2015-02-28 02:57:08 +01:00
Collin Anderson
54e984c763 cleaned whitespace 2015-02-17 11:07:37 -05:00
Yury Delendik
2ac7ac4678 Removes lastScrollSource and isViewerInPresentationMode from TextLayerBuilderOptions 2014-12-20 11:14:13 -06:00
Yury Delendik
f68678086d Simple restructuring PageView into PDFPageView 2014-12-17 15:21:54 -06:00
Fil Zembowicz
dcb931dbe0 Use existing page count in nextMatch 2014-10-02 08:57:01 -04:00
Fil Zembowicz
4275481e08 Fix how matches are found in search
Instead of keeping track of where the search starts, just
keep track of the number of pages and make sure we don't
visit pages more than once.
2014-10-01 19:57:57 -04:00
Yury Delendik
374b94381d Moves scrollPageIntoView to the PDFViewer. 2014-09-30 07:13:46 -05:00
Yury Delendik
7642c39734 Moves pdfDocument.getPage/getTextContent requests out of PDFView 2014-09-21 12:47:26 -05:00
Yury Delendik
7af8748151 Moves viewer code into PDFViewer and some code from PageView. 2014-09-21 12:47:07 -05:00
Tim van der Meij
dbe22475e1 Converting PDFFindBar and PDFFindController to classes 2014-07-29 21:59:01 +02:00
Tim van der Meij
fbfb9458d6 Implement text normalization for page content and queries 2014-06-20 23:32:44 +02:00
Tim van der Meij
ec1b58a30a Fix code style issues in pdf_find_controller.js and build strings more efficiently 2014-06-20 21:14:29 +02:00
Brendan Dahl
5bd8a83c9b Build the text layer geometry on the worker. 2014-04-09 16:44:07 -07:00
Stratos Voukelatos
6a8c998ebd Fix error message typo
It should read 'PDFFindController cannot be initialized without a PDFFindBar instance'.
2014-03-27 21:43:58 +02:00
Jonas Jenwald
af4e977848 Fix coding style in web/pdf_find_controller.js 2014-03-09 11:51:16 +01:00
Yury Delendik
48f0d0a131 Refactors nextPageMatch (nits) 2014-01-28 11:11:02 -06:00
Yury Delendik
187c9007ef Merge pull request #4131 from karlden/findUnboundedRecursionBug960409
Fixes find functionality recursion (bugzilla FF bug 960409)
2014-01-28 06:44:42 -08:00
Yury Delendik
96fff4cc74 Refactors getTextContent return value 2014-01-17 13:26:00 -06:00
Karl Denninghoff
1be27e3c81 Fixes but 960409 and adresses review comments including removal of do-while construct 2014-01-16 13:58:29 -08:00
Yury Delendik
5bf3e44e30 Introduces LegacyPromise; polyfills DOM Promise 2014-01-03 18:17:05 -06:00
Jonas Jenwald
982a286f7b Begin searching from current page 2013-11-19 12:24:42 +01:00
Jonas
54dfe05e30 Prevent searching during load from breaking the find functionality 2013-09-05 00:25:19 +02:00
Jonas
baba41f702 Prevent searching from breaking when opening a new file in the web viewer 2013-08-23 11:08:03 +02:00
Vivin Paliath
83b6eaed16 pr #3356
squashing commits.
2013-06-18 09:05:55 -07:00