Skip to content

Commit

Permalink
optimizing relseasing canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
awang committed Aug 1, 2015
1 parent cb1b58c commit 97b04e6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions web/pdf_thumbnail_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
var canvas = document.createElement('canvas');
//canvas.id = this.renderingId;

canvas.className = 'thumbnailImage';
canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{page: this.id}, 'Thumbnail of Page {{page}}'));
//canvas.className = 'thumbnailImage';
//canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
// {page: this.id}, 'Thumbnail of Page {{page}}'));

this.canvas = canvas;
this.div.setAttribute('data-loaded', true);
Expand All @@ -203,6 +203,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
this.image.id = this.renderingId;
this.image.style.height = canvas.style.height;
this.image.style.width = canvas.style.width;
this.image.className = 'thumbnailImage';
this.image.setAttribute('aria-label', mozL10n.get('thumb_page_canvas',
{page: this.id}, 'Thumbnail of Page {{page}}'));
this.ring.appendChild(this.image);
return ctx;
},
Expand Down Expand Up @@ -318,7 +321,9 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
ctx.drawImage(reducedImage, 0, 0, reducedWidth, reducedHeight,
0, 0, canvas.width, canvas.height);
this.image.src = canvas.toDataURL();
ctx.clearRect(0, 0, canvas.style.width, canvas.style.height);
this.canvas.width = 0;
this.canvas.height = 0;
delete this.canvas;
}
};

Expand Down

0 comments on commit 97b04e6

Please sign in to comment.