From: Zhenbo Li Subject: mshtml: Added IHTMLInputElement::size property implementation. Message-Id: <53E890AD.3080808@gmail.com> Date: Mon, 11 Aug 2014 17:45:17 +0800 --- dlls/mshtml/htmlinput.c | 31 +++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index f832b88..c356ac0 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -262,15 +262,38 @@ static HRESULT WINAPI HTMLInputElement_get_form(IHTMLInputElement *iface, IHTMLF static HRESULT WINAPI HTMLInputElement_put_size(IHTMLInputElement *iface, LONG v) { HTMLInputElement *This = impl_from_IHTMLInputElement(iface); - FIXME("(%p)->(%d)\n", This, v); - return E_NOTIMPL; + UINT32 val = v; + nsresult nsres; + + TRACE("(%p)->(%d)\n", This, v); + if (v <= 0) + return CTL_E_INVALIDPROPERTYVALUE; + + nsres = nsIDOMHTMLInputElement_SetSize(This->nsinput, val); + if (NS_FAILED(nsres)) { + ERR("Set Size(%u) failed: %08x\n", val, nsres); + return E_FAIL; + } + return S_OK; } static HRESULT WINAPI HTMLInputElement_get_size(IHTMLInputElement *iface, LONG *p) { HTMLInputElement *This = impl_from_IHTMLInputElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + UINT32 val; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + if (p == NULL) + return E_INVALIDARG; + + nsres = nsIDOMHTMLInputElement_GetSize(This->nsinput, &val); + if (NS_FAILED(nsres)) { + ERR("Get Size failed: %08x\n", nsres); + return E_FAIL; + } + *p = val; + return S_OK; } static HRESULT WINAPI HTMLInputElement_put_maxLength(IHTMLInputElement *iface, LONG v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 33645c8..45eedec 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -3302,6 +3302,29 @@ static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const c _test_input_src(line, input, src); } +#define test_input_set_size(u,s,r) _test_input_set_size(__LINE__,u,s,r) +static void _test_input_set_size(unsigned line, IHTMLInputElement *input, LONG size, HRESULT exret) +{ + HRESULT hres; + + hres = IHTMLInputElement_put_size(input, size); + ok_(__FILE__,line) (hres == exret, "Expect ret = %08x, got: %08x\n", exret, hres); +} + +#define test_input_get_size(u,s) _test_input_get_size(__LINE__,u,s) +static void _test_input_get_size(unsigned line, IHTMLInputElement *input, LONG exsize) +{ + HRESULT hres; + LONG size; + + hres = IHTMLInputElement_get_size(input, &size); + ok_(__FILE__,line) (hres == S_OK, "get_size failed: %08x\n", hres); + ok_(__FILE__,line) (size == exsize, "Expect %d, got %d\n", exsize, size); + + hres = IHTMLInputElement_get_size(input, NULL); + ok_(__FILE__,line) (hres == E_INVALIDARG, "Expect ret E_INVALIDARG, got: %08x\n", hres); +} + #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c) static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass) { @@ -6865,6 +6888,13 @@ static void test_elems(IHTMLDocument2 *doc) test_input_src(input, NULL); test_input_set_src(input, "about:blank"); + test_input_set_size(input, 15, S_OK); + test_input_get_size(input, 15); + test_input_set_size(input, -100, CTL_E_INVALIDPROPERTYVALUE); + test_input_get_size(input, 15); + test_input_set_size(input, 0, CTL_E_INVALIDPROPERTYVALUE); + test_input_get_size(input, 15); + IHTMLInputElement_Release(input); IHTMLElement_Release(elem); }