mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Use more optional chaining in the code-base
This patch updates a bunch of older code, that makes conditional function calls, to use optional chaining rather than `if`-blocks. These mostly mechanical changes reduce the size of the `gulp mozcentral` build by a little over 1 kB.
This commit is contained in:
parent
9578152ae4
commit
38ee28b1d3
15 changed files with 51 additions and 119 deletions
|
@ -1354,9 +1354,7 @@ class PDFPageProxy {
|
|||
pageColors = null,
|
||||
printAnnotationStorage = null,
|
||||
}) {
|
||||
if (this._stats) {
|
||||
this._stats.time("Overall");
|
||||
}
|
||||
this._stats?.time("Overall");
|
||||
|
||||
const intentArgs = this._transport.getRenderingIntent(
|
||||
intent,
|
||||
|
@ -1401,9 +1399,7 @@ class PDFPageProxy {
|
|||
separateAnnots: null,
|
||||
};
|
||||
|
||||
if (this._stats) {
|
||||
this._stats.time("Page Request");
|
||||
}
|
||||
this._stats?.time("Page Request");
|
||||
this._pumpOperatorList(intentArgs);
|
||||
}
|
||||
|
||||
|
@ -1427,10 +1423,9 @@ class PDFPageProxy {
|
|||
} else {
|
||||
internalRenderTask.capability.resolve();
|
||||
}
|
||||
if (this._stats) {
|
||||
this._stats.timeEnd("Rendering");
|
||||
this._stats.timeEnd("Overall");
|
||||
}
|
||||
|
||||
this._stats?.timeEnd("Rendering");
|
||||
this._stats?.timeEnd("Overall");
|
||||
};
|
||||
|
||||
const internalRenderTask = new InternalRenderTask({
|
||||
|
@ -1465,9 +1460,8 @@ class PDFPageProxy {
|
|||
complete();
|
||||
return;
|
||||
}
|
||||
if (this._stats) {
|
||||
this._stats.time("Rendering");
|
||||
}
|
||||
this._stats?.time("Rendering");
|
||||
|
||||
internalRenderTask.initializeGraphics({
|
||||
transparency,
|
||||
optionalContentConfig,
|
||||
|
@ -1523,9 +1517,7 @@ class PDFPageProxy {
|
|||
separateAnnots: null,
|
||||
};
|
||||
|
||||
if (this._stats) {
|
||||
this._stats.time("Page Request");
|
||||
}
|
||||
this._stats?.time("Page Request");
|
||||
this._pumpOperatorList(intentArgs);
|
||||
}
|
||||
return intentState.opListReadCapability.promise;
|
||||
|
@ -1697,14 +1689,11 @@ class PDFPageProxy {
|
|||
if (!intentState) {
|
||||
return; // Rendering was cancelled.
|
||||
}
|
||||
if (this._stats) {
|
||||
this._stats.timeEnd("Page Request");
|
||||
}
|
||||
this._stats?.timeEnd("Page Request");
|
||||
|
||||
// TODO Refactor RenderPageRequest to separate rendering
|
||||
// and operator list logic
|
||||
if (intentState.displayReadyCapability) {
|
||||
intentState.displayReadyCapability.resolve(transparency);
|
||||
}
|
||||
intentState.displayReadyCapability?.resolve(transparency);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3259,17 +3248,14 @@ class InternalRenderTask {
|
|||
});
|
||||
this.operatorListIdx = 0;
|
||||
this.graphicsReady = true;
|
||||
if (this.graphicsReadyCallback) {
|
||||
this.graphicsReadyCallback();
|
||||
}
|
||||
this.graphicsReadyCallback?.();
|
||||
}
|
||||
|
||||
cancel(error = null) {
|
||||
this.running = false;
|
||||
this.cancelled = true;
|
||||
if (this.gfx) {
|
||||
this.gfx.endDrawing();
|
||||
}
|
||||
this.gfx?.endDrawing();
|
||||
|
||||
if (this._canvas) {
|
||||
InternalRenderTask.#canvasInUse.delete(this._canvas);
|
||||
}
|
||||
|
@ -3289,10 +3275,7 @@ class InternalRenderTask {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.stepper) {
|
||||
this.stepper.updateOperatorList(this.operatorList);
|
||||
}
|
||||
this.stepper?.updateOperatorList(this.operatorList);
|
||||
|
||||
if (this.running) {
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue