From d27417768e70637b94c951bb911df780930f8f73 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 23 Oct 2012 13:41:51 +0200 Subject: [PATCH] mshtml: Added IHTMLIFrameElement::width property implementation. --- dlls/mshtml/htmliframe.c | 33 +++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmliframe.c b/dlls/mshtml/htmliframe.c index c1f12642fb3..64f44fd3bc7 100644 --- a/dlls/mshtml/htmliframe.c +++ b/dlls/mshtml/htmliframe.c @@ -256,15 +256,40 @@ static HRESULT WINAPI HTMLIFrameElement2_get_height(IHTMLIFrameElement2 *iface, static HRESULT WINAPI HTMLIFrameElement2_put_width(IHTMLIFrameElement2 *iface, VARIANT v) { HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + if(V_VT(&v) != VT_BSTR) { + FIXME("Unsupported %s\n", debugstr_variant(&v)); + return E_NOTIMPL; + } + + nsAString_InitDepend(&nsstr, V_BSTR(&v)); + nsres = nsIDOMHTMLIFrameElement_SetWidth(This->framebase.nsiframe, &nsstr); + nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) { + ERR("SetWidth failed: %08x\n", nsres); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI HTMLIFrameElement2_get_width(IHTMLIFrameElement2 *iface, VARIANT *p) { HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMHTMLIFrameElement_GetWidth(This->framebase.nsiframe, &nsstr); + + V_VT(p) = VT_BSTR; + return return_nsstr(nsres, &nsstr, &V_BSTR(p)); } static const IHTMLIFrameElement2Vtbl HTMLIFrameElement2Vtbl = { diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 3c1b0e24e48..20e9e4c9745 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -5283,6 +5283,39 @@ static void _set_iframe_height(unsigned line, IHTMLElement *elem, const char *va IHTMLIFrameElement2_Release(iframe); } +#define test_iframe_width(a,b) _test_iframe_width(__LINE__,a,b) +static void _test_iframe_width(unsigned line, IHTMLElement *elem, const char *exval) +{ + IHTMLIFrameElement2 *iframe = _get_iframe2_iface(line, (IUnknown*)elem); + VARIANT v; + HRESULT hres; + + hres = IHTMLIFrameElement2_get_width(iframe, &v); + ok_(__FILE__,line)(hres == S_OK, "get_width failed: %08x\n", hres); + ok_(__FILE__,line)(V_VT(&v) == VT_BSTR, "V_VT(width) = %d\n", V_VT(&v)); + if(exval) + ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&v), exval), "width = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v)), exval); + else + ok_(__FILE__,line)(!V_BSTR(&v), "width = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + IHTMLIFrameElement2_Release(iframe); +} + +#define set_iframe_width(a,b) _set_iframe_width(__LINE__,a,b) +static void _set_iframe_width(unsigned line, IHTMLElement *elem, const char *val) +{ + IHTMLIFrameElement2 *iframe = _get_iframe2_iface(line, (IUnknown*)elem); + VARIANT v; + HRESULT hres; + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr(val); + hres = IHTMLIFrameElement2_put_width(iframe, v); + ok_(__FILE__,line)(hres == S_OK, "put_width failed: %08x\n", hres); + VariantClear(&v); + IHTMLIFrameElement2_Release(iframe); +} + static void test_iframe_elem(IHTMLElement *elem) { IHTMLDocument2 *content_doc, *owner_doc; @@ -5330,6 +5363,11 @@ static void test_iframe_elem(IHTMLElement *elem) set_iframe_height(elem, "50%"); test_iframe_height(elem, "50%"); + test_iframe_width(elem, NULL); + set_iframe_width(elem, "150px"); + set_iframe_width(elem, "70%"); + test_iframe_width(elem, "70%"); + str = a2bstr("text/html"); V_VT(&errv) = VT_ERROR; disp = NULL;