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
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
);
49 return IUnknown_QueryInterface(This
->impl
.unk
, riid
, ppv
);
51 hres
= HTMLDOMNode_QI(This
, riid
, ppv
);
53 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
58 static ULONG WINAPI
HTMLDOMNode_AddRef(IHTMLDOMNode
*iface
)
60 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
63 return IUnknown_AddRef(This
->impl
.unk
);
65 TRACE("(%p)\n", This
);
66 return IHTMLDocument2_AddRef(HTMLDOC(This
->doc
));
69 static ULONG WINAPI
HTMLDOMNode_Release(IHTMLDOMNode
*iface
)
71 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
74 return IUnknown_Release(This
->impl
.unk
);
76 TRACE("(%p)\n", This
);
77 return IHTMLDocument2_Release(HTMLDOC(This
->doc
));
80 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode
*iface
, UINT
*pctinfo
)
82 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
83 FIXME("(%p)->(%p)\n", This
, pctinfo
);
87 static HRESULT WINAPI
HTMLDOMNode_GetTypeInfo(IHTMLDOMNode
*iface
, UINT iTInfo
,
88 LCID lcid
, ITypeInfo
**ppTInfo
)
90 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
91 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
95 static HRESULT WINAPI
HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode
*iface
, REFIID riid
,
96 LPOLESTR
*rgszNames
, UINT cNames
,
97 LCID lcid
, DISPID
*rgDispId
)
99 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
100 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
105 static HRESULT WINAPI
HTMLDOMNode_Invoke(IHTMLDOMNode
*iface
, DISPID dispIdMember
,
106 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
107 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
109 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
110 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
111 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
115 static HRESULT WINAPI
HTMLDOMNode_get_nodeType(IHTMLDOMNode
*iface
, long *p
)
117 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
118 FIXME("(%p)->(%p)\n", This
, p
);
122 static HRESULT WINAPI
HTMLDOMNode_get_parentNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
124 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
125 FIXME("(%p)->(%p)\n", This
, p
);
129 static HRESULT WINAPI
HTMLDOMNode_hasChildNodes(IHTMLDOMNode
*iface
, VARIANT_BOOL
*fChildren
)
131 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
132 FIXME("(%p)->(%p)\n", This
, fChildren
);
136 static HRESULT WINAPI
HTMLDOMNode_get_childNodes(IHTMLDOMNode
*iface
, IDispatch
**p
)
138 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
139 FIXME("(%p)->(%p)\n", This
, p
);
143 static HRESULT WINAPI
HTMLDOMNode_get_attributes(IHTMLDOMNode
*iface
, IDispatch
**p
)
145 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
146 FIXME("(%p)->(%p)\n", This
, p
);
150 static HRESULT WINAPI
HTMLDOMNode_insertBefore(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
151 VARIANT refChild
, IHTMLDOMNode
**node
)
153 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
154 FIXME("(%p)->(%p v %p)\n", This
, newChild
, node
);
158 static HRESULT WINAPI
HTMLDOMNode_removeChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
161 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
162 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
166 static HRESULT WINAPI
HTMLDOMNode_replaceChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
167 IHTMLDOMNode
*oldChild
, IHTMLDOMNode
**node
)
169 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
170 FIXME("(%p)->(%p %p %p)\n", This
, newChild
, oldChild
, node
);
174 static HRESULT WINAPI
HTMLDOMNode_cloneNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
175 IHTMLDOMNode
**clonedNode
)
177 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
178 FIXME("(%p)->(%x %p)\n", This
, fDeep
, clonedNode
);
182 static HRESULT WINAPI
HTMLDOMNode_removeNode(IHTMLDOMNode
*iface
, VARIANT_BOOL fDeep
,
183 IHTMLDOMNode
**removed
)
185 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
186 FIXME("(%p)->(%x %p)\n", This
, fDeep
, removed
);
190 static HRESULT WINAPI
HTMLDOMNode_swapNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*otherNode
,
191 IHTMLDOMNode
**swappedNode
)
193 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
194 FIXME("(%p)->(%p %p)\n", This
, otherNode
, swappedNode
);
198 static HRESULT WINAPI
HTMLDOMNode_replaceNode(IHTMLDOMNode
*iface
, IHTMLDOMNode
*replacement
,
199 IHTMLDOMNode
**replaced
)
201 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
202 FIXME("(%p)->(%p %p)\n", This
, replacement
, replaced
);
206 static HRESULT WINAPI
HTMLDOMNode_appendChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
*newChild
,
209 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
210 FIXME("(%p)->(%p %p)\n", This
, newChild
, node
);
214 static HRESULT WINAPI
HTMLDOMNode_get_nodeName(IHTMLDOMNode
*iface
, BSTR
*p
)
216 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
218 TRACE("(%p)->(%p)\n", This
, p
);
224 const PRUnichar
*name
;
227 nsAString_Init(&name_str
, NULL
);
228 nsres
= nsIDOMNode_GetNodeName(This
->nsnode
, &name_str
);
230 if(NS_SUCCEEDED(nsres
)) {
231 nsAString_GetData(&name_str
, &name
, NULL
);
232 *p
= SysAllocString(name
);
234 ERR("GetNodeName failed: %08x\n", nsres
);
237 nsAString_Finish(&name_str
);
243 static HRESULT WINAPI
HTMLDOMNode_put_nodeValue(IHTMLDOMNode
*iface
, VARIANT v
)
245 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
246 FIXME("(%p)->()\n", This
);
250 static HRESULT WINAPI
HTMLDOMNode_get_nodeValue(IHTMLDOMNode
*iface
, VARIANT
*p
)
252 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
253 FIXME("(%p)->(%p)\n", This
, p
);
257 static HRESULT WINAPI
HTMLDOMNode_get_firstChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
259 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
260 FIXME("(%p)->(%p)\n", This
, p
);
264 static HRESULT WINAPI
HTMLDOMNode_get_lastChild(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
266 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
267 FIXME("(%p)->(%p)\n", This
, p
);
271 static HRESULT WINAPI
HTMLDOMNode_get_previousSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
273 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLDOMNode_get_nextSibling(IHTMLDOMNode
*iface
, IHTMLDOMNode
**p
)
280 HTMLDOMNode
*This
= HTMLDOMNODE_THIS(iface
);
281 FIXME("(%p)->(%p)\n", This
, p
);
285 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl
= {
286 HTMLDOMNode_QueryInterface
,
289 HTMLDOMNode_GetTypeInfoCount
,
290 HTMLDOMNode_GetTypeInfo
,
291 HTMLDOMNode_GetIDsOfNames
,
293 HTMLDOMNode_get_nodeType
,
294 HTMLDOMNode_get_parentNode
,
295 HTMLDOMNode_hasChildNodes
,
296 HTMLDOMNode_get_childNodes
,
297 HTMLDOMNode_get_attributes
,
298 HTMLDOMNode_insertBefore
,
299 HTMLDOMNode_removeChild
,
300 HTMLDOMNode_replaceChild
,
301 HTMLDOMNode_cloneNode
,
302 HTMLDOMNode_removeNode
,
303 HTMLDOMNode_swapNode
,
304 HTMLDOMNode_replaceNode
,
305 HTMLDOMNode_appendChild
,
306 HTMLDOMNode_get_nodeName
,
307 HTMLDOMNode_put_nodeValue
,
308 HTMLDOMNode_get_nodeValue
,
309 HTMLDOMNode_get_firstChild
,
310 HTMLDOMNode_get_lastChild
,
311 HTMLDOMNode_get_previousSibling
,
312 HTMLDOMNode_get_nextSibling
315 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*This
, REFIID riid
, void **ppv
)
319 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
320 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
321 *ppv
= HTMLDOMNODE(This
);
322 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
323 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
324 *ppv
= HTMLDOMNODE(This
);
325 }else if(IsEqualGUID(&IID_IHTMLDOMNode
, riid
)) {
326 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This
, ppv
);
327 *ppv
= HTMLDOMNODE(This
);
331 IUnknown_AddRef((IUnknown
*)*ppv
);
335 return E_NOINTERFACE
;
340 * List looks really ugly here. We should use a better data structure or
341 * (better) find a way to store HTMLDOMelement poiner in nsIDOMNode.
344 HTMLDOMNode
*get_node(HTMLDocument
*This
, nsIDOMNode
*nsnode
)
346 HTMLDOMNode
*iter
= This
->nodes
, *ret
;
350 if(iter
->nsnode
== nsnode
)
358 ret
= mshtml_alloc(sizeof(HTMLDOMNode
));
359 ret
->lpHTMLDOMNodeVtbl
= &HTMLDOMNodeVtbl
;
360 ret
->node_type
= NT_UNKNOWN
;
361 ret
->impl
.unk
= NULL
;
362 ret
->destructor
= NULL
;
365 nsIDOMNode_AddRef(nsnode
);
366 ret
->nsnode
= nsnode
;
368 ret
->next
= This
->nodes
;
371 nsIDOMNode_GetNodeType(nsnode
, &node_type
);
373 if(node_type
== NS_ELEMENT_NODE
374 || node_type
== NS_DOCUMENT_NODE
)
375 HTMLElement_Create(ret
);
380 void release_nodes(HTMLDocument
*This
)
382 HTMLDOMNode
*iter
, *next
;
387 for(iter
= This
->nodes
; iter
; iter
= next
) {
390 iter
->destructor(iter
->impl
.unk
);
391 nsIDOMNode_Release(iter
->nsnode
);