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
);
36 const IHTMLDOMChildrenCollectionVtbl
*lpIHTMLDOMChildrenCollectionVtbl
;
40 /* FIXME: implement weak reference */
43 nsIDOMNodeList
*nslist
;
44 } HTMLDOMChildrenCollection
;
46 #define HTMLCHILDCOL(x) ((IHTMLDOMChildrenCollection*) &(x)->lpIHTMLDOMChildrenCollectionVtbl)
48 #define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface)
50 static HRESULT WINAPI
HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection
*iface
, REFIID riid
, void **ppv
)
52 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
56 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
57 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
58 *ppv
= HTMLCHILDCOL(This
);
59 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
60 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
61 *ppv
= HTMLCHILDCOL(This
);
62 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
63 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
64 *ppv
= DISPATCHEX(&This
->dispex
);
65 }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection
, riid
)) {
66 TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This
, ppv
);
67 *ppv
= HTMLCHILDCOL(This
);
71 IUnknown_AddRef((IUnknown
*)*ppv
);
75 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
79 static ULONG WINAPI
HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection
*iface
)
81 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
82 LONG ref
= InterlockedIncrement(&This
->ref
);
84 TRACE("(%p) ref=%d\n", This
, ref
);
89 static ULONG WINAPI
HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection
*iface
)
91 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
92 LONG ref
= InterlockedDecrement(&This
->ref
);
94 TRACE("(%p) ref=%d\n", This
, ref
);
97 nsIDOMNodeList_Release(This
->nslist
);
104 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection
*iface
, UINT
*pctinfo
)
106 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
107 FIXME("(%p)->(%p)\n", This
, pctinfo
);
111 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection
*iface
, UINT iTInfo
,
112 LCID lcid
, ITypeInfo
**ppTInfo
)
114 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
115 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
119 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection
*iface
, REFIID riid
,
120 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
122 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
123 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
128 static HRESULT WINAPI
HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection
*iface
, DISPID dispIdMember
,
129 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
130 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
132 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
133 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
134 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
138 static HRESULT WINAPI
HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection
*iface
, long *p
)
140 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
143 TRACE("(%p)->(%p)\n", This
, p
);
145 nsIDOMNodeList_GetLength(This
->nslist
, &length
);
150 static HRESULT WINAPI
HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection
*iface
, IUnknown
**p
)
152 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
153 FIXME("(%p)->(%p)\n", This
, p
);
157 static HRESULT WINAPI
HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
*iface
, long index
, IDispatch
**ppItem
)
159 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
160 nsIDOMNode
*nsnode
= NULL
;
164 TRACE("(%p)->(%ld %p)\n", This
, index
, ppItem
);
166 nsIDOMNodeList_GetLength(This
->nslist
, &length
);
167 if(index
< 0 || index
> length
)
170 nsres
= nsIDOMNodeList_Item(This
->nslist
, index
, &nsnode
);
171 if(NS_FAILED(nsres
) || !nsnode
) {
172 ERR("Item failed: %08x\n", nsres
);
176 *ppItem
= (IDispatch
*)get_node(This
->doc
, nsnode
, TRUE
);
177 IDispatch_AddRef(*ppItem
);
181 #undef HTMLCHILDCOL_THIS
183 static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl
= {
184 HTMLDOMChildrenCollection_QueryInterface
,
185 HTMLDOMChildrenCollection_AddRef
,
186 HTMLDOMChildrenCollection_Release
,
187 HTMLDOMChildrenCollection_GetTypeInfoCount
,
188 HTMLDOMChildrenCollection_GetTypeInfo
,
189 HTMLDOMChildrenCollection_GetIDsOfNames
,
190 HTMLDOMChildrenCollection_Invoke
,
191 HTMLDOMChildrenCollection_get_length
,
192 HTMLDOMChildrenCollection__newEnum
,
193 HTMLDOMChildrenCollection_item
196 static dispex_static_data_t HTMLDOMChildrenCollection_dispex
= {
198 DispDOMChildrenCollection_tid
,
201 IHTMLDOMChildrenCollection_tid
,
206 static IHTMLDOMChildrenCollection
*create_child_collection(HTMLDocument
*doc
, nsIDOMNodeList
*nslist
)
208 HTMLDOMChildrenCollection
*ret
;
210 ret
= heap_alloc_zero(sizeof(*ret
));
211 ret
->lpIHTMLDOMChildrenCollectionVtbl
= &HTMLDOMChildrenCollectionVtbl
;
214 nsIDOMNodeList_AddRef(nslist
);
215 ret
->nslist
= nslist
;
218 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLCHILDCOL(ret
), &HTMLDOMChildrenCollection_dispex
);
220 return HTMLCHILDCOL(ret
);
223 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
225 static HRESULT WINAPI
HTMLDOMNode_QueryInterface(IHTMLDOMNode
*iface
,
226 REFIID riid
, void **ppv
)
228 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
230 return This
->vtbl
->qi(This
, riid
, ppv
);
233 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
235 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
236 LONG ref
= InterlockedIncrement(&This
->ref
);
238 TRACE("(%p) ref=%d\n", This
, ref
);
243 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
245 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
246 LONG ref
= InterlockedDecrement(&This
->ref
);
248 TRACE("(%p) ref=%d\n", This
, ref
);
251 This
->vtbl
->destructor(This
);
258 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
260 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
261 FIXME("(%p)->(%p)\n", This
, pctinfo
);
265 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
266 LCID lcid
, ITypeInfo
**ppTInfo
)
268 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
269 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
273 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
274 LPOLESTR
*rgszNames
, UINT cNames
,
275 LCID lcid
, DISPID
*rgDispId
)
277 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
278 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
283 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
284 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
285 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
287 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
288 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
289 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
293 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
295 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
298 TRACE("(%p)->(%p)\n", This
, p
);
300 nsIDOMNode_GetNodeType(This
->nsnode
, &type
);
315 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
316 * It needs more tests.
318 FIXME("type %u\n", type
);
325 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
327 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
328 FIXME("(%p)->(%p)\n", This
, p
);
332 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
334 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
335 FIXME("(%p)->(%p)\n", This
, fChildren
);
339 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
341 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
342 nsIDOMNodeList
*nslist
;
345 TRACE("(%p)->(%p)\n", This
, p
);
347 nsres
= nsIDOMNode_GetChildNodes(This
->nsnode
, &nslist
);
348 if(NS_FAILED(nsres
)) {
349 ERR("GetChildNodes failed: %08x\n", nsres
);
353 *p
= (IDispatch
*)create_child_collection(This
->doc
, nslist
);
354 nsIDOMNodeList_Release(nslist
);
359 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
361 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
362 FIXME("(%p)->(%p)\n", This
, p
);
366 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
367 VARIANT refChild
, IHTMLDOMNode
**node
)
369 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
370 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
374 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
377 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
378 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
382 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
383 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
385 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
386 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
390 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
391 IHTMLDOMNode
**clonedNode
)
393 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
394 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
398 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
399 IHTMLDOMNode
**removed
)
401 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
402 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
406 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
407 IHTMLDOMNode
**swappedNode
)
409 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
410 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
414 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
415 IHTMLDOMNode
**replaced
)
417 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
418 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
422 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
425 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
426 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
430 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
432 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
434 TRACE("(%p)->(%p)\n", This
, p
);
440 const PRUnichar
*name
;
443 nsAString_Init(&name_str
, NULL
);
444 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
446 if(NS_SUCCEEDED(nsres
)) {
447 nsAString_GetData(&name_str
, &name
);
448 *p
= SysAllocString(name
);
450 ERR("GetNodeName failed: %08x\n", nsres
);
453 nsAString_Finish(&name_str
);
459 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
461 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
462 FIXME("(%p)->()\n", This
);
466 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
468 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
469 FIXME("(%p)->(%p)\n", This
, p
);
473 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
475 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
476 nsIDOMNode
*nschild
= NULL
;
478 TRACE("(%p)->(%p)\n", This
, p
);
480 nsIDOMNode_GetFirstChild(This
->nsnode
, &nschild
);
482 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
483 IHTMLDOMNode_AddRef(*p
);
491 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
493 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
494 FIXME("(%p)->(%p)\n", This
, p
);
498 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
500 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
501 FIXME("(%p)->(%p)\n", This
, p
);
505 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
507 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
508 FIXME("(%p)->(%p)\n", This
, p
);
512 #undef HTMLDOMNODE_THIS
514 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
515 HTMLDOMNode_QueryInterface
,
518 HTMLDOMNode_GetTypeInfoCount
,
519 HTMLDOMNode_GetTypeInfo
,
520 HTMLDOMNode_GetIDsOfNames
,
522 HTMLDOMNode_get_nodeType
,
523 HTMLDOMNode_get_parentNode
,
524 HTMLDOMNode_hasChildNodes
,
525 HTMLDOMNode_get_childNodes
,
526 HTMLDOMNode_get_attributes
,
527 HTMLDOMNode_insertBefore
,
528 HTMLDOMNode_removeChild
,
529 HTMLDOMNode_replaceChild
,
530 HTMLDOMNode_cloneNode
,
531 HTMLDOMNode_removeNode
,
532 HTMLDOMNode_swapNode
,
533 HTMLDOMNode_replaceNode
,
534 HTMLDOMNode_appendChild
,
535 HTMLDOMNode_get_nodeName
,
536 HTMLDOMNode_put_nodeValue
,
537 HTMLDOMNode_get_nodeValue
,
538 HTMLDOMNode_get_firstChild
,
539 HTMLDOMNode_get_lastChild
,
540 HTMLDOMNode_get_previousSibling
,
541 HTMLDOMNode_get_nextSibling
544 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
546 static HRESULT WINAPI
HTMLDOMNode2_QueryInterface(IHTMLDOMNode2
*iface
,
547 REFIID riid
, void **ppv
)
549 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
551 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This
), riid
, ppv
);
554 static ULONG WINAPI
HTMLDOMNode2_AddRef(IHTMLDOMNode2
*iface
)
556 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
558 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This
));
561 static ULONG WINAPI
HTMLDOMNode2_Release(IHTMLDOMNode2
*iface
)
563 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
565 return IHTMLDOMNode_Release(HTMLDOMNODE(This
));
568 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2
*iface
, UINT
*pctinfo
)
570 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
571 FIXME("(%p)->(%p)\n", This
, pctinfo
);
575 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2
*iface
, UINT iTInfo
,
576 LCID lcid
, ITypeInfo
**ppTInfo
)
578 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
579 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
583 static HRESULT WINAPI
HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2
*iface
, REFIID riid
,
584 LPOLESTR
*rgszNames
, UINT cNames
,
585 LCID lcid
, DISPID
*rgDispId
)
587 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
588 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
593 static HRESULT WINAPI
HTMLDOMNode2_Invoke(IHTMLDOMNode2
*iface
, DISPID dispIdMember
,
594 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
595 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
597 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
598 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
599 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
603 static HRESULT WINAPI
HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2
*iface
, IDispatch
**p
)
605 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
606 FIXME("(%p)->(%p)\n", This
, p
);
610 #undef HTMLDOMNODE2_THIS
612 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl
= {
613 HTMLDOMNode2_QueryInterface
,
615 HTMLDOMNode2_Release
,
616 HTMLDOMNode2_GetTypeInfoCount
,
617 HTMLDOMNode2_GetTypeInfo
,
618 HTMLDOMNode2_GetIDsOfNames
,
620 HTMLDOMNode2_get_ownerDocument
623 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
627 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
628 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
629 *ppv
= HTMLDOMNODE(This
);
630 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
631 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
632 *ppv
= HTMLDOMNODE(This
);
633 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
634 if(This
->dispex
.data
) {
635 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
636 *ppv
= DISPATCHEX(&This
->dispex
);
638 FIXME("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
639 return E_NOINTERFACE
;
641 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
642 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
643 *ppv
= HTMLDOMNODE(This
);
644 }else if(IsEqualGUID(&IID_IHTMLDOMNode2
, riid
)) {
645 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This
, ppv
);
646 *ppv
= HTMLDOMNODE2(This
);
650 IUnknown_AddRef((IUnknown
*)*ppv
);
654 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
655 return E_NOINTERFACE
;
658 void HTMLDOMNode_destructor(HTMLDOMNode
*This
)
661 nsIDOMNode_Release(This
->nsnode
);
662 if(This
->event_target
)
663 release_event_target(This
->event_target
);
666 static const NodeImplVtbl HTMLDOMNodeImplVtbl
= {
668 HTMLDOMNode_destructor
671 static HTMLDOMNode
*create_node(HTMLDocument
*doc
, nsIDOMNode
*nsnode
)
676 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
680 ret
= &HTMLElement_Create(nsnode
)->node
;
683 ret
= HTMLDOMTextNode_Create(nsnode
);
686 ret
= &HTMLCommentElement_Create(nsnode
)->node
;
689 ret
= heap_alloc_zero(sizeof(HTMLDOMNode
));
690 ret
->vtbl
= &HTMLDOMNodeImplVtbl
;
693 ret
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
694 ret
->lpHTMLDOMNode2Vtbl
= &HTMLDOMNode2Vtbl
;
698 nsIDOMNode_AddRef(nsnode
);
699 ret
->nsnode
= nsnode
;
701 TRACE("type %d ret %p\n", node_type
, ret
);
708 * List looks really ugly here. We should use a better data structure or
709 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
712 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
, BOOL create
)
714 HTMLDOMNode
*iter
= This
->nodes
, *ret
;
717 if(iter
->nsnode
== nsnode
)
725 ret
= create_node(This
, nsnode
);
727 ret
->next
= This
->nodes
;
733 void release_nodes(HTMLDocument
*This
)
735 HTMLDOMNode
*iter
, *next
;
740 for(iter
= This
->nodes
; iter
; iter
= next
) {
743 IHTMLDOMNode_Release(HTMLDOMNODE(iter
));