mozilla/pdf.js — pull request #4209 by Rob--W (2014-01-28 16:21:36+00:00)
Title: Update Grab to pan to fix performance issue

Reported at http://stackoverflow.com/questions/21392844/pdf-js-recalculating-problme
See also https://github.com/Rob--W/grab-to-pan.js/commit/e0f893753ac10a5c97159fd01155b05d234f4c0f

To verify that this patch improves performance, just follow the following steps:

1. Build the latest version of PDF.js and open the PDF Viewer.
2. Scroll through the whole document (tracemonkey) to get all pages rendered.
3. Activate the hand tool (press H).
3. Open the developer tools (Chrome).
4. Go to the Timeline tab and start the timeline.
5. Click inside the PDF and move the mouse a little bit.
6. Look at the purple bar ("recalculating styles") to see how much time it took to change the cursor ("Recalculate Style (viewer.js:2201)" (with a Call Site Stack to GrabToPan__onmousedown/move)).

Before this patch, my laptop reported ~35 ms, after the fix, the time went down to 0.3ms. For large documents, the performance improvement is even more significant.