mshtml: Added noscript tag handling tests.
[wine] / dlls / mshtml / htmlobject.c
1 /*
2  * Copyright 2010 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 #include <assert.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
29
30 #include "wine/debug.h"
31
32 #include "mshtml_private.h"
33 #include "pluginhost.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 typedef struct {
38     HTMLPluginContainer plugin_container;
39
40     IHTMLObjectElement IHTMLObjectElement_iface;
41     IHTMLObjectElement2 IHTMLObjectElement2_iface;
42
43     nsIDOMHTMLObjectElement *nsobject;
44 } HTMLObjectElement;
45
46 static inline HTMLObjectElement *impl_from_IHTMLObjectElement(IHTMLObjectElement *iface)
47 {
48     return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement_iface);
49 }
50
51 static HRESULT WINAPI HTMLObjectElement_QueryInterface(IHTMLObjectElement *iface,
52         REFIID riid, void **ppv)
53 {
54     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
55
56     return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
57             riid, ppv);
58 }
59
60 static ULONG WINAPI HTMLObjectElement_AddRef(IHTMLObjectElement *iface)
61 {
62     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
63
64     return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
65 }
66
67 static ULONG WINAPI HTMLObjectElement_Release(IHTMLObjectElement *iface)
68 {
69     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
70
71     return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
72 }
73
74 static HRESULT WINAPI HTMLObjectElement_GetTypeInfoCount(IHTMLObjectElement *iface, UINT *pctinfo)
75 {
76     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
77     return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
78             pctinfo);
79 }
80
81 static HRESULT WINAPI HTMLObjectElement_GetTypeInfo(IHTMLObjectElement *iface, UINT iTInfo,
82                                               LCID lcid, ITypeInfo **ppTInfo)
83 {
84     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
85     return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
86             iTInfo, lcid, ppTInfo);
87 }
88
89 static HRESULT WINAPI HTMLObjectElement_GetIDsOfNames(IHTMLObjectElement *iface, REFIID riid,
90                                                 LPOLESTR *rgszNames, UINT cNames,
91                                                 LCID lcid, DISPID *rgDispId)
92 {
93     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
94     return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
95             riid, rgszNames, cNames, lcid, rgDispId);
96 }
97
98 static HRESULT WINAPI HTMLObjectElement_Invoke(IHTMLObjectElement *iface, DISPID dispIdMember,
99                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
100                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
101 {
102     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
103     return IDispatchEx_Invoke(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
104             dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
105 }
106
107 static HRESULT WINAPI HTMLObjectElement_get_object(IHTMLObjectElement *iface, IDispatch **p)
108 {
109     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
110
111     TRACE("(%p)->(%p)\n", This, p);
112
113     return get_plugin_disp(&This->plugin_container, p);
114 }
115
116 static HRESULT WINAPI HTMLObjectElement_get_classid(IHTMLObjectElement *iface, BSTR *p)
117 {
118     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
119
120     TRACE("(%p)->(%p)\n", This, p);
121
122     return IHTMLObjectElement2_get_classid(&This->IHTMLObjectElement2_iface, p);
123 }
124
125 static HRESULT WINAPI HTMLObjectElement_get_data(IHTMLObjectElement *iface, BSTR *p)
126 {
127     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
128
129     TRACE("(%p)->(%p)\n", This, p);
130
131     return IHTMLObjectElement2_get_data(&This->IHTMLObjectElement2_iface, p);
132 }
133
134 static HRESULT WINAPI HTMLObjectElement_put_recordset(IHTMLObjectElement *iface, IDispatch *v)
135 {
136     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
137     FIXME("(%p)->(%p)\n", This, v);
138     return E_NOTIMPL;
139 }
140
141 static HRESULT WINAPI HTMLObjectElement_get_recordset(IHTMLObjectElement *iface, IDispatch **p)
142 {
143     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
144     FIXME("(%p)->(%p)\n", This, p);
145     return E_NOTIMPL;
146 }
147
148 static HRESULT WINAPI HTMLObjectElement_put_align(IHTMLObjectElement *iface, BSTR v)
149 {
150     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
151     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152     return E_NOTIMPL;
153 }
154
155 static HRESULT WINAPI HTMLObjectElement_get_align(IHTMLObjectElement *iface, BSTR *p)
156 {
157     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
158     FIXME("(%p)->(%p)\n", This, p);
159     return E_NOTIMPL;
160 }
161
162 static HRESULT WINAPI HTMLObjectElement_put_name(IHTMLObjectElement *iface, BSTR v)
163 {
164     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
165     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI HTMLObjectElement_get_name(IHTMLObjectElement *iface, BSTR *p)
170 {
171     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
172     FIXME("(%p)->(%p)\n", This, p);
173     return E_NOTIMPL;
174 }
175
176 static HRESULT WINAPI HTMLObjectElement_put_codeBase(IHTMLObjectElement *iface, BSTR v)
177 {
178     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
179     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
180     return E_NOTIMPL;
181 }
182
183 static HRESULT WINAPI HTMLObjectElement_get_codeBase(IHTMLObjectElement *iface, BSTR *p)
184 {
185     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
186     FIXME("(%p)->(%p)\n", This, p);
187     return E_NOTIMPL;
188 }
189
190 static HRESULT WINAPI HTMLObjectElement_put_codeType(IHTMLObjectElement *iface, BSTR v)
191 {
192     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
193     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
194     return E_NOTIMPL;
195 }
196
197 static HRESULT WINAPI HTMLObjectElement_get_codeType(IHTMLObjectElement *iface, BSTR *p)
198 {
199     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
200     FIXME("(%p)->(%p)\n", This, p);
201     return E_NOTIMPL;
202 }
203
204 static HRESULT WINAPI HTMLObjectElement_put_code(IHTMLObjectElement *iface, BSTR v)
205 {
206     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
207     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
208     return E_NOTIMPL;
209 }
210
211 static HRESULT WINAPI HTMLObjectElement_get_code(IHTMLObjectElement *iface, BSTR *p)
212 {
213     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
214     FIXME("(%p)->(%p)\n", This, p);
215     return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI HTMLObjectElement_get_BaseHref(IHTMLObjectElement *iface, BSTR *p)
219 {
220     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
221     FIXME("(%p)->(%p)\n", This, p);
222     return E_NOTIMPL;
223 }
224
225 static HRESULT WINAPI HTMLObjectElement_put_type(IHTMLObjectElement *iface, BSTR v)
226 {
227     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
228     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
229     return E_NOTIMPL;
230 }
231
232 static HRESULT WINAPI HTMLObjectElement_get_type(IHTMLObjectElement *iface, BSTR *p)
233 {
234     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
235     FIXME("(%p)->(%p)\n", This, p);
236     return E_NOTIMPL;
237 }
238
239 static HRESULT WINAPI HTMLObjectElement_get_form(IHTMLObjectElement *iface, IHTMLFormElement **p)
240 {
241     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
242     FIXME("(%p)->(%p)\n", This, p);
243     return E_NOTIMPL;
244 }
245
246 static HRESULT WINAPI HTMLObjectElement_put_width(IHTMLObjectElement *iface, VARIANT v)
247 {
248     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
249     nsAString width_str;
250     PRUnichar buf[12];
251     nsresult nsres;
252
253     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
254
255     switch(V_VT(&v)) {
256     case VT_I4: {
257         static const WCHAR formatW[] = {'%','d',0};
258         sprintfW(buf, formatW, V_I4(&v));
259         break;
260     }
261     default:
262         FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
263         return E_NOTIMPL;
264     }
265
266     nsAString_InitDepend(&width_str, buf);
267     nsres = nsIDOMHTMLObjectElement_SetWidth(This->nsobject, &width_str);
268     nsAString_Finish(&width_str);
269     if(NS_FAILED(nsres)) {
270         FIXME("SetWidth failed: %08x\n", nsres);
271         return E_FAIL;
272     }
273
274     notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
275     return S_OK;
276 }
277
278 static HRESULT WINAPI HTMLObjectElement_get_width(IHTMLObjectElement *iface, VARIANT *p)
279 {
280     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
281     nsAString width_str;
282     nsresult nsres;
283     HRESULT hres;
284
285     TRACE("(%p)->(%p)\n", This, p);
286
287     nsAString_Init(&width_str, NULL);
288     nsres = nsIDOMHTMLObjectElement_GetWidth(This->nsobject, &width_str);
289     if(NS_SUCCEEDED(nsres)) {
290         const PRUnichar *width;
291
292         nsAString_GetData(&width_str, &width);
293         V_VT(p) = VT_BSTR;
294         V_BSTR(p) = SysAllocString(width);
295         hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
296     }else {
297         ERR("GetWidth failed: %08x\n", nsres);
298         hres = E_FAIL;
299     }
300
301     nsAString_Finish(&width_str);
302     return hres;
303 }
304
305 static HRESULT WINAPI HTMLObjectElement_put_height(IHTMLObjectElement *iface, VARIANT v)
306 {
307     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
308     nsAString height_str;
309     PRUnichar buf[12];
310     nsresult nsres;
311
312     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
313
314     switch(V_VT(&v)) {
315     case VT_I4: {
316         static const WCHAR formatW[] = {'%','d',0};
317         sprintfW(buf, formatW, V_I4(&v));
318         break;
319     }
320     default:
321         FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
322         return E_NOTIMPL;
323     }
324
325     nsAString_InitDepend(&height_str, buf);
326     nsres = nsIDOMHTMLObjectElement_SetHeight(This->nsobject, &height_str);
327     nsAString_Finish(&height_str);
328     if(NS_FAILED(nsres)) {
329         FIXME("SetHeight failed: %08x\n", nsres);
330         return E_FAIL;
331     }
332
333     notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
334     return S_OK;
335 }
336
337 static HRESULT WINAPI HTMLObjectElement_get_height(IHTMLObjectElement *iface, VARIANT *p)
338 {
339     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
340     nsAString height_str;
341     nsresult nsres;
342     HRESULT hres;
343
344     TRACE("(%p)->(%p)\n", This, p);
345
346     nsAString_Init(&height_str, NULL);
347     nsres = nsIDOMHTMLObjectElement_GetHeight(This->nsobject, &height_str);
348     if(NS_SUCCEEDED(nsres)) {
349         const PRUnichar *height;
350
351         nsAString_GetData(&height_str, &height);
352         V_VT(p) = VT_BSTR;
353         V_BSTR(p) = SysAllocString(height);
354         hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
355     }else {
356         ERR("GetHeight failed: %08x\n", nsres);
357         hres = E_FAIL;
358     }
359
360     nsAString_Finish(&height_str);
361     return hres;
362 }
363
364 static HRESULT WINAPI HTMLObjectElement_get_readyState(IHTMLObjectElement *iface, LONG *p)
365 {
366     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
367     FIXME("(%p)->(%p)\n", This, p);
368     return E_NOTIMPL;
369 }
370
371 static HRESULT WINAPI HTMLObjectElement_put_onreadystatechange(IHTMLObjectElement *iface, VARIANT v)
372 {
373     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
374     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
375     return E_NOTIMPL;
376 }
377
378 static HRESULT WINAPI HTMLObjectElement_get_onreadystatechange(IHTMLObjectElement *iface, VARIANT *p)
379 {
380     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
381     FIXME("(%p)->(%p)\n", This, p);
382     return E_NOTIMPL;
383 }
384
385 static HRESULT WINAPI HTMLObjectElement_put_onerror(IHTMLObjectElement *iface, VARIANT v)
386 {
387     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
388     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
389     return E_NOTIMPL;
390 }
391
392 static HRESULT WINAPI HTMLObjectElement_get_onerror(IHTMLObjectElement *iface, VARIANT *p)
393 {
394     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
395     FIXME("(%p)->(%p)\n", This, p);
396     return E_NOTIMPL;
397 }
398
399 static HRESULT WINAPI HTMLObjectElement_put_altHtml(IHTMLObjectElement *iface, BSTR v)
400 {
401     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
402     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
403     return E_NOTIMPL;
404 }
405
406 static HRESULT WINAPI HTMLObjectElement_get_altHtml(IHTMLObjectElement *iface, BSTR *p)
407 {
408     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
409     FIXME("(%p)->(%p)\n", This, p);
410     return E_NOTIMPL;
411 }
412
413 static HRESULT WINAPI HTMLObjectElement_put_vspace(IHTMLObjectElement *iface, LONG v)
414 {
415     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
416     FIXME("(%p)->(%d)\n", This, v);
417     return E_NOTIMPL;
418 }
419
420 static HRESULT WINAPI HTMLObjectElement_get_vspace(IHTMLObjectElement *iface, LONG *p)
421 {
422     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
423     PRInt32 vspace;
424     nsresult nsres;
425
426     TRACE("(%p)->(%p)\n", This, p);
427
428     nsres = nsIDOMHTMLObjectElement_GetVspace(This->nsobject, &vspace);
429     if(NS_FAILED(nsres)) {
430         ERR("GetVspace failed: %08x\n", nsres);
431         return E_FAIL;
432     }
433
434     *p = vspace;
435     return S_OK;
436 }
437
438 static HRESULT WINAPI HTMLObjectElement_put_hspace(IHTMLObjectElement *iface, LONG v)
439 {
440     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
441     FIXME("(%p)->(%d)\n", This, v);
442     return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI HTMLObjectElement_get_hspace(IHTMLObjectElement *iface, LONG *p)
446 {
447     HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
448     FIXME("(%p)->(%p)\n", This, p);
449     return E_NOTIMPL;
450 }
451
452 static const IHTMLObjectElementVtbl HTMLObjectElementVtbl = {
453     HTMLObjectElement_QueryInterface,
454     HTMLObjectElement_AddRef,
455     HTMLObjectElement_Release,
456     HTMLObjectElement_GetTypeInfoCount,
457     HTMLObjectElement_GetTypeInfo,
458     HTMLObjectElement_GetIDsOfNames,
459     HTMLObjectElement_Invoke,
460     HTMLObjectElement_get_object,
461     HTMLObjectElement_get_classid,
462     HTMLObjectElement_get_data,
463     HTMLObjectElement_put_recordset,
464     HTMLObjectElement_get_recordset,
465     HTMLObjectElement_put_align,
466     HTMLObjectElement_get_align,
467     HTMLObjectElement_put_name,
468     HTMLObjectElement_get_name,
469     HTMLObjectElement_put_codeBase,
470     HTMLObjectElement_get_codeBase,
471     HTMLObjectElement_put_codeType,
472     HTMLObjectElement_get_codeType,
473     HTMLObjectElement_put_code,
474     HTMLObjectElement_get_code,
475     HTMLObjectElement_get_BaseHref,
476     HTMLObjectElement_put_type,
477     HTMLObjectElement_get_type,
478     HTMLObjectElement_get_form,
479     HTMLObjectElement_put_width,
480     HTMLObjectElement_get_width,
481     HTMLObjectElement_put_height,
482     HTMLObjectElement_get_height,
483     HTMLObjectElement_get_readyState,
484     HTMLObjectElement_put_onreadystatechange,
485     HTMLObjectElement_get_onreadystatechange,
486     HTMLObjectElement_put_onerror,
487     HTMLObjectElement_get_onerror,
488     HTMLObjectElement_put_altHtml,
489     HTMLObjectElement_get_altHtml,
490     HTMLObjectElement_put_vspace,
491     HTMLObjectElement_get_vspace,
492     HTMLObjectElement_put_hspace,
493     HTMLObjectElement_get_hspace
494 };
495
496 static inline HTMLObjectElement *impl_from_IHTMLObjectElement2(IHTMLObjectElement2 *iface)
497 {
498     return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement2_iface);
499 }
500
501 static HRESULT WINAPI HTMLObjectElement2_QueryInterface(IHTMLObjectElement2 *iface,
502         REFIID riid, void **ppv)
503 {
504     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
505
506     return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
507             riid, ppv);
508 }
509
510 static ULONG WINAPI HTMLObjectElement2_AddRef(IHTMLObjectElement2 *iface)
511 {
512     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
513
514     return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
515 }
516
517 static ULONG WINAPI HTMLObjectElement2_Release(IHTMLObjectElement2 *iface)
518 {
519     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
520
521     return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
522 }
523
524 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfoCount(IHTMLObjectElement2 *iface, UINT *pctinfo)
525 {
526     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
527     return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
528             pctinfo);
529 }
530
531 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfo(IHTMLObjectElement2 *iface, UINT iTInfo,
532                                               LCID lcid, ITypeInfo **ppTInfo)
533 {
534     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
535     return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
536             iTInfo, lcid, ppTInfo);
537 }
538
539 static HRESULT WINAPI HTMLObjectElement2_GetIDsOfNames(IHTMLObjectElement2 *iface, REFIID riid,
540         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
541 {
542     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
543     return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
544             riid, rgszNames, cNames, lcid, rgDispId);
545 }
546
547 static HRESULT WINAPI HTMLObjectElement2_Invoke(IHTMLObjectElement2 *iface, DISPID dispIdMember,
548         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
549         EXCEPINFO *pExcepInfo, UINT *puArgErr)
550 {
551     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
552     return IDispatchEx_Invoke(&This->plugin_container.element.node.dispex.IDispatchEx_iface,
553             dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
554 }
555
556 static HRESULT WINAPI HTMLObjectElement2_namedRecordset(IHTMLObjectElement2 *iface, BSTR dataMember,
557         VARIANT *hierarchy, IDispatch **ppRecordset)
558 {
559     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
560     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
561     return E_NOTIMPL;
562 }
563
564 static HRESULT WINAPI HTMLObjectElement2_put_classid(IHTMLObjectElement2 *iface, BSTR v)
565 {
566     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
567     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
568     return E_NOTIMPL;
569 }
570
571 static HRESULT WINAPI HTMLObjectElement2_get_classid(IHTMLObjectElement2 *iface, BSTR *p)
572 {
573     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
574     FIXME("(%p)->(%p)\n", This, p);
575     return E_NOTIMPL;
576 }
577
578 static HRESULT WINAPI HTMLObjectElement2_put_data(IHTMLObjectElement2 *iface, BSTR v)
579 {
580     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
581     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
582     return E_NOTIMPL;
583 }
584
585 static HRESULT WINAPI HTMLObjectElement2_get_data(IHTMLObjectElement2 *iface, BSTR *p)
586 {
587     HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
588     FIXME("(%p)->(%p)\n", This, p);
589     return E_NOTIMPL;
590 }
591
592 static const IHTMLObjectElement2Vtbl HTMLObjectElement2Vtbl = {
593     HTMLObjectElement2_QueryInterface,
594     HTMLObjectElement2_AddRef,
595     HTMLObjectElement2_Release,
596     HTMLObjectElement2_GetTypeInfoCount,
597     HTMLObjectElement2_GetTypeInfo,
598     HTMLObjectElement2_GetIDsOfNames,
599     HTMLObjectElement2_Invoke,
600     HTMLObjectElement2_namedRecordset,
601     HTMLObjectElement2_put_classid,
602     HTMLObjectElement2_get_classid,
603     HTMLObjectElement2_put_data,
604     HTMLObjectElement2_get_data
605 };
606
607 static inline HTMLObjectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
608 {
609     return CONTAINING_RECORD(iface, HTMLObjectElement, plugin_container.element.node);
610 }
611
612 static HRESULT HTMLObjectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
613 {
614     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
615
616     if(IsEqualGUID(&IID_IUnknown, riid)) {
617         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
618         *ppv = &This->IHTMLObjectElement_iface;
619     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
620         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
621         *ppv = &This->IHTMLObjectElement_iface;
622     }else if(IsEqualGUID(&IID_IHTMLObjectElement, riid)) {
623         TRACE("(%p)->(IID_IHTMLObjectElement %p)\n", This, ppv);
624         *ppv = &This->IHTMLObjectElement_iface;
625     }else if(IsEqualGUID(&IID_IHTMLObjectElement2, riid)) {
626         TRACE("(%p)->(IID_IHTMLObjectElement2 %p)\n", This, ppv);
627         *ppv = &This->IHTMLObjectElement2_iface;
628     }else if(IsEqualGUID(&IID_HTMLPluginContainer, riid)) {
629         TRACE("(%p)->(IID_HTMLPluginContainer %p)\n", This, ppv);
630         *ppv = &This->plugin_container;
631         return S_OK;
632     }else {
633         HRESULT hres;
634
635         hres = HTMLElement_QI(&This->plugin_container.element.node, riid, ppv);
636         if(hres == E_NOINTERFACE && This->plugin_container.plugin_host && This->plugin_container.plugin_host->plugin_unk) {
637             IUnknown *plugin_iface, *ret;
638
639             hres = IUnknown_QueryInterface(This->plugin_container.plugin_host->plugin_unk, riid, (void**)&plugin_iface);
640             if(hres == S_OK) {
641                 hres = wrap_iface(plugin_iface, (IUnknown*)&This->IHTMLObjectElement_iface, &ret);
642                 IUnknown_Release(plugin_iface);
643                 if(FAILED(hres))
644                     return hres;
645
646                 TRACE("returning plugin iface %p wrapped to %p\n", plugin_iface, ret);
647                 *ppv = ret;
648                 return S_OK;
649             }
650         }
651
652         return hres;
653     }
654
655     IUnknown_AddRef((IUnknown*)*ppv);
656     return S_OK;
657 }
658
659 static void HTMLObjectElement_destructor(HTMLDOMNode *iface)
660 {
661     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
662
663     if(This->plugin_container.plugin_host)
664         detach_plugin_host(This->plugin_container.plugin_host);
665
666     HTMLElement_destructor(&This->plugin_container.element.node);
667 }
668
669 static HRESULT HTMLObjectElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
670 {
671     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
672     FIXME("(%p)->(%p)\n", This, p);
673     return E_NOTIMPL;
674 }
675
676 static HRESULT HTMLObjectElement_get_dispid(HTMLDOMNode *iface, BSTR name,
677         DWORD grfdex, DISPID *pid)
678 {
679     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
680
681     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), grfdex, pid);
682
683     return get_plugin_dispid(&This->plugin_container, name, pid);
684 }
685
686 static HRESULT HTMLObjectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
687         WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
688 {
689     HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
690
691     TRACE("(%p)->(%d)\n", This, id);
692
693     return invoke_plugin_prop(&This->plugin_container, id, lcid, flags, params, res, ei);
694 }
695
696 static const NodeImplVtbl HTMLObjectElementImplVtbl = {
697     HTMLObjectElement_QI,
698     HTMLObjectElement_destructor,
699     HTMLElement_clone,
700     HTMLElement_handle_event,
701     HTMLElement_get_attr_col,
702     NULL,
703     NULL,
704     NULL,
705     NULL,
706     NULL,
707     HTMLObjectElement_get_readystate,
708     HTMLObjectElement_get_dispid,
709     HTMLObjectElement_invoke
710 };
711
712 static const tid_t HTMLObjectElement_iface_tids[] = {
713     HTMLELEMENT_TIDS,
714     IHTMLObjectElement_tid,
715     IHTMLObjectElement2_tid,
716     0
717 };
718 static dispex_static_data_t HTMLObjectElement_dispex = {
719     NULL,
720     DispHTMLObjectElement_tid,
721     NULL,
722     HTMLObjectElement_iface_tids
723 };
724
725 HRESULT HTMLObjectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
726 {
727     HTMLObjectElement *ret;
728     nsresult nsres;
729
730     ret = heap_alloc_zero(sizeof(*ret));
731     if(!ret)
732         return E_OUTOFMEMORY;
733
734     ret->IHTMLObjectElement_iface.lpVtbl = &HTMLObjectElementVtbl;
735     ret->IHTMLObjectElement2_iface.lpVtbl = &HTMLObjectElement2Vtbl;
736     ret->plugin_container.element.node.vtbl = &HTMLObjectElementImplVtbl;
737
738     HTMLElement_Init(&ret->plugin_container.element, doc, nselem, &HTMLObjectElement_dispex);
739
740     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLObjectElement, (void**)&ret->nsobject);
741
742     /* Share nsobject reference with nsnode */
743     assert(nsres == NS_OK && (nsIDOMNode*)ret->nsobject == ret->plugin_container.element.node.nsnode);
744     nsIDOMNode_Release(ret->plugin_container.element.node.nsnode);
745
746     *elem = &ret->plugin_container.element;
747     return S_OK;
748 }