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