pdf.js/web
Jonas Jenwald 9eb9065c79 Ensure that we use the *correct* paintedViewport in PDFPageView.cssTransform, to avoid visual glitches on quick rotations (PR 7738 follow-up)
*This fixes a regression from commit c9a0955c9c, i.e. PR 7738.*

Currently if you quickly rotate a document at least *twice*,[1] such that rendering of a page hasn't finished for the first rotation before the last rotation is triggered, the `cssTransform` method can fail to update the page correctly leading to it looking temporarily distorted.

The reason why things break is that previously we stored the `viewport` on the canvas DOM element, meaning that when it was accessed in `cssTransform` is was guaranteed to point to the `viewport` of the `zoomLayer` canvas.
Generally you want to avoid storing data on DOM elements this way, and during the `PDFPageView` refactoring needed to support SVG rendering, the previous `viewport` was instead stored directly on `PDFPageView`.
However, the problem is first of all that the `paintedViewport` only stores the *last* `viewport` computed, and second of all that there're no guarantees that it actually applies to the current `zoomLayer` canvas.
If a document is rotated slowly enough that rendering finishes *before* the next rotation then this problem doesn't exist, but for sufficiently quick rotations rendering will be cancelled at least once and the `paintedViewport` could thus be bogus.

The solution for the above problems is to ensure that we track the correct `viewport` for each DOM element (canvas or svg),[2] which seemed easist to do with a `WeakMap`.[3]

---
[1] I'm able to reproduce this using the `tracemonkey` file, but please note that for pages with few operations, i.e. that render very quickly, the effect may be hard to spot.

[2] One other possible solution that I briefly considered, was to wait until rendering finished before storing the current `viewport`. However, that would have caused issues with rotating a page before the *first* rendering operation had finished.

[3] This regression took me way longer to both figure out, and fix, than I'd like to admit :-)
2017-01-23 12:13:53 +01:00
..
images optimize png images using zopflipng 2016-07-10 17:49:16 +08:00
.gitignore Remove obselete file from .gitignore 2015-01-26 16:44:45 +01:00
annotation_layer_builder.css Button widget annotations: improve unit tests, simplify code and remove labels 2016-12-17 20:38:48 +01:00
annotation_layer_builder.js Interactive forms: remove global PDFJS usage 2016-09-19 00:12:42 +02:00
app.js Convert the only remaining consumer (in hand_tool.js) of the 'localized' event to use the localized Promise instead, and only re-dispatch the 'localized' event on the eventBus for GENERIC builds 2016-12-14 16:19:10 +01:00
chrome-i18n-allow-access-to-file-urls.json Add translations of "Allow access to file URLs" 2015-08-14 18:59:55 +02:00
chromecom.js Switch to using ESLint, instead of JSHint, for linting 2016-12-16 21:06:36 +01:00
compatibility.js Enable the no-else-return ESLint rule 2017-01-09 20:27:39 +01:00
compressed.tracemonkey-pldi-09.pdf Add Makefile. Move some files around to make building the website easier. 2011-07-05 10:53:57 -07:00
debugger.js [Bug 1331081] omit addEventListener/removeEventListener's third parameter when it's false 2017-01-17 17:50:21 +01:00
default_preferences.json Adds SVG rendering capabilities to the PDFViewer. 2016-11-18 13:03:49 -06:00
dom_events.js Remove the previousPageNumber parameter from the pagechanging/pagechange` events, and stop dispatching the events if the input is out of bounds 2016-07-25 10:08:53 +02:00
download_manager.js Switch to using ESLint, instead of JSHint, for linting 2016-12-16 21:06:36 +01:00
firefox_print_service.js Removes mozPrintCallback polyfill, converts canvas to PNG. 2016-10-11 10:08:13 -05:00
firefoxcom.js Enable the spaced-comment ESLint rule 2017-01-19 16:41:59 +01:00
grab_to_pan.js Switch to using ESLint, instead of JSHint, for linting 2016-12-16 21:06:36 +01:00
hand_tool.js Convert the only remaining consumer (in hand_tool.js) of the 'localized' event to use the localized Promise instead, and only re-dispatch the 'localized' event on the eventBus for GENERIC builds 2016-12-14 16:19:10 +01:00
interfaces.js Interactive forms: remove global PDFJS usage 2016-09-19 00:12:42 +02:00
overlay_manager.js Moves all document.getElementById lookups into viewer.js 2016-04-21 11:39:11 -05:00
password_prompt.js Moves all document.getElementById lookups into viewer.js 2016-04-21 11:39:11 -05:00
pdf_attachment_viewer.js Adds EventBus. 2016-04-28 06:57:24 -05:00
pdf_document_properties.js Enable the no-else-return ESLint rule 2017-01-09 20:27:39 +01:00
pdf_find_bar.js Added multiple term search functionality (with default phrase search) 2016-05-26 18:24:58 +05:00
pdf_find_controller.js Enable the no-else-return ESLint rule 2017-01-09 20:27:39 +01:00
pdf_history.js [Bug 1331081] omit addEventListener/removeEventListener's third parameter when it's false 2017-01-17 17:50:21 +01:00
pdf_link_service.js Remove/deprecate specifying a pageNumber directly after the hash symbol (#), to improve compatibility since other PDF viewers don't support this form (issue 7746) 2016-10-27 23:25:53 +02:00
pdf_outline_viewer.js Update PDFOutlineViewer_bindLink to look more like LinkAnnotationElement_bindLink 2016-10-23 16:08:26 +02:00
pdf_page_view.js Ensure that we use the *correct* paintedViewport in PDFPageView.cssTransform, to avoid visual glitches on quick rotations (PR 7738 follow-up) 2017-01-23 12:13:53 +01:00
pdf_presentation_mode.js Replaces all preprocessor directives with PDFJSDev calls. 2016-10-14 10:57:53 -05:00
pdf_print_service.js Merge pull request #7973 from Snuffleupagus/eslint_spaced-comment 2017-01-22 21:58:42 +01:00
pdf_rendering_queue.js Introduces UMD headers to the web/ folder. 2016-04-13 10:09:48 -05:00
pdf_sidebar.js Adds EventBus. 2016-04-28 06:57:24 -05:00
pdf_thumbnail_view.js Add PageLabels to PDFPageView and PDFThumbnailView 2016-10-26 13:30:37 +02:00
pdf_thumbnail_viewer.js Add PageLabels to PDFPageView and PDFThumbnailView 2016-10-26 13:30:37 +02:00
pdf_viewer.component.js Switch to using ESLint, instead of JSHint, for linting 2016-12-16 21:06:36 +01:00
pdf_viewer.css Better components examples. 2016-04-28 13:30:03 -05:00
pdf_viewer.js Enable the no-else-return ESLint rule 2017-01-09 20:27:39 +01:00
pdfjs.js Replace pdfjsLib with module that represents pdf.js. 2016-04-13 10:11:34 -05:00
preferences.js Removes web/default_preferences.js file. 2017-01-10 08:33:32 -06:00
secondary_toolbar.js Fix errors reported by the no-extra-bind ESLint rule 2016-12-12 20:35:50 +01:00
text_layer_builder.css Use default line height for the text layer 2015-12-02 23:00:12 +01:00
text_layer_builder.js Replaces all preprocessor directives with PDFJSDev calls. 2016-10-14 10:57:53 -05:00
toolbar.js Refactor toolbar (and secondary toolbar). 2016-11-18 12:51:15 -06:00
ui_utils.js Enable the no-else-return ESLint rule 2017-01-09 20:27:39 +01:00
view_history.js Rename the ViewHistory localStorage (and sessionStorage) key from database to pdfjs.history, and migrate existing data on read (issue 7760) 2016-11-21 21:03:37 +01:00
viewer-snippet-chrome-extension.html Remove type="text/javascript" from script tags. 2014-05-13 02:41:01 +02:00
viewer-snippet-chrome-overlays.html Add translations of "Allow access to file URLs" 2015-08-14 18:59:55 +02:00
viewer-snippet-firefox-extension.html Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
viewer-snippet-minified.html Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
viewer-snippet.html Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
viewer.css Viewer: remove unused CSS rule 2016-11-24 23:44:57 +01:00
viewer.html Removes web/default_preferences.js file. 2017-01-10 08:33:32 -06:00
viewer.js Better DOMContentLoaded handling. 2017-01-10 08:49:08 -06:00