push 38a8c0aff9170390b5a3ded41e7cf5b02f3a73d8
[wine/hacks.git] / dlls / mshtml / htmlframebase.c
blob717429882c4beed313204e673fd304ba4f9e4969
1 /*
2 * Copyright 2008 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "mshtml_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
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};
38 HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
40 nsIDOMWindow *nswindow;
41 HTMLWindow *window;
42 HRESULT hres = S_OK;
44 if(frame->content_window)
45 return S_OK;
47 nswindow = get_nsdoc_window(nsdoc);
48 if(!nswindow)
49 return E_FAIL;
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;
59 frame->content_window = window;
60 window->frame_element = frame;
61 return S_OK;
64 #define HTMLFRAMEBASE_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase, iface)
66 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
68 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
70 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
73 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
75 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
77 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
80 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
82 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
84 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
87 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
89 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
91 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
94 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
95 LCID lcid, ITypeInfo **ppTInfo)
97 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
99 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
102 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
103 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
105 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
107 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames,
108 cNames, lcid, rgDispId);
111 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
112 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
113 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
115 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
117 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid,
118 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
121 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
123 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
125 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
127 if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
128 FIXME("detached element\n");
129 return E_FAIL;
132 return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
135 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
137 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
138 FIXME("(%p)->(%p)\n", This, p);
139 return E_NOTIMPL;
142 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
144 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
145 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
146 return E_NOTIMPL;
149 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
151 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
152 nsAString nsstr;
153 const PRUnichar *strdata;
154 nsresult nsres;
156 TRACE("(%p)->(%p)\n", This, p);
158 if(This->nsframe) {
159 nsAString_Init(&nsstr, NULL);
160 nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
161 }else if(This->nsiframe) {
162 nsAString_Init(&nsstr, NULL);
163 nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
164 }else {
165 ERR("No attached ns frame object\n");
166 return E_UNEXPECTED;
169 if(NS_FAILED(nsres)) {
170 ERR("GetName failed: 0x%08x\n", nsres);
171 nsAString_Finish(&nsstr);
172 return E_FAIL;
175 nsAString_GetData(&nsstr, &strdata);
176 if(*strdata) {
177 *p = SysAllocString(strdata);
178 if(!*p) {
179 nsAString_Finish(&nsstr);
180 return E_OUTOFMEMORY;
182 }else
183 *p = NULL;
185 nsAString_Finish(&nsstr);
187 return S_OK;
190 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
192 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
193 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
194 return E_NOTIMPL;
197 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
199 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
200 FIXME("(%p)->(%p)\n", This, p);
201 return E_NOTIMPL;
204 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
206 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
207 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
208 return E_NOTIMPL;
211 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
213 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
214 FIXME("(%p)->(%p)\n", This, p);
215 return E_NOTIMPL;
218 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
220 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
221 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
222 return E_NOTIMPL;
225 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
227 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
228 FIXME("(%p)->(%p)\n", This, p);
229 return E_NOTIMPL;
232 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
234 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
235 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
236 return E_NOTIMPL;
239 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
241 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
242 FIXME("(%p)->(%p)\n", This, p);
243 return E_NOTIMPL;
246 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
248 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
249 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
250 return E_NOTIMPL;
253 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
255 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
256 FIXME("(%p)->(%p)\n", This, p);
257 return E_NOTIMPL;
260 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
262 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
263 FIXME("(%p)->(%x)\n", This, v);
264 return E_NOTIMPL;
267 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
269 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
270 FIXME("(%p)->(%p)\n", This, p);
271 return E_NOTIMPL;
274 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
276 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
277 nsAString nsstr;
278 nsresult nsres;
280 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
282 if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
283 return E_INVALIDARG;
285 if(This->nsframe) {
286 nsAString_Init(&nsstr, v);
287 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
288 }else if(This->nsiframe) {
289 nsAString_Init(&nsstr, v);
290 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
291 }else {
292 ERR("No attached ns frame object\n");
293 return E_UNEXPECTED;
295 nsAString_Finish(&nsstr);
297 if(NS_FAILED(nsres)) {
298 ERR("SetScrolling failed: 0x%08x\n", nsres);
299 return E_FAIL;
302 return S_OK;
305 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
307 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
308 nsAString nsstr;
309 const PRUnichar *strdata;
310 nsresult nsres;
312 TRACE("(%p)->(%p)\n", This, p);
314 if(This->nsframe) {
315 nsAString_Init(&nsstr, NULL);
316 nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
317 }else if(This->nsiframe) {
318 nsAString_Init(&nsstr, NULL);
319 nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
320 }else {
321 ERR("No attached ns frame object\n");
322 return E_UNEXPECTED;
325 if(NS_FAILED(nsres)) {
326 ERR("GetScrolling failed: 0x%08x\n", nsres);
327 nsAString_Finish(&nsstr);
328 return E_FAIL;
331 nsAString_GetData(&nsstr, &strdata);
333 if(*strdata)
334 *p = SysAllocString(strdata);
335 else
336 *p = SysAllocString(autoW);
338 nsAString_Finish(&nsstr);
340 return *p ? S_OK : E_OUTOFMEMORY;
343 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
344 HTMLFrameBase_QueryInterface,
345 HTMLFrameBase_AddRef,
346 HTMLFrameBase_Release,
347 HTMLFrameBase_GetTypeInfoCount,
348 HTMLFrameBase_GetTypeInfo,
349 HTMLFrameBase_GetIDsOfNames,
350 HTMLFrameBase_Invoke,
351 HTMLFrameBase_put_src,
352 HTMLFrameBase_get_src,
353 HTMLFrameBase_put_name,
354 HTMLFrameBase_get_name,
355 HTMLFrameBase_put_border,
356 HTMLFrameBase_get_border,
357 HTMLFrameBase_put_frameBorder,
358 HTMLFrameBase_get_frameBorder,
359 HTMLFrameBase_put_frameSpacing,
360 HTMLFrameBase_get_frameSpacing,
361 HTMLFrameBase_put_marginWidth,
362 HTMLFrameBase_get_marginWidth,
363 HTMLFrameBase_put_marginHeight,
364 HTMLFrameBase_get_marginHeight,
365 HTMLFrameBase_put_noResize,
366 HTMLFrameBase_get_noResize,
367 HTMLFrameBase_put_scrolling,
368 HTMLFrameBase_get_scrolling
371 #define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase2, iface)
373 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
375 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
377 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
380 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
382 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
384 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
387 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
389 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
391 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
394 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
396 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
397 FIXME("(%p)\n", This);
398 return E_NOTIMPL;
401 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
402 LCID lcid, ITypeInfo **ppTInfo)
404 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
405 FIXME("(%p)\n", This);
406 return E_NOTIMPL;
409 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
410 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
412 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
413 FIXME("(%p)\n", This);
414 return E_NOTIMPL;
417 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
418 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
419 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
421 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
422 FIXME("(%p)\n", This);
423 return E_NOTIMPL;
426 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
428 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
430 TRACE("(%p)->(%p)\n", This, p);
432 if(This->content_window) {
433 IHTMLWindow2_AddRef(HTMLWINDOW2(This->content_window));
434 *p = HTMLWINDOW2(This->content_window);
435 }else {
436 WARN("NULL content window\n");
437 *p = NULL;
439 return S_OK;
442 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
444 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
445 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
446 return E_NOTIMPL;
449 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
451 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
452 FIXME("(%p)->(%p)\n", This, p);
453 return E_NOTIMPL;
456 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
458 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
459 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
460 return E_NOTIMPL;
463 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
465 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
466 FIXME("(%p)->(%p)\n", This, p);
467 return E_NOTIMPL;
470 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
472 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
474 TRACE("(%p)->(%p)\n", This, p);
476 if(!This->content_window || !This->content_window->doc) {
477 FIXME("no document associated\n");
478 return E_FAIL;
481 return IHTMLDocument2_get_readyState(HTMLDOC(&This->content_window->doc->basedoc), p);
484 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
486 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
487 FIXME("(%p)->(%x)\n", This, v);
488 return E_NOTIMPL;
491 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
493 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
494 FIXME("(%p)->(%p)\n", This, p);
495 return E_NOTIMPL;
498 #undef HTMLFRAMEBASE2_THIS
500 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
501 HTMLFrameBase2_QueryInterface,
502 HTMLFrameBase2_AddRef,
503 HTMLFrameBase2_Release,
504 HTMLFrameBase2_GetTypeInfoCount,
505 HTMLFrameBase2_GetTypeInfo,
506 HTMLFrameBase2_GetIDsOfNames,
507 HTMLFrameBase2_Invoke,
508 HTMLFrameBase2_get_contentWindow,
509 HTMLFrameBase2_put_onload,
510 HTMLFrameBase2_get_onload,
511 HTMLFrameBase2_put_onreadystatechange,
512 HTMLFrameBase2_get_onreadystatechange,
513 HTMLFrameBase2_get_readyState,
514 HTMLFrameBase2_put_allowTransparency,
515 HTMLFrameBase2_get_allowTransparency
518 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
520 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
521 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
522 *ppv = HTMLFRAMEBASE(This);
523 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
524 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
525 *ppv = HTMLFRAMEBASE2(This);
526 }else {
527 return HTMLElement_QI(&This->element.node, riid, ppv);
530 IUnknown_AddRef((IUnknown*)*ppv);
531 return S_OK;
534 void HTMLFrameBase_destructor(HTMLFrameBase *This)
536 if(This->content_window)
537 This->content_window->frame_element = NULL;
539 if(This->nsframe)
540 nsIDOMHTMLFrameElement_Release(This->nsframe);
541 if(This->nsiframe)
542 nsIDOMHTMLIFrameElement_Release(This->nsiframe);
544 HTMLElement_destructor(&This->element.node);
547 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
548 dispex_static_data_t *dispex_data)
550 nsresult nsres;
552 This->lpIHTMLFrameBaseVtbl = &HTMLFrameBaseVtbl;
553 This->lpIHTMLFrameBase2Vtbl = &HTMLFrameBase2Vtbl;
555 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
557 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
558 if(NS_FAILED(nsres)) {
559 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
560 if(NS_FAILED(nsres))
561 ERR("Could not get nsIDOMHTML[I]Frame interface\n");
562 }else
563 This->nsiframe = NULL;
566 typedef struct {
567 HTMLFrameBase framebase;
568 } HTMLFrameElement;
570 #define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface)
572 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
574 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
576 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
579 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
581 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
583 HTMLFrameBase_destructor(&This->framebase);
586 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
588 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
590 if(!This->framebase.content_window || !This->framebase.content_window->doc) {
591 *p = NULL;
592 return S_OK;
595 *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc);
596 IDispatch_AddRef(*p);
597 return S_OK;
600 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
602 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
603 nsIDOMDocument *nsdoc;
604 nsresult nsres;
605 HRESULT hres;
607 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
608 if(NS_FAILED(nsres) || !nsdoc) {
609 ERR("GetContentDocument failed: %08x\n", nsres);
610 return E_FAIL;
613 hres = set_frame_doc(&This->framebase, nsdoc);
614 nsIDOMDocument_Release(nsdoc);
615 return hres;
618 #undef HTMLFRAME_NODE_THIS
620 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
621 HTMLFrameElement_QI,
622 HTMLFrameElement_destructor,
623 NULL,
624 NULL,
625 NULL,
626 NULL,
627 HTMLFrameElement_get_document,
628 NULL,
629 NULL,
630 NULL,
631 HTMLFrameElement_bind_to_tree
634 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
636 HTMLFrameElement *ret;
638 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
640 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
642 HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL);
644 return &ret->framebase.element;