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