1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-03 08:07:17 -05:00

[ecmascript] Added element_offset parameter to eval

This commit is contained in:
Witold Filipczyk 2022-11-14 21:33:24 +01:00
parent 0ff62b5ee8
commit 7a9ba1184d
3 changed files with 7 additions and 5 deletions

View File

@ -143,7 +143,7 @@ process_snippets(struct ecmascript_interpreter *interpreter,
if (*string->source != '^') { if (*string->source != '^') {
/* Evaluate <script>code</script> snippet */ /* Evaluate <script>code</script> snippet */
ecmascript_eval(interpreter, string, NULL); ecmascript_eval(interpreter, string, NULL, (*current)->element_offset);
continue; continue;
} }
@ -208,7 +208,7 @@ process_snippets(struct ecmascript_interpreter *interpreter,
if (fragment) { if (fragment) {
struct string code = INIT_STRING(fragment->data, (int)fragment->length); struct string code = INIT_STRING(fragment->data, (int)fragment->length);
ecmascript_eval(interpreter, &code, NULL); ecmascript_eval(interpreter, &code, NULL, (*current)->element_offset);
} }
} }
check_for_rerender(interpreter, "eval"); check_for_rerender(interpreter, "eval");

View File

@ -389,12 +389,13 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
void void
ecmascript_eval(struct ecmascript_interpreter *interpreter, ecmascript_eval(struct ecmascript_interpreter *interpreter,
struct string *code, struct string *ret) struct string *code, struct string *ret, int element_offset)
{ {
if (!get_ecmascript_enable(interpreter)) if (!get_ecmascript_enable(interpreter))
return; return;
assert(interpreter); assert(interpreter);
interpreter->backend_nesting++; interpreter->backend_nesting++;
interpreter->element_offset = element_offset;
#ifdef CONFIG_MUJS #ifdef CONFIG_MUJS
mujs_eval(interpreter, code, ret); mujs_eval(interpreter, code, ret);
#elif defined(CONFIG_QUICKJS) #elif defined(CONFIG_QUICKJS)
@ -637,7 +638,7 @@ ecmascript_timeout_handler(void *val)
interpreter->vs->ecmascript_fragile); interpreter->vs->ecmascript_fragile);
t->tid = TIMER_ID_UNDEF; t->tid = TIMER_ID_UNDEF;
/* The expired timer ID has now been erased. */ /* The expired timer ID has now been erased. */
ecmascript_eval(interpreter, &t->code, NULL); ecmascript_eval(interpreter, &t->code, NULL, 0);
del_from_list(t); del_from_list(t);
done_string(&t->code); done_string(&t->code);

View File

@ -106,6 +106,7 @@ struct ecmascript_interpreter {
const char *fun; const char *fun;
#endif #endif
bool changed; bool changed;
int element_offset;
}; };
struct ecmascript_timeout { struct ecmascript_timeout {
@ -157,7 +158,7 @@ void ecmascript_moved_form_state(struct form_state *fs);
void ecmascript_reset_state(struct view_state *vs); void ecmascript_reset_state(struct view_state *vs);
void ecmascript_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret); void ecmascript_eval(struct ecmascript_interpreter *interpreter, struct string *code, struct string *ret, int element_offset);
char *ecmascript_eval_stringback(struct ecmascript_interpreter *interpreter, struct string *code); char *ecmascript_eval_stringback(struct ecmascript_interpreter *interpreter, struct string *code);
/* Returns -1 if undefined. */ /* Returns -1 if undefined. */
int ecmascript_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code); int ecmascript_eval_boolback(struct ecmascript_interpreter *interpreter, struct string *code);