[Pkg-javascript-commits] [pdf.js] 72/210: Remove LegacyPromise in src/core/core.js

David Prévot taffit at moszumanska.debian.org
Thu Jun 5 14:21:03 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 034f1102dae10c94161c25665d7d76d9f931fdc4
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri May 2 00:17:30 2014 +0200

    Remove LegacyPromise in src/core/core.js
---
 src/core/core.js | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

diff --git a/src/core/core.js b/src/core/core.js
index 5d1e3c2..1f054ac 100644
--- a/src/core/core.js
+++ b/src/core/core.js
@@ -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() {

-- 
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