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_IHTMLDOMChildrenCollection
, riid
)) {
62 TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This
, ppv
);
63 *ppv
= HTMLCHILDCOL(This
);
64 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
65 return *ppv
? S_OK
: E_NOINTERFACE
;
69 IUnknown_AddRef((IUnknown
*)*ppv
);
73 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
77 static ULONG WINAPI
HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection
*iface
)
79 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
80 LONG ref
= InterlockedIncrement(&This
->ref
);
82 TRACE("(%p) ref=%d\n", This
, ref
);
87 static ULONG WINAPI
HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection
*iface
)
89 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
90 LONG ref
= InterlockedDecrement(&This
->ref
);
92 TRACE("(%p) ref=%d\n", This
, ref
);
95 nsIDOMNodeList_Release(This
->nslist
);
102 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection
*iface
, UINT
*pctinfo
)
104 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
105 FIXME("(%p)->(%p)\n", This
, pctinfo
);
109 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection
*iface
, UINT iTInfo
,
110 LCID lcid
, ITypeInfo
**ppTInfo
)
112 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
113 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
117 static HRESULT WINAPI
HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection
*iface
, REFIID riid
,
118 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
120 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
121 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
126 static HRESULT WINAPI
HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection
*iface
, DISPID dispIdMember
,
127 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
128 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
130 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
131 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
132 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
136 static HRESULT WINAPI
HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection
*iface
, long *p
)
138 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
141 TRACE("(%p)->(%p)\n", This
, p
);
143 nsIDOMNodeList_GetLength(This
->nslist
, &length
);
148 static HRESULT WINAPI
HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection
*iface
, IUnknown
**p
)
150 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
151 FIXME("(%p)->(%p)\n", This
, p
);
155 static HRESULT WINAPI
HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
*iface
, long index
, IDispatch
**ppItem
)
157 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
158 nsIDOMNode
*nsnode
= NULL
;
162 TRACE("(%p)->(%ld %p)\n", This
, index
, ppItem
);
164 nsIDOMNodeList_GetLength(This
->nslist
, &length
);
165 if(index
< 0 || index
>= length
)
168 nsres
= nsIDOMNodeList_Item(This
->nslist
, index
, &nsnode
);
169 if(NS_FAILED(nsres
) || !nsnode
) {
170 ERR("Item failed: %08x\n", nsres
);
174 *ppItem
= (IDispatch
*)get_node(This
->doc
, nsnode
, TRUE
);
175 IDispatch_AddRef(*ppItem
);
179 #define DISPID_CHILDCOL_0 MSHTML_DISPID_CUSTOM_MIN
181 static HRESULT
HTMLDOMChildrenCollection_get_dispid(IUnknown
*iface
, BSTR name
, DWORD flags
, DISPID
*dispid
)
183 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
188 for(ptr
= name
; *ptr
&& isdigitW(*ptr
); ptr
++)
189 idx
= idx
*10 + (*ptr
-'0');
191 return DISP_E_UNKNOWNNAME
;
193 nsIDOMNodeList_GetLength(This
->nslist
, &len
);
195 return DISP_E_UNKNOWNNAME
;
197 *dispid
= DISPID_CHILDCOL_0
+ idx
;
198 TRACE("ret %x\n", *dispid
);
202 static HRESULT
HTMLDOMChildrenCollection_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
203 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
205 HTMLDOMChildrenCollection
*This
= HTMLCHILDCOL_THIS(iface
);
207 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
210 case INVOKE_PROPERTYGET
: {
211 IDispatch
*disp
= NULL
;
214 hres
= IHTMLDOMChildrenCollection_item(HTMLCHILDCOL(This
), id
- DISPID_CHILDCOL_0
, &disp
);
218 V_VT(res
) = VT_DISPATCH
;
219 V_DISPATCH(res
) = disp
;
224 FIXME("unimplemented flags %x\n", flags
);
231 #undef HTMLCHILDCOL_THIS
233 static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl
= {
234 HTMLDOMChildrenCollection_QueryInterface
,
235 HTMLDOMChildrenCollection_AddRef
,
236 HTMLDOMChildrenCollection_Release
,
237 HTMLDOMChildrenCollection_GetTypeInfoCount
,
238 HTMLDOMChildrenCollection_GetTypeInfo
,
239 HTMLDOMChildrenCollection_GetIDsOfNames
,
240 HTMLDOMChildrenCollection_Invoke
,
241 HTMLDOMChildrenCollection_get_length
,
242 HTMLDOMChildrenCollection__newEnum
,
243 HTMLDOMChildrenCollection_item
246 static const tid_t HTMLDOMChildrenCollection_iface_tids
[] = {
247 IHTMLDOMChildrenCollection_tid
,
251 static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl
= {
252 HTMLDOMChildrenCollection_get_dispid
,
253 HTMLDOMChildrenCollection_invoke
256 static dispex_static_data_t HTMLDOMChildrenCollection_dispex
= {
257 &HTMLDOMChildrenCollection_dispex_vtbl
,
258 DispDOMChildrenCollection_tid
,
260 HTMLDOMChildrenCollection_iface_tids
263 static IHTMLDOMChildrenCollection
*create_child_collection(HTMLDocument
*doc
, nsIDOMNodeList
*nslist
)
265 HTMLDOMChildrenCollection
*ret
;
267 ret
= heap_alloc_zero(sizeof(*ret
));
268 ret
->lpIHTMLDOMChildrenCollectionVtbl
= &HTMLDOMChildrenCollectionVtbl
;
271 nsIDOMNodeList_AddRef(nslist
);
272 ret
->nslist
= nslist
;
275 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLCHILDCOL(ret
), &HTMLDOMChildrenCollection_dispex
);
277 return HTMLCHILDCOL(ret
);
280 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
282 static HRESULT WINAPI
HTMLDOMNode_QueryInterface(IHTMLDOMNode
*iface
,
283 REFIID riid
, void **ppv
)
285 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
287 return This
->vtbl
->qi(This
, riid
, ppv
);
290 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
292 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
293 LONG ref
= InterlockedIncrement(&This
->ref
);
295 TRACE("(%p) ref=%d\n", This
, ref
);
300 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
302 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
303 LONG ref
= InterlockedDecrement(&This
->ref
);
305 TRACE("(%p) ref=%d\n", This
, ref
);
308 This
->vtbl
->destructor(This
);
315 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
317 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
318 FIXME("(%p)->(%p)\n", This
, pctinfo
);
322 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
323 LCID lcid
, ITypeInfo
**ppTInfo
)
325 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
326 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
330 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
331 LPOLESTR
*rgszNames
, UINT cNames
,
332 LCID lcid
, DISPID
*rgDispId
)
334 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
335 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
340 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
341 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
342 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
344 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
345 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
346 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
350 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
352 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
355 TRACE("(%p)->(%p)\n", This
, p
);
357 nsIDOMNode_GetNodeType(This
->nsnode
, &type
);
375 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
376 * It needs more tests.
378 FIXME("type %u\n", type
);
385 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
387 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
392 TRACE("(%p)->(%p)\n", This
, p
);
394 nsres
= nsIDOMNode_GetParentNode(This
->nsnode
, &nsnode
);
395 if(NS_FAILED(nsres
)) {
396 ERR("GetParentNode failed: %08x\n", nsres
);
405 node
= get_node(This
->doc
, nsnode
, TRUE
);
406 *p
= HTMLDOMNODE(node
);
407 IHTMLDOMNode_AddRef(*p
);
411 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
413 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
414 PRBool has_child
= FALSE
;
417 TRACE("(%p)->(%p)\n", This
, fChildren
);
419 nsres
= nsIDOMNode_HasChildNodes(This
->nsnode
, &has_child
);
421 ERR("HasChildNodes failed: %08x\n", nsres
);
423 *fChildren
= has_child
? VARIANT_TRUE
: VARIANT_FALSE
;
427 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
429 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
430 nsIDOMNodeList
*nslist
;
433 TRACE("(%p)->(%p)\n", This
, p
);
435 nsres
= nsIDOMNode_GetChildNodes(This
->nsnode
, &nslist
);
436 if(NS_FAILED(nsres
)) {
437 ERR("GetChildNodes failed: %08x\n", nsres
);
441 *p
= (IDispatch
*)create_child_collection(This
->doc
, nslist
);
442 nsIDOMNodeList_Release(nslist
);
447 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
449 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
450 FIXME("(%p)->(%p)\n", This
, p
);
454 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
455 VARIANT refChild
, IHTMLDOMNode
**node
)
457 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
458 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
462 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*oldChild
,
465 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
466 HTMLDOMNode
*node_obj
;
470 TRACE("(%p)->(%p %p)\n", This
, oldChild
, node
);
472 node_obj
= get_node_obj(This
->doc
, (IUnknown
*)oldChild
);
476 nsres
= nsIDOMNode_RemoveChild(This
->nsnode
, node_obj
->nsnode
, &nsnode
);
477 if(NS_FAILED(nsres
)) {
478 ERR("RemoveChild failed: %08x\n", nsres
);
482 /* FIXME: Make sure that node != newChild */
483 *node
= HTMLDOMNODE(get_node(This
->doc
, nsnode
, TRUE
));
484 IHTMLDOMNode_AddRef(*node
);
488 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
489 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
491 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
492 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
496 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
497 IHTMLDOMNode
**clonedNode
)
499 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
500 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
504 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
505 IHTMLDOMNode
**removed
)
507 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
508 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
512 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
513 IHTMLDOMNode
**swappedNode
)
515 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
516 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
520 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
521 IHTMLDOMNode
**replaced
)
523 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
524 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
528 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
531 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
532 HTMLDOMNode
*node_obj
;
536 TRACE("(%p)->(%p %p)\n", This
, newChild
, node
);
538 node_obj
= get_node_obj(This
->doc
, (IUnknown
*)newChild
);
542 nsres
= nsIDOMNode_AppendChild(This
->nsnode
, node_obj
->nsnode
, &nsnode
);
543 if(NS_FAILED(nsres
)) {
544 ERR("AppendChild failed: %08x\n", nsres
);
548 /* FIXME: Make sure that node != newChild */
549 *node
= HTMLDOMNODE(get_node(This
->doc
, nsnode
, TRUE
));
550 IHTMLDOMNode_AddRef(*node
);
554 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
556 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
558 TRACE("(%p)->(%p)\n", This
, p
);
564 const PRUnichar
*name
;
567 nsAString_Init(&name_str
, NULL
);
568 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
570 if(NS_SUCCEEDED(nsres
)) {
571 nsAString_GetData(&name_str
, &name
);
572 *p
= SysAllocString(name
);
574 ERR("GetNodeName failed: %08x\n", nsres
);
577 nsAString_Finish(&name_str
);
583 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
585 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
587 TRACE("(%p)->()\n", This
);
593 TRACE("bstr %s\n", debugstr_w(V_BSTR(&v
)));
595 nsAString_Init(&val_str
, V_BSTR(&v
));
596 nsIDOMNode_SetNodeValue(This
->nsnode
, &val_str
);
597 nsAString_Finish(&val_str
);
603 FIXME("unsupported vt %d\n", V_VT(&v
));
609 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
611 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
612 const PRUnichar
*val
;
615 TRACE("(%p)->(%p)\n", This
, p
);
617 nsAString_Init(&val_str
, NULL
);
618 nsIDOMNode_GetNodeValue(This
->nsnode
, &val_str
);
619 nsAString_GetData(&val_str
, &val
);
623 V_BSTR(p
) = SysAllocString(val
);
628 nsAString_Finish(&val_str
);
633 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
635 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
636 nsIDOMNode
*nschild
= NULL
;
638 TRACE("(%p)->(%p)\n", This
, p
);
640 nsIDOMNode_GetFirstChild(This
->nsnode
, &nschild
);
642 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
643 IHTMLDOMNode_AddRef(*p
);
651 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
653 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
654 nsIDOMNode
*nschild
= NULL
;
656 TRACE("(%p)->(%p)\n", This
, p
);
658 nsIDOMNode_GetLastChild(This
->nsnode
, &nschild
);
660 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
661 IHTMLDOMNode_AddRef(*p
);
669 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
671 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
672 FIXME("(%p)->(%p)\n", This
, p
);
676 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
678 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
679 FIXME("(%p)->(%p)\n", This
, p
);
683 #undef HTMLDOMNODE_THIS
685 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
686 HTMLDOMNode_QueryInterface
,
689 HTMLDOMNode_GetTypeInfoCount
,
690 HTMLDOMNode_GetTypeInfo
,
691 HTMLDOMNode_GetIDsOfNames
,
693 HTMLDOMNode_get_nodeType
,
694 HTMLDOMNode_get_parentNode
,
695 HTMLDOMNode_hasChildNodes
,
696 HTMLDOMNode_get_childNodes
,
697 HTMLDOMNode_get_attributes
,
698 HTMLDOMNode_insertBefore
,
699 HTMLDOMNode_removeChild
,
700 HTMLDOMNode_replaceChild
,
701 HTMLDOMNode_cloneNode
,
702 HTMLDOMNode_removeNode
,
703 HTMLDOMNode_swapNode
,
704 HTMLDOMNode_replaceNode
,
705 HTMLDOMNode_appendChild
,
706 HTMLDOMNode_get_nodeName
,
707 HTMLDOMNode_put_nodeValue
,
708 HTMLDOMNode_get_nodeValue
,
709 HTMLDOMNode_get_firstChild
,
710 HTMLDOMNode_get_lastChild
,
711 HTMLDOMNode_get_previousSibling
,
712 HTMLDOMNode_get_nextSibling
715 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
717 static HRESULT WINAPI
HTMLDOMNode2_QueryInterface(IHTMLDOMNode2
*iface
,
718 REFIID riid
, void **ppv
)
720 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
722 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This
), riid
, ppv
);
725 static ULONG WINAPI
HTMLDOMNode2_AddRef(IHTMLDOMNode2
*iface
)
727 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
729 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This
));
732 static ULONG WINAPI
HTMLDOMNode2_Release(IHTMLDOMNode2
*iface
)
734 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
736 return IHTMLDOMNode_Release(HTMLDOMNODE(This
));
739 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2
*iface
, UINT
*pctinfo
)
741 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
742 FIXME("(%p)->(%p)\n", This
, pctinfo
);
746 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2
*iface
, UINT iTInfo
,
747 LCID lcid
, ITypeInfo
**ppTInfo
)
749 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
750 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
754 static HRESULT WINAPI
HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2
*iface
, REFIID riid
,
755 LPOLESTR
*rgszNames
, UINT cNames
,
756 LCID lcid
, DISPID
*rgDispId
)
758 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
759 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
764 static HRESULT WINAPI
HTMLDOMNode2_Invoke(IHTMLDOMNode2
*iface
, DISPID dispIdMember
,
765 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
766 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
768 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
769 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
770 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
774 static HRESULT WINAPI
HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2
*iface
, IDispatch
**p
)
776 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
777 FIXME("(%p)->(%p)\n", This
, p
);
781 #undef HTMLDOMNODE2_THIS
783 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl
= {
784 HTMLDOMNode2_QueryInterface
,
786 HTMLDOMNode2_Release
,
787 HTMLDOMNode2_GetTypeInfoCount
,
788 HTMLDOMNode2_GetTypeInfo
,
789 HTMLDOMNode2_GetIDsOfNames
,
791 HTMLDOMNode2_get_ownerDocument
794 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
798 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
799 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
800 *ppv
= HTMLDOMNODE(This
);
801 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
802 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
803 *ppv
= HTMLDOMNODE(This
);
804 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
805 if(This
->dispex
.data
) {
806 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
807 *ppv
= DISPATCHEX(&This
->dispex
);
809 FIXME("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
810 return E_NOINTERFACE
;
812 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
813 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
814 *ppv
= HTMLDOMNODE(This
);
815 }else if(IsEqualGUID(&IID_IHTMLDOMNode2
, riid
)) {
816 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This
, ppv
);
817 *ppv
= HTMLDOMNODE2(This
);
818 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
819 return *ppv
? S_OK
: E_NOINTERFACE
;
823 IUnknown_AddRef((IUnknown
*)*ppv
);
827 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
828 return E_NOINTERFACE
;
831 void HTMLDOMNode_destructor(HTMLDOMNode
*This
)
834 nsIDOMNode_Release(This
->nsnode
);
835 if(This
->event_target
)
836 release_event_target(This
->event_target
);
839 static const NodeImplVtbl HTMLDOMNodeImplVtbl
= {
841 HTMLDOMNode_destructor
844 void HTMLDOMNode_Init(HTMLDocument
*doc
, HTMLDOMNode
*node
, nsIDOMNode
*nsnode
)
846 node
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
847 node
->lpHTMLDOMNode2Vtbl
= &HTMLDOMNode2Vtbl
;
851 nsIDOMNode_AddRef(nsnode
);
852 node
->nsnode
= nsnode
;
854 node
->next
= doc
->nodes
;
858 static HTMLDOMNode
*create_node(HTMLDocument
*doc
, nsIDOMNode
*nsnode
)
863 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
867 ret
= &HTMLElement_Create(doc
, nsnode
, FALSE
)->node
;
870 ret
= HTMLDOMTextNode_Create(doc
, nsnode
);
873 ret
= &HTMLCommentElement_Create(doc
, nsnode
)->node
;
876 ret
= heap_alloc_zero(sizeof(HTMLDOMNode
));
877 ret
->vtbl
= &HTMLDOMNodeImplVtbl
;
878 HTMLDOMNode_Init(doc
, ret
, nsnode
);
881 TRACE("type %d ret %p\n", node_type
, ret
);
888 * List looks really ugly here. We should use a better data structure or
889 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
892 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
, BOOL create
)
894 HTMLDOMNode
*iter
= This
->nodes
;
897 if(iter
->nsnode
== nsnode
)
905 return create_node(This
, nsnode
);
910 * We should use better way for getting node object (like private interface)
911 * or avoid it at all.
913 static HTMLDOMNode
*get_node_obj(HTMLDocument
*This
, IUnknown
*iface
)
915 HTMLDOMNode
*iter
= This
->nodes
;
918 IUnknown_QueryInterface(iface
, &IID_IHTMLDOMNode
, (void**)&node
);
919 IHTMLDOMNode_Release(node
);
922 if(HTMLDOMNODE(iter
) == node
)
927 FIXME("Not found %p\n", iface
);
931 void release_nodes(HTMLDocument
*This
)
933 HTMLDOMNode
*iter
, *next
;
938 for(iter
= This
->nodes
; iter
; iter
= next
) {
941 IHTMLDOMNode_Release(HTMLDOMNODE(iter
));