Commit 508aa85c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLInputElement::src property implementation.

parent ee5d6784
...@@ -295,7 +295,7 @@ static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p) ...@@ -295,7 +295,7 @@ static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
} }
nsAString_GetData(&src_str, &src); nsAString_GetData(&src_str, &src);
hres = nsuri_to_url(src, p); hres = nsuri_to_url(src, TRUE, p);
nsAString_Finish(&src_str); nsAString_Finish(&src_str);
return hres; return hres;
......
...@@ -506,15 +506,42 @@ static HRESULT WINAPI HTMLInputElement_get_alt(IHTMLInputElement *iface, BSTR *p ...@@ -506,15 +506,42 @@ static HRESULT WINAPI HTMLInputElement_get_alt(IHTMLInputElement *iface, BSTR *p
static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v) static HRESULT WINAPI HTMLInputElement_put_src(IHTMLInputElement *iface, BSTR v)
{ {
HTMLInputElement *This = HTMLINPUT_THIS(iface); HTMLInputElement *This = HTMLINPUT_THIS(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(v)); nsAString nsstr;
return E_NOTIMPL; 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) static HRESULT WINAPI HTMLInputElement_get_src(IHTMLInputElement *iface, BSTR *p)
{ {
HTMLInputElement *This = HTMLINPUT_THIS(iface); HTMLInputElement *This = HTMLINPUT_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); const PRUnichar *src;
return E_NOTIMPL; 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) static HRESULT WINAPI HTMLInputElement_put_lowsrc(IHTMLInputElement *iface, BSTR v)
......
...@@ -554,7 +554,7 @@ void init_nsio(nsIComponentManager*,nsIComponentRegistrar*); ...@@ -554,7 +554,7 @@ void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
void release_nsio(void); void release_nsio(void);
BOOL install_wine_gecko(BOOL); 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); void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
......
...@@ -77,7 +77,7 @@ static const char *debugstr_nsacstr(const nsACString *nsstr) ...@@ -77,7 +77,7 @@ static const char *debugstr_nsacstr(const nsACString *nsstr)
return debugstr_a(data); 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; const WCHAR *ptr = nsuri;
...@@ -86,9 +86,13 @@ HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret) ...@@ -86,9 +86,13 @@ HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret)
if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR))) if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
ptr += sizeof(wine_prefixW)/sizeof(WCHAR); ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
if(*ptr || ret_empty) {
*ret = SysAllocString(ptr); *ret = SysAllocString(ptr);
if(!*ret) if(!*ret)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}else {
*ret = NULL;
}
TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret)); TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
return S_OK; return S_OK;
......
...@@ -1586,6 +1586,35 @@ static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val) ...@@ -1586,6 +1586,35 @@ static void _test_input_put_value(unsigned line, IUnknown *unk, const char *val)
IHTMLInputElement_Release(input); 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) #define test_elem_class(u,c) _test_elem_class(__LINE__,u,c)
static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass) static void _test_elem_class(unsigned line, IUnknown *unk, const char *exclass)
{ {
...@@ -4622,6 +4651,9 @@ static void test_elems(IHTMLDocument2 *doc) ...@@ -4622,6 +4651,9 @@ static void test_elems(IHTMLDocument2 *doc)
test_input_set_checked(input, VARIANT_TRUE); test_input_set_checked(input, VARIANT_TRUE);
test_input_set_checked(input, VARIANT_FALSE); test_input_set_checked(input, VARIANT_FALSE);
test_input_src(input, NULL);
test_input_set_src(input, "about:blank");
IHTMLInputElement_Release(input); IHTMLInputElement_Release(input);
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment