mstask: Implement GetTargetComputer.
[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     nsAString nsstr;
277     nsresult nsres;
278
279     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
280
281     if(V_VT(&v) != VT_BSTR) {
282         FIXME("unsupported %s\n", debugstr_variant(&v));
283         return E_NOTIMPL;
284     }
285
286     nsAString_InitDepend(&nsstr, V_BSTR(&v));
287     if(This->nsframe)
288         nsres = nsIDOMHTMLFrameElement_SetMarginWidth(This->nsframe, &nsstr);
289     else
290         nsres = nsIDOMHTMLIFrameElement_SetMarginWidth(This->nsiframe, &nsstr);
291     nsAString_Finish(&nsstr);
292     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
293 }
294
295 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
296 {
297     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
298     nsAString nsstr;
299     nsresult nsres;
300     HRESULT hres = S_OK;
301
302     TRACE("(%p)->(%p)\n", This, p);
303
304     nsAString_Init(&nsstr, NULL);
305     if(This->nsframe)
306         nsres = nsIDOMHTMLFrameElement_GetMarginWidth(This->nsframe, &nsstr);
307     else
308         nsres = nsIDOMHTMLIFrameElement_GetMarginWidth(This->nsiframe, &nsstr);
309     if(NS_SUCCEEDED(nsres)) {
310         const PRUnichar *str, *end;
311
312         nsAString_GetData(&nsstr, &str);
313
314         if(*str) {
315             BSTR ret;
316
317             end = strstrW(str, pxW);
318             if(!end)
319                 end = str+strlenW(str);
320             ret = SysAllocStringLen(str, end-str);
321             if(ret) {
322                 V_VT(p) = VT_BSTR;
323                 V_BSTR(p) = ret;
324             }else {
325                 hres = E_OUTOFMEMORY;
326             }
327         }else {
328             V_VT(p) = VT_BSTR;
329             V_BSTR(p) = NULL;
330         }
331     }else {
332         ERR("GetMarginWidth failed: %08x\n", nsres);
333         hres = E_FAIL;
334     }
335
336     nsAString_Finish(&nsstr);
337     return hres;
338 }
339
340 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
341 {
342     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
343     nsAString nsstr;
344     nsresult nsres;
345
346     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
347
348     if(V_VT(&v) != VT_BSTR) {
349         FIXME("unsupported %s\n", debugstr_variant(&v));
350         return E_NOTIMPL;
351     }
352
353     nsAString_InitDepend(&nsstr, V_BSTR(&v));
354     if(This->nsframe)
355         nsres = nsIDOMHTMLFrameElement_SetMarginHeight(This->nsframe, &nsstr);
356     else
357         nsres = nsIDOMHTMLIFrameElement_SetMarginHeight(This->nsiframe, &nsstr);
358     nsAString_Finish(&nsstr);
359     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
360 }
361
362 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
363 {
364     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
365     nsAString nsstr;
366     nsresult nsres;
367     HRESULT hres = S_OK;
368
369     TRACE("(%p)->(%p)\n", This, p);
370
371     nsAString_Init(&nsstr, NULL);
372     if(This->nsframe)
373         nsres = nsIDOMHTMLFrameElement_GetMarginHeight(This->nsframe, &nsstr);
374     else
375         nsres = nsIDOMHTMLIFrameElement_GetMarginHeight(This->nsiframe, &nsstr);
376     if(NS_SUCCEEDED(nsres)) {
377         const PRUnichar *str, *end;
378
379         nsAString_GetData(&nsstr, &str);
380
381         if(*str) {
382             BSTR ret;
383
384             end = strstrW(str, pxW);
385             if(!end)
386                 end = str+strlenW(str);
387             ret = SysAllocStringLen(str, end-str);
388             if(ret) {
389                 V_VT(p) = VT_BSTR;
390                 V_BSTR(p) = ret;
391             }else {
392                 hres = E_OUTOFMEMORY;
393             }
394         }else {
395             V_VT(p) = VT_BSTR;
396             V_BSTR(p) = NULL;
397         }
398     }else {
399         ERR("SetMarginHeight failed: %08x\n", nsres);
400         hres = E_FAIL;
401     }
402
403     nsAString_Finish(&nsstr);
404     return hres;
405 }
406
407 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
408 {
409     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
410     FIXME("(%p)->(%x)\n", This, v);
411     return E_NOTIMPL;
412 }
413
414 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
415 {
416     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
417     FIXME("(%p)->(%p)\n", This, p);
418     return E_NOTIMPL;
419 }
420
421 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
422 {
423     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
424     nsAString nsstr;
425     nsresult nsres;
426
427     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
428
429     if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
430         return E_INVALIDARG;
431
432     if(This->nsframe) {
433         nsAString_InitDepend(&nsstr, v);
434         nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
435     }else if(This->nsiframe) {
436         nsAString_InitDepend(&nsstr, v);
437         nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
438     }else {
439         ERR("No attached ns frame object\n");
440         return E_UNEXPECTED;
441     }
442     nsAString_Finish(&nsstr);
443
444     if(NS_FAILED(nsres)) {
445         ERR("SetScrolling failed: 0x%08x\n", nsres);
446         return E_FAIL;
447     }
448
449     return S_OK;
450 }
451
452 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
453 {
454     HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
455     nsAString nsstr;
456     const PRUnichar *strdata;
457     nsresult nsres;
458
459     TRACE("(%p)->(%p)\n", This, p);
460
461     if(This->nsframe) {
462         nsAString_Init(&nsstr, NULL);
463         nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
464     }else if(This->nsiframe) {
465         nsAString_Init(&nsstr, NULL);
466         nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
467     }else {
468         ERR("No attached ns frame object\n");
469         return E_UNEXPECTED;
470     }
471
472     if(NS_FAILED(nsres)) {
473         ERR("GetScrolling failed: 0x%08x\n", nsres);
474         nsAString_Finish(&nsstr);
475         return E_FAIL;
476     }
477
478     nsAString_GetData(&nsstr, &strdata);
479
480     if(*strdata)
481         *p = SysAllocString(strdata);
482     else
483         *p = SysAllocString(autoW);
484
485     nsAString_Finish(&nsstr);
486
487     return *p ? S_OK : E_OUTOFMEMORY;
488 }
489
490 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
491     HTMLFrameBase_QueryInterface,
492     HTMLFrameBase_AddRef,
493     HTMLFrameBase_Release,
494     HTMLFrameBase_GetTypeInfoCount,
495     HTMLFrameBase_GetTypeInfo,
496     HTMLFrameBase_GetIDsOfNames,
497     HTMLFrameBase_Invoke,
498     HTMLFrameBase_put_src,
499     HTMLFrameBase_get_src,
500     HTMLFrameBase_put_name,
501     HTMLFrameBase_get_name,
502     HTMLFrameBase_put_border,
503     HTMLFrameBase_get_border,
504     HTMLFrameBase_put_frameBorder,
505     HTMLFrameBase_get_frameBorder,
506     HTMLFrameBase_put_frameSpacing,
507     HTMLFrameBase_get_frameSpacing,
508     HTMLFrameBase_put_marginWidth,
509     HTMLFrameBase_get_marginWidth,
510     HTMLFrameBase_put_marginHeight,
511     HTMLFrameBase_get_marginHeight,
512     HTMLFrameBase_put_noResize,
513     HTMLFrameBase_get_noResize,
514     HTMLFrameBase_put_scrolling,
515     HTMLFrameBase_get_scrolling
516 };
517
518 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
519 {
520     return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
521 }
522
523 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
524 {
525     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
526
527     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
528 }
529
530 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
531 {
532     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
533
534     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
535 }
536
537 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
538 {
539     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
540
541     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
542 }
543
544 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
545 {
546     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
547     FIXME("(%p)\n", This);
548     return E_NOTIMPL;
549 }
550
551 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
552         LCID lcid, ITypeInfo **ppTInfo)
553 {
554     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
555     FIXME("(%p)\n", This);
556     return E_NOTIMPL;
557 }
558
559 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
560         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
561 {
562     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
563     FIXME("(%p)\n", This);
564     return E_NOTIMPL;
565 }
566
567 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
568         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
569         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
570 {
571     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
572     FIXME("(%p)\n", This);
573     return E_NOTIMPL;
574 }
575
576 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
577 {
578     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
579
580     TRACE("(%p)->(%p)\n", This, p);
581
582     if(This->content_window) {
583         IHTMLWindow2_AddRef(&This->content_window->base.IHTMLWindow2_iface);
584         *p = &This->content_window->base.IHTMLWindow2_iface;
585     }else {
586         WARN("NULL content window\n");
587         *p = NULL;
588     }
589     return S_OK;
590 }
591
592 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
593 {
594     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
595     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
596     return E_NOTIMPL;
597 }
598
599 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
600 {
601     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
602     FIXME("(%p)->(%p)\n", This, p);
603     return E_NOTIMPL;
604 }
605
606 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
607 {
608     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
609     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
610     return E_NOTIMPL;
611 }
612
613 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
614 {
615     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
616     FIXME("(%p)->(%p)\n", This, p);
617     return E_NOTIMPL;
618 }
619
620 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
621 {
622     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
623
624     TRACE("(%p)->(%p)\n", This, p);
625
626     if(!This->content_window || !This->content_window->base.inner_window->doc) {
627         FIXME("no document associated\n");
628         return E_FAIL;
629     }
630
631     return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface, p);
632 }
633
634 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
635 {
636     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
637     FIXME("(%p)->(%x)\n", This, v);
638     return E_NOTIMPL;
639 }
640
641 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
642 {
643     HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
644     FIXME("(%p)->(%p)\n", This, p);
645     return E_NOTIMPL;
646 }
647
648 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
649     HTMLFrameBase2_QueryInterface,
650     HTMLFrameBase2_AddRef,
651     HTMLFrameBase2_Release,
652     HTMLFrameBase2_GetTypeInfoCount,
653     HTMLFrameBase2_GetTypeInfo,
654     HTMLFrameBase2_GetIDsOfNames,
655     HTMLFrameBase2_Invoke,
656     HTMLFrameBase2_get_contentWindow,
657     HTMLFrameBase2_put_onload,
658     HTMLFrameBase2_get_onload,
659     HTMLFrameBase2_put_onreadystatechange,
660     HTMLFrameBase2_get_onreadystatechange,
661     HTMLFrameBase2_get_readyState,
662     HTMLFrameBase2_put_allowTransparency,
663     HTMLFrameBase2_get_allowTransparency
664 };
665
666 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
667 {
668     if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
669         TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
670         *ppv = &This->IHTMLFrameBase_iface;
671     }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
672         TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
673         *ppv = &This->IHTMLFrameBase2_iface;
674     }else {
675         return HTMLElement_QI(&This->element.node, riid, ppv);
676     }
677
678     IUnknown_AddRef((IUnknown*)*ppv);
679     return S_OK;
680 }
681
682 void HTMLFrameBase_destructor(HTMLFrameBase *This)
683 {
684     if(This->content_window)
685         This->content_window->frame_element = NULL;
686
687     HTMLElement_destructor(&This->element.node);
688 }
689
690 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
691         dispex_static_data_t *dispex_data)
692 {
693     nsresult nsres;
694
695     This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
696     This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
697
698     HTMLElement_Init(&This->element, doc, nselem, dispex_data);
699
700     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
701     if(NS_FAILED(nsres)) {
702         This->nsframe = NULL;
703         nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
704         assert(nsres == NS_OK && (nsIDOMNode*)This->nsiframe == This->element.node.nsnode);
705     }else {
706         assert((nsIDOMNode*)This->nsframe == This->element.node.nsnode);
707         This->nsiframe = NULL;
708     }
709
710     /* Share the reference with nsnode */
711     nsIDOMNode_Release(This->element.node.nsnode);
712 }