From d90c1e1c7fad0178a921d5737c9a4769c34046dc Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 5 Jun 2020 18:28:37 +0200 Subject: [PATCH] mshtml: Use default white value in IHTMLDocument2::get_bgColor. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49062 Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmldoc.c | 36 ++++++++++++++---------------------- dlls/mshtml/tests/dom.c | 8 ++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index a000884dc86..57ec662de84 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -711,34 +711,26 @@ static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v) static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p) { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - IHTMLElement *element = NULL; - IHTMLBodyElement *body; - HRESULT hr; + nsAString nsstr; + nsresult nsres; + HRESULT hres; 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(!This->doc_node->nsdoc) { + WARN("NULL nsdoc\n"); + return E_UNEXPECTED; } - if(!element) - { - FIXME("Empty body element.\n"); - return hr; + nsAString_Init(&nsstr, NULL); + nsres = nsIDOMHTMLDocument_GetBgColor(This->doc_node->nsdoc, &nsstr); + hres = return_nsstr_variant(nsres, &nsstr, NSSTR_COLOR, p); + if(hres == S_OK && V_VT(p) == VT_BSTR && !V_BSTR(p)) { + TRACE("default #ffffff"); + if(!(V_BSTR(p) = SysAllocString(L"#ffffff"))) + hres = E_OUTOFMEMORY; } - - 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; + return hres; } 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 25b8b3536c2..ff33ff76efe 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -6695,6 +6695,10 @@ static void test_body_funs(IHTMLBodyElement *body, IHTMLDocument2 *doc) ok(V_VT(&vDefaultbg) == VT_BSTR, "bstr != NULL\n"); ok(!V_BSTR(&vDefaultbg), "V_BSTR(bgColor) = %s\n", wine_dbgstr_w(V_BSTR(&vDefaultbg))); + hres = IHTMLDocument2_get_bgColor(doc, &vbg); + ok(hres == S_OK, "get_bgColor failed: %08x\n", hres); + ok(V_VT(&vbg) == VT_BSTR && V_BSTR(&vbg) && !wcscmp(V_BSTR(&vbg), L"#ffffff"), "bgColor = %s\n", wine_dbgstr_variant(&vbg)); + V_VT(&vbg) = VT_BSTR; V_BSTR(&vbg) = SysAllocString(L"red"); hres = IHTMLBodyElement_put_bgColor(body, vbg); @@ -6707,6 +6711,10 @@ static void test_body_funs(IHTMLBodyElement *body, IHTMLDocument2 *doc) ok(!lstrcmpW(V_BSTR(&vbg), L"#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_BSTR(&vbg) && !wcscmp(V_BSTR(&vbg), L"#ff0000"), "bgColor = %s\n", wine_dbgstr_variant(&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");