Jacek Caban : shdocvw: Return IHTMLDocument2's IDispatch in get_Document.
Alexandre Julliard
julliard at winehq.org
Mon Jun 21 11:07:04 CDT 2010
Module: wine
Branch: master
Commit: 2c354b8bbbd4f59962673894caa8f188cc682eca
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2c354b8bbbd4f59962673894caa8f188cc682eca
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sun Jun 20 14:40:09 2010 +0200
shdocvw: Return IHTMLDocument2's IDispatch in get_Document.
---
dlls/mshtml/tests/htmldoc.c | 5 +++++
dlls/shdocvw/tests/webbrowser.c | 6 ++++++
dlls/shdocvw/webbrowser.c | 22 +++++++++++++++++++---
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/tests/htmldoc.c b/dlls/mshtml/tests/htmldoc.c
index 319e5fd..2d51262 100644
--- a/dlls/mshtml/tests/htmldoc.c
+++ b/dlls/mshtml/tests/htmldoc.c
@@ -4515,6 +4515,11 @@ static void test_QueryInterface(IHTMLDocument2 *doc)
hres = IUnknown_QueryInterface(doc, &IID_IStdMarshalInfo, (void**)&qi);
ok(hres == E_NOINTERFACE, "QueryInterface returned %08x, expected E_NOINTERFACE\n", hres);
ok(qi == NULL, "qi=%p, expected NULL\n", qi);
+
+ hres = IUnknown_QueryInterface(doc, &IID_IDispatch, (void**)&qi);
+ ok(hres == S_OK, "Could not get IDispatch interface: %08x\n", hres);
+ ok(qi != (IUnknown*)doc, "disp == doc\n");
+ IUnknown_Release(qi);
}
static void init_test(enum load_state_t ls) {
diff --git a/dlls/shdocvw/tests/webbrowser.c b/dlls/shdocvw/tests/webbrowser.c
index 17189fc..15fc1ec 100644
--- a/dlls/shdocvw/tests/webbrowser.c
+++ b/dlls/shdocvw/tests/webbrowser.c
@@ -2369,6 +2369,7 @@ static void test_IServiceProvider(IUnknown *unk)
#define get_document(u) _get_document(__LINE__,u)
static IDispatch *_get_document(unsigned line, IUnknown *unk)
{
+ IHTMLDocument2 *html_doc;
IWebBrowser2 *wb;
IDispatch *disp;
HRESULT hres;
@@ -2382,6 +2383,11 @@ static IDispatch *_get_document(unsigned line, IUnknown *unk)
ok_(__FILE__,line)(hres == S_OK, "get_Document failed: %08x\n", hres);
ok_(__FILE__,line)(disp != NULL, "doc_disp == NULL\n");
+ hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
+ ok_(__FILE__,line)(hres == S_OK, "Could not get IHTMLDocument iface: %08x\n", hres);
+ ok(disp == (IDispatch*)html_doc, "disp != html_doc\n");
+ IHTMLDocument_Release(html_doc);
+
return disp;
}
diff --git a/dlls/shdocvw/webbrowser.c b/dlls/shdocvw/webbrowser.c
index 0c26a83..20d39bb 100644
--- a/dlls/shdocvw/webbrowser.c
+++ b/dlls/shdocvw/webbrowser.c
@@ -22,6 +22,7 @@
#include "wine/debug.h"
#include "shdocvw.h"
#include "exdispid.h"
+#include "mshtml.h"
WINE_DEFAULT_DEBUG_CHANNEL(shdocvw);
@@ -334,13 +335,28 @@ static HRESULT WINAPI WebBrowser_get_Container(IWebBrowser2 *iface, IDispatch **
static HRESULT WINAPI WebBrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
{
WebBrowser *This = WEBBROWSER_THIS(iface);
+ IDispatch *disp = NULL;
TRACE("(%p)->(%p)\n", This, ppDisp);
- *ppDisp = NULL;
- if(This->doc_host.document)
- IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)ppDisp);
+ if(This->doc_host.document) {
+ HRESULT hres;
+
+ hres = IUnknown_QueryInterface(This->doc_host.document, &IID_IDispatch, (void**)&disp);
+ if(SUCCEEDED(hres)) {
+ IDispatch *html_doc;
+
+ /* Some broken apps cast returned IDispatch to IHTMLDocument2
+ * without QueryInterface call */
+ hres = IDispatch_QueryInterface(disp, &IID_IHTMLDocument2, (void**)&html_doc);
+ if(SUCCEEDED(hres)) {
+ IDispatch_Release(disp);
+ disp = html_doc;
+ }
+ }
+ }
+ *ppDisp = disp;
return S_OK;
}
More information about the wine-cvs
mailing list