summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2013-02-19 23:27:10 (GMT)
committer Vincent Sanders <vince@kyllikki.org>2013-02-19 23:27:10 (GMT)
commit081cf689356ef9138b67da2c687883b9c3354a63 (patch)
treec482500d137ff527279e15f1167ac3d2022fb013
parentf7ae4017ff50be5ef4eb3047ebbff4820550d5ed (diff)
downloadlibdom-081cf689356ef9138b67da2c687883b9c3354a63.tar.gz
libdom-081cf689356ef9138b67da2c687883b9c3354a63.tar.bz2
add context for default action function
-rw-r--r--bindings/hubbub/parser.c1
-rw-r--r--bindings/xml/expat_xmlparser.c1
-rw-r--r--bindings/xml/libxml_xmlparser.c1
-rw-r--r--include/dom/core/implementation.h1
-rw-r--r--src/core/document.c12
-rw-r--r--src/core/document.h6
-rw-r--r--src/core/implementation.c5
-rw-r--r--src/core/node.c3
-rw-r--r--src/events/document_event.c4
-rw-r--r--src/events/document_event.h4
-rw-r--r--src/html/html_document.c8
-rw-r--r--src/html/html_document.h7
12 files changed, 36 insertions, 17 deletions
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 0c80a65..b597f9a 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -794,6 +794,7 @@ dom_hubbub_parser_create(dom_hubbub_parser_params *params,
NULL,
NULL,
params->daf,
+ params->ctx,
&binding->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(binding->parser);
diff --git a/bindings/xml/expat_xmlparser.c b/bindings/xml/expat_xmlparser.c
index cc08171..f2ffc76 100644
--- a/bindings/xml/expat_xmlparser.c
+++ b/bindings/xml/expat_xmlparser.c
@@ -478,6 +478,7 @@ dom_xml_parser_create(const char *enc, const char *int_enc,
/* qname */ NULL,
/* doctype */ NULL,
NULL,
+ NULL,
document);
if (err != DOM_NO_ERR) {
diff --git a/bindings/xml/libxml_xmlparser.c b/bindings/xml/libxml_xmlparser.c
index dde598c..87b137d 100644
--- a/bindings/xml/libxml_xmlparser.c
+++ b/bindings/xml/libxml_xmlparser.c
@@ -214,6 +214,7 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
/* qname */ NULL,
/* doctype */ NULL,
NULL,
+ NULL,
document);
if (err != DOM_NO_ERR) {
diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h
index e48e506..2a47da0 100644
--- a/include/dom/core/implementation.h
+++ b/include/dom/core/implementation.h
@@ -43,6 +43,7 @@ dom_exception dom_implementation_create_document(
const char *namespace, const char *qname,
struct dom_document_type *doctype,
dom_events_default_action_fetcher daf,
+ void *daf_ctx,
struct dom_document **doc);
dom_exception dom_implementation_get_feature(
diff --git a/src/core/document.c b/src/core/document.c
index 97d93a6..8f316ff 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -79,7 +79,8 @@ static dom_exception dom_document_dup_node(dom_document *doc,
* The returned document will already be referenced.
*/
dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
- dom_document **doc)
+ void *daf_ctx,
+ dom_document **doc)
{
dom_document *d;
dom_exception err;
@@ -98,7 +99,7 @@ dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
* reaches zero. Documents own themselves (this simplifies the
* rest of the code, as it doesn't need to special case Documents)
*/
- err = _dom_document_initialise(d, daf);
+ err = _dom_document_initialise(d, daf, daf_ctx);
if (err != DOM_NO_ERR) {
/* Clean up document */
free(d);
@@ -111,8 +112,9 @@ dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
}
/* Initialise the document */
-dom_exception _dom_document_initialise(dom_document *doc,
- dom_events_default_action_fetcher daf)
+dom_exception _dom_document_initialise(dom_document *doc,
+ dom_events_default_action_fetcher daf,
+ void *daf_ctx)
{
dom_exception err;
dom_string *name;
@@ -248,7 +250,7 @@ dom_exception _dom_document_initialise(dom_document *doc,
}
/* We should not pass a NULL when all things hook up */
- return _dom_document_event_internal_initialise(doc, &doc->dei, daf);
+ return _dom_document_event_internal_initialise(doc, &doc->dei, daf, daf_ctx);
}
diff --git a/src/core/document.h b/src/core/document.h
index 89635ff..de49cf2 100644
--- a/src/core/document.h
+++ b/src/core/document.h
@@ -72,11 +72,13 @@ struct dom_document {
/* Create a DOM document */
dom_exception _dom_document_create(dom_events_default_action_fetcher daf,
- dom_document **doc);
+ void *daf_ctx,
+ dom_document **doc);
/* Initialise the document */
dom_exception _dom_document_initialise(dom_document *doc,
- dom_events_default_action_fetcher daf);
+ dom_events_default_action_fetcher daf,
+ void *daf_ctx);
/* Finalise the document */
bool _dom_document_finalise(dom_document *doc);
diff --git a/src/core/implementation.c b/src/core/implementation.c
index c80af7f..bc07c6d 100644
--- a/src/core/implementation.c
+++ b/src/core/implementation.c
@@ -153,6 +153,7 @@ dom_exception dom_implementation_create_document(
const char *namespace, const char *qname,
struct dom_document_type *doctype,
dom_events_default_action_fetcher daf,
+ void *daf_ctx,
struct dom_document **doc)
{
struct dom_document *d;
@@ -198,11 +199,11 @@ dom_exception dom_implementation_create_document(
if (impl_type == DOM_IMPLEMENTATION_HTML) {
dom_html_document *html_doc;
- err = _dom_html_document_create(daf, &html_doc);
+ err = _dom_html_document_create(daf, daf_ctx, &html_doc);
d = (dom_document *) html_doc;
} else {
- err = _dom_document_create(daf, &d);
+ err = _dom_document_create(daf, daf_ctx, &d);
}
if (err != DOM_NO_ERR) {
diff --git a/src/core/node.c b/src/core/node.c
index c7794e6..1323fca 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -2315,7 +2315,7 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
dom_document_event_internal *dei;
dom_event_target **targets;
uint32_t ntargets, ntargets_allocated, targetnr;
- void *pw = NULL;
+ void *pw;
assert(et != NULL);
assert(evt != NULL);
@@ -2376,6 +2376,7 @@ dom_exception _dom_node_dispatch_event(dom_event_target *et,
/* The started callback of default action */
dei = &doc->dei;
+ pw = dei->actions_ctx;
if (dei->actions != NULL) {
dom_default_action_callback cb = dei->actions(evt->type,
DOM_DEFAULT_ACTION_STARTED, &pw);
diff --git a/src/events/document_event.c b/src/events/document_event.c
index 0546364..37aeb73 100644
--- a/src/events/document_event.c
+++ b/src/events/document_event.c
@@ -51,7 +51,8 @@ static const char *__event_types[] = {
*/
dom_exception _dom_document_event_internal_initialise(struct dom_document *doc,
dom_document_event_internal *dei,
- dom_events_default_action_fetcher actions)
+ dom_events_default_action_fetcher actions,
+ void *actions_ctx)
{
lwc_error err;
int i;
@@ -66,6 +67,7 @@ dom_exception _dom_document_event_internal_initialise(struct dom_document *doc,
}
dei->actions = actions;
+ dei->actions_ctx = actions_ctx;
return DOM_NO_ERR;
}
diff --git a/src/events/document_event.h b/src/events/document_event.h
index 2458508..1e04045 100644
--- a/src/events/document_event.h
+++ b/src/events/document_event.h
@@ -38,6 +38,7 @@ typedef enum {
struct dom_document_event_internal {
dom_events_default_action_fetcher actions;
/**< The default action fetecher */
+ void *actions_ctx; /**< The default action fetcher context */
struct lwc_string_s *event_types[DOM_EVENT_COUNT];
/**< Events type names */
};
@@ -53,7 +54,8 @@ typedef struct dom_document_event_internal dom_document_event_internal;
/* Initialise this DocumentEvent */
dom_exception _dom_document_event_internal_initialise(struct dom_document *doc,
dom_document_event_internal *dei,
- dom_events_default_action_fetcher actions);
+ dom_events_default_action_fetcher actions,
+ void *actions_ctx);
/* Finalise this DocumentEvent */
void _dom_document_event_internal_finalise(struct dom_document *doc,
diff --git a/src/html/html_document.c b/src/html/html_document.c
index cec4526..e248e17 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -50,6 +50,7 @@ static struct dom_node_protect_vtable html_document_protect_vtable = {
/* Create a HTMLDocument */
dom_exception _dom_html_document_create(
dom_events_default_action_fetcher daf,
+ void *daf_ctx,
dom_html_document **doc)
{
dom_exception error;
@@ -62,7 +63,7 @@ dom_exception _dom_html_document_create(
result->base.base.base.vtable = &html_document_vtable;
result->base.base.vtable = &html_document_protect_vtable;
- error = _dom_html_document_initialise(result, daf);
+ error = _dom_html_document_initialise(result, daf, daf_ctx);
if (error != DOM_NO_ERR) {
free(result);
return error;
@@ -74,12 +75,13 @@ dom_exception _dom_html_document_create(
/* Initialise a HTMLDocument */
dom_exception _dom_html_document_initialise(dom_html_document *doc,
- dom_events_default_action_fetcher daf)
+ dom_events_default_action_fetcher daf,
+ void *daf_ctx)
{
dom_exception error;
int sidx;
- error = _dom_document_initialise(&doc->base, daf);
+ error = _dom_document_initialise(&doc->base, daf, daf_ctx);
if (error != DOM_NO_ERR)
return error;
diff --git a/src/html/html_document.h b/src/html/html_document.h
index ecc6236..67250f5 100644
--- a/src/html/html_document.h
+++ b/src/html/html_document.h
@@ -33,10 +33,13 @@ struct dom_html_document {
/* Create a HTMLDocument */
dom_exception _dom_html_document_create(
dom_events_default_action_fetcher daf,
+ void *daf_ctx,
dom_html_document **doc);
/* Initialise a HTMLDocument */
-dom_exception _dom_html_document_initialise(dom_html_document *doc,
- dom_events_default_action_fetcher daf);
+dom_exception _dom_html_document_initialise(
+ dom_html_document *doc,
+ dom_events_default_action_fetcher daf,
+ void *daf_ctx);
/* Finalise a HTMLDocument */
bool _dom_html_document_finalise(dom_html_document *doc);