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);
217 FIXME("(%p)->(%p)\n", This, p);
221 static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
223 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
224 FIXME("(%p)->()\n", This);
228 static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p)
230 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
231 FIXME("(%p)->(%p)\n", This, p);
235 static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
237 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
238 FIXME("(%p)->(%p)\n", This, p);
242 static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
244 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
245 FIXME("(%p)->(%p)\n", This, p);
249 static HRESULT WINAPI HTMLDOMNode_get_previousSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
251 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
252 FIXME("(%p)->(%p)\n", This, p);
256 static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
258 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
259 FIXME("(%p)->(%p)\n", This, p);
263 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
264 HTMLDOMNode_QueryInterface,
267 HTMLDOMNode_GetTypeInfoCount,
268 HTMLDOMNode_GetTypeInfo,
269 HTMLDOMNode_GetIDsOfNames,
271 HTMLDOMNode_get_nodeType,
272 HTMLDOMNode_get_parentNode,
273 HTMLDOMNode_hasChildNodes,
274 HTMLDOMNode_get_childNodes,
275 HTMLDOMNode_get_attributes,
276 HTMLDOMNode_insertBefore,
277 HTMLDOMNode_removeChild,
278 HTMLDOMNode_replaceChild,
279 HTMLDOMNode_cloneNode,
280 HTMLDOMNode_removeNode,
281 HTMLDOMNode_swapNode,
282 HTMLDOMNode_replaceNode,
283 HTMLDOMNode_appendChild,
284 HTMLDOMNode_get_nodeName,
285 HTMLDOMNode_put_nodeValue,
286 HTMLDOMNode_get_nodeValue,
287 HTMLDOMNode_get_firstChild,
288 HTMLDOMNode_get_lastChild,
289 HTMLDOMNode_get_previousSibling,
290 HTMLDOMNode_get_nextSibling
293 HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
297 if(IsEqualGUID(&IID_IUnknown, riid)) {
298 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
299 *ppv = HTMLDOMNODE(This);
300 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
301 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
302 *ppv = HTMLDOMNODE(This);
303 }else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
304 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
305 *ppv = HTMLDOMNODE(This);
309 IUnknown_AddRef((IUnknown*)*ppv);
313 return E_NOINTERFACE;
318 * List looks really ugly here. We should use a better data structure or
319 * (better) find a way to store HTMLDOMelement poiner in nsIDOMNode.
322 HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode)
324 HTMLDOMNode *iter = This->nodes, *ret;
328 if(iter->nsnode == nsnode)
336 ret = mshtml_alloc(sizeof(HTMLDOMNode));
337 ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
338 ret->node_type = NT_UNKNOWN;
339 ret->impl.unk = NULL;
340 ret->destructor = NULL;
343 nsIDOMNode_AddRef(nsnode);
344 ret->nsnode = nsnode;
346 ret->next = This->nodes;
349 nsIDOMNode_GetNodeType(nsnode, &node_type);
351 if(node_type == NS_ELEMENT_NODE
352 || node_type == NS_DOCUMENT_NODE)
353 HTMLElement_Create(ret);
358 void release_nodes(HTMLDocument *This)
360 HTMLDOMNode *iter, *next;
365 for(iter = This->nodes; iter; iter = next) {
368 iter->destructor(iter->impl.unk);
369 nsIDOMNode_Release(iter->nsnode);