mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #19508 from calixteman/issue19505
[JS] Skip throwing actions
This commit is contained in:
commit
203452c170
6 changed files with 49 additions and 23 deletions
|
@ -175,9 +175,16 @@ class Doc extends PDFObject {
|
|||
|
||||
_runActions(name) {
|
||||
const actions = this._actions.get(name);
|
||||
if (actions) {
|
||||
for (const action of actions) {
|
||||
if (!actions) {
|
||||
return;
|
||||
}
|
||||
for (const action of actions) {
|
||||
try {
|
||||
this._globalEval(action);
|
||||
} catch (error) {
|
||||
const serializedError = serializeError(error);
|
||||
serializedError.value = `Error when executing "${name}" for document\n${serializedError.value}`;
|
||||
this._send(serializedError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
serializeError,
|
||||
USERACTIVATION_CALLBACKID,
|
||||
USERACTIVATION_MAXTIME_VALIDITY,
|
||||
} from "./app_utils.js";
|
||||
|
@ -311,12 +310,7 @@ class EventDispatcher {
|
|||
const source = this._objects[first];
|
||||
globalThis.event = new Event({});
|
||||
|
||||
try {
|
||||
this.runCalculate(source, globalThis.event);
|
||||
} catch (error) {
|
||||
this._isCalculating = false;
|
||||
throw error;
|
||||
}
|
||||
this.runCalculate(source, globalThis.event);
|
||||
|
||||
this._isCalculating = false;
|
||||
}
|
||||
|
@ -345,15 +339,8 @@ class EventDispatcher {
|
|||
event.value = null;
|
||||
const target = this._objects[targetId];
|
||||
let savedValue = target.obj._getValue();
|
||||
try {
|
||||
this.runActions(source, target, event, "Calculate");
|
||||
} catch (error) {
|
||||
const fieldId = target.obj._id;
|
||||
const serializedError = serializeError(error);
|
||||
serializedError.value = `Error when calculating value for field "${fieldId}"\n${serializedError.value}`;
|
||||
this._externalCall("send", [serializedError]);
|
||||
continue;
|
||||
}
|
||||
this.runActions(source, target, event, "Calculate");
|
||||
|
||||
if (!event.rc) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
import { createActionsMap, FieldType, getFieldType } from "./common.js";
|
||||
import { Color } from "./color.js";
|
||||
import { PDFObject } from "./pdf_object.js";
|
||||
import { serializeError } from "./app_utils.js";
|
||||
|
||||
class Field extends PDFObject {
|
||||
constructor(data) {
|
||||
|
@ -552,14 +553,15 @@ class Field extends PDFObject {
|
|||
}
|
||||
|
||||
const actions = this._actions.get(eventName);
|
||||
try {
|
||||
for (const action of actions) {
|
||||
for (const action of actions) {
|
||||
try {
|
||||
// Action evaluation must happen in the global scope
|
||||
this._globalEval(action);
|
||||
} catch (error) {
|
||||
const serializedError = serializeError(error);
|
||||
serializedError.value = `Error when executing "${eventName}" for field "${this._id}"\n${serializedError.value}`;
|
||||
this._send(serializedError);
|
||||
}
|
||||
} catch (error) {
|
||||
event.rc = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue