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
);
35 const IHTMLDOMChildrenCollectionVtbl
*lpIHTMLDOMChildrenCollectionVtbl
;
39 /* FIXME: implement weak reference */
42 nsIDOMNodeList
*nslist
;
43 } HTMLDOMChildrenCollection
;
45 #define HTMLCHILDCOL(x) ((IHTMLDOMChildrenCollection*) &(x)->lpIHTMLDOMChildrenCollectionVtbl)
47 #define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface)
49 static HRESULT WINAPI
HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection
*iface
, REFIID riid
, void **ppv
)
51 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
55 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
56 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
57 *ppv
= HTMLCHILDCOL(This
);
58 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
59 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
60 *ppv
= HTMLCHILDCOL(This
);
61 }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection
, riid
)) {
62 TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This
, ppv
);
63 *ppv
= HTMLCHILDCOL(This
);
67 IUnknown_AddRef((IUnknown
*)*ppv
);
71 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
75 static ULONG WINAPI
HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection
*iface
)
77 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
78 LONG ref
= InterlockedIncrement(&This
->ref
);
80 TRACE("(%p) ref=%d\n", This
, ref
);
85 static ULONG WINAPI
HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection
*iface
)
87 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
88 LONG ref
= InterlockedDecrement(&This
->ref
);
90 TRACE("(%p) ref=%d\n", This
, ref
);
93 nsIDOMNodeList_Release(This
->nslist
);
100 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection
*iface
, UINT
*pctinfo
)
102 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
103 FIXME("(%p)->(%p)\n", This
, pctinfo
);
107 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection
*iface
, UINT iTInfo
,
108 LCID lcid
, ITypeInfo
**ppTInfo
)
110 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
111 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
115 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection
*iface
, REFIID riid
,
116 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
118 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
119 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
124 static HRESULT WINAPI
HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection
*iface
, DISPID dispIdMember
,
125 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
126 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
128 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
129 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
130 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
134 static HRESULT WINAPI
HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection
*iface
, long *p
)
136 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
137 FIXME("(%p)->(%p)\n", This
, p
);
141 static HRESULT WINAPI
HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection
*iface
, IUnknown
**p
)
143 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
144 FIXME("(%p)->(%p)\n", This
, p
);
148 static HRESULT WINAPI
HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
*iface
, long index
, IDispatch
**ppItem
)
150 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
151 FIXME("(%p)->(%ld %p)\n", This
, index
, ppItem
);
155 #undef HTMLCHILDCOL_THIS
157 static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl
= {
158 HTMLDOMChildrenCollection_QueryInterface
,
159 HTMLDOMChildrenCollection_AddRef
,
160 HTMLDOMChildrenCollection_Release
,
161 HTMLDOMChildrenCollection_GetTypeInfoCount
,
162 HTMLDOMChildrenCollection_GetTypeInfo
,
163 HTMLDOMChildrenCollection_GetIDsOfNames
,
164 HTMLDOMChildrenCollection_Invoke
,
165 HTMLDOMChildrenCollection_get_length
,
166 HTMLDOMChildrenCollection__newEnum
,
167 HTMLDOMChildrenCollection_item
170 static IHTMLDOMChildrenCollection
*create_child_collection(HTMLDocument
*doc
, nsIDOMNodeList
*nslist
)
172 HTMLDOMChildrenCollection
*ret
;
174 ret
= heap_alloc_zero(sizeof(*ret
));
175 ret
->lpIHTMLDOMChildrenCollectionVtbl
= &HTMLDOMChildrenCollectionVtbl
;
178 nsIDOMNodeList_AddRef(nslist
);
179 ret
->nslist
= nslist
;
182 return HTMLCHILDCOL(ret
);
185 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
187 static HRESULT WINAPI
HTMLDOMNode_QueryInterface(IHTMLDOMNode
*iface
,
188 REFIID riid
, void **ppv
)
190 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
192 return This
->vtbl
->qi(This
, riid
, ppv
);
195 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
197 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
198 LONG ref
= InterlockedIncrement(&This
->ref
);
200 TRACE("(%p) ref=%d\n", This
, ref
);
205 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
207 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
208 LONG ref
= InterlockedDecrement(&This
->ref
);
210 TRACE("(%p) ref=%d\n", This
, ref
);
213 This
->vtbl
->destructor(This
);
220 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
222 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
223 FIXME("(%p)->(%p)\n", This
, pctinfo
);
227 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
228 LCID lcid
, ITypeInfo
**ppTInfo
)
230 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
231 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
235 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
236 LPOLESTR
*rgszNames
, UINT cNames
,
237 LCID lcid
, DISPID
*rgDispId
)
239 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
240 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
245 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
246 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
247 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
249 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
250 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
251 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
255 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
257 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
260 TRACE("(%p)->(%p)\n", This
, p
);
262 nsIDOMNode_GetNodeType(This
->nsnode
, &type
);
277 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
278 * It needs more tests.
280 FIXME("type %u\n", type
);
287 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
289 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
290 FIXME("(%p)->(%p)\n", This
, p
);
294 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
296 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
297 FIXME("(%p)->(%p)\n", This
, fChildren
);
301 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
303 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
304 nsIDOMNodeList
*nslist
;
307 TRACE("(%p)->(%p)\n", This
, p
);
309 nsres
= nsIDOMNode_GetChildNodes(This
->nsnode
, &nslist
);
310 if(NS_FAILED(nsres
)) {
311 ERR("GetChildNodes failed: %08x\n", nsres
);
315 *p
= (IDispatch
*)create_child_collection(This
->doc
, nslist
);
316 nsIDOMNodeList_Release(nslist
);
321 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
323 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
324 FIXME("(%p)->(%p)\n", This
, p
);
328 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
329 VARIANT refChild
, IHTMLDOMNode
**node
)
331 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
332 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
336 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
339 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
340 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
344 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
345 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
347 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
348 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
352 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
353 IHTMLDOMNode
**clonedNode
)
355 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
356 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
360 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
361 IHTMLDOMNode
**removed
)
363 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
364 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
368 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
369 IHTMLDOMNode
**swappedNode
)
371 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
372 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
376 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
377 IHTMLDOMNode
**replaced
)
379 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
380 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
384 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
387 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
388 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
392 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
394 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
396 TRACE("(%p)->(%p)\n", This
, p
);
402 const PRUnichar
*name
;
405 nsAString_Init(&name_str
, NULL
);
406 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
408 if(NS_SUCCEEDED(nsres
)) {
409 nsAString_GetData(&name_str
, &name
);
410 *p
= SysAllocString(name
);
412 ERR("GetNodeName failed: %08x\n", nsres
);
415 nsAString_Finish(&name_str
);
421 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
423 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
424 FIXME("(%p)->()\n", This
);
428 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
430 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
431 FIXME("(%p)->(%p)\n", This
, p
);
435 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
437 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
438 nsIDOMNode
*nschild
= NULL
;
440 TRACE("(%p)->(%p)\n", This
, p
);
442 nsIDOMNode_GetFirstChild(This
->nsnode
, &nschild
);
444 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
445 IHTMLDOMNode_AddRef(*p
);
453 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
455 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
456 FIXME("(%p)->(%p)\n", This
, p
);
460 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
462 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
463 FIXME("(%p)->(%p)\n", This
, p
);
467 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
469 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
470 FIXME("(%p)->(%p)\n", This
, p
);
474 #undef HTMLDOMNODE_THIS
476 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
477 HTMLDOMNode_QueryInterface
,
480 HTMLDOMNode_GetTypeInfoCount
,
481 HTMLDOMNode_GetTypeInfo
,
482 HTMLDOMNode_GetIDsOfNames
,
484 HTMLDOMNode_get_nodeType
,
485 HTMLDOMNode_get_parentNode
,
486 HTMLDOMNode_hasChildNodes
,
487 HTMLDOMNode_get_childNodes
,
488 HTMLDOMNode_get_attributes
,
489 HTMLDOMNode_insertBefore
,
490 HTMLDOMNode_removeChild
,
491 HTMLDOMNode_replaceChild
,
492 HTMLDOMNode_cloneNode
,
493 HTMLDOMNode_removeNode
,
494 HTMLDOMNode_swapNode
,
495 HTMLDOMNode_replaceNode
,
496 HTMLDOMNode_appendChild
,
497 HTMLDOMNode_get_nodeName
,
498 HTMLDOMNode_put_nodeValue
,
499 HTMLDOMNode_get_nodeValue
,
500 HTMLDOMNode_get_firstChild
,
501 HTMLDOMNode_get_lastChild
,
502 HTMLDOMNode_get_previousSibling
,
503 HTMLDOMNode_get_nextSibling
506 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
508 static HRESULT WINAPI
HTMLDOMNode2_QueryInterface(IHTMLDOMNode2
*iface
,
509 REFIID riid
, void **ppv
)
511 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
513 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This
), riid
, ppv
);
516 static ULONG WINAPI
HTMLDOMNode2_AddRef(IHTMLDOMNode2
*iface
)
518 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
520 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This
));
523 static ULONG WINAPI
HTMLDOMNode2_Release(IHTMLDOMNode2
*iface
)
525 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
527 return IHTMLDOMNode_Release(HTMLDOMNODE(This
));
530 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2
*iface
, UINT
*pctinfo
)
532 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
533 FIXME("(%p)->(%p)\n", This
, pctinfo
);
537 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2
*iface
, UINT iTInfo
,
538 LCID lcid
, ITypeInfo
**ppTInfo
)
540 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
541 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
545 static HRESULT WINAPI
HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2
*iface
, REFIID riid
,
546 LPOLESTR
*rgszNames
, UINT cNames
,
547 LCID lcid
, DISPID
*rgDispId
)
549 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
550 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
555 static HRESULT WINAPI
HTMLDOMNode2_Invoke(IHTMLDOMNode2
*iface
, DISPID dispIdMember
,
556 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
557 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
559 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
560 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
561 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
565 static HRESULT WINAPI
HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2
*iface
, IDispatch
**p
)
567 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
568 FIXME("(%p)->(%p)\n", This
, p
);
572 #undef HTMLDOMNODE2_THIS
574 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl
= {
575 HTMLDOMNode2_QueryInterface
,
577 HTMLDOMNode2_Release
,
578 HTMLDOMNode2_GetTypeInfoCount
,
579 HTMLDOMNode2_GetTypeInfo
,
580 HTMLDOMNode2_GetIDsOfNames
,
582 HTMLDOMNode2_get_ownerDocument
585 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
589 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
590 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
591 *ppv
= HTMLDOMNODE(This
);
592 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
593 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
594 *ppv
= HTMLDOMNODE(This
);
595 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
596 if(This
->dispex
.data
) {
597 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
598 *ppv
= DISPATCHEX(&This
->dispex
);
600 FIXME("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
601 return E_NOINTERFACE
;
603 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
604 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
605 *ppv
= HTMLDOMNODE(This
);
606 }else if(IsEqualGUID(&IID_IHTMLDOMNode2
, riid
)) {
607 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This
, ppv
);
608 *ppv
= HTMLDOMNODE2(This
);
612 IUnknown_AddRef((IUnknown
*)*ppv
);
616 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
617 return E_NOINTERFACE
;
620 void HTMLDOMNode_destructor(HTMLDOMNode
*This
)
623 nsIDOMNode_Release(This
->nsnode
);
624 if(This
->event_target
)
625 release_event_target(This
->event_target
);
628 static const NodeImplVtbl HTMLDOMNodeImplVtbl
= {
630 HTMLDOMNode_destructor
633 static HTMLDOMNode
*create_node(HTMLDocument
*doc
, nsIDOMNode
*nsnode
)
638 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
642 ret
= &HTMLElement_Create(nsnode
)->node
;
645 ret
= HTMLDOMTextNode_Create(nsnode
);
648 ret
= heap_alloc_zero(sizeof(HTMLDOMNode
));
649 ret
->vtbl
= &HTMLDOMNodeImplVtbl
;
652 ret
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
653 ret
->lpHTMLDOMNode2Vtbl
= &HTMLDOMNode2Vtbl
;
657 nsIDOMNode_AddRef(nsnode
);
658 ret
->nsnode
= nsnode
;
660 TRACE("type %d ret %p\n", node_type
, ret
);
667 * List looks really ugly here. We should use a better data structure or
668 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
671 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
, BOOL create
)
673 HTMLDOMNode
*iter
= This
->nodes
, *ret
;
676 if(iter
->nsnode
== nsnode
)
684 ret
= create_node(This
, nsnode
);
686 ret
->next
= This
->nodes
;
692 void release_nodes(HTMLDocument
*This
)
694 HTMLDOMNode
*iter
, *next
;
699 for(iter
= This
->nodes
; iter
; iter
= next
) {
702 IHTMLDOMNode_Release(HTMLDOMNODE(iter
));