Jacek Caban : mshtml: Use default white value in IHTMLDocument2::get_bgColor.

Alexandre Julliard julliard at winehq.org
Fri Jun 5 14:16:53 CDT 2020


Module: wine
Branch: master
Commit: d90c1e1c7fad0178a921d5737c9a4769c34046dc
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d90c1e1c7fad0178a921d5737c9a4769c34046dc

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Jun  5 18:28:37 2020 +0200

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 <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 a000884dc8..57ec662de8 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(!element)
-    {
-        FIXME("Empty body element.\n");
-        return hr;
+    if(!This->doc_node->nsdoc) {
+        WARN("NULL nsdoc\n");
+        return E_UNEXPECTED;
     }
 
-    hr = IHTMLElement_QueryInterface(element, &IID_IHTMLBodyElement, (void**)&body);
-    if (SUCCEEDED(hr))
-    {
-        hr = IHTMLBodyElement_get_bgColor(body, p);
-        IHTMLBodyElement_Release(body);
+    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;
     }
-    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 25b8b3536c..ff33ff76ef 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");




More information about the wine-cvs mailing list