Module: wine Branch: master Commit: 22ee077382b9c947639b7146f6fca8153fa7eabf URL: https://source.winehq.org/git/wine.git/?a=commit;h=22ee077382b9c947639b7146f...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Thu Jun 20 00:07:41 2019 +0000
mshtml: Implement IHTMLDocument2 put/get_bgColor.
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmldoc.c | 60 +++++++++++++++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 34 ++++++++++++++++++++++++++-- 2 files changed, 88 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index af99d64..87ee8e6 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -678,15 +678,67 @@ static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v) { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); - return E_NOTIMPL; + IHTMLElement *element = NULL; + IHTMLBodyElement *body; + HRESULT hr; + + TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); + + hr = IHTMLDocument2_get_body(iface, &element); + if (FAILED(hr)) + { + ERR("Failed to get body (0x%08x)\n", hr); + return hr; + } + + if(!element) + { + FIXME("Empty body element.\n"); + return hr; + } + + hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body); + if (SUCCEEDED(hr)) + { + hr = IHTMLBodyElement_put_bgColor(body, v); + IHTMLBodyElement_Release(body); + } + IHTMLElement_Release(element); + + return hr; }
static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p) { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + IHTMLElement *element = NULL; + IHTMLBodyElement *body; + HRESULT hr; + + TRACE("(%p)->(%p)\n", This, p); + + hr = IHTMLDocument2_get_body(iface, &element); + if (FAILED(hr)) + { + ERR("Failed to get body (0x%08x)\n", hr); + return hr; + } + + if(!element) + { + FIXME("Empty body element.\n"); + return hr; + } + + hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body); + if (SUCCEEDED(hr)) + { + hr = IHTMLBodyElement_get_bgColor(body, p); + IHTMLBodyElement_Release(body); + } + IHTMLElement_Release(element); + + return hr; }
static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index e152c4f..f6eebbc 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -6708,7 +6708,7 @@ static void _set_body_scroll(unsigned line, IHTMLBodyElement *body, const char * _test_body_scroll(line, body, val); }
-static void test_body_funs(IHTMLBodyElement *body) +static void test_body_funs(IHTMLBodyElement *body, IHTMLDocument2 *doc) { VARIANT vbg, vDefaultbg; HRESULT hres; @@ -6730,6 +6730,36 @@ static void test_body_funs(IHTMLBodyElement *body) ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); VariantClear(&vbg);
+ hres = IHTMLDocument2_get_bgColor(doc, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + /* Restore Original */ + hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vDefaultbg); + + /* Set via IHTMLDocument2 */ + V_VT(&vbg) = VT_BSTR; + V_BSTR(&vbg) = a2bstr("red"); + hres = IHTMLDocument2_put_bgColor(doc, vbg); + ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); + VariantClear(&vbg); + + hres = IHTMLBodyElement_get_bgColor(body, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + + hres = IHTMLDocument2_get_bgColor(doc, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR, "V_VT(&vbg) != VT_BSTR\n"); + ok(!strcmp_wa(V_BSTR(&vbg), "#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg))); + VariantClear(&vbg); + /* Restore Original */ hres = IHTMLBodyElement_put_bgColor(body, vDefaultbg); ok(hres == S_OK, "put_bgColor failed: %08x\n", hres); @@ -7161,7 +7191,7 @@ static void test_defaults(IHTMLDocument2 *doc) hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body); ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres); test_default_body(body); - test_body_funs(body); + test_body_funs(body, doc); IHTMLBodyElement_Release(body);
test_elem_set_outertext_fail(elem);