2 * Copyright 2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 static HTMLDOMNode *get_node_obj(HTMLDocument*,IUnknown*);
38 const IHTMLDOMChildrenCollectionVtbl *lpIHTMLDOMChildrenCollectionVtbl;
42 /* FIXME: implement weak reference */
45 nsIDOMNodeList *nslist;
46 } HTMLDOMChildrenCollection;
48 #define HTMLCHILDCOL(x) ((IHTMLDOMChildrenCollection*) &(x)->lpIHTMLDOMChildrenCollectionVtbl)
50 #define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface)
52 static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv)
54 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
58 if(IsEqualGUID(&IID_IUnknown, riid)) {
59 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
60 *ppv = HTMLCHILDCOL(This);
61 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
62 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
63 *ppv = HTMLCHILDCOL(This);
64 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
65 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
66 *ppv = DISPATCHEX(&This->dispex);
67 }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) {
68 TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv);
69 *ppv = HTMLCHILDCOL(This);
73 IUnknown_AddRef((IUnknown*)*ppv);
77 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
81 static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface)
83 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
84 LONG ref = InterlockedIncrement(&This->ref);
86 TRACE("(%p) ref=%d\n", This, ref);
91 static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface)
93 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
94 LONG ref = InterlockedDecrement(&This->ref);
96 TRACE("(%p) ref=%d\n", This, ref);
99 nsIDOMNodeList_Release(This->nslist);
106 static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo)
108 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
109 FIXME("(%p)->(%p)\n", This, pctinfo);
113 static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo,
114 LCID lcid, ITypeInfo **ppTInfo)
116 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
117 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
121 static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid,
122 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
124 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
125 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
130 static HRESULT WINAPI HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection *iface, DISPID dispIdMember,
131 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
132 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
134 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
135 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
136 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, long *p)
142 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
145 TRACE("(%p)->(%p)\n", This, p);
147 nsIDOMNodeList_GetLength(This->nslist, &length);
152 static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
154 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
155 FIXME("(%p)->(%p)\n", This, p);
159 static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, long index, IDispatch **ppItem)
161 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
162 nsIDOMNode *nsnode = NULL;
166 TRACE("(%p)->(%ld %p)\n", This, index, ppItem);
168 nsIDOMNodeList_GetLength(This->nslist, &length);
169 if(index < 0 || index > length)
172 nsres = nsIDOMNodeList_Item(This->nslist, index, &nsnode);
173 if(NS_FAILED(nsres) || !nsnode) {
174 ERR("Item failed: %08x\n", nsres);
178 *ppItem = (IDispatch*)get_node(This->doc, nsnode, TRUE);
179 IDispatch_AddRef(*ppItem);
183 #define DISPID_CHILDCOL_0 MSHTML_DISPID_CUSTOM_MIN
185 static HRESULT HTMLDOMChildrenCollection_get_dispid(IUnknown *iface, BSTR name, DWORD flags, DISPID *dispid)
187 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
192 for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
193 idx = idx*10 + (*ptr-'0');
195 return DISP_E_UNKNOWNNAME;
197 nsIDOMNodeList_GetLength(This->nslist, &len);
199 return DISP_E_UNKNOWNNAME;
201 *dispid = DISPID_CHILDCOL_0 + idx;
202 TRACE("ret %x\n", *dispid);
206 static HRESULT HTMLDOMChildrenCollection_invoke(IUnknown *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
207 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
209 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
211 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
214 case INVOKE_PROPERTYGET: {
215 IDispatch *disp = NULL;
218 hres = IHTMLDOMChildrenCollection_item(HTMLCHILDCOL(This), id - DISPID_CHILDCOL_0, &disp);
222 V_VT(res) = VT_DISPATCH;
223 V_DISPATCH(res) = disp;
228 FIXME("unimplemented flags %x\n", flags);
235 #undef HTMLCHILDCOL_THIS
237 static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = {
238 HTMLDOMChildrenCollection_QueryInterface,
239 HTMLDOMChildrenCollection_AddRef,
240 HTMLDOMChildrenCollection_Release,
241 HTMLDOMChildrenCollection_GetTypeInfoCount,
242 HTMLDOMChildrenCollection_GetTypeInfo,
243 HTMLDOMChildrenCollection_GetIDsOfNames,
244 HTMLDOMChildrenCollection_Invoke,
245 HTMLDOMChildrenCollection_get_length,
246 HTMLDOMChildrenCollection__newEnum,
247 HTMLDOMChildrenCollection_item
250 static const tid_t HTMLDOMChildrenCollection_iface_tids[] = {
251 IHTMLDOMChildrenCollection_tid,
255 static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = {
256 HTMLDOMChildrenCollection_get_dispid,
257 HTMLDOMChildrenCollection_invoke
260 static dispex_static_data_t HTMLDOMChildrenCollection_dispex = {
261 &HTMLDOMChildrenCollection_dispex_vtbl,
262 DispDOMChildrenCollection_tid,
264 HTMLDOMChildrenCollection_iface_tids
267 static IHTMLDOMChildrenCollection *create_child_collection(HTMLDocument *doc, nsIDOMNodeList *nslist)
269 HTMLDOMChildrenCollection *ret;
271 ret = heap_alloc_zero(sizeof(*ret));
272 ret->lpIHTMLDOMChildrenCollectionVtbl = &HTMLDOMChildrenCollectionVtbl;
275 nsIDOMNodeList_AddRef(nslist);
276 ret->nslist = nslist;
279 init_dispex(&ret->dispex, (IUnknown*)HTMLCHILDCOL(ret), &HTMLDOMChildrenCollection_dispex);
281 return HTMLCHILDCOL(ret);
284 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
286 static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
287 REFIID riid, void **ppv)
289 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
291 return This->vtbl->qi(This, riid, ppv);
294 static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
296 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
297 LONG ref = InterlockedIncrement(&This->ref);
299 TRACE("(%p) ref=%d\n", This, ref);
304 static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
306 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
307 LONG ref = InterlockedDecrement(&This->ref);
309 TRACE("(%p) ref=%d\n", This, ref);
312 This->vtbl->destructor(This);
319 static HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
321 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
322 FIXME("(%p)->(%p)\n", This, pctinfo);
326 static HRESULT WINAPI HTMLDOMNode_GetTypeInfo(IHTMLDOMNode *iface, UINT iTInfo,
327 LCID lcid, ITypeInfo **ppTInfo)
329 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
330 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
334 static HRESULT WINAPI HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode *iface, REFIID riid,
335 LPOLESTR *rgszNames, UINT cNames,
336 LCID lcid, DISPID *rgDispId)
338 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
339 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
344 static HRESULT WINAPI HTMLDOMNode_Invoke(IHTMLDOMNode *iface, DISPID dispIdMember,
345 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
346 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
348 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
349 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
350 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
354 static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p)
356 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
359 TRACE("(%p)->(%p)\n", This, p);
361 nsIDOMNode_GetNodeType(This->nsnode, &type);
376 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
377 * It needs more tests.
379 FIXME("type %u\n", type);
386 static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p)
388 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
389 FIXME("(%p)->(%p)\n", This, p);
393 static HRESULT WINAPI HTMLDOMNode_hasChildNodes(IHTMLDOMNode *iface, VARIANT_BOOL *fChildren)
395 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
396 FIXME("(%p)->(%p)\n", This, fChildren);
400 static HRESULT WINAPI HTMLDOMNode_get_childNodes(IHTMLDOMNode *iface, IDispatch **p)
402 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
403 nsIDOMNodeList *nslist;
406 TRACE("(%p)->(%p)\n", This, p);
408 nsres = nsIDOMNode_GetChildNodes(This->nsnode, &nslist);
409 if(NS_FAILED(nsres)) {
410 ERR("GetChildNodes failed: %08x\n", nsres);
414 *p = (IDispatch*)create_child_collection(This->doc, nslist);
415 nsIDOMNodeList_Release(nslist);
420 static HRESULT WINAPI HTMLDOMNode_get_attributes(IHTMLDOMNode *iface, IDispatch **p)
422 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
423 FIXME("(%p)->(%p)\n", This, p);
427 static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
428 VARIANT refChild, IHTMLDOMNode **node)
430 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
431 FIXME("(%p)->(%p v %p)\n", This, newChild, node);
435 static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode *oldChild,
438 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
439 FIXME("(%p)->(%p %p)\n", This, oldChild, node);
443 static HRESULT WINAPI HTMLDOMNode_replaceChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
444 IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
446 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
447 FIXME("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
451 static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
452 IHTMLDOMNode **clonedNode)
454 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
455 FIXME("(%p)->(%x %p)\n", This, fDeep, clonedNode);
459 static HRESULT WINAPI HTMLDOMNode_removeNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
460 IHTMLDOMNode **removed)
462 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
463 FIXME("(%p)->(%x %p)\n", This, fDeep, removed);
467 static HRESULT WINAPI HTMLDOMNode_swapNode(IHTMLDOMNode *iface, IHTMLDOMNode *otherNode,
468 IHTMLDOMNode **swappedNode)
470 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
471 FIXME("(%p)->(%p %p)\n", This, otherNode, swappedNode);
475 static HRESULT WINAPI HTMLDOMNode_replaceNode(IHTMLDOMNode *iface, IHTMLDOMNode *replacement,
476 IHTMLDOMNode **replaced)
478 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
479 FIXME("(%p)->(%p %p)\n", This, replacement, replaced);
483 static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
486 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
487 HTMLDOMNode *node_obj;
491 TRACE("(%p)->(%p %p)\n", This, newChild, node);
493 node_obj = get_node_obj(This->doc, (IUnknown*)newChild);
497 nsres = nsIDOMNode_AppendChild(This->nsnode, node_obj->nsnode, &nsnode);
498 if(NS_FAILED(nsres)) {
499 ERR("AppendChild failed: %08x\n", nsres);
503 /* FIXME: Make sure that node != newChild */
504 *node = HTMLDOMNODE(get_node(This->doc, nsnode, TRUE));
505 IHTMLDOMNode_AddRef(*node);
509 static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
511 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
513 TRACE("(%p)->(%p)\n", This, p);
519 const PRUnichar *name;
522 nsAString_Init(&name_str, NULL);
523 nsres = nsIDOMNode_GetNodeName(This->nsnode, &name_str);
525 if(NS_SUCCEEDED(nsres)) {
526 nsAString_GetData(&name_str, &name);
527 *p = SysAllocString(name);
529 ERR("GetNodeName failed: %08x\n", nsres);
532 nsAString_Finish(&name_str);
538 static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
540 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
542 TRACE("(%p)->()\n", This);
548 TRACE("bstr %s\n", debugstr_w(V_BSTR(&v)));
550 nsAString_Init(&val_str, V_BSTR(&v));
551 nsIDOMNode_SetNodeValue(This->nsnode, &val_str);
552 nsAString_Finish(&val_str);
558 FIXME("unsupported vt %d\n", V_VT(&v));
564 static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p)
566 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
567 const PRUnichar *val;
570 TRACE("(%p)->(%p)\n", This, p);
572 nsAString_Init(&val_str, NULL);
573 nsIDOMNode_GetNodeValue(This->nsnode, &val_str);
574 nsAString_GetData(&val_str, &val);
578 V_BSTR(p) = SysAllocString(val);
583 nsAString_Finish(&val_str);
588 static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
590 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
591 nsIDOMNode *nschild = NULL;
593 TRACE("(%p)->(%p)\n", This, p);
595 nsIDOMNode_GetFirstChild(This->nsnode, &nschild);
597 *p = HTMLDOMNODE(get_node(This->doc, nschild, TRUE));
598 IHTMLDOMNode_AddRef(*p);
606 static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
608 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
609 nsIDOMNode *nschild = NULL;
611 TRACE("(%p)->(%p)\n", This, p);
613 nsIDOMNode_GetLastChild(This->nsnode, &nschild);
615 *p = HTMLDOMNODE(get_node(This->doc, nschild, TRUE));
616 IHTMLDOMNode_AddRef(*p);
624 static HRESULT WINAPI HTMLDOMNode_get_previousSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
626 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
627 FIXME("(%p)->(%p)\n", This, p);
631 static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
633 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
634 FIXME("(%p)->(%p)\n", This, p);
638 #undef HTMLDOMNODE_THIS
640 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
641 HTMLDOMNode_QueryInterface,
644 HTMLDOMNode_GetTypeInfoCount,
645 HTMLDOMNode_GetTypeInfo,
646 HTMLDOMNode_GetIDsOfNames,
648 HTMLDOMNode_get_nodeType,
649 HTMLDOMNode_get_parentNode,
650 HTMLDOMNode_hasChildNodes,
651 HTMLDOMNode_get_childNodes,
652 HTMLDOMNode_get_attributes,
653 HTMLDOMNode_insertBefore,
654 HTMLDOMNode_removeChild,
655 HTMLDOMNode_replaceChild,
656 HTMLDOMNode_cloneNode,
657 HTMLDOMNode_removeNode,
658 HTMLDOMNode_swapNode,
659 HTMLDOMNode_replaceNode,
660 HTMLDOMNode_appendChild,
661 HTMLDOMNode_get_nodeName,
662 HTMLDOMNode_put_nodeValue,
663 HTMLDOMNode_get_nodeValue,
664 HTMLDOMNode_get_firstChild,
665 HTMLDOMNode_get_lastChild,
666 HTMLDOMNode_get_previousSibling,
667 HTMLDOMNode_get_nextSibling
670 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
672 static HRESULT WINAPI HTMLDOMNode2_QueryInterface(IHTMLDOMNode2 *iface,
673 REFIID riid, void **ppv)
675 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
677 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This), riid, ppv);
680 static ULONG WINAPI HTMLDOMNode2_AddRef(IHTMLDOMNode2 *iface)
682 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
684 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This));
687 static ULONG WINAPI HTMLDOMNode2_Release(IHTMLDOMNode2 *iface)
689 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
691 return IHTMLDOMNode_Release(HTMLDOMNODE(This));
694 static HRESULT WINAPI HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2 *iface, UINT *pctinfo)
696 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
697 FIXME("(%p)->(%p)\n", This, pctinfo);
701 static HRESULT WINAPI HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2 *iface, UINT iTInfo,
702 LCID lcid, ITypeInfo **ppTInfo)
704 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
705 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
709 static HRESULT WINAPI HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2 *iface, REFIID riid,
710 LPOLESTR *rgszNames, UINT cNames,
711 LCID lcid, DISPID *rgDispId)
713 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
714 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
719 static HRESULT WINAPI HTMLDOMNode2_Invoke(IHTMLDOMNode2 *iface, DISPID dispIdMember,
720 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
721 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
723 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
724 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
725 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
729 static HRESULT WINAPI HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2 *iface, IDispatch **p)
731 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
732 FIXME("(%p)->(%p)\n", This, p);
736 #undef HTMLDOMNODE2_THIS
738 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl = {
739 HTMLDOMNode2_QueryInterface,
741 HTMLDOMNode2_Release,
742 HTMLDOMNode2_GetTypeInfoCount,
743 HTMLDOMNode2_GetTypeInfo,
744 HTMLDOMNode2_GetIDsOfNames,
746 HTMLDOMNode2_get_ownerDocument
749 HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
753 if(IsEqualGUID(&IID_IUnknown, riid)) {
754 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
755 *ppv = HTMLDOMNODE(This);
756 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
757 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
758 *ppv = HTMLDOMNODE(This);
759 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
760 if(This->dispex.data) {
761 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
762 *ppv = DISPATCHEX(&This->dispex);
764 FIXME("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
765 return E_NOINTERFACE;
767 }else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
768 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
769 *ppv = HTMLDOMNODE(This);
770 }else if(IsEqualGUID(&IID_IHTMLDOMNode2, riid)) {
771 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This, ppv);
772 *ppv = HTMLDOMNODE2(This);
776 IUnknown_AddRef((IUnknown*)*ppv);
780 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
781 return E_NOINTERFACE;
784 void HTMLDOMNode_destructor(HTMLDOMNode *This)
787 nsIDOMNode_Release(This->nsnode);
788 if(This->event_target)
789 release_event_target(This->event_target);
792 static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
794 HTMLDOMNode_destructor
797 void HTMLDOMNode_Init(HTMLDocument *doc, HTMLDOMNode *node, nsIDOMNode *nsnode)
799 node->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
800 node->lpHTMLDOMNode2Vtbl = &HTMLDOMNode2Vtbl;
804 nsIDOMNode_AddRef(nsnode);
805 node->nsnode = nsnode;
807 node->next = doc->nodes;
811 static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
816 nsIDOMNode_GetNodeType(nsnode, &node_type);
820 ret = &HTMLElement_Create(doc, nsnode, FALSE)->node;
823 ret = HTMLDOMTextNode_Create(doc, nsnode);
826 ret = &HTMLCommentElement_Create(doc, nsnode)->node;
829 ret = heap_alloc_zero(sizeof(HTMLDOMNode));
830 ret->vtbl = &HTMLDOMNodeImplVtbl;
831 HTMLDOMNode_Init(doc, ret, nsnode);
834 TRACE("type %d ret %p\n", node_type, ret);
841 * List looks really ugly here. We should use a better data structure or
842 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
845 HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode, BOOL create)
847 HTMLDOMNode *iter = This->nodes;
850 if(iter->nsnode == nsnode)
858 return create_node(This, nsnode);
863 * We should use better way for getting node object (like private interface)
864 * or avoid it at all.
866 static HTMLDOMNode *get_node_obj(HTMLDocument *This, IUnknown *iface)
868 HTMLDOMNode *iter = This->nodes;
871 IUnknown_QueryInterface(iface, &IID_IHTMLDOMNode, (void**)&node);
872 IHTMLDOMNode_Release(node);
875 if(HTMLDOMNODE(iter) == node)
880 FIXME("Not found %p\n", iface);
884 void release_nodes(HTMLDocument *This)
886 HTMLDOMNode *iter, *next;
891 for(iter = This->nodes; iter; iter = next) {
894 IHTMLDOMNode_Release(HTMLDOMNODE(iter));