Jactry Zeng : mshtml: Add IHTMLTableCell::bgColor property implementation.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Sep 9 14:09:52 CDT 2014
Module: wine
Branch: master
Commit: 0cab370d1154ff600784363ea659daedcd45aaf7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=0cab370d1154ff600784363ea659daedcd45aaf7
Author: Jactry Zeng <wine at jactry.com>
Date: Fri Aug 29 23:40:05 2014 +0800
mshtml: Add IHTMLTableCell::bgColor property implementation.
---
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..4bcde18 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));
+
+ if(!variant_to_nscolor(&v, &strColor))
+ return S_OK;
+
+ 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 f946550..17f39ce 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);
}
More information about the wine-cvs
mailing list