mshtml: Added new helper for getting element attribute value and use it in script.c.

This commit is contained in:
Jacek Caban 2014-05-27 11:28:56 +02:00 committed by Alexandre Julliard
parent 4745fd03d4
commit 39e24713e9
3 changed files with 26 additions and 13 deletions

View File

@ -156,6 +156,25 @@ HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, cons
return hres;
}
nsresult get_elem_attr_value(nsIDOMHTMLElement *nselem, const WCHAR *name, nsAString *val_str, const PRUnichar **val)
{
nsAString name_str;
nsresult nsres;
nsAString_InitDepend(&name_str, name);
nsAString_Init(val_str, NULL);
nsres = nsIDOMHTMLElement_GetAttribute(nselem, &name_str, val_str);
nsAString_Finish(&name_str);
if(NS_FAILED(nsres)) {
ERR("GetAttribute(%s) failed: %08x\n", debugstr_w(name), nsres);
nsAString_Finish(val_str);
return nsres;
}
nsAString_GetData(val_str, val);
return NS_OK;
}
typedef struct
{
DispatchEx dispex;

View File

@ -959,6 +959,8 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL) DECLSPEC_HIDDEN
IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
nsresult get_elem_attr_value(nsIDOMHTMLElement*,const WCHAR*,nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
/* commands */
typedef struct {
DWORD id;

View File

@ -784,7 +784,7 @@ static void parse_script_elem(ScriptHost *script_host, HTMLScriptElement *script
return;
}
}else {
ERR("GetAttribute(event) failed: %08x\n", nsres);
ERR("GetEvent failed: %08x\n", nsres);
}
nsAString_Finish(&event_str);
@ -849,7 +849,8 @@ static BOOL get_guid_from_language(LPCWSTR type, GUID *guid)
static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *nsscript, GUID *guid)
{
nsAString attr_str, val_str;
const PRUnichar *language;
nsAString val_str;
BOOL ret = FALSE;
nsresult nsres;
@ -871,26 +872,17 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns
ERR("GetType failed: %08x\n", nsres);
}
nsAString_InitDepend(&attr_str, languageW);
nsres = nsIDOMHTMLScriptElement_GetAttribute(nsscript, &attr_str, &val_str);
nsAString_Finish(&attr_str);
nsres = get_elem_attr_value((nsIDOMHTMLElement*)nsscript, languageW, &val_str, &language);
if(NS_SUCCEEDED(nsres)) {
const PRUnichar *language;
nsAString_GetData(&val_str, &language);
if(*language) {
ret = get_guid_from_language(language, guid);
}else {
*guid = get_default_script_guid(window);
ret = TRUE;
}
}else {
ERR("GetAttribute(language) failed: %08x\n", nsres);
nsAString_Finish(&val_str);
}
nsAString_Finish(&val_str);
return ret;
}