From: Zhenbo Li Subject: mshtml: Added IHTMLInputElement::readOnly property. (try 2) Message-Id: <53ED832C.4000000@gmail.com> Date: Fri, 15 Aug 2014 11:49:00 +0800 Supersedes 106014 try 2: Remove "? TRUE : FALSE" part. (Thanks Jacek) --- dlls/mshtml/htmlinput.c | 26 ++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 17 +++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index f832b88..18bf75b 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -389,15 +389,33 @@ static HRESULT WINAPI HTMLInputElement_get_defaultValue(IHTMLInputElement *iface static HRESULT WINAPI HTMLInputElement_put_readOnly(IHTMLInputElement *iface, VARIANT_BOOL v) { HTMLInputElement *This = impl_from_IHTMLInputElement(iface); - FIXME("(%p)->(%x)\n", This, v); - return E_NOTIMPL; + nsresult nsres; + + TRACE("(%p)->(%x)\n", This, v); + + nsres = nsIDOMHTMLInputElement_SetReadOnly(This->nsinput, v != VARIANT_FALSE); + if (NS_FAILED(nsres)) { + ERR("Set ReadOnly Failed: %08x\n", nsres); + return E_FAIL; + } + return S_OK; } static HRESULT WINAPI HTMLInputElement_get_readOnly(IHTMLInputElement *iface, VARIANT_BOOL *p) { HTMLInputElement *This = impl_from_IHTMLInputElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsresult nsres; + cpp_bool b; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLInputElement_GetReadOnly(This->nsinput, &b); + if (NS_FAILED(nsres)) { + ERR("Get ReadOnly Failed: %08x\n", nsres); + return E_FAIL; + } + *p = b ? VARIANT_TRUE : VARIANT_FALSE; + return S_OK; } static HRESULT WINAPI HTMLInputElement_createTextRange(IHTMLInputElement *iface, IHTMLTxtRange **range) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 33645c8..7eb41d5 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -3302,6 +3302,20 @@ static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const c _test_input_src(line, input, src); } +#define test_input_readOnly(u,b) _test_input_readOnly(__LINE__,u,b) +static void _test_input_readOnly(unsigned line, IHTMLInputElement *input, VARIANT_BOOL v) +{ + HRESULT hres; + VARIANT_BOOL b = 100; + + hres = IHTMLInputElement_put_readOnly(input, v); + ok_(__FILE__,line)(hres == S_OK, "put readOnly failed: %08x\n", hres); + + hres = IHTMLInputElement_get_readOnly(input, &b); + ok_(__FILE__,line)(hres == S_OK, "get readOnly failed: %08x\n", hres); + ok_(__FILE__,line)(v == b, "Expect %x, got %x\n", v, b); +} + #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 +6879,9 @@ static void test_elems(IHTMLDocument2 *doc) test_input_src(input, NULL); test_input_set_src(input, "about:blank"); + test_input_readOnly(input, VARIANT_TRUE); + test_input_readOnly(input, VARIANT_FALSE); + IHTMLInputElement_Release(input); IHTMLElement_Release(elem); }