Jacek Caban : mshmtl: Moved ICustomDoc implementation to HTMLDocumentObj.

Alexandre Julliard julliard at winehq.org
Thu Sep 17 13:52:46 CDT 2009


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Sep 16 22:14:05 2009 +0200

mshmtl: Moved ICustomDoc implementation to HTMLDocumentObj.

---

 dlls/mshtml/htmldoc.c        |   58 +++++++++++++++++++++++++++++++++++++----
 dlls/mshtml/mshtml_private.h |    2 +-
 dlls/mshtml/oleobj.c         |   41 -----------------------------
 dlls/mshtml/tests/dom.c      |    6 ++++
 4 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 3bd6ddf..4999e72 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -1682,9 +1682,6 @@ static BOOL htmldoc_qi(HTMLDocument *This, REFIID riid, void **ppv)
     }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
         TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppv);
         *ppv = PERSTRINIT(This);
-    }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
-        TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
-        *ppv = CUSTOMDOC(This);
     }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
         TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppv);
         *ppv = HTMLDOC(This);
@@ -1860,6 +1857,46 @@ HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocumentObj *doc_ob
     return S_OK;
 }
 
+/**********************************************************
+ * ICustomDoc implementation
+ */
+
+#define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocumentObj, CustomDoc, iface)
+
+static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
+{
+    HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
+    return IHTMLDocument2_QueryInterface(HTMLDOC(&This->basedoc), riid, ppv);
+}
+
+static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
+{
+    HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
+    return IHTMLDocument2_AddRef(HTMLDOC(&This->basedoc));
+}
+
+static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
+{
+    HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
+    return IHTMLDocument_Release(HTMLDOC(&This->basedoc));
+}
+
+static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
+{
+    HTMLDocumentObj *This = CUSTOMDOC_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, pUIHandler);
+    return E_NOTIMPL;
+}
+
+#undef CUSTOMDOC_THIS
+
+static const ICustomDocVtbl CustomDocVtbl = {
+    CustomDoc_QueryInterface,
+    CustomDoc_AddRef,
+    CustomDoc_Release,
+    CustomDoc_SetUIHandler
+};
+
 #define HTMLDOCOBJ_THIS(base) DEFINE_THIS2(HTMLDocumentObj, basedoc, base)
 
 static HRESULT HTMLDocumentObj_QueryInterface(HTMLDocument *base, REFIID riid, void **ppv)
@@ -1869,9 +1906,17 @@ static HRESULT HTMLDocumentObj_QueryInterface(HTMLDocument *base, REFIID riid, v
     if(htmldoc_qi(&This->basedoc, riid, ppv))
         return *ppv ? S_OK : E_NOINTERFACE;
 
-    FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
-    *ppv = NULL;
-    return E_NOINTERFACE;
+    if(IsEqualGUID(&IID_ICustomDoc, riid)) {
+        TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppv);
+        *ppv = CUSTOMDOC(This);
+    }else {
+        FIXME("Unimplemented interface %s\n", debugstr_guid(riid));
+        *ppv = NULL;
+        return E_NOINTERFACE;
+    }
+
+    IUnknown_AddRef((IUnknown*)*ppv);
+    return S_OK;
 }
 
 static ULONG HTMLDocumentObj_AddRef(HTMLDocument *base)
@@ -1952,6 +1997,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
 
     init_doc(&doc->basedoc, &HTMLDocumentObjVtbl);
 
+    doc->lpCustomDocVtbl = &CustomDocVtbl;
     doc->ref = 1;
     doc->basedoc.doc_obj = doc;
 
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 828aebb..eb85c42 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -274,7 +274,6 @@ struct HTMLDocument {
     const IOleControlVtbl                 *lpOleControlVtbl;
     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
-    const ICustomDocVtbl                  *lpCustomDocVtbl;
     const IDispatchExVtbl                 *lpIDispatchExVtbl;
     const ISupportErrorInfoVtbl           *lpSupportErrorInfoVtbl;
 
@@ -308,6 +307,7 @@ static inline ULONG htmldoc_release(HTMLDocument *This)
 
 struct HTMLDocumentObj {
     HTMLDocument basedoc;
+    const ICustomDocVtbl  *lpCustomDocVtbl;
 
     LONG ref;
 
diff --git a/dlls/mshtml/oleobj.c b/dlls/mshtml/oleobj.c
index 5a2f3de..e9cb204 100644
--- a/dlls/mshtml/oleobj.c
+++ b/dlls/mshtml/oleobj.c
@@ -705,46 +705,6 @@ static const IOleControlVtbl OleControlVtbl = {
     OleControl_FreezeEvents
 };
 
-/**********************************************************
- * ICustomDoc implementation
- */
-
-#define CUSTOMDOC_THIS(iface) DEFINE_THIS(HTMLDocument, CustomDoc, iface)
-
-static HRESULT WINAPI CustomDoc_QueryInterface(ICustomDoc *iface, REFIID riid, void **ppv)
-{
-    HTMLDocument *This = CUSTOMDOC_THIS(iface);
-    return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
-}
-
-static ULONG WINAPI CustomDoc_AddRef(ICustomDoc *iface)
-{
-    HTMLDocument *This = CUSTOMDOC_THIS(iface);
-    return IHTMLDocument2_AddRef(HTMLDOC(This));
-}
-
-static ULONG WINAPI CustomDoc_Release(ICustomDoc *iface)
-{
-    HTMLDocument *This = CUSTOMDOC_THIS(iface);
-    return IHTMLDocument_Release(HTMLDOC(This));
-}
-
-static HRESULT WINAPI CustomDoc_SetUIHandler(ICustomDoc *iface, IDocHostUIHandler *pUIHandler)
-{
-    HTMLDocument *This = CUSTOMDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, pUIHandler);
-    return E_NOTIMPL;
-}
-
-#undef CUSTOMDOC_THIS
-
-static const ICustomDocVtbl CustomDocVtbl = {
-    CustomDoc_QueryInterface,
-    CustomDoc_AddRef,
-    CustomDoc_Release,
-    CustomDoc_SetUIHandler
-};
-
 void HTMLDocument_LockContainer(HTMLDocumentObj *This, BOOL fLock)
 {
     IOleContainer *container;
@@ -766,5 +726,4 @@ void HTMLDocument_OleObj_Init(HTMLDocument *This)
     This->lpOleObjectVtbl = &OleObjectVtbl;
     This->lpOleDocumentVtbl = &OleDocumentVtbl;
     This->lpOleControlVtbl = &OleControlVtbl;
-    This->lpCustomDocVtbl = &CustomDocVtbl;
 }
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index bc6f699..5bbb54a 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -4095,6 +4095,7 @@ static void test_window(IHTMLDocument2 *doc)
     IHTMLWindow2 *window, *window2, *self;
     IHTMLDocument2 *doc2 = NULL;
     IDispatch *disp;
+    IUnknown *unk;
     BSTR str;
     HRESULT hres;
 
@@ -4110,6 +4111,11 @@ static void test_window(IHTMLDocument2 *doc)
     test_ifaces((IUnknown*)doc2, doc_node_iids);
     test_ifaces((IUnknown*)doc, doc_obj_iids);
 
+    unk = (void*)0xdeadbeef;
+    hres = IHTMLDocument2_QueryInterface(doc2, &IID_ICustomDoc, (void**)&unk);
+    ok(hres == E_NOINTERFACE, "QueryInterface(IID_ICustomDoc) returned: %08x\n", hres);
+    ok(!unk, "unk = %p\n", unk);
+
     IHTMLDocument_Release(doc2);
 
     hres = IHTMLWindow2_get_window(window, &window2);




More information about the wine-cvs mailing list