]> git.parisson.com Git - pdf.js.git/commitdiff
Address latest review comments by Artur
authorJulian Viereck <julian.viereck@gmail.com>
Thu, 13 Oct 2011 18:30:55 +0000 (20:30 +0200)
committerJulian Viereck <julian.viereck@gmail.com>
Thu, 13 Oct 2011 18:30:55 +0000 (20:30 +0200)
pdf.js
worker.js
worker/processor_handler.js

diff --git a/pdf.js b/pdf.js
index 85560087cbc11b65488430f324e487a6544510ca..97cedd2b0328328d3baf1f3f7cb6439e238c443f 100644 (file)
--- 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
index b4ac115879507b08413db48c54839be028c38a4a..c46f722860ac8f778e58a3d492afd77b7534bfd7 100644 (file)
--- 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;
     }
index 37ac3c76fd5b3aef6a4c0dff1ab904a34d50ccb8..6844168e6acec1d41de0f49b96dbe42d405933df 100644 (file)
@@ -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++) {