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 const IHTMLFrameBase2Vtbl
*lpIHTMLFrameBase2Vtbl
;
40 nsIDOMHTMLIFrameElement
*nsiframe
;
43 #define HTMLFRAMEBASE2(x) (&(x)->lpIHTMLFrameBase2Vtbl)
45 #define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLFrameBase2, iface)
47 static HRESULT WINAPI
HTMLIFrameBase2_QueryInterface(IHTMLFrameBase2
*iface
, REFIID riid
, void **ppv
)
49 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->framebase
.element
.node
), riid
, ppv
);
54 static ULONG WINAPI
HTMLIFrameBase2_AddRef(IHTMLFrameBase2
*iface
)
56 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->framebase
.element
.node
));
61 static ULONG WINAPI
HTMLIFrameBase2_Release(IHTMLFrameBase2
*iface
)
63 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->framebase
.element
.node
));
68 static HRESULT WINAPI
HTMLIFrameBase2_GetTypeInfoCount(IHTMLFrameBase2
*iface
, UINT
*pctinfo
)
70 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
71 FIXME("(%p)\n", This
);
75 static HRESULT WINAPI
HTMLIFrameBase2_GetTypeInfo(IHTMLFrameBase2
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
79 FIXME("(%p)\n", This
);
83 static HRESULT WINAPI
HTMLIFrameBase2_GetIDsOfNames(IHTMLFrameBase2
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
86 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
87 FIXME("(%p)\n", This
);
91 static HRESULT WINAPI
HTMLIFrameBase2_Invoke(IHTMLFrameBase2
*iface
, DISPID dispIdMember
,
92 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
93 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
95 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
96 FIXME("(%p)\n", This
);
100 static HRESULT WINAPI
HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2
*iface
, IHTMLWindow2
**p
)
102 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
104 TRACE("(%p)->(%p)\n", This
, p
);
106 if(This
->framebase
.content_window
) {
107 IHTMLWindow2_AddRef(HTMLWINDOW2(This
->framebase
.content_window
));
108 *p
= HTMLWINDOW2(This
->framebase
.content_window
);
110 WARN("NULL content window\n");
116 static HRESULT WINAPI
HTMLIFrameBase2_put_onload(IHTMLFrameBase2
*iface
, VARIANT v
)
118 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
119 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
123 static HRESULT WINAPI
HTMLIFrameBase2_get_onload(IHTMLFrameBase2
*iface
, VARIANT
*p
)
125 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
126 FIXME("(%p)->(%p)\n", This
, p
);
130 static HRESULT WINAPI
HTMLIFrameBase2_put_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT v
)
132 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
133 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
137 static HRESULT WINAPI
HTMLIFrameBase2_get_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT
*p
)
139 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
140 FIXME("(%p)->(%p)\n", This
, p
);
144 static HRESULT WINAPI
HTMLIFrameBase2_get_readyState(IHTMLFrameBase2
*iface
, BSTR
*p
)
146 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
147 FIXME("(%p)->(%p)\n", This
, p
);
151 static HRESULT WINAPI
HTMLIFrameBase2_put_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL v
)
153 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
154 FIXME("(%p)->(%x)\n", This
, v
);
158 static HRESULT WINAPI
HTMLIFrameBase2_get_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL
*p
)
160 HTMLIFrame
*This
= HTMLFRAMEBASE2_THIS(iface
);
161 FIXME("(%p)->(%p)\n", This
, p
);
165 #undef HTMLFRAMEBASE2_THIS
167 static const IHTMLFrameBase2Vtbl HTMLIFrameBase2Vtbl
= {
168 HTMLIFrameBase2_QueryInterface
,
169 HTMLIFrameBase2_AddRef
,
170 HTMLIFrameBase2_Release
,
171 HTMLIFrameBase2_GetTypeInfoCount
,
172 HTMLIFrameBase2_GetTypeInfo
,
173 HTMLIFrameBase2_GetIDsOfNames
,
174 HTMLIFrameBase2_Invoke
,
175 HTMLIFrameBase2_get_contentWindow
,
176 HTMLIFrameBase2_put_onload
,
177 HTMLIFrameBase2_get_onload
,
178 HTMLIFrameBase2_put_onreadystatechange
,
179 HTMLIFrameBase2_get_onreadystatechange
,
180 HTMLIFrameBase2_get_readyState
,
181 HTMLIFrameBase2_put_allowTransparency
,
182 HTMLIFrameBase2_get_allowTransparency
185 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
187 static HRESULT
HTMLIFrame_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
189 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
193 if(IsEqualGUID(&IID_IHTMLFrameBase2
, riid
)) {
194 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This
, ppv
);
195 *ppv
= HTMLFRAMEBASE2(This
);
197 return HTMLFrameBase_QI(&This
->framebase
, riid
, ppv
);
200 IUnknown_AddRef((IUnknown
*)*ppv
);
204 static void HTMLIFrame_destructor(HTMLDOMNode
*iface
)
206 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
209 nsIDOMHTMLIFrameElement_Release(This
->nsiframe
);
211 HTMLFrameBase_destructor(&This
->framebase
);
214 #undef HTMLIFRAME_NODE_THIS
216 static const NodeImplVtbl HTMLIFrameImplVtbl
= {
218 HTMLIFrame_destructor
221 static const tid_t HTMLIFrame_iface_tids
[] = {
232 static dispex_static_data_t HTMLIFrame_dispex
= {
236 HTMLIFrame_iface_tids
239 static HTMLWindow
*get_content_window(nsIDOMHTMLIFrameElement
*nsiframe
)
242 nsIDOMWindow
*nswindow
;
243 nsIDOMDocument
*nsdoc
;
246 nsres
= nsIDOMHTMLIFrameElement_GetContentDocument(nsiframe
, &nsdoc
);
247 if(NS_FAILED(nsres
)) {
248 ERR("GetContentDocument failed: %08x\n", nsres
);
253 FIXME("NULL contentDocument\n");
257 nswindow
= get_nsdoc_window(nsdoc
);
258 nsIDOMDocument_Release(nsdoc
);
262 ret
= nswindow_to_window(nswindow
);
263 nsIDOMWindow_Release(nswindow
);
265 ERR("Could not get window object\n");
270 HTMLElement
*HTMLIFrame_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLWindow
*content_window
)
275 ret
= heap_alloc_zero(sizeof(HTMLIFrame
));
277 ret
->lpIHTMLFrameBase2Vtbl
= &HTMLIFrameBase2Vtbl
;
278 ret
->framebase
.element
.node
.vtbl
= &HTMLIFrameImplVtbl
;
280 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLIFrameElement
, (void**)&ret
->nsiframe
);
282 ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres
);
285 content_window
= get_content_window(ret
->nsiframe
);
287 HTMLFrameBase_Init(&ret
->framebase
, doc
, nselem
, content_window
, &HTMLIFrame_dispex
);
289 return &ret
->framebase
.element
;