Merge pull request #16440 from Snuffleupagus/more-modern-JS

Introduce even more modern JavaScript features in the code-base
This commit is contained in:
Jonas Jenwald 2023-05-18 20:56:00 +02:00 committed by GitHub
commit 3be66f59d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 25 additions and 31 deletions

View File

@ -477,11 +477,7 @@ class CCITTFaxDecoder {
this.byteAlign = options.EncodedByteAlign || false;
this.columns = options.Columns || 1728;
this.rows = options.Rows || 0;
let eoblock = options.EndOfBlock;
if (eoblock === null || eoblock === undefined) {
eoblock = true;
}
this.eoblock = eoblock;
this.eoblock = options.EndOfBlock ?? true;
this.black = options.BlackIs1 || false;
this.codingLine = new Uint32Array(this.columns + 1);

View File

@ -928,8 +928,8 @@ const CalGrayCS = (function CalGrayCSClosure() {
"WhitePoint missing - required for color space CalGray"
);
}
blackPoint = blackPoint || [0, 0, 0];
gamma = gamma || 1;
blackPoint ||= [0, 0, 0];
gamma ||= 1;
// Translate arguments to spec variables.
this.XW = whitePoint[0];

View File

@ -1702,7 +1702,7 @@ class PDFDocument {
get calculationOrderIds() {
const acroForm = this.catalog.acroForm;
if (!acroForm || !acroForm.has("CO")) {
if (!acroForm?.has("CO")) {
return shadow(this, "calculationOrderIds", null);
}

View File

@ -2579,7 +2579,7 @@ class Font {
if (!isTrueType) {
const isComposite =
properties.composite &&
((properties.cidToGidMap || []).length > 0 ||
(properties.cidToGidMap?.length > 0 ||
!(properties.cMap instanceof IdentityCMap));
// OpenType font (skip composite fonts with non-default glyph mapping).
if (

View File

@ -1282,7 +1282,7 @@ class Parser {
tok = tok2 || this.lexer.next();
if (tok.id === TOKEN.step) {
[tok, step] = this.parseSimpleExpr();
tok = tok || this.lexer.next();
tok ||= this.lexer.next();
}
if (tok.id !== TOKEN.do) {

View File

@ -932,7 +932,7 @@ class Border extends XFAObject {
const { edges } = this[$getExtra]();
const edgeStyles = edges.map(node => {
const style = node[$toStyle]();
style.color = style.color || "#000000";
style.color ||= "#000000";
return style;
});
@ -3871,7 +3871,7 @@ class NumericEdit extends XFAObject {
attributes: {
type: "text",
fieldId: field[$uid],
dataId: (field[$data] && field[$data][$uid]) || field[$uid],
dataId: field[$data]?.[$uid] || field[$uid],
class: ["xfaTextfield"],
style,
"aria-label": ariaLabel(field),

View File

@ -2061,7 +2061,7 @@ class CanvasGraphics {
}
if (isAddToPathSet) {
const paths = this.pendingTextPaths || (this.pendingTextPaths = []);
const paths = (this.pendingTextPaths ||= []);
paths.push({
transform: getCurrentTransform(ctx),
x,

View File

@ -760,22 +760,20 @@ class PDFDateString {
}
// Lazily initialize the regular expression.
if (!pdfDateStringRegex) {
pdfDateStringRegex = new RegExp(
"^D:" + // Prefix (required)
"(\\d{4})" + // Year (required)
"(\\d{2})?" + // Month (optional)
"(\\d{2})?" + // Day (optional)
"(\\d{2})?" + // Hour (optional)
"(\\d{2})?" + // Minute (optional)
"(\\d{2})?" + // Second (optional)
"([Z|+|-])?" + // Universal time relation (optional)
"(\\d{2})?" + // Offset hour (optional)
"'?" + // Splitting apostrophe (optional)
"(\\d{2})?" + // Offset minute (optional)
"'?" // Trailing apostrophe (optional)
);
}
pdfDateStringRegex ||= new RegExp(
"^D:" + // Prefix (required)
"(\\d{4})" + // Year (required)
"(\\d{2})?" + // Month (optional)
"(\\d{2})?" + // Day (optional)
"(\\d{2})?" + // Hour (optional)
"(\\d{2})?" + // Minute (optional)
"(\\d{2})?" + // Second (optional)
"([Z|+|-])?" + // Universal time relation (optional)
"(\\d{2})?" + // Offset hour (optional)
"'?" + // Splitting apostrophe (optional)
"(\\d{2})?" + // Offset minute (optional)
"'?" // Trailing apostrophe (optional)
);
// Optional fields that don't satisfy the requirements from the regular
// expression (such as incorrect digit counts or numbers that are out of

View File

@ -371,7 +371,7 @@ class Field extends PDFObject {
nIdx = Array.isArray(this._currentValueIndices)
? this._currentValueIndices[0]
: this._currentValueIndices;
nIdx = nIdx || 0;
nIdx ||= 0;
}
if (nIdx < 0 || nIdx >= this.numItems) {

View File

@ -373,7 +373,7 @@ class ChromePreferences extends BasePreferences {
);
chrome.storage.managed.get(defaultManagedPrefs, function (items) {
items = items || defaultManagedPrefs;
items ||= defaultManagedPrefs;
// Migration logic for deprecated preferences: If the new preference
// 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