Gitweb links:
...log
http://git.netsurf-browser.org/netsurf.git/shortlog/9b640a0e989b92fce97aa2342858a1acb104f1f2
...commit
http://git.netsurf-browser.org/netsurf.git/commit/9b640a0e989b92fce97aa2342858a1acb104f1f2
...tree
http://git.netsurf-browser.org/netsurf.git/tree/9b640a0e989b92fce97aa2342858a1acb104f1f2
The branch, dsilvers/eventtarget has been updated
discards 3e49db5b651a6c424ee0bbcc5012973566b635e3 (commit)
discards d7c7ec5d4ad55819d61f8576249865269e3c9672 (commit)
discards a611c5757ea6d98cca41b2ad08bc5fde39ef48dd (commit)
discards 1d7514cd735e86adf929406dd20fd6675e7f1a9d (commit)
discards b49f0f9141a132679e9cdca944e72ebad80682ed (commit)
discards 7417da3a3452f3dac5eba0f79ce8f0610535cdb6 (commit)
discards 546ed22b553eb380e906816cdf81a0b267a79837 (commit)
discards 77eb3c576efeafd9dd4801487da5f868e80ab0d5 (commit)
discards bfde01c854284a9dcf1ae1e11639566c79cf8019 (commit)
discards 238d03fbe245b45e25033796b502b1ee3eab8e31 (commit)
discards ce43bc236847b51e7ca833ea76c237130c1d6209 (commit)
via 9b640a0e989b92fce97aa2342858a1acb104f1f2 (commit)
via 10f1b7a1aaec183defb6ae724576910494026954 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (3e49db5b651a6c424ee0bbcc5012973566b635e3)
\
N -- N -- N (9b640a0e989b92fce97aa2342858a1acb104f1f2)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/netsurf.git/commit/?id=9b640a0e989b92fce97aa2342858a1acb104f1f2
commit 9b640a0e989b92fce97aa2342858a1acb104f1f2
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
splitme: clean all this up
diff --git a/Docs/UnimplementedJavascript.txt b/Docs/UnimplementedJavascript.txt
index 2b3a7d9..1b851b8 100644
--- a/Docs/UnimplementedJavascript.txt
+++ b/Docs/UnimplementedJavascript.txt
@@ -439,9 +439,6 @@ setter EventSource::onopen(user);\n
getter EventSource::readyState(unsigned short);\n
getter EventSource::url(string);\n
getter EventSource::withCredentials(boolean);\n
-method EventTarget::addEventListener();\n
-method EventTarget::dispatchEvent();\n
-method EventTarget::removeEventListener();\n
getter Event::timeStamp(user);\n
method External::AddSearchProvider();\n
method External::IsSearchProviderInstalled();\n
diff --git a/content/handlers/javascript/duktape/EventTarget.bnd
b/content/handlers/javascript/duktape/EventTarget.bnd
new file mode 100644
index 0000000..fe78194
--- /dev/null
+++ b/content/handlers/javascript/duktape/EventTarget.bnd
@@ -0,0 +1,278 @@
+/* Event Target binding for browser using duktape and libdom
+ *
+ * Copyright 2016 Daniel Silverstone <[email protected]>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * Released under the terms of the MIT License,
+ * http://www.opensource.org/licenses/mit-license
+ */
+
+class EventTarget {
+ private bool is_node;
+ private bool capture_registered;
+ private bool bubbling_registered;
+};
+
+prologue EventTarget()
+%{
+
+static event_listener_flags event_listener_pop_options(duk_context *ctx)
+{
+ event_listener_flags ret = ELF_NONE;
+ /* ... options */
+ duk_get_prop_string(ctx, -1, "capture");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_CAPTURE;
+ duk_pop(ctx);
+ duk_get_prop_string(ctx, -1, "passive");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_PASSIVE;
+ duk_pop(ctx);
+ duk_get_prop_string(ctx, -1, "once");
+ if (duk_to_boolean(ctx, -1))
+ ret |= ELF_CAPTURE;
+ duk_pop_2(ctx);
+ /* ... */
+ return ret;
+}
+
+static void event_target_register_listener(duk_context *ctx,
+ event_listener_flags flags)
+{
+ /* ... listeners callback */
+ /* If the given callback with the given flags is already present,
+ * we do not re-add it, otherwise we need to add to listeners
+ * a tuple of the callback and flags
+ */
+ duk_uarridx_t idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx)) {
+ /* ... listeners callback candidate */
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ if (duk_strict_equals(ctx, -1, -3) &&
+ duk_get_int(ctx, -1) == (duk_int_t)flags) {
+ /* already present, nothing to do */
+ duk_pop_n(ctx, 5);
+ /* ... */
+ return;
+ }
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ duk_pop_3(ctx);
+ /* ... listeners callback */
+ idx++;
+ }
+ /* ... listeners callback undefined */
+ duk_pop(ctx);
+ /* ... listeners callback */
+ duk_push_array(ctx);
+ /* ... listeners callback newcandidate */
+ duk_insert(ctx, -2);
+ /* ... listeners newcandidate callback */
+ duk_put_prop_index(ctx, -2, 0);
+ /* ... listeners newcandidate */
+ duk_push_int(ctx, (duk_int_t)flags);
+ /* ... listeners newcandidate flags */
+ duk_put_prop_index(ctx, -2, 1);
+ /* ... listeners newcandidate */
+ duk_put_prop_index(ctx, -2, idx);
+ /* ... listeners */
+ duk_pop(ctx);
+ /* ... */
+}
+
+static void event_target_unregister_listener(duk_context *ctx,
+ event_listener_flags flags)
+{
+ /* ... listeners callback */
+ /* If the given callback with the given flags is present,
+ * we remove it and shuffle the rest up.
+ */
+ duk_uarridx_t idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx)) {
+ /* ... listeners callback candidate */
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ if (duk_strict_equals(ctx, -1, -3) &&
+ duk_get_int(ctx, -1) == (duk_int_t)flags) {
+ /* present */
+ duk_pop(ctx);
+ /* ... listeners callback candidate candidatecallback */
+ duk_put_prop_index(ctx, -2, 2);
+ /* ... listeners callback candidate */
+ duk_pop(ctx);
+ /* ... listeners callback */
+ duk_push_int(ctx, idx);
+ /* ... listeners callback found_at */
+ break;
+ }
+ /* ... listeners callback candidate candidatecallback
candidateflags */
+ duk_pop_3(ctx);
+ /* ... listeners callback */
+ idx++;
+ }
+ /* ... listeners callback undefined/found_at */
+ if (duk_is_undefined(ctx, -1)) {
+ /* not found, clean up and come out */
+ duk_pop_3(ctx);
+ return;
+ }
+ idx = duk_to_int(ctx, -1);
+ duk_pop_2(ctx);
+ /* ... listeners */
+ dukky_shuffle_array(ctx, idx);
+ /* ... listeners */
+ duk_pop(ctx);
+ /* ... */
+}
+
+
+%}
+
+init EventTarget()
+%{
+ priv->is_node = false;
+ priv->capture_registered = false;
+ priv->bubbling_registered = false;
+
+%}
+
+method EventTarget::addEventListener()
+%{
+ dom_exception exc;
+ event_listener_flags flags = ELF_NONE;
+ /* Incoming stack is: type callback [options] */
+ if (duk_get_top(ctx) < 2) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) > 3) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) == 2) {
+ duk_push_object(ctx);
+ /* type callback options */
+ }
+ if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT) {
+ /* legacy support, if not object, it's the capture value */
+ duk_push_object(ctx);
+ /* ... capture options */
+ duk_insert(ctx, -2);
+ /* ... options capture */
+ duk_put_prop_string(ctx, -2, "capture");
+ /* ... options */
+ }
+ /* type callback options */
+ flags = event_listener_pop_options(ctx);
+ /* type callback */
+ duk_dup(ctx, -2);
+ /* type callback type */
+ duk_push_this(ctx);
+ /* type callback type this(=EventTarget) */
+ if (dukky_event_target_push_listeners(ctx, false) && priv->is_node) {
+ /* Take a moment to register a JS callback */
+ duk_size_t ev_ty_l;
+ const char *ev_ty = duk_to_lstring(ctx, -3, &ev_ty_l);
+ dom_string *ev_ty_s;
+ exc = dom_string_create((const uint8_t*)ev_ty, ev_ty_l,
+ &ev_ty_s);
+ if (exc != DOM_NO_ERR) {
+ LOG("Oh dear, failed to create dom_string in
addEventListener()");
+ return 0;
+ }
+ dukky_register_event_listener_for(
+ ctx, (dom_element *)((node_private_t *)priv)->node,
+ ev_ty_s,
+ !!(flags & ELF_CAPTURE));
+ dom_string_unref(ev_ty_s);
+ }
+ /* type callback typelisteners */
+ duk_insert(ctx, -2);
+ /* type typelisteners callback */
+ event_target_register_listener(ctx, flags);
+ /* type */
+ return 0;
+%}
+
+method EventTarget::removeEventListener()
+%{
+ event_listener_flags flags = ELF_NONE;
+ /* Incoming stack is: type callback [options] */
+ if (duk_get_top(ctx) < 2) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) > 3) return 0; /* Bad arguments */
+ if (duk_get_top(ctx) == 2) {
+ duk_push_object(ctx);
+ /* type callback options */
+ }
+ if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT) {
+ /* legacy support, if not object, it's the capture value */
+ duk_push_object(ctx);
+ /* ... capture options */
+ duk_insert(ctx, -2);
+ /* ... options capture */
+ duk_put_prop_string(ctx, -2, "capture");
+ /* ... options */
+ }
+ /* type callback options */
+ flags = event_listener_pop_options(ctx);
+ /* type callback */
+ duk_dup(ctx, -2);
+ /* type callback type */
+ duk_push_this(ctx);
+ /* type callback type this(=EventTarget) */
+ if (dukky_event_target_push_listeners(ctx, true)) {
+ /* nothing to do because the listener wasn't there at all */
+ duk_pop_3(ctx);
+ return 0;
+ }
+ /* type callback typelisteners */
+ duk_insert(ctx, -2);
+ /* type typelisteners callback */
+ event_target_unregister_listener(ctx, flags);
+ /* type */
+ return 0;
+%}
+
+
+
+method EventTarget::dispatchEvent()
+%{
+ dom_exception exc;
+ if (!dukky_instanceof(ctx, 0, PROTO_NAME(EVENT))) return 0;
+
+ duk_get_prop_string(ctx, 0, PRIVATE_MAGIC);
+ event_private_t *evpriv = duk_get_pointer(ctx, -1);
+ duk_pop(ctx);
+
+ dom_event *evt = evpriv->evt;
+
+ /* Dispatch event logic, see:
+ * https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
+ */
+ bool in_dispatch;
+ if (dom_event_in_dispatch(evt, &in_dispatch) != DOM_NO_ERR) return 0;
+ if (in_dispatch) {
+ /** \todo Raise InvalidStateException */
+ return 0;
+ }
+
+ bool is_initialised;
+ if (dom_event_is_initialised(evt, &is_initialised) != DOM_NO_ERR)
return 0;
+ if (is_initialised == false) {
+ /** \todo Raise InvalidStateException */
+ return 0;
+ }
+
+ if (dom_event_set_is_trusted(evt, false) != DOM_NO_ERR) return 0;
+
+ /** \todo work out how to dispatch against non-node things */
+ if (priv->is_node == false) return 0;
+
+ bool success;
+ /* Event prepared, dispatch against ourselves */
+ exc = dom_event_target_dispatch_event(
+ ((node_private_t *)priv)->node,
+ evt,
+ &success);
+ if (exc != DOM_NO_ERR) return 0; /**< \todo raise correct exception */
+
+ duk_push_boolean(ctx, success);
+ return 1;
+%}
diff --git a/content/handlers/javascript/duktape/Node.bnd
b/content/handlers/javascript/duktape/Node.bnd
index f237c87..f14cfc1 100644
--- a/content/handlers/javascript/duktape/Node.bnd
+++ b/content/handlers/javascript/duktape/Node.bnd
@@ -16,6 +16,7 @@ init Node(struct dom_node *node)
%{
priv->node = node;
dom_node_ref(node);
+ priv->parent.is_node = true;
%}
fini Node()
diff --git a/content/handlers/javascript/duktape/dukky.c
b/content/handlers/javascript/duktape/dukky.c
index 1282ad9..46ff584 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -46,6 +46,7 @@
#define EVENT_MAGIC MAGIC(EVENT_MAP)
#define HANDLER_LISTENER_MAGIC MAGIC(HANDLER_LISTENER_MAP)
#define HANDLER_MAGIC MAGIC(HANDLER_MAP)
+#define EVENT_LISTENER_JS_MAGIC MAGIC(EVENT_LISTENER_JS_MAP)
static duk_ret_t dukky_populate_object(duk_context *ctx)
{
@@ -809,6 +810,8 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
dom_exception exc;
dom_event_target *targ;
dom_event_flow_phase phase;
+ duk_uarridx_t idx;
+ event_listener_flags flags;
/* Retrieve the JS context from the Duktape context */
duk_get_memory_functions(ctx, &funcs);
@@ -839,7 +842,13 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
LOG("Unable to find the event target");
return;
}
-
+
+ /* If we're capturing right now, we skip the 'event handler'
+ * and go straight to the extras
+ */
+ if (phase == DOM_CAPTURING_PHASE)
+ goto handle_extras;
+
/* ... */
if (dukky_push_node(ctx, (dom_node *)targ) == false) {
dom_string_unref(name);
@@ -850,13 +859,9 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
/* ... node */
if (dukky_get_current_value_of_event_handler(
ctx, name, (dom_event_target *)targ) == false) {
- dom_node_unref(targ);
- dom_string_unref(name);
- return;
+ /* ... */
+ goto handle_extras;
}
- /** @todo handle other kinds of event than the generic case */
- dom_node_unref(targ);
- dom_string_unref(name);
/* ... handler node */
dukky_push_event(ctx, evt);
/* ... handler node event */
@@ -882,7 +887,7 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
duk_pop_n(ctx, 6);
/* ... */
- return;
+ goto handle_extras;
}
/* ... result */
if (duk_is_boolean(ctx, -1) &&
@@ -890,12 +895,113 @@ static void dukky_generic_event_handler(dom_event *evt,
void *pw)
dom_event_prevent_default(evt);
}
duk_pop(ctx);
+handle_extras:
/* ... */
+ duk_push_lstring(ctx, dom_string_data(name), dom_string_length(name));
+ dukky_push_node(ctx, (dom_node *)targ);
+ /* ... type node */
+ if (dukky_event_target_push_listeners(ctx, true)) {
+ /* Nothing to do */
+ duk_pop(ctx);
+ goto out;
+ }
+ /* ... sublisteners */
+ duk_push_array(ctx);
+ /* ... sublisteners copy */
+ idx = 0;
+ while (duk_get_prop_index(ctx, -2, idx)) {
+ /* ... sublisteners copy handler */
+ duk_get_prop_index(ctx, -1, 1);
+ /* ... sublisteners copy handler flags */
+ if ((event_listener_flags)duk_to_int(ctx, -1) & ELF_ONCE) {
+ duk_dup(ctx, -4);
+ /* ... subl copy handler flags subl */
+ dukky_shuffle_array(ctx, idx);
+ duk_pop(ctx);
+ /* ... subl copy handler flags */
+ }
+ duk_pop(ctx);
+ /* ... sublisteners copy handler */
+ duk_put_prop_index(ctx, -2, idx);
+ /* ... sublisteners copy */
+ idx++;
+ }
+ /* ... sublisteners copy undefined */
+ duk_pop(ctx);
+ /* ... sublisteners copy */
+ duk_insert(ctx, -2);
+ /* ... copy sublisteners */
+ duk_pop(ctx);
+ /* ... copy */
+ idx = 0;
+ while (duk_get_prop_index(ctx, -1, idx++)) {
+ /* ... copy handler */
+ if (duk_get_prop_index(ctx, -1, 2)) {
+ /* ... copy handler meh */
+ duk_pop_2(ctx);
+ continue;
+ }
+ duk_pop(ctx);
+ duk_get_prop_index(ctx, -1, 0);
+ duk_get_prop_index(ctx, -2, 1);
+ /* ... copy handler callback flags */
+ flags = (event_listener_flags)duk_get_int(ctx, -1);
+ duk_pop(ctx);
+ /* ... copy handler callback */
+ if (((phase == DOM_CAPTURING_PHASE) && !(flags & ELF_CAPTURE))
||
+ ((phase != DOM_CAPTURING_PHASE) && (flags & ELF_CAPTURE))) {
+ duk_pop_2(ctx);
+ /* ... copy */
+ continue;
+ }
+ /* ... copy handler callback */
+ dukky_push_node(ctx, (dom_node *)targ);
+ /* ... copy handler callback node */
+ dukky_push_event(ctx, evt);
+ /* ... copy handler callback node event */
+ (void) nsu_getmonotonic_ms(&jsctx->exec_start_time);
+ if (duk_pcall_method(ctx, 1) != 0) {
+ /* Failed to run the method */
+ /* ... copy handler err */
+ LOG("OH NOES! An error running a callback. Meh.");
+ exc = dom_event_stop_immediate_propagation(evt);
+ if (exc != DOM_NO_ERR)
+ LOG("WORSE! could not stop propagation");
+ duk_get_prop_string(ctx, -1, "name");
+ duk_get_prop_string(ctx, -2, "message");
+ duk_get_prop_string(ctx, -3, "fileName");
+ duk_get_prop_string(ctx, -4, "lineNumber");
+ duk_get_prop_string(ctx, -5, "stack");
+ /* ... err name message fileName lineNumber stack */
+ LOG("Uncaught error in JS: %s: %s",
duk_safe_to_string(ctx, -5),
+ duk_safe_to_string(ctx, -4));
+ LOG(" was at: %s line %s",
duk_safe_to_string(ctx, -3),
+ duk_safe_to_string(ctx, -2));
+ LOG(" Stack trace: %s", duk_safe_to_string(ctx,
-1));
+
+ duk_pop_n(ctx, 7);
+ /* ... copy */
+ continue;
+ }
+ /* ... copy handler result */
+ if (duk_is_boolean(ctx, -1) &&
+ duk_to_boolean(ctx, -1) == 0) {
+ dom_event_prevent_default(evt);
+ }
+ duk_pop_2(ctx);
+ /* ... copy */
+ }
+ duk_pop_2(ctx);
+out:
+ /* ... */
+ dom_node_unref(targ);
+ dom_string_unref(name);
}
void dukky_register_event_listener_for(duk_context *ctx,
struct dom_element *ele,
- dom_string *name)
+ dom_string *name,
+ bool capture)
{
dom_event_listener *listen = NULL;
dom_exception exc;
@@ -927,7 +1033,7 @@ void dukky_register_event_listener_for(duk_context *ctx,
&listen);
if (exc != DOM_NO_ERR) return;
exc = dom_event_target_add_event_listener(
- ele, name, listen, false);
+ ele, name, listen, capture);
if (exc != DOM_NO_ERR) {
LOG("Unable to register listener for %p.%*s",
ele, dom_string_length(name), dom_string_data(name));
@@ -938,6 +1044,71 @@ void dukky_register_event_listener_for(duk_context *ctx,
dom_event_listener_unref(listen);
}
+/* The sub-listeners are a list of {callback,flags} tuples */
+/* We return true if we created a new sublistener table */
+/* If we're told to not create, but we want to, we still return true */
+bool dukky_event_target_push_listeners(duk_context *ctx, bool dont_create)
+{
+ bool ret = false;
+ /* ... type this */
+ duk_get_prop_string(ctx, -1, EVENT_LISTENER_JS_MAGIC);
+ if (duk_is_undefined(ctx, -1)) {
+ /* ... type this null */
+ duk_pop(ctx);
+ duk_push_object(ctx);
+ duk_dup(ctx, -1);
+ /* ... type this listeners listeners */
+ duk_put_prop_string(ctx, -3, EVENT_LISTENER_JS_MAGIC);
+ /* ... type this listeners */
+ }
+ /* ... type this listeners */
+ duk_insert(ctx, -3);
+ /* ... listeners type this */
+ duk_pop(ctx);
+ /* ... listeners type */
+ duk_dup(ctx, -1);
+ /* ... listeners type type */
+ duk_get_prop(ctx, -3);
+ /* ... listeners type ??? */
+ if (duk_is_undefined(ctx, -1)) {
+ /* ... listeners type ??? */
+ if (dont_create == true) {
+ duk_pop_3(ctx);
+ duk_push_undefined(ctx);
+ return true;
+ }
+ duk_pop(ctx);
+ duk_push_array(ctx);
+ duk_dup(ctx, -2);
+ duk_dup(ctx, -2);
+ /* ... listeners type sublisteners type sublisteners */
+ duk_put_prop(ctx, -5);
+ /* ... listeners type sublisteners */
+ ret = true;
+ }
+ duk_insert(ctx, -3);
+ /* ... sublisteners listeners type */
+ duk_pop_2(ctx);
+ /* ... sublisteners */
+ return ret;
+}
+
+/* Shuffle a duktape array "down" one. This involves iterating from
+ * the index provided, shuffling elements down, until we reach an
+ * undefined
+ */
+void dukky_shuffle_array(duk_context *ctx, duk_uarridx_t idx)
+{
+ /* ... somearr */
+ while (duk_get_prop_index(ctx, -1, idx + 1)) {
+ duk_put_prop_index(ctx, -2, idx);
+ idx++;
+ }
+ /* ... somearr undefined */
+ duk_del_prop_index(ctx, -2, idx + 1);
+ duk_pop(ctx);
+}
+
void js_handle_new_element(jscontext *ctx, struct dom_element *node)
{
@@ -995,7 +1166,7 @@ void js_handle_new_element(jscontext *ctx, struct
dom_element *node)
&sub);
if (exc == DOM_NO_ERR) {
dukky_register_event_listener_for(
- CTX, node, sub);
+ CTX, node, sub, false);
dom_string_unref(sub);
}
}
diff --git a/content/handlers/javascript/duktape/dukky.h
b/content/handlers/javascript/duktape/dukky.h
index 0c3ff0e..b5809aa 100644
--- a/content/handlers/javascript/duktape/dukky.h
+++ b/content/handlers/javascript/duktape/dukky.h
@@ -37,9 +37,20 @@ duk_bool_t dukky_push_node(duk_context *ctx, struct dom_node
*node);
void dukky_inject_not_ctr(duk_context *ctx, int idx, const char *name);
void dukky_register_event_listener_for(duk_context *ctx,
struct dom_element *ele,
- dom_string *name);
+ dom_string *name,
+ bool capture);
bool dukky_get_current_value_of_event_handler(duk_context *ctx,
dom_string *name,
dom_event_target *et);
+bool dukky_event_target_push_listeners(duk_context *ctx, bool dont_create);
+
+typedef enum {
+ ELF_CAPTURE = 1 << 0,
+ ELF_PASSIVE = 1 << 1,
+ ELF_ONCE = 1 << 2,
+ ELF_NONE = 0
+} event_listener_flags;
+
+void dukky_shuffle_array(duk_context *ctx, duk_uarridx_t idx);
#endif
diff --git a/content/handlers/javascript/duktape/netsurf.bnd
b/content/handlers/javascript/duktape/netsurf.bnd
index 4aca475..2a56ccc 100644
--- a/content/handlers/javascript/duktape/netsurf.bnd
+++ b/content/handlers/javascript/duktape/netsurf.bnd
@@ -54,6 +54,7 @@ struct dom_html_br_element;
};
+#include "EventTarget.bnd"
#include "Console.bnd"
#include "Window.bnd"
#include "Document.bnd"
diff --git a/test/js/dom-change-event.html b/test/js/dom-change-event.html
new file mode 100644
index 0000000..6c6fbfb
--- /dev/null
+++ b/test/js/dom-change-event.html
@@ -0,0 +1,17 @@
+<html>
+ <head>
+ <title>DOM Change event handling</title>
+ <script type="text/javascript">
+ document.addEventListener("DOMNodeInserted",
+ function(ev) {
+ console.log("\n\nHELLO WORLD!\n\n");
+ console.log(ev);
+ console.log("\n\n");
+ }, false);
+ console.log("Moooo!");
+ </script>
+ </head>
+ <body>
+ <div>I got inserted</div>
+ </body>
+</html>
diff --git a/utils/corestrings.c b/utils/corestrings.c
index 363c851..87a3423 100644
--- a/utils/corestrings.c
+++ b/utils/corestrings.c
@@ -277,6 +277,14 @@ dom_string *corestring_dom_onfocus;
dom_string *corestring_dom_onload;
dom_string *corestring_dom_onresize;
dom_string *corestring_dom_onscroll;
+dom_string *corestring_dom_autocomplete;
+dom_string *corestring_dom_autocompleteerror;
+dom_string *corestring_dom_dragexit;
+dom_string *corestring_dom_mouseenter;
+dom_string *corestring_dom_mouseleave;
+dom_string *corestring_dom_wheel;
+dom_string *corestring_dom_sort;
+dom_string *corestring_dom_toggle;
dom_string *corestring_dom___ns_key_box_node_data;
dom_string *corestring_dom___ns_key_libcss_node_data;
dom_string *corestring_dom___ns_key_file_name_node_data;
@@ -563,6 +571,15 @@ void corestrings_fini(void)
CSS_DOM_STRING_UNREF(onload);
CSS_DOM_STRING_UNREF(onresize);
CSS_DOM_STRING_UNREF(onscroll);
+ /* Corestrings used by DOM event registration */
+ CSS_DOM_STRING_UNREF(autocomplete);
+ CSS_DOM_STRING_UNREF(autocompleteerror);
+ CSS_DOM_STRING_UNREF(dragexit);
+ CSS_DOM_STRING_UNREF(mouseenter);
+ CSS_DOM_STRING_UNREF(mouseleave);
+ CSS_DOM_STRING_UNREF(wheel);
+ CSS_DOM_STRING_UNREF(sort);
+ CSS_DOM_STRING_UNREF(toggle);
/* DOM userdata keys, not really CSS */
CSS_DOM_STRING_UNREF(__ns_key_box_node_data);
CSS_DOM_STRING_UNREF(__ns_key_libcss_node_data);
@@ -894,6 +911,15 @@ nserror corestrings_init(void)
CSS_DOM_STRING_INTERN(onload);
CSS_DOM_STRING_INTERN(onresize);
CSS_DOM_STRING_INTERN(onscroll);
+ /* Corestrings used by DOM event registration */
+ CSS_DOM_STRING_INTERN(autocomplete);
+ CSS_DOM_STRING_INTERN(autocompleteerror);
+ CSS_DOM_STRING_INTERN(dragexit);
+ CSS_DOM_STRING_INTERN(mouseenter);
+ CSS_DOM_STRING_INTERN(mouseleave);
+ CSS_DOM_STRING_INTERN(wheel);
+ CSS_DOM_STRING_INTERN(sort);
+ CSS_DOM_STRING_INTERN(toggle);
/* DOM userdata keys, not really CSS */
CSS_DOM_STRING_INTERN(__ns_key_box_node_data);
CSS_DOM_STRING_INTERN(__ns_key_libcss_node_data);
diff --git a/utils/corestrings.h b/utils/corestrings.h
index a02bdda..88dc2ce 100644
--- a/utils/corestrings.h
+++ b/utils/corestrings.h
@@ -295,7 +295,15 @@ extern struct dom_string *corestring_dom_onfocus;
extern struct dom_string *corestring_dom_onload;
extern struct dom_string *corestring_dom_onresize;
extern struct dom_string *corestring_dom_onscroll;
-
+/* Corestrings used by DOM event registration */
+extern struct dom_string *corestring_dom_autocomplete;
+extern struct dom_string *corestring_dom_autocompleteerror;
+extern struct dom_string *corestring_dom_dragexit;
+extern struct dom_string *corestring_dom_mouseenter;
+extern struct dom_string *corestring_dom_mouseleave;
+extern struct dom_string *corestring_dom_wheel;
+extern struct dom_string *corestring_dom_sort;
+extern struct dom_string *corestring_dom_toggle;
/* DOM userdata keys */
extern struct dom_string *corestring_dom___ns_key_box_node_data;
extern struct dom_string *corestring_dom___ns_key_libcss_node_data;
-----------------------------------------------------------------------
Summary of changes:
frontends/gtk/gui.c | 6 ++++++
frontends/gtk/hotlist.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index c08ab0a..8d6b422 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -449,6 +449,12 @@ static void gui_quit(void)
messages_get_errorcode(res));
}
+ res = hotlist_fini(nsoption_charp(hotlist_path));
+ if (res != NSERROR_OK) {
+ LOG("Error finalising hotlist: %s",
+ messages_get_errorcode(res));
+ }
+
free(nsgtk_config_home);
gtk_fetch_filetype_fin();
diff --git a/frontends/gtk/hotlist.c b/frontends/gtk/hotlist.c
index 6ce9060..34a1377 100644
--- a/frontends/gtk/hotlist.c
+++ b/frontends/gtk/hotlist.c
@@ -398,7 +398,7 @@ nserror nsgtk_hotlist_destroy(void)
return NSERROR_OK;
}
- res = hotlist_fini(nsoption_charp(hotlist_path));
+ res = hotlist_manager_fini();
if (res == NSERROR_OK) {
res = nsgtk_corewindow_fini(&hotlist_window->core);
gtk_widget_destroy(GTK_WIDGET(hotlist_window->wnd));
--
NetSurf Browser
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org