Remove the closure used with the InternalRenderTask
class
This patch utilizes the same approach as used in lots of other parts of the code-base, which thus *slightly* reduces the size of this code.
This commit is contained in:
parent
b18620ac0f
commit
4c679d80ac
@ -3063,11 +3063,11 @@ class RenderTask {
|
||||
* For internal use only.
|
||||
* @ignore
|
||||
*/
|
||||
const InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
const canvasInRendering = new WeakSet();
|
||||
|
||||
// eslint-disable-next-line no-shadow
|
||||
class InternalRenderTask {
|
||||
static get canvasInUse() {
|
||||
return shadow(this, "canvasInUse", new WeakSet());
|
||||
}
|
||||
|
||||
constructor({
|
||||
callback,
|
||||
params,
|
||||
@ -3117,14 +3117,14 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
return;
|
||||
}
|
||||
if (this._canvas) {
|
||||
if (canvasInRendering.has(this._canvas)) {
|
||||
if (InternalRenderTask.canvasInUse.has(this._canvas)) {
|
||||
throw new Error(
|
||||
"Cannot use the same canvas during multiple render() operations. " +
|
||||
"Use different canvas or ensure previous operations were " +
|
||||
"cancelled or completed."
|
||||
);
|
||||
}
|
||||
canvasInRendering.add(this._canvas);
|
||||
InternalRenderTask.canvasInUse.add(this._canvas);
|
||||
}
|
||||
|
||||
if (this._pdfBug && globalThis.StepperManager?.enabled) {
|
||||
@ -3163,7 +3163,7 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
this.gfx.endDrawing();
|
||||
}
|
||||
if (this._canvas) {
|
||||
canvasInRendering.delete(this._canvas);
|
||||
InternalRenderTask.canvasInUse.delete(this._canvas);
|
||||
}
|
||||
this.callback(
|
||||
error ||
|
||||
@ -3229,15 +3229,13 @@ const InternalRenderTask = (function InternalRenderTaskClosure() {
|
||||
if (this.operatorList.lastChunk) {
|
||||
this.gfx.endDrawing();
|
||||
if (this._canvas) {
|
||||
canvasInRendering.delete(this._canvas);
|
||||
InternalRenderTask.canvasInUse.delete(this._canvas);
|
||||
}
|
||||
this.callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return InternalRenderTask;
|
||||
})();
|
||||
|
||||
/** @type {string} */
|
||||
const version =
|
||||
|
Loading…
x
Reference in New Issue
Block a user