From 47d835206708bdedb63d779614056dca17ace71f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 23 Jun 2008 09:52:17 -0500 Subject: [PATCH] mshtml: Added IHTMLElement::put_className implementation. --- dlls/mshtml/htmlelem.c | 19 +++++++++++++++++-- dlls/mshtml/tests/dom.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 895606502f2..ce93399c270 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -252,8 +252,23 @@ static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strA static HRESULT WINAPI HTMLElement_put_className(IHTMLElement *iface, BSTR v) { HTMLElement *This = HTMLELEM_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString classname_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + if(!This->nselem) { + FIXME("NULL nselem\n"); + return E_NOTIMPL; + } + + nsAString_Init(&classname_str, v); + nsres = nsIDOMHTMLElement_SetClassName(This->nselem, &classname_str); + nsAString_Finish(&classname_str); + if(NS_FAILED(nsres)) + ERR("SetClassName failed: %08x\n", nsres); + + return S_OK; } static HRESULT WINAPI HTMLElement_get_className(IHTMLElement *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index e67ca760a5f..56240200c29 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -935,6 +935,22 @@ static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass) SysFreeString(class); } +#define test_elem_set_class(u,c) _test_elem_set_class(__LINE__,u,c) +static void _test_elem_set_class(unsigned line, IUnknown *unk, const char *class) +{ + IHTMLElement *elem = _get_elem_iface(line, unk); + BSTR tmp; + HRESULT hres; + + tmp = class ? a2bstr(class) : NULL; + hres = IHTMLElement_put_className(elem, tmp); + IHTMLElement_Release(elem); + ok_(__FILE__,line) (hres == S_OK, "put_className failed: %08x\n", hres); + SysFreeString(tmp); + + _test_elem_class(line, unk, class); +} + #define get_child_item(c,i) _get_child_item(__LINE__,c,i) static IHTMLDOMNode *_get_child_item(unsigned line, IHTMLDOMChildrenCollection *col, long idx) { @@ -1804,6 +1820,8 @@ static void test_elems(IHTMLDocument2 *doc) test_elem_attr(elem, xxxW, NULL); test_elem_attr(elem, idW, sW); test_elem_class((IUnknown*)elem, NULL); + test_elem_set_class((IUnknown*)elem, "cl"); + test_elem_set_class((IUnknown*)elem, NULL); IHTMLElement_Release(elem); } -- 2.11.4.GIT