Simplify initialization of static class properties in the worker-thread

Now that we no longer depend on the old Babel version in SystemJS we can remove the `static get ...` work-arounds used to define constants, which leads to slightly more compact code.
This commit is contained in:
Jonas Jenwald 2023-03-15 12:20:41 +01:00
parent d950b91c4e
commit b0a1af306d
6 changed files with 16 additions and 58 deletions

View File

@ -182,13 +182,9 @@ function incrementCachedImageMaskCount(data) {
// Trying to minimize Date.now() usage and check every 100 time.
class TimeSlotManager {
static get TIME_SLOT_DURATION_MS() {
return shadow(this, "TIME_SLOT_DURATION_MS", 20);
}
static TIME_SLOT_DURATION_MS = 20;
static get CHECK_TIME_EVERY() {
return shadow(this, "CHECK_TIME_EVERY", 100);
}
static CHECK_TIME_EVERY = 100;
constructor() {
this.reset();
@ -4838,9 +4834,7 @@ class EvaluatorPreprocessor {
return shadow(this, "opMap", getOPMap());
}
static get MAX_INVALID_PATH_OPS() {
return shadow(this, "MAX_INVALID_PATH_OPS", 10);
}
static MAX_INVALID_PATH_OPS = 10;
constructor(stream, xref, stateManager = new StateManager()) {
// TODO(mduan): pass array of knownCommands rather than this.opMap

View File

@ -513,9 +513,7 @@ function isPDFFunction(v) {
}
class PostScriptStack {
static get MAX_STACK_SIZE() {
return shadow(this, "MAX_STACK_SIZE", 100);
}
static MAX_STACK_SIZE = 100;
constructor(initialStack) {
this.stack = initialStack ? Array.from(initialStack) : [];

View File

@ -16,7 +16,6 @@
import {
assert,
MAX_IMAGE_SIZE_TO_CACHE,
shadow,
unreachable,
warn,
} from "../shared/util.js";
@ -173,17 +172,11 @@ class RegionalImageCache extends BaseLocalCache {
}
class GlobalImageCache {
static get NUM_PAGES_THRESHOLD() {
return shadow(this, "NUM_PAGES_THRESHOLD", 2);
}
static NUM_PAGES_THRESHOLD = 2;
static get MIN_IMAGES_TO_CACHE() {
return shadow(this, "MIN_IMAGES_TO_CACHE", 10);
}
static MIN_IMAGES_TO_CACHE = 10;
static get MAX_BYTE_SIZE() {
return shadow(this, "MAX_BYTE_SIZE", 5 * MAX_IMAGE_SIZE_TO_CACHE);
}
static MAX_BYTE_SIZE = 5 * MAX_IMAGE_SIZE_TO_CACHE;
constructor() {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {

View File

@ -13,13 +13,7 @@
* limitations under the License.
*/
import {
ImageKind,
OPS,
RenderingIntentFlag,
shadow,
warn,
} from "../shared/util.js";
import { ImageKind, OPS, RenderingIntentFlag, warn } from "../shared/util.js";
function addState(parentState, pattern, checkFn, iterateFn, processFn) {
let state = parentState;
@ -586,14 +580,10 @@ class QueueOptimizer extends NullOptimizer {
}
class OperatorList {
static get CHUNK_SIZE() {
return shadow(this, "CHUNK_SIZE", 1000);
}
static CHUNK_SIZE = 1000;
// Close to chunk size.
static get CHUNK_SIZE_ABOUT() {
return shadow(this, "CHUNK_SIZE_ABOUT", this.CHUNK_SIZE - 5);
}
static CHUNK_SIZE_ABOUT = this.CHUNK_SIZE - 5;
constructor(intent = 0, streamSink) {
this._streamSink = streamSink;

View File

@ -17,7 +17,6 @@ import {
assert,
FormatError,
info,
shadow,
unreachable,
Util,
warn,
@ -89,9 +88,7 @@ class Pattern {
class BaseShading {
// A small number to offset the first/last color stops so we can insert ones
// to support extend. Number.MIN_VALUE is too small and breaks the extend.
static get SMALL_NUMBER() {
return shadow(this, "SMALL_NUMBER", 1e-6);
}
static SMALL_NUMBER = 1e-6;
constructor() {
if (this.constructor === BaseShading) {
@ -374,18 +371,12 @@ const getB = (function getBClosure() {
})();
class MeshShading extends BaseShading {
static get MIN_SPLIT_PATCH_CHUNKS_AMOUNT() {
return shadow(this, "MIN_SPLIT_PATCH_CHUNKS_AMOUNT", 3);
}
static MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
static get MAX_SPLIT_PATCH_CHUNKS_AMOUNT() {
return shadow(this, "MAX_SPLIT_PATCH_CHUNKS_AMOUNT", 20);
}
static MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
// Count of triangles per entire mesh bounds.
static get TRIANGLE_DENSITY() {
return shadow(this, "TRIANGLE_DENSITY", 20);
}
static TRIANGLE_DENSITY = 20;
constructor(
stream,

View File

@ -13,13 +13,7 @@
* limitations under the License.
*/
import {
FormatError,
info,
shadow,
unreachable,
Util,
} from "../shared/util.js";
import { FormatError, info, unreachable, Util } from "../shared/util.js";
import { getCurrentTransform } from "./display_utils.js";
const PathType = {
@ -462,9 +456,7 @@ const PaintType = {
class TilingPattern {
// 10in @ 300dpi shall be enough.
static get MAX_PATTERN_SIZE() {
return shadow(this, "MAX_PATTERN_SIZE", 3000);
}
static MAX_PATTERN_SIZE = 3000;
constructor(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
this.operatorList = IR[2];