From a2190f91c91f1d0468b9286bf43ac874b9b64ba1 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 1 Dec 2019 10:11:38 +0000 Subject: html: Split out helper for firing DOM events and swallowing errors. --- content/handlers/html/html.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'content/handlers/html') diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c index c66d2aca1..e47ee7f4f 100644 --- a/content/handlers/html/html.c +++ b/content/handlers/html/html.c @@ -77,6 +77,28 @@ static const char *html_types[] = { "text/html" }; +/** + * Fire an event at the DOM + * + * Helper that swallows DOM errors. + * + * \param[in] event the event to fire at the DOM + * \param[in] target the event target + * \return true on success + */ +static bool fire_dom_event(dom_event *event, dom_node *target) +{ + dom_exception exc; + bool result; + + exc = dom_event_target_dispatch_event(target, event, &result); + if (exc != DOM_NO_ERR) { + return false; + } + + return result; +} + /* Exported interface, see html_internal.h */ bool fire_generic_dom_event(dom_string *type, dom_node *target, bool bubbles, bool cancelable) @@ -94,10 +116,7 @@ bool fire_generic_dom_event(dom_string *type, dom_node *target, } NSLOG(netsurf, INFO, "Dispatching '%*s' against %p", dom_string_length(type), dom_string_data(type), target); - exc = dom_event_target_dispatch_event(target, evt, &result); - if (exc != DOM_NO_ERR) { - result = false; - } + result = fire_dom_event(evt, target); dom_event_unref(evt); return result; } -- cgit v1.2.3