mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
mshtml: Accept different VARIANT types in document_write.
This commit is contained in:
parent
6c2235cf98
commit
f6980025b9
2 changed files with 60 additions and 13 deletions
|
@ -799,8 +799,8 @@ static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
|
|||
|
||||
static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
|
||||
{
|
||||
VARIANT *var, tmp;
|
||||
nsAString nsstr;
|
||||
VARIANT *var;
|
||||
ULONG i, argc;
|
||||
nsresult nsres;
|
||||
HRESULT hres;
|
||||
|
@ -824,27 +824,38 @@ static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
|
|||
return hres;
|
||||
}
|
||||
|
||||
nsAString_Init(&nsstr, NULL);
|
||||
V_VT(&tmp) = VT_EMPTY;
|
||||
|
||||
argc = psarray->rgsabound[0].cElements;
|
||||
for(i=0; i < argc; i++) {
|
||||
if(V_VT(var+i) == VT_BSTR) {
|
||||
nsAString_SetData(&nsstr, V_BSTR(var+i));
|
||||
if(!ln || i != argc-1)
|
||||
nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
|
||||
else
|
||||
nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
|
||||
if(NS_FAILED(nsres))
|
||||
ERR("Write failed: %08x\n", nsres);
|
||||
nsAString_InitDepend(&nsstr, V_BSTR(var+i));
|
||||
}else {
|
||||
FIXME("unsupported arg[%d] = %s\n", i, debugstr_variant(var+i));
|
||||
hres = VariantChangeType(&tmp, var+i, 0, VT_BSTR);
|
||||
if(FAILED(hres)) {
|
||||
WARN("Could not convert %s to string\n", debugstr_variant(var+i));
|
||||
break;
|
||||
}
|
||||
nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
|
||||
}
|
||||
|
||||
if(!ln || i != argc-1)
|
||||
nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
|
||||
else
|
||||
nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, NULL /* FIXME! */);
|
||||
nsAString_Finish(&nsstr);
|
||||
if(V_VT(var+i) != VT_BSTR)
|
||||
VariantClear(&tmp);
|
||||
if(NS_FAILED(nsres)) {
|
||||
ERR("Write failed: %08x\n", nsres);
|
||||
hres = E_FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nsAString_Finish(&nsstr);
|
||||
SafeArrayUnaccessData(psarray);
|
||||
|
||||
return S_OK;
|
||||
return hres;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
|
||||
|
|
|
@ -4783,6 +4783,34 @@ static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text)
|
|||
SafeArrayDestroy(sa);
|
||||
}
|
||||
|
||||
static void doc_complex_write(IHTMLDocument2 *doc)
|
||||
{
|
||||
SAFEARRAYBOUND dim = {5, 0};
|
||||
SAFEARRAY *sa;
|
||||
VARIANT *args;
|
||||
HRESULT hres;
|
||||
|
||||
sa = SafeArrayCreate(VT_VARIANT, 1, &dim);
|
||||
SafeArrayAccessData(sa, (void**)&args);
|
||||
|
||||
V_VT(args) = VT_BSTR;
|
||||
V_BSTR(args) = a2bstr("<body i4val=\"");
|
||||
V_VT(args+1) = VT_I4;
|
||||
V_I4(args+1) = 4;
|
||||
V_VT(args+2) = VT_BSTR;
|
||||
V_BSTR(args+2) = a2bstr("\" r8val=\"");
|
||||
V_VT(args+3) = VT_R8;
|
||||
V_R8(args+3) = 3.14;
|
||||
V_VT(args+4) = VT_BSTR;
|
||||
V_BSTR(args+4) = a2bstr("\">");
|
||||
SafeArrayUnaccessData(sa);
|
||||
|
||||
hres = IHTMLDocument2_write(doc, sa);
|
||||
ok(hres == S_OK, "write failed: %08x\n", hres);
|
||||
|
||||
SafeArrayDestroy(sa);
|
||||
}
|
||||
|
||||
static void test_frame_doc(IUnknown *frame_elem, BOOL iframe)
|
||||
{
|
||||
IHTMLDocument2 *window_doc, *elem_doc;
|
||||
|
@ -4823,6 +4851,7 @@ static void test_iframe_elem(IHTMLElement *elem)
|
|||
IHTMLDocument2 *content_doc, *owner_doc;
|
||||
IHTMLElementCollection *col;
|
||||
IHTMLWindow2 *content_window;
|
||||
IHTMLElement *body;
|
||||
IDispatch *disp;
|
||||
VARIANT errv;
|
||||
BSTR str;
|
||||
|
@ -4854,7 +4883,9 @@ static void test_iframe_elem(IHTMLElement *elem)
|
|||
ok(iface_cmp((IUnknown*)disp, (IUnknown*)content_window), "disp != content_window\n");
|
||||
IDispatch_Release(disp);
|
||||
|
||||
doc_write(content_doc, FALSE, "<html><head><title>test</title></head><body><br /></body>");
|
||||
doc_write(content_doc, FALSE, "<html><head><title>test</title></head>");
|
||||
doc_complex_write(content_doc);
|
||||
doc_write(content_doc, TRUE, "<br />");
|
||||
doc_write(content_doc, TRUE, "</html>");
|
||||
|
||||
hres = IHTMLDocument2_get_all(content_doc, &col);
|
||||
|
@ -4862,6 +4893,11 @@ static void test_iframe_elem(IHTMLElement *elem)
|
|||
test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
|
||||
IHTMLElementCollection_Release(col);
|
||||
|
||||
body = doc_get_body(content_doc);
|
||||
test_elem_attr(body, "i4val", "4");
|
||||
test_elem_attr(body, "r8val", "3.14");
|
||||
IHTMLElement_Release(body);
|
||||
|
||||
hres = IHTMLDocument2_close(content_doc);
|
||||
ok(hres == S_OK, "close failed: %08x\n", hres);
|
||||
|
||||
|
|
Loading…
Reference in a new issue