From: Jactry Zeng Subject: [PATCH] mshtml: Add IHTMLTableCell::bgColor property implementation. Message-Id: <54009985.9050808@jactry.com> Date: Fri, 29 Aug 2014 23:17:25 +0800 --- dlls/mshtml/htmltablecell.c | 40 ++++++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmltablecell.c b/dlls/mshtml/htmltablecell.c index eedae5b..6f65102 100644 --- a/dlls/mshtml/htmltablecell.c +++ b/dlls/mshtml/htmltablecell.c @@ -174,15 +174,47 @@ static HRESULT WINAPI HTMLTableCell_get_vAlign(IHTMLTableCell *iface, BSTR *p) static HRESULT WINAPI HTMLTableCell_put_bgColor(IHTMLTableCell *iface, VARIANT v) { HTMLTableCell *This = impl_from_IHTMLTableCell(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + nsAString strColor; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + nsAString_InitDepend(&strColor, V_BSTR(&v)); + variant_to_nscolor(&v, &strColor); + nsres = nsIDOMHTMLTableCellElement_SetBgColor(This->nscell, &strColor); + nsAString_Finish(&strColor); + + if(NS_FAILED(nsres)) { + ERR("SetBgColor(%s) failed: %08x\n", debugstr_variant(&v), nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLTableCell_get_bgColor(IHTMLTableCell *iface, VARIANT *p) { HTMLTableCell *This = impl_from_IHTMLTableCell(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString strColor; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&strColor, NULL); + nsres = nsIDOMHTMLTableCellElement_GetBgColor(This->nscell, &strColor); + + if(NS_SUCCEEDED(nsres)) { + const PRUnichar *color; + nsAString_GetData(&strColor, &color); + V_VT(p) = VT_BSTR; + hres = nscolor_to_str(color, &V_BSTR(p)); + }else { + ERR("GetBgColor failed: %08x\n", nsres); + hres = E_FAIL; + } + nsAString_Finish(&strColor); + return hres; } static HRESULT WINAPI HTMLTableCell_put_noWrap(IHTMLTableCell *iface, VARIANT_BOOL v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 160a81e..c4440b4 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -6113,6 +6113,7 @@ static void test_td_elem(IHTMLElement *elem) HRESULT hres; LONG lval; BSTR str; + VARIANT vbg, vDefaultbg; hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableCell, (void**)&cell); ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres); @@ -6138,6 +6139,40 @@ static void test_td_elem(IHTMLElement *elem) SysFreeString(str); } + hres = IHTMLTableCell_get_bgColor(cell, &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 = IHTMLTableCell_put_bgColor(cell, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTableCell_get_bgColor(cell, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != 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 = IHTMLTableCell_put_bgColor(cell, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLTableCell_get_bgColor(cell, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != 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 = IHTMLTableCell_put_bgColor(cell, vDefaultbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vDefaultbg); + IHTMLTableCell_Release(cell); }