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.
Determine the page rotation at the same place as where the page size is
determined. This allows us to implement custom print page rotation logic
in one place, in the future.
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.
Please see http://eslint.org/docs/rules/spaced-comment.
Note that the exceptions added for `line` comments are intended to still allow use of the old preprocessor without linting errors.
Also, I took the opportunity to improve the grammar slightly (w.r.t. capitalization and punctuation) for comments touched in the patch.
- Renamed startPrint to performPrint to emphasize that the method
does not start the print process (preparing pages for the printer),
but that it does the actual printing (sending pages off to the
printer).
- Put performPrint in the PDFPrintService, so that it can be
overridden if needed.
- Move the global scratchCanvas to PDFPrintService. This is mainly to
make it easier to reason about the state of scratchCanvas. In practice
there is no difference because only one PDFPrintService instance can
be instantiated at any given time.
- Move all logic of using the rendered page to one location.
This makes it easier to replace the printing logic later, when I add
special handling to out-of-process frames in the Chrome extension.
Make sure that the print service is stopped as soon as possible when
aborted, and that it is not possible for a (slow) promise to
accidentally wipe the state of a print job that was started later.