Address brendan's comments
This commit is contained in:
parent
dbccbaaa27
commit
27fe18e8c6
@ -305,9 +305,6 @@ ChromeActions.prototype = {
|
||||
getLocale: function() {
|
||||
return getStringPref('general.useragent.locale', 'en-US');
|
||||
},
|
||||
getLoadingType: function() {
|
||||
return 'passive';
|
||||
},
|
||||
getStrings: function(data) {
|
||||
try {
|
||||
// Lazy initialization of localizedStrings
|
||||
|
@ -531,7 +531,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
translated = this.translateFont(font, xref);
|
||||
} catch (e) {
|
||||
if (e instanceof MissingDataException) {
|
||||
font.loadedName = undefined;
|
||||
font.loadedName = null;
|
||||
throw e;
|
||||
}
|
||||
translated = new ErrorFont(e instanceof Error ? e.message : e);
|
||||
|
@ -30,29 +30,23 @@ var BasePdfManager = (function BasePdfManagerClosure() {
|
||||
throw new NotImplementedException();
|
||||
},
|
||||
|
||||
ensureModel: function BasePdfManager_ensureModel(prop) {
|
||||
var args = [].slice.call(arguments);
|
||||
args.unshift(this.pdfModel);
|
||||
return this.ensure.apply(this, args);
|
||||
ensureModel: function BasePdfManager_ensureModel(prop, args) {
|
||||
return this.ensure(this.pdfModel, prop, args);
|
||||
},
|
||||
|
||||
ensureXRef: function BasePdfManager_ensureXRef(prop) {
|
||||
var args = [].slice.call(arguments);
|
||||
args.unshift(this.pdfModel.xref);
|
||||
return this.ensure.apply(this, args);
|
||||
ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
|
||||
return this.ensure(this.pdfModel.xref, prop, args);
|
||||
},
|
||||
|
||||
ensureCatalog: function BasePdfManager_ensureCatalog(prop) {
|
||||
var args = [].slice.call(arguments);
|
||||
args.unshift(this.pdfModel.catalog);
|
||||
return this.ensure.apply(this, args);
|
||||
ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
|
||||
return this.ensure(this.pdfModel.catalog, prop, args);
|
||||
},
|
||||
|
||||
getPage: function BasePdfManager_pagePage(pageIndex) {
|
||||
return this.pdfModel.getPage(pageIndex);
|
||||
},
|
||||
|
||||
ensure: function BasePdfManager_ensure(obj, prop) {
|
||||
ensure: function BasePdfManager_ensure(obj, prop, args) {
|
||||
return new NotImplementedException();
|
||||
},
|
||||
|
||||
@ -76,13 +70,12 @@ var LocalPdfManager = (function LocalPdfManagerClosure() {
|
||||
LocalPdfManager.prototype.constructor = LocalPdfManager;
|
||||
|
||||
LocalPdfManager.prototype.ensure =
|
||||
function LocalPdfManager_ensure(obj, prop) {
|
||||
function LocalPdfManager_ensure(obj, prop, args) {
|
||||
var promise = new PDFJS.Promise();
|
||||
var result;
|
||||
var value = obj[prop];
|
||||
try {
|
||||
var value = obj[prop];
|
||||
var result;
|
||||
if (typeof(value) === 'function') {
|
||||
var args = [].slice.call(arguments, 2);
|
||||
result = value.apply(obj, args);
|
||||
} else {
|
||||
result = value;
|
||||
@ -109,7 +102,7 @@ var LocalPdfManager = (function LocalPdfManagerClosure() {
|
||||
|
||||
var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
|
||||
var CHUNK_SIZE = 64000;
|
||||
var CHUNK_SIZE = 65536;
|
||||
|
||||
function NetworkPdfManager(args, msgHandler) {
|
||||
|
||||
@ -131,23 +124,19 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
NetworkPdfManager.prototype = Object.create(BasePdfManager.prototype);
|
||||
NetworkPdfManager.prototype.constructor = NetworkPdfManager;
|
||||
|
||||
// FIXME(mack): Make ensure() use array for all arguments
|
||||
NetworkPdfManager.prototype.ensure =
|
||||
function NetworkPdfManager_ensure(obj, prop) {
|
||||
function NetworkPdfManager_ensure(obj, prop, args) {
|
||||
var promise = new PDFJS.Promise();
|
||||
var args = [].slice.call(arguments);
|
||||
args.unshift(promise);
|
||||
this.ensureHelper.apply(this, args);
|
||||
this.ensureHelper(promise, obj, prop, args);
|
||||
return promise;
|
||||
};
|
||||
|
||||
NetworkPdfManager.prototype.ensureHelper =
|
||||
function NetworkPdfManager_ensureHelper(promise, obj, prop) {
|
||||
function NetworkPdfManager_ensureHelper(promise, obj, prop, args) {
|
||||
try {
|
||||
var result;
|
||||
var value = obj[prop];
|
||||
if (typeof(value) === 'function') {
|
||||
var args = [].slice.call(arguments, 3);
|
||||
result = value.apply(obj, args);
|
||||
} else {
|
||||
result = value;
|
||||
@ -160,9 +149,8 @@ var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
return;
|
||||
}
|
||||
|
||||
var allArgs = Array.prototype.slice.call(arguments);
|
||||
this.streamManager.requestRange(e.begin, e.end, function() {
|
||||
this.ensureHelper.apply(this, allArgs);
|
||||
this.ensureHelper(promise, obj, prop, args);
|
||||
}.bind(this));
|
||||
}
|
||||
};
|
||||
|
@ -144,9 +144,9 @@ var WorkerMessageHandler = {
|
||||
loadDocumentPromise.reject(e);
|
||||
};
|
||||
|
||||
pdfManager.ensureModel('checkHeader').then(function() {
|
||||
pdfManager.ensureModel('parseStartXRef').then(function() {
|
||||
pdfManager.ensureModel('parse', recoveryMode).then(
|
||||
pdfManager.ensureModel('checkHeader', []).then(function() {
|
||||
pdfManager.ensureModel('parseStartXRef', []).then(function() {
|
||||
pdfManager.ensureModel('parse', [recoveryMode]).then(
|
||||
parseSuccess, parseFailure);
|
||||
});
|
||||
});
|
||||
@ -255,7 +255,7 @@ var WorkerMessageHandler = {
|
||||
|
||||
var onSuccess = function(doc) {
|
||||
handler.send('GetDoc', { pdfInfo: doc });
|
||||
pdfManager.ensureModel('traversePages');
|
||||
pdfManager.ensureModel('traversePages', []);
|
||||
};
|
||||
|
||||
var onFailure = function(e) {
|
||||
@ -345,12 +345,14 @@ var WorkerMessageHandler = {
|
||||
|
||||
handler.on('GetAnnotationsRequest', function wphSetupGetAnnotations(data) {
|
||||
pdfManager.getPage(data.pageIndex).then(function(page) {
|
||||
pdfManager.ensure(page, 'getAnnotations').then(function(annotations) {
|
||||
handler.send('GetAnnotations', {
|
||||
pageIndex: data.pageIndex,
|
||||
annotations: annotations
|
||||
});
|
||||
});
|
||||
pdfManager.ensure(page, 'getAnnotations',[]).then(
|
||||
function(annotations) {
|
||||
handler.send('GetAnnotations', {
|
||||
pageIndex: data.pageIndex,
|
||||
annotations: annotations
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user