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 HTMLDOMNode
*node_obj
;
443 TRACE("(%p)->(%p %p)\n", This
, oldChild
, node
);
445 node_obj
= get_node_obj(This
->doc
, (IUnknown
*)oldChild
);
449 nsres
= nsIDOMNode_RemoveChild(This
->nsnode
, node_obj
->nsnode
, &nsnode
);
450 if(NS_FAILED(nsres
)) {
451 ERR("RemoveChild failed: %08x\n", nsres
);
455 /* FIXME: Make sure that node != newChild */
456 *node
= HTMLDOMNODE(get_node(This
->doc
, nsnode
, TRUE
));
457 IHTMLDOMNode_AddRef(*node
);
461 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
462 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
464 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
465 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
469 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
470 IHTMLDOMNode
**clonedNode
)
472 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
473 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
477 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
478 IHTMLDOMNode
**removed
)
480 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
481 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
485 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
486 IHTMLDOMNode
**swappedNode
)
488 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
489 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
493 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
494 IHTMLDOMNode
**replaced
)
496 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
497 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
501 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
504 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
505 HTMLDOMNode
*node_obj
;
509 TRACE("(%p)->(%p %p)\n", This
, newChild
, node
);
511 node_obj
= get_node_obj(This
->doc
, (IUnknown
*)newChild
);
515 nsres
= nsIDOMNode_AppendChild(This
->nsnode
, node_obj
->nsnode
, &nsnode
);
516 if(NS_FAILED(nsres
)) {
517 ERR("AppendChild failed: %08x\n", nsres
);
521 /* FIXME: Make sure that node != newChild */
522 *node
= HTMLDOMNODE(get_node(This
->doc
, nsnode
, TRUE
));
523 IHTMLDOMNode_AddRef(*node
);
527 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
529 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
531 TRACE("(%p)->(%p)\n", This
, p
);
537 const PRUnichar
*name
;
540 nsAString_Init(&name_str
, NULL
);
541 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
543 if(NS_SUCCEEDED(nsres
)) {
544 nsAString_GetData(&name_str
, &name
);
545 *p
= SysAllocString(name
);
547 ERR("GetNodeName failed: %08x\n", nsres
);
550 nsAString_Finish(&name_str
);
556 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
558 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
560 TRACE("(%p)->()\n", This
);
566 TRACE("bstr %s\n", debugstr_w(V_BSTR(&v
)));
568 nsAString_Init(&val_str
, V_BSTR(&v
));
569 nsIDOMNode_SetNodeValue(This
->nsnode
, &val_str
);
570 nsAString_Finish(&val_str
);
576 FIXME("unsupported vt %d\n", V_VT(&v
));
582 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
584 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
585 const PRUnichar
*val
;
588 TRACE("(%p)->(%p)\n", This
, p
);
590 nsAString_Init(&val_str
, NULL
);
591 nsIDOMNode_GetNodeValue(This
->nsnode
, &val_str
);
592 nsAString_GetData(&val_str
, &val
);
596 V_BSTR(p
) = SysAllocString(val
);
601 nsAString_Finish(&val_str
);
606 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
608 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
609 nsIDOMNode
*nschild
= NULL
;
611 TRACE("(%p)->(%p)\n", This
, p
);
613 nsIDOMNode_GetFirstChild(This
->nsnode
, &nschild
);
615 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
616 IHTMLDOMNode_AddRef(*p
);
624 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
626 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
627 nsIDOMNode
*nschild
= NULL
;
629 TRACE("(%p)->(%p)\n", This
, p
);
631 nsIDOMNode_GetLastChild(This
->nsnode
, &nschild
);
633 *p
= HTMLDOMNODE(get_node(This
->doc
, nschild
, TRUE
));
634 IHTMLDOMNode_AddRef(*p
);
642 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
644 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
645 FIXME("(%p)->(%p)\n", This
, p
);
649 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
651 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
652 FIXME("(%p)->(%p)\n", This
, p
);
656 #undef HTMLDOMNODE_THIS
658 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
659 HTMLDOMNode_QueryInterface
,
662 HTMLDOMNode_GetTypeInfoCount
,
663 HTMLDOMNode_GetTypeInfo
,
664 HTMLDOMNode_GetIDsOfNames
,
666 HTMLDOMNode_get_nodeType
,
667 HTMLDOMNode_get_parentNode
,
668 HTMLDOMNode_hasChildNodes
,
669 HTMLDOMNode_get_childNodes
,
670 HTMLDOMNode_get_attributes
,
671 HTMLDOMNode_insertBefore
,
672 HTMLDOMNode_removeChild
,
673 HTMLDOMNode_replaceChild
,
674 HTMLDOMNode_cloneNode
,
675 HTMLDOMNode_removeNode
,
676 HTMLDOMNode_swapNode
,
677 HTMLDOMNode_replaceNode
,
678 HTMLDOMNode_appendChild
,
679 HTMLDOMNode_get_nodeName
,
680 HTMLDOMNode_put_nodeValue
,
681 HTMLDOMNode_get_nodeValue
,
682 HTMLDOMNode_get_firstChild
,
683 HTMLDOMNode_get_lastChild
,
684 HTMLDOMNode_get_previousSibling
,
685 HTMLDOMNode_get_nextSibling
688 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
690 static HRESULT WINAPI
HTMLDOMNode2_QueryInterface(IHTMLDOMNode2
*iface
,
691 REFIID riid
, void **ppv
)
693 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
695 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This
), riid
, ppv
);
698 static ULONG WINAPI
HTMLDOMNode2_AddRef(IHTMLDOMNode2
*iface
)
700 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
702 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This
));
705 static ULONG WINAPI
HTMLDOMNode2_Release(IHTMLDOMNode2
*iface
)
707 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
709 return IHTMLDOMNode_Release(HTMLDOMNODE(This
));
712 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2
*iface
, UINT
*pctinfo
)
714 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
715 FIXME("(%p)->(%p)\n", This
, pctinfo
);
719 static HRESULT WINAPI
HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2
*iface
, UINT iTInfo
,
720 LCID lcid
, ITypeInfo
**ppTInfo
)
722 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
723 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
727 static HRESULT WINAPI
HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2
*iface
, REFIID riid
,
728 LPOLESTR
*rgszNames
, UINT cNames
,
729 LCID lcid
, DISPID
*rgDispId
)
731 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
732 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
737 static HRESULT WINAPI
HTMLDOMNode2_Invoke(IHTMLDOMNode2
*iface
, DISPID dispIdMember
,
738 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
739 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
741 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
742 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
743 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
747 static HRESULT WINAPI
HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2
*iface
, IDispatch
**p
)
749 HTMLDOMNode
*This
= HTMLDOMNODE2_THIS(iface
);
750 FIXME("(%p)->(%p)\n", This
, p
);
754 #undef HTMLDOMNODE2_THIS
756 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl
= {
757 HTMLDOMNode2_QueryInterface
,
759 HTMLDOMNode2_Release
,
760 HTMLDOMNode2_GetTypeInfoCount
,
761 HTMLDOMNode2_GetTypeInfo
,
762 HTMLDOMNode2_GetIDsOfNames
,
764 HTMLDOMNode2_get_ownerDocument
767 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
771 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
772 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
773 *ppv
= HTMLDOMNODE(This
);
774 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
775 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
776 *ppv
= HTMLDOMNODE(This
);
777 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
778 if(This
->dispex
.data
) {
779 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
780 *ppv
= DISPATCHEX(&This
->dispex
);
782 FIXME("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
783 return E_NOINTERFACE
;
785 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
786 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
787 *ppv
= HTMLDOMNODE(This
);
788 }else if(IsEqualGUID(&IID_IHTMLDOMNode2
, riid
)) {
789 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This
, ppv
);
790 *ppv
= HTMLDOMNODE2(This
);
794 IUnknown_AddRef((IUnknown
*)*ppv
);
798 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
799 return E_NOINTERFACE
;
802 void HTMLDOMNode_destructor(HTMLDOMNode
*This
)
805 nsIDOMNode_Release(This
->nsnode
);
806 if(This
->event_target
)
807 release_event_target(This
->event_target
);
810 static const NodeImplVtbl HTMLDOMNodeImplVtbl
= {
812 HTMLDOMNode_destructor
815 void HTMLDOMNode_Init(HTMLDocument
*doc
, HTMLDOMNode
*node
, nsIDOMNode
*nsnode
)
817 node
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
818 node
->lpHTMLDOMNode2Vtbl
= &HTMLDOMNode2Vtbl
;
822 nsIDOMNode_AddRef(nsnode
);
823 node
->nsnode
= nsnode
;
825 node
->next
= doc
->nodes
;
829 static HTMLDOMNode
*create_node(HTMLDocument
*doc
, nsIDOMNode
*nsnode
)
834 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
838 ret
= &HTMLElement_Create(doc
, nsnode
, FALSE
)->node
;
841 ret
= HTMLDOMTextNode_Create(doc
, nsnode
);
844 ret
= &HTMLCommentElement_Create(doc
, nsnode
)->node
;
847 ret
= heap_alloc_zero(sizeof(HTMLDOMNode
));
848 ret
->vtbl
= &HTMLDOMNodeImplVtbl
;
849 HTMLDOMNode_Init(doc
, ret
, nsnode
);
852 TRACE("type %d ret %p\n", node_type
, ret
);
859 * List looks really ugly here. We should use a better data structure or
860 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
863 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
, BOOL create
)
865 HTMLDOMNode
*iter
= This
->nodes
;
868 if(iter
->nsnode
== nsnode
)
876 return create_node(This
, nsnode
);
881 * We should use better way for getting node object (like private interface)
882 * or avoid it at all.
884 static HTMLDOMNode
*get_node_obj(HTMLDocument
*This
, IUnknown
*iface
)
886 HTMLDOMNode
*iter
= This
->nodes
;
889 IUnknown_QueryInterface(iface
, &IID_IHTMLDOMNode
, (void**)&node
);
890 IHTMLDOMNode_Release(node
);
893 if(HTMLDOMNODE(iter
) == node
)
898 FIXME("Not found %p\n", iface
);
902 void release_nodes(HTMLDocument
*This
)
904 HTMLDOMNode
*iter
, *next
;
909 for(iter
= This
->nodes
; iter
; iter
= next
) {
912 IHTMLDOMNode_Release(HTMLDOMNODE(iter
));