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 const tid_t HTMLDOMChildrenCollection_iface_tids
[] = {
197 IHTMLDOMChildrenCollection_tid
,
200 static dispex_static_data_t HTMLDOMChildrenCollection_dispex
= {
202 DispDOMChildrenCollection_tid
,
204 HTMLDOMChildrenCollection_iface_tids
207 static IHTMLDOMChildrenCollection
*create_child_collection(HTMLDocument
*doc
, nsIDOMNodeList
*nslist
)
209 HTMLDOMChildrenCollection
*ret
;
211 ret
= heap_alloc_zero(sizeof(*ret
));
212 ret
->lpIHTMLDOMChildrenCollectionVtbl
= &HTMLDOMChildrenCollectionVtbl
;
215 nsIDOMNodeList_AddRef(nslist
);
216 ret
->nslist
= nslist
;
219 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLCHILDCOL(ret
), &HTMLDOMChildrenCollection_dispex
);
221 return HTMLCHILDCOL(ret
);
224 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
226 static HRESULT WINAPI
HTMLDOMNode_QueryInterface(IHTMLDOMNode
*iface
,
227 REFIID riid
, void **ppv
)
229 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
231 return This
->vtbl
->qi(This
, riid
, ppv
);
234 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
236 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
237 LONG ref
= InterlockedIncrement(&This
->ref
);
239 TRACE("(%p) ref=%d\n", This
, ref
);
244 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
246 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
247 LONG ref
= InterlockedDecrement(&This
->ref
);
249 TRACE("(%p) ref=%d\n", This
, ref
);
252 This
->vtbl
->destructor(This
);
259 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
261 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
262 FIXME("(%p)->(%p)\n", This
, pctinfo
);
266 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
267 LCID lcid
, ITypeInfo
**ppTInfo
)
269 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
270 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
274 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
275 LPOLESTR
*rgszNames
, UINT cNames
,
276 LCID lcid
, DISPID
*rgDispId
)
278 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
279 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
284 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
285 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
286 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
288 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
289 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
290 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
294 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
296 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
299 TRACE("(%p)->(%p)\n", This
, p
);
301 nsIDOMNode_GetNodeType(This
->nsnode
, &type
);
316 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
317 * It needs more tests.
319 FIXME("type %u\n", type
);
326 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
328 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
329 FIXME("(%p)->(%p)\n", This
, p
);
333 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
335 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
336 FIXME("(%p)->(%p)\n", This
, fChildren
);
340 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
342 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
343 nsIDOMNodeList
*nslist
;
346 TRACE("(%p)->(%p)\n", This
, p
);
348 nsres
= nsIDOMNode_GetChildNodes(This
->nsnode
, &nslist
);
349 if(NS_FAILED(nsres
)) {
350 ERR("GetChildNodes failed: %08x\n", nsres
);
354 *p
= (IDispatch
*)create_child_collection(This
->doc
, nslist
);
355 nsIDOMNodeList_Release(nslist
);
360 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
362 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
363 FIXME("(%p)->(%p)\n", This
, p
);
367 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
368 VARIANT refChild
, IHTMLDOMNode
**node
)
370 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
371 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
375 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
378 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
379 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
383 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
384 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
386 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
387 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
391 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
392 IHTMLDOMNode
**clonedNode
)
394 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
395 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
399 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
400 IHTMLDOMNode
**removed
)
402 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
403 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
407 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
408 IHTMLDOMNode
**swappedNode
)
410 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
411 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
415 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
416 IHTMLDOMNode
**replaced
)
418 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
419 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
423 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
426 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
427 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
431 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
433 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
435 TRACE("(%p)->(%p)\n", This
, p
);
441 const PRUnichar
*name
;
444 nsAString_Init(&name_str
, NULL
);
445 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
447 if(NS_SUCCEEDED(nsres
)) {
448 nsAString_GetData(&name_str
, &name
);
449 *p
= SysAllocString(name
);
451 ERR("GetNodeName failed: %08x\n", nsres
);
454 nsAString_Finish(&name_str
);
460 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
462 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
464 TRACE("(%p)->()\n", This
);
470 TRACE("bstr %s\n", debugstr_w(V_BSTR(&v
)));
472 nsAString_Init(&val_str
, V_BSTR(&v
));
473 nsIDOMNode_SetNodeValue(This
->nsnode
, &val_str
);
474 nsAString_Finish(&val_str
);
480 FIXME("unsupported vt %d\n", V_VT(&v
));
486 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
488 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
489 const PRUnichar
*val
;
492 TRACE("(%p)->(%p)\n", This
, p
);
494 nsAString_Init(&val_str
, NULL
);
495 nsIDOMNode_GetNodeValue(This
->nsnode
, &val_str
);
496 nsAString_GetData(&val_str
, &val
);
500 V_BSTR(p
) = SysAllocString(val
);
505 nsAString_Finish(&val_str
);
510 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
512 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
513 nsIDOMNode
*nschild
= NULL
;
515 TRACE("(%p)->(%p)\n", This
, p
);
517 nsIDOMNode_GetFirstChild(This
->nsnode
, &nschild
);
519 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
520 IHTMLDOMNode_AddRef(*p
);
528 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
530 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
531 FIXME("(%p)->(%p)\n", This
, p
);
535 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
537 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
538 FIXME("(%p)->(%p)\n", This
, p
);
542 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
544 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
545 FIXME("(%p)->(%p)\n", This
, p
);
549 #undef HTMLDOMNODE_THIS
551 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
552 HTMLDOMNode_QueryInterface
,
555 HTMLDOMNode_GetTypeInfoCount
,
556 HTMLDOMNode_GetTypeInfo
,
557 HTMLDOMNode_GetIDsOfNames
,
559 HTMLDOMNode_get_nodeType
,
560 HTMLDOMNode_get_parentNode
,
561 HTMLDOMNode_hasChildNodes
,
562 HTMLDOMNode_get_childNodes
,
563 HTMLDOMNode_get_attributes
,
564 HTMLDOMNode_insertBefore
,
565 HTMLDOMNode_removeChild
,
566 HTMLDOMNode_replaceChild
,
567 HTMLDOMNode_cloneNode
,
568 HTMLDOMNode_removeNode
,
569 HTMLDOMNode_swapNode
,
570 HTMLDOMNode_replaceNode
,
571 HTMLDOMNode_appendChild
,
572 HTMLDOMNode_get_nodeName
,
573 HTMLDOMNode_put_nodeValue
,
574 HTMLDOMNode_get_nodeValue
,
575 HTMLDOMNode_get_firstChild
,
576 HTMLDOMNode_get_lastChild
,
577 HTMLDOMNode_get_previousSibling
,
578 HTMLDOMNode_get_nextSibling
581 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
583 static HRESULT WINAPI
HTMLDOMNode2_QueryInterface(IHTMLDOMNode2
*iface
,
584 REFIID riid
, void **ppv
)
586 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
588 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This
), riid
, ppv
);
591 static ULONG WINAPI
HTMLDOMNode2_AddRef(IHTMLDOMNode2
*iface
)
593 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
595 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This
));
598 static ULONG WINAPI
HTMLDOMNode2_Release(IHTMLDOMNode2
*iface
)
600 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
602 return IHTMLDOMNode_Release(HTMLDOMNODE(This
));
605 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2
*iface
, UINT
*pctinfo
)
607 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
608 FIXME("(%p)->(%p)\n", This
, pctinfo
);
612 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2
*iface
, UINT iTInfo
,
613 LCID lcid
, ITypeInfo
**ppTInfo
)
615 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
616 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
620 static HRESULT WINAPI
HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2
*iface
, REFIID riid
,
621 LPOLESTR
*rgszNames
, UINT cNames
,
622 LCID lcid
, DISPID
*rgDispId
)
624 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
625 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
630 static HRESULT WINAPI
HTMLDOMNode2_Invoke(IHTMLDOMNode2
*iface
, DISPID dispIdMember
,
631 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
632 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
634 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
635 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
636 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
640 static HRESULT WINAPI
HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2
*iface
, IDispatch
**p
)
642 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
643 FIXME("(%p)->(%p)\n", This
, p
);
647 #undef HTMLDOMNODE2_THIS
649 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl
= {
650 HTMLDOMNode2_QueryInterface
,
652 HTMLDOMNode2_Release
,
653 HTMLDOMNode2_GetTypeInfoCount
,
654 HTMLDOMNode2_GetTypeInfo
,
655 HTMLDOMNode2_GetIDsOfNames
,
657 HTMLDOMNode2_get_ownerDocument
660 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
664 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
665 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
666 *ppv
= HTMLDOMNODE(This
);
667 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
668 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
669 *ppv
= HTMLDOMNODE(This
);
670 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
671 if(This
->dispex
.data
) {
672 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
673 *ppv
= DISPATCHEX(&This
->dispex
);
675 FIXME("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
676 return E_NOINTERFACE
;
678 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
679 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
680 *ppv
= HTMLDOMNODE(This
);
681 }else if(IsEqualGUID(&IID_IHTMLDOMNode2
, riid
)) {
682 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This
, ppv
);
683 *ppv
= HTMLDOMNODE2(This
);
687 IUnknown_AddRef((IUnknown
*)*ppv
);
691 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
692 return E_NOINTERFACE
;
695 void HTMLDOMNode_destructor(HTMLDOMNode
*This
)
698 nsIDOMNode_Release(This
->nsnode
);
699 if(This
->event_target
)
700 release_event_target(This
->event_target
);
703 static const NodeImplVtbl HTMLDOMNodeImplVtbl
= {
705 HTMLDOMNode_destructor
708 static HTMLDOMNode
*create_node(HTMLDocument
*doc
, nsIDOMNode
*nsnode
)
713 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
717 ret
= &HTMLElement_Create(nsnode
)->node
;
720 ret
= HTMLDOMTextNode_Create(nsnode
);
723 ret
= &HTMLCommentElement_Create(nsnode
)->node
;
726 ret
= heap_alloc_zero(sizeof(HTMLDOMNode
));
727 ret
->vtbl
= &HTMLDOMNodeImplVtbl
;
730 ret
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
731 ret
->lpHTMLDOMNode2Vtbl
= &HTMLDOMNode2Vtbl
;
735 nsIDOMNode_AddRef(nsnode
);
736 ret
->nsnode
= nsnode
;
738 TRACE("type %d ret %p\n", node_type
, ret
);
745 * List looks really ugly here. We should use a better data structure or
746 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
749 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
, BOOL create
)
751 HTMLDOMNode
*iter
= This
->nodes
, *ret
;
754 if(iter
->nsnode
== nsnode
)
762 ret
= create_node(This
, nsnode
);
764 ret
->next
= This
->nodes
;
770 void release_nodes(HTMLDocument
*This
)
772 HTMLDOMNode
*iter
, *next
;
777 for(iter
= This
->nodes
; iter
; iter
= next
) {
780 IHTMLDOMNode_Release(HTMLDOMNODE(iter
));