Jacek Caban : mshtml: Use set_nsstyle_attr_var in IHTMLStyle:: put_width implementation.

Alexandre Julliard julliard at winehq.org
Tue Feb 9 10:37:55 CST 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb  8 21:48:31 2010 +0100

mshtml: Use set_nsstyle_attr_var in IHTMLStyle::put_width implementation.

---

 dlls/mshtml/htmlstyle.c |   16 +++++-----------
 dlls/mshtml/tests/dom.c |   12 ++++++++++++
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 04ba1d6..3022e2b 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -345,10 +345,12 @@ HRESULT set_nsstyle_attr_var(nsIDOMCSSStyleDeclaration *nsstyle, styleid_t sid,
 
     case VT_I4: {
         WCHAR str[14];
+
         static const WCHAR format[] = {'%','d',0};
+        static const WCHAR px_format[] = {'%','d','p','x',0};
 
-        wsprintfW(str, format, V_I4(value));
-        return set_nsstyle_attr(nsstyle, sid, str, flags);
+        wsprintfW(str, flags&ATTR_FIX_PX ? px_format : format, V_I4(value));
+        return set_nsstyle_attr(nsstyle, sid, str, flags & ~ATTR_FIX_PX);
     }
     default:
         FIXME("not implemented vt %d\n", V_VT(value));
@@ -1779,15 +1781,7 @@ static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v)
 
     TRACE("(%p)->(v%d)\n", This, V_VT(&v));
 
-    switch(V_VT(&v)) {
-    case VT_BSTR:
-        TRACE("%s\n", debugstr_w(V_BSTR(&v)));
-        return set_style_attr(This, STYLEID_WIDTH, V_BSTR(&v), 0);
-    default:
-        FIXME("unsupported vt %d\n", V_VT(&v));
-    }
-
-    return E_NOTIMPL;
+    return set_nsstyle_attr_var(This->nsstyle, STYLEID_WIDTH, &v, ATTR_FIX_PX);
 }
 
 static HRESULT WINAPI HTMLStyle_get_width(IHTMLStyle *iface, VARIANT *p)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index ba8f7bd..aa09d9e 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -3869,6 +3869,18 @@ static void test_default_style(IHTMLStyle *style)
     ok(!strcmp_wa(V_BSTR(&v), "auto"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
     VariantClear(&v);
 
+    V_VT(&v) = VT_I4;
+    V_I4(&v) = 100;
+    hres = IHTMLStyle_put_width(style, v);
+    ok(hres == S_OK, "put_width failed: %08x\n", hres);
+
+    V_VT(&v) = VT_EMPTY;
+    hres = IHTMLStyle_get_width(style, &v);
+    ok(hres == S_OK, "get_width failed: %08x\n", hres);
+    ok(V_VT(&v) == VT_BSTR, "V_VT(v)=%d\n", V_VT(&v));
+    ok(!strcmp_wa(V_BSTR(&v), "100px"), "V_BSTR(v)=%s\n", wine_dbgstr_w(V_BSTR(&v)));
+    VariantClear(&v);
+
     /* margin tests */
     str = (void*)0xdeadbeef;
     hres = IHTMLStyle_get_margin(style, &str);




More information about the wine-cvs mailing list