[Pkg-javascript-commits] [pdf.js] 81/174: Adds deprecation warning for the API calls.

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 5135aa9becc15a79a565ddf33452e2351196bd5b
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Wed Oct 21 08:54:31 2015 -0500

    Adds deprecation warning for the API calls.
---
 src/display/api.js        | 11 ++++++++---
 src/shared/util.js        |  5 +++++
 web/pdf_page_view.js      |  2 +-
 web/pdf_thumbnail_view.js |  4 ++--
 web/viewer.js             | 14 +++++++++-----
 5 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/display/api.js b/src/display/api.js
index 59efee3..fb47469 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -19,7 +19,7 @@
            Promise, PasswordResponses, PasswordException, InvalidPDFException,
            MissingPDFException, UnknownErrorException, FontFaceObject,
            loadJpegStream, createScratchCanvas, CanvasGraphics, stringToBytes,
-           UnexpectedResponseException */
+           UnexpectedResponseException, deprecated */
 
 'use strict';
 
@@ -259,6 +259,10 @@ PDFJS.getDocument = function getDocument(src,
   var task = new PDFDocumentLoadingTask();
 
   // Support of the obsolete arguments (for compatibility with API v1.0)
+  if (arguments.length > 1) {
+    deprecated('getDocument is called with pdfDataRangeTransport, ' +
+               'passwordCallback or progressCallback argument');
+  }
   if (pdfDataRangeTransport) {
     if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
       // Not a PDFDataRangeTransport instance, trying to add missing properties.
@@ -786,6 +790,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
 
       // Obsolete parameter support
       if (params.continueCallback) {
+        deprecated('render is used with continueCallback parameter');
         renderTask.onContinue = params.continueCallback;
       }
 
@@ -900,10 +905,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
     },
 
     /**
-     * Cleans up resources allocated by the page.
-     * Deprecated, use cleanup() instead.
+     * Cleans up resources allocated by the page. (deprecated)
      */
     destroy: function() {
+      deprecated('page destroy method, use cleanup() instead');
       this.cleanup();
     },
 
diff --git a/src/shared/util.js b/src/shared/util.js
index f4821bc..1adeb82 100644
--- a/src/shared/util.js
+++ b/src/shared/util.js
@@ -213,6 +213,11 @@ function warn(msg) {
   }
 }
 
+// Deprecated API function -- treated as warnings.
+function deprecated(details) {
+  warn('Deprecated API usage: ' + details);
+}
+
 // Fatal errors that should trigger the fallback UI and halt execution by
 // throwing an exception.
 function error(msg) {
diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js
index d3f2d9a..34345a3 100644
--- a/web/pdf_page_view.js
+++ b/web/pdf_page_view.js
@@ -457,9 +457,9 @@ var PDFPageView = (function PDFPageViewClosure() {
         canvasContext: ctx,
         viewport: this.viewport,
         // intent: 'default', // === 'display'
-        continueCallback: renderContinueCallback
       };
       var renderTask = this.renderTask = this.pdfPage.render(renderContext);
+      renderTask.onContinue = renderContinueCallback;
 
       this.renderTask.promise.then(
         function pdfPageRenderCallback() {
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 88c92c7..24e4cf5 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -285,10 +285,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
 
       var renderContext = {
         canvasContext: ctx,
-        viewport: drawViewport,
-        continueCallback: renderContinueCallback
+        viewport: drawViewport
       };
       var renderTask = this.renderTask = this.pdfPage.render(renderContext);
+      renderTask.onContinue = renderContinueCallback;
 
       renderTask.promise.then(
         function pdfPageRenderCallback() {
diff --git a/web/viewer.js b/web/viewer.js
index bb53afa..632afe0 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -526,6 +526,9 @@ var PDFViewerApplication = {
       this.setTitleUsingUrl(file.originalUrl);
       parameters.url = file.url;
     }
+    if (pdfDataRangeTransport) {
+      parameters.range = pdfDataRangeTransport;
+    }
     if (args) {
       for (var prop in args) {
         parameters[prop] = args[prop];
@@ -535,18 +538,19 @@ var PDFViewerApplication = {
     var self = this;
     self.downloadComplete = false;
 
-    var passwordNeeded = function passwordNeeded(updatePassword, reason) {
+    var loadingTask = PDFJS.getDocument(parameters);
+
+    loadingTask.onPassword = function passwordNeeded(updatePassword, reason) {
       PasswordPrompt.updatePassword = updatePassword;
       PasswordPrompt.reason = reason;
       PasswordPrompt.open();
     };
 
-    function getDocumentProgress(progressData) {
+    loadingTask.onProgress = function getDocumentProgress(progressData) {
       self.progress(progressData.loaded / progressData.total);
-    }
+    };
 
-    PDFJS.getDocument(parameters, pdfDataRangeTransport, passwordNeeded,
-                      getDocumentProgress).then(
+    loadingTask.promise.then(
       function getDocumentCallback(pdfDocument) {
         self.load(pdfDocument, scale);
       },

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