Commit Graph

168 Commits

Author SHA1 Message Date
Jonas Jenwald
3c7b7be100 Prevent circular references in the /Pages tree 2020-02-19 01:49:39 +01:00
Jonas Jenwald
7322a24ce4 Remove the FIREFOX build flag, since it's completely unused
After PR 9566, which removed all of the old Firefox extension code, the `FIREFOX` build flag is no longer used for anything.
It thus seems to me that it should be removed, for a couple of reasons:
 - It's simply dead code now, which only serves to add confusion when looking at the `PDFJSDev` calls.
 - It used to be that `MOZCENTRAL` and `FIREFOX` was *almost* always used together. However, ever since PR 9566 there's obviously been no effort put into keeping the `FIREFOX` build flags up to date.
 - In the event that a new, Webextension based, Firefox addon is created in the future you'd still need to audit all `MOZCENTRAL` (and possibly `CHROME`) build flags to see what'd make sense for the addon.
2020-01-21 00:06:15 +01:00
Jonas Jenwald
16a94412e4 Remove the unused id properties from page and thumbnail canvas/image DOM elements (issue 11499)
As described in the issue, having a DOM element with `id=page2` (or any other number) will automatically cause that element to become linkable through the URL hash. That's currently leading to some confusing and outright wrong behaviour, since it obviously only works for pages that have been loaded and rendered.

For PDF documents the only officially supported way to reference a particular page through the URL hash is using the `#page=2` format, which also works for all pages regardless if they're loaded or not.

As far as I can tell there's nothing in the PDF.js default viewer that actually depends on the page/thumbnail `id` at this point in time, hence why I believe that this removal ought to be safe.
Just as a pre-caution this patch adds an `aria-label` to the page canvas, similar to the thumbnail canvas/image, to at least keep this information in the DOM.
2020-01-11 14:11:47 +01:00
Jonas Jenwald
36881e3770 Ensure that all import and require statements, in the entire code-base, have a .js file extension
In order to eventually get rid of SystemJS and start using native `import`s instead, we'll need to provide "complete" file identifiers since otherwise there'll be MIME type errors when attempting to use `import`.
2020-01-04 13:01:43 +01:00
Jonas Jenwald
5d14e68bec Enable the ESLint prefer-const rule in the web/ directory
Please find additional details about the ESLint rule at https://eslint.org/docs/rules/prefer-const

Note that this patch is generated automatically, by using the ESLint `--fix` argument, and will thus require some additional clean-up (which is done separately).
2019-12-27 01:03:58 +01:00
Jonas Jenwald
a63f7ad486 Fix the linting errors, from the Prettier auto-formatting, that ESLint --fix couldn't handle
This patch makes the follow changes:
 - Remove no longer necessary inline `// eslint-disable-...` comments.
 - Fix `// eslint-disable-...` comments that Prettier moved down, thus causing new linting errors.
 - Concatenate strings which now fit on just one line.
 - Fix comments that are now too long.
 - Finally, and most importantly, adjust comments that Prettier moved down, since the new positions often is confusing or outright wrong.
2019-12-26 12:35:12 +01:00
Jonas Jenwald
de36b2aaba Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).

Prettier is being used for a couple of reasons:

 - To be consistent with `mozilla-central`, where Prettier is already in use across the tree.

 - To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.

Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.

*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.

(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-26 12:34:24 +01:00
Tim van der Meij
f4daafc077
Consistently use square brackets for optional parameters in JSDoc comments
Square brackets are recommended to indicate optional parameters. Using
them helps for automatically generating correct documentation.
2019-10-13 13:58:17 +02:00
Jonas Jenwald
366eebeb0f Refactor the onBeforeDraw/onAfterDraw functionality used in BaseViewer and PDFPageView
This functionality is very old, and pre-dates e.g. the introduction of the `EventBus` by a number of years. Rather than attaching two callback functions to every single `PDFPageView` instance, it's thus now possible to utilize the `EventBus` such that you only need a grand total of two listeners to achieve the same result.

For the `onAfterDraw` callback the replacement is particularly simple, given that a 'pagerendered' event is already being dispatched in the appropriate spot. An added benefit here is the ability to remove the event listener, since we only ever care about *one* (arbitrary) page being rendered for the `BaseViewer.onePageRendered` promise.

For the `onBeforeDraw` callback, a new 'pagerender' event was thus added to replace the callback.
2019-07-19 12:57:14 +02:00
Brendan Dahl
60b8b7a8d2 Add timestamp to the page rendered event.
This is needed to track rendering time in Firefox's talos performance
framework. See https://bugzilla.mozilla.org/show_bug.cgi?id=1565680
2019-07-12 14:08:23 -07:00
Jonas Jenwald
599dcf5a44 Fix {PDFPageView, PDFThumbnailView}.cancelRendering to avoid visual artifacts when called directly
Currently these methods are only used from the respective `reset` methods, and from `{BaseViewer, PDFThumbnailViewer}._cancelRendering` which only runs when the active document is closed.

This patch changes `{PDFPageView, PDFThumbnailView}.cancelRendering` to *only* cancel any pending rendering operations, and doesn't attempt to reset e.g. the `renderingState`, since that causes visual glitches (duplicated canvases in the viewer) when called directly.
Furthermore, unless you "know" what you're doing, the `{PDFPageView, PDFThumbnailView}.reset` methods are what *should* normally be used instead.
2019-02-16 11:11:07 +01:00
Jonas Jenwald
1ded729130 Simplify the updatetextlayermatches event handling in TextLayerBuilder
This implements the nice suggestion from https://github.com/mozilla/pdf.js/pull/10099#discussion_r219698000, which I at the time didn't think would work.
I'll probably have to plead temporary insanity here, since it *should* have been totally obvious to me how this could be implemented. By simply not registering the event until the `textLayer` is actually rendered, removing the event on `cancel` works just fine.

This patch also removes the `pagecancelled` event, given that it's no longer used anywhere in the code-base and that its implemention was flawed since it wasn't guaranteed to be called in *every* situation where rendering was actually cancelled.
2019-02-16 11:11:04 +01:00
Jonas Jenwald
5081063b9e Attempt to clean-up/restore pending rendering operations when errors occurs while a RenderTask runs (PR 10202 follow-up)
This piggybacks of the existing `cancel` functionality, to ensure that any pending operations are closed *and* that any temporary canvases are actually being removed.

Also simplifies `finishPaintTask` in `PDFPageView.draw` slightly, by converting it to an async function.
2019-01-26 16:02:51 +01:00
Jonas Jenwald
f0719ed565 [api-minor] Change the getViewport method, on PDFPageProxy, to take a parameter object rather than a bunch of (randomly) ordered parameters
If, as PR 10368 suggests, more parameters should be added to `getViewport` I think that it would be a mistake to not change the signature *first* to avoid needlessly unwieldy call-sites.

To not break any existing code and third-party use-cases, this is obviously implemented with a deprecation warning *and* with a working fallback[1] for the old method signature.

---
[1] This is limited to `GENERIC` builds, which should be sufficient.
2018-12-21 11:55:20 +01:00
Jonas Jenwald
e2e9657ed0 Remove the attachDOMEventsToEventBus functionality, since EventBus instances are able to re-dispatch events to the DOM (PR 10019, bug 1492849 follow-up)
This also removes the old 'pagechange'/'scalechange'/'documentload' events.
2018-10-31 23:32:39 +01:00
Jonas Jenwald
1eaa3b8a08 Dispatch a 'pagecancelled' event, in PDFPageView.cancelRendering, when rendering is cancelled
Also, the patch updates `TextLayerBuilder` to use the new 'pagecancelled' event for (future) event removal purposes.
2018-09-23 22:34:39 +02:00
Jonas Jenwald
77efed6626 Replace the PDFJS.disableWebGL option with a enableWebGL option passed, via BaseViewer/PDFPageView, to PDFPageProxy.render
Please note that the, pre-existing, viewer preference is already named `enableWebGL`; fixes 4919.
2018-02-13 16:56:56 +01:00
Jonas Jenwald
a1cfa5f4d7 Replace the disableTextLayer and enhanceTextSelection options/preferences with a single textLayerMode option/preference
Rather than having two different (but connected) options for the textLayer, I think that it makes sense to try and unify this. For example: currently if `disableTextLayer === true`, then the value of `enhanceTextSelection` is simply ignored.

Since PDF.js version `2.0` already won't be backwards compatible in lots of ways, I don't think that we need to worry about migrating existing preferences here.
2018-02-13 16:56:54 +01:00
Jonas Jenwald
c45c394364 Move the imageResourcesPath option to a BaseViewer/PDFPageView/AnnotationLayerBuilder option
This removes the `PDFJS.imageResourcesPath` dependency from the viewer components and the test-suite, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 14:28:38 +01:00
Jonas Jenwald
fdf99c6af5 Move the maxCanvasPixels option to a BaseViewer/PDFPageView option
This removes the `PDFJS.maxCanvasPixels` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 13:42:03 +01:00
Jonas Jenwald
f4280368f7 Move the useOnlyCssZoom option to a BaseViewer/PDFPageView option
This removes the `PDFJS.useOnlyCssZoom` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 13:42:03 +01:00
Tim van der Meij
d36c46b2c9
Remove the CustomStyle class
It is only used in a few places to handle prefixing style properties if
necessary. However, we used it only for `transform`, `transformOrigin`
and `borderRadius`, which according to Can I Use are supported natively
(unprefixed) in the browsers that PDF.js 2.0 supports. Therefore, we can
remove this class, which should help performance too since this avoids
extra function calls in parts of the code that are called often.
2017-12-31 14:22:11 +01:00
Yury Delendik
b4e25fb2e8 Merge remote-tracking branch 'mozilla/version-2.0' into v2 2017-10-27 14:01:45 -05:00
Jonas Jenwald
ee5862bd81 Prevent the annotationLayer from, in some cases, becoming duplicated on the first page when the document loads
I don't know if this is a regression, but I noticed earlier today that depending on the initial scale *and* sidebar state, the `annotationLayer` of the first rendered page may end up duplicated; please see screen-shot below.

[screen-shot]

I can reproduce this reliable with e.g. https://arxiv.org/pdf/1112.0542v1.pdf#zoom=page-width&pagemode=bookmarks.
When the document loads, rendering of the first page begins immediately. When the sidebar is then opened, that forces re-rendering which thus aborts rendering of the first page.
Note that calling `PDFPageView.draw()` will always, provided an `AnnotationLayerFactory` instance exists, call `AnnotationLayerBuilder.render()`. Hence the events described above will result in *two* such calls, where the actual annotation rendering/updating happens asynchronously.

For reasons that I don't (at all) understand, when multiple `pdfPage.getAnnotations()` promises are handled back-to-back (in `AnnotationLayerBuilder.render()`), the `this.div` property seems to not update in time for the subsequent calls.
This thus, at least in Firefox, result in double rendering of all annotations on the first page.

Obviously it'd be good to find out why it breaks, since it *really* shouldn't, but this patch at least provides a (hopefully) acceptable work-around by ignoring `getAnnotations()` calls for `AnnotationLayerBuilder` instances that we're destroying (in `PDFPageView.reset()`).
2017-10-07 11:34:53 +02:00
Jonas Jenwald
43134d5b33 Only handle RenderingCancelledException in the viewer code, when rendering is cancelled 2017-10-04 18:13:46 +02:00
Yury Delendik
47c28643d6 Revert PDFPageView.pdfPage reset. 2017-08-31 16:49:01 -05:00
Yury Delendik
d0e93721ae More robust getPage() error handling. 2017-08-04 17:03:33 -05:00
Yury Delendik
e2ca894fec Merge pull request #8488 from mukulmishra18/streams-getTextContent
Streams get text content
2017-06-23 12:52:13 -05:00
Jonas Jenwald
426e26c63b Don't use a hidden canvas when constructing the zoomLayer in PDFPageView.update
*This is an existing issue that I noticed while testing PR 8552.*

When zooming or rotation occurs, we'll try to use the current canvas as a (CSS transformed) preview until the page has been completely re-drawn.
If you manage to change the scale (or rotation) *very* quickly, it's possible that `PDFPageView.update` can be called *before* a previous `render` operation has progressed far enough to remove the `hidden` property from the canvas.

The result is thus that a page may be *entirely* black during zooming or rotation, which doesn't look very good. This effect can be a bit difficult to spot, but it does manifest even in the default viewer.
2017-06-22 10:05:41 +02:00
Mukul Mishra
0c13d0ff46 Adds Streams API in getTextContent to stream data.
This patch adds Streams API support in getTextContent
so that we can stream data in chunks instead of fetching
whole data from worker thread to main thread. This patch
supports Streams API without changing the core functionality
of getTextContent.

Enqueue textContent directly at getTextContent in partialEvaluator.

Adds desiredSize and ready property in streamSink.
2017-06-17 20:03:27 +05:30
Jonas Jenwald
70d6550002 Remove PDFPageView.updatePosition since it's not actually necessary
This method is currently called from `PDFViewer._scrollUpdate` on *every* scroll event in the viewer.

However, I cannot see why this code is now necessary (assuming that it once was), since text-selection and searching still works *exactly* the same way with this patch as with the current `master`.

When `PDFPageView.updatePosition` is called, the page can be in either of these states:
 1. The page hasn't been rendered, in which case the `textLayer` property doesn't exist yet.
 2. The page is currently rendering, meaning that the `textLayer` property exists. Given that the `textContent` won't be fetched until the page has been successfully rendered, `TextLayerBuilder.render` will return immediately and effectively be a no-op (since there's nothing to render yet).
 3. The has been been rendered, and the `textLayer` is currently rendering.
 4. The page, and its `textLayer`, has been completely rendered. In this case, `TextLayerBuilder.render` will return immediately and effectively be a no-op.

Here, only the *third* case seem to require any further analysis:
When scrolling occurs while the `textLayer` is rendering, `TextLayerBuilder.render` will via a helper method call `TextLayerRenderTask.cancel` (in src/display/text_layer.js) to stop processing.
However, due to the run-to-completion nature of JavaScript, once `TextLayerRenderTask._render` has been invoked `appendText` will always run.[1]

So even though we cancel rendering of pending `textLayer`s during scrolling, via the repeated `TextLayerBuilder.render` calls from within the `PDFPageView.updatePosition` method, that does *not* prevent us from running the code inside of `TextLayerRenderTask._render` over and over for the *same* page; which all seems *very* inefficient to me.[2]

All this will thus have the effect of delaying the *actual* rendering of a `textLayer` ever so slightly while scrolling in the viewer. However, it does so at the expense of potentially hundreds of unnecessary `appendText` calls.[3]

Hence it seems to me that it's less resource intensive overall to simply let rendering of the `textLayer` complete, once it has started. Obviously, we still abort all rendering of a page, and its `textLayer`, when it's being destroyed (e.g. by being evicted from the page cache).

In case that there's any worry that the patch could affect e.g. highlighting of search results, please note that the existing code in `TextLayerBuilder.render` already calls `updateMatches` when the `TextLayerTask` resolves successfully.

*I'm sorry that this became quite long, but to try and summarize:*
`PDFPageView.updatePosition` doesn't actually do anything in *most* cases. In the one case where it matters, it seems that it's actually doing more harm than good; which is why I'm proposing that we just remove it.

---
[1] Although we may be able to skip the `render` call, provided that it happens *after* a `timeout` (as is the case in the default viewer).
[2] With current work being done to support streaming of `TextContent`, we'd also need to add just as many duplicate API calls to `PDFPageView.updatePosition`.
[3] The number of duplicate `appendText` calls is directly proportional not only to the scroll speed, but also to the number of pages in the document.
2017-06-15 13:25:37 +02:00
Yury Delendik
5438ce9b98 Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
Yury Delendik
1e6f49b129 Merge pull request #8462 from yurydelendik/rm=umd
Removes last UMDs from the modules.
2017-05-31 07:27:19 -05:00
Yury Delendik
66c8893815 Removes last UMDs from the modules. 2017-05-31 07:14:17 -05:00
Tim van der Meij
6dfdff2f03
Convert the page view to ES6 syntax 2017-05-31 00:41:39 +02:00
Jonas Jenwald
a9e5bc91fb Replace unnecessary var self = this statements with arrow functions in web/pdf_page_view.js and web/pdf_thumbnail_view.js
Also replaces `var` with `let` in code that's touched in the patch. Please note that this should be completely safe, for two separate reasons, since trying to access let in a scope where it's not defined is first of all a runtime error and second of all an ESLint error (thanks to the `no-undef` rule).
2017-05-16 13:48:27 +02:00
Jonas Jenwald
2a0207ccaf Enable the object-shorthand ESLint rule in web
Please see http://eslint.org/docs/rules/object-shorthand.

For the most part, these changes are of the search-and-replace kind, and the previously enabled `no-undef` rule should complement the tests in helping ensure that no stupid errors crept into to the patch.
2017-04-29 20:29:04 +02:00
Jonas Jenwald
79e0745a12 Import getGlobalEventBus correctly from web/dom_events.js in various /web files, to un-break e.g. the viewer components (PR 8203 follow-up)
In PR 8203, I somehow managed to mess up the import of `getGlobalEventBus` in *all* files where it's present; my sincere apologies for this!
2017-04-17 00:54:29 +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
b2c3f8f081 Convert a number of import * as pdfjsLib from 'pdfjs-web/pdfjs'; cases to only specify the necessary imports
Rather than always importing everything from the `web/pdfjs.js`, similar to all other imports we can just choose what we actually need.
2017-04-09 11:55:48 +02: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
Yury Delendik
31f8875614 Merge pull request #8157 from Snuffleupagus/api-RenderTask-cancel-Error
[api-minor] Reject the `RenderTask` with an actual `Error`, instead of just a `string`, when rendering is cancelled
2017-04-04 09:38:47 -05:00
Jonas Jenwald
d98a6319ec Refactor removing of the zoomLayer into a helper method, and use that in PDFPageView.reset to ensure that the entire zoomLayer is actually removed (issue 8209) 2017-03-29 16:41:38 +02:00
Jonas Jenwald
d37d271afa [api-minor] Reject the RenderTask with an actual Error, instead of just a string, when rendering is cancelled
This patch gets rid of the only case in the code-base where we're throwing a plain `string`, rather than an `Error`, which besides better/more consistent error handling also allows us to enable the [`no-throw-literal`](http://eslint.org/docs/rules/no-throw-literal) ESLint rule.
2017-03-13 18:58:21 +01:00
Jonas Jenwald
52e0f51917 Enable the no-unused-vars ESLint rule
Please see http://eslint.org/docs/rules/no-unused-vars; note that this patch purposely uses the same rule options as in `mozilla-central`, such that it fixes part of issue 7957.

It wasn't, in my opinion, entirely straightforward to enable this rule compared to the already existing rules. In many cases a `var descriptiveName = ...` format was used (more or less) to document the code, and I choose to place the old variable name in a trailing comment to not lose that information.

I welcome feedback on these changes, since it wasn't always entirely easy to know what changes made the most sense in every situation.
2017-01-29 23:23:17 +01:00
Tim van der Meij
2170eda9df Merge pull request #7971 from davehouse/remove_viewer_page_div_id
remove viewer page div id
2017-01-23 22:27:26 +01:00
Dave House
52360694b0
Remove ids from viewer page and thumbnail divs
The id, and parsing it for the page number, is replaced by the
data-page-number attribute (added here for thumbnails).
2017-01-23 07:46:39 -07:00
Jonas Jenwald
9eb9065c79 Ensure that we use the *correct* paintedViewport in PDFPageView.cssTransform, to avoid visual glitches on quick rotations (PR 7738 follow-up)
*This fixes a regression from commit c9a0955c9c, i.e. PR 7738.*

Currently if you quickly rotate a document at least *twice*,[1] such that rendering of a page hasn't finished for the first rotation before the last rotation is triggered, the `cssTransform` method can fail to update the page correctly leading to it looking temporarily distorted.

The reason why things break is that previously we stored the `viewport` on the canvas DOM element, meaning that when it was accessed in `cssTransform` is was guaranteed to point to the `viewport` of the `zoomLayer` canvas.
Generally you want to avoid storing data on DOM elements this way, and during the `PDFPageView` refactoring needed to support SVG rendering, the previous `viewport` was instead stored directly on `PDFPageView`.
However, the problem is first of all that the `paintedViewport` only stores the *last* `viewport` computed, and second of all that there're no guarantees that it actually applies to the current `zoomLayer` canvas.
If a document is rotated slowly enough that rendering finishes *before* the next rotation then this problem doesn't exist, but for sufficiently quick rotations rendering will be cancelled at least once and the `paintedViewport` could thus be bogus.

The solution for the above problems is to ensure that we track the correct `viewport` for each DOM element (canvas or svg),[2] which seemed easist to do with a `WeakMap`.[3]

---
[1] I'm able to reproduce this using the `tracemonkey` file, but please note that for pages with few operations, i.e. that render very quickly, the effect may be hard to spot.

[2] One other possible solution that I briefly considered, was to wait until rendering finished before storing the current `viewport`. However, that would have caused issues with rotating a page before the *first* rendering operation had finished.

[3] This regression took me way longer to both figure out, and fix, than I'd like to admit :-)
2017-01-23 12:13:53 +01:00
Yury Delendik
77b7b84d1e Removes rest of 'no-else-return' comments. 2017-01-09 19:13:36 -06: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
73e0daed6c Let finishPaintTask in pdf_page_view.js return a promise instead, to avoid having to throw in the paintTask.promise rejection handler, and don't reject the PDFPageView_draw promise when rendering is cancelled
As mentioned on IRC yesterday, we currently throw even when rendering is `cancelled`, which is annoying when the devtools are active. Furthermore, since `cancelled` isn't really an error, rejecting the `PDFPageView_draw` promise seems somewhat strange in that case.
2016-12-17 22:29:48 +01:00
Jonas Jenwald
9872660a95 Return a mock object in paintOnSvg when SVG rendering is not supported, to prevent TypeErrors in the addons
Currently if you try to enable SVG rendering in the addons, a `TypeError` is thrown by the browser since we have code that depends on what `paintOnCanvas`/`paintOnSvg` (should) return.
2016-11-19 13:32:17 +01:00
Jonas Jenwald
7272bb4894 Prevent "unreachable code after return statement" warnings from PDFPageView_paintOnSvg in the addons
Follow-up to PR 7738.
2016-11-18 21:18:27 +01:00
Yury Delendik
f7d6f3a739 Adds SVG rendering capabilities to the PDFViewer. 2016-11-18 13:03:49 -06:00
Yury Delendik
c9a0955c9c Refactors PDFPageView_draw. 2016-11-18 12:57:11 -06:00
Jonas Jenwald
efb9619e53 Add PageLabels to PDFPageView and PDFThumbnailView 2016-10-26 13:30:37 +02:00
Yury Delendik
0576c9c6c6 Replaces all preprocessor directives with PDFJSDev calls. 2016-10-14 10:57:53 -05:00
Jonas Jenwald
3904be8889 Ensure that we cancel any pending textLayer rendering operations when the viewer is closed (issue 7274) 2016-10-11 22:01:22 +02:00
Jonas Jenwald
a824c6c4f6 Ensure that any pending rendering operations in PDFViewer/PDFThumbnailViewer are cancelled when the viewer is closed 2016-10-11 22:01:22 +02:00
Yury Delendik
24a7a58da7 Moves mozPrintCallback specific code to firefox_printservice.js 2016-10-08 07:33:07 -05:00
Yury Delendik
29947b5a57 Printing canvases at PDF document size. 2016-10-06 07:51:45 -05:00
Tim van der Meij
2da2c45889 Interactive forms: remove global PDFJS usage 2016-09-19 00:12:42 +02:00
Tim van der Meij
dbea302a6e Text widget annotations: do not render on canvas as well
If interactive forms are enabled, then the display layer takes care of
rendering the form elements. There is no need to draw them on the canvas
as well. This also leads to issues when values are prefilled, because
the text fields are transparent, so the contents that have been rendered
onto the canvas will be visible too.

We address this issue by passing the `renderInteractiveForms` parameter
to the render task and handling it when the page is rendered (i.e., when
the canvas is rendered).
2016-09-17 15:24:48 +02:00
Tim van der Meij
7c961b6b7a Minor code style improvements after #7539 2016-09-01 18:07:12 +02:00
Jeremy Press
6faa84abdb Continuing fairexpand #6663
1. Expanding divs to improve text selection. (Yury)
2. Adding enhanceTextSelection as an option.
3. Moving feature functionality from text_layer_builder.js to text_layer.js.
4. Added expandTextDivs method to only load expanded divs on first click, and only show on subsequent clicks
2016-08-31 09:54:52 -07:00
Jonas Jenwald
f297e4d17c [api-minor] Add a parameter to PDFPageProxy_getTextContent that controls whether PartialEvaluator_getTextContent will attempt to combine same line text items
From the discussion in issue 7445, it seems that there may be cases where an API consumer would want to get the text content as is, without combined text items.
2016-07-19 13:38:57 +02:00
klemens
6f03f62327 trivial spelling fixes 2016-07-17 14:33:41 +02: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
Jonas Jenwald
b13b78388b Prevent intermittent "Node was not found" errors when removing the zoomLayer in PDFPageView_draw
I've seen the above error occasionally when the scale is updated many times in quick succession, but I've not been able to pinpoint exactly why it happens.
Since the error isn't caught, this means that the `pageViewDrawCallback` function doesn't run to completion.

Unfortunately, given the very intermittent nature of the issue, I haven't got any good STR for reliably reproducing this issue. However, I hope that this patch can be accepted anyway, since it's simple and should help prevent unnecessary errors.
2016-05-08 16:03:17 +02:00
Yury Delendik
7fd3db9977 Adds EventBus. 2016-04-28 06:57:24 -05:00
Yury Delendik
b6c74f2056 Moves all document.getElementById lookups into viewer.js 2016-04-21 11:39:11 -05:00
Yury Delendik
50fe8e7c75 Removes PDFView global and pagerender event support. 2016-04-13 10:11:43 -05:00
Yury Delendik
4165cedc9f Replace pdfjsLib with module that represents pdf.js. 2016-04-13 10:11:34 -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
Tobias Schneider
708895ffba Let print canvas height scale proportionally 2016-03-21 14:21:07 -07:00
Tobias Schneider
aeabd0db20 Fix insertion of blank pages during printing due to non-matching page sizes 2016-03-21 14:21:07 -07:00
Tim van der Meij
6a33dfd13a Implement support for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Yury Delendik
85e95d34ed Use RequireJS in the viewer, examples and tests. 2015-12-29 09:20:52 -06:00
Jonas Jenwald
3079dd937f Remove a superfluous "s" in AnnotationsLayerBuilder from files in web/
This patch makes the naming consistent with the `TextLayerBuilder`, and also the new `AnnotationLayer`, and should thus help reduce possible confusion when working with the code.
Please note that the files were renamed using `git mv`, in order to preserve blame.
2015-12-18 19:55:54 +01:00
Tim van der Meij
bce3214105 Move link creation logic to src/display/annotation_layer.js
Additionally simplify the div creation logic (it needs to happen only
once, so it should not be in the for-loop) and remove/rename variables
for shorter code.
2015-12-08 23:56:17 +01: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
Jonas Jenwald
b05652ca97 [api-minor] Let getAnnotations fetch all annotations by default, unless an intent is specified
Currently `getAnnotations` will *only* fetch annotations that are either `viewable` or `printable`. This is "hidden" inside the `core.js` file, meaning that API consumers might be confused as to why they are not recieving *all* the annotations present for a page.

I thus think that the API should, by default, return *all* available annotations unless specifically told otherwise. In e.g. the default viewer, we obviously only want to display annotations that are `viewable`, hence this patch adds an `intent` parameter to `getAnnotations` that makes it possible to decide if only `viewable` or `printable` annotations should be fetched.
2015-11-22 15:51:37 +01:00
Jonas Jenwald
93f4f7a649 Use DEFAULT_SCALE instead of 1.0 as the default value if the scale option isn't specified when initializing PDFPageView
A small piece of cleanup, in order to avoid unnecessarily hardcoding a default value.
2015-11-20 13:30:04 +01:00
Yury Delendik
2f34fd46cb Move CustomStyle. 2015-11-19 10:47:17 -06:00
Jonas Jenwald
f341d81ae8 Ensure that the hidden attribute is always removed from the canvas when rendering is complete (issue 6661)
Fixes 6661.
2015-11-19 12:31:49 +01:00
Yury Delendik
194994a289 Merge pull request #6551 from yurydelendik/subaa
[api-minor] Enables subpixel anti-aliasing for most of the content.
2015-11-17 19:45:32 -06:00
Yury Delendik
1d8800370a Allow subpixel anti-aliasing for most of the content. 2015-11-16 10:50:02 -06: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
Jonas Jenwald
2646f27434 Dispatch the pagerendered event when zooming is only done with CSS (issue 6463)
In my opinion, this event shouldn't be dispatched in `PDFPageView.cssTransform`, since that would cause *two* events to be fired when "normal" zooming is used (once in `PDFPageView.cssTransform`, and once in `PDFPageView.draw`).

Fixes 6463.
2015-11-12 16:46:50 +01:00
Jonas Jenwald
dbc611ac9d Ensure that the textLayer has the same dimensions as the canvasWrapper (issue 6596)
This is a quick fix to get `scrollIntoView` working again for search results, but we really ought to re-write that function since it seems way too brittle.

Fixes 6596.
2015-11-06 12:43:22 +01:00
Yury Delendik
7cb32759ed Better CSS scaling for deviceRixelRatio != 1. 2015-10-28 17:27:42 -05:00
Yury Delendik
5135aa9bec Adds deprecation warning for the API calls. 2015-10-23 09:06:32 -05:00
Yury Delendik
59c13b32aa Adds destroy method to the document loading task.
Also renames PDFPageProxy.destroy method to cleanup.
2015-10-23 08:57:14 -05:00
Tim van der Meij
e28ad20d15 Merge pull request #6475 from Snuffleupagus/PDFPageView-annotationLayer-div
Tweak `PDFPageView` to reflect that `this.annotationLayer` is an `AnnotationsLayerBuilder` instance, instead of a DOM element (PR 5552 follow-up)
2015-09-29 23:38:04 +02:00
Jonas Jenwald
5e7ce9d62d Fix incorrect indentation, and remove else after return, in PDFPageView_update 2015-09-26 15:41:02 +02:00
Jonas Jenwald
1ae9ba1d64 Don't clear the canvas until re-rendering is finished when the scale or rotation is changed (issue 6467)
*This regressed in PR 4920.*

The main motivation for PR 4920 was to quickly get rid of old canvases when pages are evicted from the `PDFPageViewBuffer` cache. However it inadvertently broke the use-case where the `canvas` is used as a preview, on scale or rotation changes, until the re-rendering is finished.

Fixes 6467.
2015-09-26 15:40:59 +02:00
Jonas Jenwald
c7fd7f898f Tweak PDFPageView to reflect that this.annotationLayer is an AnnotationsLayerBuilder instance, instead of a DOM element (PR 5552 follow-up)
In PR 5552, specifically commit 9f384bbb41, the meaning of `this.annotationLayer` changed in `PDFPageView`. Previously it referred directly to a DOM element, but now it's instead an instance of `AnnotationsLayerBuilder`.
This patch tweaks things so that we won't try to hide a non-existent `annotationLayer` div in `PDFPageView_reset`, and also so that we don't attempt to insert empty (`null`) DOM elements in `PDFPageView_draw`.
2015-09-24 12:24:47 +02:00
Tim van der Meij
d7aa95d6b1 Merge pull request #5857 from Rob--W/print-page-size
Set page size via @page + size
2015-05-14 16:52:40 +02:00