2 * Copyright 2008 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
28 #include "mshtml_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 HTMLFrameBase framebase;
36 IHTMLIFrameElement IHTMLIFrameElement_iface;
37 IHTMLIFrameElement2 IHTMLIFrameElement2_iface;
38 IHTMLIFrameElement3 IHTMLIFrameElement3_iface;
41 static inline HTMLIFrame *impl_from_IHTMLIFrameElement(IHTMLIFrameElement *iface)
43 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement_iface);
46 static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface,
47 REFIID riid, void **ppv)
49 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
51 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
54 static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface)
56 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
58 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
61 static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface)
63 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
65 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
68 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo)
70 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
71 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.dispex.IDispatchEx_iface,
75 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
79 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.dispex.IDispatchEx_iface, iTInfo,
83 static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
86 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
87 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.dispex.IDispatchEx_iface, riid,
88 rgszNames, cNames, lcid, rgDispId);
91 static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember,
92 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
93 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
95 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
96 return IDispatchEx_Invoke(&This->framebase.element.node.dispex.IDispatchEx_iface, dispIdMember,
97 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v)
102 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
103 FIXME("(%p)->(%d)\n", This, v);
107 static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p)
109 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
110 FIXME("(%p)->(%p)\n", This, p);
114 static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v)
116 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
117 FIXME("(%p)->(%d)\n", This, v);
121 static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p)
123 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
124 FIXME("(%p)->(%p)\n", This, p);
128 static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v)
130 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
131 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
135 static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p)
137 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
138 FIXME("(%p)->(%p)\n", This, p);
142 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = {
143 HTMLIFrameElement_QueryInterface,
144 HTMLIFrameElement_AddRef,
145 HTMLIFrameElement_Release,
146 HTMLIFrameElement_GetTypeInfoCount,
147 HTMLIFrameElement_GetTypeInfo,
148 HTMLIFrameElement_GetIDsOfNames,
149 HTMLIFrameElement_Invoke,
150 HTMLIFrameElement_put_vspace,
151 HTMLIFrameElement_get_vspace,
152 HTMLIFrameElement_put_hspace,
153 HTMLIFrameElement_get_hspace,
154 HTMLIFrameElement_put_align,
155 HTMLIFrameElement_get_align
158 static inline HTMLIFrame *impl_from_IHTMLIFrameElement2(IHTMLIFrameElement2 *iface)
160 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement2_iface);
163 static HRESULT WINAPI HTMLIFrameElement2_QueryInterface(IHTMLIFrameElement2 *iface,
164 REFIID riid, void **ppv)
166 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
168 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
171 static ULONG WINAPI HTMLIFrameElement2_AddRef(IHTMLIFrameElement2 *iface)
173 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
175 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
178 static ULONG WINAPI HTMLIFrameElement2_Release(IHTMLIFrameElement2 *iface)
180 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
182 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
185 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfoCount(IHTMLIFrameElement2 *iface, UINT *pctinfo)
187 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
188 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.dispex.IDispatchEx_iface,
192 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfo(IHTMLIFrameElement2 *iface, UINT iTInfo,
193 LCID lcid, ITypeInfo **ppTInfo)
195 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
196 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.dispex.IDispatchEx_iface, iTInfo,
200 static HRESULT WINAPI HTMLIFrameElement2_GetIDsOfNames(IHTMLIFrameElement2 *iface, REFIID riid,
201 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
203 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
204 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.dispex.IDispatchEx_iface, riid,
205 rgszNames, cNames, lcid, rgDispId);
208 static HRESULT WINAPI HTMLIFrameElement2_Invoke(IHTMLIFrameElement2 *iface, DISPID dispIdMember,
209 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
210 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
212 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
213 return IDispatchEx_Invoke(&This->framebase.element.node.dispex.IDispatchEx_iface, dispIdMember,
214 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
217 static HRESULT WINAPI HTMLIFrameElement2_put_height(IHTMLIFrameElement2 *iface, VARIANT v)
219 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
220 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
224 static HRESULT WINAPI HTMLIFrameElement2_get_height(IHTMLIFrameElement2 *iface, VARIANT *p)
226 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
227 FIXME("(%p)->(%p)\n", This, p);
231 static HRESULT WINAPI HTMLIFrameElement2_put_width(IHTMLIFrameElement2 *iface, VARIANT v)
233 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
234 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
238 static HRESULT WINAPI HTMLIFrameElement2_get_width(IHTMLIFrameElement2 *iface, VARIANT *p)
240 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
241 FIXME("(%p)->(%p)\n", This, p);
245 static const IHTMLIFrameElement2Vtbl HTMLIFrameElement2Vtbl = {
246 HTMLIFrameElement2_QueryInterface,
247 HTMLIFrameElement2_AddRef,
248 HTMLIFrameElement2_Release,
249 HTMLIFrameElement2_GetTypeInfoCount,
250 HTMLIFrameElement2_GetTypeInfo,
251 HTMLIFrameElement2_GetIDsOfNames,
252 HTMLIFrameElement2_Invoke,
253 HTMLIFrameElement2_put_height,
254 HTMLIFrameElement2_get_height,
255 HTMLIFrameElement2_put_width,
256 HTMLIFrameElement2_get_width
259 static inline HTMLIFrame *impl_from_IHTMLIFrameElement3(IHTMLIFrameElement3 *iface)
261 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement3_iface);
264 static HRESULT WINAPI HTMLIFrameElement3_QueryInterface(IHTMLIFrameElement3 *iface,
265 REFIID riid, void **ppv)
267 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
269 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
272 static ULONG WINAPI HTMLIFrameElement3_AddRef(IHTMLIFrameElement3 *iface)
274 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
276 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
279 static ULONG WINAPI HTMLIFrameElement3_Release(IHTMLIFrameElement3 *iface)
281 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
283 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
286 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfoCount(IHTMLIFrameElement3 *iface, UINT *pctinfo)
288 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
289 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.dispex.IDispatchEx_iface,
293 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfo(IHTMLIFrameElement3 *iface, UINT iTInfo,
294 LCID lcid, ITypeInfo **ppTInfo)
296 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
297 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.dispex.IDispatchEx_iface, iTInfo,
301 static HRESULT WINAPI HTMLIFrameElement3_GetIDsOfNames(IHTMLIFrameElement3 *iface, REFIID riid,
302 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
304 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
305 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.dispex.IDispatchEx_iface, riid,
306 rgszNames, cNames, lcid, rgDispId);
309 static HRESULT WINAPI HTMLIFrameElement3_Invoke(IHTMLIFrameElement3 *iface, DISPID dispIdMember,
310 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
311 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
313 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
314 return IDispatchEx_Invoke(&This->framebase.element.node.dispex.IDispatchEx_iface, dispIdMember,
315 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
318 static HRESULT WINAPI HTMLIFrameElement3_get_contentDocument(IHTMLIFrameElement3 *iface, IDispatch **p)
320 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
321 FIXME("(%p)->(%p)\n", This, p);
325 static HRESULT WINAPI HTMLIFrameElement3_put_src(IHTMLIFrameElement3 *iface, BSTR v)
327 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
328 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
332 static HRESULT WINAPI HTMLIFrameElement3_get_src(IHTMLIFrameElement3 *iface, BSTR *p)
334 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
335 FIXME("(%p)->(%p)\n", This, p);
339 static HRESULT WINAPI HTMLIFrameElement3_put_longDesc(IHTMLIFrameElement3 *iface, BSTR v)
341 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
342 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
346 static HRESULT WINAPI HTMLIFrameElement3_get_longDesc(IHTMLIFrameElement3 *iface, BSTR *p)
348 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
349 FIXME("(%p)->(%p)\n", This, p);
353 static HRESULT WINAPI HTMLIFrameElement3_put_frameBorder(IHTMLIFrameElement3 *iface, BSTR v)
355 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
356 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
360 static HRESULT WINAPI HTMLIFrameElement3_get_frameBorder(IHTMLIFrameElement3 *iface, BSTR *p)
362 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
363 FIXME("(%p)->(%p)\n", This, p);
367 static const IHTMLIFrameElement3Vtbl HTMLIFrameElement3Vtbl = {
368 HTMLIFrameElement3_QueryInterface,
369 HTMLIFrameElement3_AddRef,
370 HTMLIFrameElement3_Release,
371 HTMLIFrameElement3_GetTypeInfoCount,
372 HTMLIFrameElement3_GetTypeInfo,
373 HTMLIFrameElement3_GetIDsOfNames,
374 HTMLIFrameElement3_Invoke,
375 HTMLIFrameElement3_get_contentDocument,
376 HTMLIFrameElement3_put_src,
377 HTMLIFrameElement3_get_src,
378 HTMLIFrameElement3_put_longDesc,
379 HTMLIFrameElement3_get_longDesc,
380 HTMLIFrameElement3_put_frameBorder,
381 HTMLIFrameElement3_get_frameBorder
384 static inline HTMLIFrame *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
386 return CONTAINING_RECORD(iface, HTMLIFrame, framebase.element.node);
389 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
391 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
393 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
394 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
395 *ppv = &This->IHTMLIFrameElement_iface;
396 }else if(IsEqualGUID(&IID_IHTMLIFrameElement2, riid)) {
397 TRACE("(%p)->(IID_IHTMLIFrameElement2 %p)\n", This, ppv);
398 *ppv = &This->IHTMLIFrameElement2_iface;
399 }else if(IsEqualGUID(&IID_IHTMLIFrameElement3, riid)) {
400 TRACE("(%p)->(IID_IHTMLIFrameElement3 %p)\n", This, ppv);
401 *ppv = &This->IHTMLIFrameElement3_iface;
403 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
406 IUnknown_AddRef((IUnknown*)*ppv);
410 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
412 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
414 HTMLFrameBase_destructor(&This->framebase);
417 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
419 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
421 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
426 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
427 IDispatch_AddRef(*p);
431 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
432 DWORD grfdex, DISPID *pid)
434 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
436 if(!This->framebase.content_window)
437 return DISP_E_UNKNOWNNAME;
439 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
442 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
443 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
445 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
447 if(!This->framebase.content_window) {
448 ERR("no content window to invoke on\n");
452 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
453 flags, params, res, ei, caller);
456 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
458 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
460 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
463 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
465 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
466 nsIDOMDocument *nsdoc;
470 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
471 if(NS_FAILED(nsres) || !nsdoc) {
472 ERR("GetContentDocument failed: %08x\n", nsres);
476 hres = set_frame_doc(&This->framebase, nsdoc);
477 nsIDOMDocument_Release(nsdoc);
481 static const NodeImplVtbl HTMLIFrameImplVtbl = {
483 HTMLIFrame_destructor,
485 HTMLElement_handle_event,
486 HTMLElement_get_attr_col,
491 HTMLIFrame_get_document,
492 HTMLIFrame_get_readystate,
493 HTMLIFrame_get_dispid,
495 HTMLIFrame_bind_to_tree
498 static const tid_t HTMLIFrame_iface_tids[] = {
502 IHTMLIFrameElement_tid,
503 IHTMLIFrameElement2_tid,
504 IHTMLIFrameElement3_tid,
508 static dispex_static_data_t HTMLIFrame_dispex = {
512 HTMLIFrame_iface_tids
515 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
519 ret = heap_alloc_zero(sizeof(HTMLIFrame));
521 return E_OUTOFMEMORY;
523 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
524 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
525 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
526 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
528 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
530 *elem = &ret->framebase.element;