Merge pull request #8357 from Snuffleupagus/core-rm-bind
Replace unnecessary `bind(this)` and `var self = this` statements with arrow functions in remaining `src/core/` files
This commit is contained in:
commit
de7002dc6c
@ -417,20 +417,17 @@ var Annotation = (function AnnotationClosure() {
|
||||
},
|
||||
|
||||
loadResources: function Annotation_loadResources(keys) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
this.appearance.dict.getAsync('Resources').then(function (resources) {
|
||||
return this.appearance.dict.getAsync('Resources').then((resources) => {
|
||||
if (!resources) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
var objectLoader = new ObjectLoader(resources.map,
|
||||
keys,
|
||||
resources.xref);
|
||||
objectLoader.load().then(function() {
|
||||
resolve(resources);
|
||||
}, reject);
|
||||
}, reject);
|
||||
}.bind(this));
|
||||
return objectLoader.load().then(function() {
|
||||
return resources;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
getOperatorList: function Annotation_getOperatorList(evaluator, task,
|
||||
@ -454,15 +451,14 @@ var Annotation = (function AnnotationClosure() {
|
||||
var bbox = appearanceDict.getArray('BBox') || [0, 0, 1, 1];
|
||||
var matrix = appearanceDict.getArray('Matrix') || [1, 0, 0, 1, 0, 0];
|
||||
var transform = getTransformMatrix(data.rect, bbox, matrix);
|
||||
var self = this;
|
||||
|
||||
return resourcesPromise.then(function(resources) {
|
||||
return resourcesPromise.then((resources) => {
|
||||
var opList = new OperatorList();
|
||||
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
|
||||
return evaluator.getOperatorList(self.appearance, task,
|
||||
resources, opList).then(function () {
|
||||
return evaluator.getOperatorList(this.appearance, task,
|
||||
resources, opList).then(() => {
|
||||
opList.addOp(OPS.endAnnotation, []);
|
||||
self.appearance.reset();
|
||||
this.appearance.reset();
|
||||
return opList;
|
||||
});
|
||||
});
|
||||
|
@ -334,12 +334,12 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
|
||||
};
|
||||
rangeReader.read().then(readChunk, reject);
|
||||
});
|
||||
promise.then(function (data) {
|
||||
promise.then((data) => {
|
||||
if (this.aborted) {
|
||||
return; // ignoring any data after abort
|
||||
}
|
||||
this.onReceiveData({ chunk: data, begin, });
|
||||
}.bind(this));
|
||||
});
|
||||
// TODO check errors
|
||||
},
|
||||
|
||||
|
@ -225,18 +225,15 @@ var Page = (function PageClosure() {
|
||||
// TODO: add async getInheritedPageProp and remove this.
|
||||
this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
|
||||
}
|
||||
return this.resourcesPromise.then(function resourceSuccess() {
|
||||
return this.resourcesPromise.then(() => {
|
||||
var objectLoader = new ObjectLoader(this.resources.map,
|
||||
keys,
|
||||
this.xref);
|
||||
return objectLoader.load();
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
getOperatorList: function Page_getOperatorList(handler, task, intent,
|
||||
renderInteractiveForms) {
|
||||
var self = this;
|
||||
|
||||
getOperatorList(handler, task, intent, renderInteractiveForms) {
|
||||
var pdfManager = this.pdfManager;
|
||||
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream',
|
||||
[]);
|
||||
@ -259,17 +256,16 @@ var Page = (function PageClosure() {
|
||||
this.evaluatorOptions);
|
||||
|
||||
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
var pageListPromise = dataPromises.then(function(data) {
|
||||
var contentStream = data[0];
|
||||
var opList = new OperatorList(intent, handler, self.pageIndex);
|
||||
var pageListPromise = dataPromises.then(([contentStream]) => {
|
||||
var opList = new OperatorList(intent, handler, this.pageIndex);
|
||||
|
||||
handler.send('StartRenderPage', {
|
||||
transparency: partialEvaluator.hasBlendModes(self.resources),
|
||||
pageIndex: self.pageIndex,
|
||||
transparency: partialEvaluator.hasBlendModes(this.resources),
|
||||
pageIndex: this.pageIndex,
|
||||
intent,
|
||||
});
|
||||
return partialEvaluator.getOperatorList(contentStream, task,
|
||||
self.resources, opList).then(function () {
|
||||
this.resources, opList).then(function () {
|
||||
return opList;
|
||||
});
|
||||
});
|
||||
@ -278,10 +274,7 @@ var Page = (function PageClosure() {
|
||||
// page's operator list to render them.
|
||||
var annotationsPromise = pdfManager.ensure(this, 'annotations');
|
||||
return Promise.all([pageListPromise, annotationsPromise]).then(
|
||||
function(datas) {
|
||||
var pageOpList = datas[0];
|
||||
var annotations = datas[1];
|
||||
|
||||
function ([pageOpList, annotations]) {
|
||||
if (annotations.length === 0) {
|
||||
pageOpList.flush(true);
|
||||
return pageOpList;
|
||||
@ -310,11 +303,7 @@ var Page = (function PageClosure() {
|
||||
});
|
||||
},
|
||||
|
||||
extractTextContent: function Page_extractTextContent(handler, task,
|
||||
normalizeWhitespace,
|
||||
combineTextItems) {
|
||||
var self = this;
|
||||
|
||||
extractTextContent(handler, task, normalizeWhitespace, combineTextItems) {
|
||||
var pdfManager = this.pdfManager;
|
||||
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream',
|
||||
[]);
|
||||
@ -325,20 +314,18 @@ var Page = (function PageClosure() {
|
||||
'Font'
|
||||
]);
|
||||
|
||||
var dataPromises = Promise.all([contentStreamPromise,
|
||||
resourcesPromise]);
|
||||
return dataPromises.then(function(data) {
|
||||
var contentStream = data[0];
|
||||
var partialEvaluator = new PartialEvaluator(pdfManager, self.xref,
|
||||
handler, self.pageIndex,
|
||||
self.idFactory,
|
||||
self.fontCache,
|
||||
self.builtInCMapCache,
|
||||
self.evaluatorOptions);
|
||||
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
return dataPromises.then(([contentStream]) => {
|
||||
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref,
|
||||
handler, this.pageIndex,
|
||||
this.idFactory,
|
||||
this.fontCache,
|
||||
this.builtInCMapCache,
|
||||
this.evaluatorOptions);
|
||||
|
||||
return partialEvaluator.getTextContent(contentStream,
|
||||
task,
|
||||
self.resources,
|
||||
this.resources,
|
||||
/* stateManager = */ null,
|
||||
normalizeWhitespace,
|
||||
combineTextItems);
|
||||
|
@ -633,7 +633,7 @@ var Font = (function FontClosure() {
|
||||
properties.differences);
|
||||
} else {
|
||||
glyphsUnicodeMap = getGlyphsUnicode();
|
||||
this.toUnicode.forEach(function(charCode, unicodeCharCode) {
|
||||
this.toUnicode.forEach((charCode, unicodeCharCode) => {
|
||||
if (!this.composite) {
|
||||
glyphName = (properties.differences[charCode] ||
|
||||
properties.defaultEncoding[charCode]);
|
||||
@ -643,7 +643,7 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
}
|
||||
this.toFontChar[charCode] = unicodeCharCode;
|
||||
}.bind(this));
|
||||
});
|
||||
}
|
||||
this.loadedName = fontName.split('-')[0];
|
||||
this.loading = false;
|
||||
|
@ -429,27 +429,24 @@ var Catalog = (function CatalogClosure() {
|
||||
this.fontCache.forEach(function (promise) {
|
||||
promises.push(promise);
|
||||
});
|
||||
return Promise.all(promises).then(function (translatedFonts) {
|
||||
return Promise.all(promises).then((translatedFonts) => {
|
||||
for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
|
||||
var font = translatedFonts[i].dict;
|
||||
delete font.translated;
|
||||
}
|
||||
this.fontCache.clear();
|
||||
this.builtInCMapCache = Object.create(null);
|
||||
}.bind(this));
|
||||
});
|
||||
},
|
||||
|
||||
getPage: function Catalog_getPage(pageIndex) {
|
||||
if (!(pageIndex in this.pagePromises)) {
|
||||
this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(
|
||||
function (a) {
|
||||
var dict = a[0];
|
||||
var ref = a[1];
|
||||
([dict, ref]) => {
|
||||
return this.pageFactory.createPage(pageIndex, dict, ref,
|
||||
this.fontCache,
|
||||
this.builtInCMapCache);
|
||||
}.bind(this)
|
||||
);
|
||||
});
|
||||
}
|
||||
return this.pagePromises[pageIndex];
|
||||
},
|
||||
@ -1772,8 +1769,7 @@ var ObjectLoader = (function() {
|
||||
}
|
||||
|
||||
if (pendingRequests.length) {
|
||||
this.xref.stream.manager.requestRanges(pendingRequests).then(
|
||||
function pendingRequestCallback() {
|
||||
this.xref.stream.manager.requestRanges(pendingRequests).then(() => {
|
||||
nodesToVisit = nodesToRevisit;
|
||||
for (var i = 0; i < nodesToRevisit.length; i++) {
|
||||
var node = nodesToRevisit[i];
|
||||
@ -1784,7 +1780,7 @@ var ObjectLoader = (function() {
|
||||
}
|
||||
}
|
||||
this._walk(nodesToVisit);
|
||||
}.bind(this), this.capability.reject);
|
||||
}, this.capability.reject);
|
||||
return;
|
||||
}
|
||||
// Everything is loaded.
|
||||
|
Loading…
Reference in New Issue
Block a user