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
28 #include "mshtml_private.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 HTMLFrameBase framebase
;
39 nsIDOMHTMLIFrameElement
*nsiframe
;
42 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
44 static HRESULT
HTMLIFrame_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
46 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
48 return HTMLFrameBase_QI(&This
->framebase
, riid
, ppv
);
51 static void HTMLIFrame_destructor(HTMLDOMNode
*iface
)
53 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
56 nsIDOMHTMLIFrameElement_Release(This
->nsiframe
);
58 HTMLFrameBase_destructor(&This
->framebase
);
61 static HRESULT
HTMLIFrame_get_document(HTMLDOMNode
*iface
, IDispatch
**p
)
63 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
65 if(!This
->framebase
.content_window
|| !This
->framebase
.content_window
->doc
) {
70 *p
= (IDispatch
*)HTMLDOC(&This
->framebase
.content_window
->doc
->basedoc
);
75 static HRESULT
HTMLIFrame_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
77 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
79 return IHTMLFrameBase2_get_readyState(HTMLFRAMEBASE2(&This
->framebase
), p
);
82 #undef HTMLIFRAME_NODE_THIS
84 static const NodeImplVtbl HTMLIFrameImplVtbl
= {
86 HTMLIFrame_destructor
,
91 HTMLIFrame_get_document
,
92 HTMLIFrame_get_readystate
95 static const tid_t HTMLIFrame_iface_tids
[] = {
106 static dispex_static_data_t HTMLIFrame_dispex
= {
110 HTMLIFrame_iface_tids
113 static HTMLWindow
*get_content_window(nsIDOMHTMLIFrameElement
*nsiframe
)
116 nsIDOMWindow
*nswindow
;
117 nsIDOMDocument
*nsdoc
;
120 nsres
= nsIDOMHTMLIFrameElement_GetContentDocument(nsiframe
, &nsdoc
);
121 if(NS_FAILED(nsres
)) {
122 ERR("GetContentDocument failed: %08x\n", nsres
);
127 FIXME("NULL contentDocument\n");
131 nswindow
= get_nsdoc_window(nsdoc
);
132 nsIDOMDocument_Release(nsdoc
);
136 ret
= nswindow_to_window(nswindow
);
137 nsIDOMWindow_Release(nswindow
);
139 ERR("Could not get window object\n");
144 HTMLElement
*HTMLIFrame_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLWindow
*content_window
)
149 ret
= heap_alloc_zero(sizeof(HTMLIFrame
));
151 ret
->framebase
.element
.node
.vtbl
= &HTMLIFrameImplVtbl
;
153 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLIFrameElement
, (void**)&ret
->nsiframe
);
155 ERR("Could not get nsIDOMHTMLIFrameElement iface: %08x\n", nsres
);
158 content_window
= get_content_window(ret
->nsiframe
);
160 HTMLFrameBase_Init(&ret
->framebase
, doc
, nselem
, content_window
, &HTMLIFrame_dispex
);
162 return &ret
->framebase
.element
;