Jacek Caban : mshtml: Added support for IDispatchEx to HTMLSelectionObject object.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 11 11:04:45 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Nov 11 10:55:53 2014 +0100

mshtml: Added support for IDispatchEx to HTMLSelectionObject object.

---

 dlls/mshtml/mshtml_private.h |  1 +
 dlls/mshtml/selection.c      | 56 +++++++++++++++++++++++++++-----------------
 dlls/mshtml/tests/dom.c      |  2 ++
 3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 6346dac..011fa9a 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -174,6 +174,7 @@ typedef struct event_target_t event_target_t;
     XIID(IHTMLScreen) \
     XIID(IHTMLScriptElement) \
     XIID(IHTMLSelectElement) \
+    XIID(IHTMLSelectionObject) \
     XIID(IHTMLStorage) \
     XIID(IHTMLStyle) \
     XIID(IHTMLStyle2) \
diff --git a/dlls/mshtml/selection.c b/dlls/mshtml/selection.c
index db3b7b3..f34154b 100644
--- a/dlls/mshtml/selection.c
+++ b/dlls/mshtml/selection.c
@@ -32,6 +32,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
 typedef struct {
+    DispatchEx dispex;
     IHTMLSelectionObject IHTMLSelectionObject_iface;
 
     LONG ref;
@@ -52,26 +53,24 @@ static HRESULT WINAPI HTMLSelectionObject_QueryInterface(IHTMLSelectionObject *i
 {
     HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
 
-    *ppv = NULL;
+    TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
 
     if(IsEqualGUID(&IID_IUnknown, riid)) {
-        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
         *ppv = &This->IHTMLSelectionObject_iface;
     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
-        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
         *ppv = &This->IHTMLSelectionObject_iface;
     }else if(IsEqualGUID(&IID_IHTMLSelectionObject, riid)) {
-        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
         *ppv = &This->IHTMLSelectionObject_iface;
+    }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
+        return *ppv ? S_OK : E_NOINTERFACE;
+    }else {
+        *ppv = NULL;
+        WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
+        return E_NOINTERFACE;
     }
 
-    if(*ppv) {
-        IUnknown_AddRef((IUnknown*)*ppv);
-        return S_OK;
-    }
-
-    WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
-    return E_NOINTERFACE;
+    IUnknown_AddRef((IUnknown*)*ppv);
+    return S_OK;
 }
 
 static ULONG WINAPI HTMLSelectionObject_AddRef(IHTMLSelectionObject *iface)
@@ -96,6 +95,7 @@ static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface)
             nsISelection_Release(This->nsselection);
         if(This->doc)
             list_remove(&This->entry);
+        release_dispex(&This->dispex);
         heap_free(This);
     }
 
@@ -105,16 +105,16 @@ static ULONG WINAPI HTMLSelectionObject_Release(IHTMLSelectionObject *iface)
 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfoCount(IHTMLSelectionObject *iface, UINT *pctinfo)
 {
     HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
-    FIXME("(%p)->(%p)\n", This, pctinfo);
-    return E_NOTIMPL;
+
+    return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
 }
 
 static HRESULT WINAPI HTMLSelectionObject_GetTypeInfo(IHTMLSelectionObject *iface, UINT iTInfo,
                                               LCID lcid, ITypeInfo **ppTInfo)
 {
     HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
-    FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
-    return E_NOTIMPL;
+
+    return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
 }
 
 static HRESULT WINAPI HTMLSelectionObject_GetIDsOfNames(IHTMLSelectionObject *iface, REFIID riid,
@@ -122,9 +122,9 @@ static HRESULT WINAPI HTMLSelectionObject_GetIDsOfNames(IHTMLSelectionObject *if
                                                 LCID lcid, DISPID *rgDispId)
 {
     HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(iface);
-    FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
-          lcid, rgDispId);
-    return E_NOTIMPL;
+
+    return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
+            cNames, lcid, rgDispId);
 }
 
 static HRESULT WINAPI HTMLSelectionObject_Invoke(IHTMLSelectionObject *iface, DISPID dispIdMember,
@@ -132,9 +132,10 @@ static HRESULT WINAPI HTMLSelectionObject_Invoke(IHTMLSelectionObject *iface, DI
                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 {
     HTMLSelectionObject *This = impl_from_IHTMLSelectionObject(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;
+
+
+    return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
+            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
 }
 
 static HRESULT WINAPI HTMLSelectionObject_createRange(IHTMLSelectionObject *iface, IDispatch **range)
@@ -233,6 +234,17 @@ static const IHTMLSelectionObjectVtbl HTMLSelectionObjectVtbl = {
     HTMLSelectionObject_get_type
 };
 
+static const tid_t HTMLSelectionObject_iface_tids[] = {
+    IHTMLSelectionObject_tid,
+    0
+};
+static dispex_static_data_t HTMLSelectionObject_dispex = {
+    NULL,
+    IHTMLSelectionObject_tid,
+    NULL,
+    HTMLSelectionObject_iface_tids
+};
+
 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselection, IHTMLSelectionObject **ret)
 {
     HTMLSelectionObject *selection;
@@ -241,6 +253,8 @@ HRESULT HTMLSelectionObject_Create(HTMLDocumentNode *doc, nsISelection *nsselect
     if(!selection)
         return E_OUTOFMEMORY;
 
+    init_dispex(&selection->dispex, (IUnknown*)&selection->IHTMLSelectionObject_iface, &HTMLSelectionObject_dispex);
+
     selection->IHTMLSelectionObject_iface.lpVtbl = &HTMLSelectionObjectVtbl;
     selection->ref = 1;
     selection->nsselection = nsselection; /* We shouldn't call AddRef here */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index c4766dc..5dc0c4c 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -4975,6 +4975,8 @@ static void test_txtrange(IHTMLDocument2 *doc)
     hres = IHTMLDocument2_get_selection(doc, &selection);
     ok(hres == S_OK, "IHTMLDocument2_get_selection failed: %08x\n", hres);
 
+    test_disp((IUnknown*)selection, &IID_IHTMLSelectionObject, "[object]");
+
     hres = IHTMLSelectionObject_createRange(selection, &disp_range);
     ok(hres == S_OK, "IHTMLSelectionObject_createRange failed: %08x\n", hres);
     IHTMLSelectionObject_Release(selection);




More information about the wine-cvs mailing list