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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 #define NSSUPPORTS(x) ((nsISupports*) &(x)->lpSupportsVtbl)
40 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
42 static HRESULT WINAPI
HTMLDOMNode_QueryInterface(IHTMLDOMNode
*iface
,
43 REFIID riid
, void **ppv
)
45 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
48 return IUnknown_QueryInterface(This
->impl
.unk
, riid
, ppv
);
52 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
53 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
54 *ppv
= HTMLDOMNODE(This
);
55 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
56 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
57 *ppv
= HTMLDOMNODE(This
);
58 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
59 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
60 *ppv
= HTMLDOMNODE(This
);
64 IUnknown_AddRef((IUnknown
*)*ppv
);
68 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
72 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
74 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
77 return IUnknown_AddRef(This
->impl
.unk
);
79 TRACE("(%p)\n", This
);
80 return IHTMLDocument2_AddRef(HTMLDOC(This
->doc
));
83 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
85 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
88 return IUnknown_Release(This
->impl
.unk
);
90 TRACE("(%p)\n", This
);
91 return IHTMLDocument2_Release(HTMLDOC(This
->doc
));
94 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
96 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
97 FIXME("(%p)->(%p)\n", This
, pctinfo
);
101 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
102 LCID lcid
, ITypeInfo
**ppTInfo
)
104 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
105 FIXME("(%p)->(%u %lu %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
109 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
110 LPOLESTR
*rgszNames
, UINT cNames
,
111 LCID lcid
, DISPID
*rgDispId
)
113 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
114 FIXME("(%p)->(%s %p %u %lu %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
119 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
120 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
121 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
123 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
124 FIXME("(%p)->(%ld %s %ld %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
125 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
129 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
131 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
132 FIXME("(%p)->(%p)\n", This
, p
);
136 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
138 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
139 FIXME("(%p)->(%p)\n", This
, p
);
143 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
145 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
146 FIXME("(%p)->(%p)\n", This
, fChildren
);
150 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
152 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
153 FIXME("(%p)->(%p)\n", This
, p
);
157 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
159 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
160 FIXME("(%p)->(%p)\n", This
, p
);
164 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
165 VARIANT refChild
, IHTMLDOMNode
**node
)
167 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
168 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
172 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
175 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
176 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
180 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
181 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
183 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
184 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
188 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
189 IHTMLDOMNode
**clonedNode
)
191 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
192 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
196 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
197 IHTMLDOMNode
**removed
)
199 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
200 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
204 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
205 IHTMLDOMNode
**swappedNode
)
207 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
208 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
212 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
213 IHTMLDOMNode
**replaced
)
215 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
216 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
220 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
223 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
224 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
228 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
230 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
231 FIXME("(%p)->(%p)\n", This
, p
);
235 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
237 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
238 FIXME("(%p)->()\n", This
);
242 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
244 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
245 FIXME("(%p)->(%p)\n", This
, p
);
249 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
251 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
252 FIXME("(%p)->(%p)\n", This
, p
);
256 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
258 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
259 FIXME("(%p)->(%p)\n", This
, p
);
263 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
265 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
266 FIXME("(%p)->(%p)\n", This
, p
);
270 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
272 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
273 FIXME("(%p)->(%p)\n", This
, p
);
277 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
278 HTMLDOMNode_QueryInterface
,
281 HTMLDOMNode_GetTypeInfoCount
,
282 HTMLDOMNode_GetTypeInfo
,
283 HTMLDOMNode_GetIDsOfNames
,
285 HTMLDOMNode_get_nodeType
,
286 HTMLDOMNode_get_parentNode
,
287 HTMLDOMNode_hasChildNodes
,
288 HTMLDOMNode_get_childNodes
,
289 HTMLDOMNode_get_attributes
,
290 HTMLDOMNode_insertBefore
,
291 HTMLDOMNode_removeChild
,
292 HTMLDOMNode_replaceChild
,
293 HTMLDOMNode_cloneNode
,
294 HTMLDOMNode_removeNode
,
295 HTMLDOMNode_swapNode
,
296 HTMLDOMNode_replaceNode
,
297 HTMLDOMNode_appendChild
,
298 HTMLDOMNode_get_nodeName
,
299 HTMLDOMNode_put_nodeValue
,
300 HTMLDOMNode_get_nodeValue
,
301 HTMLDOMNode_get_firstChild
,
302 HTMLDOMNode_get_lastChild
,
303 HTMLDOMNode_get_previousSibling
,
304 HTMLDOMNode_get_nextSibling
309 * List looks really ugly here. We should use a better data structure or
310 * (better) find a way to store HTMLDOMelement poiner in nsIDOMNode.
313 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
)
315 HTMLDOMNode
*iter
= This
->nodes
, *ret
;
319 if(iter
->nsnode
== nsnode
)
327 ret
= HeapAlloc(GetProcessHeap(), 0, sizeof(HTMLDOMNode
));
328 ret
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
329 ret
->node_type
= NT_UNKNOWN
;
330 ret
->impl
.unk
= NULL
;
333 nsIDOMNode_AddRef(nsnode
);
334 ret
->nsnode
= nsnode
;
336 ret
->next
= This
->nodes
;
339 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
341 if(node_type
== NS_ELEMENT_NODE
342 || node_type
== NS_DOCUMENT_NODE
)
343 HTMLElement_Create(ret
);
348 void release_nodes(HTMLDocument
*This
)
350 HTMLDOMNode
*iter
, *next
;
355 for(iter
= This
->nodes
; iter
; iter
= next
) {
358 iter
->destructor(iter
->impl
.unk
);
359 nsIDOMNode_Release(iter
->nsnode
);
360 HeapFree(GetProcessHeap(), 0, iter
);