mshtml: Add check for doc_obj being NULL (Coverity).
[wine] / dlls / mshtml / htmlelem3.c
1 /*
2  * Copyright 2008 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 #include "wine/unicode.h"
30
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35
36 #define HTMLELEM3_THIS(iface) DEFINE_THIS(HTMLElement, HTMLElement3, iface)
37
38 static HRESULT WINAPI HTMLElement3_QueryInterface(IHTMLElement3 *iface,
39                                                   REFIID riid, void **ppv)
40 {
41     HTMLElement *This = HTMLELEM3_THIS(iface);
42     return IHTMLElement_QueryInterface(HTMLELEM(This), riid, ppv);
43 }
44
45 static ULONG WINAPI HTMLElement3_AddRef(IHTMLElement3 *iface)
46 {
47     HTMLElement *This = HTMLELEM3_THIS(iface);
48     return IHTMLElement_AddRef(HTMLELEM(This));
49 }
50
51 static ULONG WINAPI HTMLElement3_Release(IHTMLElement3 *iface)
52 {
53     HTMLElement *This = HTMLELEM3_THIS(iface);
54     return IHTMLElement_Release(HTMLELEM(This));
55 }
56
57 static HRESULT WINAPI HTMLElement3_GetTypeInfoCount(IHTMLElement3 *iface, UINT *pctinfo)
58 {
59     HTMLElement *This = HTMLELEM3_THIS(iface);
60     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
61 }
62
63 static HRESULT WINAPI HTMLElement3_GetTypeInfo(IHTMLElement3 *iface, UINT iTInfo,
64                                                LCID lcid, ITypeInfo **ppTInfo)
65 {
66     HTMLElement *This = HTMLELEM3_THIS(iface);
67     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
68 }
69
70 static HRESULT WINAPI HTMLElement3_GetIDsOfNames(IHTMLElement3 *iface, REFIID riid,
71                                                 LPOLESTR *rgszNames, UINT cNames,
72                                                 LCID lcid, DISPID *rgDispId)
73 {
74     HTMLElement *This = HTMLELEM3_THIS(iface);
75     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
76 }
77
78 static HRESULT WINAPI HTMLElement3_Invoke(IHTMLElement3 *iface, DISPID dispIdMember,
79                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
80                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
81 {
82     HTMLElement *This = HTMLELEM3_THIS(iface);
83     return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid,
84             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
85 }
86
87 static HRESULT WINAPI HTMLElement3_mergeAttributes(IHTMLElement3 *iface, IHTMLElement *mergeThis, VARIANT *pvarFlags)
88 {
89     HTMLElement *This = HTMLELEM3_THIS(iface);
90     FIXME("(%p)->(%p %p)\n", This, mergeThis, pvarFlags);
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI HTMLElement3_get_isMultiLine(IHTMLElement3 *iface, VARIANT_BOOL *p)
95 {
96     HTMLElement *This = HTMLELEM3_THIS(iface);
97     FIXME("(%p)->(%p)\n", This, p);
98     return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI HTMLElement3_get_canHaveHTML(IHTMLElement3 *iface, VARIANT_BOOL *p)
102 {
103     HTMLElement *This = HTMLELEM3_THIS(iface);
104     FIXME("(%p)->(%p)\n", This, p);
105     return E_NOTIMPL;
106 }
107
108 static HRESULT WINAPI HTMLElement3_put_onlayoutcomplete(IHTMLElement3 *iface, VARIANT v)
109 {
110     HTMLElement *This = HTMLELEM3_THIS(iface);
111     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
112     return E_NOTIMPL;
113 }
114
115 static HRESULT WINAPI HTMLElement3_get_onlayoutcomplete(IHTMLElement3 *iface, VARIANT *p)
116 {
117     HTMLElement *This = HTMLELEM3_THIS(iface);
118     FIXME("(%p)->(%p)\n", This, p);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI HTMLElement3_put_onpage(IHTMLElement3 *iface, VARIANT v)
123 {
124     HTMLElement *This = HTMLELEM3_THIS(iface);
125     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
126     return E_NOTIMPL;
127 }
128
129 static HRESULT WINAPI HTMLElement3_get_onpage(IHTMLElement3 *iface, VARIANT *p)
130 {
131     HTMLElement *This = HTMLELEM3_THIS(iface);
132     FIXME("(%p)->(%p)\n", This, p);
133     return E_NOTIMPL;
134 }
135
136 static HRESULT WINAPI HTMLElement3_put_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL v)
137 {
138     HTMLElement *This = HTMLELEM3_THIS(iface);
139     FIXME("(%p)->(%x)\n", This, v);
140     return E_NOTIMPL;
141 }
142
143 static HRESULT WINAPI HTMLElement3_get_inflateBlock(IHTMLElement3 *iface, VARIANT_BOOL *p)
144 {
145     HTMLElement *This = HTMLELEM3_THIS(iface);
146     FIXME("(%p)->(%p)\n", This, p);
147     return E_NOTIMPL;
148 }
149
150 static HRESULT WINAPI HTMLElement3_put_onbeforedeactivate(IHTMLElement3 *iface, VARIANT v)
151 {
152     HTMLElement *This = HTMLELEM3_THIS(iface);
153     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
154     return E_NOTIMPL;
155 }
156
157 static HRESULT WINAPI HTMLElement3_get_onbeforedeactivate(IHTMLElement3 *iface, VARIANT *p)
158 {
159     HTMLElement *This = HTMLELEM3_THIS(iface);
160     FIXME("(%p)->(%p)\n", This, p);
161     return E_NOTIMPL;
162 }
163
164 static HRESULT WINAPI HTMLElement3_setActive(IHTMLElement3 *iface)
165 {
166     HTMLElement *This = HTMLELEM3_THIS(iface);
167     FIXME("(%p)\n", This);
168     return E_NOTIMPL;
169 }
170
171 static HRESULT WINAPI HTMLElement3_put_contentEditable(IHTMLElement3 *iface, BSTR v)
172 {
173     HTMLElement *This = HTMLELEM3_THIS(iface);
174     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI HTMLElement3_get_contentEditable(IHTMLElement3 *iface, BSTR *p)
179 {
180     HTMLElement *This = HTMLELEM3_THIS(iface);
181     FIXME("(%p)->(%p)\n", This, p);
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI HTMLElement3_get_isContentEditable(IHTMLElement3 *iface, VARIANT_BOOL *p)
186 {
187     HTMLElement *This = HTMLELEM3_THIS(iface);
188     FIXME("(%p)->(%p)\n", This, p);
189     return E_NOTIMPL;
190 }
191
192 static HRESULT WINAPI HTMLElement3_put_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL v)
193 {
194     HTMLElement *This = HTMLELEM3_THIS(iface);
195     FIXME("(%p)->(%x)\n", This, v);
196     return E_NOTIMPL;
197 }
198
199 static HRESULT WINAPI HTMLElement3_get_hideFocus(IHTMLElement3 *iface, VARIANT_BOOL *p)
200 {
201     HTMLElement *This = HTMLELEM3_THIS(iface);
202     FIXME("(%p)->(%p)\n", This, p);
203     return E_NOTIMPL;
204 }
205
206 static const WCHAR disabledW[] = {'d','i','s','a','b','l','e','d',0};
207
208 static HRESULT WINAPI HTMLElement3_put_disabled(IHTMLElement3 *iface, VARIANT_BOOL v)
209 {
210     HTMLElement *This = HTMLELEM3_THIS(iface);
211     VARIANT *var;
212     HRESULT hres;
213
214     TRACE("(%p)->(%x)\n", This, v);
215
216     if(This->node.vtbl->put_disabled)
217         return This->node.vtbl->put_disabled(&This->node, v);
218
219     hres = dispex_get_dprop_ref(&This->node.dispex, disabledW, TRUE, &var);
220     if(FAILED(hres))
221         return hres;
222
223     VariantClear(var);
224     V_VT(var) = VT_BOOL;
225     V_BOOL(var) = v;
226     return S_OK;
227 }
228
229 static HRESULT WINAPI HTMLElement3_get_disabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
230 {
231     HTMLElement *This = HTMLELEM3_THIS(iface);
232     VARIANT *var;
233     HRESULT hres;
234
235     TRACE("(%p)->(%p)\n", This, p);
236
237     if(This->node.vtbl->get_disabled)
238         return This->node.vtbl->get_disabled(&This->node, p);
239
240     hres = dispex_get_dprop_ref(&This->node.dispex, disabledW, FALSE, &var);
241     if(hres == DISP_E_UNKNOWNNAME) {
242         *p = VARIANT_FALSE;
243         return S_OK;
244     }
245     if(FAILED(hres))
246         return hres;
247
248     if(V_VT(var) != VT_BOOL) {
249         FIXME("vt %d\n", V_VT(var));
250         return E_NOTIMPL;
251     }
252
253     *p = V_BOOL(var);
254     return S_OK;
255 }
256
257 static HRESULT WINAPI HTMLElement3_get_isDisabled(IHTMLElement3 *iface, VARIANT_BOOL *p)
258 {
259     HTMLElement *This = HTMLELEM3_THIS(iface);
260     FIXME("(%p)->(%p)\n", This, p);
261     return E_NOTIMPL;
262 }
263
264 static HRESULT WINAPI HTMLElement3_put_onmove(IHTMLElement3 *iface, VARIANT v)
265 {
266     HTMLElement *This = HTMLELEM3_THIS(iface);
267     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
268     return E_NOTIMPL;
269 }
270
271 static HRESULT WINAPI HTMLElement3_get_onmove(IHTMLElement3 *iface, VARIANT *p)
272 {
273     HTMLElement *This = HTMLELEM3_THIS(iface);
274     FIXME("(%p)->(%p)\n", This, p);
275     return E_NOTIMPL;
276 }
277
278 static HRESULT WINAPI HTMLElement3_put_oncontrolselect(IHTMLElement3 *iface, VARIANT v)
279 {
280     HTMLElement *This = HTMLELEM3_THIS(iface);
281     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
282     return E_NOTIMPL;
283 }
284
285 static HRESULT WINAPI HTMLElement3_get_oncontrolselect(IHTMLElement3 *iface, VARIANT *p)
286 {
287     HTMLElement *This = HTMLELEM3_THIS(iface);
288     FIXME("(%p)->(%p)\n", This, p);
289     return E_NOTIMPL;
290 }
291
292 static HRESULT WINAPI HTMLElement3_fireEvent(IHTMLElement3 *iface, BSTR bstrEventName,
293         VARIANT *pvarEventObject, VARIANT_BOOL *pfCancelled)
294 {
295     HTMLElement *This = HTMLELEM3_THIS(iface);
296
297     TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(bstrEventName), debugstr_variant(pvarEventObject),
298           pfCancelled);
299
300     return dispatch_event(&This->node, bstrEventName, pvarEventObject, pfCancelled);
301 }
302
303 static HRESULT WINAPI HTMLElement3_put_onresizestart(IHTMLElement3 *iface, VARIANT v)
304 {
305     HTMLElement *This = HTMLELEM3_THIS(iface);
306     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
307     return E_NOTIMPL;
308 }
309
310 static HRESULT WINAPI HTMLElement3_get_onresizestart(IHTMLElement3 *iface, VARIANT *p)
311 {
312     HTMLElement *This = HTMLELEM3_THIS(iface);
313     FIXME("(%p)->(%p)\n", This, p);
314     return E_NOTIMPL;
315 }
316
317 static HRESULT WINAPI HTMLElement3_put_onresizeend(IHTMLElement3 *iface, VARIANT v)
318 {
319     HTMLElement *This = HTMLELEM3_THIS(iface);
320     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
321     return E_NOTIMPL;
322 }
323
324 static HRESULT WINAPI HTMLElement3_get_onresizeend(IHTMLElement3 *iface, VARIANT *p)
325 {
326     HTMLElement *This = HTMLELEM3_THIS(iface);
327     FIXME("(%p)->(%p)\n", This, p);
328     return E_NOTIMPL;
329 }
330
331 static HRESULT WINAPI HTMLElement3_put_onmovestart(IHTMLElement3 *iface, VARIANT v)
332 {
333     HTMLElement *This = HTMLELEM3_THIS(iface);
334     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
335     return E_NOTIMPL;
336 }
337
338 static HRESULT WINAPI HTMLElement3_get_onmovestart(IHTMLElement3 *iface, VARIANT *p)
339 {
340     HTMLElement *This = HTMLELEM3_THIS(iface);
341     FIXME("(%p)->(%p)\n", This, p);
342     return E_NOTIMPL;
343 }
344
345 static HRESULT WINAPI HTMLElement3_put_onmoveend(IHTMLElement3 *iface, VARIANT v)
346 {
347     HTMLElement *This = HTMLELEM3_THIS(iface);
348     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
349     return E_NOTIMPL;
350 }
351
352 static HRESULT WINAPI HTMLElement3_get_onmoveend(IHTMLElement3 *iface, VARIANT *p)
353 {
354     HTMLElement *This = HTMLELEM3_THIS(iface);
355     FIXME("(%p)->(%p)\n", This, p);
356     return E_NOTIMPL;
357 }
358
359 static HRESULT WINAPI HTMLElement3_put_onmousecenter(IHTMLElement3 *iface, VARIANT v)
360 {
361     HTMLElement *This = HTMLELEM3_THIS(iface);
362     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
363     return E_NOTIMPL;
364 }
365
366 static HRESULT WINAPI HTMLElement3_get_onmousecenter(IHTMLElement3 *iface, VARIANT *p)
367 {
368     HTMLElement *This = HTMLELEM3_THIS(iface);
369     FIXME("(%p)->(%p)\n", This, p);
370     return E_NOTIMPL;
371 }
372
373 static HRESULT WINAPI HTMLElement3_put_onmouseleave(IHTMLElement3 *iface, VARIANT v)
374 {
375     HTMLElement *This = HTMLELEM3_THIS(iface);
376     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
377     return E_NOTIMPL;
378 }
379
380 static HRESULT WINAPI HTMLElement3_get_onmouseleave(IHTMLElement3 *iface, VARIANT *p)
381 {
382     HTMLElement *This = HTMLELEM3_THIS(iface);
383     FIXME("(%p)->(%p)\n", This, p);
384     return E_NOTIMPL;
385 }
386
387 static HRESULT WINAPI HTMLElement3_put_onactivate(IHTMLElement3 *iface, VARIANT v)
388 {
389     HTMLElement *This = HTMLELEM3_THIS(iface);
390     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
391     return E_NOTIMPL;
392 }
393
394 static HRESULT WINAPI HTMLElement3_get_onactivate(IHTMLElement3 *iface, VARIANT *p)
395 {
396     HTMLElement *This = HTMLELEM3_THIS(iface);
397     FIXME("(%p)->(%p)\n", This, p);
398     return E_NOTIMPL;
399 }
400
401 static HRESULT WINAPI HTMLElement3_put_ondeactivate(IHTMLElement3 *iface, VARIANT v)
402 {
403     HTMLElement *This = HTMLELEM3_THIS(iface);
404     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
405     return E_NOTIMPL;
406 }
407
408 static HRESULT WINAPI HTMLElement3_get_ondeactivate(IHTMLElement3 *iface, VARIANT *p)
409 {
410     HTMLElement *This = HTMLELEM3_THIS(iface);
411     FIXME("(%p)->(%p)\n", This, p);
412     return E_NOTIMPL;
413 }
414
415 static HRESULT WINAPI HTMLElement3_dragDrop(IHTMLElement3 *iface, VARIANT_BOOL *pfRet)
416 {
417     HTMLElement *This = HTMLELEM3_THIS(iface);
418     FIXME("(%p)->(%p)\n", This, pfRet);
419     return E_NOTIMPL;
420 }
421
422 static HRESULT WINAPI HTMLElement3_get_glyphMode(IHTMLElement3 *iface, LONG *p)
423 {
424     HTMLElement *This = HTMLELEM3_THIS(iface);
425     FIXME("(%p)->(%p)\n", This, p);
426     return E_NOTIMPL;
427 }
428
429 #undef HTMLELEM2_THIS
430
431 static const IHTMLElement3Vtbl HTMLElement3Vtbl = {
432     HTMLElement3_QueryInterface,
433     HTMLElement3_AddRef,
434     HTMLElement3_Release,
435     HTMLElement3_GetTypeInfoCount,
436     HTMLElement3_GetTypeInfo,
437     HTMLElement3_GetIDsOfNames,
438     HTMLElement3_Invoke,
439     HTMLElement3_mergeAttributes,
440     HTMLElement3_get_isMultiLine,
441     HTMLElement3_get_canHaveHTML,
442     HTMLElement3_put_onlayoutcomplete,
443     HTMLElement3_get_onlayoutcomplete,
444     HTMLElement3_put_onpage,
445     HTMLElement3_get_onpage,
446     HTMLElement3_put_inflateBlock,
447     HTMLElement3_get_inflateBlock,
448     HTMLElement3_put_onbeforedeactivate,
449     HTMLElement3_get_onbeforedeactivate,
450     HTMLElement3_setActive,
451     HTMLElement3_put_contentEditable,
452     HTMLElement3_get_contentEditable,
453     HTMLElement3_get_isContentEditable,
454     HTMLElement3_put_hideFocus,
455     HTMLElement3_get_hideFocus,
456     HTMLElement3_put_disabled,
457     HTMLElement3_get_disabled,
458     HTMLElement3_get_isDisabled,
459     HTMLElement3_put_onmove,
460     HTMLElement3_get_onmove,
461     HTMLElement3_put_oncontrolselect,
462     HTMLElement3_get_oncontrolselect,
463     HTMLElement3_fireEvent,
464     HTMLElement3_put_onresizestart,
465     HTMLElement3_get_onresizestart,
466     HTMLElement3_put_onresizeend,
467     HTMLElement3_get_onresizeend,
468     HTMLElement3_put_onmovestart,
469     HTMLElement3_get_onmovestart,
470     HTMLElement3_put_onmoveend,
471     HTMLElement3_get_onmoveend,
472     HTMLElement3_put_onmousecenter,
473     HTMLElement3_get_onmousecenter,
474     HTMLElement3_put_onmouseleave,
475     HTMLElement3_get_onmouseleave,
476     HTMLElement3_put_onactivate,
477     HTMLElement3_get_onactivate,
478     HTMLElement3_put_ondeactivate,
479     HTMLElement3_get_ondeactivate,
480     HTMLElement3_dragDrop,
481     HTMLElement3_get_glyphMode
482 };
483
484 void HTMLElement3_Init(HTMLElement *This)
485 {
486     This->lpHTMLElement3Vtbl = &HTMLElement3Vtbl;
487 }