[Pkg-javascript-commits] [pdf.js] 96/109: Don't show thumbnails until the `canvas` to `image` conversion is done (issue 6442)
David Prévot
taffit at moszumanska.debian.org
Fri Sep 25 03:04:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 1b50932eaa838bfd0ba0f8ab10d35afb665708d3
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Sat Sep 12 11:51:25 2015 +0200
Don't show thumbnails until the `canvas` to `image` conversion is done (issue 6442)
---
web/pdf_thumbnail_view.js | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index b8c54fe..88c92c7 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -184,9 +184,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
_getPageDrawContext:
function PDFThumbnailView_getPageDrawContext(noCtxScale) {
var canvas = document.createElement('canvas');
-
this.canvas = canvas;
- this.div.setAttribute('data-loaded', true);
var ctx = canvas.getContext('2d');
var outputScale = getOutputScale(ctx);
@@ -201,8 +199,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
}
var image = document.createElement('img');
- image.id = this.renderingId;
+ this.image = image;
+ image.id = this.renderingId;
image.className = 'thumbnailImage';
image.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{ page: this.id }, 'Thumbnail of Page {{page}}'));
@@ -210,9 +209,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
image.style.width = canvas.style.width;
image.style.height = canvas.style.height;
- this.image = image;
- this.ring.appendChild(this.image);
-
return ctx;
},
@@ -220,16 +216,19 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
* @private
*/
_convertCanvasToImage: function PDFThumbnailView_convertCanvasToImage() {
- if (!this.canvas) {
- return;
- }
- this.image.src = this.canvas.toDataURL();
-
- // Zeroing the width and height causes Firefox to release graphics
- // resources immediately, which can greatly reduce memory consumption.
- this.canvas.width = 0;
- this.canvas.height = 0;
- delete this.canvas;
+ if (!this.canvas) {
+ return;
+ }
+ this.image.src = this.canvas.toDataURL();
+
+ this.div.setAttribute('data-loaded', true);
+ this.ring.appendChild(this.image);
+
+ // Zeroing the width and height causes Firefox to release graphics
+ // resources immediately, which can greatly reduce memory consumption.
+ this.canvas.width = 0;
+ this.canvas.height = 0;
+ delete this.canvas;
},
draw: function PDFThumbnailView_draw() {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list