Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/mshtml/htmldoc.c | 48 +++++++++++++++++++++++++++++++++++++---- dlls/mshtml/tests/dom.c | 34 +++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 6 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 1ccfa3020a..594096ea45 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -680,15 +680,55 @@ 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; + 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; + } + + 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; + 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; + } + + 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 01c6191a6e..9e6c407451 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); @@ -7154,7 +7184,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);
Hi Alistair,
On 6/11/19 7:13 AM, Alistair Leslie-Hughes wrote:
--- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -680,15 +680,55 @@ 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;
- IHTMLBodyElement *body;
- HRESULT hr;
- TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
- hr = IHTMLDocument2_get_body(iface, &element);
Note that get_body() may return success with NULL body (for example for framesets). It's fine to just have FIXME for that case, but we shouldn't crash.
Thanks,
Jacek