diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 9e32b27707b..d5b6cbe5c8f 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -901,17 +901,14 @@ static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p) return E_NOTIMPL; } -static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray) +static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln) { - HTMLDocument *This = HTMLDOC_THIS(iface); nsAString nsstr; VARIANT *var; - ULONG i; + ULONG i, argc; nsresult nsres; HRESULT hres; - TRACE("(%p)->(%p)\n", iface, psarray); - if(!This->nsdoc) { WARN("NULL nsdoc\n"); return E_UNEXPECTED; @@ -930,10 +927,14 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr nsAString_Init(&nsstr, NULL); - for(i=0; i < psarray->rgsabound[0].cElements; i++) { + 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)); - nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr); + if(!ln || i != argc-1) + nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr); + else + nsres = nsIDOMHTMLDocument_Writeln(This->nsdoc, &nsstr); if(NS_FAILED(nsres)) ERR("Write failed: %08x\n", nsres); }else { @@ -947,11 +948,22 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr return S_OK; } +static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray) +{ + HTMLDocument *This = HTMLDOC_THIS(iface); + + TRACE("(%p)->(%p)\n", iface, psarray); + + return document_write(This, psarray, FALSE); +} + static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray) { HTMLDocument *This = HTMLDOC_THIS(iface); - FIXME("(%p)->(%p)\n", This, psarray); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, psarray); + + return document_write(This, psarray, TRUE); } static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name, diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 551289668b7..266c63d100b 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -4165,7 +4165,7 @@ static void test_table_elem(IHTMLElement *elem) IHTMLTable_Release(table); } -static void doc_write(IHTMLDocument2 *doc, const char *text) +static void doc_write(IHTMLDocument2 *doc, BOOL ln, const char *text) { SAFEARRAYBOUND dim; SAFEARRAY *sa; @@ -4181,7 +4181,10 @@ static void doc_write(IHTMLDocument2 *doc, const char *text) V_BSTR(var) = str = a2bstr(text); SafeArrayUnaccessData(sa); - hres = IHTMLDocument2_write(doc, sa); + if(ln) + hres = IHTMLDocument2_writeln(doc, sa); + else + hres = IHTMLDocument2_write(doc, sa); ok(hres == S_OK, "write failed: %08x\n", hres); SysFreeString(str); @@ -4233,7 +4236,8 @@ 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, "