mshtml: Added IHTMImgElement::get_src implementation.

This commit is contained in:
Jacek Caban 2008-10-13 14:50:37 -05:00 committed by Alexandre Julliard
parent 59c66e34a9
commit aae2c59dfd
4 changed files with 55 additions and 2 deletions

View File

@ -280,8 +280,25 @@ static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
{
HTMLImgElement *This = HTMLIMG_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 = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &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, p);
nsAString_Finish(&src_str);
return hres;
}
static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)

View File

@ -502,6 +502,8 @@ void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
BOOL install_wine_gecko(BOOL);
HRESULT nsuri_to_url(LPCWSTR,BSTR*);
void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
void call_property_onchanged(ConnectionPoint*,DISPID);

View File

@ -67,6 +67,23 @@ typedef struct {
static nsresult create_uri(nsIURI*,NSContainer*,nsIWineURI**);
HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret)
{
const WCHAR *ptr = nsuri;
static const WCHAR wine_prefixW[] = {'w','i','n','e',':'};
if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
*ret = SysAllocString(ptr);
if(!*ret)
return E_OUTOFMEMORY;
TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
return S_OK;
}
static BOOL exec_shldocvw_67(HTMLDocument *doc, LPCWSTR url)
{
IOleCommandTarget *cmdtrg = NULL;

View File

@ -1316,6 +1316,20 @@ static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
ok(l == l2, "unexpected left %ld, expected %ld\n", l2, l);
}
#define test_img_src(i,s) _test_img_src(__LINE__,i,s)
static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
{
IHTMLImgElement *img = _get_img_iface(line, unk);
BSTR src;
HRESULT hres;
hres = IHTMLImgElement_get_src(img, &src);
IHTMLImgElement_Release(img);
ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", dbgstr_w(src), exsrc);
SysFreeString(src);
}
#define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
{
@ -1328,6 +1342,8 @@ static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
IHTMLImgElement_Release(img);
SysFreeString(tmp);
ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
_test_img_src(line, unk, src);
}
#define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
@ -3077,6 +3093,7 @@ static void test_elems(IHTMLDocument2 *doc)
elem = get_elem_by_id(doc, imgidW, TRUE);
if(elem) {
test_img_src((IUnknown*)elem, "");
test_img_set_src((IUnknown*)elem, "about:blank");
test_img_alt((IUnknown*)elem, NULL);
test_img_set_alt((IUnknown*)elem, "alt test");