mshtml: Use return_nsstr helper in more functions.

This commit is contained in:
Jacek Caban 2012-04-13 12:20:25 +02:00 committed by Alexandre Julliard
parent 29fbc70267
commit 16a5a5c91b
9 changed files with 27 additions and 201 deletions

View File

@ -155,41 +155,21 @@ static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
{
HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
nsAString nsstr;
const PRUnichar *strdata;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
if(This->nsframe) {
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 {
if(!This->nsframe && !This->nsiframe) {
ERR("No attached ns frame object\n");
return E_UNEXPECTED;
}
if(NS_FAILED(nsres)) {
ERR("GetName failed: 0x%08x\n", nsres);
nsAString_Finish(&nsstr);
return E_FAIL;
}
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;
nsAString_Init(&nsstr, NULL);
if(This->nsframe)
nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
else
nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
return return_nsstr(nsres, &nsstr, p);
}
static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)

View File

@ -251,17 +251,7 @@ static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
nsAString_Init(&alt_str, NULL);
nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &alt_str, p);
}
static HRESULT WINAPI HTMLImgElement_put_src(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)
{
HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
nsAString strName;
nsAString name;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&strName, NULL);
nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName);
if(NS_SUCCEEDED(nsres)) {
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;
nsAString_Init(&name, NULL);
nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &name);
return return_nsstr(nsres, &name, p);
}
static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)

View File

@ -136,25 +136,13 @@ static HRESULT WINAPI HTMLInputElement_get_type(IHTMLInputElement *iface, BSTR *
{
HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
nsAString type_str;
const PRUnichar *type;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&type_str, NULL);
nsres = nsIDOMHTMLInputElement_GetType(This->nsinput, &type_str);
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;
return return_nsstr(nsres, &type_str, p);
}
static HRESULT WINAPI HTMLInputElement_put_value(IHTMLInputElement *iface, BSTR v)
@ -210,25 +198,13 @@ static HRESULT WINAPI HTMLInputElement_get_name(IHTMLInputElement *iface, BSTR *
{
HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
nsAString name_str;
const PRUnichar *name;
nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL);
nsres = nsIDOMHTMLInputElement_GetName(This->nsinput, &name_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &name_str, p);
}
static HRESULT WINAPI HTMLInputElement_put_status(IHTMLInputElement *iface, VARIANT_BOOL v)

View File

@ -697,30 +697,14 @@ static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode
static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
{
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
nsAString name;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
*p = NULL;
if(This->nsnode) {
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;
nsAString_Init(&name, NULL);
nsres = nsIDOMNode_GetNodeName(This->nsnode, &name);
return return_nsstr(nsres, &name, p);
}
static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)

View File

@ -153,23 +153,13 @@ static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BST
{
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
nsAString value_str;
const PRUnichar *value;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str);
if(NS_SUCCEEDED(nsres)) {
nsAString_GetData(&value_str, &value);
*p = SysAllocString(value);
}else {
ERR("GetValue failed: %08x\n", nsres);
*p = NULL;
}
nsAString_Finish(&value_str);
return S_OK;
return return_nsstr(nsres, &value_str, p);
}
static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
@ -253,23 +243,13 @@ static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR
{
HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
nsAString text_str;
const PRUnichar *text;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&text_str, NULL);
nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str);
if(NS_SUCCEEDED(nsres)) {
nsAString_GetData(&text_str, &text);
*p = SysAllocString(text);
}else {
ERR("GetText failed: %08x\n", nsres);
*p = NULL;
}
nsAString_Finish(&text_str);
return S_OK;
return return_nsstr(nsres, &text_str, p);
}
static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)

View File

@ -240,7 +240,6 @@ static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR
static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
{
HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
const PRUnichar *nstype;
nsAString nstype_str;
nsresult nsres;
@ -248,14 +247,7 @@ static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR
nsAString_Init(&nstype_str, NULL);
nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
if(NS_FAILED(nsres))
ERR("GetType failed: %08x\n", nsres);
nsAString_GetData(&nstype_str, &nstype);
*p = *nstype ? SysAllocString(nstype) : NULL;
nsAString_Finish(&nstype_str);
return S_OK;
return return_nsstr(nsres, &nstype_str, p);
}
static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {

View File

@ -266,26 +266,14 @@ static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *if
static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
{
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
const PRUnichar *type;
nsAString type_str;
nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&type_str, NULL);
nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &type_str, p);
}
static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
@ -309,25 +297,13 @@ static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BST
{
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
nsAString value_str;
const PRUnichar *value = NULL;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &value_str, p);
}
static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)

View File

@ -135,25 +135,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface,
{
HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
nsAString value_str;
const PRUnichar *value;
nsresult nsres;
HRESULT hres = S_OK;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&value_str, NULL);
nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &value_str, p);
}
static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
@ -167,25 +155,13 @@ static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface,
{
HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
nsAString name_str;
const PRUnichar *name;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL);
nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &name_str, p);
}
static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)

View File

@ -750,30 +750,12 @@ static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
HTMLWindow *This = impl_from_IHTMLWindow2(iface);
nsAString name_str;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&name_str, NULL);
nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
if(NS_SUCCEEDED(nsres)) {
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;
return return_nsstr(nsres, &name_str, p);
}
static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)