kernel32: Add a test for threads state when a process is being terminated.
[wine] / dlls / mshtml / htmlhead.c
1  /*
2  * Copyright 2011 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27
28 #include "wine/debug.h"
29
30 #include "mshtml_private.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
33
34 typedef struct {
35     HTMLElement element;
36
37     IHTMLTitleElement IHTMLTitleElement_iface;
38 } HTMLTitleElement;
39
40 static inline HTMLTitleElement *impl_from_IHTMLTitleElement(IHTMLTitleElement *iface)
41 {
42     return CONTAINING_RECORD(iface, HTMLTitleElement, IHTMLTitleElement_iface);
43 }
44
45 static HRESULT WINAPI HTMLTitleElement_QueryInterface(IHTMLTitleElement *iface,
46                                                          REFIID riid, void **ppv)
47 {
48     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
49
50     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
51 }
52
53 static ULONG WINAPI HTMLTitleElement_AddRef(IHTMLTitleElement *iface)
54 {
55     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
56
57     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
58 }
59
60 static ULONG WINAPI HTMLTitleElement_Release(IHTMLTitleElement *iface)
61 {
62     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
63
64     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
65 }
66
67 static HRESULT WINAPI HTMLTitleElement_GetTypeInfoCount(IHTMLTitleElement *iface, UINT *pctinfo)
68 {
69     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
70
71     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
72 }
73
74 static HRESULT WINAPI HTMLTitleElement_GetTypeInfo(IHTMLTitleElement *iface, UINT iTInfo,
75         LCID lcid, ITypeInfo **ppTInfo)
76 {
77     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
78
79     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
80             ppTInfo);
81 }
82
83 static HRESULT WINAPI HTMLTitleElement_GetIDsOfNames(IHTMLTitleElement *iface, REFIID riid,
84         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
85 {
86     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
87
88     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
89             cNames, lcid, rgDispId);
90 }
91
92 static HRESULT WINAPI HTMLTitleElement_Invoke(IHTMLTitleElement *iface, DISPID dispIdMember,
93         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
95 {
96     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
97
98     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
99             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 }
101
102 static HRESULT WINAPI HTMLTitleElement_put_text(IHTMLTitleElement *iface, BSTR v)
103 {
104     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
105     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
106     return E_NOTIMPL;
107 }
108
109 static HRESULT WINAPI HTMLTitleElement_get_text(IHTMLTitleElement *iface, BSTR *p)
110 {
111     HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
112     FIXME("(%p)->(%p)\n", This, p);
113     return E_NOTIMPL;
114 }
115
116 static const IHTMLTitleElementVtbl HTMLTitleElementVtbl = {
117     HTMLTitleElement_QueryInterface,
118     HTMLTitleElement_AddRef,
119     HTMLTitleElement_Release,
120     HTMLTitleElement_GetTypeInfoCount,
121     HTMLTitleElement_GetTypeInfo,
122     HTMLTitleElement_GetIDsOfNames,
123     HTMLTitleElement_Invoke,
124     HTMLTitleElement_put_text,
125     HTMLTitleElement_get_text
126 };
127
128 static inline HTMLTitleElement *HTMLTitleElement_from_HTMLDOMNode(HTMLDOMNode *iface)
129 {
130     return CONTAINING_RECORD(iface, HTMLTitleElement, element.node);
131 }
132
133 static HRESULT HTMLTitleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
134 {
135     HTMLTitleElement *This = HTMLTitleElement_from_HTMLDOMNode(iface);
136
137     if(IsEqualGUID(&IID_IHTMLTitleElement, riid)) {
138         TRACE("(%p)->(IID_IHTMLTitleElement %p)\n", This, ppv);
139         *ppv = &This->IHTMLTitleElement_iface;
140     }else {
141         return HTMLElement_QI(&This->element.node, riid, ppv);
142     }
143
144     IUnknown_AddRef((IUnknown*)*ppv);
145     return S_OK;
146 }
147
148 static void HTMLTitleElement_destructor(HTMLDOMNode *iface)
149 {
150     HTMLTitleElement *This = HTMLTitleElement_from_HTMLDOMNode(iface);
151
152     HTMLElement_destructor(&This->element.node);
153 }
154
155 static const NodeImplVtbl HTMLTitleElementImplVtbl = {
156     HTMLTitleElement_QI,
157     HTMLTitleElement_destructor,
158     HTMLElement_cpc,
159     HTMLElement_clone,
160     HTMLElement_handle_event,
161     HTMLElement_get_attr_col
162 };
163
164 static const tid_t HTMLTitleElement_iface_tids[] = {
165     HTMLELEMENT_TIDS,
166     IHTMLTitleElement_tid,
167     0
168 };
169 static dispex_static_data_t HTMLTitleElement_dispex = {
170     NULL,
171     DispHTMLTitleElement_tid,
172     NULL,
173     HTMLTitleElement_iface_tids
174 };
175
176 HRESULT HTMLTitleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
177 {
178     HTMLTitleElement *ret;
179
180     ret = heap_alloc_zero(sizeof(*ret));
181     if(!ret)
182         return E_OUTOFMEMORY;
183
184     ret->IHTMLTitleElement_iface.lpVtbl = &HTMLTitleElementVtbl;
185     ret->element.node.vtbl = &HTMLTitleElementImplVtbl;
186
187     HTMLElement_Init(&ret->element, doc, nselem, &HTMLTitleElement_dispex);
188
189     *elem = &ret->element;
190     return S_OK;
191 }
192
193 typedef struct {
194     HTMLElement element;
195
196     IHTMLHeadElement IHTMLHeadElement_iface;
197 } HTMLHeadElement;
198
199 static inline HTMLHeadElement *impl_from_IHTMLHeadElement(IHTMLHeadElement *iface)
200 {
201     return CONTAINING_RECORD(iface, HTMLHeadElement, IHTMLHeadElement_iface);
202 }
203
204 static HRESULT WINAPI HTMLHeadElement_QueryInterface(IHTMLHeadElement *iface,
205                                                          REFIID riid, void **ppv)
206 {
207     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
208
209     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
210 }
211
212 static ULONG WINAPI HTMLHeadElement_AddRef(IHTMLHeadElement *iface)
213 {
214     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
215
216     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
217 }
218
219 static ULONG WINAPI HTMLHeadElement_Release(IHTMLHeadElement *iface)
220 {
221     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
222
223     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
224 }
225
226 static HRESULT WINAPI HTMLHeadElement_GetTypeInfoCount(IHTMLHeadElement *iface, UINT *pctinfo)
227 {
228     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
229
230     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
231 }
232
233 static HRESULT WINAPI HTMLHeadElement_GetTypeInfo(IHTMLHeadElement *iface, UINT iTInfo,
234                                               LCID lcid, ITypeInfo **ppTInfo)
235 {
236     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
237
238     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
239             ppTInfo);
240 }
241
242 static HRESULT WINAPI HTMLHeadElement_GetIDsOfNames(IHTMLHeadElement *iface, REFIID riid,
243                                                 LPOLESTR *rgszNames, UINT cNames,
244                                                 LCID lcid, DISPID *rgDispId)
245 {
246     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
247
248     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
249             cNames, lcid, rgDispId);
250 }
251
252 static HRESULT WINAPI HTMLHeadElement_Invoke(IHTMLHeadElement *iface, DISPID dispIdMember,
253                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
254                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
255 {
256     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
257
258     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
259             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
260 }
261
262 static HRESULT WINAPI HTMLHeadElement_put_profile(IHTMLHeadElement *iface, BSTR v)
263 {
264     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
265     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
266     return E_NOTIMPL;
267 }
268
269 static HRESULT WINAPI HTMLHeadElement_get_profile(IHTMLHeadElement *iface, BSTR *p)
270 {
271     HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
272     FIXME("(%p)->(%p)\n", This, p);
273     return E_NOTIMPL;
274 }
275
276 static const IHTMLHeadElementVtbl HTMLHeadElementVtbl = {
277     HTMLHeadElement_QueryInterface,
278     HTMLHeadElement_AddRef,
279     HTMLHeadElement_Release,
280     HTMLHeadElement_GetTypeInfoCount,
281     HTMLHeadElement_GetTypeInfo,
282     HTMLHeadElement_GetIDsOfNames,
283     HTMLHeadElement_Invoke,
284     HTMLHeadElement_put_profile,
285     HTMLHeadElement_get_profile
286 };
287
288 static inline HTMLHeadElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
289 {
290     return CONTAINING_RECORD(iface, HTMLHeadElement, element.node);
291 }
292
293 static HRESULT HTMLHeadElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
294 {
295     HTMLHeadElement *This = impl_from_HTMLDOMNode(iface);
296
297     if(IsEqualGUID(&IID_IHTMLHeadElement, riid)) {
298         TRACE("(%p)->(IID_IHTMLHeadElement %p)\n", This, ppv);
299         *ppv = &This->IHTMLHeadElement_iface;
300     }else {
301         return HTMLElement_QI(&This->element.node, riid, ppv);
302     }
303
304     IUnknown_AddRef((IUnknown*)*ppv);
305     return S_OK;
306 }
307
308 static void HTMLHeadElement_destructor(HTMLDOMNode *iface)
309 {
310     HTMLHeadElement *This = impl_from_HTMLDOMNode(iface);
311
312     HTMLElement_destructor(&This->element.node);
313 }
314
315 static const NodeImplVtbl HTMLHeadElementImplVtbl = {
316     HTMLHeadElement_QI,
317     HTMLHeadElement_destructor,
318     HTMLElement_cpc,
319     HTMLElement_clone,
320     HTMLElement_handle_event,
321     HTMLElement_get_attr_col
322 };
323
324 static const tid_t HTMLHeadElement_iface_tids[] = {
325     HTMLELEMENT_TIDS,
326     IHTMLHeadElement_tid,
327     0
328 };
329 static dispex_static_data_t HTMLHeadElement_dispex = {
330     NULL,
331     DispHTMLHeadElement_tid,
332     NULL,
333     HTMLHeadElement_iface_tids
334 };
335
336 HRESULT HTMLHeadElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
337 {
338     HTMLHeadElement *ret;
339
340     ret = heap_alloc_zero(sizeof(*ret));
341     if(!ret)
342         return E_OUTOFMEMORY;
343
344     ret->IHTMLHeadElement_iface.lpVtbl = &HTMLHeadElementVtbl;
345     ret->element.node.vtbl = &HTMLHeadElementImplVtbl;
346
347     HTMLElement_Init(&ret->element, doc, nselem, &HTMLHeadElement_dispex);
348
349     *elem = &ret->element;
350     return S_OK;
351 }