mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Adds Promise to the getOperatorList
This commit is contained in:
parent
37a6aac972
commit
d8eb8b1de1
6 changed files with 568 additions and 488 deletions
|
@ -219,11 +219,9 @@ var Annotation = (function AnnotationClosure() {
|
|||
},
|
||||
|
||||
getOperatorList: function Annotation_getOperatorList(evaluator) {
|
||||
var capability = createPromiseCapability();
|
||||
|
||||
if (!this.appearance) {
|
||||
capability.resolve(new OperatorList());
|
||||
return capability.promise;
|
||||
return Promise.resolve(new OperatorList());
|
||||
}
|
||||
|
||||
var data = this.data;
|
||||
|
@ -242,18 +240,18 @@ var Annotation = (function AnnotationClosure() {
|
|||
var bbox = appearanceDict.get('BBox') || [0, 0, 1, 1];
|
||||
var matrix = appearanceDict.get('Matrix') || [1, 0, 0, 1, 0 ,0];
|
||||
var transform = getTransformMatrix(data.rect, bbox, matrix);
|
||||
var self = this;
|
||||
|
||||
resourcesPromise.then(function(resources) {
|
||||
var opList = new OperatorList();
|
||||
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
|
||||
evaluator.getOperatorList(this.appearance, resources, opList);
|
||||
opList.addOp(OPS.endAnnotation, []);
|
||||
capability.resolve(opList);
|
||||
|
||||
this.appearance.reset();
|
||||
}.bind(this), capability.reject);
|
||||
|
||||
return capability.promise;
|
||||
return resourcesPromise.then(function(resources) {
|
||||
var opList = new OperatorList();
|
||||
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
|
||||
return evaluator.getOperatorList(self.appearance, resources, opList).
|
||||
then(function () {
|
||||
opList.addOp(OPS.endAnnotation, []);
|
||||
self.appearance.reset();
|
||||
return opList;
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -512,8 +510,10 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() {
|
|||
}
|
||||
|
||||
var stream = new Stream(stringToBytes(data.defaultAppearance));
|
||||
evaluator.getOperatorList(stream, this.fieldResources, opList);
|
||||
return Promise.resolve(opList);
|
||||
return evaluator.getOperatorList(stream, this.fieldResources, opList).
|
||||
then(function () {
|
||||
return opList;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue