[PATCH] Implement IHTMLStyle get/set Attribute
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Mon Jan 5 04:22:35 CST 2009
---
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 de363bb..516aa3e 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2745,6 +2745,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)) {
--
1.5.4.3
--------------090605080605060604060000--
More information about the wine-patches
mailing list