Release 0.9.61.
[wine/gsoc-2012-control.git] / dlls / mshtml / htmlnode.c
blobf330d15ac64d8703c2ad4859031b48eef533f6ab
1 /*
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 DispatchEx dispex;
36 const IHTMLDOMChildrenCollectionVtbl *lpIHTMLDOMChildrenCollectionVtbl;
38 LONG ref;
40 /* FIXME: implement weak reference */
41 HTMLDocument *doc;
43 nsIDOMNodeList *nslist;
44 } HTMLDOMChildrenCollection;
46 #define HTMLCHILDCOL(x) ((IHTMLDOMChildrenCollection*) &(x)->lpIHTMLDOMChildrenCollectionVtbl)
48 #define HTMLCHILDCOL_THIS(iface) DEFINE_THIS(HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection, iface)
50 static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv)
52 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
54 *ppv = NULL;
56 if(IsEqualGUID(&IID_IUnknown, riid)) {
57 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
58 *ppv = HTMLCHILDCOL(This);
59 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
60 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
61 *ppv = HTMLCHILDCOL(This);
62 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
63 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
64 *ppv = DISPATCHEX(&This->dispex);
65 }else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) {
66 TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv);
67 *ppv = HTMLCHILDCOL(This);
70 if(*ppv) {
71 IUnknown_AddRef((IUnknown*)*ppv);
72 return S_OK;
75 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
76 return E_NOINTERFACE;
79 static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface)
81 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
82 LONG ref = InterlockedIncrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
86 return ref;
89 static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface)
91 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
92 LONG ref = InterlockedDecrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, ref);
96 if(!ref) {
97 nsIDOMNodeList_Release(This->nslist);
98 heap_free(This);
101 return ref;
104 static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo)
106 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
107 FIXME("(%p)->(%p)\n", This, pctinfo);
108 return E_NOTIMPL;
111 static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo,
112 LCID lcid, ITypeInfo **ppTInfo)
114 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
115 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
116 return E_NOTIMPL;
119 static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid,
120 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
122 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
123 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
124 lcid, rgDispId);
125 return E_NOTIMPL;
128 static HRESULT WINAPI HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection *iface, DISPID dispIdMember,
129 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
130 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
132 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
133 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
134 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, long *p)
140 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
141 PRUint32 length=0;
143 TRACE("(%p)->(%p)\n", This, p);
145 nsIDOMNodeList_GetLength(This->nslist, &length);
146 *p = length;
147 return S_OK;
150 static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
152 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
153 FIXME("(%p)->(%p)\n", This, p);
154 return E_NOTIMPL;
157 static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, long index, IDispatch **ppItem)
159 HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
160 nsIDOMNode *nsnode = NULL;
161 PRUint32 length=0;
162 nsresult nsres;
164 TRACE("(%p)->(%ld %p)\n", This, index, ppItem);
166 nsIDOMNodeList_GetLength(This->nslist, &length);
167 if(index < 0 || index > length)
168 return E_INVALIDARG;
170 nsres = nsIDOMNodeList_Item(This->nslist, index, &nsnode);
171 if(NS_FAILED(nsres) || !nsnode) {
172 ERR("Item failed: %08x\n", nsres);
173 return E_FAIL;
176 *ppItem = (IDispatch*)get_node(This->doc, nsnode, TRUE);
177 IDispatch_AddRef(*ppItem);
178 return S_OK;
181 #undef HTMLCHILDCOL_THIS
183 static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = {
184 HTMLDOMChildrenCollection_QueryInterface,
185 HTMLDOMChildrenCollection_AddRef,
186 HTMLDOMChildrenCollection_Release,
187 HTMLDOMChildrenCollection_GetTypeInfoCount,
188 HTMLDOMChildrenCollection_GetTypeInfo,
189 HTMLDOMChildrenCollection_GetIDsOfNames,
190 HTMLDOMChildrenCollection_Invoke,
191 HTMLDOMChildrenCollection_get_length,
192 HTMLDOMChildrenCollection__newEnum,
193 HTMLDOMChildrenCollection_item
196 static dispex_static_data_t HTMLDOMChildrenCollection_dispex = {
197 NULL,
198 DispDOMChildrenCollection_tid,
199 NULL,
201 IHTMLDOMChildrenCollection_tid,
206 static IHTMLDOMChildrenCollection *create_child_collection(HTMLDocument *doc, nsIDOMNodeList *nslist)
208 HTMLDOMChildrenCollection *ret;
210 ret = heap_alloc_zero(sizeof(*ret));
211 ret->lpIHTMLDOMChildrenCollectionVtbl = &HTMLDOMChildrenCollectionVtbl;
212 ret->ref = 1;
214 nsIDOMNodeList_AddRef(nslist);
215 ret->nslist = nslist;
216 ret->doc = doc;
218 init_dispex(&ret->dispex, (IUnknown*)HTMLCHILDCOL(ret), &HTMLDOMChildrenCollection_dispex);
220 return HTMLCHILDCOL(ret);
223 #define HTMLDOMNODE_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode, iface)
225 static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
226 REFIID riid, void **ppv)
228 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
230 return This->vtbl->qi(This, riid, ppv);
233 static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
235 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
236 LONG ref = InterlockedIncrement(&This->ref);
238 TRACE("(%p) ref=%d\n", This, ref);
240 return ref;
243 static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
245 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
246 LONG ref = InterlockedDecrement(&This->ref);
248 TRACE("(%p) ref=%d\n", This, ref);
250 if(!ref) {
251 This->vtbl->destructor(This);
252 heap_free(This);
255 return ref;
258 static HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
260 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
261 FIXME("(%p)->(%p)\n", This, pctinfo);
262 return E_NOTIMPL;
265 static HRESULT WINAPI HTMLDOMNode_GetTypeInfo(IHTMLDOMNode *iface, UINT iTInfo,
266 LCID lcid, ITypeInfo **ppTInfo)
268 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
269 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
270 return E_NOTIMPL;
273 static HRESULT WINAPI HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode *iface, REFIID riid,
274 LPOLESTR *rgszNames, UINT cNames,
275 LCID lcid, DISPID *rgDispId)
277 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
278 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
279 lcid, rgDispId);
280 return E_NOTIMPL;
283 static HRESULT WINAPI HTMLDOMNode_Invoke(IHTMLDOMNode *iface, DISPID dispIdMember,
284 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
285 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
287 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
288 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
289 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
290 return E_NOTIMPL;
293 static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p)
295 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
296 PRUint16 type = -1;
298 TRACE("(%p)->(%p)\n", This, p);
300 nsIDOMNode_GetNodeType(This->nsnode, &type);
302 switch(type) {
303 case ELEMENT_NODE:
304 *p = 1;
305 break;
306 case TEXT_NODE:
307 *p = 3;
308 break;
309 case COMMENT_NODE:
310 *p = 8;
311 break;
312 default:
314 * FIXME:
315 * According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
316 * It needs more tests.
318 FIXME("type %u\n", type);
319 *p = 0;
322 return S_OK;
325 static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p)
327 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
328 FIXME("(%p)->(%p)\n", This, p);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLDOMNode_hasChildNodes(IHTMLDOMNode *iface, VARIANT_BOOL *fChildren)
334 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
335 FIXME("(%p)->(%p)\n", This, fChildren);
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLDOMNode_get_childNodes(IHTMLDOMNode *iface, IDispatch **p)
341 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
342 nsIDOMNodeList *nslist;
343 nsresult nsres;
345 TRACE("(%p)->(%p)\n", This, p);
347 nsres = nsIDOMNode_GetChildNodes(This->nsnode, &nslist);
348 if(NS_FAILED(nsres)) {
349 ERR("GetChildNodes failed: %08x\n", nsres);
350 return E_FAIL;
353 *p = (IDispatch*)create_child_collection(This->doc, nslist);
354 nsIDOMNodeList_Release(nslist);
356 return S_OK;
359 static HRESULT WINAPI HTMLDOMNode_get_attributes(IHTMLDOMNode *iface, IDispatch **p)
361 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
362 FIXME("(%p)->(%p)\n", This, p);
363 return E_NOTIMPL;
366 static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
367 VARIANT refChild, IHTMLDOMNode **node)
369 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
370 FIXME("(%p)->(%p v %p)\n", This, newChild, node);
371 return E_NOTIMPL;
374 static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
375 IHTMLDOMNode **node)
377 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
378 FIXME("(%p)->(%p %p)\n", This, newChild, node);
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLDOMNode_replaceChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
383 IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
385 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
386 FIXME("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
387 return E_NOTIMPL;
390 static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
391 IHTMLDOMNode **clonedNode)
393 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
394 FIXME("(%p)->(%x %p)\n", This, fDeep, clonedNode);
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLDOMNode_removeNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
399 IHTMLDOMNode **removed)
401 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
402 FIXME("(%p)->(%x %p)\n", This, fDeep, removed);
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLDOMNode_swapNode(IHTMLDOMNode *iface, IHTMLDOMNode *otherNode,
407 IHTMLDOMNode **swappedNode)
409 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
410 FIXME("(%p)->(%p %p)\n", This, otherNode, swappedNode);
411 return E_NOTIMPL;
414 static HRESULT WINAPI HTMLDOMNode_replaceNode(IHTMLDOMNode *iface, IHTMLDOMNode *replacement,
415 IHTMLDOMNode **replaced)
417 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
418 FIXME("(%p)->(%p %p)\n", This, replacement, replaced);
419 return E_NOTIMPL;
422 static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
423 IHTMLDOMNode **node)
425 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
426 FIXME("(%p)->(%p %p)\n", This, newChild, node);
427 return E_NOTIMPL;
430 static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
432 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
434 TRACE("(%p)->(%p)\n", This, p);
436 *p = NULL;
438 if(This->nsnode) {
439 nsAString name_str;
440 const PRUnichar *name;
441 nsresult nsres;
443 nsAString_Init(&name_str, NULL);
444 nsres = nsIDOMNode_GetNodeName(This->nsnode, &name_str);
446 if(NS_SUCCEEDED(nsres)) {
447 nsAString_GetData(&name_str, &name);
448 *p = SysAllocString(name);
449 }else {
450 ERR("GetNodeName failed: %08x\n", nsres);
453 nsAString_Finish(&name_str);
456 return S_OK;
459 static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
461 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
462 FIXME("(%p)->()\n", This);
463 return E_NOTIMPL;
466 static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p)
468 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
470 return E_NOTIMPL;
473 static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
475 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
476 nsIDOMNode *nschild = NULL;
478 TRACE("(%p)->(%p)\n", This, p);
480 nsIDOMNode_GetFirstChild(This->nsnode, &nschild);
481 if(nschild) {
482 *p = HTMLDOMNODE(get_node(This->doc, nschild, TRUE));
483 IHTMLDOMNode_AddRef(*p);
484 }else {
485 *p = NULL;
488 return S_OK;
491 static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
493 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
495 return E_NOTIMPL;
498 static HRESULT WINAPI HTMLDOMNode_get_previousSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
500 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
501 FIXME("(%p)->(%p)\n", This, p);
502 return E_NOTIMPL;
505 static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
507 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
508 FIXME("(%p)->(%p)\n", This, p);
509 return E_NOTIMPL;
512 #undef HTMLDOMNODE_THIS
514 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
515 HTMLDOMNode_QueryInterface,
516 HTMLDOMNode_AddRef,
517 HTMLDOMNode_Release,
518 HTMLDOMNode_GetTypeInfoCount,
519 HTMLDOMNode_GetTypeInfo,
520 HTMLDOMNode_GetIDsOfNames,
521 HTMLDOMNode_Invoke,
522 HTMLDOMNode_get_nodeType,
523 HTMLDOMNode_get_parentNode,
524 HTMLDOMNode_hasChildNodes,
525 HTMLDOMNode_get_childNodes,
526 HTMLDOMNode_get_attributes,
527 HTMLDOMNode_insertBefore,
528 HTMLDOMNode_removeChild,
529 HTMLDOMNode_replaceChild,
530 HTMLDOMNode_cloneNode,
531 HTMLDOMNode_removeNode,
532 HTMLDOMNode_swapNode,
533 HTMLDOMNode_replaceNode,
534 HTMLDOMNode_appendChild,
535 HTMLDOMNode_get_nodeName,
536 HTMLDOMNode_put_nodeValue,
537 HTMLDOMNode_get_nodeValue,
538 HTMLDOMNode_get_firstChild,
539 HTMLDOMNode_get_lastChild,
540 HTMLDOMNode_get_previousSibling,
541 HTMLDOMNode_get_nextSibling
544 #define HTMLDOMNODE2_THIS(iface) DEFINE_THIS(HTMLDOMNode, HTMLDOMNode2, iface)
546 static HRESULT WINAPI HTMLDOMNode2_QueryInterface(IHTMLDOMNode2 *iface,
547 REFIID riid, void **ppv)
549 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
551 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(This), riid, ppv);
554 static ULONG WINAPI HTMLDOMNode2_AddRef(IHTMLDOMNode2 *iface)
556 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
558 return IHTMLDOMNode_AddRef(HTMLDOMNODE(This));
561 static ULONG WINAPI HTMLDOMNode2_Release(IHTMLDOMNode2 *iface)
563 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
565 return IHTMLDOMNode_Release(HTMLDOMNODE(This));
568 static HRESULT WINAPI HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2 *iface, UINT *pctinfo)
570 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
571 FIXME("(%p)->(%p)\n", This, pctinfo);
572 return E_NOTIMPL;
575 static HRESULT WINAPI HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2 *iface, UINT iTInfo,
576 LCID lcid, ITypeInfo **ppTInfo)
578 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
579 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
580 return E_NOTIMPL;
583 static HRESULT WINAPI HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2 *iface, REFIID riid,
584 LPOLESTR *rgszNames, UINT cNames,
585 LCID lcid, DISPID *rgDispId)
587 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
588 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
589 lcid, rgDispId);
590 return E_NOTIMPL;
593 static HRESULT WINAPI HTMLDOMNode2_Invoke(IHTMLDOMNode2 *iface, DISPID dispIdMember,
594 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
595 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
597 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
598 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
599 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
600 return E_NOTIMPL;
603 static HRESULT WINAPI HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2 *iface, IDispatch **p)
605 HTMLDOMNode *This = HTMLDOMNODE2_THIS(iface);
606 FIXME("(%p)->(%p)\n", This, p);
607 return E_NOTIMPL;
610 #undef HTMLDOMNODE2_THIS
612 static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl = {
613 HTMLDOMNode2_QueryInterface,
614 HTMLDOMNode2_AddRef,
615 HTMLDOMNode2_Release,
616 HTMLDOMNode2_GetTypeInfoCount,
617 HTMLDOMNode2_GetTypeInfo,
618 HTMLDOMNode2_GetIDsOfNames,
619 HTMLDOMNode2_Invoke,
620 HTMLDOMNode2_get_ownerDocument
623 HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
625 *ppv = NULL;
627 if(IsEqualGUID(&IID_IUnknown, riid)) {
628 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
629 *ppv = HTMLDOMNODE(This);
630 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
631 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
632 *ppv = HTMLDOMNODE(This);
633 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
634 if(This->dispex.data) {
635 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
636 *ppv = DISPATCHEX(&This->dispex);
637 }else {
638 FIXME("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
639 return E_NOINTERFACE;
641 }else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
642 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
643 *ppv = HTMLDOMNODE(This);
644 }else if(IsEqualGUID(&IID_IHTMLDOMNode2, riid)) {
645 TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This, ppv);
646 *ppv = HTMLDOMNODE2(This);
649 if(*ppv) {
650 IUnknown_AddRef((IUnknown*)*ppv);
651 return S_OK;
654 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
655 return E_NOINTERFACE;
658 void HTMLDOMNode_destructor(HTMLDOMNode *This)
660 if(This->nsnode)
661 nsIDOMNode_Release(This->nsnode);
662 if(This->event_target)
663 release_event_target(This->event_target);
666 static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
667 HTMLDOMNode_QI,
668 HTMLDOMNode_destructor
671 static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
673 HTMLDOMNode *ret;
674 PRUint16 node_type;
676 nsIDOMNode_GetNodeType(nsnode, &node_type);
678 switch(node_type) {
679 case ELEMENT_NODE:
680 ret = &HTMLElement_Create(nsnode)->node;
681 break;
682 case TEXT_NODE:
683 ret = HTMLDOMTextNode_Create(nsnode);
684 break;
685 case COMMENT_NODE:
686 ret = &HTMLCommentElement_Create(nsnode)->node;
687 break;
688 default:
689 ret = heap_alloc_zero(sizeof(HTMLDOMNode));
690 ret->vtbl = &HTMLDOMNodeImplVtbl;
693 ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
694 ret->lpHTMLDOMNode2Vtbl = &HTMLDOMNode2Vtbl;
695 ret->ref = 1;
696 ret->doc = doc;
698 nsIDOMNode_AddRef(nsnode);
699 ret->nsnode = nsnode;
701 TRACE("type %d ret %p\n", node_type, ret);
703 return ret;
707 * FIXME
708 * List looks really ugly here. We should use a better data structure or
709 * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
712 HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode, BOOL create)
714 HTMLDOMNode *iter = This->nodes, *ret;
716 while(iter) {
717 if(iter->nsnode == nsnode)
718 break;
719 iter = iter->next;
722 if(iter || !create)
723 return iter;
725 ret = create_node(This, nsnode);
727 ret->next = This->nodes;
728 This->nodes = ret;
730 return ret;
733 void release_nodes(HTMLDocument *This)
735 HTMLDOMNode *iter, *next;
737 if(!This->nodes)
738 return;
740 for(iter = This->nodes; iter; iter = next) {
741 next = iter->next;
742 iter->doc = NULL;
743 IHTMLDOMNode_Release(HTMLDOMNODE(iter));