Merge pull request #12875 from Snuffleupagus/src-display-more-optional-chaining

Replace some ternary operators with optional chaining, and nullish coalescing, in the `src/display/`-folder
This commit is contained in:
Tim van der Meij 2021-01-19 18:58:01 +01:00 committed by GitHub
commit 5e1e0e03a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 14 deletions

View File

@ -2605,7 +2605,7 @@ class WorkerTransport {
.sendWithPromise("SaveDocument", {
numPages: this._numPages,
annotationStorage: annotationStorage?.getAll() || null,
filename: this._fullReader ? this._fullReader.filename : null,
filename: this._fullReader?.filename ?? null,
})
.finally(() => {
if (annotationStorage) {
@ -2800,7 +2800,7 @@ class PDFObjects {
has(objId) {
const obj = this._objs[objId];
return obj ? obj.resolved : false;
return obj?.resolved || false;
}
/**

View File

@ -1506,10 +1506,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
if (!fontObj) {
throw new Error(`Can't find font for ${fontRefName}`);
}
current.fontMatrix = fontObj.fontMatrix
? fontObj.fontMatrix
: FONT_IDENTITY_MATRIX;
current.fontMatrix = fontObj.fontMatrix || FONT_IDENTITY_MATRIX;
// A valid matrix needs all main diagonal elements to be non-zero
// This also ensures we bypass FF bugzilla bug #719844.

View File

@ -66,7 +66,7 @@ class PDFFetchStream {
}
get _progressiveDataLength() {
return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
return this._fullRequestReader?._loaded ?? 0;
}
getFullReader() {

View File

@ -146,7 +146,7 @@ class Metadata {
}
get(name) {
return this._metadataMap.has(name) ? this._metadataMap.get(name) : null;
return this._metadataMap.get(name) ?? null;
}
getAll() {

View File

@ -69,7 +69,7 @@ class PDFNodeStream {
}
get _progressiveDataLength() {
return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
return this._fullRequestReader?._loaded ?? 0;
}
getFullReader() {

View File

@ -981,10 +981,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
this.addFontStyle(fontObj);
this.embeddedFonts[fontObj.loadedName] = fontObj;
}
current.fontMatrix = fontObj.fontMatrix
? fontObj.fontMatrix
: FONT_IDENTITY_MATRIX;
current.fontMatrix = fontObj.fontMatrix || FONT_IDENTITY_MATRIX;
let bold = "normal";
if (fontObj.black) {

View File

@ -83,7 +83,7 @@ class PDFDataTransportStream {
}
get _progressiveDataLength() {
return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
return this._fullRequestReader?._loaded ?? 0;
}
_onProgress(evt) {