mshtml: Added IHTMLImgElement::[get|put]_alt implementation.

This commit is contained in:
Jacek Caban 2008-06-30 21:39:36 +02:00 committed by Alexandre Julliard
parent fe863e0326
commit 4690d6d572
2 changed files with 75 additions and 8 deletions

View File

@ -228,15 +228,41 @@ static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, long *p)
static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v) static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
{ {
HTMLImgElement *This = HTMLIMG_THIS(iface); HTMLImgElement *This = HTMLIMG_THIS(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(v)); nsAString alt_str;
return E_NOTIMPL; nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
nsAString_Init(&alt_str, v);
nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
nsAString_Finish(&alt_str);
if(NS_FAILED(nsres))
ERR("SetAlt failed: %08x\n", nsres);
return S_OK;
} }
static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p) static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
{ {
HTMLImgElement *This = HTMLIMG_THIS(iface); HTMLImgElement *This = HTMLIMG_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); nsAString alt_str;
return E_NOTIMPL; nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&alt_str, NULL);
nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
if(NS_SUCCEEDED(nsres)) {
const PRUnichar *alt;
nsAString_GetData(&alt_str, &alt);
*p = *alt ? SysAllocString(alt) : NULL;
}else {
ERR("GetAlt failed: %08x\n", nsres);
}
nsAString_Finish(&alt_str);
return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
} }
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)

View File

@ -411,6 +411,17 @@ static IHTMLDOMNode *_get_node_iface(unsigned line, IUnknown *unk)
return node; return node;
} }
#define get_img_iface(u) _get_img_iface(__LINE__,u)
static IHTMLImgElement *_get_img_iface(unsigned line, IUnknown *unk)
{
IHTMLImgElement *img;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
return img;
}
#define test_node_name(u,n) _test_node_name(__LINE__,u,n) #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname) static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
{ {
@ -932,13 +943,10 @@ static long _get_node_type(unsigned line, IUnknown *unk)
#define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s) #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) static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
{ {
IHTMLImgElement *img; IHTMLImgElement *img = _get_img_iface(line, unk);
BSTR tmp; BSTR tmp;
HRESULT hres; HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLImgElement, (void**)&img);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLImgElement: %08x\n", hres);
tmp = a2bstr(src); tmp = a2bstr(src);
hres = IHTMLImgElement_put_src(img, tmp); hres = IHTMLImgElement_put_src(img, tmp);
IHTMLImgElement_Release(img); IHTMLImgElement_Release(img);
@ -946,6 +954,37 @@ static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres); ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
} }
#define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
static void _test_img_alt(unsigned line, IUnknown *unk, const char *exalt)
{
IHTMLImgElement *img = _get_img_iface(line, unk);
BSTR alt;
HRESULT hres;
hres = IHTMLImgElement_get_alt(img, &alt);
ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
if(exalt)
ok_(__FILE__,line) (!strcmp_wa(alt, exalt), "inexopected alt %s\n", dbgstr_w(alt));
else
ok_(__FILE__,line) (!alt, "alt != NULL\n");
SysFreeString(alt);
}
#define test_img_set_alt(u,a) _test_img_set_alt(__LINE__,u,a)
static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
{
IHTMLImgElement *img = _get_img_iface(line, unk);
BSTR tmp;
HRESULT hres;
tmp = a2bstr(alt);
hres = IHTMLImgElement_put_alt(img, tmp);
ok_(__FILE__,line) (hres == S_OK, "get_alt failed: %08x\n", hres);
SysFreeString(tmp);
_test_img_alt(line, unk, alt);
}
#define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b) #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb) static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
{ {
@ -2167,6 +2206,8 @@ static void test_elems(IHTMLDocument2 *doc)
elem = get_elem_by_id(doc, imgidW, TRUE); elem = get_elem_by_id(doc, imgidW, TRUE);
if(elem) { if(elem) {
test_img_set_src((IUnknown*)elem, "about:blank"); test_img_set_src((IUnknown*)elem, "about:blank");
test_img_alt((IUnknown*)elem, NULL);
test_img_set_alt((IUnknown*)elem, "alt test");
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
} }