Ensure to call the pageDone callback after it's really done

This commit is contained in:
Julian Viereck 2011-09-09 09:24:31 -07:00
parent 342547831d
commit 90da4fc831

20
pdf.js
View File

@ -3386,13 +3386,12 @@ var Page = (function() {
// Firefox error reporting from XHR callbacks. // Firefox error reporting from XHR callbacks.
setTimeout(function() { setTimeout(function() {
var exc = null; var exc = null;
// try { try {
self.display(gfx); self.display(gfx, continuation);
self.stats.render = Date.now(); } catch (e) {
// } catch (e) { exc = e.toString();
// exc = e.toString(); continuation(exc);
// } }
continuation(exc);
}); });
}; };
@ -3446,7 +3445,7 @@ var Page = (function() {
); );
}, },
display: function(gfx) { display: function(gfx, callback) {
var xref = this.xref; var xref = this.xref;
var resources = xref.fetchIfRef(this.resources); var resources = xref.fetchIfRef(this.resources);
var mediaBox = xref.fetchIfRef(this.mediaBox); var mediaBox = xref.fetchIfRef(this.mediaBox);
@ -3460,8 +3459,13 @@ var Page = (function() {
var length = this.IRQueue.fnArray.length; var length = this.IRQueue.fnArray.length;
var IRQueue = this.IRQueue; var IRQueue = this.IRQueue;
var self = this;
function next() { function next() {
startIdx = gfx.executeIRQueue(IRQueue, startIdx, next); startIdx = gfx.executeIRQueue(IRQueue, startIdx, next);
if (startIdx == length) {
self.stats.render = Date.now();
callback();
}
} }
next(); next();
}, },