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:
parent
03a046f967
commit
9f0be72618
|
@ -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)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
TRACE("%p.%s = %s\n", nselem, debugstr_w(event_info[i].attr_name), debugstr_w(attr_value));
|
nsres = nsIDOMHTMLElement_GetAttributes(nselem, &attr_map);
|
||||||
|
if(NS_FAILED(nsres))
|
||||||
|
return;
|
||||||
|
|
||||||
disp = script_parse_event(doc->window, attr_value);
|
nsres = nsIDOMMozNamedAttrMap_GetLength(attr_map, &length);
|
||||||
if(disp) {
|
assert(nsres == NS_OK);
|
||||||
hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
|
|
||||||
if(SUCCEEDED(hres)) {
|
nsAString_Init(&name_str, NULL);
|
||||||
set_event_handler_disp(&node->event_target, i, disp);
|
nsAString_Init(&value_str, NULL);
|
||||||
node_release(node);
|
|
||||||
}
|
for(i = 0; i < length; i++) {
|
||||||
IDispatch_Release(disp);
|
nsres = nsIDOMMozNamedAttrMap_Item(attr_map, i, &attr);
|
||||||
}
|
if(NS_FAILED(nsres))
|
||||||
nsAString_Finish(&attr_value_str);
|
continue;
|
||||||
|
|
||||||
|
nsres = nsIDOMAttr_GetName(attr, &name_str);
|
||||||
|
if(NS_FAILED(nsres)) {
|
||||||
|
nsIDOMAttr_Release(attr);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue