From d97b4d260ee921888680c946f8877cbf58965ffe Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 1 Dec 2009 14:04:38 -0600 Subject: [PATCH] mshtml: Implement IHTMLStyle::{get, put}_border{Top, Bottom, Right}. --- dlls/mshtml/htmlstyle.c | 33 ++++++++----- dlls/mshtml/htmlstyle.h | 3 ++ dlls/mshtml/tests/dom.c | 102 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 126 insertions(+), 12 deletions(-) diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index 13ac74e124b..7a43701f605 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -49,6 +49,8 @@ static const WCHAR attrBackgroundRepeat[] = {'b','a','c','k','g','r','o','u','n','d','-','r','e','p','e','a','t',0}; static const WCHAR attrBorder[] = {'b','o','r','d','e','r',0}; +static const WCHAR attrBorderBottom[] = + {'b','o','r','d','e','r','-','b','o','t','t','o','m',0}; static const WCHAR attrBorderBottomColor[] = {'b','o','r','d','e','r','-','b','o','t','t','o','m','-','c','o','l','o','r',0}; static const WCHAR attrBorderBottomStyle[] = @@ -65,12 +67,16 @@ static const WCHAR attrBorderLeftStyle[] = {'b','o','r','d','e','r','-','l','e','f','t','-','s','t','y','l','e',0}; static const WCHAR attrBorderLeftWidth[] = {'b','o','r','d','e','r','-','l','e','f','t','-','w','i','d','t','h',0}; +static const WCHAR attrBorderRight[] = + {'b','o','r','d','e','r','-','r','i','g','h','t',0}; static const WCHAR attrBorderRightColor[] = {'b','o','r','d','e','r','-','r','i','g','h','t','-','c','o','l','o','r',0}; static const WCHAR attrBorderRightStyle[] = {'b','o','r','d','e','r','-','r','i','g','h','t','-','s','t','y','l','e',0}; static const WCHAR attrBorderRightWidth[] = {'b','o','r','d','e','r','-','r','i','g','h','t','-','w','i','d','t','h',0}; +static const WCHAR attrBorderTop[] = + {'b','o','r','d','e','r','-','t','o','p',0}; static const WCHAR attrBorderTopColor[] = {'b','o','r','d','e','r','-','t','o','p','-','c','o','l','o','r',0}; static const WCHAR attrBorderStyle[] = @@ -167,6 +173,7 @@ static const struct{ {attrBackgroundPositionY, DISPID_IHTMLSTYLE_BACKGROUNDPOSITIONY}, {attrBackgroundRepeat, DISPID_IHTMLSTYLE_BACKGROUNDREPEAT}, {attrBorder, DISPID_IHTMLSTYLE_BORDER}, + {attrBorderBottom, DISPID_IHTMLSTYLE_BORDERBOTTOM}, {attrBorderBottomColor, DISPID_IHTMLSTYLE_BORDERBOTTOMCOLOR}, {attrBorderBottomStyle, DISPID_IHTMLSTYLE_BORDERBOTTOMSTYLE}, {attrBorderBottomWidth, DISPID_IHTMLSTYLE_BORDERBOTTOMWIDTH}, @@ -175,10 +182,12 @@ static const struct{ {attrBorderLeftColor, DISPID_IHTMLSTYLE_BORDERLEFTCOLOR}, {attrBorderLeftStyle, DISPID_IHTMLSTYLE_BORDERLEFTSTYLE}, {attrBorderLeftWidth, DISPID_IHTMLSTYLE_BORDERLEFTWIDTH}, + {attrBorderRight, DISPID_IHTMLSTYLE_BORDERRIGHT}, {attrBorderRightColor, DISPID_IHTMLSTYLE_BORDERRIGHTCOLOR}, {attrBorderRightStyle, DISPID_IHTMLSTYLE_BORDERRIGHTSTYLE}, {attrBorderRightWidth, DISPID_IHTMLSTYLE_BORDERRIGHTWIDTH}, {attrBorderStyle, DISPID_IHTMLSTYLE_BORDERSTYLE}, + {attrBorderTop, DISPID_IHTMLSTYLE_BORDERTOP}, {attrBorderTopColor, DISPID_IHTMLSTYLE_BORDERTOPCOLOR}, {attrBorderTopStyle, DISPID_IHTMLSTYLE_BORDERTOPSTYLE}, {attrBorderTopWidth, DISPID_IHTMLSTYLE_BORDERTOPWIDTH}, @@ -1433,43 +1442,43 @@ static HRESULT WINAPI HTMLStyle_get_border(IHTMLStyle *iface, BSTR *p) static HRESULT WINAPI HTMLStyle_put_borderTop(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)); + return set_style_attr(This, STYLEID_BORDER_TOP, v, ATTR_FIX_PX); } static HRESULT WINAPI HTMLStyle_get_borderTop(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_TOP, p); } static HRESULT WINAPI HTMLStyle_put_borderRight(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)); + return set_style_attr(This, STYLEID_BORDER_RIGHT, v, ATTR_FIX_PX); } static HRESULT WINAPI HTMLStyle_get_borderRight(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_RIGHT, p); } static HRESULT WINAPI HTMLStyle_put_borderBottom(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)); + return set_style_attr(This, STYLEID_BORDER_BOTTOM, v, ATTR_FIX_PX); } static HRESULT WINAPI HTMLStyle_get_borderBottom(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_BOTTOM, p); } static HRESULT WINAPI HTMLStyle_put_borderLeft(IHTMLStyle *iface, BSTR v) diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h index 4252caa572d..7168eec429d 100644 --- a/dlls/mshtml/htmlstyle.h +++ b/dlls/mshtml/htmlstyle.h @@ -42,6 +42,7 @@ typedef enum { STYLEID_BACKGROUND_POSITION_Y, STYLEID_BACKGROUND_REPEAT, STYLEID_BORDER, + STYLEID_BORDER_BOTTOM, STYLEID_BORDER_BOTTOM_COLOR, STYLEID_BORDER_BOTTOM_STYLE, STYLEID_BORDER_BOTTOM_WIDTH, @@ -50,10 +51,12 @@ typedef enum { STYLEID_BORDER_LEFT_COLOR, STYLEID_BORDER_LEFT_STYLE, STYLEID_BORDER_LEFT_WIDTH, + STYLEID_BORDER_RIGHT, STYLEID_BORDER_RIGHT_COLOR, STYLEID_BORDER_RIGHT_STYLE, STYLEID_BORDER_RIGHT_WIDTH, STYLEID_BORDER_STYLE, + STYLEID_BORDER_TOP, STYLEID_BORDER_TOP_COLOR, STYLEID_BORDER_TOP_STYLE, STYLEID_BORDER_TOP_WIDTH, diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index e0e1413b097..41faa94d095 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4285,6 +4285,108 @@ static void test_default_style(IHTMLStyle *style) ok(hres == S_OK, "put_borderColor failed: %08x\n", hres); SysFreeString(sDefault); + /* BorderRight */ + hres = IHTMLStyle_get_borderRight(style, &sDefault); + ok(hres == S_OK, "get_borderRight failed: %08x\n", hres); + + str = a2bstr("thick dotted red"); + hres = IHTMLStyle_put_borderRight(style, str); + ok(hres == S_OK, "put_borderRight failed: %08x\n", hres); + SysFreeString(str); + + /* IHTMLStyle_get_borderRight appears to have a bug where + it returns the first letter of the color. So we check + each style individually. + */ + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderRightColor(style, &v); + todo_wine ok(hres == S_OK, "get_borderRightColor failed: %08x\n", hres); + todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderRightWidth(style, &v); + ok(hres == S_OK, "get_borderRightWidth failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + hres = IHTMLStyle_get_borderRightStyle(style, &str); + ok(hres == S_OK, "get_borderRightStyle failed: %08x\n", hres); + ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IHTMLStyle_put_borderRight(style, sDefault); + ok(hres == S_OK, "put_borderRight failed: %08x\n", hres); + SysFreeString(sDefault); + + /* BorderTop */ + hres = IHTMLStyle_get_borderTop(style, &sDefault); + ok(hres == S_OK, "get_borderTop failed: %08x\n", hres); + + str = a2bstr("thick dotted red"); + hres = IHTMLStyle_put_borderTop(style, str); + ok(hres == S_OK, "put_borderTop failed: %08x\n", hres); + SysFreeString(str); + + /* IHTMLStyle_get_borderTop appears to have a bug where + it returns the first letter of the color. So we check + each style individually. + */ + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderTopColor(style, &v); + todo_wine ok(hres == S_OK, "get_borderTopColor failed: %08x\n", hres); + todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderTopWidth(style, &v); + ok(hres == S_OK, "get_borderTopWidth failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + hres = IHTMLStyle_get_borderTopStyle(style, &str); + ok(hres == S_OK, "get_borderTopStyle failed: %08x\n", hres); + ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IHTMLStyle_put_borderTop(style, sDefault); + ok(hres == S_OK, "put_borderTop failed: %08x\n", hres); + SysFreeString(sDefault); + + /* BorderBottom */ + hres = IHTMLStyle_get_borderBottom(style, &sDefault); + ok(hres == S_OK, "get_borderBottom failed: %08x\n", hres); + + str = a2bstr("thick dotted red"); + hres = IHTMLStyle_put_borderBottom(style, str); + ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres); + SysFreeString(str); + + /* IHTMLStyle_get_borderBottom appears to have a bug where + it returns the first letter of the color. So we check + each style individually. + */ + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderBottomColor(style, &v); + todo_wine ok(hres == S_OK, "get_borderBottomColor failed: %08x\n", hres); + todo_wine ok(!strcmp_wa(V_BSTR(&v), "red"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + V_BSTR(&v) = NULL; + hres = IHTMLStyle_get_borderBottomWidth(style, &v); + ok(hres == S_OK, "get_borderBottomWidth failed: %08x\n", hres); + ok(!strcmp_wa(V_BSTR(&v), "thick"), "str=%s\n", wine_dbgstr_w(V_BSTR(&v))); + VariantClear(&v); + + hres = IHTMLStyle_get_borderBottomStyle(style, &str); + ok(hres == S_OK, "get_borderBottomStyle failed: %08x\n", hres); + ok(!strcmp_wa(str, "dotted"), "str=%s\n", wine_dbgstr_w(str)); + SysFreeString(str); + + hres = IHTMLStyle_put_borderBottom(style, sDefault); + ok(hres == S_OK, "put_borderBottom failed: %08x\n", hres); + SysFreeString(sDefault); + /* BorderLeft */ hres = IHTMLStyle_get_borderLeft(style, &sDefault); ok(hres == S_OK, "get_borderLeft failed: %08x\n", hres);