mshtml: Reimplemented check_event_attr to iterate though declared attributes instead of all known events.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-02-17 13:16:56 +01:00 committed by Alexandre Julliard
parent 03a046f967
commit 9f0be72618
1 changed files with 68 additions and 20 deletions

View File

@ -1596,34 +1596,82 @@ void update_doc_cp_events(HTMLDocumentNode *doc, cp_static_data_t *cp)
void check_event_attr(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) void check_event_attr(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{ {
const PRUnichar *attr_value; nsIDOMMozNamedAttrMap *attr_map;
nsAString attr_value_str; const PRUnichar *name, *value;
nsAString name_str, value_str;
HTMLDOMNode *node = NULL;
cpp_bool has_attrs;
nsIDOMAttr *attr;
IDispatch *disp; IDispatch *disp;
HTMLDOMNode *node; UINT32 length, i;
int i; eventid_t eid;
nsresult nsres; nsresult nsres;
HRESULT hres; HRESULT hres;
for(i=0; i < EVENTID_LAST; i++) { nsres = nsIDOMHTMLElement_HasAttributes(nselem, &has_attrs);
nsres = get_elem_attr_value(nselem, event_info[i].attr_name, &attr_value_str, &attr_value); if(NS_FAILED(nsres) || !has_attrs)
if(NS_SUCCEEDED(nsres)) { return;
if(!*attr_value)
nsres = nsIDOMHTMLElement_GetAttributes(nselem, &attr_map);
if(NS_FAILED(nsres))
return;
nsres = nsIDOMMozNamedAttrMap_GetLength(attr_map, &length);
assert(nsres == NS_OK);
nsAString_Init(&name_str, NULL);
nsAString_Init(&value_str, NULL);
for(i = 0; i < length; i++) {
nsres = nsIDOMMozNamedAttrMap_Item(attr_map, i, &attr);
if(NS_FAILED(nsres))
continue; continue;
TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value)); nsres = nsIDOMAttr_GetName(attr, &name_str);
if(NS_FAILED(nsres)) {
disp = script_parse_event(doc->window, attr_value); nsIDOMAttr_Release(attr);
if(disp) { continue;
hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
if(SUCCEEDED(hres)) {
set_event_handler_disp(&node->event_target, i, disp);
node_release(node);
} }
nsAString_GetData(&name_str, &name);
eid = attr_to_eid(name);
if(eid == EVENTID_LAST) {
nsIDOMAttr_Release(attr);
continue;
}
nsres = nsIDOMAttr_GetValue(attr, &value_str);
nsIDOMAttr_Release(attr);
if(NS_FAILED(nsres))
continue;
nsAString_GetData(&value_str, &value);
if(!*value)
continue;
TRACE("%p.%s = %s\n", nselem, debugstr_w(name), debugstr_w(value));
disp = script_parse_event(doc->window, value);
if(!disp)
continue;
if(!node) {
hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
if(FAILED(hres)) {
IDispatch_Release(disp);
break;
}
}
set_event_handler_disp(&node->event_target, eid, disp);
IDispatch_Release(disp); IDispatch_Release(disp);
} }
nsAString_Finish(&attr_value_str);
} if(node)
} node_release(node);
nsAString_Finish(&name_str);
nsAString_Finish(&value_str);
nsIDOMMozNamedAttrMap_Release(attr_map);
} }
HRESULT doc_init_events(HTMLDocumentNode *doc) HRESULT doc_init_events(HTMLDocumentNode *doc)