[Pkg-javascript-commits] [pdf.js] 17/174: Don't clear the `canvas` until re-rendering is finished when the `scale` or `rotation` is changed (issue 6467)
David Prévot
taffit at moszumanska.debian.org
Thu Nov 19 18:45:00 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 1ae9ba1d6464870e1431fb998a946266c60c01a7
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Wed Sep 23 12:34:24 2015 +0200
Don't clear the `canvas` until re-rendering is finished when the `scale` or `rotation` is changed (issue 6467)
*This regressed in PR 4920.*
The main motivation for PR 4920 was to quickly get rid of old canvases when pages are evicted from the `PDFPageViewBuffer` cache. However it inadvertently broke the use-case where the `canvas` is used as a preview, on scale or rotation changes, until the re-rendering is finished.
Fixes 6467.
---
web/pdf_page_view.js | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js
index fc68ee0..f408faf 100644
--- a/web/pdf_page_view.js
+++ b/web/pdf_page_view.js
@@ -105,7 +105,7 @@ var PDFPageView = (function PDFPageViewClosure() {
}
},
- reset: function PDFPageView_reset(keepAnnotations) {
+ reset: function PDFPageView_reset(keepZoomLayer, keepAnnotations) {
if (this.renderTask) {
this.renderTask.cancel();
}
@@ -117,12 +117,12 @@ var PDFPageView = (function PDFPageViewClosure() {
div.style.height = Math.floor(this.viewport.height) + 'px';
var childNodes = div.childNodes;
- var currentZoomLayer = this.zoomLayer || null;
+ var currentZoomLayerNode = (keepZoomLayer && this.zoomLayer) || null;
var currentAnnotationNode = (keepAnnotations && this.annotationLayer &&
this.annotationLayer.div) || null;
for (var i = childNodes.length - 1; i >= 0; i--) {
var node = childNodes[i];
- if (currentZoomLayer === node || currentAnnotationNode === node) {
+ if (currentZoomLayerNode === node || currentAnnotationNode === node) {
continue;
}
div.removeChild(node);
@@ -139,7 +139,7 @@ var PDFPageView = (function PDFPageViewClosure() {
this.annotationLayer = null;
}
- if (this.canvas) {
+ if (this.canvas && !currentZoomLayerNode) {
// Zeroing the width and height causes Firefox to release graphics
// resources immediately, which can greatly reduce memory consumption.
this.canvas.width = 0;
@@ -190,7 +190,7 @@ var PDFPageView = (function PDFPageViewClosure() {
if (this.zoomLayer) {
this.cssTransform(this.zoomLayer.firstChild);
}
- this.reset(true);
+ this.reset(/* keepZoomLayer = */ true, true);
},
/**
@@ -401,6 +401,12 @@ var PDFPageView = (function PDFPageViewClosure() {
}
if (self.zoomLayer) {
+ // Zeroing the width and height causes Firefox to release graphics
+ // resources immediately, which can greatly reduce memory consumption.
+ var zoomLayerCanvas = self.zoomLayer.firstChild;
+ zoomLayerCanvas.width = 0;
+ zoomLayerCanvas.height = 0;
+
div.removeChild(self.zoomLayer);
self.zoomLayer = null;
}
--
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