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