[Pkg-javascript-commits] [pdf.js] 48/161: Fix coding style in src/display/api.js

David Prévot taffit at moszumanska.debian.org
Sat Apr 19 14:16:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit a1ee567d60cf87a6d13d928655e0ffc67bd21fac
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri Mar 14 13:24:04 2014 +0100

    Fix coding style in src/display/api.js
---
 src/display/api.js | 94 ++++++++++++++++++++++++++++++------------------------
 1 file changed, 52 insertions(+), 42 deletions(-)

diff --git a/src/display/api.js b/src/display/api.js
index 5f3a129..aa08313 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -27,14 +27,15 @@
  * above this value will not be drawn. Use -1 for no limit.
  * @var {number}
  */
-PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
+PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
+                      -1 : PDFJS.maxImageSize);
 
 /**
  * The url of where the predefined Adobe CMaps are located. Include trailing
  * slash.
  * @var {string}
  */
-PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
+PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
 
 /*
  * By default fonts are converted to OpenType fonts and loaded via font face
@@ -42,16 +43,16 @@ PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  * that constructs the glyphs with primitive path commands.
  * @var {boolean}
  */
-PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ?
-                        false : PDFJS.disableFontFace;
+PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
+                         false : PDFJS.disableFontFace);
 
 /**
  * Path for image resources, mainly for annotation icons. Include trailing
  * slash.
  * @var {string}
  */
-PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
-                           '' : PDFJS.imageResourcesPath;
+PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ?
+                            '' : PDFJS.imageResourcesPath);
 
 /**
  * Disable the web worker and run all code on the main thread. This will happen
@@ -59,8 +60,8 @@ PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
  * to workers.
  * @var {boolean}
  */
-PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
-                      false : PDFJS.disableWorker;
+PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
+                       false : PDFJS.disableWorker);
 
 /**
  * Path and filename of the worker file. Required when the worker is enabled in
@@ -68,7 +69,7 @@ PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
  * loaded based on the location of the pdf.js file.
  * @var {string}
  */
-PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
+PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
 
 /**
  * Disable range request loading of PDF files. When enabled and if the server
@@ -76,8 +77,8 @@ PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  * Enabled (false) by default.
  * @var {boolean}
  */
-PDFJS.disableRange = PDFJS.disableRange === undefined ?
-                     false : PDFJS.disableRange;
+PDFJS.disableRange = (PDFJS.disableRange === undefined ?
+                      false : PDFJS.disableRange);
 
 /**
  * Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
@@ -85,28 +86,28 @@ PDFJS.disableRange = PDFJS.disableRange === undefined ?
  * the current page. This default behavior can be disabled.
  * @var {boolean}
  */
-PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ?
-                         false : PDFJS.disableAutoFetch;
+PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
+                          false : PDFJS.disableAutoFetch);
 
 /**
  * Enables special hooks for debugging PDF.js.
  * @var {boolean}
  */
-PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
+PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
 
 /**
  * Enables transfer usage in postMessage for ArrayBuffers.
  * @var {boolean}
  */
-PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ?
-                             true : PDFJS.postMessageTransfers;
+PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
+                              true : PDFJS.postMessageTransfers);
 
 /**
  * Disables URL.createObjectURL usage.
  * @var {boolean}
  */
-PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ?
-                               false : PDFJS.disableCreateObjectURL;
+PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
+                                false : PDFJS.disableCreateObjectURL);
 
 /**
  * Controls the logging level.
@@ -116,8 +117,8 @@ PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ?
  * - infos
  * @var {number}
  */
-PDFJS.verbosity = PDFJS.verbosity === undefined ?
-                  PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity;
+PDFJS.verbosity = (PDFJS.verbosity === undefined ?
+                   PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity);
 
 /**
  * Document initialization / loading parameters object.
@@ -172,8 +173,9 @@ PDFJS.getDocument = function getDocument(source,
           'string or a parameter object');
   }
 
-  if (!source.url && !source.data)
+  if (!source.url && !source.data) {
     error('Invalid parameter array, need either .data or .url');
+  }
 
   // copy/use all keys as is except 'url' -- full path is required
   var params = {};
@@ -187,8 +189,8 @@ PDFJS.getDocument = function getDocument(source,
 
   workerInitializedPromise = new PDFJS.LegacyPromise();
   workerReadyPromise = new PDFJS.LegacyPromise();
-  transport = new WorkerTransport(workerInitializedPromise,
-      workerReadyPromise, pdfDataRangeTransport, progressCallback);
+  transport = new WorkerTransport(workerInitializedPromise, workerReadyPromise,
+                                  pdfDataRangeTransport, progressCallback);
   workerInitializedPromise.then(function transportInitialized() {
     transport.passwordCallback = passwordCallback;
     transport.fetchDocument(params);
@@ -287,7 +289,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
       var metadata = this.pdfInfo.metadata;
       promise.resolve({
         info: info,
-        metadata: metadata ? new PDFJS.Metadata(metadata) : null
+        metadata: (metadata ? new PDFJS.Metadata(metadata) : null)
       });
       return promise;
     },
@@ -387,8 +389,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
      * with transforms required for rendering.
      */
     getViewport: function PDFPageProxy_getViewport(scale, rotate) {
-      if (arguments.length < 2)
+      if (arguments.length < 2) {
         rotate = this.rotate;
+      }
       return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
     },
     /**
@@ -396,8 +399,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
      * annotation objects.
      */
     getAnnotations: function PDFPageProxy_getAnnotations() {
-      if (this.annotationsPromise)
+      if (this.annotationsPromise) {
         return this.annotationsPromise;
+      }
 
       var promise = new PDFJS.LegacyPromise();
       this.annotationsPromise = promise;
@@ -429,9 +433,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
       // this call to render.
       this.pendingDestroy = false;
 
-      var renderingIntent = 'intent' in params ?
-        (params.intent == 'print' ? 'print' : 'display') :
-        'display';
+      var renderingIntent = ('intent' in params ?
+        (params.intent == 'print' ? 'print' : 'display') : 'display');
 
       if (!this.intentStates[renderingIntent]) {
         this.intentStates[renderingIntent] = {};
@@ -457,9 +460,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
       }
 
       var internalRenderTask = new InternalRenderTask(complete, params,
-                                       this.objs, this.commonObjs,
-                                       intentState.operatorList,
-                                       this.pageNumber);
+                                                      this.objs,
+                                                      this.commonObjs,
+                                                      intentState.operatorList,
+                                                      this.pageNumber);
       if (!intentState.renderTasks) {
         intentState.renderTasks = [];
       }
@@ -535,8 +539,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
       if (!this.pendingDestroy ||
           Object.keys(this.intentStates).some(function(intent) {
             var intentState = this.intentStates[intent];
-            return intentState.renderTasks.length !== 0 ||
-                   intentState.receivingOperatorList;
+            return (intentState.renderTasks.length !== 0 ||
+                    intentState.receivingOperatorList);
           }, this)) {
         return;
       }
@@ -591,7 +595,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
  */
 var WorkerTransport = (function WorkerTransportClosure() {
   function WorkerTransport(workerInitializedPromise, workerReadyPromise,
-      pdfDataRangeTransport, progressCallback) {
+                           pdfDataRangeTransport, progressCallback) {
     this.pdfDataRangeTransport = pdfDataRangeTransport;
 
     this.workerReadyPromise = workerReadyPromise;
@@ -815,8 +819,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
       messageHandler.on('commonobj', function transportObj(data) {
         var id = data[0];
         var type = data[1];
-        if (this.commonObjs.hasData(id))
+        if (this.commonObjs.hasData(id)) {
           return;
+        }
 
         switch (type) {
           case 'Font':
@@ -893,17 +898,19 @@ var WorkerTransport = (function WorkerTransportClosure() {
       messageHandler.on('PageError', function transportError(data, intent) {
         var page = this.pageCache[data.pageNum - 1];
         var intentState = page.intentStates[intent];
-        if (intentState.displayReadyPromise)
+        if (intentState.displayReadyPromise) {
           intentState.displayReadyPromise.reject(data.error);
-        else
+        } else {
           error(data.error);
+        }
       }, this);
 
       messageHandler.on('JpegDecode', function(data, deferred) {
         var imageUrl = data[0];
         var components = data[1];
-        if (components != 3 && components != 1)
+        if (components != 3 && components != 1) {
           error('Only 3 component or 1 component can be returned');
+        }
 
         var img = new Image();
         img.onload = (function messageHandler_onloadClosure() {
@@ -963,8 +970,9 @@ var WorkerTransport = (function WorkerTransportClosure() {
       }
 
       var pageIndex = pageNumber - 1;
-      if (pageIndex in this.pagePromises)
+      if (pageIndex in this.pagePromises) {
         return this.pagePromises[pageIndex];
+      }
       var promise = new PDFJS.LegacyPromise();
       this.pagePromises[pageIndex] = promise;
       this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
@@ -1033,8 +1041,9 @@ var PDFObjects = (function PDFObjectsClosure() {
      * Ensures there is an object defined for `objId`.
      */
     ensureObj: function PDFObjects_ensureObj(objId) {
-      if (this.objs[objId])
+      if (this.objs[objId]) {
         return this.objs[objId];
+      }
 
       var obj = {
         promise: new LegacyPromise(),
@@ -1069,8 +1078,9 @@ var PDFObjects = (function PDFObjectsClosure() {
 
       // If there isn't an object yet or the object isn't resolved, then the
       // data isn't ready yet!
-      if (!obj || !obj.resolved)
+      if (!obj || !obj.resolved) {
         error('Requesting object that isn\'t resolved yet ' + objId);
+      }
 
       return obj.data;
     },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list