Merge pull request #11219 from Snuffleupagus/throw-deprecated-methods

[api-minor] Replace all `deprecated` calls with throwing of actual `Error`s
This commit is contained in:
Tim van der Meij 2019-10-09 23:32:22 +02:00 committed by GitHub
commit d2959fc9c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,9 +23,8 @@ import {
unreachable, warn unreachable, warn
} from '../shared/util'; } from '../shared/util';
import { import {
deprecated, DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, loadScript,
loadScript, PageViewport, releaseImageResources, RenderingCancelledException, PageViewport, releaseImageResources, RenderingCancelledException, StatTimer
StatTimer
} from './display_utils'; } from './display_utils';
import { FontFaceObject, FontLoader } from './font_loader'; import { FontFaceObject, FontLoader } from './font_loader';
import { apiCompatibilityParams } from './api_compatibility'; import { apiCompatibilityParams } from './api_compatibility';
@ -467,6 +466,7 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
} }
/** /**
* Promise for document loading task completion.
* @return {Promise} * @return {Promise}
*/ */
get promise() { get promise() {
@ -494,16 +494,11 @@ const PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
/** /**
* Registers callbacks to indicate the document loading completion. * Registers callbacks to indicate the document loading completion.
* * @ignore
* @param {function} onFulfilled The callback for the loading completion.
* @param {function} onRejected The callback for the loading failure.
* @return {Promise} A promise that is resolved after the onFulfilled or
* onRejected callback.
*/ */
then(onFulfilled, onRejected) { then(onFulfilled, onRejected) {
deprecated('PDFDocumentLoadingTask.then method, ' + throw new Error('Removed API method: ' +
'use the `promise` getter instead.'); 'PDFDocumentLoadingTask.then, use the `promise` getter instead.');
return this.promise.then.apply(this.promise, arguments);
} }
} }
return PDFDocumentLoadingTask; return PDFDocumentLoadingTask;
@ -964,10 +959,8 @@ class PDFPageProxy {
getViewport({ scale, rotation = this.rotate, dontFlip = false, } = {}) { getViewport({ scale, rotation = this.rotate, dontFlip = false, } = {}) {
if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) && if ((typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) &&
(arguments.length > 1 || typeof arguments[0] === 'number')) { (arguments.length > 1 || typeof arguments[0] === 'number')) {
deprecated('getViewport is called with obsolete arguments.'); throw new Error(
scale = arguments[0]; 'PDFPageProxy.getViewport is called with obsolete arguments.');
rotation = typeof arguments[1] === 'number' ? arguments[1] : this.rotate;
dontFlip = typeof arguments[2] === 'boolean' ? arguments[2] : false;
} }
return new PageViewport({ return new PageViewport({
viewBox: this.view, viewBox: this.view,
@ -2545,15 +2538,11 @@ class RenderTask {
/** /**
* Registers callbacks to indicate the rendering task completion. * Registers callbacks to indicate the rendering task completion.
* * @ignore
* @param {function} onFulfilled The callback for the rendering completion.
* @param {function} onRejected The callback for the rendering failure.
* @return {Promise} A promise that is resolved after the onFulfilled or
* onRejected callback.
*/ */
then(onFulfilled, onRejected) { then(onFulfilled, onRejected) {
deprecated('RenderTask.then method, use the `promise` getter instead.'); throw new Error('Removed API method: ' +
return this.promise.then.apply(this.promise, arguments); 'RenderTask.then, use the `promise` getter instead.');
} }
} }