Merge pull request #6443 from Snuffleupagus/issue-6442

Don't show thumbnails until the `canvas` to `image` conversion is done (issue 6442)
This commit is contained in:
Tim van der Meij 2015-09-12 13:38:25 +02:00
commit 11a0e1c5f7

View File

@ -184,9 +184,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
_getPageDrawContext: _getPageDrawContext:
function PDFThumbnailView_getPageDrawContext(noCtxScale) { function PDFThumbnailView_getPageDrawContext(noCtxScale) {
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
this.canvas = canvas; this.canvas = canvas;
this.div.setAttribute('data-loaded', true);
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
var outputScale = getOutputScale(ctx); var outputScale = getOutputScale(ctx);
@ -201,8 +199,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
} }
var image = document.createElement('img'); var image = document.createElement('img');
image.id = this.renderingId; this.image = image;
image.id = this.renderingId;
image.className = 'thumbnailImage'; image.className = 'thumbnailImage';
image.setAttribute('aria-label', mozL10n.get('thumb_page_canvas', image.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{ page: this.id }, 'Thumbnail of Page {{page}}')); { page: this.id }, 'Thumbnail of Page {{page}}'));
@ -210,9 +209,6 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
image.style.width = canvas.style.width; image.style.width = canvas.style.width;
image.style.height = canvas.style.height; image.style.height = canvas.style.height;
this.image = image;
this.ring.appendChild(this.image);
return ctx; return ctx;
}, },
@ -225,6 +221,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
} }
this.image.src = this.canvas.toDataURL(); 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 // Zeroing the width and height causes Firefox to release graphics
// resources immediately, which can greatly reduce memory consumption. // resources immediately, which can greatly reduce memory consumption.
this.canvas.width = 0; this.canvas.width = 0;