mozilla/pdf.js — pull request #3670 by Rob--W (2013-09-10 23:04:53+00:00)
Title: Polyfill for mozPrintCallback

I've created a shim for <canvas>.mozPrintCallback, which traps `window.print()` calls and Ctrl + P shortcuts when mozPrintCallback is not supported.

This shim does the following:
1. Intercept window.print()
2. For a window.print() call (if allowed, ie. no previous print job):
1. Dispatch the beforeprint event.
2. Render a printg progress dialog.
3. For each canvas, call mozPrintCallback if existent (one at a time, async).
4. During each mozPrintCallback callback, update the progress dialog.
5. When all es have been rendered, invoke the real window.print().
6. Dispatch the afterprint event.

Effects across browsers:

- In Firefox, mozPrintCallback was already supported, so this patch does nothing.
- In Chrome, the feature works well.
- In IE10, it's impossible to prevent the default behavior for the Ctrl + P shortcut, so the dialog shows too early (when every page is ready, the correct dialog is shown though).

I didn't test the changes with Opera or Safari, but since they're both webkit browsers, I expect the same result as in Chrome.