From b832aa5c1ec3a9874b68f090f9ea0d852165a6a7 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Thu, 13 Oct 2011 20:30:55 +0200 Subject: [PATCH] Address latest review comments by Artur --- pdf.js | 18 +++++++++--------- worker.js | 12 +++++++----- worker/processor_handler.js | 18 ------------------ 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/pdf.js b/pdf.js index 85560087c..97cedd2b0 100644 --- a/pdf.js +++ b/pdf.js @@ -3548,13 +3548,13 @@ var Page = (function pagePage() { // Firefox error reporting from XHR callbacks. setTimeout(function pageSetTimeout() { var exc = null; - // try { + try { self.display(gfx, continuation); - // } catch (e) { - // exc = e.toString(); - // continuation(exc); - // throw e; - // } + } catch (e) { + exc = e.toString(); + continuation(exc); + throw e; + } }); }; @@ -4564,6 +4564,7 @@ var PartialEvaluator = (function partialEvaluator() { getIRQueue: function partialEvaluatorGetIRQueue(stream, resources, queue, dependency) { + var self = this; var xref = this.xref; var handler = this.handler; var uniquePrefix = this.uniquePrefix; @@ -4579,7 +4580,6 @@ var PartialEvaluator = (function partialEvaluator() { } } - var self = this; function handleSetFont(fontName, fontRef) { var loadedName = null; @@ -4784,7 +4784,7 @@ var PartialEvaluator = (function partialEvaluator() { // This adds the IRQueue of the xObj to the current queue. var depIdx = dependency.length; - this.getIRQueue(xobj, xobj.dict.get('Resources'), queue, + this.getIRQueue(xobj, xobj.dict.get('Resources'), queue, dependency); // Add the dependencies that are required to execute the @@ -5389,7 +5389,7 @@ function ScratchCanvas(width, height) { } var CanvasGraphics = (function canvasGraphics() { - // Defines the time the executeIRQueue gone be executing + // Defines the time the executeIRQueue gonna be executing // before it stops and shedules a continue of execution. var kExecutionTime = 50; // Number of IR commands to execute before checking diff --git a/worker.js b/worker.js index b4ac11587..c46f72286 100644 --- a/worker.js +++ b/worker.js @@ -7,8 +7,8 @@ var useWorker = false; var WorkerPage = (function() { - function constructor(workerPDF, page, objs) { - this.workerPDF = workerPDF; + function constructor(pdf, page, objs) { + this.pdf = pdf; this.page = page; this.objs = objs; @@ -39,7 +39,7 @@ var WorkerPage = (function() { // this.page.startRendering(ctx, callback, errback); this.startRenderingTime = Date.now(); - this.workerPDF.startRendering(this); + this.pdf.startRendering(this); }, startRenderingFromIRQueue: function(IRQueue, fonts) { @@ -53,7 +53,9 @@ var WorkerPage = (function() { console.log('page=%d - total time: time=%dms', pageNum, Date.now() - this.startRenderingTime); - this.callback(err); + if (this.callback) { + this.callback(err); + } }.bind(this); this.page.startRenderingFromIRQueue(gfx, IRQueue, fonts, callback); }, @@ -165,7 +167,7 @@ var PDFObjects = (function() { * Sets the data of an object but *doesn't* resolve it. */ setData: function(objId, data) { - // Watchout! If you call `this.ensureObj(objId, data)` you'll gone create + // Watchout! If you call `this.ensureObj(objId, data)` you'll gonna create // a *resolved* promise which shouldn't be the case! this.ensureObj(objId).data = data; } diff --git a/worker/processor_handler.js b/worker/processor_handler.js index 37ac3c76f..6844168e6 100644 --- a/worker/processor_handler.js +++ b/worker/processor_handler.js @@ -33,24 +33,6 @@ var WorkerProcessorHandler = { console.log('page=%d - getIRQueue: time=%dms, len=%d', pageNum, Date.now() - start, IRQueue.fnArray.length); - if (false /* show used commands */) { - var cmdMap = {}; - - var fnArray = IRQueue .fnArray; - for (var i = 0; i < fnArray.length; i++) { - var entry = fnArray[i]; - if (entry == 'paintReadyFormXObject') { - //console.log(preCompilation.argsArray[i]); - } - if (cmdMap[entry] == null) { - cmdMap[entry] = 1; - } else { - cmdMap[entry] += 1; - } - } - console.log('cmds', JSON.stringify(cmdMap)); - } - // Filter the dependecies for fonts. var fonts = {}; for (var i = 0; i < dependency.length; i++) {