Cleaning up fonts when viewer is idle for some time

This commit is contained in:
Yury Delendik 2013-11-14 13:43:38 -08:00
parent 945e370d4f
commit e712c4136a
9 changed files with 93 additions and 9 deletions

View file

@ -38,6 +38,7 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
var SCALE_SELECT_PADDING = 22;
var THUMBNAIL_SCROLL_MARGIN = -19;
var USE_ONLY_CSS_ZOOM = false;
var CLEANUP_TIMEOUT = 30000;
//#if B2G
//USE_ONLY_CSS_ZOOM = true;
//#endif
@ -106,6 +107,7 @@ var PDFView = {
lastScroll: 0,
previousPageNumber: 1,
isViewerEmbedded: (window.parent !== window),
idleTimeout: null,
// called once when the document is loaded
initialize: function pdfViewInitialize() {
@ -1011,6 +1013,11 @@ var PDFView = {
},
renderHighestPriority: function pdfViewRenderHighestPriority() {
if (PDFView.idleTimeout) {
clearTimeout(PDFView.idleTimeout);
PDFView.idleTimeout = null;
}
// Pages have a higher priority than thumbnails, so check them first.
var visiblePages = this.getVisiblePages();
var pageView = this.getHighestPriority(visiblePages, this.pages,
@ -1025,9 +1032,24 @@ var PDFView = {
var thumbView = this.getHighestPriority(visibleThumbs,
this.thumbnails,
this.thumbnailViewScroll.down);
if (thumbView)
if (thumbView) {
this.renderView(thumbView, 'thumbnail');
return;
}
}
PDFView.idleTimeout = setTimeout(function () {
PDFView.cleanup();
}, CLEANUP_TIMEOUT);
},
cleanup: function pdfViewCleanup() {
for (var i = 0, ii = this.pages.length; i < ii; i++) {
if (this.pages[i]) {
this.pages[i].resetRenderingState();
}
}
this.pdfDocument.cleanup();
},
getHighestPriority: function pdfViewGetHighestPriority(visible, views,