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
;
39 static inline HTMLIFrame
*impl_from_IHTMLIFrameElement(IHTMLIFrameElement
*iface
)
41 return CONTAINING_RECORD(iface
, HTMLIFrame
, IHTMLIFrameElement_iface
);
44 static HRESULT WINAPI
HTMLIFrameElement_QueryInterface(IHTMLIFrameElement
*iface
,
45 REFIID riid
, void **ppv
)
47 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
49 return IHTMLDOMNode_QueryInterface(&This
->framebase
.element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
52 static ULONG WINAPI
HTMLIFrameElement_AddRef(IHTMLIFrameElement
*iface
)
54 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
56 return IHTMLDOMNode_AddRef(&This
->framebase
.element
.node
.IHTMLDOMNode_iface
);
59 static ULONG WINAPI
HTMLIFrameElement_Release(IHTMLIFrameElement
*iface
)
61 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
63 return IHTMLDOMNode_Release(&This
->framebase
.element
.node
.IHTMLDOMNode_iface
);
66 static HRESULT WINAPI
HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement
*iface
, UINT
*pctinfo
)
68 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
69 return IDispatchEx_GetTypeInfoCount(&This
->framebase
.element
.node
.dispex
.IDispatchEx_iface
,
73 static HRESULT WINAPI
HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement
*iface
, UINT iTInfo
,
74 LCID lcid
, ITypeInfo
**ppTInfo
)
76 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
77 return IDispatchEx_GetTypeInfo(&This
->framebase
.element
.node
.dispex
.IDispatchEx_iface
, iTInfo
,
81 static HRESULT WINAPI
HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement
*iface
, REFIID riid
,
82 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
84 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
85 return IDispatchEx_GetIDsOfNames(&This
->framebase
.element
.node
.dispex
.IDispatchEx_iface
, riid
,
86 rgszNames
, cNames
, lcid
, rgDispId
);
89 static HRESULT WINAPI
HTMLIFrameElement_Invoke(IHTMLIFrameElement
*iface
, DISPID dispIdMember
,
90 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
91 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
93 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
94 return IDispatchEx_Invoke(&This
->framebase
.element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
,
95 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
98 static HRESULT WINAPI
HTMLIFrameElement_put_vspace(IHTMLIFrameElement
*iface
, LONG v
)
100 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
101 FIXME("(%p)->(%d)\n", This
, v
);
105 static HRESULT WINAPI
HTMLIFrameElement_get_vspace(IHTMLIFrameElement
*iface
, LONG
*p
)
107 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
108 FIXME("(%p)->(%p)\n", This
, p
);
112 static HRESULT WINAPI
HTMLIFrameElement_put_hspace(IHTMLIFrameElement
*iface
, LONG v
)
114 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
115 FIXME("(%p)->(%d)\n", This
, v
);
119 static HRESULT WINAPI
HTMLIFrameElement_get_hspace(IHTMLIFrameElement
*iface
, LONG
*p
)
121 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
122 FIXME("(%p)->(%p)\n", This
, p
);
126 static HRESULT WINAPI
HTMLIFrameElement_put_align(IHTMLIFrameElement
*iface
, BSTR v
)
128 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
129 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
133 static HRESULT WINAPI
HTMLIFrameElement_get_align(IHTMLIFrameElement
*iface
, BSTR
*p
)
135 HTMLIFrame
*This
= impl_from_IHTMLIFrameElement(iface
);
136 FIXME("(%p)->(%p)\n", This
, p
);
140 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl
= {
141 HTMLIFrameElement_QueryInterface
,
142 HTMLIFrameElement_AddRef
,
143 HTMLIFrameElement_Release
,
144 HTMLIFrameElement_GetTypeInfoCount
,
145 HTMLIFrameElement_GetTypeInfo
,
146 HTMLIFrameElement_GetIDsOfNames
,
147 HTMLIFrameElement_Invoke
,
148 HTMLIFrameElement_put_vspace
,
149 HTMLIFrameElement_get_vspace
,
150 HTMLIFrameElement_put_hspace
,
151 HTMLIFrameElement_get_hspace
,
152 HTMLIFrameElement_put_align
,
153 HTMLIFrameElement_get_align
156 static inline HTMLIFrame
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
158 return CONTAINING_RECORD(iface
, HTMLIFrame
, framebase
.element
.node
);
161 static HRESULT
HTMLIFrame_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
163 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
165 if(IsEqualGUID(&IID_IHTMLIFrameElement
, riid
)) {
166 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This
, ppv
);
167 *ppv
= &This
->IHTMLIFrameElement_iface
;
169 return HTMLFrameBase_QI(&This
->framebase
, riid
, ppv
);
172 IUnknown_AddRef((IUnknown
*)*ppv
);
176 static void HTMLIFrame_destructor(HTMLDOMNode
*iface
)
178 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
180 HTMLFrameBase_destructor(&This
->framebase
);
183 static HRESULT
HTMLIFrame_get_document(HTMLDOMNode
*iface
, IDispatch
**p
)
185 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
187 if(!This
->framebase
.content_window
|| !This
->framebase
.content_window
->doc
) {
192 *p
= (IDispatch
*)&This
->framebase
.content_window
->doc
->basedoc
.IHTMLDocument2_iface
;
193 IDispatch_AddRef(*p
);
197 static HRESULT
HTMLIFrame_get_dispid(HTMLDOMNode
*iface
, BSTR name
,
198 DWORD grfdex
, DISPID
*pid
)
200 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
202 if(!This
->framebase
.content_window
)
203 return DISP_E_UNKNOWNNAME
;
205 return search_window_props(This
->framebase
.content_window
, name
, grfdex
, pid
);
208 static HRESULT
HTMLIFrame_invoke(HTMLDOMNode
*iface
, DISPID id
, LCID lcid
,
209 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
211 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
213 if(!This
->framebase
.content_window
) {
214 ERR("no content window to invoke on\n");
218 return IDispatchEx_InvokeEx(&This
->framebase
.content_window
->IDispatchEx_iface
, id
, lcid
,
219 flags
, params
, res
, ei
, caller
);
222 static HRESULT
HTMLIFrame_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
224 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
226 return IHTMLFrameBase2_get_readyState(&This
->framebase
.IHTMLFrameBase2_iface
, p
);
229 static HRESULT
HTMLIFrame_bind_to_tree(HTMLDOMNode
*iface
)
231 HTMLIFrame
*This
= impl_from_HTMLDOMNode(iface
);
232 nsIDOMDocument
*nsdoc
;
236 nsres
= nsIDOMHTMLIFrameElement_GetContentDocument(This
->framebase
.nsiframe
, &nsdoc
);
237 if(NS_FAILED(nsres
) || !nsdoc
) {
238 ERR("GetContentDocument failed: %08x\n", nsres
);
242 hres
= set_frame_doc(&This
->framebase
, nsdoc
);
243 nsIDOMDocument_Release(nsdoc
);
247 static const NodeImplVtbl HTMLIFrameImplVtbl
= {
249 HTMLIFrame_destructor
,
255 HTMLIFrame_get_document
,
256 HTMLIFrame_get_readystate
,
257 HTMLIFrame_get_dispid
,
259 HTMLIFrame_bind_to_tree
262 static const tid_t HTMLIFrame_iface_tids
[] = {
266 IHTMLIFrameElement_tid
,
270 static dispex_static_data_t HTMLIFrame_dispex
= {
274 HTMLIFrame_iface_tids
277 HRESULT
HTMLIFrame_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
281 ret
= heap_alloc_zero(sizeof(HTMLIFrame
));
283 return E_OUTOFMEMORY
;
285 ret
->IHTMLIFrameElement_iface
.lpVtbl
= &HTMLIFrameElementVtbl
;
286 ret
->framebase
.element
.node
.vtbl
= &HTMLIFrameImplVtbl
;
288 HTMLFrameBase_Init(&ret
->framebase
, doc
, nselem
, &HTMLIFrame_dispex
);
290 *elem
= &ret
->framebase
.element
;