mirror of
https://github.com/rkd77/elinks.git
synced 2024-08-20 20:54:47 -04:00
DOM, ecmascript: Table with functions to make and done html objects.
This commit is contained in:
parent
446eec0bd3
commit
7b26b1dffd
@ -1,7 +1,7 @@
|
||||
top_builddir=../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
|
||||
OBJS = html.o renderer.o
|
||||
OBJS = renderer.o
|
||||
SUBDIRS-$(CONFIG_ECMASCRIPT) += ecmascript
|
||||
|
||||
include $(top_srcdir)/Makefile.lib
|
||||
|
@ -112,6 +112,15 @@ const JSClass HTMLElement_class = {
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Node_finalize
|
||||
};
|
||||
|
||||
void
|
||||
make_HTMLElement(JSContext *ctx, struct dom_node *node)
|
||||
{
|
||||
node->data.element.html_data = mem_calloc(1, sizeof(struct HTMLElement_struct));
|
||||
if (node->data.element.html_data) {
|
||||
node->ecmascript_obj = JS_NewObject(ctx, (JSClass *)&HTMLElement_class, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
done_HTMLElement(void *data)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define EL__DOCUMENT_DOM_ECMASCRIPT_SPIDERMONKEY_HTML_HTMLELEMENT_H
|
||||
|
||||
#include "ecmascript/spidermonkey/util.h"
|
||||
struct dom_node;
|
||||
|
||||
extern const JSClass HTMLElement_class;
|
||||
extern const JSFunctionSpec HTMLElement_funcs[];
|
||||
@ -22,5 +23,87 @@ struct html_objects { /* FIXME: Better name for this type. */
|
||||
JSObject *HTMLElement_object;
|
||||
};
|
||||
|
||||
void make_HTMLElement(JSContext *ctx, struct dom_node *node);
|
||||
void done_HTMLElement(void *data);
|
||||
|
||||
#define make_ABBR_object make_HTMLElement
|
||||
#define make_ACRONYM_object make_HTMLElement
|
||||
#define make_ADDRESS_object make_HTMLElement
|
||||
#define make_B_object make_HTMLElement
|
||||
#define make_BDO_object make_HTMLElement
|
||||
#define make_BIG_object make_HTMLElement
|
||||
#define make_BLOCKQUOTE_object make_HTMLElement
|
||||
#define make_CENTER_object make_HTMLElement
|
||||
#define make_CITE_object make_HTMLElement
|
||||
#define make_CODE_object make_HTMLElement
|
||||
#define make_COLGROUP_object make_HTMLElement
|
||||
#define make_DD_object make_HTMLElement
|
||||
#define make_DEL_object make_HTMLElement
|
||||
#define make_DFN_object make_HTMLElement
|
||||
#define make_DT_object make_HTMLElement
|
||||
#define make_EM_object make_HTMLElement
|
||||
#define make_FIELDSET_object make_HTMLElement
|
||||
#define make_I_object make_HTMLElement
|
||||
#define make_INS_object make_HTMLElement
|
||||
#define make_KBD_object make_HTMLElement
|
||||
#define make_NOFRAMES_object make_HTMLElement
|
||||
#define make_NOSCRIPT_object make_HTMLElement
|
||||
#define make_Q_object make_HTMLElement
|
||||
#define make_S_object make_HTMLElement
|
||||
#define make_SAMP_object make_HTMLElement
|
||||
#define make_SMALL_object make_HTMLElement
|
||||
#define make_SPAN_object make_HTMLElement
|
||||
#define make_STRIKE_object make_HTMLElement
|
||||
#define make_STRONG_object make_HTMLElement
|
||||
#define make_SUB_object make_HTMLElement
|
||||
#define make_SUP_object make_HTMLElement
|
||||
#define make_TBODY_object make_HTMLElement
|
||||
#define make_TFOOT_object make_HTMLElement
|
||||
#define make_TH_object make_HTMLElement
|
||||
#define make_THEAD_object make_HTMLElement
|
||||
#define make_TT_object make_HTMLElement
|
||||
#define make_U_object make_HTMLElement
|
||||
#define make_VAR_object make_HTMLElement
|
||||
#define make_XMP_object make_HTMLElement
|
||||
|
||||
#define done_ABBR_object NULL
|
||||
#define done_ACRONYM_object NULL
|
||||
#define done_ADDRESS_object NULL
|
||||
#define done_B_object NULL
|
||||
#define done_BDO_object NULL
|
||||
#define done_BIG_object NULL
|
||||
#define done_BLOCKQUOTE_object NULL
|
||||
#define done_CENTER_object NULL
|
||||
#define done_CITE_object NULL
|
||||
#define done_CODE_object NULL
|
||||
#define done_COLGROUP_object NULL
|
||||
#define done_DD_object NULL
|
||||
#define done_DEL_object NULL
|
||||
#define done_DFN_object NULL
|
||||
#define done_DT_object NULL
|
||||
#define done_EM_object NULL
|
||||
#define done_FIELDSET_object NULL
|
||||
#define done_I_object NULL
|
||||
#define done_INS_object NULL
|
||||
#define done_KBD_object NULL
|
||||
#define done_NOFRAMES_object NULL
|
||||
#define done_NOSCRIPT_object NULL
|
||||
#define done_Q_object NULL
|
||||
#define done_S_object NULL
|
||||
#define done_SAMP_object NULL
|
||||
#define done_SMALL_object NULL
|
||||
#define done_SPAN_object NULL
|
||||
#define done_STRIKE_object NULL
|
||||
#define done_STRONG_object NULL
|
||||
#define done_SUB_object NULL
|
||||
#define done_SUP_object NULL
|
||||
#define done_TBODY_object NULL
|
||||
#define done_TFOOT_object NULL
|
||||
#define done_TH_object NULL
|
||||
#define done_THEAD_object NULL
|
||||
#define done_TT_object NULL
|
||||
#define done_U_object NULL
|
||||
#define done_VAR_object NULL
|
||||
#define done_XMP_object NULL
|
||||
|
||||
#endif
|
||||
|
@ -15,4 +15,17 @@ struct H1_struct {
|
||||
|
||||
void make_H1_object(JSContext *ctx, struct dom_node *node);
|
||||
void done_H1_object(void *data);
|
||||
|
||||
#define make_H2_object make_H1_object
|
||||
#define make_H3_object make_H1_object
|
||||
#define make_H4_object make_H1_object
|
||||
#define make_H5_object make_H1_object
|
||||
#define make_H6_object make_H1_object
|
||||
|
||||
#define done_H2_object done_H1_object
|
||||
#define done_H3_object done_H1_object
|
||||
#define done_H4_object done_H1_object
|
||||
#define done_H5_object done_H1_object
|
||||
#define done_H6_object done_H1_object
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@ static JSBool
|
||||
HTMLImageElement_getProperty(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct dom_node *node;
|
||||
struct IMAGE_struct *html;
|
||||
struct IMG_struct *html;
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
return JS_TRUE;
|
||||
@ -75,7 +75,7 @@ static JSBool
|
||||
HTMLImageElement_setProperty(JSContext *ctx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
struct dom_node *node;
|
||||
struct IMAGE_struct *html;
|
||||
struct IMG_struct *html;
|
||||
|
||||
if (!JSVAL_IS_INT(id))
|
||||
return JS_TRUE;
|
||||
@ -158,20 +158,20 @@ const JSClass HTMLImageElement_class = {
|
||||
};
|
||||
|
||||
void
|
||||
make_IMAGE_object(JSContext *ctx, struct dom_node *node)
|
||||
make_IMG_object(JSContext *ctx, struct dom_node *node)
|
||||
{
|
||||
struct html_objects *o = JS_GetContextPrivate(ctx);
|
||||
|
||||
node->data.element.html_data = mem_calloc(1, sizeof(struct IMAGE_struct));
|
||||
node->data.element.html_data = mem_calloc(1, sizeof(struct IMG_struct));
|
||||
if (node->data.element.html_data) {
|
||||
node->ecmascript_obj = JS_NewObject(ctx, (JSClass *)&HTMLImageElement_class, o->HTMLElement_object, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
done_IMAGE_object(void *data)
|
||||
done_IMG_object(void *data)
|
||||
{
|
||||
struct IMAGE_struct *d = data;
|
||||
struct IMG_struct *d = data;
|
||||
|
||||
mem_free_if(d->name);
|
||||
mem_free_if(d->align);
|
||||
|
@ -8,7 +8,7 @@ extern const JSClass HTMLImageElement_class;
|
||||
extern const JSFunctionSpec HTMLImageElement_funcs[];
|
||||
extern const JSPropertySpec HTMLImageElement_props[];
|
||||
|
||||
struct IMAGE_struct {
|
||||
struct IMG_struct {
|
||||
struct HTMLElement_struct html;
|
||||
unsigned char *name;
|
||||
unsigned char *align;
|
||||
@ -24,6 +24,6 @@ struct IMAGE_struct {
|
||||
unsigned int is_map:1;
|
||||
};
|
||||
|
||||
void make_IMAGE_object(JSContext *ctx, struct dom_node *node);
|
||||
void done_IMAGE_object(void *data);
|
||||
void make_IMG_object(JSContext *ctx, struct dom_node *node);
|
||||
void done_IMG_object(void *data);
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@ top_builddir=../../../../../..
|
||||
include $(top_builddir)/Makefile.config
|
||||
|
||||
INCLUDES += $(SPIDERMONKEY_CFLAGS)
|
||||
OBJS = HTMLAnchorElement.o HTMLAppletElement.o HTMLAreaElement.o \
|
||||
OBJS = html.o HTMLAnchorElement.o HTMLAppletElement.o HTMLAreaElement.o \
|
||||
HTMLBaseElement.o HTMLBaseFontElement.o HTMLBodyElement.o \
|
||||
HTMLBRElement.o HTMLButtonElement.o HTMLCollection.o \
|
||||
HTMLDirectoryElement.o HTMLDivElement.o HTMLDListElement.o \
|
||||
|
104
src/document/dom/ecmascript/spidermonkey/html/html.c
Normal file
104
src/document/dom/ecmascript/spidermonkey/html/html.c
Normal file
@ -0,0 +1,104 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "dom/node.h"
|
||||
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLAnchorElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLAppletElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLAreaElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLBaseElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLBaseFontElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLBodyElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLBRElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLButtonElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLCollection.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLDirectoryElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLDivElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLDListElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLDocument.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLFieldSetElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLFontElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLFormElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLFrameElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLFrameSetElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLHeadElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLHeadingElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLHRElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLHtmlElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLIFrameElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLImageElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLInputElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLIsIndexElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLLabelElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLLegendElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLLIElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLLinkElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLMapElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLMenuElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLMetaElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLModElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLObjectElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLOListElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLOptGroupElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLOptionElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLOptionsCollection.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLParagraphElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLParamElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLPreElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLQuoteElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLScriptElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLSelectElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLStyleElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableCaptionElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableCellElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableColElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableRowElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTableSectionElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTextAreaElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLTitleElement.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/HTMLUListElement.h"
|
||||
#include "dom/sgml/html/html.h"
|
||||
#include "ecmascript/spidermonkey/util.h"
|
||||
|
||||
typedef void (make_function_T)(JSContext *ctx, struct dom_node *node);
|
||||
typedef void (done_function_T)(void *data);
|
||||
|
||||
struct HTML_functions {
|
||||
make_function_T *make;
|
||||
done_function_T *done;
|
||||
};
|
||||
|
||||
#define HTML_(node,name,id) { make##_##name##_object, done##_##name##_object }
|
||||
|
||||
struct HTML_functions func[HTML_ELEMENTS] = {
|
||||
{ NULL, NULL },
|
||||
#include "dom/sgml/html/element.inc"
|
||||
};
|
||||
|
||||
void
|
||||
done_dom_node_html_data(struct dom_node *node)
|
||||
{
|
||||
int type = node->data.element.type;
|
||||
void *data = node->data.element.html_data;
|
||||
|
||||
if (func[type].done)
|
||||
func[type].done(data);
|
||||
done_HTMLElement(data);
|
||||
mem_free(data);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
make_dom_node_html_data(, struct dom_node *node)
|
||||
{
|
||||
int type = node->data.element.type;
|
||||
|
||||
if (func[type].make)
|
||||
func[type].make(ctx, node);
|
||||
}
|
||||
#endif
|
12
src/document/dom/ecmascript/spidermonkey/html/html.h
Normal file
12
src/document/dom/ecmascript/spidermonkey/html/html.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef EL__DOCUMENT_DOM_ECMASCRIPT_SPIDERMONKEY_HTML_HTML_H
|
||||
#define EL__DOCUMENT_DOM_ECMASCRIPT_SPIDERMONKEY_HTML_HTML_H
|
||||
|
||||
struct dom_node;
|
||||
|
||||
void done_dom_node_html_data(struct dom_node *node);
|
||||
|
||||
#if 0
|
||||
void make_dom_node_html_data(JSContext *ctx, struct dom_node *node);
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,13 +0,0 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "elinks.h"
|
||||
|
||||
#include "dom/node.h"
|
||||
|
||||
void
|
||||
done_dom_node_html_data(struct dom_node *node)
|
||||
{
|
||||
}
|
||||
|
@ -1,10 +0,0 @@
|
||||
|
||||
#ifndef EL__DOCUMENT_DOM_HTML_H
|
||||
#define EL__DOCUMENT_DOM_HTML_H
|
||||
|
||||
struct dom_node;
|
||||
|
||||
void done_dom_node_html_data(struct dom_node *node);
|
||||
|
||||
#endif
|
||||
|
@ -12,9 +12,9 @@
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
/* FIXME: SEE ? */
|
||||
#include "document/dom/ecmascript/spidermonkey.h"
|
||||
#include "document/dom/ecmascript/spidermonkey/html/html.h"
|
||||
#endif
|
||||
|
||||
#include "document/dom/html.h"
|
||||
#include "dom/node.h"
|
||||
#include "dom/string.h"
|
||||
#include "util/hash.h"
|
||||
@ -465,11 +465,10 @@ done_dom_node(struct dom_node *node)
|
||||
}
|
||||
#ifdef CONFIG_ECMASCRIPT
|
||||
#ifdef CONFIG_SPIDERMONKEY
|
||||
if (node->ecmascript_obj) {
|
||||
done_dom_node_ecmascript_obj(node);
|
||||
}
|
||||
if (node->type == DOM_NODE_ELEMENT && node->data.element.html_data) {
|
||||
done_dom_node_html_data(node);
|
||||
if (node->ecmascript_obj)
|
||||
done_dom_node_ecmascript_obj(node);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user