qcap: Implement a stubbed SmartTee filter.
[wine/multimedia.git] / dlls / mshtml / htmlframe.c
blobdde6e62a26db9a0822f515a6d678116d54059f41
1 /*
2 * Copyright 2010 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 IHTMLFrameElement3 IHTMLFrameElement3_iface;
37 } HTMLFrameElement;
39 static inline HTMLFrameElement *impl_from_IHTMLFrameElement3(IHTMLFrameElement3 *iface)
41 return CONTAINING_RECORD(iface, HTMLFrameElement, IHTMLFrameElement3_iface);
44 static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface,
45 REFIID riid, void **ppv)
47 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
49 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
52 static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface)
54 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
56 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
59 static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface)
61 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
63 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
66 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo)
68 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
69 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
70 pctinfo);
73 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo,
74 LCID lcid, ITypeInfo **ppTInfo)
76 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
77 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
78 lcid, ppTInfo);
81 static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid,
82 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
84 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
85 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
86 rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
94 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
95 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p)
100 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
101 IHTMLDocument2 *doc;
102 HRESULT hres;
104 TRACE("(%p)->(%p)\n", This, p);
106 if(!This->framebase.content_window) {
107 FIXME("NULL window\n");
108 return E_FAIL;
111 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
112 if(FAILED(hres))
113 return hres;
115 *p = doc ? (IDispatch*)doc : NULL;
116 return S_OK;
119 static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v)
121 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
122 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
123 return E_NOTIMPL;
126 static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p)
128 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
129 FIXME("(%p)->(%p)\n", This, p);
130 return E_NOTIMPL;
133 static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v)
135 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
136 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p)
142 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
143 FIXME("(%p)->(%p)\n", This, p);
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v)
149 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
150 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p)
156 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
157 FIXME("(%p)->(%p)\n", This, p);
158 return E_NOTIMPL;
161 static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = {
162 HTMLFrameElement3_QueryInterface,
163 HTMLFrameElement3_AddRef,
164 HTMLFrameElement3_Release,
165 HTMLFrameElement3_GetTypeInfoCount,
166 HTMLFrameElement3_GetTypeInfo,
167 HTMLFrameElement3_GetIDsOfNames,
168 HTMLFrameElement3_Invoke,
169 HTMLFrameElement3_get_contentDocument,
170 HTMLFrameElement3_put_src,
171 HTMLFrameElement3_get_src,
172 HTMLFrameElement3_put_longDesc,
173 HTMLFrameElement3_get_longDesc,
174 HTMLFrameElement3_put_frameBorder,
175 HTMLFrameElement3_get_frameBorder
178 static inline HTMLFrameElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
180 return CONTAINING_RECORD(iface, HTMLFrameElement, framebase.element.node);
183 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
185 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
187 if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) {
188 TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv);
189 *ppv = &This->IHTMLFrameElement3_iface;
190 }else {
191 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
194 IUnknown_AddRef((IUnknown*)*ppv);
195 return S_OK;
198 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
200 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
202 HTMLFrameBase_destructor(&This->framebase);
205 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
207 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
209 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
210 *p = NULL;
211 return S_OK;
214 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
215 IDispatch_AddRef(*p);
216 return S_OK;
219 static HRESULT HTMLFrameElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
221 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
223 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
226 static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
227 DWORD grfdex, DISPID *pid)
229 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
231 if(!This->framebase.content_window)
232 return DISP_E_UNKNOWNNAME;
234 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
237 static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
238 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
240 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
242 if(!This->framebase.content_window) {
243 ERR("no content window to invoke on\n");
244 return E_FAIL;
247 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
248 flags, params, res, ei, caller);
251 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
253 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
254 nsIDOMDocument *nsdoc;
255 nsresult nsres;
256 HRESULT hres;
258 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
259 if(NS_FAILED(nsres) || !nsdoc) {
260 ERR("GetContentDocument failed: %08x\n", nsres);
261 return E_FAIL;
264 hres = set_frame_doc(&This->framebase, nsdoc);
265 nsIDOMDocument_Release(nsdoc);
266 return hres;
269 static void HTMLFrameElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
271 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
273 if(This->framebase.nsframe)
274 note_cc_edge((nsISupports*)This->framebase.nsframe, "This->nsframe", cb);
277 static void HTMLFrameElement_unlink(HTMLDOMNode *iface)
279 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
281 if(This->framebase.nsframe) {
282 nsIDOMHTMLFrameElement *nsframe = This->framebase.nsframe;
284 This->framebase.nsframe = NULL;
285 nsIDOMHTMLFrameElement_Release(nsframe);
289 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
290 HTMLFrameElement_QI,
291 HTMLFrameElement_destructor,
292 HTMLElement_cpc,
293 HTMLElement_clone,
294 HTMLElement_handle_event,
295 HTMLElement_get_attr_col,
296 NULL,
297 NULL,
298 NULL,
299 NULL,
300 HTMLFrameElement_get_document,
301 HTMLFrameElement_get_readystate,
302 HTMLFrameElement_get_dispid,
303 HTMLFrameElement_invoke,
304 HTMLFrameElement_bind_to_tree,
305 HTMLFrameElement_traverse,
306 HTMLFrameElement_unlink
309 static const tid_t HTMLFrameElement_iface_tids[] = {
310 HTMLELEMENT_TIDS,
311 IHTMLFrameBase_tid,
312 IHTMLFrameBase2_tid,
313 IHTMLFrameElement3_tid,
317 static dispex_static_data_t HTMLFrameElement_dispex = {
318 NULL,
319 DispHTMLFrameElement_tid,
320 NULL,
321 HTMLFrameElement_iface_tids
324 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
326 HTMLFrameElement *ret;
328 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
329 if(!ret)
330 return E_OUTOFMEMORY;
332 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
333 ret->IHTMLFrameElement3_iface.lpVtbl = &HTMLFrameElement3Vtbl;
335 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex);
337 *elem = &ret->framebase.element;
338 return S_OK;