diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2019-12-01 10:11:38 +0000 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2019-12-01 21:25:46 +0000 |
commit | a2190f91c91f1d0468b9286bf43ac874b9b64ba1 (patch) | |
tree | 2cc695d983de295802aa9902a1fcd9c704db7ccf | |
parent | 12fd5ddd69500f504735d458093fe41e3da40a49 (diff) | |
download | netsurf-a2190f91c91f1d0468b9286bf43ac874b9b64ba1.tar.gz netsurf-a2190f91c91f1d0468b9286bf43ac874b9b64ba1.tar.bz2 |
html: Split out helper for firing DOM events and swallowing errors.
-rw-r--r-- | content/handlers/html/html.c | 27 |
1 files changed, 23 insertions, 4 deletions
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; } |