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

[quickjs] libdom element.c

Many TODOs left.
This commit is contained in:
Witold Filipczyk 2023-04-02 20:41:28 +02:00
parent 934928d3b5
commit adff92389f
7 changed files with 2687 additions and 2 deletions

View File

@ -231,6 +231,7 @@ CORESTRING_DOM_STRING(DOMAttrModified);
CORESTRING_DOM_STRING(DOMNodeInserted); CORESTRING_DOM_STRING(DOMNodeInserted);
CORESTRING_DOM_STRING(DOMNodeInsertedIntoDocument); CORESTRING_DOM_STRING(DOMNodeInsertedIntoDocument);
CORESTRING_DOM_STRING(DOMSubtreeModified); CORESTRING_DOM_STRING(DOMSubtreeModified);
CORESTRING_DOM_STRING(dir);
CORESTRING_DOM_STRING(drag); CORESTRING_DOM_STRING(drag);
CORESTRING_DOM_STRING(dragend); CORESTRING_DOM_STRING(dragend);
CORESTRING_DOM_STRING(dragenter); CORESTRING_DOM_STRING(dragenter);
@ -259,6 +260,7 @@ CORESTRING_DOM_STRING(invalid);
CORESTRING_DOM_STRING(keydown); CORESTRING_DOM_STRING(keydown);
CORESTRING_DOM_STRING(keypress); CORESTRING_DOM_STRING(keypress);
CORESTRING_DOM_STRING(keyup); CORESTRING_DOM_STRING(keyup);
CORESTRING_DOM_STRING(lang);
CORESTRING_DOM_STRING(link); CORESTRING_DOM_STRING(link);
CORESTRING_DOM_STRING(languagechange); CORESTRING_DOM_STRING(languagechange);
CORESTRING_DOM_STRING(load); CORESTRING_DOM_STRING(load);

View File

@ -1,6 +1,6 @@
top_builddir=../../../.. top_builddir=../../../..
include $(top_builddir)/Makefile.config include $(top_builddir)/Makefile.config
OBJS = attr.o attributes.o collection.o console.o form.o forms.o heartbeat.o history.o input.o keyboard.o localstorage.o location.o mapa.obj message.o navigator.o nodelist.o screen.o unibar.o window.o xhr.o OBJS = attr.o attributes.o collection.o console.o element.o form.o forms.o heartbeat.o history.o input.o keyboard.o localstorage.o location.o mapa.obj message.o navigator.o nodelist.o screen.o unibar.o window.o xhr.o
include $(top_srcdir)/Makefile.lib include $(top_srcdir)/Makefile.lib

File diff suppressed because it is too large Load Diff

View File

@ -24,6 +24,12 @@ attr_save_in_map(void *m, void *node, JSValueConst value)
(*mapa)[node] = value; (*mapa)[node] = value;
} }
void attr_save_in_map_void(void *m, void *node, void *value)
{
std::map<void *, void *> *mapa = static_cast<std::map<void *, void *> *>(m);
(*mapa)[node] = value;
}
void * void *
attr_create_new_attrs_map(void) attr_create_new_attrs_map(void)
{ {
@ -56,6 +62,22 @@ attr_create_new_collections_map(void)
return (void *)mapa; return (void *)mapa;
} }
void *
attr_create_new_elements_map(void)
{
std::map<void *, JSValueConst> *mapa = new std::map<void *, JSValueConst>;
return (void *)mapa;
}
void *
attr_create_new_privates_map_void(void)
{
std::map<void *, void *> *mapa = new std::map<void *, void *>;
return (void *)mapa;
}
void * void *
attr_create_new_form_elements_map(void) attr_create_new_form_elements_map(void)
{ {
@ -199,6 +221,22 @@ attr_find_in_map(void *m, void *node)
return value->second; return value->second;
} }
void *
attr_find_in_map_void(void *m, void *node)
{
std::map<void *, void *> *mapa = static_cast<std::map<void *, void *> *>(m);
if (!mapa) {
return NULL;
}
auto value = (*mapa).find(node);
if (value == (*mapa).end()) {
return NULL;
}
return value->second;
}
void void
attr_erase_from_map(void *m, void *node) attr_erase_from_map(void *m, void *node)
{ {

View File

@ -10,11 +10,15 @@ extern "C" {
struct Xhr; struct Xhr;
void attr_save_in_map(void *m, void *node, JSValueConst value); void attr_save_in_map(void *m, void *node, JSValueConst value);
void attr_save_in_map_void(void *m, void *node, void *value);
void *attr_create_new_attrs_map(void); void *attr_create_new_attrs_map(void);
void *attr_create_new_attributes_map(void); void *attr_create_new_attributes_map(void);
void *attr_create_new_attributes_map_rev(void); void *attr_create_new_attributes_map_rev(void);
void *attr_create_new_collections_map(void); void *attr_create_new_collections_map(void);
void *attr_create_new_collections_map_rev(void); void *attr_create_new_collections_map_rev(void);
void *attr_create_new_elements_map(void);
void *attr_create_new_privates_map_void(void);
void *attr_create_new_form_elements_map(void); void *attr_create_new_form_elements_map(void);
void *attr_create_new_form_elements_map_rev(void); void *attr_create_new_form_elements_map_rev(void);
void *attr_create_new_form_map(void); void *attr_create_new_form_map(void);
@ -33,6 +37,8 @@ void attr_clear_map_str(void *m);
void delete_map_str(void *m); void delete_map_str(void *m);
JSValue attr_find_in_map(void *m, void *node); JSValue attr_find_in_map(void *m, void *node);
void *attr_find_in_map_void(void *m, void *node);
void attr_erase_from_map(void *m, void *node); void attr_erase_from_map(void *m, void *node);
void attr_save_in_map_rev(void *m, JSValueConst value, void *node); void attr_save_in_map_rev(void *m, JSValueConst value, void *node);

View File

@ -1,2 +1,2 @@
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'form.c', 'forms.c', 'heartbeat.c', 'history.c', 'input.c', 'keyboard.c', 'localstorage.c', 'location.c', srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'element.c', 'form.c', 'forms.c', 'heartbeat.c', 'history.c', 'input.c', 'keyboard.c', 'localstorage.c', 'location.c',
'mapa.cpp', 'message.c', 'navigator.c', 'nodelist.c', 'screen.c', 'unibar.c', 'window.c', 'xhr.c') 'mapa.cpp', 'message.c', 'navigator.c', 'nodelist.c', 'screen.c', 'unibar.c', 'window.c', 'xhr.c')

View File

@ -61,6 +61,8 @@
#include <map> #include <map>
#include <string> #include <string>
#ifndef CONFIG_LIBDOM
#define countof(x) (sizeof(x) / sizeof((x)[0])) #define countof(x) (sizeof(x) / sizeof((x)[0]))
static JSClassID js_element_class_id; static JSClassID js_element_class_id;
@ -2233,3 +2235,4 @@ check_element_event(void *elem, const char *event_name, struct term_event *ev)
done_heartbeat(interpreter->heartbeat); done_heartbeat(interpreter->heartbeat);
check_for_rerender(interpreter, event_name); check_for_rerender(interpreter, event_name);
} }
#endif