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);
36 const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
40 nsIDOMHTMLIFrameElement *nsiframe;
41 HTMLWindow *content_window;
44 #define HTMLFRAMEBASE2(x) (&(x)->lpIHTMLFrameBase2Vtbl)
46 static HRESULT create_content_window(HTMLIFrame *This, nsIDOMHTMLDocument *nsdoc, HTMLWindow **ret)
48 nsIDOMDocumentView *nsdocview;
49 nsIDOMAbstractView *nsview;
50 nsIDOMWindow *nswindow;
54 nsres = nsIDOMHTMLDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentView, (void**)&nsdocview);
55 if(NS_FAILED(nsres)) {
56 ERR("Could not get nsIDOMDocumentView: %08x\n", nsres);
60 nsres = nsIDOMDocumentView_GetDefaultView(nsdocview, &nsview);
61 nsIDOMDocumentView_Release(nsdocview);
62 if(NS_FAILED(nsres)) {
63 ERR("GetDefaultView failed: %08x\n", nsres);
67 nsres = nsIDOMAbstractView_QueryInterface(nsview, &IID_nsIDOMWindow, (void**)&nswindow);
68 nsIDOMAbstractView_Release(nsview);
69 if(NS_FAILED(nsres)) {
70 ERR("Coult not get nsIDOMWindow iface: %08x\n", nsres);
74 hres = HTMLWindow_Create(This->element.node.doc->basedoc.doc_obj, nswindow, ret);
76 nsIDOMWindow_Release(nswindow);
80 #define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLFrameBase2, iface)
82 static HRESULT WINAPI HTMLIFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
84 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
86 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
89 static ULONG WINAPI HTMLIFrameBase2_AddRef(IHTMLFrameBase2 *iface)
91 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
93 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
96 static ULONG WINAPI HTMLIFrameBase2_Release(IHTMLFrameBase2 *iface)
98 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
100 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
103 static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
105 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
106 FIXME("(%p)\n", This);
110 static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
111 LCID lcid, ITypeInfo **ppTInfo)
113 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
114 FIXME("(%p)\n", This);
118 static HRESULT WINAPI HTMLIFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
119 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
121 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
122 FIXME("(%p)\n", This);
126 static HRESULT WINAPI HTMLIFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
127 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
128 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
130 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
131 FIXME("(%p)\n", This);
135 static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
137 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
139 TRACE("(%p)->(%p)\n", This, p);
141 if(!This->content_window) {
142 nsIDOMHTMLDocument *nshtmldoc;
143 HTMLDocumentNode *content_doc;
144 nsIDOMDocument *nsdoc;
149 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->nsiframe, &nsdoc);
150 if(NS_FAILED(nsres)) {
151 ERR("GetContentDocument failed: %08x\n", nsres);
156 FIXME("NULL contentDocument\n");
160 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
161 nsIDOMDocument_Release(nsdoc);
162 if(NS_FAILED(nsres)) {
163 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
167 hres = create_content_window(This, nshtmldoc, &window);
169 nsIDOMHTMLDocument_Release(nshtmldoc);
173 hres = create_doc_from_nsdoc(nshtmldoc, This->element.node.doc->basedoc.doc_obj, window, &content_doc);
174 nsIDOMHTMLDocument_Release(nshtmldoc);
176 window_set_docnode(window, content_doc);
178 IHTMLWindow2_Release(HTMLWINDOW2(window));
179 htmldoc_release(&content_doc->basedoc);
183 This->content_window = window;
186 IHTMLWindow2_AddRef(HTMLWINDOW2(This->content_window));
187 *p = HTMLWINDOW2(This->content_window);
191 static HRESULT WINAPI HTMLIFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
193 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
194 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
198 static HRESULT WINAPI HTMLIFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
200 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
201 FIXME("(%p)->(%p)\n", This, p);
205 static HRESULT WINAPI HTMLIFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
207 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
208 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
212 static HRESULT WINAPI HTMLIFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
214 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
215 FIXME("(%p)->(%p)\n", This, p);
219 static HRESULT WINAPI HTMLIFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
221 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
222 FIXME("(%p)->(%p)\n", This, p);
226 static HRESULT WINAPI HTMLIFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
228 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
229 FIXME("(%p)->(%x)\n", This, v);
233 static HRESULT WINAPI HTMLIFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
235 HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface);
236 FIXME("(%p)->(%p)\n", This, p);
240 #undef HTMLFRAMEBASE2_THIS
242 static const IHTMLFrameBase2Vtbl HTMLIFrameBase2Vtbl = {
243 HTMLIFrameBase2_QueryInterface,
244 HTMLIFrameBase2_AddRef,
245 HTMLIFrameBase2_Release,
246 HTMLIFrameBase2_GetTypeInfoCount,
247 HTMLIFrameBase2_GetTypeInfo,
248 HTMLIFrameBase2_GetIDsOfNames,
249 HTMLIFrameBase2_Invoke,
250 HTMLIFrameBase2_get_contentWindow,
251 HTMLIFrameBase2_put_onload,
252 HTMLIFrameBase2_get_onload,
253 HTMLIFrameBase2_put_onreadystatechange,
254 HTMLIFrameBase2_get_onreadystatechange,
255 HTMLIFrameBase2_get_readyState,
256 HTMLIFrameBase2_put_allowTransparency,
257 HTMLIFrameBase2_get_allowTransparency
260 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, element.node, iface)
262 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
264 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
268 if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
269 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
270 *ppv = HTMLFRAMEBASE2(This);
272 return HTMLElement_QI(&This->element.node, riid, ppv);
275 IUnknown_AddRef((IUnknown*)*ppv);
279 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
281 HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface);
283 if(This->content_window)
284 IHTMLWindow2_Release(HTMLWINDOW2(This->content_window));
286 nsIDOMHTMLIFrameElement_Release(This->nsiframe);
288 HTMLElement_destructor(&This->element.node);
291 #undef HTMLIFRAME_NODE_THIS
293 static const NodeImplVtbl HTMLIFrameImplVtbl = {
295 HTMLIFrame_destructor
298 static const tid_t HTMLIFrame_iface_tids[] = {
308 static dispex_static_data_t HTMLIFrame_dispex = {
312 HTMLIFrame_iface_tids
315 HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement *nselem)
320 ret = heap_alloc_zero(sizeof(HTMLIFrame));
322 ret->lpIHTMLFrameBase2Vtbl = &HTMLIFrameBase2Vtbl;
323 ret->element.node.vtbl = &HTMLIFrameImplVtbl;
325 HTMLElement_Init(&ret->element, &HTMLIFrame_dispex);
327 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe);
329 ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres);
331 return &ret->element;