Commit 39e24713 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent 4745fd03
......@@ -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;
......
......@@ -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;
......
......@@ -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,25 +872,16 @@ 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);
}
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment