Commit | Line | Data |
---|---|---|
2e52c61c JC |
1 | /* |
2 | * Copyright 2008 Jacek Caban for CodeWeavers | |
3 | * | |
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. | |
8 | * | |
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. | |
13 | * | |
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 | |
17 | */ | |
18 | ||
19 | #include <stdarg.h> | |
20 | ||
21 | #define COBJMACROS | |
22 | ||
23 | #include "windef.h" | |
24 | #include "winbase.h" | |
25 | #include "winuser.h" | |
26 | #include "ole2.h" | |
27 | ||
28 | #include "mshtml_private.h" | |
29 | ||
30 | #include "wine/debug.h" | |
31 | ||
32 | WINE_DEFAULT_DEBUG_CHANNEL(mshtml); | |
33 | ||
34 | typedef struct { | |
35 | HTMLElement element; | |
36 | const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl; | |
37 | ||
38 | LONG ref; | |
39 | ||
40 | nsIDOMHTMLIFrameElement *nsiframe; | |
f27386fb | 41 | HTMLDocument *content_doc; |
2e52c61c JC |
42 | } HTMLIFrame; |
43 | ||
44 | #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl) | |
45 | ||
46 | #define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLIFrame, IHTMLFrameBase2, iface) | |
47 | ||
48 | static HRESULT WINAPI HTMLIFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv) | |
49 | { | |
50 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
51 | ||
52 | return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv); | |
53 | } | |
54 | ||
55 | static ULONG WINAPI HTMLIFrameBase2_AddRef(IHTMLFrameBase2 *iface) | |
56 | { | |
57 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
58 | ||
59 | return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node)); | |
60 | } | |
61 | ||
62 | static ULONG WINAPI HTMLIFrameBase2_Release(IHTMLFrameBase2 *iface) | |
63 | { | |
64 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
65 | ||
66 | return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node)); | |
67 | } | |
68 | ||
69 | static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo) | |
70 | { | |
71 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
72 | FIXME("(%p)\n", This); | |
73 | return E_NOTIMPL; | |
74 | } | |
75 | ||
76 | static HRESULT WINAPI HTMLIFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo, | |
77 | LCID lcid, ITypeInfo **ppTInfo) | |
78 | { | |
79 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
80 | FIXME("(%p)\n", This); | |
81 | return E_NOTIMPL; | |
82 | } | |
83 | ||
84 | static HRESULT WINAPI HTMLIFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid, | |
85 | LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) | |
86 | { | |
87 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
88 | FIXME("(%p)\n", This); | |
89 | return E_NOTIMPL; | |
90 | } | |
91 | ||
92 | static HRESULT WINAPI HTMLIFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember, | |
93 | REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, | |
94 | VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) | |
95 | { | |
96 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
97 | FIXME("(%p)\n", This); | |
98 | return E_NOTIMPL; | |
99 | } | |
100 | ||
101 | static HRESULT WINAPI HTMLIFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p) | |
102 | { | |
103 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
f27386fb JC |
104 | |
105 | TRACE("(%p)->(%p)\n", This, p); | |
106 | ||
107 | if(!This->content_doc) { | |
108 | nsIDOMHTMLDocument *nshtmldoc; | |
109 | nsIDOMDocument *nsdoc; | |
110 | nsresult nsres; | |
111 | HRESULT hres; | |
112 | ||
113 | nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->nsiframe, &nsdoc); | |
114 | if(NS_FAILED(nsres)) { | |
115 | ERR("GetContentDocument failed: %08x\n", nsres); | |
116 | return E_FAIL; | |
117 | } | |
118 | ||
119 | if(!nsdoc) { | |
120 | FIXME("NULL contentDocument\n"); | |
121 | return E_FAIL; | |
122 | } | |
123 | ||
124 | nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc); | |
125 | nsIDOMDocument_Release(nsdoc); | |
126 | if(NS_FAILED(nsres)) { | |
127 | ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres); | |
128 | return E_FAIL; | |
129 | } | |
130 | ||
131 | hres = create_doc_from_nsdoc(nshtmldoc, &This->content_doc); | |
132 | nsIDOMHTMLDocument_Release(nshtmldoc); | |
133 | if(FAILED(hres)) | |
134 | return hres; | |
135 | } | |
136 | ||
137 | return IHTMLDocument2_get_parentWindow(HTMLDOC(This->content_doc), p); | |
2e52c61c JC |
138 | } |
139 | ||
140 | static HRESULT WINAPI HTMLIFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v) | |
141 | { | |
142 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
143 | FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); | |
144 | return E_NOTIMPL; | |
145 | } | |
146 | ||
147 | static HRESULT WINAPI HTMLIFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p) | |
148 | { | |
149 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
150 | FIXME("(%p)->(%p)\n", This, p); | |
151 | return E_NOTIMPL; | |
152 | } | |
153 | ||
154 | static HRESULT WINAPI HTMLIFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v) | |
155 | { | |
156 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
157 | FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); | |
158 | return E_NOTIMPL; | |
159 | } | |
160 | ||
161 | static HRESULT WINAPI HTMLIFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p) | |
162 | { | |
163 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
164 | FIXME("(%p)->(%p)\n", This, p); | |
165 | return E_NOTIMPL; | |
166 | } | |
167 | ||
168 | static HRESULT WINAPI HTMLIFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p) | |
169 | { | |
170 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
171 | FIXME("(%p)->(%p)\n", This, p); | |
172 | return E_NOTIMPL; | |
173 | } | |
174 | ||
175 | static HRESULT WINAPI HTMLIFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v) | |
176 | { | |
177 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
178 | FIXME("(%p)->(%x)\n", This, v); | |
179 | return E_NOTIMPL; | |
180 | } | |
181 | ||
182 | static HRESULT WINAPI HTMLIFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p) | |
183 | { | |
184 | HTMLIFrame *This = HTMLFRAMEBASE2_THIS(iface); | |
185 | FIXME("(%p)->(%p)\n", This, p); | |
186 | return E_NOTIMPL; | |
187 | } | |
188 | ||
189 | #undef HTMLFRAMEBASE2_THIS | |
190 | ||
191 | static const IHTMLFrameBase2Vtbl HTMLIFrameBase2Vtbl = { | |
192 | HTMLIFrameBase2_QueryInterface, | |
193 | HTMLIFrameBase2_AddRef, | |
194 | HTMLIFrameBase2_Release, | |
195 | HTMLIFrameBase2_GetTypeInfoCount, | |
196 | HTMLIFrameBase2_GetTypeInfo, | |
197 | HTMLIFrameBase2_GetIDsOfNames, | |
198 | HTMLIFrameBase2_Invoke, | |
199 | HTMLIFrameBase2_get_contentWindow, | |
200 | HTMLIFrameBase2_put_onload, | |
201 | HTMLIFrameBase2_get_onload, | |
202 | HTMLIFrameBase2_put_onreadystatechange, | |
203 | HTMLIFrameBase2_get_onreadystatechange, | |
204 | HTMLIFrameBase2_get_readyState, | |
205 | HTMLIFrameBase2_put_allowTransparency, | |
206 | HTMLIFrameBase2_get_allowTransparency | |
207 | }; | |
208 | ||
209 | #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, element.node, iface) | |
210 | ||
211 | static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) | |
212 | { | |
213 | HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface); | |
214 | ||
215 | *ppv = NULL; | |
216 | ||
217 | if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) { | |
218 | TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv); | |
219 | *ppv = HTMLFRAMEBASE2(This); | |
220 | }else { | |
221 | return HTMLElement_QI(&This->element.node, riid, ppv); | |
222 | } | |
223 | ||
224 | IUnknown_AddRef((IUnknown*)*ppv); | |
225 | return S_OK; | |
226 | } | |
227 | ||
228 | static void HTMLIFrame_destructor(HTMLDOMNode *iface) | |
229 | { | |
230 | HTMLIFrame *This = HTMLIFRAME_NODE_THIS(iface); | |
231 | ||
f27386fb JC |
232 | if(This->content_doc) |
233 | IHTMLDocument2_Release(HTMLDOC(This->content_doc)); | |
2e52c61c JC |
234 | if(This->nsiframe) |
235 | nsIDOMHTMLIFrameElement_Release(This->nsiframe); | |
236 | ||
237 | HTMLElement_destructor(&This->element.node); | |
238 | } | |
239 | ||
240 | #undef HTMLIFRAME_NODE_THIS | |
241 | ||
242 | static const NodeImplVtbl HTMLIFrameImplVtbl = { | |
243 | HTMLIFrame_QI, | |
244 | HTMLIFrame_destructor | |
245 | }; | |
246 | ||
712c4d9a JC |
247 | static const tid_t HTMLIFrame_iface_tids[] = { |
248 | IHTMLDOMNode_tid, | |
249 | IHTMLDOMNode2_tid, | |
250 | IHTMLElement_tid, | |
251 | IHTMLElement2_tid, | |
252 | IHTMLElement3_tid, | |
253 | IHTMLFrameBase2_tid, | |
254 | 0 | |
255 | }; | |
256 | ||
257 | static dispex_static_data_t HTMLIFrame_dispex = { | |
258 | NULL, | |
259 | DispHTMLIFrame_tid, | |
260 | NULL, | |
261 | HTMLIFrame_iface_tids | |
262 | }; | |
263 | ||
2e52c61c JC |
264 | HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement *nselem) |
265 | { | |
266 | HTMLIFrame *ret; | |
267 | nsresult nsres; | |
268 | ||
269 | ret = heap_alloc_zero(sizeof(HTMLIFrame)); | |
270 | ||
271 | ret->lpIHTMLFrameBase2Vtbl = &HTMLIFrameBase2Vtbl; | |
272 | ret->element.node.vtbl = &HTMLIFrameImplVtbl; | |
273 | ||
712c4d9a | 274 | init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLFRAMEBASE2(ret), &HTMLIFrame_dispex); |
2e52c61c JC |
275 | HTMLElement_Init(&ret->element); |
276 | ||
277 | nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe); | |
278 | if(NS_FAILED(nsres)) | |
279 | ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres); | |
280 | ||
281 | return &ret->element; | |
282 | } |