mshtml: HTMLWindow_item code clean up.
[wine] / dlls / mshtml / htmlframebase.c
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 static const WCHAR autoW[] = {'a','u','t','o',0};
35 static const WCHAR yesW[] = {'y','e','s',0};
36 static const WCHAR noW[] = {'n','o',0};
37
38 HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
39 {
40     nsIDOMWindow *nswindow;
41     HTMLWindow *window;
42     nsresult nsres;
43     HRESULT hres = S_OK;
44
45     if(frame->content_window)
46         return S_OK;
47
48     nsres = nsIDOMDocument_GetDefaultView(nsdoc, &nswindow);
49     if(NS_FAILED(nsres) || !nswindow)
50         return E_FAIL;
51
52     window = nswindow_to_window(nswindow);
53     if(!window)
54         hres = HTMLWindow_Create(frame->element.node.doc->basedoc.doc_obj, nswindow,
55                 frame->element.node.doc->basedoc.window, &window);
56     nsIDOMWindow_Release(nswindow);
57     if(FAILED(hres))
58         return hres;
59
60     frame->content_window = window;
61     window->frame_element = frame;
62     return S_OK;
63 }
64
65 static inline HTMLFrameBase *impl_from_IHTMLFrameBase(IHTMLFrameBase *iface)
66 {
67     return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase_iface);
68 }
69
70 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
71 {
72     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
73
74     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
75 }
76
77 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
78 {
79     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
80
81     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
82 }
83
84 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
85 {
86     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
87
88     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
89 }
90
91 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
92 {
93     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
94
95     return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
96 }
97
98 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
99         LCID lcid, ITypeInfo **ppTInfo)
100 {
101     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
102
103     return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
104             ppTInfo);
105 }
106
107 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
108         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
109 {
110     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
111
112     return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
113             cNames, lcid, rgDispId);
114 }
115
116 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
117         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
118         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
119 {
120     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
121
122     return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
123             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
124 }
125
126 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
127 {
128     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
129
130     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
131
132     if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
133         FIXME("detached element\n");
134         return E_FAIL;
135     }
136
137     return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
138 }
139
140 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
141 {
142     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
143     FIXME("(%p)->(%p)\n", This, p);
144     return E_NOTIMPL;
145 }
146
147 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
148 {
149     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
150     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
151     return E_NOTIMPL;
152 }
153
154 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
155 {
156     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
157     nsAString nsstr;
158     const PRUnichar *strdata;
159     nsresult nsres;
160
161     TRACE("(%p)->(%p)\n", This, p);
162
163     if(This->nsframe) {
164         nsAString_Init(&nsstr, NULL);
165         nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
166     }else if(This->nsiframe) {
167         nsAString_Init(&nsstr, NULL);
168         nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
169     }else {
170         ERR("No attached ns frame object\n");
171         return E_UNEXPECTED;
172     }
173
174     if(NS_FAILED(nsres)) {
175         ERR("GetName failed: 0x%08x\n", nsres);
176         nsAString_Finish(&nsstr);
177         return E_FAIL;
178     }
179
180     nsAString_GetData(&nsstr, &strdata);
181     if(*strdata) {
182         *p = SysAllocString(strdata);
183         if(!*p) {
184             nsAString_Finish(&nsstr);
185             return E_OUTOFMEMORY;
186         }
187     }else
188         *p = NULL;
189
190     nsAString_Finish(&nsstr);
191
192     return S_OK;
193 }
194
195 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
196 {
197     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
198     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
199     return E_NOTIMPL;
200 }
201
202 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
203 {
204     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
205     FIXME("(%p)->(%p)\n", This, p);
206     return E_NOTIMPL;
207 }
208
209 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
210 {
211     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
212     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
217 {
218     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
219     FIXME("(%p)->(%p)\n", This, p);
220     return E_NOTIMPL;
221 }
222
223 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
224 {
225     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
226     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
227     return E_NOTIMPL;
228 }
229
230 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
231 {
232     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
233     FIXME("(%p)->(%p)\n", This, p);
234     return E_NOTIMPL;
235 }
236
237 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
238 {
239     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
240     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
241     return E_NOTIMPL;
242 }
243
244 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
245 {
246     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
247     FIXME("(%p)->(%p)\n", This, p);
248     return E_NOTIMPL;
249 }
250
251 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
252 {
253     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
254     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
255     return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
259 {
260     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
261     FIXME("(%p)->(%p)\n", This, p);
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
266 {
267     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
268     FIXME("(%p)->(%x)\n", This, v);
269     return E_NOTIMPL;
270 }
271
272 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
273 {
274     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
275     FIXME("(%p)->(%p)\n", This, p);
276     return E_NOTIMPL;
277 }
278
279 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
280 {
281     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
282     nsAString nsstr;
283     nsresult nsres;
284
285     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
286
287     if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
288         return E_INVALIDARG;
289
290     if(This->nsframe) {
291         nsAString_InitDepend(&nsstr, v);
292         nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
293     }else if(This->nsiframe) {
294         nsAString_InitDepend(&nsstr, v);
295         nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
296     }else {
297         ERR("No attached ns frame object\n");
298         return E_UNEXPECTED;
299     }
300     nsAString_Finish(&nsstr);
301
302     if(NS_FAILED(nsres)) {
303         ERR("SetScrolling failed: 0x%08x\n", nsres);
304         return E_FAIL;
305     }
306
307     return S_OK;
308 }
309
310 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
311 {
312     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
313     nsAString nsstr;
314     const PRUnichar *strdata;
315     nsresult nsres;
316
317     TRACE("(%p)->(%p)\n", This, p);
318
319     if(This->nsframe) {
320         nsAString_Init(&nsstr, NULL);
321         nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
322     }else if(This->nsiframe) {
323         nsAString_Init(&nsstr, NULL);
324         nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
325     }else {
326         ERR("No attached ns frame object\n");
327         return E_UNEXPECTED;
328     }
329
330     if(NS_FAILED(nsres)) {
331         ERR("GetScrolling failed: 0x%08x\n", nsres);
332         nsAString_Finish(&nsstr);
333         return E_FAIL;
334     }
335
336     nsAString_GetData(&nsstr, &strdata);
337
338     if(*strdata)
339         *p = SysAllocString(strdata);
340     else
341         *p = SysAllocString(autoW);
342
343     nsAString_Finish(&nsstr);
344
345     return *p ? S_OK : E_OUTOFMEMORY;
346 }
347
348 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
349     HTMLFrameBase_QueryInterface,
350     HTMLFrameBase_AddRef,
351     HTMLFrameBase_Release,
352     HTMLFrameBase_GetTypeInfoCount,
353     HTMLFrameBase_GetTypeInfo,
354     HTMLFrameBase_GetIDsOfNames,
355     HTMLFrameBase_Invoke,
356     HTMLFrameBase_put_src,
357     HTMLFrameBase_get_src,
358     HTMLFrameBase_put_name,
359     HTMLFrameBase_get_name,
360     HTMLFrameBase_put_border,
361     HTMLFrameBase_get_border,
362     HTMLFrameBase_put_frameBorder,
363     HTMLFrameBase_get_frameBorder,
364     HTMLFrameBase_put_frameSpacing,
365     HTMLFrameBase_get_frameSpacing,
366     HTMLFrameBase_put_marginWidth,
367     HTMLFrameBase_get_marginWidth,
368     HTMLFrameBase_put_marginHeight,
369     HTMLFrameBase_get_marginHeight,
370     HTMLFrameBase_put_noResize,
371     HTMLFrameBase_get_noResize,
372     HTMLFrameBase_put_scrolling,
373     HTMLFrameBase_get_scrolling
374 };
375
376 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
377 {
378     return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
379 }
380
381 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
382 {
383     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
384
385     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
386 }
387
388 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
389 {
390     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
391
392     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
393 }
394
395 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
396 {
397     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
398
399     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
400 }
401
402 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
403 {
404     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
405     FIXME("(%p)\n", This);
406     return E_NOTIMPL;
407 }
408
409 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
410         LCID lcid, ITypeInfo **ppTInfo)
411 {
412     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
413     FIXME("(%p)\n", This);
414     return E_NOTIMPL;
415 }
416
417 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
418         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
419 {
420     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
421     FIXME("(%p)\n", This);
422     return E_NOTIMPL;
423 }
424
425 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
426         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
427         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
428 {
429     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
430     FIXME("(%p)\n", This);
431     return E_NOTIMPL;
432 }
433
434 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
435 {
436     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
437
438     TRACE("(%p)->(%p)\n", This, p);
439
440     if(This->content_window) {
441         IHTMLWindow2_AddRef(&This->content_window->IHTMLWindow2_iface);
442         *p = &This->content_window->IHTMLWindow2_iface;
443     }else {
444         WARN("NULL content window\n");
445         *p = NULL;
446     }
447     return S_OK;
448 }
449
450 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
451 {
452     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
453     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
454     return E_NOTIMPL;
455 }
456
457 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
458 {
459     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
460     FIXME("(%p)->(%p)\n", This, p);
461     return E_NOTIMPL;
462 }
463
464 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
465 {
466     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
467     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
468     return E_NOTIMPL;
469 }
470
471 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
472 {
473     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
474     FIXME("(%p)->(%p)\n", This, p);
475     return E_NOTIMPL;
476 }
477
478 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
479 {
480     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
481
482     TRACE("(%p)->(%p)\n", This, p);
483
484     if(!This->content_window || !This->content_window->doc) {
485         FIXME("no document associated\n");
486         return E_FAIL;
487     }
488
489     return IHTMLDocument2_get_readyState(&This->content_window->doc->basedoc.IHTMLDocument2_iface, p);
490 }
491
492 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
493 {
494     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
495     FIXME("(%p)->(%x)\n", This, v);
496     return E_NOTIMPL;
497 }
498
499 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
500 {
501     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
502     FIXME("(%p)->(%p)\n", This, p);
503     return E_NOTIMPL;
504 }
505
506 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
507     HTMLFrameBase2_QueryInterface,
508     HTMLFrameBase2_AddRef,
509     HTMLFrameBase2_Release,
510     HTMLFrameBase2_GetTypeInfoCount,
511     HTMLFrameBase2_GetTypeInfo,
512     HTMLFrameBase2_GetIDsOfNames,
513     HTMLFrameBase2_Invoke,
514     HTMLFrameBase2_get_contentWindow,
515     HTMLFrameBase2_put_onload,
516     HTMLFrameBase2_get_onload,
517     HTMLFrameBase2_put_onreadystatechange,
518     HTMLFrameBase2_get_onreadystatechange,
519     HTMLFrameBase2_get_readyState,
520     HTMLFrameBase2_put_allowTransparency,
521     HTMLFrameBase2_get_allowTransparency
522 };
523
524 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
525 {
526     if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
527         TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
528         *ppv = &This->IHTMLFrameBase_iface;
529     }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
530         TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
531         *ppv = &This->IHTMLFrameBase2_iface;
532     }else {
533         return HTMLElement_QI(&This->element.node, riid, ppv);
534     }
535
536     IUnknown_AddRef((IUnknown*)*ppv);
537     return S_OK;
538 }
539
540 void HTMLFrameBase_destructor(HTMLFrameBase *This)
541 {
542     if(This->content_window)
543         This->content_window->frame_element = NULL;
544
545     if(This->nsframe)
546         nsIDOMHTMLFrameElement_Release(This->nsframe);
547     if(This->nsiframe)
548         nsIDOMHTMLIFrameElement_Release(This->nsiframe);
549
550     HTMLElement_destructor(&This->element.node);
551 }
552
553 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
554         dispex_static_data_t *dispex_data)
555 {
556     nsresult nsres;
557
558     This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
559     This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
560
561     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
562
563     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
564     if(NS_FAILED(nsres)) {
565         nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
566         if(NS_FAILED(nsres))
567             ERR("Could not get nsIDOMHTML[I]Frame interface\n");
568     }else
569         This->nsiframe = NULL;
570 }