[Pkg-javascript-commits] [pdf.js] 68/210: Remove LegacyPromise in src/shared/annotation.js
David Prévot
taffit at moszumanska.debian.org
Thu Jun 5 14:21:02 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch upstream
in repository pdf.js.
commit cb59e7f872f9b9f25aedb2ab6617b8342d22abbb
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Fri May 2 00:52:03 2014 +0200
Remove LegacyPromise in src/shared/annotation.js
---
src/shared/annotation.js | 59 ++++++++++++++++++++++--------------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/shared/annotation.js b/src/shared/annotation.js
index 0596bfd..269254a 100644
--- a/src/shared/annotation.js
+++ b/src/shared/annotation.js
@@ -17,7 +17,7 @@
/* globals Util, isDict, isName, stringToPDFString, warn, Dict, Stream,
stringToBytes, PDFJS, isWorker, assert, NotImplementedException,
Promise, isArray, ObjectLoader, isValidUrl, OperatorList, OPS,
- LegacyPromise */
+ createPromiseCapability */
'use strict';
@@ -195,31 +195,29 @@ var Annotation = (function AnnotationClosure() {
data.rect); // rectangle is nessessary
},
- loadResources: function(keys) {
- var promise = new LegacyPromise();
- this.appearance.dict.getAsync('Resources').then(function(resources) {
- if (!resources) {
- promise.resolve();
- return;
- }
- var objectLoader = new ObjectLoader(resources.map,
- keys,
- resources.xref);
- objectLoader.load().then(function() {
- promise.resolve(resources);
- });
+ loadResources: function Annotation_loadResources(keys) {
+ return new Promise(function (resolve, reject) {
+ this.appearance.dict.getAsync('Resources').then(function (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 promise;
},
getOperatorList: function Annotation_getOperatorList(evaluator) {
-
- var promise = new LegacyPromise();
+ var capability = createPromiseCapability();
if (!this.appearance) {
- promise.resolve(new OperatorList());
- return promise;
+ capability.resolve(new OperatorList());
+ return capability.promise;
}
var data = this.data;
@@ -244,12 +242,12 @@ var Annotation = (function AnnotationClosure() {
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
evaluator.getOperatorList(this.appearance, resources, opList);
opList.addOp(OPS.endAnnotation, []);
- promise.resolve(opList);
+ capability.resolve(opList);
this.appearance.reset();
- }.bind(this));
+ }.bind(this), capability.reject);
- return promise;
+ return capability.promise;
}
};
@@ -329,10 +327,10 @@ var Annotation = (function AnnotationClosure() {
annotations, opList, pdfManager, partialEvaluator, intent) {
function reject(e) {
- annotationsReadyPromise.reject(e);
+ annotationsReadyCapability.reject(e);
}
- var annotationsReadyPromise = new LegacyPromise();
+ var annotationsReadyCapability = createPromiseCapability();
var annotationPromises = [];
for (var i = 0, n = annotations.length; i < n; ++i) {
@@ -349,10 +347,10 @@ var Annotation = (function AnnotationClosure() {
opList.addOpList(annotOpList);
}
opList.addOp(OPS.endAnnotations, []);
- annotationsReadyPromise.resolve();
+ annotationsReadyCapability.resolve();
}, reject);
- return annotationsReadyPromise;
+ return annotationsReadyCapability.promise;
};
return Annotation;
@@ -498,7 +496,6 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
return Annotation.prototype.getOperatorList.call(this, evaluator);
}
- var promise = new LegacyPromise();
var opList = new OperatorList();
var data = this.data;
@@ -507,8 +504,7 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
var defaultAppearance = data.defaultAppearance;
if (!defaultAppearance) {
- promise.resolve(opList);
- return promise;
+ return Promise.resolve(opList);
}
// Include any font resources found in the default appearance
@@ -543,8 +539,7 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
data.rgb = [rgbValue, rgbValue, rgbValue];
}
}
- promise.resolve(opList);
- return promise;
+ return Promise.resolve(opList);
}
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list