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

View File

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

View File

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

View File

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

View File

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

View File

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