From 44de20a0c7fb8c068e9c3af6a040afd91b890bc5 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 13 Jan 2009 18:30:17 +1100 Subject: [PATCH] mshtml: Implement IHTMLStyle get/put borderLeftStyle. --- dlls/mshtml/htmlstyle.c | 41 ++++++++++++++-- dlls/mshtml/htmlstyle.h | 1 + dlls/mshtml/tests/dom.c | 106 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 3453f7b2859..3c79ac4c725 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -45,6 +45,8 @@ static const WCHAR attrBorder[] = {'b','o','r','d','e','r',0}; static const WCHAR attrBorderLeft[] = {'b','o','r','d','e','r','-','l','e','f','t',0}; +static const WCHAR attrBorderLeftStyle[] = + {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0}; static const WCHAR attrBorderWidth[] = {'b','o','r','d','e','r','-','w','i','d','t','h',0}; static const WCHAR attrColor[] = @@ -105,6 +107,7 @@ static const struct{ {attrBackgroundImage, DISPID_IHTMLSTYLE_BACKGROUNDIMAGE}, {attrBorder, DISPID_IHTMLSTYLE_BORDER}, {attrBorderLeft, DISPID_IHTMLSTYLE_BORDERLEFT}, + {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE}, {attrBorderWidth, DISPID_IHTMLSTYLE_BORDERWIDTH}, {attrColor, DISPID_IHTMLSTYLE_COLOR}, {attrCursor, DISPID_IHTMLSTYLE_CURSOR}, @@ -413,6 +416,32 @@ static HRESULT get_nsstyle_pos(HTMLStyle *This, styleid_t sid, float *p) return hres; } +static BOOL is_valid_border_style(BSTR v) +{ + static const WCHAR styleNone[] = {'n','o','n','e',0}; + static const WCHAR styleDotted[] = {'d','o','t','t','e','d',0}; + static const WCHAR styleDashed[] = {'d','a','s','h','e','d',0}; + static const WCHAR styleSolid[] = {'s','o','l','i','d',0}; + static const WCHAR styleDouble[] = {'d','o','u','b','l','e',0}; + static const WCHAR styleGroove[] = {'g','r','o','o','v','e',0}; + static const WCHAR styleRidge[] = {'r','i','d','g','e',0}; + static const WCHAR styleInset[] = {'i','n','s','e','t',0}; + static const WCHAR styleOutset[] = {'o','u','t','s','e','t',0}; + + TRACE("%s\n", debugstr_w(v)); + + if(!v || strcmpiW(v, styleNone) == 0 || strcmpiW(v, styleDotted) == 0 || + strcmpiW(v, styleDashed) == 0 || strcmpiW(v, styleSolid) == 0 || + strcmpiW(v, styleDouble) == 0 || strcmpiW(v, styleGroove) == 0 || + strcmpiW(v, styleRidge) == 0 || strcmpiW(v, styleInset) == 0 || + strcmpiW(v, styleOutset) == 0 ) + { + return TRUE; + } + + return FALSE; +} + #define HTMLSTYLE_THIS(iface) DEFINE_THIS(HTMLStyle, HTMLStyle, iface) static HRESULT WINAPI HTMLStyle_QueryInterface(IHTMLStyle *iface, REFIID riid, void **ppv) @@ -1473,15 +1502,19 @@ static HRESULT WINAPI HTMLStyle_get_borderBottomStyle(IHTMLStyle *iface, BSTR *p static HRESULT WINAPI HTMLStyle_put_borderLeftStyle(IHTMLStyle *iface, BSTR v) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + if(!is_valid_border_style(v)) + return E_INVALIDARG; + + return set_style_attr(This, STYLEID_BORDER_LEFT_STYLE, v, 0); } static HRESULT WINAPI HTMLStyle_get_borderLeftStyle(IHTMLStyle *iface, BSTR *p) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + TRACE("(%p)->(%p)\n", This, p); + return get_style_attr(This, STYLEID_BORDER_LEFT_STYLE, p); } static HRESULT WINAPI HTMLStyle_put_width(IHTMLStyle *iface, VARIANT v) diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h index 2dedb03dc71..6ea5136041c 100644 --- a/dlls/mshtml/htmlstyle.h +++ b/dlls/mshtml/htmlstyle.h @@ -36,6 +36,7 @@ typedef enum { STYLEID_BACKGROUND_IMAGE, STYLEID_BORDER, STYLEID_BORDER_LEFT, + STYLEID_BORDER_LEFT_STYLE, STYLEID_BORDER_WIDTH, STYLEID_COLOR, STYLEID_CURSOR, diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 03068d19a84..3e9da25a809 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -1790,6 +1790,108 @@ static void _test_doc_set_title(unsigned line, IHTMLDocument2 *doc, const char * SysFreeString(tmp); } +#define test_border_styles(p, n) _test_border_styles(__LINE__, p, n) +static void _test_border_styles(unsigned line, IHTMLStyle *pStyle, BSTR Name) +{ + HRESULT hres; + DISPID dispid; + + hres = IHTMLStyle_GetIDsOfNames(pStyle, &IID_NULL, (LPOLESTR*)&Name, 1, + LOCALE_USER_DEFAULT, &dispid); + ok_(__FILE__,line) (hres == S_OK, "GetIDsOfNames: %08x\n", hres); + if(hres == S_OK) + { + DISPPARAMS params = {NULL,NULL,0,0}; + DISPID dispidNamed = DISPID_PROPERTYPUT; + VARIANT ret; + VARIANT vDefault; + VARIANTARG arg; + + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYGET, ¶ms, &vDefault, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "get_default. ret: %08x\n", hres); + + params.cArgs = 1; + params.cNamedArgs = 1; + params.rgdispidNamedArgs = &dispidNamed; + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("none"); + params.rgvarg = &arg; + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "none. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("dotted"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "dotted. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("dashed"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "dashed. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("solid"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "solid. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("double"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "double. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("groove"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "groove. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("ridge"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "ridge. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("inset"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "inset. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("outset"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "outset. ret: %08x\n", hres); + VariantClear(&arg); + + V_VT(&arg) = VT_BSTR; + V_BSTR(&arg) = a2bstr("invalid"); + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (FAILED(hres), "invalid value passed.\n"); + VariantClear(&arg); + + params.rgvarg = &vDefault; + hres = IHTMLStyle_Invoke(pStyle, dispid, &IID_NULL, LOCALE_SYSTEM_DEFAULT, + DISPATCH_PROPERTYPUT, ¶ms, &ret, NULL, NULL); + ok_(__FILE__,line) (hres == S_OK, "default. ret: %08x\n", hres); + } +} + static void test_elem_col_item(IHTMLElementCollection *col, LPCWSTR n, const elem_type_t *elem_types, long len) { @@ -2786,6 +2888,10 @@ static void test_default_style(IHTMLStyle *style) SysFreeString(str); + str = a2bstr("borderLeftStyle"); + test_border_styles(style, str); + 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)) {