1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

[api-minor] Refactor the annotation code to be asynchronous

This commit is the first step towards implementing parsing for the
appearance streams of annotations.

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>
Co-authored-by: Tim van der Meij <timvandermeij@gmail.com>
This commit is contained in:
dmitryskey 2018-03-20 20:43:40 -04:00 committed by Tim van der Meij
parent c8ee63319d
commit 3741becb9b
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
4 changed files with 482 additions and 432 deletions

View file

@ -26,13 +26,25 @@ import { Stream } from './stream';
class AnnotationFactory {
/**
* Create an `Annotation` object of the correct type for the given reference
* to an annotation dictionary. This yields a promise that is resolved when
* the `Annotation` object is constructed.
*
* @param {XRef} xref
* @param {Object} ref
* @param {PDFManager} pdfManager
* @param {Object} idFactory
* @returns {Annotation}
* @return {Promise} A promise that is resolved with an {Annotation} instance.
*/
static create(xref, ref, pdfManager, idFactory) {
return pdfManager.ensure(this, '_create',
[xref, ref, pdfManager, idFactory]);
}
/**
* @private
*/
static _create(xref, ref, pdfManager, idFactory) {
let dict = xref.fetchIfRef(ref);
if (!isDict(dict)) {
return;