Module: wine Branch: master Commit: bb829372f11d0587a6ca594e607cec8e2eb4a24c URL: http://source.winehq.org/git/wine.git/?a=commit;h=bb829372f11d0587a6ca594e60...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Mon Jan 5 21:22:35 2009 +1100
mshtml: Implement IHTMLStyle get/set Attribute.
---
dlls/mshtml/htmlstyle.c | 69 ++++++++++++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 36 ++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index fa4ad51..3453f7b 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -2048,18 +2048,75 @@ static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttribut VARIANT AttributeValue, LONG lFlags) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName), - V_VT(&AttributeValue), lFlags); - return E_NOTIMPL; + HRESULT hres; + DISPID dispid; + + TRACE("(%p)->(%s v%d %08x)\n", This, debugstr_w(strAttributeName), + V_VT(&AttributeValue), lFlags); + + if(!strAttributeName) + return E_INVALIDARG; + + if(lFlags == 1) + FIXME("Parameter lFlags ignored\n"); + + hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, (LPOLESTR*)&strAttributeName, 1, + LOCALE_USER_DEFAULT, &dispid); + if(hres == S_OK) + { + VARIANT ret; + DISPID dispidNamed = DISPID_PROPERTYPUT; + DISPPARAMS params; + + params.cArgs = 1; + params.rgvarg = &AttributeValue; + params.cNamedArgs = 1; + params.rgdispidNamedArgs = &dispidNamed; + + hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + } + else + { + FIXME("Custom attributes not supported.\n"); + } + + TRACE("ret: %08x\n", hres); + + return hres; }
static HRESULT WINAPI HTMLStyle_getAttribute(IHTMLStyle *iface, BSTR strAttributeName, LONG lFlags, VARIANT *AttributeValue) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), - lFlags, AttributeValue); - return E_NOTIMPL; + HRESULT hres; + DISPID dispid; + + TRACE("(%p)->(%s v%p %08x)\n", This, debugstr_w(strAttributeName), + AttributeValue, lFlags); + + if(!AttributeValue || !strAttributeName) + return E_INVALIDARG; + + if(lFlags == 1) + FIXME("Parameter lFlags ignored\n"); + + hres = HTMLStyle_GetIDsOfNames(iface, &IID_NULL, (LPOLESTR*)&strAttributeName, 1, + LOCALE_USER_DEFAULT, &dispid); + if(hres == S_OK) + { + DISPPARAMS params = {NULL, NULL, 0, 0 }; + + hres = HTMLStyle_Invoke(iface, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYGET, ¶ms, AttributeValue, NULL, NULL); + } + else + { + FIXME("Custom attributes not supported.\n"); + } + + return hres; }
static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName, diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index be54998..46136c1 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2750,6 +2750,42 @@ static void test_default_style(IHTMLStyle *style) ok(hres == S_OK, "put_overflow failed: %08x\n", hres); SysFreeString(sOverflowDefault);
+ /* Attribute Tests*/ + hres = IHTMLStyle_getAttribute(style, NULL, 1, &v); + ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres); + + str = a2bstr("position"); + hres = IHTMLStyle_getAttribute(style, str, 1, NULL); + ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres); + + hres = IHTMLStyle_getAttribute(style, str, 1, &v); + ok(hres == S_OK, "getAttribute failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v)); + VariantClear(&v); + + hres = IHTMLStyle_setAttribute(style, NULL, v, 1); + ok(hres == E_INVALIDARG, "getAttribute failed: %08x\n", hres); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = a2bstr("absolute"); + hres = IHTMLStyle_setAttribute(style, str, v, 1); + ok(hres == S_OK, "setAttribute failed: %08x\n", hres); + VariantClear(&v); + + hres = IHTMLStyle_getAttribute(style, str, 1, &v); + ok(hres == S_OK, "getAttribute failed: %08x\n", hres); + ok(V_VT(&v) == VT_BSTR, "type failed: %d\n", V_VT(&v)); + ok(!strcmp_wa(V_BSTR(&v), "absolute"), "str=%s\n", dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_VT(&v) = VT_BSTR; + V_BSTR(&v) = NULL; + hres = IHTMLStyle_setAttribute(style, str, v, 1); + ok(hres == S_OK, "setAttribute failed: %08x\n", hres); + VariantClear(&v); + + SysFreeString(str); + hres = IHTMLStyle_QueryInterface(style, &IID_IHTMLStyle2, (void**)&style2); ok(hres == S_OK, "Could not get IHTMLStyle2 iface: %08x\n", hres); if(SUCCEEDED(hres)) {