From 22c2d81a2d334a8ec324fb9bdb71c8f08ce12158 Mon Sep 17 00:00:00 2001 From: Zhenbo Li Date: Sun, 6 Apr 2014 22:48:41 +0800 Subject: [PATCH] mshtml: Added IHTMLTable::bgColor property implementation. --- dlls/mshtml/htmltable.c | 41 +++++++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c index e3a12642475..d711ed77d9c 100644 --- a/dlls/mshtml/htmltable.c +++ b/dlls/mshtml/htmltable.c @@ -246,15 +246,48 @@ static HRESULT WINAPI HTMLTable_get_background(IHTMLTable *iface, BSTR *p) static HRESULT WINAPI HTMLTable_put_bgColor(IHTMLTable *iface, VARIANT v) { HTMLTable *This = impl_from_IHTMLTable(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + nsAString val; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + nsAString_InitDepend(&val, V_BSTR(&v)); + variant_to_nscolor(&v, &val); + nsres = nsIDOMHTMLTableElement_SetBgColor(This->nstable, &val); + nsAString_Finish(&val); + + if (NS_FAILED(nsres)){ + ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v)); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLTable_get_bgColor(IHTMLTable *iface, VARIANT *p) { HTMLTable *This = impl_from_IHTMLTable(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString strColor; + nsresult nsres; + HRESULT hres; + const PRUnichar *color; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&strColor, NULL); + nsres = nsIDOMHTMLTableElement_GetBgColor(This->nstable, &strColor); + + if(NS_SUCCEEDED(nsres)) { + 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 HTMLTable_put_borderColor(IHTMLTable *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 76c283aeec5..23677f42ccf 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5729,6 +5729,7 @@ static void test_table_elem(IHTMLElement *elem) VARIANT v; HRESULT hres; BSTR bstr; + VARIANT vbg, vDefaultbg; static const elem_type_t row_types[] = {ET_TR,ET_TR}; static const elem_type_t all_types[] = {ET_TBODY,ET_TR,ET_TR,ET_TD,ET_TD}; @@ -5794,6 +5795,40 @@ static void test_table_elem(IHTMLElement *elem) ok(!strcmp_wa(bstr, "left"), "get_align returned %s\n", wine_dbgstr_w(bstr)); SysFreeString(bstr); + hres = IHTMLTable_get_bgColor(table, &vDefaultbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n"); + ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg))); + + V_VT(&vbg) = VT_BSTR; + V_BSTR(&vbg) = a2bstr("red"); + hres = IHTMLTable_put_bgColor(table, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTable_get_bgColor(table, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + V_VT(&vbg) = VT_I4; + V_I4(&vbg) = 0xff0000; + hres = IHTMLTable_put_bgColor(table, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTable_get_bgColor(table, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vDefaultbg) == VT_BSTR, "V_VT(&vDefaultbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + /* Restore Originial */ + hres = IHTMLTable_put_bgColor(table, vDefaultbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vDefaultbg); + IHTMLTable_Release(table); }