push 149f0a5527ac85057a8ef03858d34d91c36f97e8
[wine/hacks.git] / dlls / mshtml / htmlframebase.c
blob03b48b64e31c3cfe981b0d2a4749b3036ed5350f
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 HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
36 nsIDOMWindow *nswindow;
37 HTMLWindow *window;
38 HRESULT hres = S_OK;
40 if(frame->content_window)
41 return S_OK;
43 nswindow = get_nsdoc_window(nsdoc);
44 if(!nswindow)
45 return E_FAIL;
47 window = nswindow_to_window(nswindow);
48 if(!window)
49 hres = HTMLWindow_Create(frame->element.node.doc->basedoc.doc_obj, nswindow,
50 frame->element.node.doc->basedoc.window, &window);
51 nsIDOMWindow_Release(nswindow);
52 if(FAILED(hres))
53 return hres;
55 frame->content_window = window;
56 window->frame_element = frame;
57 return S_OK;
60 #define HTMLFRAMEBASE_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase, iface)
62 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
64 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
66 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
69 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
71 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
73 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
76 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
78 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
80 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
83 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
85 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
87 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
90 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
91 LCID lcid, ITypeInfo **ppTInfo)
93 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
95 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
98 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
99 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
101 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
103 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames,
104 cNames, lcid, rgDispId);
107 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
108 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
109 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
111 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
113 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid,
114 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
117 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
119 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
121 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
123 if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
124 FIXME("detached element\n");
125 return E_FAIL;
128 return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->url);
131 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
133 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
134 FIXME("(%p)->(%p)\n", This, p);
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
140 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
141 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
147 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
148 FIXME("(%p)->(%p)\n", This, p);
149 return E_NOTIMPL;
152 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
154 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
155 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
156 return E_NOTIMPL;
159 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
161 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
162 FIXME("(%p)->(%p)\n", This, p);
163 return E_NOTIMPL;
166 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
168 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
169 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
170 return E_NOTIMPL;
173 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
175 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
176 FIXME("(%p)->(%p)\n", This, p);
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
182 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
183 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
189 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
190 FIXME("(%p)->(%p)\n", This, p);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
196 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
197 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
198 return E_NOTIMPL;
201 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
203 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
204 FIXME("(%p)->(%p)\n", This, p);
205 return E_NOTIMPL;
208 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
210 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
211 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
212 return E_NOTIMPL;
215 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
217 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
218 FIXME("(%p)->(%p)\n", This, p);
219 return E_NOTIMPL;
222 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
224 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
225 FIXME("(%p)->(%x)\n", This, v);
226 return E_NOTIMPL;
229 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
231 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
232 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
238 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
239 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
245 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
246 FIXME("(%p)->(%p)\n", This, p);
247 return E_NOTIMPL;
250 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
251 HTMLFrameBase_QueryInterface,
252 HTMLFrameBase_AddRef,
253 HTMLFrameBase_Release,
254 HTMLFrameBase_GetTypeInfoCount,
255 HTMLFrameBase_GetTypeInfo,
256 HTMLFrameBase_GetIDsOfNames,
257 HTMLFrameBase_Invoke,
258 HTMLFrameBase_put_src,
259 HTMLFrameBase_get_src,
260 HTMLFrameBase_put_name,
261 HTMLFrameBase_get_name,
262 HTMLFrameBase_put_border,
263 HTMLFrameBase_get_border,
264 HTMLFrameBase_put_frameBorder,
265 HTMLFrameBase_get_frameBorder,
266 HTMLFrameBase_put_frameSpacing,
267 HTMLFrameBase_get_frameSpacing,
268 HTMLFrameBase_put_marginWidth,
269 HTMLFrameBase_get_marginWidth,
270 HTMLFrameBase_put_marginHeight,
271 HTMLFrameBase_get_marginHeight,
272 HTMLFrameBase_put_noResize,
273 HTMLFrameBase_get_noResize,
274 HTMLFrameBase_put_scrolling,
275 HTMLFrameBase_get_scrolling
278 #define HTMLFRAMEBASE2_THIS(iface) DEFINE_THIS(HTMLFrameBase, IHTMLFrameBase2, iface)
280 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
282 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
284 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
287 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
289 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
291 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
294 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
296 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
298 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
301 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
303 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
304 FIXME("(%p)\n", This);
305 return E_NOTIMPL;
308 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
309 LCID lcid, ITypeInfo **ppTInfo)
311 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
312 FIXME("(%p)\n", This);
313 return E_NOTIMPL;
316 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
317 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
319 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
320 FIXME("(%p)\n", This);
321 return E_NOTIMPL;
324 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
325 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
326 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
328 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
329 FIXME("(%p)\n", This);
330 return E_NOTIMPL;
333 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
335 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
337 TRACE("(%p)->(%p)\n", This, p);
339 if(This->content_window) {
340 IHTMLWindow2_AddRef(HTMLWINDOW2(This->content_window));
341 *p = HTMLWINDOW2(This->content_window);
342 }else {
343 WARN("NULL content window\n");
344 *p = NULL;
346 return S_OK;
349 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
351 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
352 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
353 return E_NOTIMPL;
356 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
358 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
359 FIXME("(%p)->(%p)\n", This, p);
360 return E_NOTIMPL;
363 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
365 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
366 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
367 return E_NOTIMPL;
370 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
372 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
373 FIXME("(%p)->(%p)\n", This, p);
374 return E_NOTIMPL;
377 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
379 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
381 TRACE("(%p)->(%p)\n", This, p);
383 if(!This->content_window || !This->content_window->doc) {
384 FIXME("no document associated\n");
385 return E_FAIL;
388 return IHTMLDocument2_get_readyState(HTMLDOC(&This->content_window->doc->basedoc), p);
391 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
393 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
394 FIXME("(%p)->(%x)\n", This, v);
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
400 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
401 FIXME("(%p)->(%p)\n", This, p);
402 return E_NOTIMPL;
405 #undef HTMLFRAMEBASE2_THIS
407 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
408 HTMLFrameBase2_QueryInterface,
409 HTMLFrameBase2_AddRef,
410 HTMLFrameBase2_Release,
411 HTMLFrameBase2_GetTypeInfoCount,
412 HTMLFrameBase2_GetTypeInfo,
413 HTMLFrameBase2_GetIDsOfNames,
414 HTMLFrameBase2_Invoke,
415 HTMLFrameBase2_get_contentWindow,
416 HTMLFrameBase2_put_onload,
417 HTMLFrameBase2_get_onload,
418 HTMLFrameBase2_put_onreadystatechange,
419 HTMLFrameBase2_get_onreadystatechange,
420 HTMLFrameBase2_get_readyState,
421 HTMLFrameBase2_put_allowTransparency,
422 HTMLFrameBase2_get_allowTransparency
425 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
427 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
428 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
429 *ppv = HTMLFRAMEBASE(This);
430 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
431 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
432 *ppv = HTMLFRAMEBASE2(This);
433 }else {
434 return HTMLElement_QI(&This->element.node, riid, ppv);
437 IUnknown_AddRef((IUnknown*)*ppv);
438 return S_OK;
441 void HTMLFrameBase_destructor(HTMLFrameBase *This)
443 if(This->content_window)
444 This->content_window->frame_element = NULL;
446 HTMLElement_destructor(&This->element.node);
449 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
450 dispex_static_data_t *dispex_data)
452 This->lpIHTMLFrameBaseVtbl = &HTMLFrameBaseVtbl;
453 This->lpIHTMLFrameBase2Vtbl = &HTMLFrameBase2Vtbl;
455 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
458 typedef struct {
459 HTMLFrameBase framebase;
460 } HTMLFrameElement;
462 #define HTMLFRAME_NODE_THIS(iface) DEFINE_THIS2(HTMLFrameElement, framebase.element.node, iface)
464 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
466 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
468 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
471 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
473 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
475 HTMLFrameBase_destructor(&This->framebase);
478 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
480 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
482 if(!This->framebase.content_window || !This->framebase.content_window->doc) {
483 *p = NULL;
484 return S_OK;
487 *p = (IDispatch*)HTMLDOC(&This->framebase.content_window->doc->basedoc);
488 IDispatch_AddRef(*p);
489 return S_OK;
492 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
494 HTMLFrameElement *This = HTMLFRAME_NODE_THIS(iface);
495 nsIDOMHTMLFrameElement *nsframe;
496 nsIDOMDocument *nsdoc;
497 nsresult nsres;
498 HRESULT hres;
500 nsres = nsIDOMHTMLElement_QueryInterface(This->framebase.element.nselem, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
501 if(NS_FAILED(nsres))
502 return E_FAIL;
504 nsres = nsIDOMHTMLFrameElement_GetContentDocument(nsframe, &nsdoc);
505 nsIDOMHTMLFrameElement_Release(nsframe);
506 if(NS_FAILED(nsres) || !nsdoc) {
507 ERR("GetContentDocument failed: %08x\n", nsres);
508 return E_FAIL;
511 hres = set_frame_doc(&This->framebase, nsdoc);
512 nsIDOMDocument_Release(nsdoc);
513 return hres;
516 #undef HTMLFRAME_NODE_THIS
518 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
519 HTMLFrameElement_QI,
520 HTMLFrameElement_destructor,
521 NULL,
522 NULL,
523 NULL,
524 NULL,
525 HTMLFrameElement_get_document,
526 NULL,
527 NULL,
528 NULL,
529 HTMLFrameElement_bind_to_tree
532 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
534 nsIDOMHTMLFrameElement *nsframe;
535 HTMLFrameElement *ret;
536 nsresult nsres;
538 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
540 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
542 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&nsframe);
543 if(NS_FAILED(nsres))
544 ERR("Could not get nsIDOMHTMLFrameElement iface: %08x\n", nsres);
546 HTMLFrameBase_Init(&ret->framebase, doc, nselem, NULL);
548 return &ret->framebase.element;