usp10: Merge neutral scripts.
[wine.git] / dlls / mshtml / htmlframe.c
blob2663616d86bd60e2bd746db9a74c4652ede59dbc
1 /*
2 * Copyright 2010 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 typedef struct {
35 HTMLFrameBase framebase;
36 IHTMLFrameElement3 IHTMLFrameElement3_iface;
37 } HTMLFrameElement;
39 static inline HTMLFrameElement *impl_from_IHTMLFrameElement3(IHTMLFrameElement3 *iface)
41 return CONTAINING_RECORD(iface, HTMLFrameElement, IHTMLFrameElement3_iface);
44 static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface,
45 REFIID riid, void **ppv)
47 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
49 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
52 static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface)
54 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
56 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
59 static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface)
61 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
63 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
66 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo)
68 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
69 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.dispex.IDispatchEx_iface,
70 pctinfo);
73 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo,
74 LCID lcid, ITypeInfo **ppTInfo)
76 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
77 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.dispex.IDispatchEx_iface, iTInfo,
78 lcid, ppTInfo);
81 static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid,
82 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
84 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
85 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.dispex.IDispatchEx_iface, riid,
86 rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
94 return IDispatchEx_Invoke(&This->framebase.element.node.dispex.IDispatchEx_iface, dispIdMember,
95 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p)
100 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
101 IHTMLDocument2 *doc;
102 HRESULT hres;
104 TRACE("(%p)->(%p)\n", This, p);
106 if(!This->framebase.content_window) {
107 FIXME("NULL window\n");
108 return E_FAIL;
111 hres = IHTMLWindow2_get_document(&This->framebase.content_window->IHTMLWindow2_iface, &doc);
112 if(FAILED(hres))
113 return hres;
115 *p = doc ? (IDispatch*)doc : NULL;
116 return S_OK;
119 static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v)
121 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
122 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
123 return E_NOTIMPL;
126 static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p)
128 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
129 FIXME("(%p)->(%p)\n", This, p);
130 return E_NOTIMPL;
133 static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v)
135 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
136 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
137 return E_NOTIMPL;
140 static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p)
142 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
143 FIXME("(%p)->(%p)\n", This, p);
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v)
149 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
150 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
151 return E_NOTIMPL;
154 static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p)
156 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
157 FIXME("(%p)->(%p)\n", This, p);
158 return E_NOTIMPL;
161 static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = {
162 HTMLFrameElement3_QueryInterface,
163 HTMLFrameElement3_AddRef,
164 HTMLFrameElement3_Release,
165 HTMLFrameElement3_GetTypeInfoCount,
166 HTMLFrameElement3_GetTypeInfo,
167 HTMLFrameElement3_GetIDsOfNames,
168 HTMLFrameElement3_Invoke,
169 HTMLFrameElement3_get_contentDocument,
170 HTMLFrameElement3_put_src,
171 HTMLFrameElement3_get_src,
172 HTMLFrameElement3_put_longDesc,
173 HTMLFrameElement3_get_longDesc,
174 HTMLFrameElement3_put_frameBorder,
175 HTMLFrameElement3_get_frameBorder
178 static inline HTMLFrameElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
180 return CONTAINING_RECORD(iface, HTMLFrameElement, framebase.element.node);
183 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
185 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
187 if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) {
188 TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv);
189 *ppv = &This->IHTMLFrameElement3_iface;
190 }else {
191 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
194 IUnknown_AddRef((IUnknown*)*ppv);
195 return S_OK;
198 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
200 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
202 HTMLFrameBase_destructor(&This->framebase);
205 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
207 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
209 if(!This->framebase.content_window || !This->framebase.content_window->doc) {
210 *p = NULL;
211 return S_OK;
214 *p = (IDispatch*)&This->framebase.content_window->doc->basedoc.IHTMLDocument2_iface;
215 IDispatch_AddRef(*p);
216 return S_OK;
219 static HRESULT HTMLFrameElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
221 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
223 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
226 static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
227 DWORD grfdex, DISPID *pid)
229 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
231 if(!This->framebase.content_window)
232 return DISP_E_UNKNOWNNAME;
234 return search_window_props(This->framebase.content_window, name, grfdex, pid);
237 static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
238 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
240 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
242 if(!This->framebase.content_window) {
243 ERR("no content window to invoke on\n");
244 return E_FAIL;
247 return IDispatchEx_InvokeEx(&This->framebase.content_window->IDispatchEx_iface, id, lcid,
248 flags, params, res, ei, caller);
251 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
253 HTMLFrameElement *This = impl_from_HTMLDOMNode(iface);
254 nsIDOMDocument *nsdoc;
255 nsresult nsres;
256 HRESULT hres;
258 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
259 if(NS_FAILED(nsres) || !nsdoc) {
260 ERR("GetContentDocument failed: %08x\n", nsres);
261 return E_FAIL;
264 hres = set_frame_doc(&This->framebase, nsdoc);
265 nsIDOMDocument_Release(nsdoc);
266 return hres;
269 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
270 HTMLFrameElement_QI,
271 HTMLFrameElement_destructor,
272 HTMLElement_clone,
273 HTMLElement_get_attr_col,
274 NULL,
275 NULL,
276 NULL,
277 NULL,
278 NULL,
279 HTMLFrameElement_get_document,
280 HTMLFrameElement_get_readystate,
281 HTMLFrameElement_get_dispid,
282 HTMLFrameElement_invoke,
283 HTMLFrameElement_bind_to_tree
286 static const tid_t HTMLFrameElement_iface_tids[] = {
287 HTMLELEMENT_TIDS,
288 IHTMLFrameBase_tid,
289 IHTMLFrameBase2_tid,
290 IHTMLFrameElement3_tid,
294 static dispex_static_data_t HTMLFrameElement_dispex = {
295 NULL,
296 DispHTMLFrameElement_tid,
297 NULL,
298 HTMLFrameElement_iface_tids
301 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
303 HTMLFrameElement *ret;
305 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
306 if(!ret)
307 return E_OUTOFMEMORY;
309 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
310 ret->IHTMLFrameElement3_iface.lpVtbl = &HTMLFrameElement3Vtbl;
312 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex);
314 *elem = &ret->framebase.element;
315 return S_OK;