1
0
Fork 0

[viewer] view.cpp -> view.c

This commit is contained in:
Witold Filipczyk 2023-11-27 19:14:39 +01:00
parent bbf902f426
commit 7e48d22f51
5 changed files with 25 additions and 19 deletions

View File

@ -13,17 +13,21 @@
#include "ecmascript/ecmascript-c.h"
#ifdef CONFIG_MUJS
#include "ecmascript/mujs.h"
#include "ecmascript/mujs/element.h"
#endif
#ifdef CONFIG_QUICKJS
#include "ecmascript/quickjs.h"
#include "ecmascript/quickjs/element.h"
#endif
#ifdef CONFIG_ECMASCRIPT_SMJS
#include "ecmascript/spidermonkey.h"
#include "ecmascript/spidermonkey/element.h"
#endif
#include "intl/libintl.h"
#include "protocol/uri.h"
#include "session/session.h"
#include "session/task.h"
#include "terminal/event.h"
#include "util/conv.h"
#include "util/memory.h"
#include "util/string.h"
@ -332,3 +336,15 @@ ecmascript_put_interpreter(struct ecmascript_interpreter *interpreter)
mem_free(interpreter);
--interpreter_count;
}
void
check_events_for_element(struct ecmascript_interpreter *ecmascript, dom_node *element, struct term_event *ev)
{
const char *event_name = script_event_hook_name[SEVHOOK_ONKEYDOWN];
check_element_event(ecmascript, element, event_name, ev);
event_name = script_event_hook_name[SEVHOOK_ONKEYUP];
check_element_event(ecmascript, element, event_name, ev);
event_name = script_event_hook_name[SEVHOOK_ONKEYPRESS];
check_element_event(ecmascript, element, event_name, ev);
}

View File

@ -1,6 +1,7 @@
#ifndef EL__ECMASCRIPT_ECMASCRIPT_C_H
#define EL__ECMASCRIPT_ECMASCRIPT_C_H
#include "ecmascript/libdom/dom.h"
#include "main/module.h"
#ifdef __cplusplus
@ -11,6 +12,7 @@ struct document_options;
struct document;
struct ecmascript_interpreter;
struct session;
struct term_event;
struct uri;
struct view_state;
@ -24,6 +26,8 @@ void ecmascript_protocol_handler(struct session *ses, struct uri *uri);
void check_for_snippets(struct view_state *vs, struct document_options *options, struct document *document);
void kill_ecmascript_timeouts(struct document *document);
void check_events_for_element(struct ecmascript_interpreter *interpreter, dom_node *element, struct term_event *ev);
extern struct module ecmascript_module;
#ifdef __cplusplus

View File

@ -5,6 +5,6 @@ INCLUDES += $(TRE_CFLAGS)
OBJS-$(CONFIG_MARKS) += marks.o
OBJS = draw.o form.obj link.obj search.o textarea.o view.obj vs.o
OBJS = draw.o form.obj link.obj search.o textarea.o view.o vs.o
include $(top_srcdir)/Makefile.lib

View File

@ -4,4 +4,4 @@ if conf_data.get('CONFIG_MARKS')
srcs += files('marks.c')
endif
srcs += files('draw.c', 'form.cpp', 'link.cpp', 'search.c', 'textarea.c', 'view.cpp', 'vs.c')
srcs += files('draw.c', 'form.cpp', 'link.cpp', 'search.c', 'textarea.c', 'view.c', 'vs.c')

View File

@ -35,16 +35,8 @@
#include "document/renderer.h"
#include "document/view.h"
#ifdef CONFIG_ECMASCRIPT_SMJS
#include "ecmascript/spidermonkey/element.h"
#endif
#ifdef CONFIG_QUICKJS
#include "ecmascript/quickjs/element.h"
#endif
#ifdef CONFIG_MUJS
#include "ecmascript/mujs/element.h"
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS) || defined(CONFIG_MUJS)
#include "ecmascript/ecmascript-c.h"
#endif
#include "intl/charsets.h"
@ -1329,13 +1321,7 @@ try_form_action(struct session *ses, struct document_view *doc_view,
dom_node *element = (dom_node *)find_in_map(mapa, link->element_offset);
if (element) {
const char *event_name = script_event_hook_name[SEVHOOK_ONKEYDOWN];
check_element_event(doc_view->vs->ecmascript, element, event_name, ev);
event_name = script_event_hook_name[SEVHOOK_ONKEYUP];
check_element_event(doc_view->vs->ecmascript, element, event_name, ev);
event_name = script_event_hook_name[SEVHOOK_ONKEYPRESS];
check_element_event(doc_view->vs->ecmascript, element, event_name, ev);
check_events_for_element(doc_view->vs->ecmascript, element, ev);
}
}