From 3a118f86f776874dffe371ed976270cb8adc4ebd Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 9 Mar 2009 20:46:01 +0100 Subject: [PATCH] mshtml: Added IHTMLStyle::put_cssText implementation. --- dlls/mshtml/htmlstyle.c | 16 ++++++++++++++-- dlls/mshtml/tests/dom.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 5fa31c805f0..76417013d7c 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -2056,8 +2056,20 @@ static HRESULT WINAPI HTMLStyle_get_pageBreakAfter(IHTMLStyle *iface, BSTR *p) static HRESULT WINAPI HTMLStyle_put_cssText(IHTMLStyle *iface, BSTR v) { HTMLStyle *This = HTMLSTYLE_THIS(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_Init(&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 HTMLStyle_get_cssText(IHTMLStyle *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index fa36c6e289d..f95b753e3f8 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1943,6 +1943,18 @@ static void _test_style_csstext(unsigned line, IHTMLStyle *style, const char *ex SysFreeString(text); } +#define test_style_set_csstext(s,t) _test_style_set_csstext(__LINE__,s,t) +static void _test_style_set_csstext(unsigned line, IHTMLStyle *style, const char *text) +{ + BSTR tmp; + HRESULT hres; + + tmp = a2bstr(text); + hres = IHTMLStyle_put_cssText(style, tmp); + ok_(__FILE__,line)(hres == S_OK, "put_cssText failed: %08x\n", hres); + SysFreeString(tmp); +} + static void test_elem_col_item(IHTMLElementCollection *col, LPCWSTR n, const elem_type_t *elem_types, long len) { @@ -3590,6 +3602,20 @@ static void test_default_style(IHTMLStyle *style) } } +static void test_set_csstext(IHTMLStyle *style) +{ + VARIANT v; + HRESULT hres; + + test_style_set_csstext(style, "background-color: black;"); + + 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), "black"), "str=%s\n", dbgstr_w(V_BSTR(&v))); + VariantClear(&v); +} + static void test_default_selection(IHTMLDocument2 *doc) { IHTMLSelectionObject *selection; @@ -3830,8 +3856,6 @@ static void test_defaults(IHTMLDocument2 *doc) test_location(doc); test_navigator(doc); - IHTMLStyle_Release(style); - elem2 = get_elem2_iface((IUnknown*)elem); hres = IHTMLElement2_get_currentStyle(elem2, &cstyle); ok(hres == S_OK, "get_currentStyle failed: %08x\n", hres); @@ -3843,6 +3867,9 @@ static void test_defaults(IHTMLDocument2 *doc) IHTMLElement_Release(elem); + test_set_csstext(style); + IHTMLStyle_Release(style); + hres = IHTMLDocument2_get_styleSheets(doc, &stylesheetcol); ok(hres == S_OK, "get_styleSheets failed: %08x\n", hres);