Jacek Caban : mshtml: Added get_childNodes implementation.

Alexandre Julliard julliard at winehq.org
Thu May 1 06:38:37 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Apr 30 18:17:34 2008 +0200

mshtml: Added get_childNodes implementation.

---

 dlls/mshtml/htmlnode.c |  171 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 169 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmlnode.c b/dlls/mshtml/htmlnode.c
index 7abf2ef..0f3e848 100644
--- a/dlls/mshtml/htmlnode.c
+++ b/dlls/mshtml/htmlnode.c
@@ -31,6 +31,157 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
 
+typedef struct {
+    const IHTMLDOMChildrenCollectionVtbl  *lpIHTMLDOMChildrenCollectionVtbl;
+
+    LONG ref;
+
+    /* FIXME: implement weak reference */
+    HTMLDocument *doc;
+
+    nsIDOMNodeList *nslist;
+} HTMLDOMChildrenCollection;
+
+#define HTMLCHILDCOL(x)  ((IHTMLDOMChildrenCollection*)  &(x)->lpIHTMLDOMChildrenCollectionVtbl)
+
+#define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface)
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+
+    *ppv = NULL;
+
+    if(IsEqualGUID(&IID_IUnknown, riid)) {
+        TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+        *ppv = HTMLCHILDCOL(This);
+    }else if(IsEqualGUID(&IID_IDispatch, riid)) {
+        TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
+        *ppv = HTMLCHILDCOL(This);
+    }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) {
+        TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv);
+        *ppv = HTMLCHILDCOL(This);
+    }
+
+    if(*ppv) {
+        IUnknown_AddRef((IUnknown*)*ppv);
+        return S_OK;
+    }
+
+    WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    LONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    LONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p) ref=%d\n", This, ref);
+
+    if(!ref) {
+        nsIDOMNodeList_Release(This->nslist);
+        heap_free(This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, pctinfo);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo,
+        LCID lcid, ITypeInfo **ppTInfo)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid,
+        LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
+          lcid, rgDispId);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection *iface, DISPID dispIdMember,
+        REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
+        VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_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;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, long *p)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%p)\n", This, p);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, long index, IDispatch **ppItem)
+{
+    HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
+    FIXME("(%p)->(%ld %p)\n", This, index, ppItem);
+    return E_NOTIMPL;
+}
+
+#undef HTMLCHILDCOL_THIS
+
+static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = {
+    HTMLDOMChildrenCollection_QueryInterface,
+    HTMLDOMChildrenCollection_AddRef,
+    HTMLDOMChildrenCollection_Release,
+    HTMLDOMChildrenCollection_GetTypeInfoCount,
+    HTMLDOMChildrenCollection_GetTypeInfo,
+    HTMLDOMChildrenCollection_GetIDsOfNames,
+    HTMLDOMChildrenCollection_Invoke,
+    HTMLDOMChildrenCollection_get_length,
+    HTMLDOMChildrenCollection__newEnum,
+    HTMLDOMChildrenCollection_item
+};
+
+static IHTMLDOMChildrenCollection *create_child_collection(HTMLDocument *doc, nsIDOMNodeList *nslist)
+{
+    HTMLDOMChildrenCollection *ret;
+
+    ret = heap_alloc_zero(sizeof(*ret));
+    ret->lpIHTMLDOMChildrenCollectionVtbl = &HTMLDOMChildrenCollectionVtbl;
+    ret->ref = 1;
+
+    nsIDOMNodeList_AddRef(nslist);
+    ret->nslist = nslist;
+    ret->doc = doc;
+
+    return HTMLCHILDCOL(ret);
+}
+
 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
 
 static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
@@ -117,6 +268,9 @@ static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p)
     case TEXT_NODE:
         *p = 3;
         break;
+    case COMMENT_NODE:
+        *p = 8;
+        break;
     default:
         /*
          * FIXME:
@@ -147,8 +301,21 @@ static HRESULT WINAPI HTMLDOMNode_hasChildNodes(IHTMLDOMNode *iface, VARIANT_BOO
 static HRESULT WINAPI HTMLDOMNode_get_childNodes(IHTMLDOMNode *iface, IDispatch **p)
 {
     HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsIDOMNodeList *nslist;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsres = nsIDOMNode_GetChildNodes(This->nsnode, &nslist);
+    if(NS_FAILED(nsres)) {
+        ERR("GetChildNodes failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    *p = (IDispatch*)create_child_collection(This->doc, nslist);
+    nsIDOMNodeList_Release(nslist);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDOMNode_get_attributes(IHTMLDOMNode *iface, IDispatch **p)




More information about the wine-cvs mailing list