mshtml: Use return_nsstr_variant in IHTMLBodyElement::get_bgColor.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Jacek Caban 2020-06-05 18:27:01 +02:00 committed by Alexandre Julliard
parent 2e767e81cc
commit 7f465761c2
3 changed files with 18 additions and 26 deletions

View File

@ -407,27 +407,14 @@ static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIA
static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p) static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
{ {
HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface); HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
nsAString strColor; nsAString nsstr;
nsresult nsres; nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&strColor, NULL); nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor); nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &nsstr);
if(NS_SUCCEEDED(nsres)) { return return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p);
const PRUnichar *color;
nsAString_GetData(&strColor, &color);
V_VT(p) = VT_BSTR;
hres = nscolor_to_str(color, &V_BSTR(p));
}else {
ERR("SetBgColor failed: %08x\n", nsres);
hres = E_FAIL;
}
nsAString_Finish(&strColor);
return hres;
} }
static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v) static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)

View File

@ -982,6 +982,7 @@ UINT32 nsAString_GetData(const nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN; void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN;
#define NSSTR_IMPLICIT_PX 0x01 #define NSSTR_IMPLICIT_PX 0x01
#define NSSTR_COLOR 0x02
HRESULT map_nsresult(nsresult) DECLSPEC_HIDDEN; HRESULT map_nsresult(nsresult) DECLSPEC_HIDDEN;
HRESULT return_nsstr(nsresult,nsAString*,BSTR*) DECLSPEC_HIDDEN; HRESULT return_nsstr(nsresult,nsAString*,BSTR*) DECLSPEC_HIDDEN;

View File

@ -964,14 +964,15 @@ HRESULT return_nsstr(nsresult nsres, nsAString *nsstr, BSTR *p)
HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, unsigned flags, VARIANT *p) HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, unsigned flags, VARIANT *p)
{ {
HRESULT hres = S_OK;
if(NS_FAILED(nsres)) { if(NS_FAILED(nsres)) {
ERR("failed: %08x\n", nsres); ERR("failed: %08x\n", nsres);
nsAString_Finish(nsstr); nsAString_Finish(nsstr);
return E_FAIL; return map_nsresult(nsres);
} }
if(NS_StringGetIsVoid(nsstr)) { if(NS_StringGetIsVoid(nsstr)) {
TRACE("ret null\n");
V_VT(p) = VT_NULL; V_VT(p) = VT_NULL;
}else { }else {
const WCHAR *str; const WCHAR *str;
@ -989,20 +990,23 @@ HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, unsigned flags, V
if(iter == str + len && dot) len = dot - str; if(iter == str + len && dot) len = dot - str;
} }
} }
TRACE("ret %s\n", debugstr_wn(str, len)); if(flags & NSSTR_COLOR) {
if(*str) { hres = nscolor_to_str(str, &V_BSTR(p));
}else if(*str) {
V_BSTR(p) = SysAllocStringLen(str, len); V_BSTR(p) = SysAllocStringLen(str, len);
if(!V_BSTR(p)) { if(!V_BSTR(p))
nsAString_Finish(nsstr); hres = E_OUTOFMEMORY;
return E_OUTOFMEMORY;
}
}else { }else {
V_BSTR(p) = NULL; V_BSTR(p) = NULL;
} }
V_VT(p) = VT_BSTR; if(SUCCEEDED(hres))
V_VT(p) = VT_BSTR;
} }
nsAString_Finish(nsstr); nsAString_Finish(nsstr);
if(FAILED(hres))
return hres;
TRACE("ret %s\n", debugstr_variant(p));
return S_OK; return S_OK;
} }