Add a InternalRenderTask.completed
getter and use it to simplify PDFPageProxy._destroy
This patch aims to simplify the `PDFPageProxy._destroy` method, by: - Replacing the unnecessary `forEach` with a "regular" `for`-loop instead. - Use a more appropriate variable name, since `intentState.renderTasks` contain instances of `InternalRenderTask`. - Move the "is rendering completed"-handling to a new `InternalRenderTask.completed` getter, to abstract away some (mostly) internal `InternalRenderTask` state.
This commit is contained in:
parent
a04a5d8325
commit
cabc2cc4fc
@ -1234,13 +1234,10 @@ class PDFPageProxy {
|
||||
// Avoid errors below, since the renderTasks are just stubs.
|
||||
return;
|
||||
}
|
||||
intentState.renderTasks.forEach(function (renderTask) {
|
||||
const renderCompleted = renderTask.capability.promise.catch(
|
||||
function () {}
|
||||
); // ignoring failures
|
||||
waitOn.push(renderCompleted);
|
||||
renderTask.cancel();
|
||||
});
|
||||
for (const internalRenderTask of intentState.renderTasks) {
|
||||
waitOn.push(internalRenderTask.completed);
|
||||
internalRenderTask.cancel();
|
||||
}
|
||||
});
|
||||
this.objs.clear();
|
||||
this.annotationsPromise = null;
|
||||
@ -2650,6 +2647,13 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
this._canvas = params.canvasContext.canvas;
|
||||
}
|
||||
|
||||
get completed() {
|
||||
return this.capability.promise.catch(function () {
|
||||
// Ignoring errors, since we only want to know when rendering is
|
||||
// no longer pending.
|
||||
});
|
||||
}
|
||||
|
||||
initializeGraphics(transparency = false) {
|
||||
if (this.cancelled) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user