[PATCH v4] mshtml: Implement IHTMLDocument2 put/get_bgColor
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Wed Jun 19 19:07:41 CDT 2019
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
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 af99d643ac..cfa21f912f 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 e152c4fc25..f6eebbc18b 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);
--
2.17.1
More information about the wine-devel
mailing list