ntoskrnl.exe/tests: Fix path buffer allocation size.
[wine.git] / dlls / mshtml / htmlobject.c
blob97dffba23a10f92f37fb744c49c7857a5282df3c
1 /*
2 * Copyright 2010 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>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
30 #include "wine/debug.h"
32 #include "mshtml_private.h"
33 #include "pluginhost.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 struct HTMLObjectElement {
38 HTMLPluginContainer plugin_container;
40 IHTMLObjectElement IHTMLObjectElement_iface;
41 IHTMLObjectElement2 IHTMLObjectElement2_iface;
43 nsIDOMHTMLObjectElement *nsobject;
46 static inline HTMLObjectElement *impl_from_IHTMLObjectElement(IHTMLObjectElement *iface)
48 return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement_iface);
51 static HRESULT WINAPI HTMLObjectElement_QueryInterface(IHTMLObjectElement *iface,
52 REFIID riid, void **ppv)
54 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
56 return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
57 riid, ppv);
60 static ULONG WINAPI HTMLObjectElement_AddRef(IHTMLObjectElement *iface)
62 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
64 return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
67 static ULONG WINAPI HTMLObjectElement_Release(IHTMLObjectElement *iface)
69 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
71 return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
74 static HRESULT WINAPI HTMLObjectElement_GetTypeInfoCount(IHTMLObjectElement *iface, UINT *pctinfo)
76 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
77 return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
78 pctinfo);
81 static HRESULT WINAPI HTMLObjectElement_GetTypeInfo(IHTMLObjectElement *iface, UINT iTInfo,
82 LCID lcid, ITypeInfo **ppTInfo)
84 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
85 return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
86 iTInfo, lcid, ppTInfo);
89 static HRESULT WINAPI HTMLObjectElement_GetIDsOfNames(IHTMLObjectElement *iface, REFIID riid,
90 LPOLESTR *rgszNames, UINT cNames,
91 LCID lcid, DISPID *rgDispId)
93 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
94 return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
95 riid, rgszNames, cNames, lcid, rgDispId);
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)
102 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
103 return IDispatchEx_Invoke(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
104 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
107 static HRESULT WINAPI HTMLObjectElement_get_object(IHTMLObjectElement *iface, IDispatch **p)
109 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
111 TRACE("(%p)->(%p)\n", This, p);
113 return get_plugin_disp(&This->plugin_container, p);
116 static HRESULT WINAPI HTMLObjectElement_get_classid(IHTMLObjectElement *iface, BSTR *p)
118 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
120 TRACE("(%p)->(%p)\n", This, p);
122 return IHTMLObjectElement2_get_classid(&This->IHTMLObjectElement2_iface, p);
125 static HRESULT WINAPI HTMLObjectElement_get_data(IHTMLObjectElement *iface, BSTR *p)
127 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
129 TRACE("(%p)->(%p)\n", This, p);
131 return IHTMLObjectElement2_get_data(&This->IHTMLObjectElement2_iface, p);
134 static HRESULT WINAPI HTMLObjectElement_put_recordset(IHTMLObjectElement *iface, IDispatch *v)
136 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
137 FIXME("(%p)->(%p)\n", This, v);
138 return E_NOTIMPL;
141 static HRESULT WINAPI HTMLObjectElement_get_recordset(IHTMLObjectElement *iface, IDispatch **p)
143 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
144 FIXME("(%p)->(%p)\n", This, p);
145 return E_NOTIMPL;
148 static HRESULT WINAPI HTMLObjectElement_put_align(IHTMLObjectElement *iface, BSTR v)
150 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
151 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
152 return E_NOTIMPL;
155 static HRESULT WINAPI HTMLObjectElement_get_align(IHTMLObjectElement *iface, BSTR *p)
157 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
158 FIXME("(%p)->(%p)\n", This, p);
159 return E_NOTIMPL;
162 static HRESULT WINAPI HTMLObjectElement_put_name(IHTMLObjectElement *iface, BSTR v)
164 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
165 nsAString nsstr;
166 nsresult nsres;
168 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
170 nsAString_InitDepend(&nsstr, v);
171 nsres = nsIDOMHTMLObjectElement_SetName(This->nsobject, &nsstr);
172 nsAString_Finish(&nsstr);
173 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
176 static HRESULT WINAPI HTMLObjectElement_get_name(IHTMLObjectElement *iface, BSTR *p)
178 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
179 nsAString nsstr;
180 nsresult nsres;
182 TRACE("(%p)->(%p)\n", This, p);
184 nsAString_Init(&nsstr, NULL);
185 nsres = nsIDOMHTMLObjectElement_GetName(This->nsobject, &nsstr);
186 return return_nsstr(nsres, &nsstr, p);
189 static HRESULT WINAPI HTMLObjectElement_put_codeBase(IHTMLObjectElement *iface, BSTR v)
191 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
192 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLObjectElement_get_codeBase(IHTMLObjectElement *iface, BSTR *p)
198 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
199 FIXME("(%p)->(%p)\n", This, p);
200 return E_NOTIMPL;
203 static HRESULT WINAPI HTMLObjectElement_put_codeType(IHTMLObjectElement *iface, BSTR v)
205 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
206 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
207 return E_NOTIMPL;
210 static HRESULT WINAPI HTMLObjectElement_get_codeType(IHTMLObjectElement *iface, BSTR *p)
212 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
213 FIXME("(%p)->(%p)\n", This, p);
214 return E_NOTIMPL;
217 static HRESULT WINAPI HTMLObjectElement_put_code(IHTMLObjectElement *iface, BSTR v)
219 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
220 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
221 return E_NOTIMPL;
224 static HRESULT WINAPI HTMLObjectElement_get_code(IHTMLObjectElement *iface, BSTR *p)
226 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
227 FIXME("(%p)->(%p)\n", This, p);
228 return E_NOTIMPL;
231 static HRESULT WINAPI HTMLObjectElement_get_BaseHref(IHTMLObjectElement *iface, BSTR *p)
233 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
234 FIXME("(%p)->(%p)\n", This, p);
235 return E_NOTIMPL;
238 static HRESULT WINAPI HTMLObjectElement_put_type(IHTMLObjectElement *iface, BSTR v)
240 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
241 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
242 return E_NOTIMPL;
245 static HRESULT WINAPI HTMLObjectElement_get_type(IHTMLObjectElement *iface, BSTR *p)
247 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
248 FIXME("(%p)->(%p)\n", This, p);
249 return E_NOTIMPL;
252 static HRESULT WINAPI HTMLObjectElement_get_form(IHTMLObjectElement *iface, IHTMLFormElement **p)
254 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
255 FIXME("(%p)->(%p)\n", This, p);
256 return E_NOTIMPL;
259 static HRESULT WINAPI HTMLObjectElement_put_width(IHTMLObjectElement *iface, VARIANT v)
261 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
262 nsAString width_str;
263 PRUnichar buf[12];
264 nsresult nsres;
266 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
268 switch(V_VT(&v)) {
269 case VT_I4: {
270 static const WCHAR formatW[] = {'%','d',0};
271 sprintfW(buf, formatW, V_I4(&v));
272 break;
274 default:
275 FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
276 return E_NOTIMPL;
279 nsAString_InitDepend(&width_str, buf);
280 nsres = nsIDOMHTMLObjectElement_SetWidth(This->nsobject, &width_str);
281 nsAString_Finish(&width_str);
282 if(NS_FAILED(nsres)) {
283 FIXME("SetWidth failed: %08x\n", nsres);
284 return E_FAIL;
287 notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
288 return S_OK;
291 static HRESULT WINAPI HTMLObjectElement_get_width(IHTMLObjectElement *iface, VARIANT *p)
293 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
294 nsAString width_str;
295 nsresult nsres;
296 HRESULT hres;
298 TRACE("(%p)->(%p)\n", This, p);
300 nsAString_Init(&width_str, NULL);
301 nsres = nsIDOMHTMLObjectElement_GetWidth(This->nsobject, &width_str);
302 if(NS_SUCCEEDED(nsres)) {
303 const PRUnichar *width;
305 nsAString_GetData(&width_str, &width);
306 V_VT(p) = VT_BSTR;
307 V_BSTR(p) = SysAllocString(width);
308 hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
309 }else {
310 ERR("GetWidth failed: %08x\n", nsres);
311 hres = E_FAIL;
314 nsAString_Finish(&width_str);
315 return hres;
318 static HRESULT WINAPI HTMLObjectElement_put_height(IHTMLObjectElement *iface, VARIANT v)
320 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
321 nsAString height_str;
322 PRUnichar buf[12];
323 nsresult nsres;
325 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
327 switch(V_VT(&v)) {
328 case VT_I4: {
329 static const WCHAR formatW[] = {'%','d',0};
330 sprintfW(buf, formatW, V_I4(&v));
331 break;
333 default:
334 FIXME("unimplemented for arg %s\n", debugstr_variant(&v));
335 return E_NOTIMPL;
338 nsAString_InitDepend(&height_str, buf);
339 nsres = nsIDOMHTMLObjectElement_SetHeight(This->nsobject, &height_str);
340 nsAString_Finish(&height_str);
341 if(NS_FAILED(nsres)) {
342 FIXME("SetHeight failed: %08x\n", nsres);
343 return E_FAIL;
346 notif_container_change(&This->plugin_container, DISPID_UNKNOWN);
347 return S_OK;
350 static HRESULT WINAPI HTMLObjectElement_get_height(IHTMLObjectElement *iface, VARIANT *p)
352 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
353 nsAString height_str;
354 nsresult nsres;
355 HRESULT hres;
357 TRACE("(%p)->(%p)\n", This, p);
359 nsAString_Init(&height_str, NULL);
360 nsres = nsIDOMHTMLObjectElement_GetHeight(This->nsobject, &height_str);
361 if(NS_SUCCEEDED(nsres)) {
362 const PRUnichar *height;
364 nsAString_GetData(&height_str, &height);
365 V_VT(p) = VT_BSTR;
366 V_BSTR(p) = SysAllocString(height);
367 hres = V_BSTR(p) ? S_OK : E_OUTOFMEMORY;
368 }else {
369 ERR("GetHeight failed: %08x\n", nsres);
370 hres = E_FAIL;
373 nsAString_Finish(&height_str);
374 return hres;
377 static HRESULT WINAPI HTMLObjectElement_get_readyState(IHTMLObjectElement *iface, LONG *p)
379 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
380 FIXME("(%p)->(%p)\n", This, p);
381 return E_NOTIMPL;
384 static HRESULT WINAPI HTMLObjectElement_put_onreadystatechange(IHTMLObjectElement *iface, VARIANT v)
386 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
387 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
388 return E_NOTIMPL;
391 static HRESULT WINAPI HTMLObjectElement_get_onreadystatechange(IHTMLObjectElement *iface, VARIANT *p)
393 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
394 FIXME("(%p)->(%p)\n", This, p);
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLObjectElement_put_onerror(IHTMLObjectElement *iface, VARIANT v)
400 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
401 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
402 return E_NOTIMPL;
405 static HRESULT WINAPI HTMLObjectElement_get_onerror(IHTMLObjectElement *iface, VARIANT *p)
407 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
408 FIXME("(%p)->(%p)\n", This, p);
409 return E_NOTIMPL;
412 static HRESULT WINAPI HTMLObjectElement_put_altHtml(IHTMLObjectElement *iface, BSTR v)
414 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
415 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
416 return E_NOTIMPL;
419 static HRESULT WINAPI HTMLObjectElement_get_altHtml(IHTMLObjectElement *iface, BSTR *p)
421 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
422 FIXME("(%p)->(%p)\n", This, p);
423 return E_NOTIMPL;
426 static HRESULT WINAPI HTMLObjectElement_put_vspace(IHTMLObjectElement *iface, LONG v)
428 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
429 FIXME("(%p)->(%d)\n", This, v);
430 return E_NOTIMPL;
433 static HRESULT WINAPI HTMLObjectElement_get_vspace(IHTMLObjectElement *iface, LONG *p)
435 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
436 nsresult nsres;
438 TRACE("(%p)->(%p)\n", This, p);
440 nsres = nsIDOMHTMLObjectElement_GetVspace(This->nsobject, p);
441 if(NS_FAILED(nsres)) {
442 ERR("GetVspace failed: %08x\n", nsres);
443 return E_FAIL;
446 return S_OK;
449 static HRESULT WINAPI HTMLObjectElement_put_hspace(IHTMLObjectElement *iface, LONG v)
451 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
452 FIXME("(%p)->(%d)\n", This, v);
453 return E_NOTIMPL;
456 static HRESULT WINAPI HTMLObjectElement_get_hspace(IHTMLObjectElement *iface, LONG *p)
458 HTMLObjectElement *This = impl_from_IHTMLObjectElement(iface);
459 FIXME("(%p)->(%p)\n", This, p);
460 return E_NOTIMPL;
463 static const IHTMLObjectElementVtbl HTMLObjectElementVtbl = {
464 HTMLObjectElement_QueryInterface,
465 HTMLObjectElement_AddRef,
466 HTMLObjectElement_Release,
467 HTMLObjectElement_GetTypeInfoCount,
468 HTMLObjectElement_GetTypeInfo,
469 HTMLObjectElement_GetIDsOfNames,
470 HTMLObjectElement_Invoke,
471 HTMLObjectElement_get_object,
472 HTMLObjectElement_get_classid,
473 HTMLObjectElement_get_data,
474 HTMLObjectElement_put_recordset,
475 HTMLObjectElement_get_recordset,
476 HTMLObjectElement_put_align,
477 HTMLObjectElement_get_align,
478 HTMLObjectElement_put_name,
479 HTMLObjectElement_get_name,
480 HTMLObjectElement_put_codeBase,
481 HTMLObjectElement_get_codeBase,
482 HTMLObjectElement_put_codeType,
483 HTMLObjectElement_get_codeType,
484 HTMLObjectElement_put_code,
485 HTMLObjectElement_get_code,
486 HTMLObjectElement_get_BaseHref,
487 HTMLObjectElement_put_type,
488 HTMLObjectElement_get_type,
489 HTMLObjectElement_get_form,
490 HTMLObjectElement_put_width,
491 HTMLObjectElement_get_width,
492 HTMLObjectElement_put_height,
493 HTMLObjectElement_get_height,
494 HTMLObjectElement_get_readyState,
495 HTMLObjectElement_put_onreadystatechange,
496 HTMLObjectElement_get_onreadystatechange,
497 HTMLObjectElement_put_onerror,
498 HTMLObjectElement_get_onerror,
499 HTMLObjectElement_put_altHtml,
500 HTMLObjectElement_get_altHtml,
501 HTMLObjectElement_put_vspace,
502 HTMLObjectElement_get_vspace,
503 HTMLObjectElement_put_hspace,
504 HTMLObjectElement_get_hspace
507 static inline HTMLObjectElement *impl_from_IHTMLObjectElement2(IHTMLObjectElement2 *iface)
509 return CONTAINING_RECORD(iface, HTMLObjectElement, IHTMLObjectElement2_iface);
512 static HRESULT WINAPI HTMLObjectElement2_QueryInterface(IHTMLObjectElement2 *iface,
513 REFIID riid, void **ppv)
515 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
517 return IHTMLDOMNode_QueryInterface(&This->plugin_container.element.node.IHTMLDOMNode_iface,
518 riid, ppv);
521 static ULONG WINAPI HTMLObjectElement2_AddRef(IHTMLObjectElement2 *iface)
523 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
525 return IHTMLDOMNode_AddRef(&This->plugin_container.element.node.IHTMLDOMNode_iface);
528 static ULONG WINAPI HTMLObjectElement2_Release(IHTMLObjectElement2 *iface)
530 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
532 return IHTMLDOMNode_Release(&This->plugin_container.element.node.IHTMLDOMNode_iface);
535 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfoCount(IHTMLObjectElement2 *iface, UINT *pctinfo)
537 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
538 return IDispatchEx_GetTypeInfoCount(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
539 pctinfo);
542 static HRESULT WINAPI HTMLObjectElement2_GetTypeInfo(IHTMLObjectElement2 *iface, UINT iTInfo,
543 LCID lcid, ITypeInfo **ppTInfo)
545 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
546 return IDispatchEx_GetTypeInfo(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
547 iTInfo, lcid, ppTInfo);
550 static HRESULT WINAPI HTMLObjectElement2_GetIDsOfNames(IHTMLObjectElement2 *iface, REFIID riid,
551 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
553 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
554 return IDispatchEx_GetIDsOfNames(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
555 riid, rgszNames, cNames, lcid, rgDispId);
558 static HRESULT WINAPI HTMLObjectElement2_Invoke(IHTMLObjectElement2 *iface, DISPID dispIdMember,
559 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
560 EXCEPINFO *pExcepInfo, UINT *puArgErr)
562 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
563 return IDispatchEx_Invoke(&This->plugin_container.element.node.event_target.dispex.IDispatchEx_iface,
564 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
567 static HRESULT WINAPI HTMLObjectElement2_namedRecordset(IHTMLObjectElement2 *iface, BSTR dataMember,
568 VARIANT *hierarchy, IDispatch **ppRecordset)
570 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
571 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
572 return E_NOTIMPL;
575 static HRESULT WINAPI HTMLObjectElement2_put_classid(IHTMLObjectElement2 *iface, BSTR v)
577 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
578 HRESULT hres;
580 static const WCHAR classidW[] = {'c','l','a','s','s','i','d',0};
582 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_w(v));
584 hres = elem_string_attr_setter(&This->plugin_container.element, classidW, v);
585 if(FAILED(hres))
586 return hres;
588 if(This->plugin_container.plugin_host) {
589 FIXME("Host already associated.\n");
590 return E_NOTIMPL;
594 * NOTE:
595 * If the element is not yet in DOM tree, we should embed it as soon as it's added.
596 * However, Gecko for some reason decides not to create NP plugin in this case,
597 * so this won't work.
600 return create_plugin_host(This->plugin_container.element.node.doc, &This->plugin_container);
603 static HRESULT WINAPI HTMLObjectElement2_get_classid(IHTMLObjectElement2 *iface, BSTR *p)
605 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
606 FIXME("(%p)->(%p)\n", This, p);
607 return E_NOTIMPL;
610 static HRESULT WINAPI HTMLObjectElement2_put_data(IHTMLObjectElement2 *iface, BSTR v)
612 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
613 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
614 return E_NOTIMPL;
617 static HRESULT WINAPI HTMLObjectElement2_get_data(IHTMLObjectElement2 *iface, BSTR *p)
619 HTMLObjectElement *This = impl_from_IHTMLObjectElement2(iface);
620 FIXME("(%p)->(%p)\n", This, p);
621 return E_NOTIMPL;
624 static const IHTMLObjectElement2Vtbl HTMLObjectElement2Vtbl = {
625 HTMLObjectElement2_QueryInterface,
626 HTMLObjectElement2_AddRef,
627 HTMLObjectElement2_Release,
628 HTMLObjectElement2_GetTypeInfoCount,
629 HTMLObjectElement2_GetTypeInfo,
630 HTMLObjectElement2_GetIDsOfNames,
631 HTMLObjectElement2_Invoke,
632 HTMLObjectElement2_namedRecordset,
633 HTMLObjectElement2_put_classid,
634 HTMLObjectElement2_get_classid,
635 HTMLObjectElement2_put_data,
636 HTMLObjectElement2_get_data
639 static inline HTMLObjectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
641 return CONTAINING_RECORD(iface, HTMLObjectElement, plugin_container.element.node);
644 static HRESULT HTMLObjectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
646 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
648 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
650 if(IsEqualGUID(&IID_IUnknown, riid)) {
651 *ppv = &This->IHTMLObjectElement_iface;
652 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
653 *ppv = &This->IHTMLObjectElement_iface;
654 }else if(IsEqualGUID(&IID_IHTMLObjectElement, riid)) {
655 *ppv = &This->IHTMLObjectElement_iface;
656 }else if(IsEqualGUID(&IID_IHTMLObjectElement2, riid)) {
657 *ppv = &This->IHTMLObjectElement2_iface;
658 }else if(IsEqualGUID(&IID_HTMLPluginContainer, riid)) {
659 /* Special pseudo-interface returning HTMLPluginContainse struct. */
660 *ppv = &This->plugin_container;
661 node_addref(&This->plugin_container.element.node);
662 return S_OK;
663 }else {
664 HRESULT hres;
666 hres = HTMLElement_QI(&This->plugin_container.element.node, riid, ppv);
667 if(hres == E_NOINTERFACE && This->plugin_container.plugin_host && This->plugin_container.plugin_host->plugin_unk) {
668 IUnknown *plugin_iface, *ret;
670 hres = IUnknown_QueryInterface(This->plugin_container.plugin_host->plugin_unk, riid, (void**)&plugin_iface);
671 if(hres == S_OK) {
672 hres = wrap_iface(plugin_iface, (IUnknown*)&This->IHTMLObjectElement_iface, &ret);
673 IUnknown_Release(plugin_iface);
674 if(FAILED(hres))
675 return hres;
677 TRACE("returning plugin iface %p wrapped to %p\n", plugin_iface, ret);
678 *ppv = ret;
679 return S_OK;
683 return hres;
686 IUnknown_AddRef((IUnknown*)*ppv);
687 return S_OK;
690 static void HTMLObjectElement_destructor(HTMLDOMNode *iface)
692 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
694 if(This->plugin_container.plugin_host)
695 detach_plugin_host(This->plugin_container.plugin_host);
697 HTMLElement_destructor(&This->plugin_container.element.node);
700 static HRESULT HTMLObjectElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
702 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
703 FIXME("(%p)->(%p)\n", This, p);
704 return E_NOTIMPL;
707 static HRESULT HTMLObjectElement_get_dispid(HTMLDOMNode *iface, BSTR name,
708 DWORD grfdex, DISPID *pid)
710 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
712 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(name), grfdex, pid);
714 return get_plugin_dispid(&This->plugin_container, name, pid);
717 static HRESULT HTMLObjectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
718 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
720 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
722 TRACE("(%p)->(%d)\n", This, id);
724 return invoke_plugin_prop(&This->plugin_container, id, lcid, flags, params, res, ei);
727 static void HTMLObjectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
729 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
731 if(This->nsobject)
732 note_cc_edge((nsISupports*)This->nsobject, "This->nsobject", cb);
735 static void HTMLObjectElement_unlink(HTMLDOMNode *iface)
737 HTMLObjectElement *This = impl_from_HTMLDOMNode(iface);
739 if(This->nsobject) {
740 nsIDOMHTMLObjectElement *nsobject = This->nsobject;
742 This->nsobject = NULL;
743 nsIDOMHTMLObjectElement_Release(nsobject);
747 static const NodeImplVtbl HTMLObjectElementImplVtbl = {
748 &CLSID_HTMLObjectElement,
749 HTMLObjectElement_QI,
750 HTMLObjectElement_destructor,
751 HTMLElement_cpc,
752 HTMLElement_clone,
753 HTMLElement_handle_event,
754 HTMLElement_get_attr_col,
755 NULL,
756 NULL,
757 NULL,
758 NULL,
759 HTMLObjectElement_get_readystate,
760 HTMLObjectElement_get_dispid,
761 HTMLObjectElement_invoke,
762 NULL,
763 HTMLObjectElement_traverse,
764 HTMLObjectElement_unlink
767 static const tid_t HTMLObjectElement_iface_tids[] = {
768 IHTMLObjectElement2_tid,
769 IHTMLObjectElement_tid,
770 HTMLELEMENT_TIDS,
773 static dispex_static_data_t HTMLObjectElement_dispex = {
774 NULL,
775 DispHTMLObjectElement_tid,
776 HTMLObjectElement_iface_tids,
777 HTMLElement_init_dispex_info
780 HRESULT HTMLObjectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
782 HTMLObjectElement *ret;
783 nsresult nsres;
785 ret = heap_alloc_zero(sizeof(*ret));
786 if(!ret)
787 return E_OUTOFMEMORY;
789 ret->IHTMLObjectElement_iface.lpVtbl = &HTMLObjectElementVtbl;
790 ret->IHTMLObjectElement2_iface.lpVtbl = &HTMLObjectElement2Vtbl;
791 ret->plugin_container.element.node.vtbl = &HTMLObjectElementImplVtbl;
793 HTMLElement_Init(&ret->plugin_container.element, doc, nselem, &HTMLObjectElement_dispex);
795 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLObjectElement, (void**)&ret->nsobject);
796 assert(nsres == NS_OK);
798 *elem = &ret->plugin_container.element;
799 return S_OK;
802 struct HTMLEmbed {
803 HTMLElement element;
805 IHTMLEmbedElement IHTMLEmbedElement_iface;
808 static inline HTMLEmbed *impl_from_IHTMLEmbedElement(IHTMLEmbedElement *iface)
810 return CONTAINING_RECORD(iface, HTMLEmbed, IHTMLEmbedElement_iface);
813 static HRESULT WINAPI HTMLEmbedElement_QueryInterface(IHTMLEmbedElement *iface,
814 REFIID riid, void **ppv)
816 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
818 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
821 static ULONG WINAPI HTMLEmbedElement_AddRef(IHTMLEmbedElement *iface)
823 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
825 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
828 static ULONG WINAPI HTMLEmbedElement_Release(IHTMLEmbedElement *iface)
830 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
832 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
835 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfoCount(IHTMLEmbedElement *iface, UINT *pctinfo)
837 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
838 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
841 static HRESULT WINAPI HTMLEmbedElement_GetTypeInfo(IHTMLEmbedElement *iface, UINT iTInfo,
842 LCID lcid, ITypeInfo **ppTInfo)
844 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
845 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
846 ppTInfo);
849 static HRESULT WINAPI HTMLEmbedElement_GetIDsOfNames(IHTMLEmbedElement *iface, REFIID riid,
850 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
852 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
853 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
854 cNames, lcid, rgDispId);
857 static HRESULT WINAPI HTMLEmbedElement_Invoke(IHTMLEmbedElement *iface, DISPID dispIdMember,
858 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
859 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
861 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
862 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
863 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
866 static HRESULT WINAPI HTMLEmbedElement_put_hidden(IHTMLEmbedElement *iface, BSTR v)
868 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
869 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
870 return E_NOTIMPL;
873 static HRESULT WINAPI HTMLEmbedElement_get_hidden(IHTMLEmbedElement *iface, BSTR *p)
875 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
876 FIXME("(%p)->(%p)\n", This, p);
877 return E_NOTIMPL;
880 static HRESULT WINAPI HTMLEmbedElement_get_palette(IHTMLEmbedElement *iface, BSTR *p)
882 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
883 FIXME("(%p)->(%p)\n", This, p);
884 return E_NOTIMPL;
887 static HRESULT WINAPI HTMLEmbedElement_get_pluginspage(IHTMLEmbedElement *iface, BSTR *p)
889 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
890 FIXME("(%p)->(%p)\n", This, p);
891 return E_NOTIMPL;
894 static HRESULT WINAPI HTMLEmbedElement_put_src(IHTMLEmbedElement *iface, BSTR v)
896 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
897 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
898 return E_NOTIMPL;
901 static HRESULT WINAPI HTMLEmbedElement_get_src(IHTMLEmbedElement *iface, BSTR *p)
903 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
904 FIXME("(%p)->(%p)\n", This, p);
905 return E_NOTIMPL;
908 static HRESULT WINAPI HTMLEmbedElement_put_units(IHTMLEmbedElement *iface, BSTR v)
910 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
911 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
912 return E_NOTIMPL;
915 static HRESULT WINAPI HTMLEmbedElement_get_units(IHTMLEmbedElement *iface, BSTR *p)
917 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
918 FIXME("(%p)->(%p)\n", This, p);
919 return E_NOTIMPL;
922 static HRESULT WINAPI HTMLEmbedElement_put_name(IHTMLEmbedElement *iface, BSTR v)
924 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
925 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
926 return E_NOTIMPL;
929 static HRESULT WINAPI HTMLEmbedElement_get_name(IHTMLEmbedElement *iface, BSTR *p)
931 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
932 FIXME("(%p)->(%p)\n", This, p);
933 return E_NOTIMPL;
936 static HRESULT WINAPI HTMLEmbedElement_put_width(IHTMLEmbedElement *iface, VARIANT v)
938 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
939 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
940 return E_NOTIMPL;
943 static HRESULT WINAPI HTMLEmbedElement_get_width(IHTMLEmbedElement *iface, VARIANT *p)
945 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
946 FIXME("(%p)->(%p)\n", This, p);
947 return E_NOTIMPL;
950 static HRESULT WINAPI HTMLEmbedElement_put_height(IHTMLEmbedElement *iface, VARIANT v)
952 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
953 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
954 return E_NOTIMPL;
957 static HRESULT WINAPI HTMLEmbedElement_get_height(IHTMLEmbedElement *iface, VARIANT *p)
959 HTMLEmbed *This = impl_from_IHTMLEmbedElement(iface);
960 FIXME("(%p)->(%p)\n", This, p);
961 return E_NOTIMPL;
964 static const IHTMLEmbedElementVtbl HTMLEmbedElementVtbl = {
965 HTMLEmbedElement_QueryInterface,
966 HTMLEmbedElement_AddRef,
967 HTMLEmbedElement_Release,
968 HTMLEmbedElement_GetTypeInfoCount,
969 HTMLEmbedElement_GetTypeInfo,
970 HTMLEmbedElement_GetIDsOfNames,
971 HTMLEmbedElement_Invoke,
972 HTMLEmbedElement_put_hidden,
973 HTMLEmbedElement_get_hidden,
974 HTMLEmbedElement_get_palette,
975 HTMLEmbedElement_get_pluginspage,
976 HTMLEmbedElement_put_src,
977 HTMLEmbedElement_get_src,
978 HTMLEmbedElement_put_units,
979 HTMLEmbedElement_get_units,
980 HTMLEmbedElement_put_name,
981 HTMLEmbedElement_get_name,
982 HTMLEmbedElement_put_width,
983 HTMLEmbedElement_get_width,
984 HTMLEmbedElement_put_height,
985 HTMLEmbedElement_get_height
988 static inline HTMLEmbed *embed_from_HTMLDOMNode(HTMLDOMNode *iface)
990 return CONTAINING_RECORD(iface, HTMLEmbed, element.node);
993 static HRESULT HTMLEmbedElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
995 HTMLEmbed *This = embed_from_HTMLDOMNode(iface);
997 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
999 if(IsEqualGUID(&IID_IUnknown, riid)) {
1000 *ppv = &This->IHTMLEmbedElement_iface;
1001 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1002 *ppv = &This->IHTMLEmbedElement_iface;
1003 }else if(IsEqualGUID(&IID_IHTMLEmbedElement, riid)) {
1004 *ppv = &This->IHTMLEmbedElement_iface;
1005 }else {
1006 return HTMLElement_QI(&This->element.node, riid, ppv);
1009 IUnknown_AddRef((IUnknown*)*ppv);
1010 return S_OK;
1013 static void HTMLEmbedElement_destructor(HTMLDOMNode *iface)
1015 HTMLEmbed *This = embed_from_HTMLDOMNode(iface);
1017 HTMLElement_destructor(&This->element.node);
1020 static const NodeImplVtbl HTMLEmbedElementImplVtbl = {
1021 &CLSID_HTMLEmbed,
1022 HTMLEmbedElement_QI,
1023 HTMLEmbedElement_destructor,
1024 HTMLElement_cpc,
1025 HTMLElement_clone,
1026 HTMLElement_handle_event,
1027 HTMLElement_get_attr_col
1030 static const tid_t HTMLEmbedElement_iface_tids[] = {
1031 HTMLELEMENT_TIDS,
1032 IHTMLEmbedElement_tid,
1035 static dispex_static_data_t HTMLEmbedElement_dispex = {
1036 NULL,
1037 DispHTMLEmbed_tid,
1038 HTMLEmbedElement_iface_tids,
1039 HTMLElement_init_dispex_info
1042 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1044 HTMLEmbed *ret;
1046 ret = heap_alloc_zero(sizeof(*ret));
1047 if(!ret)
1048 return E_OUTOFMEMORY;
1050 ret->IHTMLEmbedElement_iface.lpVtbl = &HTMLEmbedElementVtbl;
1051 ret->element.node.vtbl = &HTMLEmbedElementImplVtbl;
1053 HTMLElement_Init(&ret->element, doc, nselem, &HTMLEmbedElement_dispex);
1054 *elem = &ret->element;
1055 return S_OK;