mshtml: Added IHTMLInputElement::src property implementation.

This commit is contained in:
Jacek Caban 2009-09-14 00:36:09 +02:00 committed by Alexandre Julliard
parent ee5d678450
commit 508aa85c6b
5 changed files with 73 additions and 10 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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);
}