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