Commit 16a5a5c9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Use return_nsstr helper in more functions.

parent 29fbc702
...@@ -155,41 +155,21 @@ static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p) ...@@ -155,41 +155,21 @@ static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
{ {
HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
nsAString nsstr; nsAString nsstr;
const PRUnichar *strdata;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
if(This->nsframe) { if(!This->nsframe && !This->nsiframe) {
nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
}else if(This->nsiframe) {
nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
}else {
ERR("No attached ns frame object\n"); ERR("No attached ns frame object\n");
return E_UNEXPECTED; return E_UNEXPECTED;
} }
if(NS_FAILED(nsres)) { nsAString_Init(&nsstr, NULL);
ERR("GetName failed: 0x%08x\n", nsres); if(This->nsframe)
nsAString_Finish(&nsstr); nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
return E_FAIL; else
} nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
return return_nsstr(nsres, &nsstr, p);
nsAString_GetData(&nsstr, &strdata);
if(*strdata) {
*p = SysAllocString(strdata);
if(!*p) {
nsAString_Finish(&nsstr);
return E_OUTOFMEMORY;
}
}else
*p = NULL;
nsAString_Finish(&nsstr);
return S_OK;
} }
static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v) static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
......
...@@ -251,17 +251,7 @@ static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p) ...@@ -251,17 +251,7 @@ static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
nsAString_Init(&alt_str, NULL); nsAString_Init(&alt_str, NULL);
nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str); nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &alt_str, p);
const PRUnichar *alt;
nsAString_GetData(&alt_str, &alt);
*p = *alt ? SysAllocString(alt) : NULL;
}else {
ERR("GetAlt failed: %08x\n", nsres);
}
nsAString_Finish(&alt_str);
return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
} }
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
...@@ -459,24 +449,14 @@ static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v) ...@@ -459,24 +449,14 @@ static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p) static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
{ {
HTMLImgElement *This = impl_from_IHTMLImgElement(iface); HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
nsAString strName; nsAString name;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&strName, NULL); nsAString_Init(&name, NULL);
nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName); nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &name);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &name, p);
const PRUnichar *str;
nsAString_GetData(&strName, &str);
*p = *str ? SysAllocString(str) : NULL;
}else {
ERR("GetName failed: %08x\n", nsres);
}
nsAString_Finish(&strName);
return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
} }
static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v) static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
......
...@@ -136,25 +136,13 @@ static HRESULT WINAPI HTMLInputElement_get_type(IHTMLInputElement *iface, BSTR * ...@@ -136,25 +136,13 @@ static HRESULT WINAPI HTMLInputElement_get_type(IHTMLInputElement *iface, BSTR *
{ {
HTMLInputElement *This = impl_from_IHTMLInputElement(iface); HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
nsAString type_str; nsAString type_str;
const PRUnichar *type;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&type_str, NULL); nsAString_Init(&type_str, NULL);
nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &type_str); nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &type_str);
return return_nsstr(nsres, &type_str, p);
if(NS_SUCCEEDED(nsres)) {
nsAString_GetData(&type_str, &type);
*p = SysAllocString(type);
}else {
ERR("GetType failed: %08x\n", nsres);
}
nsAString_Finish(&type_str);
TRACE("type=%s\n", debugstr_w(*p));
return S_OK;
} }
static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v) static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v)
...@@ -210,25 +198,13 @@ static HRESULT WINAPI HTMLInputElement_get_name(IHTMLInputElement *iface, BSTR * ...@@ -210,25 +198,13 @@ static HRESULT WINAPI HTMLInputElement_get_name(IHTMLInputElement *iface, BSTR *
{ {
HTMLInputElement *This = impl_from_IHTMLInputElement(iface); HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
nsAString name_str; nsAString name_str;
const PRUnichar *name;
nsresult nsres; nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL); nsAString_Init(&name_str, NULL);
nsres = nsIDOMHTMLInputElement_GetName(This->nsinput, &name_str); nsres = nsIDOMHTMLInputElement_GetName(This->nsinput, &name_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &name_str, p);
nsAString_GetData(&name_str, &name);
*p = *name ? SysAllocString(name) : NULL;
}else {
ERR("GetName failed: %08x\n", nsres);
hres = E_FAIL;
}
nsAString_Finish(&name_str);
return hres;
} }
static HRESULT WINAPI HTMLInputElement_put_status(IHTMLInputElement *iface, VARIANT_BOOL v) static HRESULT WINAPI HTMLInputElement_put_status(IHTMLInputElement *iface, VARIANT_BOOL v)
......
...@@ -697,30 +697,14 @@ static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode ...@@ -697,30 +697,14 @@ static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode
static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p) static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
{ {
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface); HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
nsAString name;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
*p = NULL; nsAString_Init(&name, NULL);
nsres = nsIDOMNode_GetNodeName(This->nsnode, &name);
if(This->nsnode) { return return_nsstr(nsres, &name, p);
nsAString name_str;
const PRUnichar *name;
nsresult nsres;
nsAString_Init(&name_str, NULL);
nsres = nsIDOMNode_GetNodeName(This->nsnode, &name_str);
if(NS_SUCCEEDED(nsres)) {
nsAString_GetData(&name_str, &name);
*p = SysAllocString(name);
}else {
ERR("GetNodeName failed: %08x\n", nsres);
}
nsAString_Finish(&name_str);
}
return S_OK;
} }
static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v) static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
......
...@@ -153,23 +153,13 @@ static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BST ...@@ -153,23 +153,13 @@ static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BST
{ {
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface); HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
nsAString value_str; nsAString value_str;
const PRUnichar *value;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL); nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str); nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &value_str, p);
nsAString_GetData(&value_str, &value);
*p = SysAllocString(value);
}else {
ERR("GetValue failed: %08x\n", nsres);
*p = NULL;
}
nsAString_Finish(&value_str);
return S_OK;
} }
static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v) static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
...@@ -253,23 +243,13 @@ static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR ...@@ -253,23 +243,13 @@ static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR
{ {
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface); HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
nsAString text_str; nsAString text_str;
const PRUnichar *text;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&text_str, NULL); nsAString_Init(&text_str, NULL);
nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str); nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &text_str, p);
nsAString_GetData(&text_str, &text);
*p = SysAllocString(text);
}else {
ERR("GetText failed: %08x\n", nsres);
*p = NULL;
}
nsAString_Finish(&text_str);
return S_OK;
} }
static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p) static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)
......
...@@ -240,7 +240,6 @@ static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR ...@@ -240,7 +240,6 @@ static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR
static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
{ {
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface); HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
const PRUnichar *nstype;
nsAString nstype_str; nsAString nstype_str;
nsresult nsres; nsresult nsres;
...@@ -248,14 +247,7 @@ static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR ...@@ -248,14 +247,7 @@ static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR
nsAString_Init(&nstype_str, NULL); nsAString_Init(&nstype_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str); nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
if(NS_FAILED(nsres)) return return_nsstr(nsres, &nstype_str, p);
ERR("GetType failed: %08x\n", nsres);
nsAString_GetData(&nstype_str, &nstype);
*p = *nstype ? SysAllocString(nstype) : NULL;
nsAString_Finish(&nstype_str);
return S_OK;
} }
static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = { static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
......
...@@ -266,26 +266,14 @@ static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *if ...@@ -266,26 +266,14 @@ static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *if
static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p) static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
{ {
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface); HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
const PRUnichar *type;
nsAString type_str; nsAString type_str;
nsresult nsres; nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&type_str, NULL); nsAString_Init(&type_str, NULL);
nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str); nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &type_str, p);
nsAString_GetData(&type_str, &type);
*p = *type ? SysAllocString(type) : NULL;
}else {
ERR("GetType failed: %08x\n", nsres);
hres = E_FAIL;
}
nsAString_Finish(&type_str);
return hres;
} }
static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v) static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
...@@ -309,25 +297,13 @@ static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BST ...@@ -309,25 +297,13 @@ static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BST
{ {
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface); HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
nsAString value_str; nsAString value_str;
const PRUnichar *value = NULL;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL); nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str); nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &value_str, p);
nsAString_GetData(&value_str, &value);
*p = *value ? SysAllocString(value) : NULL;
}else {
ERR("GetValue failed: %08x\n", nsres);
}
nsAString_Finish(&value_str);
TRACE("value=%s\n", debugstr_w(*p));
return S_OK;
} }
static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v) static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
......
...@@ -135,25 +135,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, ...@@ -135,25 +135,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface,
{ {
HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface); HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
nsAString value_str; nsAString value_str;
const PRUnichar *value;
nsresult nsres; nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL); nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str); nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &value_str, p);
nsAString_GetData(&value_str, &value);
*p = *value ? SysAllocString(value) : NULL;
}else {
ERR("GetValue failed: %08x\n", nsres);
hres = E_FAIL;
}
nsAString_Finish(&value_str);
return hres;
} }
static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v) static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
...@@ -167,25 +155,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, ...@@ -167,25 +155,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface,
{ {
HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface); HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
nsAString name_str; nsAString name_str;
const PRUnichar *name;
nsresult nsres; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL); nsAString_Init(&name_str, NULL);
nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str); nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &name_str, p);
nsAString_GetData(&name_str, &name);
*p = SysAllocString(name);
}else {
ERR("GetName failed: %08x\n", nsres);
}
nsAString_Finish(&name_str);
TRACE("%s\n", debugstr_w(*p));
return S_OK;
} }
static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v) static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
......
...@@ -750,30 +750,12 @@ static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p) ...@@ -750,30 +750,12 @@ static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
HTMLWindow *This = impl_from_IHTMLWindow2(iface); HTMLWindow *This = impl_from_IHTMLWindow2(iface);
nsAString name_str; nsAString name_str;
nsresult nsres; nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL); nsAString_Init(&name_str, NULL);
nsres = nsIDOMWindow_GetName(This->nswindow, &name_str); nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
if(NS_SUCCEEDED(nsres)) { return return_nsstr(nsres, &name_str, p);
const PRUnichar *name;
nsAString_GetData(&name_str, &name);
if(*name) {
*p = SysAllocString(name);
hres = *p ? S_OK : E_OUTOFMEMORY;
}else {
*p = NULL;
hres = S_OK;
}
}else {
ERR("GetName failed: %08x\n", nsres);
hres = E_FAIL;
}
nsAString_Finish(&name_str);
return hres;
} }
static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p) static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
......
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