slc: Added stub for SLGetWindowsInformationDWORD.
[wine/multimedia.git] / dlls / mshtml / htmlnode.c
blobc165aa76bdd271b93e9ef44c89ff160b058dd4d2
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 "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
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);
47 return This->vtbl->qi(This, riid, ppv);
50 static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
52 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
53 LONG ref = InterlockedIncrement(&This->ref);
55 TRACE("(%p) ref=%d\n", This, ref);
57 return ref;
60 static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
62 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
63 LONG ref = InterlockedDecrement(&This->ref);
65 TRACE("(%p) ref=%d\n", This, ref);
67 if(!ref) {
68 This->vtbl->destructor(This);
69 heap_free(This);
72 return ref;
75 static HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
77 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
78 FIXME("(%p)->(%p)\n", This, pctinfo);
79 return E_NOTIMPL;
82 static HRESULT WINAPI HTMLDOMNode_GetTypeInfo(IHTMLDOMNode *iface, UINT iTInfo,
83 LCID lcid, ITypeInfo **ppTInfo)
85 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
86 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
87 return E_NOTIMPL;
90 static HRESULT WINAPI HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode *iface, REFIID riid,
91 LPOLESTR *rgszNames, UINT cNames,
92 LCID lcid, DISPID *rgDispId)
94 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
95 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
96 lcid, rgDispId);
97 return E_NOTIMPL;
100 static HRESULT WINAPI HTMLDOMNode_Invoke(IHTMLDOMNode *iface, DISPID dispIdMember,
101 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
102 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
104 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
105 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
106 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p)
112 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, p);
114 return E_NOTIMPL;
117 static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p)
119 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
120 FIXME("(%p)->(%p)\n", This, p);
121 return E_NOTIMPL;
124 static HRESULT WINAPI HTMLDOMNode_hasChildNodes(IHTMLDOMNode *iface, VARIANT_BOOL *fChildren)
126 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
127 FIXME("(%p)->(%p)\n", This, fChildren);
128 return E_NOTIMPL;
131 static HRESULT WINAPI HTMLDOMNode_get_childNodes(IHTMLDOMNode *iface, IDispatch **p)
133 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
134 FIXME("(%p)->(%p)\n", This, p);
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLDOMNode_get_attributes(IHTMLDOMNode *iface, IDispatch **p)
140 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
141 FIXME("(%p)->(%p)\n", This, p);
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
146 VARIANT refChild, IHTMLDOMNode **node)
148 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
149 FIXME("(%p)->(%p v %p)\n", This, newChild, node);
150 return E_NOTIMPL;
153 static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
154 IHTMLDOMNode **node)
156 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
157 FIXME("(%p)->(%p %p)\n", This, newChild, node);
158 return E_NOTIMPL;
161 static HRESULT WINAPI HTMLDOMNode_replaceChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
162 IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
164 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
165 FIXME("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
170 IHTMLDOMNode **clonedNode)
172 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
173 FIXME("(%p)->(%x %p)\n", This, fDeep, clonedNode);
174 return E_NOTIMPL;
177 static HRESULT WINAPI HTMLDOMNode_removeNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
178 IHTMLDOMNode **removed)
180 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
181 FIXME("(%p)->(%x %p)\n", This, fDeep, removed);
182 return E_NOTIMPL;
185 static HRESULT WINAPI HTMLDOMNode_swapNode(IHTMLDOMNode *iface, IHTMLDOMNode *otherNode,
186 IHTMLDOMNode **swappedNode)
188 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
189 FIXME("(%p)->(%p %p)\n", This, otherNode, swappedNode);
190 return E_NOTIMPL;
193 static HRESULT WINAPI HTMLDOMNode_replaceNode(IHTMLDOMNode *iface, IHTMLDOMNode *replacement,
194 IHTMLDOMNode **replaced)
196 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
197 FIXME("(%p)->(%p %p)\n", This, replacement, replaced);
198 return E_NOTIMPL;
201 static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
202 IHTMLDOMNode **node)
204 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
205 FIXME("(%p)->(%p %p)\n", This, newChild, node);
206 return E_NOTIMPL;
209 static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
211 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
213 TRACE("(%p)->(%p)\n", This, p);
215 *p = NULL;
217 if(This->nsnode) {
218 nsAString name_str;
219 const PRUnichar *name;
220 nsresult nsres;
222 nsAString_Init(&name_str, NULL);
223 nsres = nsIDOMNode_GetNodeName(This->nsnode, &name_str);
225 if(NS_SUCCEEDED(nsres)) {
226 nsAString_GetData(&name_str, &name);
227 *p = SysAllocString(name);
228 }else {
229 ERR("GetNodeName failed: %08x\n", nsres);
232 nsAString_Finish(&name_str);
235 return S_OK;
238 static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
240 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
241 FIXME("(%p)->()\n", This);
242 return E_NOTIMPL;
245 static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p)
247 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
248 FIXME("(%p)->(%p)\n", This, p);
249 return E_NOTIMPL;
252 static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
254 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
255 FIXME("(%p)->(%p)\n", This, p);
256 return E_NOTIMPL;
259 static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
261 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
262 FIXME("(%p)->(%p)\n", This, p);
263 return E_NOTIMPL;
266 static HRESULT WINAPI HTMLDOMNode_get_previousSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
268 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
269 FIXME("(%p)->(%p)\n", This, p);
270 return E_NOTIMPL;
273 static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
275 HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
276 FIXME("(%p)->(%p)\n", This, p);
277 return E_NOTIMPL;
280 static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
281 HTMLDOMNode_QueryInterface,
282 HTMLDOMNode_AddRef,
283 HTMLDOMNode_Release,
284 HTMLDOMNode_GetTypeInfoCount,
285 HTMLDOMNode_GetTypeInfo,
286 HTMLDOMNode_GetIDsOfNames,
287 HTMLDOMNode_Invoke,
288 HTMLDOMNode_get_nodeType,
289 HTMLDOMNode_get_parentNode,
290 HTMLDOMNode_hasChildNodes,
291 HTMLDOMNode_get_childNodes,
292 HTMLDOMNode_get_attributes,
293 HTMLDOMNode_insertBefore,
294 HTMLDOMNode_removeChild,
295 HTMLDOMNode_replaceChild,
296 HTMLDOMNode_cloneNode,
297 HTMLDOMNode_removeNode,
298 HTMLDOMNode_swapNode,
299 HTMLDOMNode_replaceNode,
300 HTMLDOMNode_appendChild,
301 HTMLDOMNode_get_nodeName,
302 HTMLDOMNode_put_nodeValue,
303 HTMLDOMNode_get_nodeValue,
304 HTMLDOMNode_get_firstChild,
305 HTMLDOMNode_get_lastChild,
306 HTMLDOMNode_get_previousSibling,
307 HTMLDOMNode_get_nextSibling
310 HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
312 *ppv = NULL;
314 if(IsEqualGUID(&IID_IUnknown, riid)) {
315 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
316 *ppv = HTMLDOMNODE(This);
317 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
318 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
319 *ppv = HTMLDOMNODE(This);
320 }else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
321 TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
322 *ppv = HTMLDOMNODE(This);
325 if(*ppv) {
326 IUnknown_AddRef((IUnknown*)*ppv);
327 return S_OK;
330 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
331 return E_NOINTERFACE;
334 void HTMLDOMNode_destructor(HTMLDOMNode *This)
336 if(This->nsnode)
337 nsIDOMNode_Release(This->nsnode);
340 static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
341 HTMLDOMNode_QI,
342 HTMLDOMNode_destructor
345 static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
347 HTMLDOMNode *ret;
348 PRUint16 node_type;
350 nsIDOMNode_GetNodeType(nsnode, &node_type);
352 switch(node_type) {
353 case ELEMENT_NODE:
354 ret = &HTMLElement_Create(nsnode)->node;
355 break;
356 default:
357 ret = heap_alloc(sizeof(HTMLDOMNode));
358 ret->vtbl = &HTMLDOMNodeImplVtbl;
361 ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
362 ret->ref = 1;
363 ret->doc = doc;
365 nsIDOMNode_AddRef(nsnode);
366 ret->nsnode = nsnode;
368 return ret;
372 * FIXME
373 * List looks really ugly here. We should use a better data structure or
374 * (better) find a way to store HTMLDOMelement poiner in nsIDOMNode.
377 HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode)
379 HTMLDOMNode *iter = This->nodes, *ret;
381 while(iter) {
382 if(iter->nsnode == nsnode)
383 break;
384 iter = iter->next;
387 if(iter)
388 return iter;
390 ret = create_node(This, nsnode);
392 ret->next = This->nodes;
393 This->nodes = ret;
395 return ret;
398 void release_nodes(HTMLDocument *This)
400 HTMLDOMNode *iter, *next;
402 if(!This->nodes)
403 return;
405 for(iter = This->nodes; iter; iter = next) {
406 next = iter->next;
407 iter->doc = NULL;
408 IHTMLDOMNode_Release(HTMLDOMNODE(iter));