Dispatch event when annotations have finished rendering.
This is needed for some smoke tests in mozilla central for testing forms in pdf.js. Note: AnnotationLayerBuilder.render() doesn't really need to be async, but we're talking of making the annotation's render functions async, so this will make that switch easier.
This commit is contained in:
parent
ebb903e506
commit
7bba4931ad
@ -60,9 +60,11 @@ class AnnotationLayerBuilder {
|
|||||||
/**
|
/**
|
||||||
* @param {PageViewport} viewport
|
* @param {PageViewport} viewport
|
||||||
* @param {string} intent (default value is 'display')
|
* @param {string} intent (default value is 'display')
|
||||||
|
* @returns {Promise<void>} A promise that is resolved when rendering of the
|
||||||
|
* annotations is complete.
|
||||||
*/
|
*/
|
||||||
render(viewport, intent = "display") {
|
render(viewport, intent = "display") {
|
||||||
this.pdfPage.getAnnotations({ intent }).then(annotations => {
|
return this.pdfPage.getAnnotations({ intent }).then(annotations => {
|
||||||
if (this._cancelled) {
|
if (this._cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,24 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
async _renderAnnotationLayer() {
|
||||||
|
let error = null;
|
||||||
|
try {
|
||||||
|
await this.annotationLayer.render(this.viewport, "display");
|
||||||
|
} catch (ex) {
|
||||||
|
error = ex;
|
||||||
|
} finally {
|
||||||
|
this.eventBus.dispatch("annotationlayerrendered", {
|
||||||
|
source: this,
|
||||||
|
pageNumber: this.id,
|
||||||
|
error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -384,7 +402,7 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (redrawAnnotations && this.annotationLayer) {
|
if (redrawAnnotations && this.annotationLayer) {
|
||||||
this.annotationLayer.render(this.viewport, "display");
|
this._renderAnnotationLayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,7 +560,7 @@ class PDFPageView {
|
|||||||
this.l10n
|
this.l10n
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.annotationLayer.render(this.viewport, "display");
|
this._renderAnnotationLayer();
|
||||||
}
|
}
|
||||||
div.setAttribute("data-loaded", true);
|
div.setAttribute("data-loaded", true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user