mshtml: Use stored nsdoc in IHTMLDocument2::write.

This commit is contained in:
Jacek Caban 2008-10-08 13:29:08 -05:00 committed by Alexandre Julliard
parent c5adad12fe
commit c451ac27f2
1 changed files with 6 additions and 19 deletions

View File

@ -757,8 +757,6 @@ static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
{
HTMLDocument *This = HTMLDOC_THIS(iface);
nsIDOMDocument *domdoc;
nsIDOMHTMLDocument *nsdoc;
nsAString nsstr;
VARIANT *var;
int i;
@ -767,29 +765,19 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr
TRACE("(%p)->(%p)\n", iface, psarray);
if(!This->nsdoc) {
WARN("NULL nsdoc\n");
return E_UNEXPECTED;
}
if(psarray->cDims != 1) {
FIXME("cDims=%d\n", psarray->cDims);
return E_INVALIDARG;
}
if(!This->nscontainer)
return S_OK;
nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &domdoc);
if(NS_FAILED(nsres)) {
ERR("GetDocument failed: %08x\n", nsres);
return S_OK;
}
nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIDOMHTMLDocument, (void**)&nsdoc);
nsIDOMDocument_Release(domdoc);
if(NS_FAILED(nsres))
return S_OK;
hres = SafeArrayAccessData(psarray, (void**)&var);
if(FAILED(hres)) {
WARN("SafeArrayAccessData failed: %08x\n", hres);
nsIDOMHTMLDocument_Release(nsdoc);
return hres;
}
@ -798,7 +786,7 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr
for(i=0; i < psarray->rgsabound[0].cElements; i++) {
if(V_VT(var+i) == VT_BSTR) {
nsAString_SetData(&nsstr, V_BSTR(var+i));
nsres = nsIDOMHTMLDocument_Write(nsdoc, &nsstr);
nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
if(NS_FAILED(nsres))
ERR("Write failed: %08x\n", nsres);
}else {
@ -808,7 +796,6 @@ static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarr
nsAString_Finish(&nsstr);
SafeArrayUnaccessData(psarray);
nsIDOMHTMLDocument_Release(nsdoc);
return S_OK;
}