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
;
38 #define HTMLIFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLIFrame, framebase.element.node, iface)
40 static HRESULT
HTMLIFrame_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
42 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
44 return HTMLFrameBase_QI(&This
->framebase
, riid
, ppv
);
47 static void HTMLIFrame_destructor(HTMLDOMNode
*iface
)
49 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
51 HTMLFrameBase_destructor(&This
->framebase
);
54 static HRESULT
HTMLIFrame_get_document(HTMLDOMNode
*iface
, IDispatch
**p
)
56 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
58 if(!This
->framebase
.content_window
|| !This
->framebase
.content_window
->doc
) {
63 *p
= (IDispatch
*)HTMLDOC(&This
->framebase
.content_window
->doc
->basedoc
);
68 static HRESULT
HTMLIFrame_get_dispid(HTMLDOMNode
*iface
, BSTR name
,
69 DWORD grfdex
, DISPID
*pid
)
71 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
73 if(!This
->framebase
.content_window
)
74 return DISP_E_UNKNOWNNAME
;
76 return search_window_props(This
->framebase
.content_window
, name
, grfdex
, pid
);
79 static HRESULT
HTMLIFrame_invoke(HTMLDOMNode
*iface
, DISPID id
, LCID lcid
,
80 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
82 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
84 if(!This
->framebase
.content_window
) {
85 ERR("no content window to invoke on\n");
89 return IDispatchEx_InvokeEx(DISPATCHEX(This
->framebase
.content_window
), id
, lcid
, flags
, params
, res
, ei
, caller
);
92 static HRESULT
HTMLIFrame_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
94 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
96 return IHTMLFrameBase2_get_readyState(HTMLFRAMEBASE2(&This
->framebase
), p
);
99 static HRESULT
HTMLIFrame_bind_to_tree(HTMLDOMNode
*iface
)
101 HTMLIFrame
*This
= HTMLIFRAME_NODE_THIS(iface
);
102 nsIDOMDocument
*nsdoc
;
106 nsres
= nsIDOMHTMLIFrameElement_GetContentDocument(This
->framebase
.nsiframe
, &nsdoc
);
107 if(NS_FAILED(nsres
) || !nsdoc
) {
108 ERR("GetContentDocument failed: %08x\n", nsres
);
112 hres
= set_frame_doc(&This
->framebase
, nsdoc
);
113 nsIDOMDocument_Release(nsdoc
);
117 #undef HTMLIFRAME_NODE_THIS
119 static const NodeImplVtbl HTMLIFrameImplVtbl
= {
121 HTMLIFrame_destructor
,
126 HTMLIFrame_get_document
,
127 HTMLIFrame_get_readystate
,
128 HTMLIFrame_get_dispid
,
130 HTMLIFrame_bind_to_tree
133 static const tid_t HTMLIFrame_iface_tids
[] = {
144 static dispex_static_data_t HTMLIFrame_dispex
= {
148 HTMLIFrame_iface_tids
151 HTMLElement
*HTMLIFrame_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
)
155 ret
= heap_alloc_zero(sizeof(HTMLIFrame
));
157 ret
->framebase
.element
.node
.vtbl
= &HTMLIFrameImplVtbl
;
159 HTMLFrameBase_Init(&ret
->framebase
, doc
, nselem
, &HTMLIFrame_dispex
);
161 return &ret
->framebase
.element
;