1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-26 01:15:37 +00:00

[quickjs] form.c

This commit is contained in:
Witold Filipczyk 2021-11-02 20:49:03 +01:00
parent a66a4bf995
commit 26a319e581
7 changed files with 1127 additions and 11 deletions

View File

@ -1,6 +1,10 @@
#ifndef EL__DOCUMENT_FORMS_H
#define EL__DOCUMENT_FORMS_H
#ifdef CONFIG_QUICKJS
#include <quickjs/quickjs.h>
#endif
#include "util/lists.h"
#ifdef __cplusplus
@ -42,7 +46,11 @@ struct form {
enum form_method method;
#ifdef CONFIG_ECMASCRIPT
#ifdef CONFIG_QUICKJS
JSValue ecmascript_obj;
#else
void *ecmascript_obj;
#endif
#endif
LIST_OF(struct el_form_control) items;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
#ifndef EL__ECMASCRIPT_QUICKJS_FORM_H
#define EL__ECMASCRIPT_QUICKJS_FORM_H
#include <quickjs/quickjs.h>
struct form;
JSValue js_get_form_object(JSContext *ctx, JSValueConst jsdoc, struct form *form);
#endif

View File

@ -22,7 +22,7 @@
#include "ecmascript/ecmascript.h"
#include "ecmascript/quickjs.h"
#include "ecmascript/quickjs/document.h"
//#include "ecmascript/quickjs/form.h"
#include "ecmascript/quickjs/form.h"
#include "ecmascript/quickjs/forms.h"
//#include "ecmascript/quickjs/input.h"
#include "ecmascript/quickjs/window.h"
@ -52,13 +52,6 @@
static JSClassID js_forms_class_id;
JSValue
js_get_form_object(JSContext *ctx, JSValue jsdoc, struct form *form)
{
// TODO
return JS_NULL;
}
/* Find the form whose name is @name, which should normally be a
* string (but might not be). */
static JSValue

View File

@ -1 +1 @@
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'element.c', 'forms.c', 'history.c', 'implementation.c', 'localstorage.c', 'location.c', 'navigator.c', 'nodelist.c', 'screen.c', 'unibar.c', 'window.c')
srcs += files('attr.c', 'attributes.c', 'collection.c', 'console.c', 'element.c', 'form.c', 'forms.c', 'history.c', 'implementation.c', 'localstorage.c', 'location.c', 'navigator.c', 'nodelist.c', 'screen.c', 'unibar.c', 'window.c')

View File

@ -2,6 +2,10 @@
#ifndef EL__VIEWER_TEXT_FORM_H
#define EL__VIEWER_TEXT_FORM_H
#ifdef CONFIG_QUICKJS
#include <quickjs/quickjs.h>
#endif
#include "document/forms.h"
#include "util/lists.h" /* LIST_HEAD */
#include "viewer/action.h"
@ -33,8 +37,12 @@ struct form_view {
* ECMAScript code accesses it. It is freed automatically by the
* garbage-collecting code when the ECMAScript context is over (usually
* when the document is destroyed). */
#ifdef CONFIG_QUICKJS
JSValue ecmascript_obj;
#else
void *ecmascript_obj;
#endif
#endif
};
struct form_state {
@ -84,8 +92,12 @@ struct form_state {
* ECMAScript code accesses it. It is freed automatically by the
* garbage-collecting code when the ECMAScript context is over (usually
* when the document is destroyed). */
#ifdef CONFIG_QUICKJS
JSValue ecmascript_obj;
#else
void *ecmascript_obj;
#endif
#endif
};
struct submitted_value {

View File

@ -131,8 +131,11 @@ copy_vs(struct view_state *dst, struct view_state *src)
struct form_state *srcfs = &src->form_info[i];
struct form_state *dstfs = &dst->form_info[i];
#if defined(CONFIG_ECMASCRIPT_SMJS) || defined(CONFIG_QUICKJS)
dstfs->ecmascript_obj = NULL;
#ifdef CONFIG_ECMASCRIPT_SMJS
dstfs->ecmascript_obj = nullptr;
#endif
#ifdef CONFIG_QUICKJS
dstfs->ecmascript_obj = JS_NULL;
#endif
if (srcfs->value)
dstfs->value = stracpy(srcfs->value);