*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.
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
- 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.
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`
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.
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.
The line that this patch removes has been commented out since 2012 (!), see commit c8a6a9ba00.
Also, since the patch is trivial, I'm fixing the formatting of a comment to stop [GitHub from marking it with a red color](https://github.com/mozilla/pdf.js/blob/master/web/viewer.html#L394) (and IE from complaining).
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.
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.
Since the link is no longer valid, we should remove it from the comment.
(Using the Internet Archive, it seems that the contents of that page was basically identical to the PDF specification.)
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.)
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.
Set transformation matrix in (polyfilled) mozPrintCallback when a scale
is applied. Removed _scaleX and _scaleY in favor of _transformMatrix to
emphasize that the caller MUST ensure that the state of the matrix is
correct before `addContextCurrentTransform` is called.