mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-21 03:32:35 +03:00
Ensure that those events listed in 8.1.5.2 as forwarded from body to window, don't get registered for listeners on body
This commit is contained in:
parent
9fe01f09c8
commit
b42a910ed9
@ -726,6 +726,16 @@ void js_handle_new_element(jscontext *ctx, struct dom_element *node)
|
|||||||
dom_ulong siz;
|
dom_ulong siz;
|
||||||
dom_attr *attr = NULL;
|
dom_attr *attr = NULL;
|
||||||
dom_string *key = NULL;
|
dom_string *key = NULL;
|
||||||
|
dom_string *nodename;
|
||||||
|
duk_bool_t is_body = false;
|
||||||
|
|
||||||
|
exc = dom_node_get_node_name(node, &nodename);
|
||||||
|
if (exc != DOM_NO_ERR) return;
|
||||||
|
|
||||||
|
if (nodename == corestring_dom_BODY)
|
||||||
|
is_body = true;
|
||||||
|
|
||||||
|
dom_string_unref(nodename);
|
||||||
|
|
||||||
exc = dom_node_get_attributes(node, &map);
|
exc = dom_node_get_attributes(node, &map);
|
||||||
if (exc != DOM_NO_ERR) return;
|
if (exc != DOM_NO_ERR) return;
|
||||||
@ -739,6 +749,19 @@ void js_handle_new_element(jscontext *ctx, struct dom_element *node)
|
|||||||
if (exc != DOM_NO_ERR) goto out;
|
if (exc != DOM_NO_ERR) goto out;
|
||||||
exc = dom_attr_get_name(attr, &key);
|
exc = dom_attr_get_name(attr, &key);
|
||||||
if (exc != DOM_NO_ERR) goto out;
|
if (exc != DOM_NO_ERR) goto out;
|
||||||
|
if (is_body && (
|
||||||
|
key == corestring_dom_onblur ||
|
||||||
|
key == corestring_dom_onerror ||
|
||||||
|
key == corestring_dom_onfocus ||
|
||||||
|
key == corestring_dom_onload ||
|
||||||
|
key == corestring_dom_onresize ||
|
||||||
|
key == corestring_dom_onscroll)) {
|
||||||
|
/* This is a forwarded event, it doesn't matter,
|
||||||
|
* we should skip registering for it and later
|
||||||
|
* we will register it for Window itself
|
||||||
|
*/
|
||||||
|
goto skip_register;
|
||||||
|
}
|
||||||
if (dom_string_length(key) > 2) {
|
if (dom_string_length(key) > 2) {
|
||||||
/* Can be on* */
|
/* Can be on* */
|
||||||
const uint8_t *data = (const uint8_t *)dom_string_data(key);
|
const uint8_t *data = (const uint8_t *)dom_string_data(key);
|
||||||
@ -754,6 +777,7 @@ void js_handle_new_element(jscontext *ctx, struct dom_element *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
skip_register:
|
||||||
dom_string_unref(key); key = NULL;
|
dom_string_unref(key); key = NULL;
|
||||||
dom_node_unref(attr); attr = NULL;
|
dom_node_unref(attr); attr = NULL;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,12 @@ dom_string *corestring_dom_radio;
|
|||||||
dom_string *corestring_dom_checkbox;
|
dom_string *corestring_dom_checkbox;
|
||||||
dom_string *corestring_dom_file;
|
dom_string *corestring_dom_file;
|
||||||
dom_string *corestring_dom_on;
|
dom_string *corestring_dom_on;
|
||||||
|
dom_string *corestring_dom_onblur;
|
||||||
|
dom_string *corestring_dom_onerror;
|
||||||
|
dom_string *corestring_dom_onfocus;
|
||||||
|
dom_string *corestring_dom_onload;
|
||||||
|
dom_string *corestring_dom_onresize;
|
||||||
|
dom_string *corestring_dom_onscroll;
|
||||||
dom_string *corestring_dom___ns_key_box_node_data;
|
dom_string *corestring_dom___ns_key_box_node_data;
|
||||||
dom_string *corestring_dom___ns_key_libcss_node_data;
|
dom_string *corestring_dom___ns_key_libcss_node_data;
|
||||||
dom_string *corestring_dom___ns_key_file_name_node_data;
|
dom_string *corestring_dom___ns_key_file_name_node_data;
|
||||||
@ -544,7 +550,15 @@ void corestrings_fini(void)
|
|||||||
CSS_DOM_STRING_UNREF(radio);
|
CSS_DOM_STRING_UNREF(radio);
|
||||||
CSS_DOM_STRING_UNREF(checkbox);
|
CSS_DOM_STRING_UNREF(checkbox);
|
||||||
CSS_DOM_STRING_UNREF(file);
|
CSS_DOM_STRING_UNREF(file);
|
||||||
|
/* DOM event prefix */
|
||||||
CSS_DOM_STRING_UNREF(on);
|
CSS_DOM_STRING_UNREF(on);
|
||||||
|
/* DOM events forwarded from body to window */
|
||||||
|
CSS_DOM_STRING_UNREF(onblur);
|
||||||
|
CSS_DOM_STRING_UNREF(onerror);
|
||||||
|
CSS_DOM_STRING_UNREF(onfocus);
|
||||||
|
CSS_DOM_STRING_UNREF(onload);
|
||||||
|
CSS_DOM_STRING_UNREF(onresize);
|
||||||
|
CSS_DOM_STRING_UNREF(onscroll);
|
||||||
/* DOM userdata keys, not really CSS */
|
/* DOM userdata keys, not really CSS */
|
||||||
CSS_DOM_STRING_UNREF(__ns_key_box_node_data);
|
CSS_DOM_STRING_UNREF(__ns_key_box_node_data);
|
||||||
CSS_DOM_STRING_UNREF(__ns_key_libcss_node_data);
|
CSS_DOM_STRING_UNREF(__ns_key_libcss_node_data);
|
||||||
@ -863,7 +877,15 @@ nserror corestrings_init(void)
|
|||||||
CSS_DOM_STRING_INTERN(radio);
|
CSS_DOM_STRING_INTERN(radio);
|
||||||
CSS_DOM_STRING_INTERN(checkbox);
|
CSS_DOM_STRING_INTERN(checkbox);
|
||||||
CSS_DOM_STRING_INTERN(file);
|
CSS_DOM_STRING_INTERN(file);
|
||||||
|
/* DOM event prefix */
|
||||||
CSS_DOM_STRING_INTERN(on);
|
CSS_DOM_STRING_INTERN(on);
|
||||||
|
/* DOM events forwarded from body to window */
|
||||||
|
CSS_DOM_STRING_INTERN(onblur);
|
||||||
|
CSS_DOM_STRING_INTERN(onerror);
|
||||||
|
CSS_DOM_STRING_INTERN(onfocus);
|
||||||
|
CSS_DOM_STRING_INTERN(onload);
|
||||||
|
CSS_DOM_STRING_INTERN(onresize);
|
||||||
|
CSS_DOM_STRING_INTERN(onscroll);
|
||||||
/* DOM userdata keys, not really CSS */
|
/* DOM userdata keys, not really CSS */
|
||||||
CSS_DOM_STRING_INTERN(__ns_key_box_node_data);
|
CSS_DOM_STRING_INTERN(__ns_key_box_node_data);
|
||||||
CSS_DOM_STRING_INTERN(__ns_key_libcss_node_data);
|
CSS_DOM_STRING_INTERN(__ns_key_libcss_node_data);
|
||||||
|
@ -284,7 +284,16 @@ extern struct dom_string *corestring_dom_image;
|
|||||||
extern struct dom_string *corestring_dom_radio;
|
extern struct dom_string *corestring_dom_radio;
|
||||||
extern struct dom_string *corestring_dom_checkbox;
|
extern struct dom_string *corestring_dom_checkbox;
|
||||||
extern struct dom_string *corestring_dom_file;
|
extern struct dom_string *corestring_dom_file;
|
||||||
|
/* Event prefix */
|
||||||
extern struct dom_string *corestring_dom_on;
|
extern struct dom_string *corestring_dom_on;
|
||||||
|
/* These are the event attributes which forward from body to window */
|
||||||
|
extern struct dom_string *corestring_dom_onblur;
|
||||||
|
extern struct dom_string *corestring_dom_onerror;
|
||||||
|
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;
|
||||||
|
|
||||||
/* DOM userdata keys */
|
/* DOM userdata keys */
|
||||||
extern struct dom_string *corestring_dom___ns_key_box_node_data;
|
extern struct dom_string *corestring_dom___ns_key_box_node_data;
|
||||||
extern struct dom_string *corestring_dom___ns_key_libcss_node_data;
|
extern struct dom_string *corestring_dom___ns_key_libcss_node_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user