diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index fbdf633c02e..2e2777a51b8 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -2463,20 +2463,10 @@ static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p) static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v) { HTMLStyle *This = impl_from_IHTMLStyle(iface); - nsAString text_str; - nsresult nsres; TRACE("(%p)->(%s)\n", This, debugstr_w(v)); - nsAString_InitDepend(&text_str, v); - nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str); - nsAString_Finish(&text_str); - if(NS_FAILED(nsres)) { - FIXME("SetCssStyle failed: %08x\n", nsres); - return E_FAIL; - } - - return S_OK; + return IHTMLCSSStyleDeclaration_put_cssText(&This->IHTMLCSSStyleDeclaration_iface, v); } static HRESULT WINAPI HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p) @@ -5793,8 +5783,20 @@ static HRESULT WINAPI HTMLCSSStyleDeclaration_get_pageBreakAfter(IHTMLCSSStyleDe static HRESULT WINAPI HTMLCSSStyleDeclaration_put_cssText(IHTMLCSSStyleDeclaration *iface, BSTR v) { HTMLStyle *This = impl_from_IHTMLCSSStyleDeclaration(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString text_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_InitDepend(&text_str, v); + nsres = nsIDOMCSSStyleDeclaration_SetCssText(This->nsstyle, &text_str); + nsAString_Finish(&text_str); + if(NS_FAILED(nsres)) { + FIXME("SetCssStyle failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLCSSStyleDeclaration_get_cssText(IHTMLCSSStyleDeclaration *iface, BSTR *p) diff --git a/dlls/mshtml/tests/style.c b/dlls/mshtml/tests/style.c index ca1909ca4b4..b33cd01ed56 100644 --- a/dlls/mshtml/tests/style.c +++ b/dlls/mshtml/tests/style.c @@ -355,7 +355,9 @@ static void _test_text_decoration(unsigned line, IHTMLStyle *style, const char * static void test_set_csstext(IHTMLStyle *style) { + IHTMLCSSStyleDeclaration *css_style; VARIANT v; + BSTR str; HRESULT hres; test_style_set_csstext(style, "background-color: black;"); @@ -365,6 +367,27 @@ static void test_set_csstext(IHTMLStyle *style) ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v)); ok(!strcmp_wa(V_BSTR(&v), "black"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); VariantClear(&v); + + hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLCSSStyleDeclaration, (void**)&css_style); + ok(hres == S_OK || broken(!is_ie9plus && hres == E_NOINTERFACE), + "Could not get IHTMLCSSStyleDeclaration interface: %08x\n", hres); + if(FAILED(hres)) + return; + + str = a2bstr("float: left;"); + hres = IHTMLCSSStyleDeclaration_put_cssText(css_style, str); + ok(hres == S_OK, "put_cssText failed: %08x\n", hres); + SysFreeString(str); + + hres = IHTMLCSSStyleDeclaration_get_cssFloat(css_style, &str); + ok(hres == S_OK, "get_cssText failed: %08x\n", hres); + ok(!strcmp_wa(str, "left"), "cssFloat = %s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IHTMLCSSStyleDeclaration_put_cssText(css_style, NULL); + ok(hres == S_OK, "put_cssText failed: %08x\n", hres); + + IHTMLCSSStyleDeclaration_Release(css_style); } static void test_style2(IHTMLStyle2 *style2)