mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Introduce a helper method, in PDFPageView
, for dispatching "...layerrendered" events
Currently we repeat virtually the same, with the exception of the name, event dispatching code four times for the different viewer layers.
This commit is contained in:
parent
db86f8132e
commit
303e793264
1 changed files with 12 additions and 22 deletions
|
@ -361,6 +361,14 @@ class PDFPageView {
|
|||
);
|
||||
}
|
||||
|
||||
#dispatchLayerRendered(name, error) {
|
||||
this.eventBus.dispatch(name, {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
error,
|
||||
});
|
||||
}
|
||||
|
||||
async #renderAnnotationLayer() {
|
||||
let error = null;
|
||||
try {
|
||||
|
@ -369,11 +377,7 @@ class PDFPageView {
|
|||
console.error(`#renderAnnotationLayer: "${ex}".`);
|
||||
error = ex;
|
||||
} finally {
|
||||
this.eventBus.dispatch("annotationlayerrendered", {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
error,
|
||||
});
|
||||
this.#dispatchLayerRendered("annotationlayerrendered", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,11 +389,7 @@ class PDFPageView {
|
|||
console.error(`#renderAnnotationEditorLayer: "${ex}".`);
|
||||
error = ex;
|
||||
} finally {
|
||||
this.eventBus.dispatch("annotationeditorlayerrendered", {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
error,
|
||||
});
|
||||
this.#dispatchLayerRendered("annotationeditorlayerrendered", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,12 +422,7 @@ class PDFPageView {
|
|||
this.#addLayer(this.xfaLayer.div, "xfaLayer");
|
||||
this.l10n.resume();
|
||||
}
|
||||
|
||||
this.eventBus.dispatch("xfalayerrendered", {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
error,
|
||||
});
|
||||
this.#dispatchLayerRendered("xfalayerrendered", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -446,12 +441,7 @@ class PDFPageView {
|
|||
console.error(`#renderTextLayer: "${ex}".`);
|
||||
error = ex;
|
||||
}
|
||||
|
||||
this.eventBus.dispatch("textlayerrendered", {
|
||||
source: this,
|
||||
pageNumber: this.id,
|
||||
error,
|
||||
});
|
||||
this.#dispatchLayerRendered("textlayerrendered", error);
|
||||
|
||||
this.#renderStructTreeLayer();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue