1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

[document] Added body_onkeypress

It is silly, but I want some scripts to work.
This commit is contained in:
Witold Filipczyk 2023-09-22 16:37:53 +02:00
parent 9ca95e1ffe
commit f461c86ce6
5 changed files with 13 additions and 1 deletions

View File

@ -102,6 +102,7 @@ const char *script_event_hook_name[] = {
"keydown",
"keyup",
"keypress",
"keypress",
NULL
};
@ -310,6 +311,7 @@ reset_document(struct document *document)
free_ecmascript_string_list(&document->onload_snippets);
free_uri_list(&document->ecmascript_imports);
mem_free_set(&document->text, NULL);
mem_free_set(&document->body_onkeypress, NULL);
/// kill_timer(&document->timeout);
/// free_document(document->dom);
#endif
@ -395,6 +397,7 @@ done_document(struct document *document)
}
}
free_list(document->timeouts);
mem_free_if(document->body_onkeypress);
#endif
#ifdef CONFIG_LIBDOM

View File

@ -100,6 +100,7 @@ enum script_event_hook_type {
SEVHOOK_ONKEYDOWN,
SEVHOOK_ONKEYUP,
SEVHOOK_ONKEYPRESS,
SEVHOOK_ONKEYPRESS_BODY,
};
/* keep in sync with above */
@ -231,6 +232,7 @@ struct document {
/** used by setTimeout */
LIST_OF(struct ecmascript_timeout) timeouts;
int ecmascript_counter;
char *body_onkeypress;
#endif
#ifdef CONFIG_LIBDOM
void *dom;

View File

@ -182,7 +182,9 @@ html_body(struct html_context *html_context, char *a,
get_color(html_context, a, "text", &elformat.style.color.foreground);
get_color(html_context, a, "link", &elformat.color.clink);
get_color(html_context, a, "vlink", &elformat.color.vlink);
#ifdef CONFIG_ECMASCRIPT
mem_free_set(&html_context->document->body_onkeypress, get_attr_val(a, "onkeypress", html_context->doc_cp));
#endif
if (get_bgcolor(html_context, a, &elformat.style.color.background) != -1)
html_context->was_body_background = 1;

View File

@ -1455,6 +1455,8 @@ init_link_event_hooks(struct html_context *html_context, struct link *link)
add_evhook(link->event_hooks, SEVHOOK_ONKEYUP, elformat.onkeyup);
add_evhook(link->event_hooks, SEVHOOK_ONKEYPRESS, elformat.onkeypress);
add_evhook(link->event_hooks, SEVHOOK_ONKEYPRESS_BODY, html_context->document->body_onkeypress);
#undef add_evhook
}

View File

@ -1352,6 +1352,9 @@ try_form_action(struct session *ses, struct document_view *doc_view,
if (status != FRAME_EVENT_IGNORED && !current_link_evhook(doc_view, SEVHOOK_ONKEYPRESS)) {
status = FRAME_EVENT_IGNORED;
}
if (status != FRAME_EVENT_IGNORED && !current_link_evhook(doc_view, SEVHOOK_ONKEYPRESS_BODY)) {
status = FRAME_EVENT_IGNORED;
}
}
#endif
if (status != FRAME_EVENT_IGNORED) {