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 ...@@ -156,6 +156,25 @@ HRESULT replace_node_by_html(nsIDOMHTMLDocument *nsdoc, nsIDOMNode *nsnode, cons
return hres; 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 typedef struct
{ {
DispatchEx dispex; DispatchEx dispex;
......
...@@ -959,6 +959,8 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL) DECLSPEC_HIDDEN ...@@ -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_nodelist(HTMLDocumentNode*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) 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 */ /* commands */
typedef struct { typedef struct {
DWORD id; DWORD id;
......
...@@ -784,7 +784,7 @@ static void parse_script_elem(ScriptHost *script_host, HTMLScriptElement *script ...@@ -784,7 +784,7 @@ static void parse_script_elem(ScriptHost *script_host, HTMLScriptElement *script
return; return;
} }
}else { }else {
ERR("GetAttribute(event) failed: %08x\n", nsres); ERR("GetEvent failed: %08x\n", nsres);
} }
nsAString_Finish(&event_str); nsAString_Finish(&event_str);
...@@ -849,7 +849,8 @@ static BOOL get_guid_from_language(LPCWSTR type, GUID *guid) ...@@ -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) 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; BOOL ret = FALSE;
nsresult nsres; nsresult nsres;
...@@ -871,26 +872,17 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns ...@@ -871,26 +872,17 @@ static BOOL get_script_guid(HTMLInnerWindow *window, nsIDOMHTMLScriptElement *ns
ERR("GetType failed: %08x\n", nsres); ERR("GetType failed: %08x\n", nsres);
} }
nsAString_InitDepend(&attr_str, languageW); nsres = get_elem_attr_value((nsIDOMHTMLElement*)nsscript, languageW, &val_str, &language);
nsres = nsIDOMHTMLScriptElement_GetAttribute(nsscript, &attr_str, &val_str);
nsAString_Finish(&attr_str);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
const PRUnichar *language;
nsAString_GetData(&val_str, &language);
if(*language) { if(*language) {
ret = get_guid_from_language(language, guid); ret = get_guid_from_language(language, guid);
}else { }else {
*guid = get_default_script_guid(window); *guid = get_default_script_guid(window);
ret = TRUE; ret = TRUE;
} }
}else { nsAString_Finish(&val_str);
ERR("GetAttribute(language) failed: %08x\n", nsres);
} }
nsAString_Finish(&val_str);
return ret; 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