Module: wine Branch: master Commit: 508aa85c6bf4b04b3f40b65bab1a0a04ff0b27cc URL: http://source.winehq.org/git/wine.git/?a=commit;h=508aa85c6bf4b04b3f40b65bab...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Sep 14 00:36:09 2009 +0200
mshtml: Added IHTMLInputElement::src property implementation.
---
dlls/mshtml/htmlimg.c | 2 +- dlls/mshtml/htmlinput.c | 35 +++++++++++++++++++++++++++++++---- dlls/mshtml/mshtml_private.h | 2 +- dlls/mshtml/nsio.c | 12 ++++++++---- dlls/mshtml/tests/dom.c | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 10 deletions(-)
diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index f7e2ab5..aac6f6c 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -295,7 +295,7 @@ static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p) }
nsAString_GetData(&src_str, &src); - hres = nsuri_to_url(src, p); + hres = nsuri_to_url(src, TRUE, p); nsAString_Finish(&src_str);
return hres; diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index 48f19c8..3d69e0c 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -506,15 +506,42 @@ static HRESULT WINAPI HTMLInputElement_get_alt(IHTMLInputElement *iface, BSTR *p static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v) { HTMLInputElement *This = HTMLINPUT_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_Init(&nsstr, v); + nsres = nsIDOMHTMLInputElement_SetSrc(This->nsinput, &nsstr); + nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) + ERR("SetSrc failed: %08x\n", nsres); + + return S_OK; }
static HRESULT WINAPI HTMLInputElement_get_src(IHTMLInputElement *iface, BSTR *p) { HTMLInputElement *This = HTMLINPUT_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + const PRUnichar *src; + nsAString src_str; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&src_str, NULL); + nsres = nsIDOMHTMLInputElement_GetSrc(This->nsinput, &src_str); + if(NS_FAILED(nsres)) { + ERR("GetSrc failed: %08x\n", nsres); + return E_FAIL; + } + + nsAString_GetData(&src_str, &src); + hres = nsuri_to_url(src, FALSE, p); + nsAString_Finish(&src_str); + + return hres; }
static HRESULT WINAPI HTMLInputElement_put_lowsrc(IHTMLInputElement *iface, BSTR v) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index e202688..2aedc98 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -554,7 +554,7 @@ void init_nsio(nsIComponentManager*,nsIComponentRegistrar*); void release_nsio(void); BOOL install_wine_gecko(BOOL);
-HRESULT nsuri_to_url(LPCWSTR,BSTR*); +HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c index 12e8520..88f2dc6 100644 --- a/dlls/mshtml/nsio.c +++ b/dlls/mshtml/nsio.c @@ -77,7 +77,7 @@ static const char *debugstr_nsacstr(const nsACString *nsstr) return debugstr_a(data); }
-HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret) +HRESULT nsuri_to_url(LPCWSTR nsuri, BOOL ret_empty, BSTR *ret) { const WCHAR *ptr = nsuri;
@@ -86,9 +86,13 @@ HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret) if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR))) ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
- *ret = SysAllocString(ptr); - if(!*ret) - return E_OUTOFMEMORY; + if(*ptr || ret_empty) { + *ret = SysAllocString(ptr); + if(!*ret) + return E_OUTOFMEMORY; + }else { + *ret = NULL; + }
TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret)); return S_OK; diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index b9a3ff8..bdf859f 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1586,6 +1586,35 @@ static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val) IHTMLInputElement_Release(input); }
+#define test_input_src(i,s) _test_input_src(__LINE__,i,s) +static void _test_input_src(unsigned line, IHTMLInputElement *input, const char *exsrc) +{ + BSTR src; + HRESULT hres; + + hres = IHTMLInputElement_get_src(input, &src); + ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres); + if(exsrc) + ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", wine_dbgstr_w(src), exsrc); + else + ok_(__FILE__,line) (!src, "get_src returned %s expected NULL\n", wine_dbgstr_w(src)); + SysFreeString(src); +} + +#define test_input_set_src(u,s) _test_input_set_src(__LINE__,u,s) +static void _test_input_set_src(unsigned line, IHTMLInputElement *input, const char *src) +{ + BSTR tmp; + HRESULT hres; + + tmp = a2bstr(src); + hres = IHTMLInputElement_put_src(input, tmp); + SysFreeString(tmp); + ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres); + + _test_input_src(line, input, src); +} + #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c) static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass) { @@ -4622,6 +4651,9 @@ static void test_elems(IHTMLDocument2 *doc) test_input_set_checked(input, VARIANT_TRUE); test_input_set_checked(input, VARIANT_FALSE);
+ test_input_src(input, NULL); + test_input_set_src(input, "about:blank"); + IHTMLInputElement_Release(input); IHTMLElement_Release(elem); }