Minor fixes for the jsdocs and removing unused members.

This commit is contained in:
Yury Delendik 2014-01-21 13:28:18 -06:00
parent 96fff4cc74
commit 27573ddbad

View File

@ -25,7 +25,7 @@
/** /**
* The maximum allowed image size in total pixels e.g. width * height. Images * The maximum allowed image size in total pixels e.g. width * height. Images
* above this value will not be drawn. Use -1 for no limit. * above this value will not be drawn. Use -1 for no limit.
* @var {Number} * @var {number}
*/ */
PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize; PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
@ -33,7 +33,7 @@ PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
* By default fonts are converted to OpenType fonts and loaded via font face * By default fonts are converted to OpenType fonts and loaded via font face
* rules. If disabled, the font will be rendered using a built in font renderer * rules. If disabled, the font will be rendered using a built in font renderer
* that constructs the glyphs with primitive path commands. * that constructs the glyphs with primitive path commands.
* @var {Boolean} * @var {boolean}
*/ */
PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ?
false : PDFJS.disableFontFace; false : PDFJS.disableFontFace;
@ -41,7 +41,7 @@ PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ?
/** /**
* Path for image resources, mainly for annotation icons. Include trailing * Path for image resources, mainly for annotation icons. Include trailing
* slash. * slash.
* @var {String} * @var {string}
*/ */
PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
'' : PDFJS.imageResourcesPath; '' : PDFJS.imageResourcesPath;
@ -50,7 +50,7 @@ PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ?
* Disable the web worker and run all code on the main thread. This will happen * Disable the web worker and run all code on the main thread. This will happen
* automatically if the browser doesn't support workers or sending typed arrays * automatically if the browser doesn't support workers or sending typed arrays
* to workers. * to workers.
* @var {Boolean} * @var {boolean}
*/ */
PDFJS.disableWorker = PDFJS.disableWorker === undefined ? PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
false : PDFJS.disableWorker; false : PDFJS.disableWorker;
@ -59,7 +59,7 @@ PDFJS.disableWorker = PDFJS.disableWorker === undefined ?
* Path and filename of the worker file. Required when the worker is enabled in * Path and filename of the worker file. Required when the worker is enabled in
* development mode. If unspecified in the production build, the worker will be * development mode. If unspecified in the production build, the worker will be
* loaded based on the location of the pdf.js file. * loaded based on the location of the pdf.js file.
* @var {String} * @var {string}
*/ */
PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc; PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
@ -67,7 +67,7 @@ PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
* Disable range request loading of PDF files. When enabled and if the server * Disable range request loading of PDF files. When enabled and if the server
* supports partial content requests then the PDF will be fetched in chunks. * supports partial content requests then the PDF will be fetched in chunks.
* Enabled (false) by default. * Enabled (false) by default.
* @var {Boolean} * @var {boolean}
*/ */
PDFJS.disableRange = PDFJS.disableRange === undefined ? PDFJS.disableRange = PDFJS.disableRange === undefined ?
false : PDFJS.disableRange; false : PDFJS.disableRange;
@ -76,14 +76,14 @@ PDFJS.disableRange = PDFJS.disableRange === undefined ?
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js * Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
* will automatically keep fetching more data even if it isn't needed to display * will automatically keep fetching more data even if it isn't needed to display
* the current page. This default behavior can be disabled. * the current page. This default behavior can be disabled.
* @var {Boolean} * @var {boolean}
*/ */
PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ?
false : PDFJS.disableAutoFetch; false : PDFJS.disableAutoFetch;
/** /**
* Enables special hooks for debugging PDF.js. * Enables special hooks for debugging PDF.js.
* @var {Boolean} * @var {boolean}
*/ */
PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug; PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
@ -107,32 +107,38 @@ PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ?
* - errors * - errors
* - warnings [default] * - warnings [default]
* - infos * - infos
* @var {Number} * @var {number}
*/ */
PDFJS.verbosity = PDFJS.verbosity === undefined ? PDFJS.verbosity = PDFJS.verbosity === undefined ?
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity; PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity;
/**
* Document initialization / loading parameters object.
*
* @typedef {Object} DocumentInitParameters
* @property {string} url - The URL of the PDF.
* @property {TypedArray} data - A typed array with PDF data.
* @property {Object} httpHeaders - Basic authentication headers.
* @property {boolean} withCredentials - Indicates whether or not cross-site
* Access-Control requests should be made using credentials such as cookies
* or authorization headers. The default is false.
* @property {string} password - For decrypting password-protected PDFs.
* @property {TypedArray} initialData - A typed array with the first portion or
* all of the pdf data. Used by the extension since some data is already
* loaded before the switch to range requests.
*/
/** /**
* This is the main entry point for loading a PDF and interacting with it. * This is the main entry point for loading a PDF and interacting with it.
* NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR) * NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
* is used, which means it must follow the same origin rules that any XHR does * is used, which means it must follow the same origin rules that any XHR does
* e.g. No cross domain requests without CORS. * e.g. No cross domain requests without CORS.
* *
* @param {string|TypedAray|object} source Can be an url to where a PDF is * @param {string|TypedArray|DocumentInitParameters} source Can be a url to
* located, a typed array (Uint8Array) already populated with data or * where a PDF is located, a typed array (Uint8Array) already populated with
* and parameter object with the following possible fields: * data or parameter object.
* - url - The URL of the PDF.
* - data - A typed array with PDF data.
* - httpHeaders - Basic authentication headers.
* - withCredentials - Indicates whether or not cross-site Access-Control
* requests should be made using credentials such as
* cookies or authorization headers. The default is false.
* - password - For decrypting password-protected PDFs.
* - initialData - A typed array with the first portion or all of the pdf data.
* Used by the extension since some data is already loaded
* before the switch to range requests.
* *
* @param {object} pdfDataRangeTransport is optional. It is used if you want * @param {Object} pdfDataRangeTransport is optional. It is used if you want
* to manually serve range requests for data in the PDF. See viewer.js for * to manually serve range requests for data in the PDF. See viewer.js for
* an example of pdfDataRangeTransport's interface. * an example of pdfDataRangeTransport's interface.
* *
@ -141,7 +147,8 @@ PDFJS.verbosity = PDFJS.verbosity === undefined ?
* parameters: function that needs to be called with new password and reason * parameters: function that needs to be called with new password and reason
* (see {PasswordResponses}). * (see {PasswordResponses}).
* *
* @return {Promise} A promise that is resolved with {PDFDocumentProxy} object. * @return {Promise} A promise that is resolved with {@link PDFDocumentProxy}
* object.
*/ */
PDFJS.getDocument = function getDocument(source, PDFJS.getDocument = function getDocument(source,
pdfDataRangeTransport, pdfDataRangeTransport,
@ -185,13 +192,14 @@ PDFJS.getDocument = function getDocument(source,
/** /**
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used * Proxy to a PDFDocument in the worker thread. Also, contains commonly used
* properties that can be read synchronously. * properties that can be read synchronously.
* @class
*/ */
var PDFDocumentProxy = (function PDFDocumentProxyClosure() { var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
function PDFDocumentProxy(pdfInfo, transport) { function PDFDocumentProxy(pdfInfo, transport) {
this.pdfInfo = pdfInfo; this.pdfInfo = pdfInfo;
this.transport = transport; this.transport = transport;
} }
PDFDocumentProxy.prototype = { PDFDocumentProxy.prototype = /** @lends PDFDocumentProxy.prototype */ {
/** /**
* @return {number} Total number of pages the PDF contains. * @return {number} Total number of pages the PDF contains.
*/ */
@ -213,15 +221,16 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return this.transport.embeddedFontsUsed; return this.transport.embeddedFontsUsed;
}, },
/** /**
* @param {number} The page number to get. The first page is 1. * @param {number} pageNumber The page number to get. The first page is 1.
* @return {Promise} A promise that is resolved with a {PDFPageProxy} * @return {Promise} A promise that is resolved with a {@link PDFPageProxy}
* object. * object.
*/ */
getPage: function PDFDocumentProxy_getPage(number) { getPage: function PDFDocumentProxy_getPage(pageNumber) {
return this.transport.getPage(number); return this.transport.getPage(pageNumber);
}, },
/** /**
* @param {object} Must have 'num' and 'gen' properties. * @param {{num: number, gen: number}} ref The page reference. Must have
* the 'num' and 'gen' properties.
* @return {Promise} A promise that is resolved with the page index that is * @return {Promise} A promise that is resolved with the page index that is
* associated with the reference. * associated with the reference.
*/ */
@ -246,7 +255,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return promise; return promise;
}, },
/** /**
* @return {Promise} A promise that is resolved with an {array} that is a * @return {Promise} A promise that is resolved with an {Array} that is a
* tree outline (if it has one) of the PDF. The tree is in the format of: * tree outline (if it has one) of the PDF. The tree is in the format of:
* [ * [
* { * {
@ -267,8 +276,8 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return promise; return promise;
}, },
/** /**
* @return {Promise} A promise that is resolved with an {object} that has * @return {Promise} A promise that is resolved with an {Object} that has
* info and metadata properties. Info is an {object} filled with anything * info and metadata properties. Info is an {Object} filled with anything
* available in the information dictionary and similarly metadata is a * available in the information dictionary and similarly metadata is a
* {Metadata} object with information from the metadata section of the PDF. * {Metadata} object with information from the metadata section of the PDF.
*/ */
@ -282,11 +291,6 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
}); });
return promise; return promise;
}, },
isEncrypted: function PDFDocumentProxy_isEncrypted() {
var promise = new PDFJS.LegacyPromise();
promise.resolve(this.pdfInfo.encrypted);
return promise;
},
/** /**
* @return {Promise} A promise that is resolved with a TypedArray that has * @return {Promise} A promise that is resolved with a TypedArray that has
* the raw data from the PDF. * the raw data from the PDF.
@ -303,9 +307,15 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
dataLoaded: function PDFDocumentProxy_dataLoaded() { dataLoaded: function PDFDocumentProxy_dataLoaded() {
return this.transport.dataLoaded(); return this.transport.dataLoaded();
}, },
/**
* Cleans up resources allocated by the document, e.g. created @font-face.
*/
cleanup: function PDFDocumentProxy_cleanup() { cleanup: function PDFDocumentProxy_cleanup() {
this.transport.startCleanup(); this.transport.startCleanup();
}, },
/**
* Destroys current document instance and terminates worker.
*/
destroy: function PDFDocumentProxy_destroy() { destroy: function PDFDocumentProxy_destroy() {
this.transport.destroy(); this.transport.destroy();
} }
@ -313,6 +323,22 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
return PDFDocumentProxy; return PDFDocumentProxy;
})(); })();
/**
* Page text content part.
*
* @typedef {Object} BidiText
* @property {string} str - text content.
* @property {string} dir - text direction: 'ttb', 'ltr' or 'rtl'.
* @property {number} x - x position of the text on the page.
* @property {number} y - y position of the text on the page.
* @property {number} angle - text rotation.
* @property {number} size - font size.
*/
/**
* Proxy to a PDFPage in the worker thread.
* @class
*/
var PDFPageProxy = (function PDFPageProxyClosure() { var PDFPageProxy = (function PDFPageProxyClosure() {
function PDFPageProxy(pageInfo, transport) { function PDFPageProxy(pageInfo, transport) {
this.pageInfo = pageInfo; this.pageInfo = pageInfo;
@ -326,7 +352,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
this.pendingDestroy = false; this.pendingDestroy = false;
this.renderTasks = []; this.renderTasks = [];
} }
PDFPageProxy.prototype = { PDFPageProxy.prototype = /** @lends PDFPageProxy.prototype */ {
/** /**
* @return {number} Page number of the page. First page is 1. * @return {number} Page number of the page. First page is 1.
*/ */
@ -340,14 +366,14 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return this.pageInfo.rotate; return this.pageInfo.rotate;
}, },
/** /**
* @return {object} The reference that points to this page. It has 'num' and * @return {Object} The reference that points to this page. It has 'num' and
* 'gen' properties. * 'gen' properties.
*/ */
get ref() { get ref() {
return this.pageInfo.ref; return this.pageInfo.ref;
}, },
/** /**
* @return {array} An array of the visible portion of the PDF page in the * @return {Array} An array of the visible portion of the PDF page in the
* user space units - [x1, y1, x2, y2]. * user space units - [x1, y1, x2, y2].
*/ */
get view() { get view() {
@ -366,7 +392,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
}, },
/** /**
* @return {Promise} A promise that is resolved with an {array} of the * @return {Promise} A promise that is resolved with an {Array} of the
* annotation objects. * annotation objects.
*/ */
getAnnotations: function PDFPageProxy_getAnnotations() { getAnnotations: function PDFPageProxy_getAnnotations() {
@ -380,7 +406,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
}, },
/** /**
* Begins the process of rendering a page to the desired context. * Begins the process of rendering a page to the desired context.
* @param {object} params A parameter object that supports: * @param {Object} params A parameter object that supports:
* { * {
* canvasContext(required): A 2D context of a DOM Canvas object., * canvasContext(required): A 2D context of a DOM Canvas object.,
* textLayer(optional): An object that has beginLayout, endLayout, and * textLayer(optional): An object that has beginLayout, endLayout, and
@ -465,8 +491,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
return renderTask; return renderTask;
}, },
/** /**
* @return {Promise} That is resolved with the a {string} that is the text * @return {Promise} That is resolved with the array of {@link BidiText}
* content from the page. * objects that represent the page text content.
*/ */
getTextContent: function PDFPageProxy_getTextContent() { getTextContent: function PDFPageProxy_getTextContent() {
var promise = new PDFJS.LegacyPromise(); var promise = new PDFJS.LegacyPromise();
@ -479,18 +505,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
); );
return promise; return promise;
}, },
/**
* Stub for future feature.
*/
getOperationList: function PDFPageProxy_getOperationList() {
var promise = new PDFJS.LegacyPromise();
var operationList = { // not implemented
dependencyFontsID: null,
operatorList: null
};
promise.resolve(operationList);
return promise;
},
/** /**
* Destroys resources allocated by the page. * Destroys resources allocated by the page.
*/ */
@ -501,6 +515,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
/** /**
* For internal use only. Attempts to clean up if rendering is in a state * For internal use only. Attempts to clean up if rendering is in a state
* where that's possible. * where that's possible.
* @ignore
*/ */
_tryDestroy: function PDFPageProxy__destroy() { _tryDestroy: function PDFPageProxy__destroy() {
if (!this.pendingDestroy || if (!this.pendingDestroy ||
@ -516,12 +531,14 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
}, },
/** /**
* For internal use only. * For internal use only.
* @ignore
*/ */
_startRenderPage: function PDFPageProxy_startRenderPage(transparency) { _startRenderPage: function PDFPageProxy_startRenderPage(transparency) {
this.displayReadyPromise.resolve(transparency); this.displayReadyPromise.resolve(transparency);
}, },
/** /**
* For internal use only. * For internal use only.
* @ignore
*/ */
_renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk) { _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk) {
// Add the new chunk to the current operator list. // Add the new chunk to the current operator list.
@ -544,8 +561,10 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
}; };
return PDFPageProxy; return PDFPageProxy;
})(); })();
/** /**
* For internal use only. * For internal use only.
* @ignore
*/ */
var WorkerTransport = (function WorkerTransportClosure() { var WorkerTransport = (function WorkerTransportClosure() {
function WorkerTransport(workerInitializedPromise, workerReadyPromise, function WorkerTransport(workerInitializedPromise, workerReadyPromise,
@ -629,6 +648,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
this.pagePromises = []; this.pagePromises = [];
var self = this; var self = this;
this.messageHandler.send('Terminate', null, function () { this.messageHandler.send('Terminate', null, function () {
FontLoader.clear();
if (self.worker) { if (self.worker) {
self.worker.terminate(); self.worker.terminate();
} }
@ -971,6 +991,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
* for fonts, images, rendering code and such. These objects might get processed * for fonts, images, rendering code and such. These objects might get processed
* inside of a worker. The `PDFObjects` implements some basic functions to * inside of a worker. The `PDFObjects` implements some basic functions to
* manage these objects. * manage these objects.
* @ignore
*/ */
var PDFObjects = (function PDFObjectsClosure() { var PDFObjects = (function PDFObjectsClosure() {
function PDFObjects() { function PDFObjects() {
@ -1069,24 +1090,39 @@ var PDFObjects = (function PDFObjectsClosure() {
return PDFObjects; return PDFObjects;
})(); })();
/**
* Allows controlling of the rendering tasks.
* @class
*/
var RenderTask = (function RenderTaskClosure() { var RenderTask = (function RenderTaskClosure() {
function RenderTask(internalRenderTask) { function RenderTask(internalRenderTask) {
this.internalRenderTask = internalRenderTask; this.internalRenderTask = internalRenderTask;
/**
* Promise for rendering task completion.
* @type {Promise}
*/
this.promise = new PDFJS.LegacyPromise(); this.promise = new PDFJS.LegacyPromise();
} }
RenderTask.prototype = /** @lends RenderTask.prototype */ {
/** /**
* Cancel the rendering task. If the task is curently rendering it will not be * Cancels the rendering task. If the task is currently rendering it will
* cancelled until graphics pauses with a timeout. The promise that this * not be cancelled until graphics pauses with a timeout. The promise that
* object extends will resolved when cancelled. * this object extends will resolved when cancelled.
*/ */
RenderTask.prototype.cancel = function RenderTask_cancel() { cancel: function RenderTask_cancel() {
this.internalRenderTask.cancel(); this.internalRenderTask.cancel();
this.reject(new Error('Rendering is cancelled'));
}
}; };
return RenderTask; return RenderTask;
})(); })();
/**
* For internal use only.
* @ignore
*/
var InternalRenderTask = (function InternalRenderTaskClosure() { var InternalRenderTask = (function InternalRenderTaskClosure() {
function InternalRenderTask(callback, params, objs, commonObjs, operatorList, function InternalRenderTask(callback, params, objs, commonObjs, operatorList,