From 20bd88895c5038fcae8afdc6b01ed4de7c9896a6 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 4 Feb 2009 16:32:31 +1100 Subject: [PATCH] mshtml: Implement IHTMLStyle_put_fontWeight. --- dlls/mshtml/htmlstyle.c | 31 +++++++++++++++-- dlls/mshtml/tests/dom.c | 76 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c index ad9d09532ec..2d6703a5535 100644 --- a/dlls/mshtml/htmlstyle.c +++ b/dlls/mshtml/htmlstyle.c @@ -618,8 +618,35 @@ static HRESULT WINAPI HTMLStyle_get_fontVariant(IHTMLStyle *iface, BSTR *p) static HRESULT WINAPI HTMLStyle_put_fontWeight(IHTMLStyle *iface, BSTR v) { HTMLStyle *This = HTMLSTYLE_THIS(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(v)); - return E_NOTIMPL; + static const WCHAR styleBold[] = {'b','o','l','d',0}; + static const WCHAR styleBolder[] = {'b','o','l','d','e','r',0}; + static const WCHAR styleLighter[] = {'l','i','g','h','t','e','r',0}; + static const WCHAR style100[] = {'1','0','0',0}; + static const WCHAR style200[] = {'2','0','0',0}; + static const WCHAR style300[] = {'3','0','0',0}; + static const WCHAR style400[] = {'4','0','0',0}; + static const WCHAR style500[] = {'5','0','0',0}; + static const WCHAR style600[] = {'6','0','0',0}; + static const WCHAR style700[] = {'7','0','0',0}; + static const WCHAR style800[] = {'8','0','0',0}; + static const WCHAR style900[] = {'9','0','0',0}; + + TRACE("(%p)->(%s)\n", This, debugstr_w(v)); + + /* fontWeight can only be one of the following */ + if(!v || strcmpiW(szNormal, v) == 0 || strcmpiW(styleBold, v) == 0 || + strcmpiW(styleBolder, v) == 0 || strcmpiW(styleLighter, v) == 0 || + strcmpiW(style100, v) == 0 || strcmpiW(style200, v) == 0 || + strcmpiW(style300, v) == 0 || strcmpiW(style400, v) == 0 || + strcmpiW(style500, v) == 0 || strcmpiW(style600, v) == 0 || + strcmpiW(style700, v) == 0 || strcmpiW(style800, v) == 0 || + strcmpiW(style900, v) == 0 + ) + { + return set_nsstyle_attr(This->nsstyle, STYLEID_FONT_WEIGHT, v, 0); + } + + return E_INVALIDARG; } static HRESULT WINAPI HTMLStyle_get_fontWeight(IHTMLStyle *iface, BSTR *p) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 62a07bcaffc..5118d63c820 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -2431,6 +2431,82 @@ static void test_default_style(IHTMLStyle *style) ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres); ok(!str, "fontWeight = %s\n", dbgstr_w(str)); + hres = IHTMLStyle_get_fontWeight(style, &sDefault); + ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres); + + str = a2bstr("test"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == E_INVALIDARG, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("bold"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("bolder"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("lighter"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("100"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("200"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("300"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("400"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("500"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("600"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("700"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("800"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + str = a2bstr("900"); + hres = IHTMLStyle_put_fontWeight(style, str); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + SysFreeString(str); + + hres = IHTMLStyle_get_fontWeight(style, &str); + ok(hres == S_OK, "get_fontWeight failed: %08x\n", hres); + ok(!strcmp_wa(str, "900"), "str != style900\n"); + SysFreeString(str); + + hres = IHTMLStyle_put_fontWeight(style, sDefault); + ok(hres == S_OK, "put_fontWeight failed: %08x\n", hres); + /* font Variant */ hres = IHTMLStyle_get_fontVariant(style, NULL); ok(hres == E_INVALIDARG, "get_fontVariant failed: %08x\n", hres);