mshtml: Use return_nsstr helper in HTMLElement object implementation.
This commit is contained in:
parent
b43cd188df
commit
29fbc70267
|
@ -352,7 +352,6 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
|
||||||
HTMLElement *This = impl_from_IHTMLElement(iface);
|
HTMLElement *This = impl_from_IHTMLElement(iface);
|
||||||
nsAString class_str;
|
nsAString class_str;
|
||||||
nsresult nsres;
|
nsresult nsres;
|
||||||
HRESULT hres = S_OK;
|
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, p);
|
TRACE("(%p)->(%p)\n", This, p);
|
||||||
|
|
||||||
|
@ -363,20 +362,7 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
|
||||||
|
|
||||||
nsAString_Init(&class_str, NULL);
|
nsAString_Init(&class_str, NULL);
|
||||||
nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
|
nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
|
||||||
|
return return_nsstr(nsres, &class_str, p);
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
|
||||||
const PRUnichar *class;
|
|
||||||
nsAString_GetData(&class_str, &class);
|
|
||||||
*p = *class ? SysAllocString(class) : NULL;
|
|
||||||
}else {
|
|
||||||
ERR("GetClassName failed: %08x\n", nsres);
|
|
||||||
hres = E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAString_Finish(&class_str);
|
|
||||||
|
|
||||||
TRACE("className=%s\n", debugstr_w(*p));
|
|
||||||
return hres;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
|
static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
|
||||||
|
@ -404,34 +390,24 @@ static HRESULT WINAPI HTMLElement_put_id(IHTMLElement *iface, BSTR v)
|
||||||
static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
|
static HRESULT WINAPI HTMLElement_get_id(IHTMLElement *iface, BSTR *p)
|
||||||
{
|
{
|
||||||
HTMLElement *This = impl_from_IHTMLElement(iface);
|
HTMLElement *This = impl_from_IHTMLElement(iface);
|
||||||
const PRUnichar *id;
|
|
||||||
nsAString id_str;
|
nsAString id_str;
|
||||||
nsresult nsres;
|
nsresult nsres;
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, p);
|
TRACE("(%p)->(%p)\n", This, p);
|
||||||
|
|
||||||
*p = NULL;
|
if(!This->nselem) {
|
||||||
|
*p = NULL;
|
||||||
if(!This->nselem)
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsAString_Init(&id_str, NULL);
|
nsAString_Init(&id_str, NULL);
|
||||||
nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
|
nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
|
||||||
nsAString_GetData(&id_str, &id);
|
return return_nsstr(nsres, &id_str, p);
|
||||||
|
|
||||||
if(NS_FAILED(nsres))
|
|
||||||
ERR("GetId failed: %08x\n", nsres);
|
|
||||||
else if(*id)
|
|
||||||
*p = SysAllocString(id);
|
|
||||||
|
|
||||||
nsAString_Finish(&id_str);
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
|
static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
|
||||||
{
|
{
|
||||||
HTMLElement *This = impl_from_IHTMLElement(iface);
|
HTMLElement *This = impl_from_IHTMLElement(iface);
|
||||||
const PRUnichar *tag;
|
|
||||||
nsAString tag_str;
|
nsAString tag_str;
|
||||||
nsresult nsres;
|
nsresult nsres;
|
||||||
|
|
||||||
|
@ -443,21 +419,12 @@ static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
|
||||||
WARN("NULL nselem, assuming comment\n");
|
WARN("NULL nselem, assuming comment\n");
|
||||||
|
|
||||||
*p = SysAllocString(comment_tagW);
|
*p = SysAllocString(comment_tagW);
|
||||||
return S_OK;
|
return *p ? S_OK : E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsAString_Init(&tag_str, NULL);
|
nsAString_Init(&tag_str, NULL);
|
||||||
nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
|
nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
return return_nsstr(nsres, &tag_str, p);
|
||||||
nsAString_GetData(&tag_str, &tag);
|
|
||||||
*p = SysAllocString(tag);
|
|
||||||
}else {
|
|
||||||
ERR("GetTagName failed: %08x\n", nsres);
|
|
||||||
*p = NULL;
|
|
||||||
}
|
|
||||||
nsAString_Finish(&tag_str);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
|
static HRESULT WINAPI HTMLElement_get_parentElement(IHTMLElement *iface, IHTMLElement **p)
|
||||||
|
@ -787,17 +754,7 @@ static HRESULT WINAPI HTMLElement_get_title(IHTMLElement *iface, BSTR *p)
|
||||||
|
|
||||||
nsAString_Init(&title_str, NULL);
|
nsAString_Init(&title_str, NULL);
|
||||||
nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
|
nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
return return_nsstr(nsres, &title_str, p);
|
||||||
const PRUnichar *title;
|
|
||||||
|
|
||||||
nsAString_GetData(&title_str, &title);
|
|
||||||
*p = *title ? SysAllocString(title) : NULL;
|
|
||||||
}else {
|
|
||||||
ERR("GetTitle failed: %08x\n", nsres);
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
|
static HRESULT WINAPI HTMLElement_put_language(IHTMLElement *iface, BSTR v)
|
||||||
|
@ -1018,18 +975,7 @@ static HRESULT WINAPI HTMLElement_get_innerHTML(IHTMLElement *iface, BSTR *p)
|
||||||
|
|
||||||
nsAString_Init(&html_str, NULL);
|
nsAString_Init(&html_str, NULL);
|
||||||
nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
|
nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
return return_nsstr(nsres, &html_str, p);
|
||||||
const PRUnichar *html;
|
|
||||||
|
|
||||||
nsAString_GetData(&html_str, &html);
|
|
||||||
*p = *html ? SysAllocString(html) : NULL;
|
|
||||||
}else {
|
|
||||||
FIXME("SetInnerHtml failed %08x\n", nsres);
|
|
||||||
*p = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAString_Finish(&html_str);
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
|
static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
|
||||||
|
|
|
@ -978,32 +978,18 @@ static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
|
||||||
static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
|
static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
|
||||||
{
|
{
|
||||||
HTMLElement *This = impl_from_IHTMLElement2(iface);
|
HTMLElement *This = impl_from_IHTMLElement2(iface);
|
||||||
|
nsAString dir_str;
|
||||||
|
nsresult nsres;
|
||||||
|
|
||||||
TRACE("(%p)->(%p)\n", This, p);
|
TRACE("(%p)->(%p)\n", This, p);
|
||||||
|
|
||||||
*p = NULL;
|
if(!This->nselem) {
|
||||||
|
*p = NULL;
|
||||||
if(This->nselem) {
|
return S_OK;
|
||||||
nsAString dir_str;
|
|
||||||
nsresult nsres;
|
|
||||||
|
|
||||||
nsAString_Init(&dir_str, NULL);
|
|
||||||
|
|
||||||
nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
|
|
||||||
if(NS_SUCCEEDED(nsres)) {
|
|
||||||
const PRUnichar *dir;
|
|
||||||
nsAString_GetData(&dir_str, &dir);
|
|
||||||
if(*dir)
|
|
||||||
*p = SysAllocString(dir);
|
|
||||||
}else {
|
|
||||||
ERR("GetDir failed: %08x\n", nsres);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsAString_Finish(&dir_str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("ret %s\n", debugstr_w(*p));
|
nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
|
||||||
return S_OK;
|
return return_nsstr(nsres, &dir_str, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
|
static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
|
||||||
|
|
Loading…
Reference in New Issue