Jacek Caban : mshtml: Use proper helpers in IHTMLStyle:: backgroundColor implementation.

Alexandre Julliard julliard at winehq.org
Fri Mar 30 11:27:06 CDT 2012


Module: wine
Branch: master
Commit: 27555a52d8c6f64069951c8af227e9ba56a9f5c3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=27555a52d8c6f64069951c8af227e9ba56a9f5c3

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Mar 30 14:14:16 2012 +0200

mshtml: Use proper helpers in IHTMLStyle::backgroundColor implementation.

---

 dlls/mshtml/htmlstyle.c   |   20 +++-----------------
 dlls/mshtml/tests/style.c |   12 ++++++++++++
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index f13fb35..448b7c8 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -921,30 +921,16 @@ static HRESULT WINAPI HTMLStyle_put_backgroundColor(IHTMLStyle *iface, VARIANT v
 
     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
 
-    switch(V_VT(&v)) {
-    case VT_BSTR:
-        return set_style_attr(This, STYLEID_BACKGROUND_COLOR, V_BSTR(&v), 0);
-    case VT_I4: {
-        WCHAR value[10];
-        static const WCHAR format[] = {'#','%','0','6','x',0};
-
-        wsprintfW(value, format, V_I4(&v));
-        return set_style_attr(This, STYLEID_BACKGROUND_COLOR, value, 0);
-    }
-    default:
-        FIXME("unsupported vt %d\n", V_VT(&v));
-    }
-
-    return S_OK;
+    return set_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, &v, ATTR_HEX_INT);
 }
 
 static HRESULT WINAPI HTMLStyle_get_backgroundColor(IHTMLStyle *iface, VARIANT *p)
 {
     HTMLStyle *This = impl_from_IHTMLStyle(iface);
+
     TRACE("(%p)->(%p)\n", This, p);
 
-    V_VT(p) = VT_BSTR;
-    return get_style_attr(This, STYLEID_BACKGROUND_COLOR, &V_BSTR(p));
+    return get_nsstyle_attr_var(This->nsstyle, STYLEID_BACKGROUND_COLOR, p, 0);
 }
 
 static HRESULT WINAPI HTMLStyle_put_backgroundImage(IHTMLStyle *iface, BSTR v)
diff --git a/dlls/mshtml/tests/style.c b/dlls/mshtml/tests/style.c
index 34e09b1..bb80df1 100644
--- a/dlls/mshtml/tests/style.c
+++ b/dlls/mshtml/tests/style.c
@@ -1256,6 +1256,18 @@ static void test_body_style(IHTMLStyle *style)
     ok(!V_BSTR(&v), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
     VariantClear(&v);
 
+    V_VT(&v) = VT_BSTR;
+    V_BSTR(&v) = a2bstr("red");
+    hres = IHTMLStyle_put_backgroundColor(style, v);
+    ok(hres == S_OK, "put_backgroundColor failed: %08x\n", hres);
+    VariantClear(&v);
+
+    hres = IHTMLStyle_get_backgroundColor(style, &v);
+    ok(hres == S_OK, "get_backgroundColor: %08x\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v));
+    ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+
     /* padding */
     hres = IHTMLStyle_get_padding(style, &str);
     ok(hres == S_OK, "get_padding failed: %08x\n", hres);




More information about the wine-cvs mailing list