mshtml: Implement IHTMLStyle get/set Attribute.

This commit is contained in:
Alistair Leslie-Hughes 2009-01-05 21:22:35 +11:00 committed by Alexandre Julliard
parent e50e78f1cb
commit bb829372f1
2 changed files with 99 additions and 6 deletions

View File

@ -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, &params, &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, &params, AttributeValue, NULL, NULL);
}
else
{
FIXME("Custom attributes not supported.\n");
}
return hres;
}
static HRESULT WINAPI HTMLStyle_removeAttribute(IHTMLStyle *iface, BSTR strAttributeName,

View File

@ -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)) {