mshtml: Wine Gecko 1.5 release.
[wine/multimedia.git] / dlls / mshtml / htmliframe.c
blob3acab1eaa29bc3552e75aebeaf31fbfcb49423c3
1 /*
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "mshtml_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 HTMLFrameBase framebase;
36 IHTMLIFrameElement IHTMLIFrameElement_iface;
37 } HTMLIFrame;
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,
70 pctinfo);
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,
78 lcid, ppTInfo);
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);
102 return E_NOTIMPL;
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);
109 return E_NOTIMPL;
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);
116 return E_NOTIMPL;
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);
123 return E_NOTIMPL;
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));
130 return E_NOTIMPL;
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);
137 return E_NOTIMPL;
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;
168 }else {
169 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
172 IUnknown_AddRef((IUnknown*)*ppv);
173 return S_OK;
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) {
188 *p = NULL;
189 return S_OK;
192 *p = (IDispatch*)&This->framebase.content_window->doc->basedoc.IHTMLDocument2_iface;
193 IDispatch_AddRef(*p);
194 return S_OK;
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");
215 return E_FAIL;
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;
233 nsresult nsres;
234 HRESULT hres;
236 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
237 if(NS_FAILED(nsres) || !nsdoc) {
238 ERR("GetContentDocument failed: %08x\n", nsres);
239 return E_FAIL;
242 hres = set_frame_doc(&This->framebase, nsdoc);
243 nsIDOMDocument_Release(nsdoc);
244 return hres;
247 static const NodeImplVtbl HTMLIFrameImplVtbl = {
248 HTMLIFrame_QI,
249 HTMLIFrame_destructor,
250 HTMLElement_clone,
251 HTMLElement_get_attr_col,
252 NULL,
253 NULL,
254 NULL,
255 NULL,
256 NULL,
257 HTMLIFrame_get_document,
258 HTMLIFrame_get_readystate,
259 HTMLIFrame_get_dispid,
260 HTMLIFrame_invoke,
261 HTMLIFrame_bind_to_tree
264 static const tid_t HTMLIFrame_iface_tids[] = {
265 HTMLELEMENT_TIDS,
266 IHTMLFrameBase_tid,
267 IHTMLFrameBase2_tid,
268 IHTMLIFrameElement_tid,
272 static dispex_static_data_t HTMLIFrame_dispex = {
273 NULL,
274 DispHTMLIFrame_tid,
275 NULL,
276 HTMLIFrame_iface_tids
279 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
281 HTMLIFrame *ret;
283 ret = heap_alloc_zero(sizeof(HTMLIFrame));
284 if(!ret)
285 return E_OUTOFMEMORY;
287 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
288 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
290 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
292 *elem = &ret->framebase.element;
293 return S_OK;