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(HTMLDOMNODE(&This->framebase.element.node), riid, ppv);
52 static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface)
54 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
56 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->framebase.element.node));
59 static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface)
61 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
63 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->framebase.element.node));
66 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo)
68 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
69 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->framebase.element.node.dispex), pctinfo);
72 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo,
73 LCID lcid, ITypeInfo **ppTInfo)
75 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
76 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->framebase.element.node.dispex), iTInfo, lcid, ppTInfo);
79 static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid,
80 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
82 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
83 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->framebase.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
86 static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember,
87 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
88 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
90 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
91 return IDispatchEx_Invoke(DISPATCHEX(&This->framebase.element.node.dispex), dispIdMember, riid,
92 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
95 static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v)
97 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
98 FIXME("(%p)->(%d)\n", This, v);
102 static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p)
104 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
105 FIXME("(%p)->(%p)\n", This, p);
109 static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v)
111 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
112 FIXME("(%p)->(%d)\n", This, v);
116 static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p)
118 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
119 FIXME("(%p)->(%p)\n", This, p);
123 static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v)
125 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
126 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
130 static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p)
132 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
133 FIXME("(%p)->(%p)\n", This, p);
137 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = {
138 HTMLIFrameElement_QueryInterface,
139 HTMLIFrameElement_AddRef,
140 HTMLIFrameElement_Release,
141 HTMLIFrameElement_GetTypeInfoCount,
142 HTMLIFrameElement_GetTypeInfo,
143 HTMLIFrameElement_GetIDsOfNames,
144 HTMLIFrameElement_Invoke,
145 HTMLIFrameElement_put_vspace,
146 HTMLIFrameElement_get_vspace,
147 HTMLIFrameElement_put_hspace,
148 HTMLIFrameElement_get_hspace,
149 HTMLIFrameElement_put_align,
150 HTMLIFrameElement_get_align
153 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
155 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
157 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
159 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
160 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
161 *ppv = &This->IHTMLIFrameElement_iface;
163 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
166 IUnknown_AddRef((IUnknown*)*ppv);
170 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
172 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
174 HTMLFrameBase_destructor(&This->framebase);
177 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
179 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
181 if(!This->framebase.content_window || !This->framebase.content_window->doc) {
186 *p = (IDispatch*)&This->framebase.content_window->doc->basedoc.IHTMLDocument2_iface;
187 IDispatch_AddRef(*p);
191 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
192 DWORD grfdex, DISPID *pid)
194 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
196 if(!This->framebase.content_window)
197 return DISP_E_UNKNOWNNAME;
199 return search_window_props(This->framebase.content_window, name, grfdex, pid);
202 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
203 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
205 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
207 if(!This->framebase.content_window) {
208 ERR("no content window to invoke on\n");
212 return IDispatchEx_InvokeEx(DISPATCHEX(This->framebase.content_window), id, lcid, flags, params, res, ei, caller);
215 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
217 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
219 return IHTMLFrameBase2_get_readyState(HTMLFRAMEBASE2(&This->framebase), p);
222 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
224 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
225 nsIDOMDocument *nsdoc;
229 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
230 if(NS_FAILED(nsres) || !nsdoc) {
231 ERR("GetContentDocument failed: %08x\n", nsres);
235 hres = set_frame_doc(&This->framebase, nsdoc);
236 nsIDOMDocument_Release(nsdoc);
240 #undef HTMLIFRAME_NODE_THIS
242 static const NodeImplVtbl HTMLIFrameImplVtbl = {
244 HTMLIFrame_destructor,
250 HTMLIFrame_get_document,
251 HTMLIFrame_get_readystate,
252 HTMLIFrame_get_dispid,
254 HTMLIFrame_bind_to_tree
257 static const tid_t HTMLIFrame_iface_tids[] = {
261 IHTMLIFrameElement_tid,
265 static dispex_static_data_t HTMLIFrame_dispex = {
269 HTMLIFrame_iface_tids
272 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
276 ret = heap_alloc_zero(sizeof(HTMLIFrame));
278 return E_OUTOFMEMORY;
280 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
281 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
283 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
285 *elem = &ret->framebase.element;