]> git.parisson.com Git - pdf.js.git/commitdiff
Small fixes + docs
authorJulian Viereck <julian.viereck@gmail.com>
Sat, 8 Oct 2011 15:08:17 +0000 (17:08 +0200)
committerJulian Viereck <julian.viereck@gmail.com>
Sat, 8 Oct 2011 15:08:17 +0000 (17:08 +0200)
pdf.js
test/test_slave.html
web/viewer.js
worker.js

diff --git a/pdf.js b/pdf.js
index f44fcb47455da237fb7815e73dac6c874bce790e..35b6870631910c5703b8a5d95793481f0b5c5a72 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3861,6 +3861,16 @@ var Catalog = (function catalogCatalog() {
   return constructor;
 })();
 
+/**
+ * The `PDFDocModel` holds all the data of the PDF file. Compared to the 
+ * `PDFDoc`, this one doesn't have any job management code.
+ * Right now there exists one PDFDocModel on the main thread + one object
+ * for each worker. If there is no worker support enabled, there are two
+ * `PDFDocModel` objects on the main thread created.
+ * TODO: Refactor the internal object structure, such that there is no
+ * need for the `PDFDocModel` anymore and there is only one object on the
+ * main thread and not one entire copy on each worker instance.
+ */
 var PDFDocModel = (function pdfDoc() {
   function constructor(arg, callback) {
     // Stream argument
index ace21e133a5553b1c22e875fe773a48ffc0666fb..9e5a054c68408c5042e4f57d685382899dba6a97 100644 (file)
@@ -13,7 +13,6 @@
   <script type="text/javascript" src="../worker.js"></script>
   <script type="text/javascript" src="../worker/message_handler.js"></script>
   <script type="text/javascript" src="../worker/processor_handler.js"></script>
-  <script type="text/javascript" src="../worker/font_handler.js"></script>
 </head>
 
 <body onload="load();">
index 11db7cc79245ec04a9d6529f1374ecc03b9635e4..7e5186073a0d743d45051e25d001a9bfc3384b97 100644 (file)
@@ -181,7 +181,7 @@ var PDFView = {
     while (container.hasChildNodes())
       container.removeChild(container.lastChild);
 
-    var pdf = new WorkerPDFDoc(data);
+    var pdf = new PDFDoc(data);
     var pagesCount = pdf.numPages;
     document.getElementById('numPages').innerHTML = pagesCount;
     document.getElementById('pageNumber').max = pagesCount;
index 5f74d2daf9718c5e032fe76da5cfaa82b448aa99..9aaf294100c7da3ff1b7312206548add81debd29 100644 (file)
--- a/worker.js
+++ b/worker.js
@@ -66,6 +66,12 @@ var WorkerPage = (function() {
   return constructor;
 })();
 
+/**
+ * A PDF document and page is build up of many objects. E.g. there are objects
+ * for fonts, images, rendering code and such. These objects might get processed
+ * inside of a worker. The `PDFObjects` implements some basic functions to manage
+ * these objects.
+ */
 var PDFObjects = (function() {
   function PDFObjects() {
     this.objs = {};
@@ -75,6 +81,7 @@ var PDFObjects = (function() {
     objs: null,
 
     /**
+     * Internal function.
      * Ensures there is an object defined for `objId`. Stores `data` on the
      * object *if* it is created.
      */
@@ -169,6 +176,15 @@ var PDFObjects = (function() {
 
 /**
  * "Promise" object.
+ * Each object that is stored in PDFObjects is based on a Promise object that
+ * contains the status of the object and the data. There migth be situations,
+ * where a function want to use the value of an object, but it isn't ready at
+ * that time. To get a notification, once the object is ready to be used, s.o.
+ * can add a callback using the `then` method on the promise that then calls
+ * the callback once the object gets resolved.
+ * A promise can get resolved only once and only once the data of the promise
+ * can be set. If any of these happens twice or the data is required before
+ * it was set, an exception is throw.
  */
 var Promise = (function() {
   var EMPTY_PROMISE = {};