From 70ece8a428de80d2efacef58d4a2ec259def54b8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 3 Dec 2012 17:34:03 +0000 Subject: [PATCH] add stub implemntation for event handling in elements --- javascript/js.h | 6 +++--- javascript/jsapi/htmlelement.bnd | 25 +++++++++++++++++++++++++ javascript/jsapi/window.bnd | 8 ++++++-- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/javascript/js.h b/javascript/js.h index d7943b1b7..643ce5a56 100644 --- a/javascript/js.h +++ b/javascript/js.h @@ -51,10 +51,10 @@ jsobject *js_newcompartment(jscontext *ctx, void *win_priv, void *doc_priv); /* execute some javascript in a context */ bool js_exec(jscontext *ctx, const char *txt, size_t txtlen); -typedef struct dom_document dom_document; -typedef struct dom_node dom_node; +struct dom_document; +struct 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_ */ diff --git a/javascript/jsapi/htmlelement.bnd b/javascript/jsapi/htmlelement.bnd index 71bb31bc1..15fe83e9c 100644 --- a/javascript/jsapi/htmlelement.bnd +++ b/javascript/jsapi/htmlelement.bnd @@ -36,6 +36,8 @@ binding htmlelement { private "dom_element *" node; private "struct html_content *" htmlc; + + property unshared type EventHandler; } 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) + + */ + +%} diff --git a/javascript/jsapi/window.bnd b/javascript/jsapi/window.bnd index 56b2ff090..d7f47ce44 100644 --- a/javascript/jsapi/window.bnd +++ b/javascript/jsapi/window.bnd @@ -258,12 +258,16 @@ getter EventHandler %{ /* this implementation is unique to the window object as it is * 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 %{ /* this implementation is unique to the window object as it is * 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); %}