@ -105,7 +105,7 @@ var PDFPageView = (function PDFPageViewClosure() {
}
}
} ,
} ,
reset : function PDFPageView _reset ( keepAnnotations ) {
reset : function PDFPageView _reset ( keepZoomLayer , keep Annotations ) {
if ( this . renderTask ) {
if ( this . renderTask ) {
this . renderTask . cancel ( ) ;
this . renderTask . cancel ( ) ;
}
}
@ -117,12 +117,12 @@ var PDFPageView = (function PDFPageViewClosure() {
div . style . height = Math . floor ( this . viewport . height ) + 'px' ;
div . style . height = Math . floor ( this . viewport . height ) + 'px' ;
var childNodes = div . childNodes ;
var childNodes = div . childNodes ;
var currentZoomLayer = this . zoomLayer || null ;
var currentZoomLayerNode = ( keepZoomLayer && this . zoomLayer ) || null ;
var currentAnnotationNode = ( keepAnnotations && this . annotationLayer &&
var currentAnnotationNode = ( keepAnnotations && this . annotationLayer &&
this . annotationLayer . div ) || null ;
this . annotationLayer . div ) || null ;
for ( var i = childNodes . length - 1 ; i >= 0 ; i -- ) {
for ( var i = childNodes . length - 1 ; i >= 0 ; i -- ) {
var node = childNodes [ i ] ;
var node = childNodes [ i ] ;
if ( currentZoomLayer === node || currentAnnotationNode === node ) {
if ( currentZoomLayerNode === node || currentAnnotationNode === node ) {
continue ;
continue ;
}
}
div . removeChild ( node ) ;
div . removeChild ( node ) ;
@ -139,7 +139,7 @@ var PDFPageView = (function PDFPageViewClosure() {
this . annotationLayer = null ;
this . annotationLayer = null ;
}
}
if ( this . canvas ) {
if ( this . canvas && ! currentZoomLayerNode ) {
// 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 ;
@ -190,7 +190,7 @@ var PDFPageView = (function PDFPageViewClosure() {
if ( this . zoomLayer ) {
if ( this . zoomLayer ) {
this . cssTransform ( this . zoomLayer . firstChild ) ;
this . cssTransform ( this . zoomLayer . firstChild ) ;
}
}
this . reset ( true ) ;
this . reset ( /* keepZoomLayer = */ true , true ) ;
} ,
} ,
/ * *
/ * *
@ -401,6 +401,12 @@ var PDFPageView = (function PDFPageViewClosure() {
}
}
if ( self . zoomLayer ) {
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 ) ;
div . removeChild ( self . zoomLayer ) ;
self . zoomLayer = null ;
self . zoomLayer = null ;
}
}