Commit Graph

997 Commits

Author SHA1 Message Date
Jonas Jenwald
67a1dfcfb5 Move the sidebar related code from viewer.js into PDFSidebar
The sidebar code has, except for minor fixes/additions (such as attachments), been largely untouch for years.
To avoid having a bunch of sidebar code sprinkled throughout viewer.js, this patch moves the sidebar code into a separate file (pdf_sidebar.js), similar to how most other functionality has been moved in the last few years.

Besides simply moving code around, this patch also has the added benefit that we now keep track of the sidebar state (not just opened/closed).
This now makes it possible to handle both `Preferences` *and* `ViewHistory` settings for the sidebar state in a cleaner way, preventing strange and confusing interactions between the two.
2016-02-27 14:13:09 +01:00
Jonas Jenwald
21f048234d Refactor how PDFOutlineView/PDFAttachmentView is initialized in viewer.js, rename the classes, and refactor their render methods
Changes `PDFOutlineView`/`PDFAttachmentView` to be initialized once, since we're always creating them, and refactor their `render` methods to instead pass in the `outline`/`attachments`.

For consistency with other "classes", the `PDFOutlineView`/`PDFAttachmentView` are renamed to `PDFOutlineViewer`/`PDFAttachmentViewer`.

Also, make sure that the outline/attachments are reset when the document is closed. Currently we keep the old ones around until the `getOutline`/`getAttachments` API calls are resolved for a new document.
2016-02-27 14:13:08 +01:00
Jonas Jenwald
c7a44391cf Add a reset method to PDFFindbar, and use it to clear parts of the find UI when the document is closed 2016-02-26 18:35:45 +01: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
Tim van der Meij
0351c7eff4 Move the getFileName helper function to the core
This is required to be able to use it in the annotation display code,
where we now apply it to sanitize the filename of the FileAttachment
annotation. The PDF file from https://bugzilla.mozilla.org/show_bug.cgi?id=1230933 has shown that some PDF generators include the path of the file rather than the filename, which causes filenames with weird initial characters. PDF viewers handle this differently (for example Foxit Reader just replaces forward slashes with spaces), but we think it's better to only show the filename as intended.

Additionally we add unit tests for the `getFilenameFromUrl` helper
function.
2016-02-23 22:49:53 +01:00
Tim van der Meij
6a33dfd13a Implement support for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Yury Delendik
7c89bdc8d6 Allow foriegn origin URLs only for hosted viewers. 2016-01-22 11:54:19 -06:00
Yury Delendik
f340dd5cd5 Adds pdfjs/main_loader module to better mirror pdfjs-dist/build/pdf. 2015-12-30 13:28:57 -06:00
Yury Delendik
85e95d34ed Use RequireJS in the viewer, examples and tests. 2015-12-29 09:20:52 -06:00
Tim van der Meij
df81b832bb Remove unused variables 2015-12-16 23:52:16 +01:00
Yury Delendik
c9cb6a3025 Replaces UnsupportedManager with callback. 2015-11-30 14:42:47 -06:00
Sebastian Hengst
27577a714f Issue #6569 - document_colors_disabled shouldn't escape quotes (compare-locales warning) 2015-11-22 10:14:25 +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
a4ca9986e1 Merge pull request #6318 from Snuffleupagus/bug-1191279
For documents with different page sizes, ensure that the correct page becomes visible on load when e.g. the 'page' hash parameter was provided (bug 1191279, issue 6393)
2015-11-10 17:51:02 -06:00
Tim van der Meij
7681def0de Move VIEW_HISTORY_MEMORY constant to view_history.js
Currently this constant is present in `viewer.js`, but it is not used there at all. Instead, it is used in `view_history.js` where we have a global for it. We might as well move the constant to `view_history.js` as that is the only place where it is used, thereby removing a global and an unused constant from `viewer.js`.
2015-11-01 15:45:12 +01:00
Yury Delendik
c8c211602b Merge pull request #6073 from Snuffleupagus/bug-1170063
[Firefox] Handle the user modifying the "mousewheel.with_meta.action" and "mousewheel.with_control.action" prefs (bug 1170063)
2015-10-30 11:54:04 -05:00
Andy Parisi
17fe0b1470 Added find match counter 2015-10-30 10:21:26 -05:00
Yury Delendik
62afa9f695 Fixes PDFViewerApplication.open/close methods signature. 2015-10-23 09:06:32 -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
Jonas Jenwald
610df45bad Prevent external links from "replacing" the viewer when it's embedded (bug 976541)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=976541.

This patch also adds a `externalLinkTarget` preference, to make the behaviour user configurable.
2015-10-13 22:18:08 +02:00
Jonas Jenwald
59548921d1 For documents with different page sizes, ensure that the correct page becomes visible on load when e.g. the 'page' hash parameter was provided (bug 1191279, issue 6393)
This issue is actually, in a sense, "caused" by the fact that the API/viewer supports partial loading/rendering. Previously when the *entire* document was always fetched before rendering begun, we knew all page sizes in advance and this issue didn't exist.

Now we use the size of *one* page in order to set the initial size of every page, until we've fetched the pages and thus know their correct sizes.
This means that during loading the size of the pages can change, which may cause the initial position to become scrolled out of view.

The most naive solution to this problem would perhaps be to delay setting the initial position on load for all documents, until all pages are fetched. However I think that would be a *really* bad idea, since doing so would make the initial rendering slower and make it feel sluggish for most documents.

Since there is generally no way of knowing if a document has different sized pages prior to loading it, we can only check once the pages are available.
Hence this patch, which treats documents with different sized pages as a special case, by re-applying the initial position when all pages have become available.
2015-09-06 12:09:22 +02:00
Yury Delendik
70fd360d51 Merge pull request #6242 from Rob--W/outline-collapsible
Allow outline to be collapsed / shown via +/-.
2015-08-27 08:41:34 -05:00
Rob Wu
7c992243fd Allow outline to be collapsed / shown via icon.
- This commit adds a '>' before every outline item that has subitems.
- Click on the '>' to collapse all subitems under that item (which turns
  the '>' in a 'v').
- Shift + click expands/collapses all descendant items under that tree.
- Double-clicking on the "Show Document Outline" button in the toolbar
  expands/collapses all outline items.
2015-08-22 18:49:08 +02:00
Jonas Jenwald
a6d10af3b4 Add disableStream to the list of preferences read by PDFViewerApplication.initialize (issue 6361)
Fixes 6361.
2015-08-18 12:35:42 +02:00
Tim van der Meij
26b9205c7e Merge pull request #6327 from Snuffleupagus/viewer-sidebar-prevent-switching-to-disabled-views
Prevent switching to disabled views (i.e. outline or attachments) in the sidebar
2015-08-07 22:54:08 +02:00
Jonas Jenwald
f063c78cbf Prevent switching to disabled views (i.e. outline or attachments) in the sidebar
Currently in `switchSidebarView` there is code that attempts to handle the `outline` or `attachments` being disabled. However, given the placement of it, that code does not actually accomplish anything. Even more strange is the fact that the way that the buttons are disabled, that code won't ever be hit.
(Looking back with `git blame`, it seems that it has never worked as you'd expect.)

Hence this patch, which correctly disables switching to the `outline` or `attachments` views when they are disabled.
Once PR 6314 restores the 'pagemode' hash parameter, this patch thus makes it impossible to switch to a disabled sidebar view by modifying the 'pagemode' hash of an already loaded document.
2015-08-07 13:45:32 +02:00
Jonas Jenwald
76cfd106d5 Fix 'namedaction' regression that breaks the 'Find' action
This regressed in 0ef6212b64.
2015-08-07 12:05:21 +02:00
Jonas Jenwald
5c26e5e2cd Move handling of the 'pagemode' hash parameter into viewer.js to restore the functionality
This regressed in 0ef6212b64.

Since the 'pagemode' hash parameter requires certain viewer functionality (e.g. thumbnails and an outline) in order to work, it seemed reasonable to move the functionality from `pdf_link_service.js` into `viewer.js`.
Similar to `namedaction`, this patch makes use of an event to forward the 'pagemode' parameter.
2015-08-07 12:05:17 +02:00
Tim van der Meij
d08895d659 Merge pull request #6236 from Rob--W/print-javascript-action
Detect scripted auto-print requests
2015-07-25 19:42:31 +02:00
Tim van der Meij
9c510bd6e6 Remove unused globals and updateViewarea function from viewer.js 2015-07-23 16:02:39 +02:00
Tim van der Meij
d162dba85e Merge pull request #6256 from Snuffleupagus/bug-1186842
Ensure that the viewer always receives focus when the HOME/END keys are pressed (bug 1186842)
2015-07-23 14:46:32 +02:00
Jonas Jenwald
8275dff1b1 Reduce code duplication in the 'keydown' event handler in viewer.js, by re-factoring the code which ensures that the viewerContainer is focused 2015-07-23 13:01:55 +02:00
Jonas Jenwald
d5232f5b5a Ensure that the viewer always receives focus when the HOME/END keys are pressed (bug 1186842)
It appears that I broke this with PR 4941.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1186842.
2015-07-23 12:04:49 +02:00
Jonas Jenwald
fa53cd6ca3 Use DEFAULT_SCALE_VALUE as default when fetching the zoom parameter from PDFViewerApplication.store (i.e. ViewHistory)
Since the zoom value should be in percent, using `PDFViewer.currentScale` will be wrong by a factor of 100, potentially causing the zoom level of the document to become wrong on load.
2015-07-22 23:58:30 +02:00
Jonas Jenwald
299d05eaa5 Prevent documents from intermittently opening with the zoom level set to 1% (issue 6253)
*This fixes a regression from PR 6192.*

Under some circumstances, the `resize` event handler in `viewer.js` is fired before the scale has been set. This can lead to PDF documents being rendered at the wrong zoom level when they are opened.
It seems that a way to reliably trigger this is to, using the Firefox addon, open a PDF file that triggers the `fallback` bar, in a new background tab (i.e. middle clicking on a link, or use the context menu).

Prior to PR 6192, we checked the selected option in the `scaleSelect` dropdown instead. Since `pageAutoOption` is selected by default in `viewer.html`, this should explain why the issue wasn't visible previously.
2015-07-22 23:45:33 +02:00
Rob Wu
c676ecb5a0 Detect scripted auto-print requests
Fixes #6106

To avoid future regressions, two new unit tests were added:
1. A new PDF based on the report from #6106, which contains an
   OpenAction of type JavaScript and a string "this.print({...}".
2. An existing PDF from https://bugzil.la/1001080 (from #4698).

Although it does not matter, since we don't execute the JavaScript code,
I have also changed "print(true)" to "print({})" since the print method
takes an object (not a boolean). See "Printing PDF documents", page 62:
http://adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_developer_guide.pdf
2015-07-20 18:25:02 +02:00
Jonas Jenwald
93d82e21d5 Move handling of the 'custom' scale value from pdf_viewer.js to viewer.js
The special handling of the 'custom' scale value is only relevant for the `scaleSelect` dropdown in the standard viewer, hence I think that it should be placed in `viewer.js` instead.
2015-07-19 20:02:47 +02:00
Jonas Jenwald
0c08113e39 Remove PDFViewerApplication.setScale and further simplify the scalechange event handler (issue 6158)
This finally fixes 6158.
2015-07-14 10:06:59 +02:00
Jonas Jenwald
2608757620 Simplify the code that resets the value of the pageNumber element in PDFViewerApplication.setInitialView
After the creation of `PDFViewer`, its `_resetView` method takes care of resetting, among other things, the page number property. Hence we don't need to set `pdfViewer.currentPageNumber = 1;` here any more, and the comment is no longer accurate either.
2015-07-12 16:24:07 +02:00
Jonas Jenwald
5cb15874fa Remove PDFViewerApplication.updateScaleControls (issue 6158)
*With this patch we're getting very close to fixing 6158.*

The only use-case for `PDFViewerApplication.updateScaleControls` is to try and avoid calling `selectScaleOption` from the `scalechange` event handler in viewer.js.
This will *only* happen when the user has manually changed the scale by using the `<select>` dropdown, which means that in reality this is just a micro optimization. Furthermore, `selectScaleOption` is only skipped for the "named" scale values (e.g. `auto`, `page-actual`, `page-fit`, `page-width`), thus further reducing the value of this code.

Also, since we're updating the scale `<select>` dropdown from an event handler, we're currently depending on the event being dispatched (and handled) completely before the next `scalechange` event. Relying on the execution order of the code in this way, even though it currently works, seems unfortunate since it *could* potentially cause the internal scale value and the UI from getting out of sync.
2015-07-11 11:25:32 +02:00
Jonas Jenwald
35ee1e1b0a Refactor the 'resize' event handler in viewer.js (issue 6158)
*This is the next step towards fixing 6158.*

This patch removes the dependency on the state of the scale `<select>` dropdown from the `resize` event handler, and instead uses the (in `PDFViewer`) stored `currentScaleValue`.
I believe that the way this code is currently written is purely for historical reasons, since originally *only* the numerical scale was stored internally (hence there was no other way to access the scale value).
However, since we now store the scale value, we should use it instead of quering the DOM. This helps ensure that the internally stored scale value is always accurately displayed in the UI (which should be good since, after the creation of `PDFViewer`, the `<select>` DOM element is now updated by an event handler).
2015-07-10 11:50:54 +02:00
Jonas Jenwald
1c0115a7e4 Remove the currentScaleValue getter from PDFViewerApplication (issue 6158)
*The next step towards fixing issue 6158.*

We can just as well access `pdfViewer.currentScaleValue` directly in `PDFViewerApplication`, instead of having a helper function which just acts as a wrapper for it.
2015-07-07 09:17:05 +02:00
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