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