Fix lint warnings.
This commit is contained in:
parent
a6c3a46ab4
commit
753bfcf7c7
27
extensions/firefox/bootstrap.js
vendored
27
extensions/firefox/bootstrap.js
vendored
@ -1,31 +1,36 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
let Cc = Components.classes;
|
||||
let Ci = Components.interfaces;
|
||||
let Cm = Components.manager;
|
||||
let Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
|
||||
function log(str) {
|
||||
dump(str + "\n");
|
||||
};
|
||||
dump(str + '\n');
|
||||
}
|
||||
|
||||
function startup(aData, aReason) {
|
||||
let manifestPath = "chrome.manifest";
|
||||
let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
|
||||
let manifestPath = 'chrome.manifest';
|
||||
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
|
||||
try {
|
||||
file.initWithPath(aData.installPath.path);
|
||||
file.append(manifestPath);
|
||||
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file);
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function shutdown(aData, aReason) {
|
||||
};
|
||||
}
|
||||
|
||||
function install(aData, aReason) {
|
||||
let url = "chrome://pdf.js/content/web/viewer.html?file=%s";
|
||||
Services.prefs.setCharPref("extensions.pdf.js.url", url);
|
||||
};
|
||||
let url = 'chrome://pdf.js/content/web/viewer.html?file=%s';
|
||||
Services.prefs.setCharPref('extensions.pdf.js.url', url);
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,33 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
|
||||
const PDF_CONTENT_TYPE = "application/pdf";
|
||||
const PDF_CONTENT_TYPE = 'application/pdf';
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
Cu.import('resource://gre/modules/Services.jsm');
|
||||
|
||||
// TODO
|
||||
// Add some download progress event
|
||||
|
||||
function log(aMsg) {
|
||||
let msg = "pdfContentHandler.js: " + (aMsg.join ? aMsg.join("") : aMsg);
|
||||
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
|
||||
let msg = 'pdfContentHandler.js: ' + (aMsg.join ? aMsg.join('') : aMsg);
|
||||
Cc['@mozilla.org/consoleservice;1'].getService(Ci.nsIConsoleService)
|
||||
.logStringMessage(msg);
|
||||
dump(msg + "\n");
|
||||
};
|
||||
dump(msg + '\n');
|
||||
}
|
||||
|
||||
function loadDocument(aWindow, aDocumentUrl) {
|
||||
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
||||
let xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1']
|
||||
.createInstance(Ci.nsIXMLHttpRequest);
|
||||
xhr.open("GET", aDocumentUrl);
|
||||
xhr.mozResponseType = xhr.responseType = "arraybuffer";
|
||||
xhr.open('GET', aDocumentUrl);
|
||||
xhr.mozResponseType = xhr.responseType = 'arraybuffer';
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4 && xhr.status == 200) {
|
||||
let data = (xhr.mozResponseArrayBuffer || xhr.mozResponse ||
|
||||
@ -30,23 +35,23 @@ function loadDocument(aWindow, aDocumentUrl) {
|
||||
try {
|
||||
var view = new Uint8Array(data);
|
||||
|
||||
// I think accessing aWindow.wrappedJSObject returns a
|
||||
// I think accessing aWindow.wrappedJSObject returns a
|
||||
// XPCSafeJSObjectWrapper and so it is safe but mrbkap can confirm that
|
||||
let window = aWindow.wrappedJSObject;
|
||||
var arrayBuffer = new window.ArrayBuffer(data.byteLength);
|
||||
var view2 = new window.Uint8Array(arrayBuffer);
|
||||
view2.set(view);
|
||||
|
||||
let evt = window.document.createEvent("CustomEvent");
|
||||
evt.initCustomEvent("pdfloaded", false, false, arrayBuffer);
|
||||
let evt = window.document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent('pdfloaded', false, false, arrayBuffer);
|
||||
window.document.dispatchEvent(evt);
|
||||
} catch(e) {
|
||||
log("Error - " + e);
|
||||
} catch (e) {
|
||||
log('Error - ' + e);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
};
|
||||
}
|
||||
|
||||
let WebProgressListener = {
|
||||
init: function(aWindow, aUrl) {
|
||||
@ -64,11 +69,12 @@ let WebProgressListener = {
|
||||
.getInterface(Ci.nsIWebProgress);
|
||||
try {
|
||||
webProgress.removeProgressListener(this);
|
||||
} catch(e) {}
|
||||
} catch (e) {}
|
||||
webProgress.addProgressListener(this, flags);
|
||||
},
|
||||
|
||||
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
|
||||
onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags,
|
||||
aStatus) {
|
||||
const complete = Ci.nsIWebProgressListener.STATE_IS_WINDOW +
|
||||
Ci.nsIWebProgressListener.STATE_STOP;
|
||||
if ((aStateFlags & complete) == complete && this._locationHasChanged) {
|
||||
@ -77,14 +83,17 @@ let WebProgressListener = {
|
||||
}
|
||||
},
|
||||
|
||||
onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf, aMaxSelf, aCurTotal, aMaxTotal) {
|
||||
onProgressChange: function onProgressChange(aWebProgress, aRequest, aCurSelf,
|
||||
aMaxSelf, aCurTotal, aMaxTotal) {
|
||||
},
|
||||
|
||||
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocationURI) {
|
||||
onLocationChange: function onLocationChange(aWebProgress, aRequest,
|
||||
aLocationURI) {
|
||||
this._locationHasChanged = true;
|
||||
},
|
||||
|
||||
onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
|
||||
onStatusChange: function onStatusChange(aWebProgress, aRequest, aStatus,
|
||||
aMessage) {
|
||||
},
|
||||
|
||||
onSecurityChange: function onSecurityChange(aWebProgress, aRequest, aState) {
|
||||
@ -127,16 +136,16 @@ pdfContentHandler.prototype = {
|
||||
WebProgressListener.init(window, uri.spec);
|
||||
|
||||
try {
|
||||
let url = Services.prefs.getCharPref("extensions.pdf.js.url");
|
||||
url = url.replace("%s", uri.spec);
|
||||
let url = Services.prefs.getCharPref('extensions.pdf.js.url');
|
||||
url = url.replace('%s', uri.spec);
|
||||
window.location = url;
|
||||
} catch(e) {
|
||||
log("Error - " + e);
|
||||
} catch (e) {
|
||||
log('Error - ' + e);
|
||||
}
|
||||
},
|
||||
|
||||
classID: Components.ID("{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler]),
|
||||
classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'),
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentHandler])
|
||||
};
|
||||
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([pdfContentHandler]);
|
||||
|
8
pdf.js
8
pdf.js
@ -3830,7 +3830,7 @@ var Catalog = (function catalogCatalog() {
|
||||
})();
|
||||
|
||||
var PDFDoc = (function pdfDoc() {
|
||||
function constructor(arg, callback) {
|
||||
function constructor(arg, callback) {
|
||||
// Stream argument
|
||||
if (typeof arg.isStream !== 'undefined') {
|
||||
init.call(this, arg);
|
||||
@ -3841,10 +3841,10 @@ var PDFDoc = (function pdfDoc() {
|
||||
}
|
||||
else {
|
||||
error('Unknown argument type');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init(stream){
|
||||
function init(stream) {
|
||||
assertWellFormed(stream.length > 0, 'stream must have data');
|
||||
this.stream = stream;
|
||||
this.setup();
|
||||
@ -3865,7 +3865,7 @@ var PDFDoc = (function pdfDoc() {
|
||||
stream.pos += index;
|
||||
return true; /* found */
|
||||
}
|
||||
|
||||
|
||||
constructor.prototype = {
|
||||
get linearization() {
|
||||
var length = this.stream.length;
|
||||
|
Loading…
Reference in New Issue
Block a user