Browse Source

Adds deprecation warning for the API calls.

Yury Delendik 10 years ago
parent
commit
5135aa9bec
  1. 11
      src/display/api.js
  2. 5
      src/shared/util.js
  3. 2
      web/pdf_page_view.js
  4. 4
      web/pdf_thumbnail_view.js
  5. 14
      web/viewer.js

11
src/display/api.js

@ -19,7 +19,7 @@ @@ -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, @@ -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() { @@ -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() { @@ -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();
},

5
src/shared/util.js

@ -213,6 +213,11 @@ function warn(msg) { @@ -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) {

2
web/pdf_page_view.js

@ -457,9 +457,9 @@ var PDFPageView = (function PDFPageViewClosure() { @@ -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() {

4
web/pdf_thumbnail_view.js

@ -285,10 +285,10 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() { @@ -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() {

14
web/viewer.js

@ -526,6 +526,9 @@ var PDFViewerApplication = { @@ -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 = { @@ -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);
},

Loading…
Cancel
Save