Merge pull request #3911 from yurydelendik/mem-redux2

Cleaning up fonts when viewer is idle for some time
This commit is contained in:
Brendan Dahl 2013-11-18 13:01:23 -08:00
commit 3132c9e7e9
9 changed files with 93 additions and 9 deletions

View file

@ -276,6 +276,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
dataLoaded: function PDFDocumentProxy_dataLoaded() {
return this.transport.dataLoaded();
},
cleanup: function PDFDocumentProxy_cleanup() {
this.transport.startCleanup();
},
destroy: function PDFDocumentProxy_destroy() {
this.transport.destroy();
}
@ -907,6 +910,21 @@ var WorkerTransport = (function WorkerTransportClosure() {
}
);
return promise;
},
startCleanup: function WorkerTransport_startCleanup() {
this.messageHandler.send('Cleanup', null,
function endCleanup() {
for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
var page = this.pageCache[i];
if (page) {
page.destroy();
}
}
this.commonObjs.clear();
FontLoader.clear();
}.bind(this)
);
}
};
return WorkerTransport;

View file

@ -33,6 +33,12 @@ var FontLoader = {
var styleSheet = styleElement.sheet;
styleSheet.insertRule(rule, styleSheet.cssRules.length);
},
clear: function fontLoaderClear() {
var styleElement = document.getElementById('PDFJS_FONT_STYLE_TAG');
if (styleElement) {
styleElement.parentNode.removeChild(styleElement);
}
},
//#if !(MOZCENTRAL)
get loadTestFont() {
// This is a CFF font with 1 glyph for '.' that fills its entire width and