Jacek Caban : mshtml: Added HTMLWindow's IDispatch methods implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 31 07:54:39 CDT 2007


Module: wine
Branch: master
Commit: 4005cf72d6f79404a1df377ecb3379ea5bac5180
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4005cf72d6f79404a1df377ecb3379ea5bac5180

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Jul 31 00:53:10 2007 +0200

mshtml: Added HTMLWindow's IDispatch methods implementation.

---

 dlls/mshtml/htmlwindow.c     |   47 +++++++++++++++++++++++++++++++++---------
 dlls/mshtml/main.c           |   44 ++++++++++++++++++++++++++++++++++++++-
 dlls/mshtml/mshtml_private.h |    8 +++++++
 3 files changed, 88 insertions(+), 11 deletions(-)

diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c
index 4375901..83adbdc 100644
--- a/dlls/mshtml/htmlwindow.c
+++ b/dlls/mshtml/htmlwindow.c
@@ -98,16 +98,26 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, pctinfo);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, pctinfo);
+
+    *pctinfo = 1;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
                                               LCID lcid, ITypeInfo **ppTInfo)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
-    return E_NOTIMPL;
+    HRESULT hres;
+
+    TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
+
+    hres = get_typeinfo(IHTMLWindow2_tid, ppTInfo);
+    if(SUCCEEDED(hres))
+        ITypeInfo_AddRef(*ppTInfo);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
@@ -115,9 +125,17 @@ static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid
                                                 LCID lcid, DISPID *rgDispId)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
-                                        lcid, rgDispId);
-    return E_NOTIMPL;
+    ITypeInfo *typeinfo;
+    HRESULT hres;
+
+    TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
+          lcid, rgDispId);
+
+    hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
+    if(SUCCEEDED(hres))
+        hres = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
@@ -125,9 +143,18 @@ static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMembe
                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 {
     HTMLWindow *This = HTMLWINDOW2_THIS(iface);
-    FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
-            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
-    return E_NOTIMPL;
+    ITypeInfo *typeinfo;
+    HRESULT hres;
+
+    TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
+          lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
+
+    hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
+    if(SUCCEEDED(hres))
+        hres = ITypeInfo_Invoke(typeinfo, HTMLWINDOW2(This), dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index 3f8131c..41f32eb 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -51,10 +51,52 @@ DWORD mshtml_tls = 0;
 
 static HINSTANCE shdoclc = NULL;
 
+static ITypeLib *typelib;
+static ITypeInfo *typeinfos[LAST_tid];
+
+static const REFIID tid_ids[] = {
+    &IID_IHTMLWindow2
+};
+
+HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo)
+{
+    HRESULT hres;
+
+    if(!typelib) {
+        hres = LoadRegTypeLib(&LIBID_MSHTML, 4, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
+        if(FAILED(hres)) {
+            ERR("LoadRegTypeLib failed: %08x\n", hres);
+            return hres;
+        }
+    }
+
+    if(!typeinfos[tid]) {
+        hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], typeinfos+tid);
+        if(FAILED(hres)) {
+            ERR("GetTypeInfoOfGuid failed: %08x\n", hres);
+            return hres;
+        }
+    }
+
+    *typeinfo = typeinfos[tid];
+    return S_OK;
+}
+
 static void thread_detach(void)
 {
-    thread_data_t *thread_data = get_thread_data(FALSE);
+    thread_data_t *thread_data;
+
+    if(typelib) {
+        unsigned i;
+
+        for(i=0; i < sizeof(typeinfos)/sizeof(*typeinfos); i++)
+            if(typeinfos[i])
+                ITypeInfo_Release(typeinfos[i]);
+
+        ITypeLib_Release(typelib);
+    }
 
+    thread_data = get_thread_data(FALSE);
     if(!thread_data)
         return;
 
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 27f9ba7..0bd36a7 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -472,6 +472,14 @@ HWND get_thread_hwnd(void);
 void push_task(task_t*);
 void remove_doc_tasks(const HTMLDocument*);
 
+/* typelibs */
+enum tid_t {
+    IHTMLWindow2_tid,
+    LAST_tid
+};
+
+HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
+
 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);




More information about the wine-cvs mailing list