From 081cf689356ef9138b67da2c687883b9c3354a63 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 19 Feb 2013 23:27:10 +0000 Subject: add context for default action function --- src/core/document.c | 12 +++++++----- src/core/document.h | 6 ++++-- src/core/implementation.c | 5 +++-- src/core/node.c | 3 ++- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/core') 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); -- cgit v1.2.3