1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Introduce more optional chaining in the src/core/ folder

After PR 12563 we're now free to use optional chaining in the worker-thread as well. (This patch also fixes one previously "missed" case in the `web/` folder.)

For the MOZCENTRAL build-target this patch reduces the total bundle-size by `1.6` kilobytes.
This commit is contained in:
Jonas Jenwald 2023-05-15 12:38:28 +02:00
parent c20c1b3362
commit 1b4a7c5965
27 changed files with 90 additions and 137 deletions

View file

@ -221,7 +221,7 @@ class PDFImage {
const max = (1 << bitsPerComponent) - 1;
this.decodeCoefficients = [];
this.decodeAddends = [];
const isIndexed = this.colorSpace && this.colorSpace.name === "Indexed";
const isIndexed = this.colorSpace?.name === "Indexed";
for (let i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
const dmin = this.decode[i];
const dmax = this.decode[i + 1];
@ -428,18 +428,14 @@ class PDFImage {
}
get drawWidth() {
return Math.max(
this.width,
(this.smask && this.smask.width) || 0,
(this.mask && this.mask.width) || 0
);
return Math.max(this.width, this.smask?.width || 0, this.mask?.width || 0);
}
get drawHeight() {
return Math.max(
this.height,
(this.smask && this.smask.height) || 0,
(this.mask && this.mask.height) || 0
this.smask?.height || 0,
this.mask?.height || 0
);
}
@ -640,7 +636,7 @@ class PDFImage {
'PDFImage.undoPreblend: Unsupported "buffer" type.'
);
}
const matte = this.smask && this.smask.matte;
const matte = this.smask?.matte;
if (!matte) {
return;
}