Commit d90c1e1c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

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

parent 7f465761
......@@ -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)
......
......@@ -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);
......@@ -6709,6 +6713,10 @@ static void test_body_funs(IHTMLBodyElement *body, IHTMLDocument2 *doc)
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");
ok(!lstrcmpW(V_BSTR(&vbg), L"#ff0000"), "Unexpected bgcolor %s\n", wine_dbgstr_w(V_BSTR(&vbg)));
VariantClear(&vbg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment