Introduce even more modern JavaScript features in the code-base
After PR 12563 we're now free to use e.g. logical OR assignment, nullish coalescing, and optional chaining in the entire code-base.
This commit is contained in:
parent
a24d5b629e
commit
e8030752f3
@ -477,11 +477,7 @@ class CCITTFaxDecoder {
|
|||||||
this.byteAlign = options.EncodedByteAlign || false;
|
this.byteAlign = options.EncodedByteAlign || false;
|
||||||
this.columns = options.Columns || 1728;
|
this.columns = options.Columns || 1728;
|
||||||
this.rows = options.Rows || 0;
|
this.rows = options.Rows || 0;
|
||||||
let eoblock = options.EndOfBlock;
|
this.eoblock = options.EndOfBlock ?? true;
|
||||||
if (eoblock === null || eoblock === undefined) {
|
|
||||||
eoblock = true;
|
|
||||||
}
|
|
||||||
this.eoblock = eoblock;
|
|
||||||
this.black = options.BlackIs1 || false;
|
this.black = options.BlackIs1 || false;
|
||||||
|
|
||||||
this.codingLine = new Uint32Array(this.columns + 1);
|
this.codingLine = new Uint32Array(this.columns + 1);
|
||||||
|
@ -928,8 +928,8 @@ const CalGrayCS = (function CalGrayCSClosure() {
|
|||||||
"WhitePoint missing - required for color space CalGray"
|
"WhitePoint missing - required for color space CalGray"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
blackPoint = blackPoint || [0, 0, 0];
|
blackPoint ||= [0, 0, 0];
|
||||||
gamma = gamma || 1;
|
gamma ||= 1;
|
||||||
|
|
||||||
// Translate arguments to spec variables.
|
// Translate arguments to spec variables.
|
||||||
this.XW = whitePoint[0];
|
this.XW = whitePoint[0];
|
||||||
|
@ -1702,7 +1702,7 @@ class PDFDocument {
|
|||||||
|
|
||||||
get calculationOrderIds() {
|
get calculationOrderIds() {
|
||||||
const acroForm = this.catalog.acroForm;
|
const acroForm = this.catalog.acroForm;
|
||||||
if (!acroForm || !acroForm.has("CO")) {
|
if (!acroForm?.has("CO")) {
|
||||||
return shadow(this, "calculationOrderIds", null);
|
return shadow(this, "calculationOrderIds", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2579,7 +2579,7 @@ class Font {
|
|||||||
if (!isTrueType) {
|
if (!isTrueType) {
|
||||||
const isComposite =
|
const isComposite =
|
||||||
properties.composite &&
|
properties.composite &&
|
||||||
((properties.cidToGidMap || []).length > 0 ||
|
(properties.cidToGidMap?.length > 0 ||
|
||||||
!(properties.cMap instanceof IdentityCMap));
|
!(properties.cMap instanceof IdentityCMap));
|
||||||
// OpenType font (skip composite fonts with non-default glyph mapping).
|
// OpenType font (skip composite fonts with non-default glyph mapping).
|
||||||
if (
|
if (
|
||||||
|
@ -1282,7 +1282,7 @@ class Parser {
|
|||||||
tok = tok2 || this.lexer.next();
|
tok = tok2 || this.lexer.next();
|
||||||
if (tok.id === TOKEN.step) {
|
if (tok.id === TOKEN.step) {
|
||||||
[tok, step] = this.parseSimpleExpr();
|
[tok, step] = this.parseSimpleExpr();
|
||||||
tok = tok || this.lexer.next();
|
tok ||= this.lexer.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok.id !== TOKEN.do) {
|
if (tok.id !== TOKEN.do) {
|
||||||
|
@ -932,7 +932,7 @@ class Border extends XFAObject {
|
|||||||
const { edges } = this[$getExtra]();
|
const { edges } = this[$getExtra]();
|
||||||
const edgeStyles = edges.map(node => {
|
const edgeStyles = edges.map(node => {
|
||||||
const style = node[$toStyle]();
|
const style = node[$toStyle]();
|
||||||
style.color = style.color || "#000000";
|
style.color ||= "#000000";
|
||||||
return style;
|
return style;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3871,7 +3871,7 @@ class NumericEdit extends XFAObject {
|
|||||||
attributes: {
|
attributes: {
|
||||||
type: "text",
|
type: "text",
|
||||||
fieldId: field[$uid],
|
fieldId: field[$uid],
|
||||||
dataId: (field[$data] && field[$data][$uid]) || field[$uid],
|
dataId: field[$data]?.[$uid] || field[$uid],
|
||||||
class: ["xfaTextfield"],
|
class: ["xfaTextfield"],
|
||||||
style,
|
style,
|
||||||
"aria-label": ariaLabel(field),
|
"aria-label": ariaLabel(field),
|
||||||
|
@ -2061,7 +2061,7 @@ class CanvasGraphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isAddToPathSet) {
|
if (isAddToPathSet) {
|
||||||
const paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
const paths = (this.pendingTextPaths ||= []);
|
||||||
paths.push({
|
paths.push({
|
||||||
transform: getCurrentTransform(ctx),
|
transform: getCurrentTransform(ctx),
|
||||||
x,
|
x,
|
||||||
|
@ -760,22 +760,20 @@ class PDFDateString {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Lazily initialize the regular expression.
|
// Lazily initialize the regular expression.
|
||||||
if (!pdfDateStringRegex) {
|
pdfDateStringRegex ||= new RegExp(
|
||||||
pdfDateStringRegex = new RegExp(
|
"^D:" + // Prefix (required)
|
||||||
"^D:" + // Prefix (required)
|
"(\\d{4})" + // Year (required)
|
||||||
"(\\d{4})" + // Year (required)
|
"(\\d{2})?" + // Month (optional)
|
||||||
"(\\d{2})?" + // Month (optional)
|
"(\\d{2})?" + // Day (optional)
|
||||||
"(\\d{2})?" + // Day (optional)
|
"(\\d{2})?" + // Hour (optional)
|
||||||
"(\\d{2})?" + // Hour (optional)
|
"(\\d{2})?" + // Minute (optional)
|
||||||
"(\\d{2})?" + // Minute (optional)
|
"(\\d{2})?" + // Second (optional)
|
||||||
"(\\d{2})?" + // Second (optional)
|
"([Z|+|-])?" + // Universal time relation (optional)
|
||||||
"([Z|+|-])?" + // Universal time relation (optional)
|
"(\\d{2})?" + // Offset hour (optional)
|
||||||
"(\\d{2})?" + // Offset hour (optional)
|
"'?" + // Splitting apostrophe (optional)
|
||||||
"'?" + // Splitting apostrophe (optional)
|
"(\\d{2})?" + // Offset minute (optional)
|
||||||
"(\\d{2})?" + // Offset minute (optional)
|
"'?" // Trailing apostrophe (optional)
|
||||||
"'?" // Trailing apostrophe (optional)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional fields that don't satisfy the requirements from the regular
|
// Optional fields that don't satisfy the requirements from the regular
|
||||||
// expression (such as incorrect digit counts or numbers that are out of
|
// expression (such as incorrect digit counts or numbers that are out of
|
||||||
|
@ -371,7 +371,7 @@ class Field extends PDFObject {
|
|||||||
nIdx = Array.isArray(this._currentValueIndices)
|
nIdx = Array.isArray(this._currentValueIndices)
|
||||||
? this._currentValueIndices[0]
|
? this._currentValueIndices[0]
|
||||||
: this._currentValueIndices;
|
: this._currentValueIndices;
|
||||||
nIdx = nIdx || 0;
|
nIdx ||= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nIdx < 0 || nIdx >= this.numItems) {
|
if (nIdx < 0 || nIdx >= this.numItems) {
|
||||||
|
@ -373,7 +373,7 @@ class ChromePreferences extends BasePreferences {
|
|||||||
);
|
);
|
||||||
|
|
||||||
chrome.storage.managed.get(defaultManagedPrefs, function (items) {
|
chrome.storage.managed.get(defaultManagedPrefs, function (items) {
|
||||||
items = items || defaultManagedPrefs;
|
items ||= defaultManagedPrefs;
|
||||||
// Migration logic for deprecated preferences: If the new preference
|
// Migration logic for deprecated preferences: If the new preference
|
||||||
// is not defined by an administrator (i.e. the value is the same as
|
// is not defined by an administrator (i.e. the value is the same as
|
||||||
// the default value), and a deprecated preference is set with a
|
// the default value), and a deprecated preference is set with a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user