Commit Graph

1054 Commits

Author SHA1 Message Date
Jonas Jenwald
6b2810f1f0 Pass in a PDFViewer instance to PDFPresentationMode and use it to eliminate all references to PDFViewerApplication
This patch is the the first step towards to addressing issue 6158, which will be done by refactoring the code for setting/getting the current scale in `viewer.js`.
2015-07-06 09:49:51 +02:00
Rob Wu
2932f7c676 Zoom relative to cursor position via mouse wheel
Before this patch, zooming in/out via the scroll wheel caused the page
to be zoomed relative to the upper-left corner of the page, i.e. the
upper-left corner of the page stays at a fixed position.

After this patch, the page is zoomed relative to the cursor position,
i.e. after zooming in/out, the part under the cursor 'has not moved'.

This only applies when the page does not fit in the viewport, because
pages smaller than the viewpoer are always centered.
2015-07-02 23:20:37 +02:00
Yury Delendik
f3c3b1fc2d Removes B2G preprocessing directives. 2015-06-30 16:53:32 -05:00
Yury Delendik
1b847df2f3 Using pdfjs-dist as a library for b2g viewer. 2015-06-30 16:53:32 -05:00
Jonas Jenwald
ffeba9c630 Move the page switching code into set currentPageNumber in PDFViewer instead of placing it in the pagechange event handler
The reason that this code can be moved is that the `if (this.loading && page === 1)` check, in the `pagechange` event handler in viewer.js, is never satisfied since `this.loading` is not defined in that scope.
This *could* be considered a regression from PR 5295, since prior to that `this.loading` was using the `PDFViewerApplication` scope (or `PDFView` as it were).
However, I don't think that we need to fix that since we've been shipping this code in no less than *three* Firefox releases (uplifted in https://bugzilla.mozilla.org/show_bug.cgi?id=1084158), without breaking the world.

An explanation of why the `pagechange` code works, despite `this.loading === undefined`, is that `set currentPageNumber` (in `PDFViewer`) returns early whenever `this.pdfDocument` isn't set. This check is, for all intents and purposes, functionally equivalent to checking `PDFViewerApplication.loading`.
Hence we can move the page switching code into `PDFViewer`, and also remove `PDFViewerApplication.loading` since it's not used any more.
(The `this.loading` property was added in PR 686, which was before the current viewer even existed.)

*Note:* The changes in this patch should also be beneficial to the viewer `components`, since requiring every implementer to provide their own `pagechange` event handler just to get `PDFViewer.currentPageNumber` to actually work seems like an unnecessary complication.
2015-06-24 14:07:07 +02:00
Jonas Jenwald
633d51fc22 [Firefox] Handle the user modifying the "mousewheel.with_meta.action" and "mousewheel.with_control.action" prefs (bug 1170063)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1170063.

The bug only mentions the <kbd>Meta</kbd> key, but given that a similar situation can occur for <kbd>Ctrl</kbd>, it seemed reasonable to also handle that case in the same patch.

The only possible caveat with the patch is that because of the use of `shadow`, things won't work perfectly if either of the prefs are changed *while* the viewer is active. In this case a reload is required in order for it to work correctly, but given that the issue this patch fixes should be quite rare anyway, that seems OK.
2015-06-19 14:57:32 +02:00
Jonas Jenwald
7cb62089ad Fix a typo causing a TypeError when attempting to call pdfHistory_clearHistoryState (issue 6121)
Fixes 6121.

Note: This "regressed" in PR 5823.
2015-06-16 13:16:12 +02:00
Rob Wu
f4ba0e342e Check availability of canvas & PDF before printing 2015-06-05 23:55:08 +02:00
Rob Wu
adb2f8ae21 [CRX] Add Referer request header if needed
This patch adds the Referer request header to PDF requests if
the original PDF request included the Referer header.
2015-06-05 23:24:40 +02:00
Jonas Jenwald
27713f9454 Ensure that PDFHistory does not incorrectly replace the initial document hash (issue 6079)
This is fallout from PR 5971; fixes 6079.
2015-06-04 13:58:45 +02:00
Yury Delendik
5cff06e52a Refactors PDFHistory.
# Conflicts:
#	extensions/b2g/viewer.js
#	web/pdf_history.js
#	web/pdf_viewer.component.js
#	web/viewer.js
2015-05-16 11:20:36 -05:00
Yury Delendik
0ef6212b64 Refactors PDFLinkService.
# Conflicts:
#	web/viewer.js
2015-05-16 11:20:36 -05:00
Jonas Jenwald
9deae0eb6d Merge pull request #6014 from NotablePDF/fix_scroll_zoom
Fix scroll to zoom jump between 25% and 1000%
2015-05-15 01:18:47 +02:00
Xiliang Chen
ed540a8d00 Fix scroll to zoom jump between 25% and 1000% 2015-05-15 10:16:52 +12: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
Jonas Jenwald
ba0eb7fdc6 Add the |location| to the |updateviewarea| UI event
*This patch addresses an issue I stumbled upon while working on rewriting the history implementation.*

Currently the `updateviewarea` UI event doesn't include the `location`, and in the event handler in viewer.js we instead reach into `PDFViewer` to retrieve it. Not only does this seem conceptually wrong, it also makes the `updateviewarea` event less useful in general since it's currently only possible to access the `location` if you have a reference to the `PDFViewer`.

To me, this simply appears to be an oversight in the implementation, hence this patch which adds `location` to the `updateviewarea` event. It also changes `location` to be a "private" property of `PDFViewer`.
2015-05-08 12:15:50 +02:00
David Flanagan
ae740768b0 Bug 1152841 - make pdf.js viewer app handle open requests from file viewers 2015-05-05 01:04:45 +02:00
Jonas Jenwald
66b12974c9 Prevent Firefox from warning about |unreachable code after return statement|
*This is a follow-up to PR 5966.*

Now that https://bugzilla.mozilla.org/show_bug.cgi?id=1151931 has landed, we're unfortunately in a situation where Firefox warns about `unreachable code after return statement` multiple times when using the PDF.js code in `node make server` mode.

I'm really sorry about the churn in this code!
However I don't think it's a good idea to let Firefox continue to printing these warnings in the console, since it increases the risk of missing actual errors.
2015-04-29 19:26:05 +02:00
Tim van der Meij
080ab204d6 Merge pull request #5953 from Snuffleupagus/issue-3498
Remove no longer needed hacks that enable spacebar scrolling in Firefox (issue 3498)
2015-04-27 19:10:49 +02:00
Tim van der Meij
c91f736db7 Merge pull request #5966 from Snuffleupagus/lint-viewer-preprocesser-code
Enable linting of Firefox specific code in viewer.js
2015-04-27 18:59:55 +02:00
Tim van der Meij
6abf3d6ba3 Simplify document properties field logic
This patch:
- Simplifies the way fields are passed to the document properties overlay
- Simplifies the way fields are filled internally in the document properties overlay
- Avoids passing a document properties reference to the secondary toolbar
2015-04-27 15:25:40 +02:00
Jonas Jenwald
91ce16bc1d Enable linting of Firefox specific code in viewer.js
- This patch uncomments a large portion of the Firefox specific code in viewer.js, by using a preprocessor "trick", to enable linting. Doing this actually uncovered some issues, e.g. variables defined multiple times.

 - This patch also fixes a spelling error, `adobe pdfwritter` -> `abobe pdfwriter`, in the `KNOWN_GENERATORS` list used when reporting telemetry data in Firefox.

*Please note:* there's still some Firefox specific code that is commented out, but it's usually just one (or two) lines of code. Hence the risk that errors creep in should be much lower, compared to entire code-blocks.
2015-04-26 19:52:09 +02:00
Tim van der Meij
1a5de56675 Group public/private methods and add comments
This patch:
- Puts public methods at the top of the file
- Puts private methods below the public methods and marks them with an underscore
- Adds JSDoc comments to the class
- Adds setDocumentAndUrl to avoid having to handle that in `viewer.js`
2015-04-26 15:50:28 +02:00
Tim van der Meij
7cf440c560 Refactor PDFDocumentProperties to be more class-like 2015-04-24 20:47:38 +02:00
Tim van der Meij
ca8f842d87 Rename DocumentProperties to PDFDocumentProperties 2015-04-24 20:35:11 +02:00
Jonas Jenwald
10f134bcc2 Remove no longer needed hacks that enable spacebar scrolling in Firefox (issue 3498)
Now that [bug 915962](https://bugzilla.mozilla.org/show_bug.cgi?id=915962) has landed, we no longer need any hacks to enable <kbd>spacebar</kbd> scrolling in Firefox.

Fixes 3498.
2015-04-21 22:26:50 +02:00
Jonas Jenwald
4211df63eb Refactor PDFPresentationMode to be more class-like 2015-04-21 16:28:50 +02:00
Jonas Jenwald
d5089f42fa Initial refactoring of the PDFPresentationMode code
Noteworthy changes:

 - Adds JSDoc comments to PDFPresentationMode.

 - Removes a couple of, no longer necessary, helper functions.
2015-04-21 16:28:49 +02:00
Jonas Jenwald
f15d5c8cfe Rename the presentation_mode.js file and adjust the function names
Also moves the |fullscreenchange| event listeners into PDFPresentationMode.
2015-04-21 16:28:48 +02:00
Jonas Jenwald
e7fd5b4d4d Refactor the options passed to |PresentationMode.initialize| and clean-up some code in viewer.js and presentation_mode.js
This patch:
 - Passes in a reference to the current PDFThumbnailViewer, which is used to ensure that the current thumbnail becomes visible when exiting PresentationMode.

 - Changes the way that the event listeners for the contextmenu items are defined, to avoid passing in a reference to the SecondaryToolbar.

 - Ensures that |supportsFullscreen| always returns a boolean.
   Currently `supportsFullscreen` will, when the browser supports the fullscreen API, return e.g. `function mozRequestFullScreen()` instead of `true`.

 - Simplifies the |click| handler code when PresentationMode is active.
   This code has been obsolete ever since PR 2919 landed.

 - Removes hack used to workaround a bug in WebKit browsers, which caused |mousemove| events to be fired when the cursor changed.
   This was fixed close to a year ago, see http://code.google.com/p/chromium/issues/detail?id=103041.
2015-04-21 16:27:41 +02:00
Jonas Jenwald
95b2ec124b Move the PresentationMode-specific scrollWheel code from PDFViewerApplication 2015-04-21 16:08:37 +02:00
Jonas Jenwald
2dc1af8028 Break dependencies between PresentationMode and other code, and add PresentationMode related utility methods to PDFViewer
This patch:
 - Adds a couple of utility methods to `PDFViewer` to enable checking `presentationModeState` without cumbersome comparisons.

 - Disentangles `PresentationMode` from `PDFHistory` and `HandTool`, by adding event listeners for `presentationmodechanged` to both of them.

 - Adds a utility function to `PDFViewerApplication` for requesting PresentationMode.

 - Prevents initialization of `PresentationMode` if the browser does not support the fullscreen API.
2015-04-21 16:02:32 +02:00
arai
5c4e3c31b8 Bug 1156287 - Do not extract unreachable code after return 2015-04-21 00:22:45 +09:00
Taylor Brown
34d3b96b52 prevent viewer from zooming on cmd+mousewheel 2015-04-10 15:08:32 -07:00
Jonas Jenwald
48242abe72 [B2G] Stub the |DownloadManager| to avoid error
After the refactoring in PR 5678, the B2G viewer now prints the following in the console:
```
ReferenceError: DownloadManager is not defined
```

This will obviously not matter once the B2G viewer is replaced with the new components-based one. But until that happens, I think it makes sense to just stub the class to suppress the error.
2015-04-04 21:26:33 +02:00
Jonas Jenwald
e5c4819601 Small refactoring of the code that calls |PDFViewerApplication.setInitialView|
This is a minor cleanup, to avoid an unnecessary `Promise.all` and to simplify catching |ViewHistory| errors.
2015-03-31 20:35:00 +02:00
Jonas Jenwald
6091e7bd6b Move the code that resets the history state when the |showPreviousViewOnLoad| preference is set to |false|
Since this code is *only* necessary if/when the history is actually enabled, this patch refactors it to actually reflect that.
2015-03-31 18:12:15 +02:00
Jonas Jenwald
03497eabd5 Move fetching of the |defaultZoomValue| preference value to |PDFViewerApplication.initialize|
For consistency, this preference should be placed amongst the others. The current position is purely for "historical" reasons, since it was one of the first preferences that was added to the code.
2015-03-31 15:33:21 +02:00
Rob Wu
d34e6ddd60 Set page size via @page + size
In Blink-based browsers, there is a mismatch between document size and
paper size. Even if exactly the same values and unit are used, it is
possible that the printed results takes more pages than expected.

To solve the issue, the page size is set via @page size, and the canvas
and ancestor nodes are assigned a width+height of 100% (=relative to the
page). This change resolves bugs such as blank pages and split pages.
2015-03-23 11:19:48 +01:00
Jonas Jenwald
36400ae48d Add |pageActualOption| to the list of predefined zoom options in the |scalechange| event handler in viewer.js
This patch also rearrange the order of the references to the DOM elements of the predefined zoom values, in viewer.js, to correspond with the element order in the current viewer UI. (The previous ordering is a leftover from the previous viewer UI.)
2015-03-20 22:09:34 +01:00
Jonas Jenwald
65a5543efe Disable PresentationMode for certain problematic configurations
Instead of trying to hack around various browser defects, let's just disable PresentationMode in the affected browsers. This patch:

- Disables PresentationMode in IE11+ when the viewer is embedded; fixes 4711.
2015-03-13 22:09:36 +01:00
Yury Delendik
c2dc665332 Merge pull request #5582 from Snuffleupagus/setHash-Fit-values
Fix handling of "Fit" zoom values in setHash (issue 5581)
2015-03-09 23:20:23 -05:00
speedplane
80d85b5fe7 Embedded PDF viewers should not be changing their parent page's title. 2015-03-05 22:36:08 -05:00
Jonas Jenwald
43e6de7e38 Merge pull request #5680 from Rob--W/forget-showPreviousViewOnLoad
Reset state upon load if showPreviousViewOnLoad
2015-03-02 21:49:34 +01:00
Rob Wu
6a16d7dd44 Reset state upon load if showPreviousViewOnLoad
And moved showPreviousViewOnLoad up to PDFViewerApplication.initialize
2015-03-02 21:35:44 +01:00
Yury Delendik
ce122591b9 Merge pull request #5586 from fkaelberer/updateThumbnailClassesOnlyWhenVisible
Update thumbnails only when they are visible (to improve scrolling through large documents)
2015-02-27 06:56:32 -06:00
Jonas Jenwald
8131440f9e Move the call to |PDFFindController.resolveFirstPage| into PDFViewer
From reading IRC scrollback, it became clear that having to manually call `PDFFindController.resolveFirstPage` in order for the find functionality to work isn't particulary good. Hence this PR, which moves that code into `PDFViewer.setDocument` to make life easier for third-party implementations.
2015-02-11 14:22:24 +01:00
Jonas Jenwald
d53fa1884b Simplify a couple of preprocessor tags in viewer.js 2015-01-31 22:45:20 +01:00
Jonas Jenwald
bb16475070 Use the |shadow| function from src/shared/util.js in viewer.js 2015-01-31 22:43:30 +01:00
Tim van der Meij
4c6ca1c78f Remove DownloadManager dependency
We can pass it in using the options object. Note that that this also avoids creating a DownloadManager object for each separate link (instead, having only one is enough).
2015-01-28 20:53:01 +01:00
Tim van der Meij
733882ac25 Refactor PDFAttachmentView to be more class-like and to separate functionality into methods 2015-01-28 20:53:00 +01:00
Tim van der Meij
609e2a30e9 Rename DocumentAttachmentsView to PDFAttachmentView 2015-01-28 20:52:59 +01:00
Tim van der Meij
2c19d99a2e Rename document_attachments_view.js to pdf_attachment_view.js 2015-01-28 20:52:22 +01:00
Tim van der Meij
ea1d37eb0d Refactor PDFAttachmentView to be more class-like and to separate functionality into methods 2015-01-27 22:51:39 +01:00
Tim van der Meij
b17da309ed Rename DocumentOutlineView to PDFOutlineView 2015-01-27 22:40:12 +01:00
Tim van der Meij
3eeb571425 Rename document_outline_view.js to pdf_outline_view.js 2015-01-27 22:38:45 +01:00
fkaelberer
d3022e1e70 Update thumbnail images only when sidebar is visible 2015-01-27 21:13:34 +01:00
fkaelberer
047d61ed1f Update thumbnail style only when sidebar is visible 2015-01-27 21:08:36 +01:00
Jonas Jenwald
c55dcf19a0 Move PDFThumbnailViewer to its own file 2015-01-24 15:41:18 +01:00
Jonas Jenwald
af6170ffd0 Attempt to display the File size quicker in the Document Properties dialog (PR 5554 followup) 2015-01-13 09:38:34 +01:00
Jonas Jenwald
8d0c442004 Merge pull request #5632 from yurydelendik/b2g-start
Fixes B2G file open sequence.
2015-01-09 18:00:39 +01:00
Yury Delendik
d52289d8fd Fixes B2G file open sequence. 2015-01-09 07:46:34 -06:00
Brendan Dahl
6ceb652abb Merge pull request #5554 from yurydelendik/apiref
Refactors getDocument and adds PDFDataRangeTransport.
2015-01-08 14:24:38 -08:00
Jonas Jenwald
3f061cef86 Add a |textlayerrendered| event 2015-01-06 17:57:32 +01:00
Yury Delendik
3a61edfcae Refactors getDocument and adds PDFDataRangeTransport. 2015-01-05 21:45:01 -06:00
Jonas Jenwald
5aad040735 Fix handling of "Fit" zoom values in setHash (issue 5581) 2014-12-27 12:54:29 +01:00
Yury Delendik
22c62685b0 Removes Stats dependency from PDFPageView. 2014-12-19 13:07:28 -06:00
Yury Delendik
fe4ac86781 Removes PDFPageSource 2014-12-19 09:55:11 -06:00
Yury Delendik
f68678086d Simple restructuring PageView into PDFPageView 2014-12-17 15:21:54 -06:00
Jonas Jenwald
6078901962 Prevent a "TypeError: pdfViewer is null" when the viewer loads (PR 5413 followup)
Currently if you manage to e.g. open the console (with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd>) before the viewer is initialized, the following will be printed in the console: `TypeError: pdfViewer is null`.
This doesn't cause any actual errors, but nevertheless it seems like something we should avoid.

Followup to PR 5413.
2014-11-15 12:17:10 +01:00
Yury Delendik
e294c8883a Merge pull request #5203 from Snuffleupagus/disableAutoFetch-loadingBar
Fix loadingBar hiding when disableAutoFetch is enabled (issue 3590)
2014-11-11 09:05:16 -06:00
Jonas Jenwald
2505c8613b Allow localization of the placement of percent signs in the zoom box 2014-10-21 21:41:06 +02:00
Jonas Jenwald
a1f4bff4f3 Disable zooming in Presentation Mode 2014-10-15 22:25:31 +02:00
Tim van der Meij
b215af30d3 Require destinations when they are needed and do not fetch all of them in advance 2014-10-06 22:26:18 +02:00
Jonas Jenwald
ecbb39f983 Fix loadingBar hiding when disableAutoFetch is enabled (issue 3590) 2014-10-05 23:16:36 +02:00
Jonas Jenwald
cfeb4c1019 Small refactoring of the loadingBar hiding code 2014-10-05 23:15:10 +02:00
Jonas Jenwald
a429e88c3b Fix inconsistencies in the preference names used by PDFViewerApplication
Since `preferenceSidebarViewOnLoad` is an enumeration value, it seems better to initialize it with the default one instead of a boolean.
`preferencesPdfBugEnabled` uses a superfluous "s", which is a typo I made when I introduced it.
2014-10-01 12:30:11 +02:00
Jonas Jenwald
b9ef80e167 Add a page loading indicator to the page number input 2014-10-01 00:13:44 +02:00
Yury Delendik
5e0b2d383f Fixes enabling pdfBug 2014-09-30 15:19:39 -05:00
Yury Delendik
374b94381d Moves scrollPageIntoView to the PDFViewer. 2014-09-30 07:13:46 -05:00
Brendan Dahl
1145eb8c09 Merge pull request #5295 from yurydelendik/pdfviewer
Refactoring to move page display code into separate class
2014-09-29 15:23:35 -07:00
Yury Delendik
44779f14b0 Renames and refactors PDFView to PDFViewerApplication. 2014-09-28 10:39:56 -05:00
Yury Delendik
a89bba35b2 Adds types definitions (jsdoc) for the PDFViewer code. 2014-09-28 10:39:56 -05:00
Yury Delendik
3773972dce Marks some private methods in PDFViewer and PDFThumbnailViewer
Conflicts:
	web/pdf_viewer.js
2014-09-28 10:39:56 -05:00
Yury Delendik
a1eca2084d Moves constants to avoid dependency on PDFView 2014-09-21 12:47:26 -05:00
Yury Delendik
f1851c6393 Removes any usage of PDFView in the PageView 2014-09-21 12:47:26 -05:00
Yury Delendik
fbd7eedce8 Removes PresentationMode dependency from PDFViewer 2014-09-21 12:47:26 -05:00
Yury Delendik
a06a974f78 Moves rendering queue logic from PDFView 2014-09-21 12:47:26 -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
Yury Delendik
3bce14761a Moves thumbs logic into PDFThumbnailViewer. 2014-09-20 08:19:04 -05:00
Yury Delendik
bfefadb87c Moves watchScroll and getVisibleElements from PDFView 2014-09-20 08:19:04 -05:00
Yury Delendik
c3f191a27c Implement streaming using moz-chunk-arraybuffer 2014-09-19 19:05:25 -05:00
Yury Delendik
63b7fa5634 Merge branch 'issue-4954' of https://github.com/Snuffleupagus/pdf.js into hashes
Conflicts:
	web/viewer.js
2014-09-19 18:25:11 -05:00
Manuel Padrón Martínez
293d566f67 Changed to lowercase everywhere the hashParams is compared 2014-09-18 20:18:23 +01:00
Manuel Padrón Martínez
4623f20221 Lowerize the params to allow case sensitive 2014-09-18 19:42:04 +01:00
Yury Delendik
ffb613bbac Merge pull request #5275 from Snuffleupagus/exception-propagation
Fix the exception propagation when rejecting workerReadyCapability
2014-09-16 10:05:34 -05:00
Jonas Jenwald
ed5fc43510 Add |UnexpectedResponseException| to fix the exception handling when file loading fails because the server responds with a non 404 status message 2014-09-14 11:52:33 +02:00
Yury Delendik
74d02c3406 Merge pull request #5254 from mancas/bug
Avoid showing 'blob..' as a title when using pdfjs from B2G
2014-09-11 17:03:47 -05:00
sangm
f4ccb1b61c Bug 1031612 - In PDF Viewer, the buggy XMP title "Untitled" overrides the document info title 2014-09-11 11:10:47 -05:00
Manuel Casas Barrado
f40fa1ac2a Bug 1054643 - [B2G][PDF Viewer]PDF Viewer title is shown as blob:... 2014-09-11 08:09:56 +02:00
Yury Delendik
15059ea603 Merge pull request #5229 from cpeterso/cpeterso/auto-fit-landscape
Auto zoom landscape documents (like slide presentations) to fit their height
2014-09-09 09:49:15 -05:00
Jonas Jenwald
2701edc7c6 Change getDocumentError in web/viewer.js to use instanceof instead of the exception name 2014-09-08 22:34:25 +02:00
Jonas Jenwald
ca027ebfdb Fix the exception propagation when rejecting workerReadyCapability
Currently when an exception is thrown, we try to reject `workerReadyCapability` with multiple arguments in src/core/api.js. This obviously doesn't work, hence this patch changes that to instead reject with the exception object as is.
In src/core/worker.js the exception is currently (unncessarily) wrapped in an object, so this patch also simplifies that to directly send the exception object instead.
2014-09-08 22:20:41 +02:00
Chris Peterson
81d5bd86ea Replace magic scale value 0 with UNKNOWN_SCALE 2014-08-23 00:14:44 -07:00
Chris Peterson
50a4510ab7 Auto zoom landscape documents to fit their height 2014-08-23 00:14:18 -07:00
Jonas Jenwald
5abe1cae6a Fix Zoom box resizing when it's hidden when the viewer loads (issue 5224) 2014-08-21 17:57:57 +02:00
Fabian Lange
403a4e2bda Debounces scroll events in web viewer.
As requested in #5178, this change debounces the scroll events.
The reason for doing so is that browsers can event-storm especially on
scroll, communicating hundreds of subpixel changes.

The main reason for this resulting in poor performance is that on each
scroll event `scrollTop` was queried, which forces layouting.

This change will use `requestAnimationFrame` to make sure the browser can
allocate enough time to other tasks. The delay is however quite small, thus
the reduction in executions is less noticeable. Modern browsers however utilize
`requestAnimationFrame` to smoothen out rendering.
2014-08-18 23:23:32 +02:00
Yan Or
d8bc16362c Bug 1054590 - [pdf.js] Update to use gaia-header 2014-08-15 17:57:07 -07:00
Jonas Jenwald
ca1dbda348 Disable the "Go to First/Last Page" buttons when the first/last page is currently active
Since the "Previous/Next Page" buttons are disabled when the first/last page is active, I think that for the sake of consistency the "Go to First/Last Page" should behave the same way.
2014-08-12 12:58:59 +02:00
Jonas Jenwald
3fd6c468b7 Attempt to display the File size quicker in the Document Properties dialog
Currently the File size field in the Document Properties dialog isn't set until `PDFView.pdfDocument.getDownloadInfo()` is resolved. If the Document Properties dialog is opened while a PDF file is loading with range requests, this leads to the less desirable situation where all fields *except* File size are available.

In cases where `PDFView.open()` is called with the `args` parameter defined, and `args` contains the property `length`, we actually know the File size when the PDF file begins to load. (This is usually the case when ranged loading is used in the Firefox addon/built-in version.)
Hence we can use `args.length` to set the File size immediately when `PDFView.open()` is called, resulting in a better user experience.
2014-08-11 16:44:36 +02:00
Jonas Jenwald
4737e1ad8d Remove old unused code from PDFView.close() 2014-08-10 16:50:21 +02:00
Yury Delendik
e8af56ffc5 Fixes text-selection example 2014-08-06 10:09:27 -05:00
Yury Delendik
196416cc17 Merge pull request #5100 from Rob--W/load-file-in-main-thread
Load file:-URLs in the main thread.
2014-08-06 09:54:46 -05:00
Yury Delendik
df8d2573dd Merge pull request #5007 from timvandermeij/pdfview-tlb
Converting PDFFindBar and PDFFindController to classes
2014-08-05 18:32:38 -05:00
Hengjie
eaa587753b Fix issue where pdfDocument is null
Happens when no file is loaded
2014-08-04 12:27:47 +12:00
Rob Wu
bd25f6be94 Load file:-URLs in the main thread.
QtWebKit does not support file:-URLs in Web Workers.
To solve this issue, I'm loading file:-URLs in the main thread
for generic builds. file:-URLs load relatively quick, so there
is no need for sophisticated load progress notifications.
2014-08-01 16:53:41 +02:00
Tim van der Meij
ea85a2f7a7 Use strict equalities in web/viewer.js 2014-07-31 22:06:38 +02:00
Tim van der Meij
dbe22475e1 Converting PDFFindBar and PDFFindController to classes 2014-07-29 21:59:01 +02:00
Rob Wu
bb13fb939e Initialize PDFView.url = ''
The absence of this property caused the following error in PDFView.download:

   Cannot read property 'split' of undefined

This property was unset when the PDF was loaded through a typed array instead
of a URL. With the fix, the file name will default to "document.pdf", as
defined by getPDFFileNameFromURL in web/ui_utils.js
2014-07-24 23:37:31 +02:00
Lu Wang
91b7030bf4 fix typo 2014-07-23 23:59:27 -07:00
Fabian Lange
6447397c04 Do not run cleanup while printing is ongoing. 2014-06-25 12:53:58 +02:00
Yury Delendik
df87df59b6 Increases page cache size when needed 2014-06-17 13:41:40 -05:00
Yury Delendik
6f79aef03a Uplift for B2G bug 1009780 - Improve open mechanism for downloads. 2014-06-16 19:06:36 -05:00
Jonas Jenwald
22cfcbcf8a Merge pull request #4952 from yurydelendik/telemetry
Collect More Telemetry Data
2014-06-17 00:36:58 +02:00
Jonas Jenwald
3ead6e6a94 Disable the developer hash parameters by default in PRODUCTION builds of PDF.js 2014-06-17 00:32:57 +02:00
Jonas Jenwald
1ba31a6cb7 Add pdfBugEnabled to the default preferences 2014-06-16 21:46:39 +02:00
Yury Delendik
7ac1c6b034 Reporting print usage 2014-06-14 15:55:21 -05:00
Jonas Jenwald
5ac4dd9593 Prevent rendering unnecessary pages when the HOME/END keys are pressed
Currently (at least in Firefox) when the HOME/END keys are pressed, this will trigger unnecessary rendering of pages that lay between the current page and the first/last page. Avoid this by going straight to the first/last page instead.
2014-06-14 14:11:42 +02:00
Nicholas Nethercote
f852cefdd8 Halve the size of the PageView cache. 2014-06-13 07:53:36 -07:00
Yury Delendik
2efbdfe8d4 Merge pull request #4834 from dferer/canvas-max-size
Limit the size of canvases to 5MP (iOS restriction)
2014-06-13 09:37:42 -05:00
Yury Delendik
cab043028b Merge pull request #4924 from yurydelendik/fixthumb
Fixes drawImage for thumbs
2014-06-13 09:07:41 -05:00
Samuel Chantaraud
952545e20f Limit the size of canvases to 5MP (iOS restriction) 2014-06-12 17:58:58 -04:00
Yury Delendik
d57f83e087 Reverting back disableWebGL preferences check 2014-06-12 14:47:46 -05:00
Yury Delendik
3b405cf611 Protects PDFJS.disableXXX == true from change 2014-06-12 12:40:59 -05:00
Yury Delendik
a338a7966d Fixes drawImage for thumbs 2014-06-12 10:28:42 -05:00
deathy
7d975dfe22 Fix destination name for 'Fit' zoom levels in hash params 2014-06-11 21:11:56 +03:00
Mohammed Abu-alsaad
e6546642db Added more preference variables from the available hash parameters 2014-05-30 10:44:41 +12:00
Jonas Jenwald
5cd6dddeee Convert the existing overlays to use the OverlayManager 2014-05-25 21:33:15 +02:00
Samuel Chantaraud
37c3641fad Added Promise.catch
Fixed Promise so it rejects on uncaught exception
Catch possible rejection on ViewHistory.setMultiple
2014-05-22 13:53:19 -04:00
Jonas Jenwald
b88c5330a9 Reduce the number of calls to PDFView.getVisiblePages from updateViewarea 2014-05-10 16:43:22 +02:00
Yury Delendik
c5eb058b09 Uses rAF to interrupt the operator list execution 2014-05-09 07:00:47 -05:00
Jonas Jenwald
c53bcb2992 Add a preference to set the sidebarView on load 2014-04-28 20:32:41 +02:00
Jonas Jenwald
159e86f7ab Ensure that the viewer loads even if there are errors when the preferences are read 2014-04-28 11:01:58 +02:00
Yury Delendik
42ed9025ef Merge pull request #4692 from Snuffleupagus/viewHistory-setMultiple
Add support for setting multiple values at once in ViewHistory
2014-04-27 23:26:38 -05:00
Jonas Jenwald
51d6ad7176 Fix the display of the indeterminate progress bar when the loaded percentage is NaN (issue 4696) 2014-04-27 22:11:25 +02:00
Jonas Jenwald
69eafaa58f Add support for setting multiple values at once in ViewHistory 2014-04-25 22:57:01 +02:00
Tim van der Meij
107cd8007f Move DocumentAttachmentsView to its own file 2014-04-24 22:58:21 +02:00
Tim van der Meij
1e119e093b Move DocumentOutlineView to its own file 2014-04-24 22:58:13 +02:00
Jonas Jenwald
4e1362642a Only handle scroll events when PDFView.pdfDocument is defined (issue 4642) 2014-04-19 01:55:10 +02:00
Samuel Chantaraud
25ee0e8572 Preliminary attachments support
Added a partial Filespec support
Added getAttachments in API
Added a new attachments view in UI (with a new icon by @shorlander)
2014-04-18 12:11:00 -04:00
Rob Wu
d7dfa447cd Remove unused (local) variables in web/ 2014-04-15 17:10:23 +02:00
Jonas Jenwald
12f3d58506 Ensure that the errorWrapper is closed when a new document is opened (issue 4625) 2014-04-15 13:51:40 +02:00
Yury Delendik
1fd43a87db Changes 'documentload' event behavior. 2014-04-13 21:07:36 -05:00
Yury Delendik
012a727eed Merge pull request #4598 from Rob--W/crx-filesystem-worker
Work-around for filesystem:-URL bug
2014-04-11 13:50:41 -05:00
Rob Wu
bfcc8af6ed Move logic from viewer.js to chromecom.js
and also default to '' instead of DEFAULT_URL to avoid trying to
load a non-existent file when no file has been specified.
2014-04-11 17:37:48 +02:00
Rob Wu
b64c06f68d Work-around for filesystem:-URL bug (#4592).
Visit https://robwu.nl/pdfjs/filesystem-worker-bug.htm and follow the
steps to verify that the extension works as intended with this patch.
2014-04-11 15:33:34 +02:00
Jonas Jenwald
965f7a7b14 Print WebGL status in the console 2014-04-11 13:37:50 +02:00
Tim van der Meij
b348243866 Fixes lint warning W004 in /web 2014-04-11 00:02:33 +02:00
Jonas Jenwald
eb7f369c54 Remove leading and trailing spaces from info.Producer and info.Creator when printing debug info in the console (bug 872827) 2014-04-10 12:20:39 +02:00
Brendan Dahl
ed1f8c33bd Merge pull request #4286 from yurydelendik/webgl
WebGL and misc memory optimizations
2014-04-07 14:33:34 -07:00
Yury Delendik
30ab878835 Add enableWebGL to the preferences 2014-04-03 12:20:53 -05:00
Yury Delendik
9c59437ac3 Merge pull request #4455 from aib/master
Fix download button waiting if document has started but not completed downloading
2014-04-03 09:40:06 -05:00
Yury Delendik
f57c6935d7 Implements WebGL support 2014-04-03 08:36:22 -05:00
Jonas Jenwald
c920372ff2 Rewrite 'Preferences' to make it async 2014-04-03 10:08:33 +02:00
Yury Delendik
bd11111465 Merge pull request #4545 from Rob--W/crx-api-enhancements
Use new Chromium APIs for FTP and redirects
2014-04-02 09:40:13 -05:00
Yury Delendik
75d09fd820 Merge pull request #4524 from fkaelberer/fullWidthInPresentationMode
Use full screen width in presentation mode
2014-04-02 09:03:37 -05:00
Jonas Jenwald
025f340228 Prevent the Document Properties from being empty when the dialog is opened before the file has started loading 2014-03-31 23:12:48 +02:00
Rob Wu
d04f81b964 Improved FTP support for Chromium extension 2014-03-30 00:08:02 +01:00
fkaelberer
db84851e27 Use full screen width in presentation mode 2014-03-28 08:58:18 +01:00
Brendan Dahl
a06fca142e Merge pull request #4519 from yurydelendik/pdfbugclean
Cleaning up the viewer and pdfbug; fixes bugs in Stepper
2014-03-27 13:27:15 -07:00
Yury Delendik
17eded9065 Partially reverts #3641 2014-03-27 10:50:42 -05:00
Yury Delendik
ed8ecfd00a Cleaning up the viewer and pdfbug; fixes repeats in Stepper 2014-03-26 15:18:53 -05:00
Yury Delendik
1d8f6cf0e7 Updates make.js for cmaps and make binary cmaps by default 2014-03-17 13:30:43 -05:00
Yury Delendik
69efd9cb96 CMaps binary packing 2014-03-14 16:46:35 -05:00
aib
2870a6108c Fix download button waiting if document has started but not completed downloading 2014-03-14 05:23:47 +02:00
Yury Delendik
7963f22545 Merge pull request #4259 from brendandahl/built-in-cmaps-squash
Adds built in CMaps and unifies the glyph mapping.
2014-03-13 10:27:48 -05:00
Jonas Jenwald
9e0ed5ca7e Fix coding style in web/viewer.js 2014-03-09 12:20:32 +01:00
Jonas Jenwald
6fd0b063e9 Fix scrolling using Shift+Spacebar in Firefox 2014-03-06 15:26:23 +01:00
Brendan Dahl
ce9e9e6ff7 Remove embeddedFontsUsed from API. 2014-02-27 14:06:03 -08:00
Samuel Chantaraud
dcb174ed58 Made viewer's webViewerLoad callable from outside viewer.js
To allow manual triggering when DOMContentLoaded can not be relied upon.
2014-02-27 13:45:02 -04:00
Rob Wu
3f96d0dabb Ctrl/cmd + S = save PDF instead of viewer.html 2014-02-27 16:21:47 +01:00
Samuel Chantaraud
cbc9ad3cb6 Correct formatting of locale to make it compatible with l10n (safari issue) 2014-02-26 16:09:58 -04:00
Brendan Dahl
6cce1e44dd Merge pull request #4292 from Snuffleupagus/issue-4232
Fix wrong page being displayed when entering/exiting Presentation mode with zoom set to 'page-fit'
2014-02-26 11:43:42 -08:00
Jonas Jenwald
4ee1fb7956 Fix spacebar scrolling in Firefox (4224 follow-up) 2014-02-26 20:17:58 +01:00
Brendan Dahl
0af0c6c99d Merge pull request #4229 from Rob--W/crx-stream-progress
Get progress bar for PDF streams in Chromium by passing the expected content length to the page
2014-02-26 11:12:34 -08:00
Brendan Dahl
890752680b Merge pull request #4224 from Rob--W/shortcut-responsiveness
Focus container when arrow/navigation keys are pressed
2014-02-26 10:52:17 -08:00
Jonas Jenwald
d6ca563f46 Fix wrong page being displayed when entering/exiting Presentation mode with zoom set to 'page-fit' 2014-02-11 22:51:14 +01:00
Yury Delendik
4563f6cd58 Merge pull request #4191 from Rob--W/crx-chrome-os
Register PDF Viewer as PDF handler in Chrome OS's file browser
2014-02-11 12:51:36 -06:00
Brendan Dahl
b5b94a4af3 Use built in CMaps and unify the glyph mapping. 2014-02-11 10:27:09 -08:00
Brendan Dahl
e477958b74 Remove inline script warnings. 2014-02-03 14:14:54 -08:00
Rob Wu
ce9400dc8b Handle navigation keys when viewer is not focused
Restrict the scrollbar hack to the keycode for "spacebar",
since the bug only occurs in Firefox with spacebar.

Keyboard navigation is only activated for the spacebar if
the currently focused element is not a button.
2014-01-31 14:59:49 +01:00
Rob Wu
eaf7daf7db [CRX] Pass expected length of stream to viewer
To get a progress bar for POST/FTP requests in Chromium.
2014-01-30 23:03:15 +01:00
Rob Wu
64a4a27455 Remove obsolete code from shortcut handler
These lines were introduced in 612f59aa10
when the only shortcuts were +/-/=/0 (to change zoom level).
Back then, when the input fields were focused, using these keys would
add these unwanted characters to the input field and change the zoom
level of the viewer. Having both operations at the same time was an
undesired event, so a check was inserted, to ignore shortcuts when
the toolbar is focused.

The #toolbar element doesn't exist any more, so these lines are obsolete.
2014-01-30 15:26:51 +01:00
Brendan Dahl
c2e31cd1ef Merge pull request #4205 from yurydelendik/blob-open-file
Using blob URL for open file
2014-01-28 14:15:35 -08:00
Brendan Dahl
0e000392ae Merge pull request #4179 from yurydelendik/dataLoaded
Fixes PDFDocumentProxy.getDataLoaded API name (and refactoring)
2014-01-28 13:56:01 -08:00
Yury Delendik
e5e9c6e243 Fixes PDFDocumentProxy.getDownloadInfo API name (and refactoring) 2014-01-28 15:13:47 -06:00
Tim van der Meij
b4b145507c Implements mouse wheel behaviour for non-Firefox browsers 2014-01-28 20:52:25 +01:00
Yury Delendik
18515b8668 Using blob URL for open file 2014-01-27 13:11:02 -06:00
Rob Wu
7bbff32a4d [security] Verify message source in Firefox add-on
And put initPassiveLoading within a preprocessor block because
it is only used by Firefox.
2014-01-26 12:55:48 +01:00