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);
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;
44 if(frame->content_window)
47 nswindow = get_nsdoc_window(nsdoc);
51 window = nswindow_to_window(nswindow);
53 hres = HTMLWindow_Create(frame->element.node.doc->basedoc.doc_obj, nswindow,
54 frame->element.node.doc->basedoc.window, &window);
55 nsIDOMWindow_Release(nswindow);
59 frame->content_window = window;
60 window->frame_element = frame;
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");
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);
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));
149 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
151 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
153 const PRUnichar *strdata;
156 TRACE("(%p)->(%p)\n", This, p);
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);
165 ERR("No attached ns frame object\n");
169 if(NS_FAILED(nsres)) {
170 ERR("GetName failed: 0x%08x\n", nsres);
171 nsAString_Finish(&nsstr);
175 nsAString_GetData(&nsstr, &strdata);
177 *p = SysAllocString(strdata);
179 nsAString_Finish(&nsstr);
180 return E_OUTOFMEMORY;
185 nsAString_Finish(&nsstr);
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));
197 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
199 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
200 FIXME("(%p)->(%p)\n", This, p);
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));
211 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
213 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
214 FIXME("(%p)->(%p)\n", This, p);
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));
225 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
227 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
228 FIXME("(%p)->(%p)\n", This, p);
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));
239 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
241 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
242 FIXME("(%p)->(%p)\n", This, p);
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));
253 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
255 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
256 FIXME("(%p)->(%p)\n", This, p);
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);
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);
274 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
276 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
280 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
282 if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
286 nsAString_InitDepend(&nsstr, v);
287 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
288 }else if(This->nsiframe) {
289 nsAString_InitDepend(&nsstr, v);
290 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
292 ERR("No attached ns frame object\n");
295 nsAString_Finish(&nsstr);
297 if(NS_FAILED(nsres)) {
298 ERR("SetScrolling failed: 0x%08x\n", nsres);
305 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
307 HTMLFrameBase *This = HTMLFRAMEBASE_THIS(iface);
309 const PRUnichar *strdata;
312 TRACE("(%p)->(%p)\n", This, p);
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);
321 ERR("No attached ns frame object\n");
325 if(NS_FAILED(nsres)) {
326 ERR("GetScrolling failed: 0x%08x\n", nsres);
327 nsAString_Finish(&nsstr);
331 nsAString_GetData(&nsstr, &strdata);
334 *p = SysAllocString(strdata);
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);
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);
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);
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);
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);
436 WARN("NULL content window\n");
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));
449 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
451 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
452 FIXME("(%p)->(%p)\n", This, p);
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));
463 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
465 HTMLFrameBase *This = HTMLFRAMEBASE2_THIS(iface);
466 FIXME("(%p)->(%p)\n", This, p);
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");
481 return IHTMLDocument2_get_readyState(&This->content_window->doc->basedoc.IHTMLDocument2_iface, 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);
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);
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);
527 return HTMLElement_QI(&This->element.node, riid, ppv);
530 IUnknown_AddRef((IUnknown*)*ppv);
534 void HTMLFrameBase_destructor(HTMLFrameBase *This)
536 if(This->content_window)
537 This->content_window->frame_element = NULL;
540 nsIDOMHTMLFrameElement_Release(This->nsframe);
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)
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);
561 ERR("Could not get nsIDOMHTML[I]Frame interface\n");
563 This->nsiframe = NULL;