Move IsLittleEndianCached
and IsEvalSupportedCached
to src/shared/util.js
Rather than duplicating the lookup and caching in multiple files, it seems easier to simply move all of this functionality into `src/shared/util.js` instead. This will also help avoid a bunch of ESLint errors once the `no-shadow` rule is eventually enabled.
This commit is contained in:
parent
6db8e085ee
commit
e4758beaaa
@ -17,19 +17,12 @@ import {
|
||||
FormatError,
|
||||
info,
|
||||
isBool,
|
||||
isEvalSupported,
|
||||
shadow,
|
||||
IsEvalSupportedCached,
|
||||
unreachable,
|
||||
} from "../shared/util.js";
|
||||
import { isDict, isStream } from "./primitives.js";
|
||||
import { PostScriptLexer, PostScriptParser } from "./ps_parser.js";
|
||||
|
||||
const IsEvalSupportedCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isEvalSupported());
|
||||
},
|
||||
};
|
||||
|
||||
class PDFFunctionFactory {
|
||||
constructor({ xref, isEvalSupported = true }) {
|
||||
this.xref = xref;
|
||||
|
@ -18,7 +18,7 @@ import {
|
||||
IDENTITY_MATRIX,
|
||||
ImageKind,
|
||||
info,
|
||||
isLittleEndian,
|
||||
IsLittleEndianCached,
|
||||
isNum,
|
||||
OPS,
|
||||
shadow,
|
||||
@ -46,12 +46,6 @@ var MAX_SIZE_TO_COMPILE = 1000;
|
||||
|
||||
var FULL_CHUNK_HEIGHT = 16;
|
||||
|
||||
var IsLittleEndianCached = {
|
||||
get value() {
|
||||
return shadow(IsLittleEndianCached, "value", isLittleEndian());
|
||||
},
|
||||
};
|
||||
|
||||
function addContextCurrentTransform(ctx) {
|
||||
// If the context doesn't expose a `mozCurrentTransform`, add a JS based one.
|
||||
if (!ctx.mozCurrentTransform) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
import {
|
||||
assert,
|
||||
bytesToString,
|
||||
isEvalSupported,
|
||||
IsEvalSupportedCached,
|
||||
shadow,
|
||||
string32,
|
||||
unreachable,
|
||||
@ -337,12 +337,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||
};
|
||||
} // End of PDFJSDev.test('CHROME || GENERIC')
|
||||
|
||||
const IsEvalSupportedCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isEvalSupported());
|
||||
},
|
||||
};
|
||||
|
||||
class FontFaceObject {
|
||||
constructor(
|
||||
translatedData,
|
||||
|
@ -547,14 +547,18 @@ function string32(value) {
|
||||
);
|
||||
}
|
||||
|
||||
// Lazy test the endianness of the platform
|
||||
// NOTE: This will be 'true' for simulated TypedArrays
|
||||
// Checks the endianness of the platform.
|
||||
function isLittleEndian() {
|
||||
const buffer8 = new Uint8Array(4);
|
||||
buffer8[0] = 1;
|
||||
const view32 = new Uint32Array(buffer8.buffer, 0, 1);
|
||||
return view32[0] === 1;
|
||||
}
|
||||
const IsLittleEndianCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isLittleEndian());
|
||||
},
|
||||
};
|
||||
|
||||
// Checks if it's possible to eval JS expressions.
|
||||
function isEvalSupported() {
|
||||
@ -565,6 +569,11 @@ function isEvalSupported() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
const IsEvalSupportedCached = {
|
||||
get value() {
|
||||
return shadow(this, "value", isEvalSupported());
|
||||
},
|
||||
};
|
||||
|
||||
const rgbBuf = ["rgb(", 0, ",", 0, ",", 0, ")"];
|
||||
|
||||
@ -918,8 +927,8 @@ export {
|
||||
isString,
|
||||
isSameOrigin,
|
||||
createValidAbsoluteUrl,
|
||||
isLittleEndian,
|
||||
isEvalSupported,
|
||||
IsLittleEndianCached,
|
||||
IsEvalSupportedCached,
|
||||
removeNullCharacters,
|
||||
setVerbosityLevel,
|
||||
shadow,
|
||||
|
Loading…
Reference in New Issue
Block a user