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);
324 TRACE("(%p)->(%p)\n", This, p);
326 if(!This->framebase.content_window) {
331 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
332 *p = (IDispatch*)doc;
336 static HRESULT WINAPI HTMLIFrameElement3_put_src(IHTMLIFrameElement3 *iface, BSTR v)
338 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
339 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
343 static HRESULT WINAPI HTMLIFrameElement3_get_src(IHTMLIFrameElement3 *iface, BSTR *p)
345 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
346 FIXME("(%p)->(%p)\n", This, p);
350 static HRESULT WINAPI HTMLIFrameElement3_put_longDesc(IHTMLIFrameElement3 *iface, BSTR v)
352 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
353 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
357 static HRESULT WINAPI HTMLIFrameElement3_get_longDesc(IHTMLIFrameElement3 *iface, BSTR *p)
359 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
360 FIXME("(%p)->(%p)\n", This, p);
364 static HRESULT WINAPI HTMLIFrameElement3_put_frameBorder(IHTMLIFrameElement3 *iface, BSTR v)
366 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
367 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
371 static HRESULT WINAPI HTMLIFrameElement3_get_frameBorder(IHTMLIFrameElement3 *iface, BSTR *p)
373 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
374 FIXME("(%p)->(%p)\n", This, p);
378 static const IHTMLIFrameElement3Vtbl HTMLIFrameElement3Vtbl = {
379 HTMLIFrameElement3_QueryInterface,
380 HTMLIFrameElement3_AddRef,
381 HTMLIFrameElement3_Release,
382 HTMLIFrameElement3_GetTypeInfoCount,
383 HTMLIFrameElement3_GetTypeInfo,
384 HTMLIFrameElement3_GetIDsOfNames,
385 HTMLIFrameElement3_Invoke,
386 HTMLIFrameElement3_get_contentDocument,
387 HTMLIFrameElement3_put_src,
388 HTMLIFrameElement3_get_src,
389 HTMLIFrameElement3_put_longDesc,
390 HTMLIFrameElement3_get_longDesc,
391 HTMLIFrameElement3_put_frameBorder,
392 HTMLIFrameElement3_get_frameBorder
395 static inline HTMLIFrame *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
397 return CONTAINING_RECORD(iface, HTMLIFrame, framebase.element.node);
400 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
402 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
404 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
405 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
406 *ppv = &This->IHTMLIFrameElement_iface;
407 }else if(IsEqualGUID(&IID_IHTMLIFrameElement2, riid)) {
408 TRACE("(%p)->(IID_IHTMLIFrameElement2 %p)\n", This, ppv);
409 *ppv = &This->IHTMLIFrameElement2_iface;
410 }else if(IsEqualGUID(&IID_IHTMLIFrameElement3, riid)) {
411 TRACE("(%p)->(IID_IHTMLIFrameElement3 %p)\n", This, ppv);
412 *ppv = &This->IHTMLIFrameElement3_iface;
414 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
417 IUnknown_AddRef((IUnknown*)*ppv);
421 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
423 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
425 HTMLFrameBase_destructor(&This->framebase);
428 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
430 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
432 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
437 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
438 IDispatch_AddRef(*p);
442 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
443 DWORD grfdex, DISPID *pid)
445 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
447 if(!This->framebase.content_window)
448 return DISP_E_UNKNOWNNAME;
450 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
453 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
454 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
456 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
458 if(!This->framebase.content_window) {
459 ERR("no content window to invoke on\n");
463 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
464 flags, params, res, ei, caller);
467 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
469 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
471 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
474 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
476 HTMLIFrame *This = impl_from_HTMLDOMNode(iface);
477 nsIDOMDocument *nsdoc;
481 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
482 if(NS_FAILED(nsres) || !nsdoc) {
483 ERR("GetContentDocument failed: %08x\n", nsres);
487 hres = set_frame_doc(&This->framebase, nsdoc);
488 nsIDOMDocument_Release(nsdoc);
492 static const NodeImplVtbl HTMLIFrameImplVtbl = {
494 HTMLIFrame_destructor,
496 HTMLElement_handle_event,
497 HTMLElement_get_attr_col,
502 HTMLIFrame_get_document,
503 HTMLIFrame_get_readystate,
504 HTMLIFrame_get_dispid,
506 HTMLIFrame_bind_to_tree
509 static const tid_t HTMLIFrame_iface_tids[] = {
513 IHTMLIFrameElement_tid,
514 IHTMLIFrameElement2_tid,
515 IHTMLIFrameElement3_tid,
519 static dispex_static_data_t HTMLIFrame_dispex = {
523 HTMLIFrame_iface_tids
526 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
530 ret = heap_alloc_zero(sizeof(HTMLIFrame));
532 return E_OUTOFMEMORY;
534 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
535 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
536 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
537 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
539 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
541 *elem = &ret->framebase.element;