1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Merge upstream and change to error parameter for callback.

This commit is contained in:
Brendan Dahl 2011-12-02 10:19:43 -08:00
commit e0c231eec7
16 changed files with 500 additions and 182 deletions

View file

@ -70,7 +70,6 @@ var Page = (function pagePage() {
this.ctx = null;
this.callback = null;
this.errorback = null;
}
constructor.prototype = {
@ -164,7 +163,7 @@ var Page = (function pagePage() {
IRQueue, fonts) {
var self = this;
this.IRQueue = IRQueue;
var gfx = new CanvasGraphics(this.ctx, this.objs);
var gfx = new CanvasGraphics(this.ctx, this.objs, this.textLayer);
var displayContinuation = function pageDisplayContinuation() {
// Always defer call to display() to work around bug in
@ -173,8 +172,8 @@ var Page = (function pagePage() {
try {
self.display(gfx, self.callback);
} catch (e) {
if (self.errorback)
self.errorback(e);
if (self.callback)
self.callback(e);
else
throw e;
}
@ -251,6 +250,7 @@ var Page = (function pagePage() {
startIdx = gfx.executeIRQueue(IRQueue, startIdx, next);
if (startIdx == length) {
self.stats.render = Date.now();
gfx.endDrawing();
if (callback) callback();
}
}
@ -313,10 +313,10 @@ var Page = (function pagePage() {
}
return links;
},
startRendering: function pageStartRendering(ctx, callback, errorback) {
startRendering: function pageStartRendering(ctx, callback, textLayer) {
this.ctx = ctx;
this.callback = callback;
this.errorback = errorback;
this.textLayer = textLayer;
this.startRenderingTime = Date.now();
this.pdf.startRendering(this);
@ -569,20 +569,9 @@ var PDFDoc = (function pdfDoc() {
var properties = data[4];
if (file) {
// Rewrap the ArrayBuffer in a stream.
var fontFileDict = new Dict();
fontFileDict.map = file.dict.map;
var fontFile = new Stream(file.bytes, file.start,
file.end - file.start, fontFileDict);
// Check if this is a FlateStream. Otherwise just use the created
// Stream one. This makes complex_ttf_font.pdf work.
var cmf = file.bytes[0];
if ((cmf & 0x0f) == 0x08) {
file = new FlateStream(fontFile);
} else {
file = fontFile;
}
file = new Stream(file, 0, file.length, fontFileDict);
}
// For now, resolve the font object here direclty. The real font
@ -612,8 +601,8 @@ var PDFDoc = (function pdfDoc() {
messageHandler.on('page_error', function pdfDocError(data) {
var page = this.pageCache[data.pageNum];
if (page.errorback)
page.errorback(data.error);
if (page.callback)
page.callback(data.error);
else
throw data.error;
}, this);