add stub implemntation for event handling in elements

This commit is contained in:
Vincent Sanders 2012-12-03 17:34:03 +00:00
parent 3052864773
commit 70ece8a428
3 changed files with 34 additions and 5 deletions

View File

@ -51,10 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv);
/* execute some javascript in a context */ /* execute some javascript in a context */
bool js_exec(jscontext *ctx, const char *txt, size_t txtlen); bool js_exec(jscontext *ctx, const char *txt, size_t txtlen);
typedef struct dom_document dom_document; struct dom_document;
typedef struct dom_node dom_node; struct dom_node;
/* fire an event at a dom node */ /* fire an event at a dom node */
bool js_fire_event(jscontext *ctx, const char *type, dom_document *doc, dom_node *target); bool js_fire_event(jscontext *ctx, const char *type, struct dom_document *doc, struct dom_node *target);
#endif /* _NETSURF_JAVASCRIPT_JS_H_ */ #endif /* _NETSURF_JAVASCRIPT_JS_H_ */

View File

@ -36,6 +36,8 @@ binding htmlelement {
private "dom_element *" node; private "dom_element *" node;
private "struct html_content *" htmlc; private "struct html_content *" htmlc;
property unshared type EventHandler;
} }
api finalise %{ api finalise %{
@ -214,3 +216,26 @@ getter childElementCount %{
} }
} }
%} %}
getter EventHandler %{
JSLOG("propname[%d]=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
%}
setter EventHandler %{
JSLOG("propname[%d]=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
/*
1. Create a dom_event_listener From a handle_event function pointer
and a private word In a document context
2. Register for your events on a target (dom nodes are targets)
dom_event_target_add_event_listener(node, evt_name, listener,
capture_or_not)
*/
%}

View File

@ -258,12 +258,16 @@ getter EventHandler %{
/* this implementation is unique to the window object as it is /* this implementation is unique to the window object as it is
* not a dom node. * not a dom node.
*/ */
JSLOG("propname[%d] %s %s", tinyid , jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval))); JSLOG("propname[%d]=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
%} %}
setter EventHandler %{ setter EventHandler %{
/* this implementation is unique to the window object as it is /* this implementation is unique to the window object as it is
* not a dom node. * not a dom node.
*/ */
JSLOG("propname[%d] %s %s", tinyid, jsclass_properties[tinyid].name, JS_GetTypeName(cx, JS_TypeOfValue(cx, tinyid_jsval))); JSLOG("propname[%d]=\"%s\"",
tinyid,
jsclass_properties[tinyid].name);
%} %}