[Pkg-javascript-commits] [pdf.js] 52/139: Fix code style in extensions/firefox/content/PdfStreamConverter.jsm

David Prévot taffit at moszumanska.debian.org
Fri Jan 9 21:18:26 UTC 2015


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

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

commit 4da57c3b853d569dd8ff92adeebadf2fa56c7bcb
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Aug 26 16:53:28 2014 +0200

    Fix code style in extensions/firefox/content/PdfStreamConverter.jsm
---
 extensions/firefox/content/PdfStreamConverter.jsm | 47 ++++++++++++++---------
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/extensions/firefox/content/PdfStreamConverter.jsm b/extensions/firefox/content/PdfStreamConverter.jsm
index 22d114e..b335ef2 100644
--- a/extensions/firefox/content/PdfStreamConverter.jsm
+++ b/extensions/firefox/content/PdfStreamConverter.jsm
@@ -16,7 +16,7 @@
  */
 /* jshint esnext:true */
 /* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils,
-           dump, NetworkManager, PdfJsTelemetry */
+           dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */
 
 'use strict';
 
@@ -153,21 +153,24 @@ function getLocalizedStrings(path) {
       property = key.substring(i + 1);
       key = key.substring(0, i);
     }
-    if (!(key in map))
+    if (!(key in map)) {
       map[key] = {};
+    }
     map[key][property] = string.value;
   }
   return map;
 }
 function getLocalizedString(strings, id, property) {
   property = property || 'textContent';
-  if (id in strings)
+  if (id in strings) {
     return strings[id][property];
+  }
   return id;
 }
 
 function makeContentReadable(obj, window) {
 //#if MOZCENTRAL
+  /* jshint -W027 */
   return Cu.cloneInto(obj, window);
 //#else
   if (Cu.cloneInto) {
@@ -178,7 +181,7 @@ function makeContentReadable(obj, window) {
   }
   var expose = {};
   for (let k in obj) {
-    expose[k] = "r";
+    expose[k] = 'r';
   }
   obj.__exposedProps__ = expose;
   return obj;
@@ -274,7 +277,7 @@ ChromeActions.prototype = {
     // the original url.
     var originalUri = NetUtil.newURI(data.originalUrl);
     var filename = data.filename;
-    if (typeof filename !== 'string' || 
+    if (typeof filename !== 'string' ||
         (!/\.pdf$/i.test(filename) && !data.isAttachment)) {
       filename = 'document.pdf';
     }
@@ -293,8 +296,9 @@ ChromeActions.prototype = {
     }
     NetUtil.asyncFetch(netChannel, function(aInputStream, aResult) {
       if (!Components.isSuccessCode(aResult)) {
-        if (sendResponse)
+        if (sendResponse) {
           sendResponse(true);
+        }
         return;
       }
       // Create a nsIInputStreamChannel so we can set the url on the channel
@@ -328,11 +332,13 @@ ChromeActions.prototype = {
           this.extListener.onStartRequest(aRequest, aContext);
         },
         onStopRequest: function(aRequest, aContext, aStatusCode) {
-          if (this.extListener)
+          if (this.extListener) {
             this.extListener.onStopRequest(aRequest, aContext, aStatusCode);
+          }
           // Notify the content code we're done downloading.
-          if (sendResponse)
+          if (sendResponse) {
             sendResponse(false);
+          }
         },
         onDataAvailable: function(aRequest, aContext, aInputStream, aOffset,
                                   aCount) {
@@ -350,9 +356,9 @@ ChromeActions.prototype = {
   getStrings: function(data) {
     try {
       // Lazy initialization of localizedStrings
-      if (!('localizedStrings' in this))
+      if (!('localizedStrings' in this)) {
         this.localizedStrings = getLocalizedStrings('viewer.properties');
-
+      }
       var result = this.localizedStrings[data];
       return JSON.stringify(result || null);
     } catch (e) {
@@ -405,10 +411,10 @@ ChromeActions.prototype = {
         if (!documentStats || typeof documentStats !== 'object') {
           break;
         }
-        var streamTypes = documentStats.streamTypes;
+        var i, streamTypes = documentStats.streamTypes;
         if (Array.isArray(streamTypes)) {
           var STREAM_TYPE_ID_LIMIT = 20;
-          for (var i = 0; i < STREAM_TYPE_ID_LIMIT; i++) {
+          for (i = 0; i < STREAM_TYPE_ID_LIMIT; i++) {
             if (streamTypes[i] &&
                 !this.telemetryState.streamTypesUsed[i]) {
               PdfJsTelemetry.onStreamType(i);
@@ -419,7 +425,7 @@ ChromeActions.prototype = {
         var fontTypes = documentStats.fontTypes;
         if (Array.isArray(fontTypes)) {
           var FONT_TYPE_ID_LIMIT = 20;
-          for (var i = 0; i < FONT_TYPE_ID_LIMIT; i++) {
+          for (i = 0; i < FONT_TYPE_ID_LIMIT; i++) {
             if (fontTypes[i] &&
                 !this.telemetryState.fontTypesUsed[i]) {
               PdfJsTelemetry.onFontType(i);
@@ -452,8 +458,9 @@ ChromeActions.prototype = {
       getLocalizedString(strings, 'open_with_different_viewer', 'accessKey'));
   },
   updateFindControlState: function(data) {
-    if (!this.supportsIntegratedFind())
+    if (!this.supportsIntegratedFind()) {
       return;
+    }
     // Verify what we're sending to the findbar.
     var result = data.result;
     var findPrevious = data.findPrevious;
@@ -738,11 +745,11 @@ RequestListener.prototype.receive = function(event) {
     log('Unknown action: ' + action);
     return;
   }
+  var response;
   if (sync) {
-    var response = actions[action].call(this.actions, data);
+    response = actions[action].call(this.actions, data);
     event.detail.response = response;
   } else {
-    var response;
     if (!event.detail.responseExpected) {
       doc.documentElement.removeChild(message);
       response = null;
@@ -750,7 +757,8 @@ RequestListener.prototype.receive = function(event) {
       response = function sendResponse(response) {
         try {
           var listener = doc.createEvent('CustomEvent');
-          let detail = makeContentReadable({response: response}, doc.defaultView);
+          let detail = makeContentReadable({response: response},
+                                           doc.defaultView);
           listener.initCustomEvent('pdf.js.response', true, false, detail);
           return message.dispatchEvent(listener);
         } catch (e) {
@@ -1024,10 +1032,11 @@ PdfStreamConverter.prototype = {
       return;
     }
 
-    if (Components.isSuccessCode(aStatusCode))
+    if (Components.isSuccessCode(aStatusCode)) {
       this.dataListener.finish();
-    else
+    } else {
       this.dataListener.error(aStatusCode);
+    }
     delete this.dataListener;
     delete this.binaryStream;
   }

-- 
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