diff --git a/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm b/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm
--- a/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm
+++ b/toolkit/components/pdfjs/content/PdfJsDefaultPreferences.jsm
@@ -30,10 +30,12 @@
"enablePrintAutoRotate": true,
"enableScripting": true,
"externalLinkTarget": 0,
"historyUpdateUrl": false,
"ignoreDestinationZoom": false,
+ "pageColorsBackground": "Canvas",
+ "pageColorsForeground": "CanvasText",
"pdfBugEnabled": false,
"sidebarViewOnLoad": -1,
"scrollModeOnLoad": -1,
"spreadModeOnLoad": -1,
"textLayerMode": 1,
diff --git a/toolkit/components/pdfjs/content/build/pdf.js b/toolkit/components/pdfjs/content/build/pdf.js
--- a/toolkit/components/pdfjs/content/build/pdf.js
+++ b/toolkit/components/pdfjs/content/build/pdf.js
@@ -1073,11 +1073,11 @@
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.isNodeJS = void 0;
-const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
+const isNodeJS = false;
exports.isNodeJS = isNodeJS;
/***/ }),
/* 4 */
/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
@@ -1096,13 +1096,11 @@
var _display_utils = __w_pdfjs_require__(5);
var _font_loader = __w_pdfjs_require__(7);
-var _node_utils = __w_pdfjs_require__(8);
-
-var _annotation_storage = __w_pdfjs_require__(9);
+var _annotation_storage = __w_pdfjs_require__(8);
var _canvas = __w_pdfjs_require__(10);
var _worker_options = __w_pdfjs_require__(13);
@@ -1118,16 +1116,17 @@
var _xfa_text = __w_pdfjs_require__(18);
const DEFAULT_RANGE_CHUNK_SIZE = 65536;
const RENDERING_CANCELLED_TIMEOUT = 100;
-const DefaultCanvasFactory = _display_utils.DOMCanvasFactory;
+let DefaultCanvasFactory = _display_utils.DOMCanvasFactory;
exports.DefaultCanvasFactory = DefaultCanvasFactory;
-const DefaultCMapReaderFactory = _display_utils.DOMCMapReaderFactory;
+let DefaultCMapReaderFactory = _display_utils.DOMCMapReaderFactory;
exports.DefaultCMapReaderFactory = DefaultCMapReaderFactory;
-const DefaultStandardFontDataFactory = _display_utils.DOMStandardFontDataFactory;
+let DefaultStandardFontDataFactory = _display_utils.DOMStandardFontDataFactory;
exports.DefaultStandardFontDataFactory = DefaultStandardFontDataFactory;
+;
let createPDFNetworkStream;
function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
createPDFNetworkStream = pdfNetworkStreamFactory;
}
@@ -1244,15 +1243,15 @@
if (typeof params.isEvalSupported !== "boolean") {
params.isEvalSupported = true;
}
if (typeof params.disableFontFace !== "boolean") {
- params.disableFontFace = false;
+ params.disableFontFace = _is_node.isNodeJS;
}
if (typeof params.useSystemFonts !== "boolean") {
- params.useSystemFonts = !params.disableFontFace;
+ params.useSystemFonts = !_is_node.isNodeJS && !params.disableFontFace;
}
if (typeof params.ownerDocument !== "object" || params.ownerDocument === null) {
params.ownerDocument = globalThis.document;
}
@@ -1340,11 +1339,11 @@
source.contentDispositionFilename = pdfDataRangeTransport.contentDispositionFilename;
}
const workerId = await worker.messageHandler.sendWithPromise("GetDocRequest", {
docId,
- apiVersion: '2.14.224',
+ apiVersion: '2.14.300',
source: {
data: source.data,
url: source.url,
password: source.password,
disableAutoFetch: source.disableAutoFetch,
@@ -1706,11 +1705,12 @@
transform = null,
imageLayer = null,
canvasFactory = null,
background = null,
optionalContentConfigPromise = null,
- annotationCanvasMap = null
+ annotationCanvasMap = null,
+ pageColors = null
}) {
if (this._stats) {
this._stats.time("Overall");
}
@@ -1796,11 +1796,12 @@
annotationCanvasMap,
operatorList: intentState.operatorList,
pageIndex: this._pageIndex,
canvasFactory: canvasFactoryInstance,
useRequestAnimationFrame: !intentPrint,
- pdfBug: this._pdfBug
+ pdfBug: this._pdfBug,
+ pageColors
});
(intentState.renderTasks ||= new Set()).add(internalRenderTask);
const renderTask = internalRenderTask.task;
Promise.all([intentState.displayReadyCapability.promise, optionalContentConfigPromise]).then(([transparency, optionalContentConfig]) => {
if (this.pendingCleanup) {
@@ -2481,11 +2482,11 @@
return this.#docStats;
}
getRenderingIntent(intent, annotationMode = _util.AnnotationMode.ENABLE, isOpList = false) {
let renderingIntent = _util.RenderingIntentFlag.DISPLAY;
- let lastModified = "";
+ let annotationHash = "";
switch (intent) {
case "any":
renderingIntent = _util.RenderingIntentFlag.ANY;
break;
@@ -2513,11 +2514,11 @@
renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_FORMS;
break;
case _util.AnnotationMode.ENABLE_STORAGE:
renderingIntent += _util.RenderingIntentFlag.ANNOTATIONS_STORAGE;
- lastModified = this.annotationStorage.lastModified;
+ annotationHash = this.annotationStorage.hash;
break;
default:
(0, _util.warn)(`getRenderingIntent - invalid annotationMode: ${annotationMode}`);
}
@@ -2526,11 +2527,11 @@
renderingIntent += _util.RenderingIntentFlag.OPLIST;
}
return {
renderingIntent,
- cacheKey: `${renderingIntent}_${lastModified}`
+ cacheKey: `${renderingIntent}_${annotationHash}`
};
}
destroy() {
if (this.destroyCapability) {
@@ -3203,11 +3204,12 @@
annotationCanvasMap,
operatorList,
pageIndex,
canvasFactory,
useRequestAnimationFrame = false,
- pdfBug = false
+ pdfBug = false,
+ pageColors = null
}) {
this.callback = callback;
this.params = params;
this.objs = objs;
this.commonObjs = commonObjs;
@@ -3215,10 +3217,11 @@
this.operatorListIdx = null;
this.operatorList = operatorList;
this._pageIndex = pageIndex;
this.canvasFactory = canvasFactory;
this._pdfBug = pdfBug;
+ this.pageColors = pageColors;
this.running = false;
this.graphicsReadyCallback = null;
this.graphicsReady = false;
this._useRequestAnimationFrame = useRequestAnimationFrame === true && typeof window !== "undefined";
this.cancelled = false;
@@ -3262,11 +3265,11 @@
viewport,
transform,
imageLayer,
background
} = this.params;
- this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, imageLayer, optionalContentConfig, this.annotationCanvasMap);
+ this.gfx = new _canvas.CanvasGraphics(canvasContext, this.commonObjs, this.objs, this.canvasFactory, imageLayer, optionalContentConfig, this.annotationCanvasMap, this.pageColors);
this.gfx.beginDrawing({
transform,
viewport,
transparency,
background
@@ -3360,13 +3363,13 @@
}
}
}
-const version = '2.14.224';
+const version = '2.14.300';
exports.version = version;
-const build = '2be19e828';
+const build = '96b125fb7';
exports.build = build;
/***/ }),
/* 5 */
/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
@@ -4247,58 +4250,19 @@
Object.defineProperty(exports, "__esModule", ({
value: true
}));
-exports.NodeStandardFontDataFactory = exports.NodeCanvasFactory = exports.NodeCMapReaderFactory = void 0;
-
-var _base_factory = __w_pdfjs_require__(6);
-
-var _is_node = __w_pdfjs_require__(3);
-
-var _util = __w_pdfjs_require__(1);
-
-let NodeCanvasFactory = class {
- constructor() {
- (0, _util.unreachable)("Not implemented: NodeCanvasFactory");
- }
-
-};
-exports.NodeCanvasFactory = NodeCanvasFactory;
-let NodeCMapReaderFactory = class {
- constructor() {
- (0, _util.unreachable)("Not implemented: NodeCMapReaderFactory");
- }
-
-};
-exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
-let NodeStandardFontDataFactory = class {
- constructor() {
- (0, _util.unreachable)("Not implemented: NodeStandardFontDataFactory");
- }
-
-};
-exports.NodeStandardFontDataFactory = NodeStandardFontDataFactory;
-;
-
-/***/ }),
-/* 9 */
-/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
-
-
-
-Object.defineProperty(exports, "__esModule", ({
- value: true
-}));
exports.AnnotationStorage = void 0;
+var _murmurhash = __w_pdfjs_require__(9);
+
var _util = __w_pdfjs_require__(1);
class AnnotationStorage {
constructor() {
this._storage = new Map();
- this._timeStamp = Date.now();
this._modified = false;
this.onSetModified = null;
this.onResetModified = null;
}
@@ -4310,10 +4274,14 @@
}
return Object.assign(defaultValue, value);
}
+ getRawValue(key) {
+ return this._storage.get(key);
+ }
+
setValue(key, value) {
const obj = this._storage.get(key);
let modified = false;
@@ -4329,12 +4297,10 @@
this._storage.set(key, value);
}
if (modified) {
- this._timeStamp = Date.now();
-
this._setModified();
}
}
getAll() {
@@ -4367,19 +4333,150 @@
get serializable() {
return this._storage.size > 0 ? this._storage : null;
}
- get lastModified() {
- return this._timeStamp.toString();
+ get hash() {
+ const hash = new _murmurhash.MurmurHash3_64();
+
+ for (const [key, value] of this._storage) {
+ hash.update(`${key}:${JSON.stringify(value)}`);
+ }
+
+ return hash.hexdigest();
}
}
exports.AnnotationStorage = AnnotationStorage;
/***/ }),
+/* 9 */
+/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
+
+
+
+Object.defineProperty(exports, "__esModule", ({
+ value: true
+}));
+exports.MurmurHash3_64 = void 0;
+
+var _util = __w_pdfjs_require__(1);
+
+const SEED = 0xc3d2e1f0;
+const MASK_HIGH = 0xffff0000;
+const MASK_LOW = 0xffff;
+
+class MurmurHash3_64 {
+ constructor(seed) {
+ this.h1 = seed ? seed & 0xffffffff : SEED;
+ this.h2 = seed ? seed & 0xffffffff : SEED;
+ }
+
+ update(input) {
+ let data, length;
+
+ if (typeof input === "string") {
+ data = new Uint8Array(input.length * 2);
+ length = 0;
+
+ for (let i = 0, ii = input.length; i < ii; i++) {
+ const code = input.charCodeAt(i);
+
+ if (code <= 0xff) {
+ data[length++] = code;
+ } else {
+ data[length++] = code >>> 8;
+ data[length++] = code & 0xff;
+ }
+ }
+ } else if ((0, _util.isArrayBuffer)(input)) {
+ data = input.slice();
+ length = data.byteLength;
+ } else {
+ throw new Error("Wrong data format in MurmurHash3_64_update. " + "Input must be a string or array.");
+ }
+
+ const blockCounts = length >> 2;
+ const tailLength = length - blockCounts * 4;
+ const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
+ let k1 = 0,
+ k2 = 0;
+ let h1 = this.h1,
+ h2 = this.h2;
+ const C1 = 0xcc9e2d51,
+ C2 = 0x1b873593;
+ const C1_LOW = C1 & MASK_LOW,
+ C2_LOW = C2 & MASK_LOW;
+
+ for (let i = 0; i < blockCounts; i++) {
+ if (i & 1) {
+ k1 = dataUint32[i];
+ k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
+ k1 = k1 << 15 | k1 >>> 17;
+ k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
+ h1 ^= k1;
+ h1 = h1 << 13 | h1 >>> 19;
+ h1 = h1 * 5 + 0xe6546b64;
+ } else {
+ k2 = dataUint32[i];
+ k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
+ k2 = k2 << 15 | k2 >>> 17;
+ k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
+ h2 ^= k2;
+ h2 = h2 << 13 | h2 >>> 19;
+ h2 = h2 * 5 + 0xe6546b64;
+ }
+ }
+
+ k1 = 0;
+
+ switch (tailLength) {
+ case 3:
+ k1 ^= data[blockCounts * 4 + 2] << 16;
+
+ case 2:
+ k1 ^= data[blockCounts * 4 + 1] << 8;
+
+ case 1:
+ k1 ^= data[blockCounts * 4];
+ k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
+ k1 = k1 << 15 | k1 >>> 17;
+ k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
+
+ if (blockCounts & 1) {
+ h1 ^= k1;
+ } else {
+ h2 ^= k1;
+ }
+
+ }
+
+ this.h1 = h1;
+ this.h2 = h2;
+ }
+
+ hexdigest() {
+ let h1 = this.h1,
+ h2 = this.h2;
+ h1 ^= h2 >>> 1;
+ h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
+ h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
+ h1 ^= h2 >>> 1;
+ h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
+ h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
+ h1 ^= h2 >>> 1;
+ const hex1 = (h1 >>> 0).toString(16),
+ hex2 = (h2 >>> 0).toString(16);
+ return hex1.padStart(8, "0") + hex2.padStart(8, "0");
+ }
+
+}
+
+exports.MurmurHash3_64 = MurmurHash3_64;
+
+/***/ }),
/* 10 */
/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
@@ -4392,10 +4489,12 @@
var _pattern_helper = __w_pdfjs_require__(11);
var _image_utils = __w_pdfjs_require__(12);
+var _is_node = __w_pdfjs_require__(3);
+
var _display_utils = __w_pdfjs_require__(5);
const MIN_FONT_SIZE = 16;
const MAX_FONT_SIZE = 100;
const MAX_GROUP_SIZE = 4096;
@@ -4693,25 +4792,69 @@
}
}
}
+function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH) {
+ const [a, b, c, d, tx, ty] = ctx.mozCurrentTransform;
+
+ if (b === 0 && c === 0) {
+ const tlX = destX * a + tx;
+ const rTlX = Math.round(tlX);
+ const tlY = destY * d + ty;
+ const rTlY = Math.round(tlY);
+ const brX = (destX + destW) * a + tx;
+ const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
+ const brY = (destY + destH) * d + ty;
+ const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
+ ctx.setTransform(Math.sign(a), 0, 0, Math.sign(d), rTlX, rTlY);
+ ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rWidth, rHeight);
+ ctx.setTransform(a, b, c, d, tx, ty);
+ return [rWidth, rHeight];
+ }
+
+ if (a === 0 && d === 0) {
+ const tlX = destY * c + tx;
+ const rTlX = Math.round(tlX);
+ const tlY = destX * b + ty;
+ const rTlY = Math.round(tlY);
+ const brX = (destY + destH) * c + tx;
+ const rWidth = Math.abs(Math.round(brX) - rTlX) || 1;
+ const brY = (destX + destW) * b + ty;
+ const rHeight = Math.abs(Math.round(brY) - rTlY) || 1;
+ ctx.setTransform(0, Math.sign(b), Math.sign(c), 0, rTlX, rTlY);
+ ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, 0, 0, rHeight, rWidth);
+ ctx.setTransform(a, b, c, d, tx, ty);
+ return [rHeight, rWidth];
+ }
+
+ ctx.drawImage(srcImg, srcX, srcY, srcW, srcH, destX, destY, destW, destH);
+ const scaleX = Math.hypot(a, b);
+ const scaleY = Math.hypot(c, d);
+ return [scaleX * destW, scaleY * destH];
+}
+
function compileType3Glyph(imgData) {
+ const {
+ width,
+ height
+ } = imgData;
+
+ if (!COMPILE_TYPE3_GLYPHS || width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
+ return null;
+ }
+
const POINT_TO_PROCESS_LIMIT = 1000;
const POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]);
- const width = imgData.width,
- height = imgData.height,
- width1 = width + 1;
- let i, ii, j, j0;
- const points = new Uint8Array(width1 * (height + 1));
- const lineSize = width + 7 & ~7,
- data0 = imgData.data;
- const data = new Uint8Array(lineSize * height);
- let pos = 0;
-
- for (i = 0, ii = data0.length; i < ii; i++) {
- const elem = data0[i];
+ const width1 = width + 1;
+ let points = new Uint8Array(width1 * (height + 1));
+ let i, j, j0;
+ const lineSize = width + 7 & ~7;
+ let data = new Uint8Array(lineSize * height),
+ pos = 0;
+
+ for (const elem of imgData.data) {
let mask = 128;
while (mask > 0) {
data[pos++] = elem & mask ? 0 : 255;
mask >>= 1;
@@ -4797,11 +4940,17 @@
if (count > POINT_TO_PROCESS_LIMIT) {
return null;
}
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
- const outlines = [];
+ let path, outlines, coords;
+
+ if (!_is_node.isNodeJS) {
+ path = new Path2D();
+ } else {
+ outlines = [];
+ }
for (i = 0; count && i <= height; i++) {
let p = i * width1;
const end = p + width;
@@ -4811,11 +4960,16 @@
if (p === end) {
continue;
}
- const coords = [p % width1, i];
+ if (path) {
+ path.moveTo(p % width1, i);
+ } else {
+ coords = [p % width1, i];
+ }
+
const p0 = p;
let type = points[p];
do {
const step = steps[type];
@@ -4832,37 +4986,52 @@
} else {
type = pp & 0x33 * type >> 4;
points[p] &= type >> 2 | type << 2;
}
- coords.push(p % width1, p / width1 | 0);
+ if (path) {
+ path.lineTo(p % width1, p / width1 | 0);
+ } else {
+ coords.push(p % width1, p / width1 | 0);
+ }
if (!points[p]) {
--count;
}
} while (p0 !== p);
- outlines.push(coords);
+ if (!path) {
+ outlines.push(coords);
+ }
+
--i;
}
+ data = null;
+ points = null;
+
const drawOutline = function (c) {
c.save();
c.scale(1 / width, -1 / height);
c.translate(0, -height);
- c.beginPath();
-
- for (let k = 0, kk = outlines.length; k < kk; k++) {
- const o = outlines[k];
- c.moveTo(o[0], o[1]);
-
- for (let l = 2, ll = o.length; l < ll; l += 2) {
- c.lineTo(o[l], o[l + 1]);
- }
- }
-
- c.fill();
+
+ if (path) {
+ c.fill(path);
+ } else {
+ c.beginPath();
+
+ for (const o of outlines) {
+ c.moveTo(o[0], o[1]);
+
+ for (let l = 2, ll = o.length; l < ll; l += 2) {
+ c.lineTo(o[l], o[l + 1]);
+ }
+ }
+
+ c.fill();
+ }
+
c.beginPath();
c.restore();
};
return drawOutline;
@@ -5227,13 +5396,12 @@
destCtx.setLineDash(sourceCtx.getLineDash());
destCtx.lineDashOffset = sourceCtx.lineDashOffset;
}
}
-function resetCtxToDefault(ctx) {
- ctx.strokeStyle = "#000000";
- ctx.fillStyle = "#000000";
+function resetCtxToDefault(ctx, foregroundColor) {
+ ctx.strokeStyle = ctx.fillStyle = foregroundColor || "#000000";
ctx.fillRule = "nonzero";
ctx.globalAlpha = 1;
ctx.lineWidth = 1;
ctx.lineCap = "butt";
ctx.lineJoin = "miter";
@@ -5354,11 +5522,11 @@
const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
const NORMAL_CLIP = {};
const EO_CLIP = {};
class CanvasGraphics {
- constructor(canvasCtx, commonObjs, objs, canvasFactory, imageLayer, optionalContentConfig, annotationCanvasMap) {
+ constructor(canvasCtx, commonObjs, objs, canvasFactory, imageLayer, optionalContentConfig, annotationCanvasMap, pageColors) {
this.ctx = canvasCtx;
this.current = new CanvasExtraState(this.ctx.canvas.width, this.ctx.canvas.height);
this.stateStack = [];
this.pendingClip = null;
this.pendingEOFill = false;
@@ -5384,10 +5552,12 @@
this.cachedPatterns = new Map();
this.annotationCanvasMap = annotationCanvasMap;
this.viewportScale = 1;
this.outputScaleX = 1;
this.outputScaleY = 1;
+ this.backgroundColor = pageColors?.background || null;
+ this.foregroundColor = pageColors?.foreground || null;
if (canvasCtx) {
addContextCurrentTransform(canvasCtx);
}
@@ -5410,12 +5580,44 @@
transparency = false,
background = null
}) {
const width = this.ctx.canvas.width;
const height = this.ctx.canvas.height;
+ const defaultBackgroundColor = background || "#ffffff";
this.ctx.save();
- this.ctx.fillStyle = background || "rgb(255, 255, 255)";
+
+ if (this.foregroundColor && this.backgroundColor) {
+ this.ctx.fillStyle = this.foregroundColor;
+ const fg = this.foregroundColor = this.ctx.fillStyle;
+ this.ctx.fillStyle = this.backgroundColor;
+ const bg = this.backgroundColor = this.ctx.fillStyle;
+ let isValidDefaultBg = true;
+ let defaultBg = defaultBackgroundColor;
+
+ if (fg === "#000000" && bg === "#ffffff" || fg === bg || !isValidDefaultBg) {
+ this.foregroundColor = this.backgroundColor = null;
+ } else {
+ const cB = parseInt(defaultBg.slice(1), 16);
+ const rB = (cB && 0xff0000) >> 16;
+ const gB = (cB && 0x00ff00) >> 8;
+ const bB = cB && 0x0000ff;
+
+ const newComp = x => {
+ x /= 255;
+ return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
+ };
+
+ const lumB = Math.round(0.2126 * newComp(rB) + 0.7152 * newComp(gB) + 0.0722 * newComp(bB));
+
+ this.selectColor = (r, g, b) => {
+ const lumC = 0.2126 * newComp(r) + 0.7152 * newComp(g) + 0.0722 * newComp(b);
+ return Math.round(lumC) === lumB ? bg : fg;
+ };
+ }
+ }
+
+ this.ctx.fillStyle = this.backgroundColor || defaultBackgroundColor;
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();
if (transparency) {
const transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
@@ -5425,11 +5627,11 @@
this.ctx.save();
this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
}
this.ctx.save();
- resetCtxToDefault(this.ctx);
+ resetCtxToDefault(this.ctx, this.foregroundColor);
if (transform) {
this.ctx.transform.apply(this.ctx, transform);
this.outputScaleX = transform[0];
this.outputScaleY = transform[0];
@@ -5627,12 +5829,12 @@
const cord2 = _util.Util.applyTransform([width, height], maskToCanvas);
const rect = _util.Util.normalizeRect([cord1[0], cord1[1], cord2[0], cord2[1]]);
- const drawnWidth = Math.ceil(rect[2] - rect[0]);
- const drawnHeight = Math.ceil(rect[3] - rect[1]);
+ const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
+ const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
const fillCanvas = this.cachedCanvases.getCanvas("fillCanvas", drawnWidth, drawnHeight, true);
const fillCtx = fillCanvas.context;
const offsetX = Math.min(cord1[0], cord2[0]);
const offsetY = Math.min(cord1[1], cord2[1]);
fillCtx.translate(-offsetX, -offsetY);
@@ -5646,11 +5848,11 @@
cache.set(cacheKey, scaled);
}
}
fillCtx.imageSmoothingEnabled = getImageSmoothingEnabled(fillCtx.mozCurrentTransform, img.interpolate);
- fillCtx.drawImage(scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
+ drawImageAtIntegerCoords(fillCtx, scaled, 0, 0, scaled.width, scaled.height, 0, 0, width, height);
fillCtx.globalCompositeOperation = "source-in";
const inverse = _util.Util.transform(fillCtx.mozCurrentTransformInverse, [1, 0, 0, 1, -offsetX, -offsetY]);
fillCtx.fillStyle = isPatternFill ? fillColor.getPattern(ctx, this, inverse, _pattern_helper.PathType.FILL) : fillColor;
@@ -6531,18 +6733,18 @@
this.current.fillColor = this.getColorN_Pattern(arguments);
this.current.patternFill = true;
}
setStrokeRGBColor(r, g, b) {
- const color = _util.Util.makeHexColor(r, g, b);
+ const color = this.selectColor?.(r, g, b) || _util.Util.makeHexColor(r, g, b);
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
}
setFillRGBColor(r, g, b) {
- const color = _util.Util.makeHexColor(r, g, b);
+ const color = this.selectColor?.(r, g, b) || _util.Util.makeHexColor(r, g, b);
this.ctx.fillStyle = color;
this.current.fillColor = color;
this.current.patternFill = false;
}
@@ -6812,13 +7014,13 @@
this.annotationCanvasMap.set(id, canvas);
this.annotationCanvas.savedCtx = this.ctx;
this.ctx = context;
this.ctx.setTransform(scaleX, 0, 0, -scaleY, 0, height * scaleY);
addContextCurrentTransform(this.ctx);
- resetCtxToDefault(this.ctx);
+ resetCtxToDefault(this.ctx, this.foregroundColor);
} else {
- resetCtxToDefault(this.ctx);
+ resetCtxToDefault(this.ctx, this.foregroundColor);
this.ctx.rect(rect[0], rect[1], width, height);
this.ctx.clip();
this.endPath();
}
}
@@ -6845,29 +7047,21 @@
const count = img.count;
img = this.getObject(img.data, img);
img.count = count;
const ctx = this.ctx;
- const width = img.width,
- height = img.height;
const glyph = this.processingType3;
- if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
- if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
- glyph.compiled = compileType3Glyph({
- data: img.data,
- width,
- height
- });
- } else {
- glyph.compiled = null;
- }
- }
-
- if (glyph?.compiled) {
- glyph.compiled(ctx);
- return;
+ if (glyph) {
+ if (glyph.compiled === undefined) {
+ glyph.compiled = compileType3Glyph(img);
+ }
+
+ if (glyph.compiled) {
+ glyph.compiled(ctx);
+ return;
+ }
}
const mask = this._createMaskCanvas(img);
const maskCanvas = mask.canvas;
@@ -6927,11 +7121,11 @@
maskCtx.fillRect(0, 0, width, height);
maskCtx.restore();
ctx.save();
ctx.transform.apply(ctx, image.transform);
ctx.scale(1, -1);
- ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
+ drawImageAtIntegerCoords(ctx, maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
ctx.restore();
}
this.compose();
}
@@ -7002,20 +7196,20 @@
}
const scaled = this._scaleImage(imgToPaint, ctx.mozCurrentTransformInverse);
ctx.imageSmoothingEnabled = getImageSmoothingEnabled(ctx.mozCurrentTransform, imgData.interpolate);
- ctx.drawImage(scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
+ const [rWidth, rHeight] = drawImageAtIntegerCoords(ctx, scaled.img, 0, 0, scaled.paintWidth, scaled.paintHeight, 0, -height, width, height);
if (this.imageLayer) {
const position = this.getCanvasPosition(0, -height);
this.imageLayer.appendImage({
imgData,
left: position[0],
top: position[1],
- width: width / ctx.mozCurrentTransformInverse[0],
- height: height / ctx.mozCurrentTransformInverse[3]
+ width: rWidth,
+ height: rHeight
});
}
this.compose();
this.restore();
@@ -7036,11 +7230,11 @@
for (let i = 0, ii = map.length; i < ii; i++) {
const entry = map[i];
ctx.save();
ctx.transform.apply(ctx, entry.transform);
ctx.scale(1, -1);
- ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
+ drawImageAtIntegerCoords(ctx, tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
if (this.imageLayer) {
const position = this.getCanvasPosition(entry.x, entry.y);
this.imageLayer.appendImage({
imgData,
@@ -7260,19 +7454,21 @@
exports.TilingPattern = exports.PathType = void 0;
exports.getShadingPattern = getShadingPattern;
var _util = __w_pdfjs_require__(1);
+var _is_node = __w_pdfjs_require__(3);
+
const PathType = {
FILL: "Fill",
STROKE: "Stroke",
SHADING: "Shading"
};
exports.PathType = PathType;
function applyBoundingBox(ctx, bbox) {
- if (!bbox || typeof Path2D === "undefined") {
+ if (!bbox || _is_node.isNodeJS) {
return;
}
const width = bbox[2] - bbox[0];
const height = bbox[3] - bbox[1];
@@ -9065,11 +9261,11 @@
var _util = __w_pdfjs_require__(1);
var _display_utils = __w_pdfjs_require__(5);
-var _annotation_storage = __w_pdfjs_require__(9);
+var _annotation_storage = __w_pdfjs_require__(8);
var _scripting_utils = __w_pdfjs_require__(20);
var _xfa_layer = __w_pdfjs_require__(21);
@@ -9294,10 +9490,117 @@
}
return container;
}
+ get _commonActions() {
+ const setColor = (jsName, styleName, event) => {
+ const color = event.detail[jsName];
+ event.target.style[styleName] = _scripting_utils.ColorConverters[`${color[0]}_HTML`](color.slice(1));
+ };
+
+ return (0, _util.shadow)(this, "_commonActions", {
+ display: event => {
+ const hidden = event.detail.display % 2 === 1;
+ event.target.style.visibility = hidden ? "hidden" : "visible";
+ this.annotationStorage.setValue(this.data.id, {
+ hidden,
+ print: event.detail.display === 0 || event.detail.display === 3
+ });
+ },
+ print: event => {
+ this.annotationStorage.setValue(this.data.id, {
+ print: event.detail.print
+ });
+ },
+ hidden: event => {
+ event.target.style.visibility = event.detail.hidden ? "hidden" : "visible";
+ this.annotationStorage.setValue(this.data.id, {
+ hidden: event.detail.hidden
+ });
+ },
+ focus: event => {
+ setTimeout(() => event.target.focus({
+ preventScroll: false
+ }), 0);
+ },
+ userName: event => {
+ event.target.title = event.detail.userName;
+ },
+ readonly: event => {
+ if (event.detail.readonly) {
+ event.target.setAttribute("readonly", "");
+ } else {
+ event.target.removeAttribute("readonly");
+ }
+ },
+ required: event => {
+ if (event.detail.required) {
+ event.target.setAttribute("required", "");
+ } else {
+ event.target.removeAttribute("required");
+ }
+ },
+ bgColor: event => {
+ setColor("bgColor", "backgroundColor", event);
+ },
+ fillColor: event => {
+ setColor("fillColor", "backgroundColor", event);
+ },
+ fgColor: event => {
+ setColor("fgColor", "color", event);
+ },
+ textColor: event => {
+ setColor("textColor", "color", event);
+ },
+ borderColor: event => {
+ setColor("borderColor", "borderColor", event);
+ },
+ strokeColor: event => {
+ setColor("strokeColor", "borderColor", event);
+ }
+ });
+ }
+
+ _dispatchEventFromSandbox(actions, jsEvent) {
+ const commonActions = this._commonActions;
+
+ for (const name of Object.keys(jsEvent.detail)) {
+ const action = actions[name] || commonActions[name];
+
+ if (action) {
+ action(jsEvent);
+ }
+ }
+ }
+
+ _setDefaultPropertiesFromJS(element) {
+ if (!this.enableScripting) {
+ return;
+ }
+
+ const storedData = this.annotationStorage.getRawValue(this.data.id);
+
+ if (!storedData) {
+ return;
+ }
+
+ const commonActions = this._commonActions;
+
+ for (const [actionName, detail] of Object.entries(storedData)) {
+ const action = commonActions[actionName];
+
+ if (action) {
+ action({
+ detail,
+ target: element
+ });
+ delete storedData[actionName];
+ }
+ }
+ }
+
_createQuadrilaterals(ignoreBorder = false) {
if (!this.data.quadPoints) {
return null;
}
@@ -9606,12 +9909,11 @@
switch (field.type) {
case "text":
{
const value = field.defaultValue || "";
storage.setValue(id, {
- value,
- valueAsString: value
+ value
});
break;
}
case "checkbox":
@@ -9750,87 +10052,10 @@
_setBackgroundColor(element) {
const color = this.data.backgroundColor || null;
element.style.backgroundColor = color === null ? "transparent" : _util.Util.makeHexColor(color[0], color[1], color[2]);
}
- _dispatchEventFromSandbox(actions, jsEvent) {
- const setColor = (jsName, styleName, event) => {
- const color = event.detail[jsName];
- event.target.style[styleName] = _scripting_utils.ColorConverters[`${color[0]}_HTML`](color.slice(1));
- };
-
- const commonActions = {
- display: event => {
- const hidden = event.detail.display % 2 === 1;
- event.target.style.visibility = hidden ? "hidden" : "visible";
- this.annotationStorage.setValue(this.data.id, {
- hidden,
- print: event.detail.display === 0 || event.detail.display === 3
- });
- },
- print: event => {
- this.annotationStorage.setValue(this.data.id, {
- print: event.detail.print
- });
- },
- hidden: event => {
- event.target.style.visibility = event.detail.hidden ? "hidden" : "visible";
- this.annotationStorage.setValue(this.data.id, {
- hidden: event.detail.hidden
- });
- },
- focus: event => {
- setTimeout(() => event.target.focus({
- preventScroll: false
- }), 0);
- },
- userName: event => {
- event.target.title = event.detail.userName;
- },
- readonly: event => {
- if (event.detail.readonly) {
- event.target.setAttribute("readonly", "");
- } else {
- event.target.removeAttribute("readonly");
- }
- },
- required: event => {
- if (event.detail.required) {
- event.target.setAttribute("required", "");
- } else {
- event.target.removeAttribute("required");
- }
- },
- bgColor: event => {
- setColor("bgColor", "backgroundColor", event);
- },
- fillColor: event => {
- setColor("fillColor", "backgroundColor", event);
- },
- fgColor: event => {
- setColor("fgColor", "color", event);
- },
- textColor: event => {
- setColor("textColor", "color", event);
- },
- borderColor: event => {
- setColor("borderColor", "borderColor", event);
- },
- strokeColor: event => {
- setColor("strokeColor", "borderColor", event);
- }
- };
-
- for (const name of Object.keys(jsEvent.detail)) {
- const action = actions[name] || commonActions[name];
-
- if (action) {
- action(jsEvent);
- }
- }
- }
-
}
class TextWidgetAnnotationElement extends WidgetAnnotationElement {
constructor(parameters) {
const isRenderable = parameters.renderForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
@@ -9859,17 +10084,17 @@
this.container.className = "textWidgetAnnotation";
let element = null;
if (this.renderForms) {
const storedData = storage.getValue(id, {
- value: this.data.fieldValue,
- valueAsString: this.data.fieldValue
+ value: this.data.fieldValue
});
- const textContent = storedData.valueAsString || storedData.value || "";
+ const textContent = storedData.formattedValue || storedData.value || "";
const elementData = {
userValue: null,
- formattedValue: null
+ formattedValue: null,
+ valueOnFocus: ""
};
if (this.data.multiLine) {
element = document.createElement("textarea");
element.textContent = textContent;
@@ -9890,60 +10115,62 @@
value: event.target.value
});
this.setPropertyOnSiblings(element, "value", event.target.value, "value");
});
element.addEventListener("resetform", event => {
- const defaultValue = this.data.defaultFieldValue || "";
+ const defaultValue = this.data.defaultFieldValue ?? "";
element.value = elementData.userValue = defaultValue;
- delete elementData.formattedValue;
+ elementData.formattedValue = null;
});
let blurListener = event => {
- if (elementData.formattedValue) {
- event.target.value = elementData.formattedValue;
+ const {
+ formattedValue
+ } = elementData;
+
+ if (formattedValue !== null && formattedValue !== undefined) {
+ event.target.value = formattedValue;
}
event.target.scrollLeft = 0;
};
if (this.enableScripting && this.hasJSActions) {
element.addEventListener("focus", event => {
if (elementData.userValue) {
event.target.value = elementData.userValue;
}
+
+ elementData.valueOnFocus = event.target.value;
});
element.addEventListener("updatefromsandbox", jsEvent => {
const actions = {
value(event) {
- elementData.userValue = event.detail.value || "";
+ elementData.userValue = event.detail.value ?? "";
storage.setValue(id, {
value: elementData.userValue.toString()
});
-
- if (!elementData.formattedValue) {
- event.target.value = elementData.userValue;
- }
+ event.target.value = elementData.userValue;
},
- valueAsString(event) {
- elementData.formattedValue = event.detail.valueAsString || "";
-
- if (event.target !== document.activeElement) {
- event.target.value = elementData.formattedValue;
+ formattedValue(event) {
+ const {
+ formattedValue
+ } = event.detail;
+ elementData.formattedValue = formattedValue;
+
+ if (formattedValue !== null && formattedValue !== undefined && event.target !== document.activeElement) {
+ event.target.value = formattedValue;
}
storage.setValue(id, {
- formattedValue: elementData.formattedValue
+ formattedValue
});
},
selRange(event) {
- const [selStart, selEnd] = event.detail.selRange;
-
- if (selStart >= 0 && selEnd < event.target.value.length) {
- event.target.setSelectionRange(selStart, selEnd);
- }
+ event.target.setSelectionRange(...event.detail.selRange);
}
};
this._dispatchEventFromSandbox(actions, jsEvent);
@@ -9961,36 +10188,47 @@
if (commitKey === -1) {
return;
}
- elementData.userValue = event.target.value;
+ const {
+ value
+ } = event.target;
+
+ if (elementData.valueOnFocus === value) {
+ return;
+ }
+
+ elementData.userValue = value;
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
- value: event.target.value,
+ value,
willCommit: true,
commitKey,
selStart: event.target.selectionStart,
selEnd: event.target.selectionEnd
}
});
});
const _blurListener = blurListener;
blurListener = null;
element.addEventListener("blur", event => {
- elementData.userValue = event.target.value;
-
- if (this._mouseState.isDown) {
+ const {
+ value
+ } = event.target;
+ elementData.userValue = value;
+
+ if (this._mouseState.isDown && elementData.valueOnFocus !== value) {
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
- value: event.target.value,
+ value,
willCommit: true,
commitKey: 1,
selStart: event.target.selectionStart,
selEnd: event.target.selectionEnd
}
@@ -10000,30 +10238,71 @@
_blurListener(event);
});
if (this.data.actions?.Keystroke) {
element.addEventListener("beforeinput", event => {
- elementData.formattedValue = "";
const {
data,
target
} = event;
const {
value,
selectionStart,
selectionEnd
} = target;
+ let selStart = selectionStart,
+ selEnd = selectionEnd;
+
+ switch (event.inputType) {
+ case "deleteWordBackward":
+ {
+ const match = value.substring(0, selectionStart).match(/\w*[^\w]*$/);
+
+ if (match) {
+ selStart -= match[0].length;
+ }
+
+ break;
+ }
+
+ case "deleteWordForward":
+ {
+ const match = value.substring(selectionStart).match(/^[^\w]*\w*/);
+
+ if (match) {
+ selEnd += match[0].length;
+ }
+
+ break;
+ }
+
+ case "deleteContentBackward":
+ if (selectionStart === selectionEnd) {
+ selStart -= 1;
+ }
+
+ break;
+
+ case "deleteContentForward":
+ if (selectionStart === selectionEnd) {
+ selEnd += 1;
+ }
+
+ break;
+ }
+
+ event.preventDefault();
this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
source: this,
detail: {
id,
name: "Keystroke",
value,
- change: data,
+ change: data || "",
willCommit: false,
- selStart: selectionStart,
- selEnd: selectionEnd
+ selStart,
+ selEnd
}
});
});
}
@@ -10053,10 +10332,12 @@
this._setTextStyle(element);
this._setBackgroundColor(element);
+ this._setDefaultPropertiesFromJS(element);
+
this.container.appendChild(element);
return this.container;
}
_setTextStyle(element) {
@@ -10161,10 +10442,12 @@
this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
}
this._setBackgroundColor(element);
+ this._setDefaultPropertiesFromJS(element);
+
this.container.appendChild(element);
return this.container;
}
}
@@ -10252,10 +10535,12 @@
this._setEventListeners(element, [["change", "Validate"], ["change", "Action"], ["focus", "Focus"], ["blur", "Blur"], ["mousedown", "Mouse Down"], ["mouseenter", "Mouse Enter"], ["mouseleave", "Mouse Exit"], ["mouseup", "Mouse Up"]], event => event.target.checked);
}
this._setBackgroundColor(element);
+ this._setDefaultPropertiesFromJS(element);
+
this.container.appendChild(element);
return this.container;
}
}
@@ -10273,10 +10558,12 @@
if (this.data.alternativeText) {
container.title = this.data.alternativeText;
}
+ this._setDefaultPropertiesFromJS(container);
+
return container;
}
}
@@ -10510,10 +10797,12 @@
});
}
this._setBackgroundColor(selectElement);
+ this._setDefaultPropertiesFromJS(selectElement);
+
this.container.appendChild(selectElement);
return this.container;
}
}
@@ -11076,11 +11365,10 @@
} = this.data.file;
this.filename = (0, _display_utils.getFilenameFromUrl)(filename);
this.content = content;
this.linkService.eventBus?.dispatch("fileattachmentannotation", {
source: this,
- id: (0, _util.stringToPDFString)(filename),
filename,
content
});
}
@@ -12219,11 +12507,10 @@
let styleCache = Object.create(null);
const canvas = this._document.createElement("canvas");
canvas.height = canvas.width = DEFAULT_FONT_SIZE;
- canvas.mozOpaque = true;
this._layoutTextCtx = canvas.getContext("2d", {
alpha: false
});
if (this._textContent) {
@@ -12636,14 +12923,14 @@
var _svg = __w_pdfjs_require__(23);
var _xfa_layer = __w_pdfjs_require__(21);
-const pdfjsVersion = '2.14.224';
-const pdfjsBuild = '2be19e828';
+const pdfjsVersion = '2.14.300';
+const pdfjsBuild = '96b125fb7';
;
})();
/******/ return __webpack_exports__;
/******/ })()
;
});
\ No newline at end of file
diff --git a/toolkit/components/pdfjs/content/build/pdf.scripting.js b/toolkit/components/pdfjs/content/build/pdf.scripting.js
--- a/toolkit/components/pdfjs/content/build/pdf.scripting.js
+++ b/toolkit/components/pdfjs/content/build/pdf.scripting.js
@@ -154,18 +154,17 @@
default:
field = new _field.Field(obj);
}
const wrapped = new Proxy(field, proxyHandler);
-
- doc._addField(name, wrapped);
-
const _object = {
obj: field,
wrapped
};
+ doc._addField(name, _object);
+
for (const object of objs) {
appObjects[object.id] = _object;
}
if (container) {
@@ -490,11 +489,10 @@
this._kidIds = data.kidIds || null;
this._fieldType = (0, _common.getFieldType)(this._actions);
this._siblings = data.siblings || null;
this._globalEval = data.globalEval;
this._appObjects = data.appObjects;
- this.valueAsString = data.valueAsString || this._value;
}
get currentValueIndices() {
if (!this._isChoice) {
return 0;
@@ -662,20 +660,14 @@
}
}
}
get valueAsString() {
- if (this._valueAsString === undefined) {
- this._valueAsString = this._value ? this._value.toString() : "";
- }
-
- return this._valueAsString;
- }
-
- set valueAsString(val) {
- this._valueAsString = val ? val.toString() : "";
- }
+ return (this._value ?? "").toString();
+ }
+
+ set valueAsString(_) {}
browseForFileToSubmit() {
if (this._browseForFileToSubmit) {
this._browseForFileToSubmit();
}
@@ -793,11 +785,11 @@
if (this._kidIds) {
return this._kidIds.map(id => this._appObjects[id].wrapped);
}
if (this._children === null) {
- this._children = this._document.obj._getChildren(this._fieldPath);
+ this._children = this._document.obj._getChildren(this._fieldPath).map(child => child.wrapped);
}
return this._children;
}
@@ -931,11 +923,11 @@
_isButton() {
return false;
}
_reset() {
- this.value = this.valueAsString = this.defaultValue;
+ this.value = this.defaultValue;
}
_runActions(event) {
const eventName = event.name;
@@ -2399,11 +2391,11 @@
addSubMenu() {}
addToolButton() {}
alert(cMsg, nIcon = 0, nType = 0, cTitle = "PDF.js", oDoc = null, oCheckbox = null) {
- if (typeof cMsg === "object") {
+ if (cMsg && typeof cMsg === "object") {
nType = cMsg.nType;
cMsg = cMsg.cMsg;
}
cMsg = (cMsg || "").toString();
@@ -2507,22 +2499,22 @@
popUpMenuEx() {}
removeToolButton() {}
response(cQuestion, cTitle = "", cDefault = "", bPassword = "", cLabel = "") {
- if (typeof cQuestion === "object") {
+ if (cQuestion && typeof cQuestion === "object") {
cDefault = cQuestion.cDefault;
cQuestion = cQuestion.cQuestion;
}
cQuestion = (cQuestion || "").toString();
cDefault = (cDefault || "").toString();
return this._externalCall("prompt", [cQuestion, cDefault || ""]);
}
setInterval(cExpr, nMilliseconds = 0) {
- if (typeof cExpr === "object") {
+ if (cExpr && typeof cExpr === "object") {
nMilliseconds = cExpr.nMilliseconds || 0;
cExpr = cExpr.cExpr;
}
if (typeof cExpr !== "string") {
@@ -2539,11 +2531,11 @@
return this._registerTimeout(callbackId, true);
}
setTimeOut(cExpr, nMilliseconds = 0) {
- if (typeof cExpr === "object") {
+ if (cExpr && typeof cExpr === "object") {
nMilliseconds = cExpr.nMilliseconds || 0;
cExpr = cExpr.cExpr;
}
if (typeof cExpr !== "string") {
@@ -2612,10 +2604,11 @@
constructor(document, calculationOrder, objects) {
this._document = document;
this._calculationOrder = calculationOrder;
this._objects = objects;
this._document.obj._eventDispatcher = this;
+ this._isCalculating = false;
}
mergeChange(event) {
let value = event.value;
@@ -2699,62 +2692,83 @@
this.runValidation(source, event);
return;
case "Action":
this.runActions(source, source, event, name);
-
- if (this._document.obj.calculate) {
- this.runCalculate(source, event);
- }
-
+ this.runCalculate(source, event);
return;
}
this.runActions(source, source, event, name);
- if (name === "Keystroke") {
- if (event.rc) {
- if (event.willCommit) {
- this.runValidation(source, event);
- } else if (event.change !== savedChange.change || event.selStart !== savedChange.selStart || event.selEnd !== savedChange.selEnd) {
- source.wrapped.value = this.mergeChange(event);
+ if (name !== "Keystroke") {
+ return;
+ }
+
+ if (event.rc) {
+ if (event.willCommit) {
+ this.runValidation(source, event);
+ } else {
+ const value = source.obj.value = this.mergeChange(event);
+ let selStart, selEnd;
+
+ if (event.selStart !== savedChange.selStart || event.selEnd !== savedChange.selEnd) {
+ selStart = event.selStart;
+ selEnd = event.selEnd;
+ } else {
+ selEnd = selStart = savedChange.selStart + event.change.length;
}
- } else if (!event.willCommit) {
+
source.obj._send({
id: source.obj._id,
- value: savedChange.value,
- selRange: [savedChange.selStart, savedChange.selEnd]
- });
- } else {
- source.obj._send({
- id: source.obj._id,
- value: "",
- selRange: [0, 0]
+ value,
+ selRange: [selStart, selEnd]
});
}
+ } else if (!event.willCommit) {
+ source.obj._send({
+ id: source.obj._id,
+ value: savedChange.value,
+ selRange: [savedChange.selStart, savedChange.selEnd]
+ });
+ } else {
+ source.obj._send({
+ id: source.obj._id,
+ value: "",
+ formattedValue: null,
+ selRange: [0, 0]
+ });
}
}
runValidation(source, event) {
- const hasRan = this.runActions(source, source, event, "Validate");
+ const didValidateRun = this.runActions(source, source, event, "Validate");
if (event.rc) {
- if (hasRan) {
- source.wrapped.value = event.value;
- source.wrapped.valueAsString = event.value;
- } else {
- source.obj.value = event.value;
- source.obj.valueAsString = event.value;
+ source.obj.value = event.value;
+ this.runCalculate(source, event);
+ const savedValue = event.value = source.obj.value;
+ let formattedValue = null;
+
+ if (this.runActions(source, source, event, "Format")) {
+ formattedValue = event.value?.toString?.();
}
- if (this._document.obj.calculate) {
- this.runCalculate(source, event);
- }
-
- event.value = source.obj.value;
- this.runActions(source, source, event, "Format");
- source.wrapped.valueAsString = event.value;
+ source.obj._send({
+ id: source.obj._id,
+ value: savedValue,
+ formattedValue
+ });
+
+ event.value = savedValue;
+ } else if (didValidateRun) {
+ source.obj._send({
+ id: source.obj._id,
+ value: "",
+ formattedValue: null,
+ selRange: [0, 0]
+ });
}
}
runActions(source, target, event, eventName) {
event.source = source.wrapped;
@@ -2764,59 +2778,79 @@
event.rc = true;
return target.obj._runActions(event);
}
calculateNow() {
- if (!this._calculationOrder) {
+ if (!this._calculationOrder || this._isCalculating || !this._document.obj.calculate) {
return;
}
+ this._isCalculating = true;
const first = this._calculationOrder[0];
const source = this._objects[first];
globalThis.event = new Event({});
- this.runCalculate(source, globalThis.event);
+
+ try {
+ this.runCalculate(source, globalThis.event);
+ } catch (error) {
+ this._isCalculating = false;
+ throw error;
+ }
+
+ this._isCalculating = false;
}
runCalculate(source, event) {
- if (!this._calculationOrder) {
+ if (!this._calculationOrder || !this._document.obj.calculate) {
return;
}
for (const targetId of this._calculationOrder) {
if (!(targetId in this._objects)) {
continue;
}
if (!this._document.obj.calculate) {
- continue;
+ break;
}
event.value = null;
const target = this._objects[targetId];
+ let savedValue = target.obj.value;
this.runActions(source, target, event, "Calculate");
if (!event.rc) {
continue;
}
if (event.value !== null) {
- target.wrapped.value = event.value;
+ target.obj.value = event.value;
}
event.value = target.obj.value;
this.runActions(target, target, event, "Validate");
if (!event.rc) {
+ if (target.obj.value !== savedValue) {
+ target.wrapped.value = savedValue;
+ }
+
continue;
}
- event.value = target.obj.value;
- this.runActions(target, target, event, "Format");
-
- if (event.value !== null) {
- target.wrapped.valueAsString = event.value;
+ savedValue = event.value = target.obj.value;
+ let formattedValue = null;
+
+ if (this.runActions(target, target, event, "Format")) {
+ formattedValue = event.value?.toString?.();
}
+
+ target.obj._send({
+ id: target.obj._id,
+ value: savedValue,
+ formattedValue
+ });
}
}
}
@@ -3786,12 +3820,12 @@
getDataObject() {}
getDataObjectContents() {}
- getField(cName) {
- if (typeof cName === "object") {
+ _getField(cName) {
+ if (cName && typeof cName === "object") {
cName = cName.cName;
}
if (typeof cName !== "string") {
throw new TypeError("Invalid field name: must be a string");
@@ -3834,10 +3868,20 @@
}
return null;
}
+ getField(cName) {
+ const field = this._getField(cName);
+
+ if (!field) {
+ return null;
+ }
+
+ return field.wrapped;
+ }
+
_getChildren(fieldName) {
const len = fieldName.length;
const children = [];
const pattern = /^\.[^.]+$/;
@@ -3859,11 +3903,11 @@
getLegalWarnings() {}
getLinks() {}
getNthFieldName(nIndex) {
- if (typeof nIndex === "object") {
+ if (nIndex && typeof nIndex === "object") {
nIndex = nIndex.nIndex;
}
if (typeof nIndex !== "number") {
throw new TypeError("Invalid field index: must be a number");
@@ -3941,11 +3985,11 @@
newPage() {}
openDataObject() {}
print(bUI = true, nStart = 0, nEnd = -1, bSilent = false, bShrinkToFit = false, bPrintAsImage = false, bReverse = false, bAnnotations = true, printParams = null) {
- if (typeof bUI === "object") {
+ if (bUI && typeof bUI === "object") {
nStart = bUI.nStart;
nEnd = bUI.nEnd;
bSilent = bUI.bSilent;
bShrinkToFit = bUI.bShrinkToFit;
bPrintAsImage = bUI.bPrintAsImage;
@@ -3998,39 +4042,59 @@
removeWeblinks() {}
replacePages() {}
resetForm(aFields = null) {
- if (aFields && !Array.isArray(aFields) && typeof aFields === "object") {
+ if (aFields && typeof aFields === "object") {
aFields = aFields.aFields;
}
+ if (aFields && !Array.isArray(aFields)) {
+ aFields = [aFields];
+ }
+
let mustCalculate = false;
+ let fieldsToReset;
if (aFields) {
+ fieldsToReset = [];
+
for (const fieldName of aFields) {
if (!fieldName) {
continue;
}
- const field = this.getField(fieldName);
+ if (typeof fieldName !== "string") {
+ fieldsToReset = null;
+ break;
+ }
+
+ const field = this._getField(fieldName);
if (!field) {
continue;
}
- field.value = field.defaultValue;
- field.valueAsString = field.value;
+ fieldsToReset.push(field);
mustCalculate = true;
}
- } else {
+ }
+
+ if (!fieldsToReset) {
+ fieldsToReset = this._fields.values();
mustCalculate = this._fields.size !== 0;
-
- for (const field of this._fields.values()) {
- field.value = field.defaultValue;
- field.valueAsString = field.value;
- }
+ }
+
+ for (const field of fieldsToReset) {
+ field.obj.value = field.obj.defaultValue;
+
+ this._send({
+ id: field.obj._id,
+ value: field.obj.defaultValue,
+ formattedValue: null,
+ selRange: [0, 0]
+ });
}
if (mustCalculate) {
this.calculateNow();
}
@@ -4954,13 +5018,13 @@
}
}));
var _initialization = __w_pdfjs_require__(1);
-const pdfjsVersion = '2.14.224';
-const pdfjsBuild = '2be19e828';
+const pdfjsVersion = '2.14.300';
+const pdfjsBuild = '96b125fb7';
})();
/******/ return __webpack_exports__;
/******/ })()
;
});
\ No newline at end of file
diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.js b/toolkit/components/pdfjs/content/build/pdf.worker.js
--- a/toolkit/components/pdfjs/content/build/pdf.worker.js
+++ b/toolkit/components/pdfjs/content/build/pdf.worker.js
@@ -115,11 +115,11 @@
let terminated = false;
let cancelXHRs = null;
const WorkerTasks = [];
const verbosity = (0, _util.getVerbosityLevel)();
const apiVersion = docParams.apiVersion;
- const workerVersion = '2.14.224';
+ const workerVersion = '2.14.300';
if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
}
@@ -1730,11 +1730,11 @@
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.isNodeJS = void 0;
-const isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
+const isNodeJS = false;
exports.isNodeJS = isNodeJS;
/***/ }),
/* 5 */
/***/ ((__unused_webpack_module, exports, __w_pdfjs_require__) => {
@@ -2490,22 +2490,21 @@
}
return this.bytes[this.pos++];
}
- getBytes(length, forceClamped = false) {
+ getBytes(length) {
const bytes = this.bytes;
const pos = this.pos;
const strEnd = this.end;
if (!length) {
if (strEnd > this.progressiveDataLength) {
this.ensureRange(pos, strEnd);
}
- const subarray = bytes.subarray(pos, strEnd);
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
+ return bytes.subarray(pos, strEnd);
}
let end = pos + length;
if (end > strEnd) {
@@ -2515,12 +2514,11 @@
if (end > this.progressiveDataLength) {
this.ensureRange(pos, end);
}
this.pos = end;
- const subarray = bytes.subarray(pos, end);
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
+ return bytes.subarray(pos, end);
}
getByteRange(begin, end) {
if (begin < 0) {
begin = 0;
@@ -3428,11 +3426,11 @@
getByte() {
(0, _util.unreachable)("Abstract method `getByte` called");
}
- getBytes(length, forceClamped = false) {
+ getBytes(length) {
(0, _util.unreachable)("Abstract method `getBytes` called");
}
peekByte() {
const peekedByte = this.getByte();
@@ -3442,12 +3440,12 @@
}
return peekedByte;
}
- peekBytes(length, forceClamped = false) {
- const bytes = this.getBytes(length, forceClamped);
+ peekBytes(length) {
+ const bytes = this.getBytes(length);
this.pos -= bytes.length;
return bytes;
}
getUint16() {
@@ -3472,11 +3470,11 @@
getByteRange(begin, end) {
(0, _util.unreachable)("Abstract method `getByteRange` called");
}
getString(length) {
- return (0, _util.bytesToString)(this.getBytes(length, false));
+ return (0, _util.bytesToString)(this.getBytes(length));
}
skip(n) {
this.pos += n || 1;
}
@@ -3540,29 +3538,27 @@
}
return this.bytes[this.pos++];
}
- getBytes(length, forceClamped = false) {
+ getBytes(length) {
const bytes = this.bytes;
const pos = this.pos;
const strEnd = this.end;
if (!length) {
- const subarray = bytes.subarray(pos, strEnd);
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
+ return bytes.subarray(pos, strEnd);
}
let end = pos + length;
if (end > strEnd) {
end = strEnd;
}
this.pos = end;
- const subarray = bytes.subarray(pos, end);
- return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
+ return bytes.subarray(pos, end);
}
getByteRange(begin, end) {
if (begin < 0) {
begin = 0;
@@ -6698,10 +6694,41 @@
setColor(color) {
this.color = getRgbColor(color);
}
+ setLineEndings(lineEndings) {
+ this.lineEndings = ["None", "None"];
+
+ if (Array.isArray(lineEndings) && lineEndings.length === 2) {
+ for (let i = 0; i < 2; i++) {
+ const obj = lineEndings[i];
+
+ if (obj instanceof _primitives.Name) {
+ switch (obj.name) {
+ case "None":
+ continue;
+
+ case "Square":
+ case "Circle":
+ case "Diamond":
+ case "OpenArrow":
+ case "ClosedArrow":
+ case "Butt":
+ case "ROpenArrow":
+ case "RClosedArrow":
+ case "Slash":
+ this.lineEndings[i] = obj.name;
+ continue;
+ }
+ }
+
+ (0, _util.warn)(`Ignoring invalid lineEnding: ${obj}`);
+ }
+ }
+ }
+
setBorderAndBackgroundColors(mk) {
if (mk instanceof _primitives.Dict) {
this.borderColor = getRgbColor(mk.getArray("BC"), null);
this.backgroundColor = getRgbColor(mk.getArray("BG"), null);
} else {
@@ -7372,11 +7399,11 @@
if (isPassword) {
return null;
}
const storageEntry = annotationStorage ? annotationStorage.get(this.data.id) : undefined;
- let value = storageEntry && storageEntry.value;
+ let value = storageEntry && (storageEntry.formattedValue || storageEntry.value);
if (value === undefined) {
if (!this._hasValueFromXFA || this.appearance) {
return null;
}
@@ -7386,10 +7413,11 @@
if (!value) {
return "";
}
}
+ (0, _util.assert)(typeof value === "string", "Expected `value` to be a string.");
value = value.trim();
if (value === "") {
return "";
}
@@ -7731,11 +7759,11 @@
getFieldObject() {
return {
id: this.data.id,
value: this.data.fieldValue,
- defaultValue: this.data.defaultFieldValue,
+ defaultValue: this.data.defaultFieldValue || "",
multiline: this.data.multiLine,
password: this.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD),
charLimit: this.data.maxLen,
comb: this.data.comb,
editable: !this.data.readOnly,
@@ -8463,19 +8491,24 @@
}
class LineAnnotation extends MarkupAnnotation {
constructor(parameters) {
super(parameters);
+ const {
+ dict
+ } = parameters;
this.data.annotationType = _util.AnnotationType.LINE;
- const lineCoordinates = parameters.dict.getArray("L");
+ const lineCoordinates = dict.getArray("L");
this.data.lineCoordinates = _util.Util.normalizeRect(lineCoordinates);
+ this.setLineEndings(dict.getArray("LE"));
+ this.data.lineEndings = this.lineEndings;
if (!this.appearance) {
const strokeColor = this.color ? Array.from(this.color).map(c => c / 255) : [0, 0, 0];
- const strokeAlpha = parameters.dict.get("CA");
+ const strokeAlpha = dict.get("CA");
let fillColor = null,
- interiorColor = parameters.dict.getArray("IC");
+ interiorColor = dict.getArray("IC");
if (interiorColor) {
interiorColor = getRgbColor(interiorColor, null);
fillColor = interiorColor ? Array.from(interiorColor).map(c => c / 255) : null;
}
@@ -8613,13 +8646,22 @@
}
class PolylineAnnotation extends MarkupAnnotation {
constructor(parameters) {
super(parameters);
+ const {
+ dict
+ } = parameters;
this.data.annotationType = _util.AnnotationType.POLYLINE;
this.data.vertices = [];
- const rawVertices = parameters.dict.getArray("Vertices");
+
+ if (!(this instanceof PolygonAnnotation)) {
+ this.setLineEndings(dict.getArray("LE"));
+ this.data.lineEndings = this.lineEndings;
+ }
+
+ const rawVertices = dict.getArray("Vertices");
if (!Array.isArray(rawVertices)) {
return;
}
@@ -8630,11 +8672,11 @@
});
}
if (!this.appearance) {
const strokeColor = this.color ? Array.from(this.color).map(c => c / 255) : [0, 0, 0];
- const strokeAlpha = parameters.dict.get("CA");
+ const strokeAlpha = dict.get("CA");
const borderWidth = this.borderStyle.width || 1,
borderAdjust = 2 * borderWidth;
const bbox = [Infinity, Infinity, -Infinity, -Infinity];
for (const vertex of this.data.vertices) {
@@ -10654,11 +10696,11 @@
let imgData, args;
if (imageMask) {
const interpolate = dict.get("I", "Interpolate");
const bitStrideLength = w + 7 >> 3;
- const imgArray = image.getBytes(bitStrideLength * h, true);
+ const imgArray = image.getBytes(bitStrideLength * h);
const decode = dict.getArray("D", "Decode");
if (this.parsingType3Font) {
imgData = _image.PDFImage.createRawMask({
imgArray,
@@ -17131,11 +17173,11 @@
}
return this.buffer[this.pos++];
}
- getBytes(length, forceClamped = false) {
+ getBytes(length) {
const pos = this.pos;
let end;
if (length) {
this.ensureBuffer(pos + length);
@@ -17157,12 +17199,11 @@
end = this.bufferLength;
}
this.pos = end;
- const subarray = this.buffer.subarray(pos, end);
- return forceClamped && !(subarray instanceof Uint8ClampedArray) ? new Uint8ClampedArray(subarray) : subarray;
+ return this.buffer.subarray(pos, end);
}
reset() {
this.pos = 0;
}
@@ -19926,13 +19967,11 @@
this.currentPageInfo = info;
const rowSize = info.width + 7 >> 3;
const buffer = new Uint8ClampedArray(rowSize * info.height);
if (info.defaultPixelValue) {
- for (let i = 0, ii = buffer.length; i < ii; i++) {
- buffer[i] = 0xff;
- }
+ buffer.fill(0xff);
}
this.buffer = buffer;
}
@@ -26448,16 +26487,17 @@
hasShortCmap: false
};
}
const format = file.getUint16();
- file.skip(2 + 2);
let hasShortCmap = false;
const mappings = [];
let j, glyphId;
if (format === 0) {
+ file.skip(2 + 2);
+
for (j = 0; j < 256; j++) {
const index = file.getByte();
if (!index) {
continue;
@@ -26469,10 +26509,11 @@
});
}
hasShortCmap = true;
} else if (format === 2) {
+ file.skip(2 + 2);
const subHeaderKeys = [];
let maxSubHeaderKey = 0;
for (let i = 0; i < 256; i++) {
const subHeaderKey = file.getUint16() >> 3;
@@ -26517,10 +26558,11 @@
});
}
}
}
} else if (format === 4) {
+ file.skip(2 + 2);
const segCount = file.getUint16() >> 1;
file.skip(6);
const segments = [];
let segIndex;
@@ -26582,10 +26624,11 @@
glyphId
});
}
}
} else if (format === 6) {
+ file.skip(2 + 2);
const firstCode = file.getUint16();
const entryCount = file.getUint16();
for (j = 0; j < entryCount; j++) {
glyphId = file.getUint16();
@@ -26593,10 +26636,26 @@
mappings.push({
charCode,
glyphId
});
}
+ } else if (format === 12) {
+ file.skip(2 + 4 + 4);
+ const nGroups = file.getInt32() >>> 0;
+
+ for (j = 0; j < nGroups; j++) {
+ const startCharCode = file.getInt32() >>> 0;
+ const endCharCode = file.getInt32() >>> 0;
+ let glyphCode = file.getInt32() >>> 0;
+
+ for (let charCode = startCharCode; charCode <= endCharCode; charCode++) {
+ mappings.push({
+ charCode,
+ glyphId: glyphCode++
+ });
+ }
+ }
} else {
(0, _util.warn)("cmap table has unsupported format: " + format);
return {
platformId: -1,
encodingId: -1,
@@ -40366,11 +40425,11 @@
maxLineHeight = Math.max(maxLineHeight, img.height);
}
const imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
const imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
- const imgData = new Uint8ClampedArray(imgWidth * imgHeight * 4);
+ const imgData = new Uint8Array(imgWidth * imgHeight * 4);
const imgRowSize = imgWidth << 2;
for (let q = 0; q < count; q++) {
const data = argsArray[iFirstPIIXO + (q << 2)][0].data;
const rowSize = map[q].w << 2;
@@ -40883,11 +40942,10 @@
switch (fnArray[i]) {
case _util.OPS.paintInlineImageXObject:
case _util.OPS.paintInlineImageXObjectGroup:
case _util.OPS.paintImageMaskXObject:
const arg = argsArray[i][0];
- ;
if (!arg.cached && arg.data && arg.data.buffer instanceof ArrayBuffer) {
transfers.push(arg.data.buffer);
}
@@ -41206,19 +41264,15 @@
let data, i;
if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
data = imgArray;
} else if (!inverseDecode) {
- data = new Uint8ClampedArray(actualLength);
- data.set(imgArray);
- } else {
- data = new Uint8ClampedArray(computedLength);
+ data = new Uint8Array(imgArray);
+ } else {
+ data = new Uint8Array(computedLength);
data.set(imgArray);
-
- for (i = actualLength; i < computedLength; i++) {
- data[i] = 0xff;
- }
+ data.fill(0xff, actualLength);
}
if (inverseDecode) {
for (i = 0; i < actualLength; i++) {
data[i] ^= 0xff;
@@ -41514,11 +41568,10 @@
const numComps = this.numComps;
const originalWidth = this.width;
const originalHeight = this.height;
const bpc = this.bpc;
const rowBytes = originalWidth * numComps * bpc + 7 >> 3;
- let imgArray;
if (!forceRGBA) {
let kind;
if (this.colorSpace.name === "DeviceGray" && bpc === 1) {
@@ -41527,19 +41580,11 @@
kind = _util.ImageKind.RGB_24BPP;
}
if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
imgData.kind = kind;
- imgArray = this.getImageBytes(originalHeight * rowBytes);
-
- if (this.image instanceof _decode_stream.DecodeStream) {
- imgData.data = imgArray;
- } else {
- const newArray = new Uint8ClampedArray(imgArray.length);
- newArray.set(imgArray);
- imgData.data = newArray;
- }
+ imgData.data = this.getImageBytes(originalHeight * rowBytes, {});
if (this.needsDecode) {
(0, _util.assert)(kind === _util.ImageKind.GRAYSCALE_1BPP, "PDFImage.createImageData: The image must be grayscale.");
const buffer = imgData.data;
@@ -41559,17 +41604,23 @@
imageLength *= 3;
case "DeviceRGB":
case "DeviceCMYK":
imgData.kind = _util.ImageKind.RGB_24BPP;
- imgData.data = this.getImageBytes(imageLength, drawWidth, drawHeight, true);
+ imgData.data = this.getImageBytes(imageLength, {
+ drawWidth,
+ drawHeight,
+ forceRGB: true
+ });
return imgData;
}
}
}
- imgArray = this.getImageBytes(originalHeight * rowBytes);
+ const imgArray = this.getImageBytes(originalHeight * rowBytes, {
+ internal: true
+ });
const actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
const comps = this.getComponents(imgArray);
let alpha01, maybeUndoPreblend;
if (!forceRGBA && !this.smask && !this.mask) {
@@ -41607,11 +41658,13 @@
const width = this.width;
const height = this.height;
const bpc = this.bpc;
const rowBytes = width * numComps * bpc + 7 >> 3;
- const imgArray = this.getImageBytes(height * rowBytes);
+ const imgArray = this.getImageBytes(height * rowBytes, {
+ internal: true
+ });
const comps = this.getComponents(imgArray);
let i, length;
if (bpc === 1) {
length = width * height;
@@ -41639,16 +41692,28 @@
for (i = 0; i < length; ++i) {
buffer[i] = scale * comps[i];
}
}
- getImageBytes(length, drawWidth, drawHeight, forceRGB = false) {
+ getImageBytes(length, {
+ drawWidth,
+ drawHeight,
+ forceRGB = false,
+ internal = false
+ }) {
this.image.reset();
this.image.drawWidth = drawWidth || this.width;
this.image.drawHeight = drawHeight || this.height;
this.image.forceRGB = !!forceRGB;
- return this.image.getBytes(length, true);
+ const imageBytes = this.image.getBytes(length);
+
+ if (internal || this.image instanceof _decode_stream.DecodeStream) {
+ return imageBytes;
+ }
+
+ (0, _util.assert)(imageBytes instanceof Uint8Array, 'PDFImage.getImageBytes: Unsupported "imageBytes" type.');
+ return new Uint8Array(imageBytes);
}
}
exports.PDFImage = PDFImage;
@@ -42293,11 +42358,11 @@
if (obj instanceof _name_number_tree.NameTree) {
for (const [key, value] of obj.getAll()) {
const dest = fetchDestination(value);
if (dest) {
- dests[key] = dest;
+ dests[(0, _util.stringToPDFString)(key)] = dest;
}
}
} else if (obj instanceof _primitives.Dict) {
obj.forEach(function (key, value) {
const dest = fetchDestination(value);
@@ -42720,11 +42785,11 @@
for (const [key, value] of nameTree.getAll()) {
if (!xfaImages) {
xfaImages = new _primitives.Dict(this.xref);
}
- xfaImages.set(key, value);
+ xfaImages.set((0, _util.stringToPDFString)(key), value);
}
}
return (0, _util.shadow)(this, "xfaImages", xfaImages);
}
@@ -42760,11 +42825,11 @@
if (obj instanceof _primitives.Dict && obj.has("JavaScript")) {
const nameTree = new _name_number_tree.NameTree(obj.getRaw("JavaScript"), this.xref);
for (const [key, value] of nameTree.getAll()) {
- appendIfJavaScriptDict(key, value);
+ appendIfJavaScriptDict((0, _util.stringToPDFString)(key), value);
}
}
const openAction = this._catDict.get("OpenAction");
@@ -43353,11 +43418,13 @@
if (dest) {
if (dest instanceof _primitives.Name) {
dest = dest.name;
}
- if (typeof dest === "string" || Array.isArray(dest)) {
+ if (typeof dest === "string") {
+ resultObj.dest = (0, _util.stringToPDFString)(dest);
+ } else if (Array.isArray(dest)) {
resultObj.dest = dest;
}
}
}
@@ -43411,13 +43478,15 @@
}
if (obj.has("Kids")) {
const kids = obj.get("Kids");
- for (let i = 0, ii = kids.length; i < ii; i++) {
- const kid = kids[i];
-
+ if (!Array.isArray(kids)) {
+ continue;
+ }
+
+ for (const kid of kids) {
if (processed.has(kid)) {
throw new _util.FormatError(`Duplicate entry in "${this._type}" tree.`);
}
queue.push(kid);
@@ -43474,11 +43543,11 @@
if (key < xref.fetchIfRef(limits[0])) {
r = m - 1;
} else if (key > xref.fetchIfRef(limits[1])) {
l = m + 1;
} else {
- kidsOrEntries = xref.fetchIfRef(kids[m]);
+ kidsOrEntries = kid;
break;
}
}
if (l > r) {
@@ -62405,13 +62474,13 @@
}
}));
var _worker = __w_pdfjs_require__(1);
-const pdfjsVersion = '2.14.224';
-const pdfjsBuild = '2be19e828';
+const pdfjsVersion = '2.14.300';
+const pdfjsBuild = '96b125fb7';
})();
/******/ return __webpack_exports__;
/******/ })()
;
});
\ No newline at end of file
diff --git a/toolkit/components/pdfjs/content/web/images/toolbarButton-openFile.svg b/toolkit/components/pdfjs/content/web/images/toolbarButton-openFile.svg
deleted file mode 100644
--- a/toolkit/components/pdfjs/content/web/images/toolbarButton-openFile.svg
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
\ No newline at end of file
diff --git a/toolkit/components/pdfjs/content/web/viewer.html b/toolkit/components/pdfjs/content/web/viewer.html
--- a/toolkit/components/pdfjs/content/web/viewer.html
+++ b/toolkit/components/pdfjs/content/web/viewer.html
@@ -28,15 +28,12 @@