Module: wine Branch: master Commit: 990675e52fc64521330517ff7a8eb3140639d053 URL: http://source.winehq.org/git/wine.git/?a=commit;h=990675e52fc64521330517ff7a...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Oct 28 00:30:33 2010 +0200
mshtml: Added IHTMLFormElement_{get/put}_name implementation.
---
dlls/mshtml/htmlform.c | 37 +++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c index 954ede8..37cf2ec 100644 --- a/dlls/mshtml/htmlform.c +++ b/dlls/mshtml/htmlform.c @@ -272,15 +272,44 @@ static HRESULT WINAPI HTMLFormElement_get_target(IHTMLFormElement *iface, BSTR * static HRESULT WINAPI HTMLFormElement_put_name(IHTMLFormElement *iface, BSTR v) { HTMLFormElement *This = HTMLFORM_THIS(iface); - FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); - return E_NOTIMPL; + nsAString name_str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + + nsAString_InitDepend(&name_str, v); + nsres = nsIDOMHTMLFormElement_SetName(This->nsform, &name_str); + nsAString_Finish(&name_str); + if(NS_FAILED(nsres)) + return E_FAIL; + + return S_OK; }
static HRESULT WINAPI HTMLFormElement_get_name(IHTMLFormElement *iface, BSTR *p) { HTMLFormElement *This = HTMLFORM_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString name_str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&name_str, NULL); + nsres = nsIDOMHTMLFormElement_GetName(This->nsform, &name_str); + if(NS_SUCCEEDED(nsres)) { + const PRUnichar *name; + nsAString_GetData(&name_str, &name); + + if(*name) { + *p = SysAllocString(name); + if(!*p) + return E_OUTOFMEMORY; + }else + *p = NULL; + }else + return E_FAIL; + + return S_OK; }
static HRESULT WINAPI HTMLFormElement_put_onsubmit(IHTMLFormElement *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 7e4343f..c634cf6 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2629,6 +2629,39 @@ static void _test_form_put_method(unsigned line, IUnknown *unk, HRESULT exp_hres _test_form_method(line, unk, method); }
+#define test_form_name(f,a) _test_form_name(__LINE__,f,a) +static void _test_form_name(unsigned line, IUnknown *unk, const char *ex) +{ + IHTMLFormElement *form = _get_form_iface(line, unk); + BSTR name = (void*)0xdeadbeef; + HRESULT hres; + + hres = IHTMLFormElement_get_name(form, &name); + ok_(__FILE__,line)(hres == S_OK, "get_name failed: %08x\n", hres); + if(ex) + ok_(__FILE__,line)(!strcmp_wa(name, ex), "name=%s, expected %s\n", wine_dbgstr_w(name), ex); + else + ok_(__FILE__,line)(!name, "name=%p\n", name); + + SysFreeString(name); + IHTMLFormElement_Release(form); +} + +#define test_form_put_name(f,a) _test_form_put_name(__LINE__,f,a) +static void _test_form_put_name(unsigned line, IUnknown *unk, const char *name) +{ + IHTMLFormElement *form = _get_form_iface(line, unk); + BSTR tmp = a2bstr(name); + HRESULT hres; + + hres = IHTMLFormElement_put_name(form, tmp); + ok_(__FILE__,line)(hres == S_OK, "put_name failed: %08x\n", hres); + SysFreeString(tmp); + IHTMLFormElement_Release(form); + + _test_form_name(line, unk, name); +} + #define get_elem_doc(e) _get_elem_doc(__LINE__,e) static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk) {