From 6079c56133bfe9e2b026151e11f2c9545de90271 Mon Sep 17 00:00:00 2001 From: Zhenbo Li Date: Mon, 18 Aug 2014 17:03:11 +0800 Subject: [PATCH] mshtml: Added IHTMLImgElement::align property implementation. --- dlls/mshtml/htmlimg.c | 28 ++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c index a793397f063..8c1d324747b 100644 --- a/dlls/mshtml/htmlimg.c +++ b/dlls/mshtml/htmlimg.c @@ -412,15 +412,35 @@ static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v) { HTMLImgElement *This = impl_from_IHTMLImgElement(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + nsAString str; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + nsAString_InitDepend(&str, v); + + nsres = nsIDOMHTMLImageElement_SetAlign(This->nsimg, &str); + nsAString_Finish(&str); + if (NS_FAILED(nsres)){ + ERR("Set Align(%s) failed: %08x\n", debugstr_w(v), nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p) { HTMLImgElement *This = impl_from_IHTMLImgElement(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString str; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&str, NULL); + nsres = nsIDOMHTMLImageElement_GetAlign(This->nsimg, &str); + + return return_nsstr(nsres, &str, p); } static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index ba0c5826b1f..7cae345115b 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2783,6 +2783,24 @@ static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt) _test_img_alt(line, unk, alt); } +#define test_img_align(u,a) _test_img_align(__LINE__,u,a) +static void _test_img_align(unsigned line, IUnknown *unk, const char *align) +{ + IHTMLImgElement *img = _get_img_iface(line, unk); + BSTR tmp; + HRESULT hres; + + tmp = a2bstr(align); + hres = IHTMLImgElement_put_align(img, tmp); + ok_(__FILE__,line) (hres == S_OK, "put_align failed: %08x\n", hres); + SysFreeString(tmp); + + hres = IHTMLImgElement_get_align(img, &tmp); + ok_(__FILE__,line) (hres == S_OK, "put_align failed: %08x\n", hres); + ok_(__FILE__,line) (!strcmp_wa(tmp, align), "Expect %s, got %s\n", align, wine_dbgstr_w(tmp)); + SysFreeString(tmp); +} + #define test_img_name(u, c) _test_img_name(__LINE__,u, c) static void _test_img_name(unsigned line, IUnknown *unk, const char *pValue) { @@ -7000,6 +7018,8 @@ static void test_elems(IHTMLDocument2 *doc) elem = get_elem_by_id(doc, "imgid", TRUE); if(elem) { + test_img_align((IUnknown*)elem, "left"); + test_img_name((IUnknown*)elem, "WineImg"); test_img_src((IUnknown*)elem, "", NULL); test_img_set_src((IUnknown*)elem, "about:blank"); test_img_src((IUnknown*)elem, "about:blank", NULL);