From 81cdfc61fd6527d1640e871586f064d9dee6b38b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 24 Oct 2012 12:41:01 +0200 Subject: [PATCH] mshtml: Added IHTMLFrameBase::marginWidth property implementation. --- dlls/mshtml/htmlframebase.c | 61 ++++++++++++++++++++++++++++++++++--- dlls/mshtml/tests/dom.c | 34 +++++++++++++++++++++ 2 files changed, 91 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlframebase.c b/dlls/mshtml/htmlframebase.c index 5431187b4ef..a11adca1c73 100644 --- a/dlls/mshtml/htmlframebase.c +++ b/dlls/mshtml/htmlframebase.c @@ -273,15 +273,68 @@ static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARI static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(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)); + if(This->nsframe) + nsres = nsIDOMHTMLFrameElement_SetMarginWidth(This->nsframe, &nsstr); + else + nsres = nsIDOMHTMLIFrameElement_SetMarginWidth(This->nsiframe, &nsstr); + nsAString_Finish(&nsstr); + return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL; } static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p) { HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsAString nsstr; + nsresult nsres; + HRESULT hres = S_OK; + + TRACE("(%p)->(%p)\n", This, p); + + nsAString_Init(&nsstr, NULL); + if(This->nsframe) + nsres = nsIDOMHTMLFrameElement_GetMarginWidth(This->nsframe, &nsstr); + else + nsres = nsIDOMHTMLIFrameElement_GetMarginWidth(This->nsiframe, &nsstr); + if(NS_SUCCEEDED(nsres)) { + const PRUnichar *str, *end; + + nsAString_GetData(&nsstr, &str); + + if(*str) { + BSTR ret; + + end = strstrW(str, pxW); + if(!end) + end = str+strlenW(str); + ret = SysAllocStringLen(str, end-str); + if(ret) { + V_VT(p) = VT_BSTR; + V_BSTR(p) = ret; + }else { + hres = E_OUTOFMEMORY; + } + }else { + V_VT(p) = VT_BSTR; + V_BSTR(p) = NULL; + } + }else { + ERR("GetMarginWidth failed: %08x\n", nsres); + hres = E_FAIL; + } + + nsAString_Finish(&nsstr); + return hres; } static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index f3dcc293bd6..26567d25967 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4476,6 +4476,36 @@ static void _set_framebase_marginheight(unsigned line, IHTMLFrameBase *framebase ok_(__FILE__,line)(hres == S_OK, "put_marginHeight failed: %08x\n", hres); VariantClear(&v); } + +#define test_framebase_marginwidth(a,b) _test_framebase_marginwidth(__LINE__,a,b) +static void _test_framebase_marginwidth(unsigned line, IHTMLFrameBase *framebase, const char *exval) +{ + VARIANT v; + HRESULT hres; + + hres = IHTMLFrameBase_get_marginWidth(framebase, &v); + ok_(__FILE__,line)(hres == S_OK, "get_marginWidth failed: %08x\n", hres); + ok_(__FILE__,line)(V_VT(&v) == VT_BSTR, "V_VT(marginWidth) = %d\n", V_VT(&v)); + if(exval) + ok_(__FILE__,line)(!strcmp_wa(V_BSTR(&v), exval), "marginWidth = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v)), exval); + else + ok_(__FILE__,line)(!V_BSTR(&v), "marginWidth = %s, expected NULL\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); +} + +#define set_framebase_marginwidth(a,b) _set_framebase_marginwidth(__LINE__,a,b) +static void _set_framebase_marginwidth(unsigned line, IHTMLFrameBase *framebase, const char *val) +{ + VARIANT v; + HRESULT hres; + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr(val); + hres = IHTMLFrameBase_put_marginWidth(framebase, v); + ok_(__FILE__,line)(hres == S_OK, "put_marginWidth failed: %08x\n", hres); + VariantClear(&v); +} + static void test_framebase(IUnknown *unk) { IHTMLFrameBase *fbase; @@ -4529,6 +4559,10 @@ static void test_framebase(IUnknown *unk) set_framebase_marginheight(fbase, "1px"); test_framebase_marginheight(fbase, "1"); + test_framebase_marginwidth(fbase, NULL); + set_framebase_marginwidth(fbase, "2px"); + test_framebase_marginwidth(fbase, "2"); + IHTMLFrameBase_Release(fbase); }