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>
This commit is contained in:
Alistair Leslie-Hughes 2019-06-20 00:07:41 +00:00 committed by Alexandre Julliard
parent 328d002d84
commit 22ee077382
2 changed files with 88 additions and 6 deletions

View File

@ -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)

View File

@ -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);