Jacek Caban : mshtml: Use return_nsstr helper in HTMLElement object implementation.
Alexandre Julliard
julliard at winehq.org
Fri Apr 13 11:03:21 CDT 2012
Module: wine
Branch: master
Commit: 29fbc70267059289d5d81823dd461c207ab27d81
URL: http://source.winehq.org/git/wine.git/?a=commit;h=29fbc70267059289d5d81823dd461c207ab27d81
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Apr 13 12:02:31 2012 +0200
mshtml: Use return_nsstr helper in HTMLElement object implementation.
---
dlls/mshtml/htmlelem.c | 72 ++++++-----------------------------------------
dlls/mshtml/htmlelem2.c | 28 ++++-------------
2 files changed, 16 insertions(+), 84 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 1baf9e2..02a49d2 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -352,7 +352,6 @@ static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p)
HTMLElement *This = impl_from_IHTMLElement(iface);
nsAString class_str;
nsresult nsres;
- HRESULT hres = S_OK;
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);
nsres = nsIDOMHTMLElement_GetClassName(This->nselem, &class_str);
-
- 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;
+ return return_nsstr(nsres, &class_str, p);
}
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)
{
HTMLElement *This = impl_from_IHTMLElement(iface);
- const PRUnichar *id;
nsAString id_str;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
- *p = NULL;
-
- if(!This->nselem)
+ if(!This->nselem) {
+ *p = NULL;
return S_OK;
+ }
nsAString_Init(&id_str, NULL);
nsres = nsIDOMHTMLElement_GetId(This->nselem, &id_str);
- nsAString_GetData(&id_str, &id);
-
- if(NS_FAILED(nsres))
- ERR("GetId failed: %08x\n", nsres);
- else if(*id)
- *p = SysAllocString(id);
-
- nsAString_Finish(&id_str);
- return S_OK;
+ return return_nsstr(nsres, &id_str, p);
}
static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
{
HTMLElement *This = impl_from_IHTMLElement(iface);
- const PRUnichar *tag;
nsAString tag_str;
nsresult nsres;
@@ -443,21 +419,12 @@ static HRESULT WINAPI HTMLElement_get_tagName(IHTMLElement *iface, BSTR *p)
WARN("NULL nselem, assuming comment\n");
*p = SysAllocString(comment_tagW);
- return S_OK;
+ return *p ? S_OK : E_OUTOFMEMORY;
}
nsAString_Init(&tag_str, NULL);
nsres = nsIDOMHTMLElement_GetTagName(This->nselem, &tag_str);
- if(NS_SUCCEEDED(nsres)) {
- nsAString_GetData(&tag_str, &tag);
- *p = SysAllocString(tag);
- }else {
- ERR("GetTagName failed: %08x\n", nsres);
- *p = NULL;
- }
- nsAString_Finish(&tag_str);
-
- return S_OK;
+ return return_nsstr(nsres, &tag_str, 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);
nsres = nsIDOMHTMLElement_GetTitle(This->nselem, &title_str);
- if(NS_SUCCEEDED(nsres)) {
- 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;
+ return return_nsstr(nsres, &title_str, p);
}
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);
nsres = nsIDOMHTMLElement_GetInnerHTML(This->nselem, &html_str);
- if(NS_SUCCEEDED(nsres)) {
- 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;
+ return return_nsstr(nsres, &html_str, p);
}
static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c
index 2538b55..9362805 100644
--- a/dlls/mshtml/htmlelem2.c
+++ b/dlls/mshtml/htmlelem2.c
@@ -978,32 +978,18 @@ static HRESULT WINAPI HTMLElement2_put_dir(IHTMLElement2 *iface, BSTR v)
static HRESULT WINAPI HTMLElement2_get_dir(IHTMLElement2 *iface, BSTR *p)
{
HTMLElement *This = impl_from_IHTMLElement2(iface);
+ nsAString dir_str;
+ nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
- *p = NULL;
-
- if(This->nselem) {
- 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);
+ if(!This->nselem) {
+ *p = NULL;
+ return S_OK;
}
- TRACE("ret %s\n", debugstr_w(*p));
- return S_OK;
+ nsres = nsIDOMHTMLElement_GetDir(This->nselem, &dir_str);
+ return return_nsstr(nsres, &dir_str, p);
}
static HRESULT WINAPI HTMLElement2_createControlRange(IHTMLElement2 *iface, IDispatch **range)
More information about the wine-cvs
mailing list