Merge pull request #4726 from Snuffleupagus/remove-LegacyPromise-core.js
Remove LegacyPromise in src/core/core.js
This commit is contained in:
commit
ae92b6f96f
@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals assert, calculateMD5, Catalog, Dict, error, info, isArray,
|
||||
isArrayBuffer, isName, isStream, isString, LegacyPromise,
|
||||
isArrayBuffer, isName, isStream, isString, createPromiseCapability,
|
||||
Linearization, NullStream, PartialEvaluator, shadow, Stream, Lexer,
|
||||
StreamsSequenceStream, stringToPDFString, stringToBytes, Util, XRef,
|
||||
MissingDataException, Promise, Annotation, ObjectLoader, OperatorList
|
||||
@ -141,32 +141,28 @@ var Page = (function PageClosure() {
|
||||
return stream;
|
||||
},
|
||||
|
||||
loadResources: function(keys) {
|
||||
loadResources: function Page_loadResources(keys) {
|
||||
if (!this.resourcesPromise) {
|
||||
// TODO: add async getInheritedPageProp and remove this.
|
||||
this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
|
||||
}
|
||||
var promise = new LegacyPromise();
|
||||
this.resourcesPromise.then(function resourceSuccess() {
|
||||
return this.resourcesPromise.then(function resourceSuccess() {
|
||||
var objectLoader = new ObjectLoader(this.resources.map,
|
||||
keys,
|
||||
this.xref);
|
||||
objectLoader.load().then(function objectLoaderSuccess() {
|
||||
promise.resolve();
|
||||
});
|
||||
return objectLoader.load();
|
||||
}.bind(this));
|
||||
return promise;
|
||||
},
|
||||
|
||||
getOperatorList: function Page_getOperatorList(handler, intent) {
|
||||
var self = this;
|
||||
var promise = new LegacyPromise();
|
||||
var capability = createPromiseCapability();
|
||||
|
||||
function reject(e) {
|
||||
promise.reject(e);
|
||||
capability.reject(e);
|
||||
}
|
||||
|
||||
var pageListPromise = new LegacyPromise();
|
||||
var pageListCapability = createPromiseCapability();
|
||||
|
||||
var pdfManager = this.pdfManager;
|
||||
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream',
|
||||
@ -200,17 +196,18 @@ var Page = (function PageClosure() {
|
||||
intent: intent
|
||||
});
|
||||
partialEvaluator.getOperatorList(contentStream, self.resources, opList);
|
||||
pageListPromise.resolve(opList);
|
||||
pageListCapability.resolve(opList);
|
||||
});
|
||||
|
||||
var annotationsPromise = pdfManager.ensure(this, 'annotations');
|
||||
Promise.all([pageListPromise, annotationsPromise]).then(function(datas) {
|
||||
Promise.all([pageListCapability.promise, annotationsPromise]).then(
|
||||
function(datas) {
|
||||
var pageOpList = datas[0];
|
||||
var annotations = datas[1];
|
||||
|
||||
if (annotations.length === 0) {
|
||||
pageOpList.flush(true);
|
||||
promise.resolve(pageOpList);
|
||||
capability.resolve(pageOpList);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -218,11 +215,11 @@ var Page = (function PageClosure() {
|
||||
annotations, pageOpList, pdfManager, partialEvaluator, intent);
|
||||
annotationsReadyPromise.then(function () {
|
||||
pageOpList.flush(true);
|
||||
promise.resolve(pageOpList);
|
||||
capability.resolve(pageOpList);
|
||||
}, reject);
|
||||
}, reject);
|
||||
|
||||
return promise;
|
||||
return capability.promise;
|
||||
},
|
||||
|
||||
extractTextContent: function Page_extractTextContent() {
|
||||
|
Loading…
Reference in New Issue
Block a user