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
29 #include "mshtml_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 static const WCHAR autoW
[] = {'a','u','t','o',0};
36 static const WCHAR yesW
[] = {'y','e','s',0};
37 static const WCHAR noW
[] = {'n','o',0};
39 HRESULT
set_frame_doc(HTMLFrameBase
*frame
, nsIDOMDocument
*nsdoc
)
41 nsIDOMWindow
*nswindow
;
42 HTMLOuterWindow
*window
;
46 if(frame
->content_window
)
49 nsres
= nsIDOMDocument_GetDefaultView(nsdoc
, &nswindow
);
50 if(NS_FAILED(nsres
) || !nswindow
)
53 window
= nswindow_to_window(nswindow
);
55 hres
= HTMLOuterWindow_Create(frame
->element
.node
.doc
->basedoc
.doc_obj
, nswindow
,
56 frame
->element
.node
.doc
->basedoc
.window
, &window
);
57 nsIDOMWindow_Release(nswindow
);
61 frame
->content_window
= window
;
62 window
->frame_element
= frame
;
66 static inline HTMLFrameBase
*impl_from_IHTMLFrameBase(IHTMLFrameBase
*iface
)
68 return CONTAINING_RECORD(iface
, HTMLFrameBase
, IHTMLFrameBase_iface
);
71 static HRESULT WINAPI
HTMLFrameBase_QueryInterface(IHTMLFrameBase
*iface
, REFIID riid
, void **ppv
)
73 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
75 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
78 static ULONG WINAPI
HTMLFrameBase_AddRef(IHTMLFrameBase
*iface
)
80 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
82 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
85 static ULONG WINAPI
HTMLFrameBase_Release(IHTMLFrameBase
*iface
)
87 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
89 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
92 static HRESULT WINAPI
HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase
*iface
, UINT
*pctinfo
)
94 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
96 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
99 static HRESULT WINAPI
HTMLFrameBase_GetTypeInfo(IHTMLFrameBase
*iface
, UINT iTInfo
,
100 LCID lcid
, ITypeInfo
**ppTInfo
)
102 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
104 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
108 static HRESULT WINAPI
HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase
*iface
, REFIID riid
,
109 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
111 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
113 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
114 cNames
, lcid
, rgDispId
);
117 static HRESULT WINAPI
HTMLFrameBase_Invoke(IHTMLFrameBase
*iface
, DISPID dispIdMember
,
118 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
119 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
121 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
123 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
124 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
127 static HRESULT WINAPI
HTMLFrameBase_put_src(IHTMLFrameBase
*iface
, BSTR v
)
129 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
131 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
133 if(!This
->content_window
|| !This
->element
.node
.doc
|| !This
->element
.node
.doc
->basedoc
.window
) {
134 FIXME("detached element\n");
138 return navigate_url(This
->content_window
, v
, This
->element
.node
.doc
->basedoc
.window
->uri
);
141 static HRESULT WINAPI
HTMLFrameBase_get_src(IHTMLFrameBase
*iface
, BSTR
*p
)
143 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
144 FIXME("(%p)->(%p)\n", This
, p
);
148 static HRESULT WINAPI
HTMLFrameBase_put_name(IHTMLFrameBase
*iface
, BSTR v
)
150 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
151 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
155 static HRESULT WINAPI
HTMLFrameBase_get_name(IHTMLFrameBase
*iface
, BSTR
*p
)
157 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
161 TRACE("(%p)->(%p)\n", This
, p
);
163 if(!This
->nsframe
&& !This
->nsiframe
) {
164 ERR("No attached ns frame object\n");
168 nsAString_Init(&nsstr
, NULL
);
170 nsres
= nsIDOMHTMLFrameElement_GetName(This
->nsframe
, &nsstr
);
172 nsres
= nsIDOMHTMLIFrameElement_GetName(This
->nsiframe
, &nsstr
);
173 return return_nsstr(nsres
, &nsstr
, p
);
176 static HRESULT WINAPI
HTMLFrameBase_put_border(IHTMLFrameBase
*iface
, VARIANT v
)
178 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
179 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
183 static HRESULT WINAPI
HTMLFrameBase_get_border(IHTMLFrameBase
*iface
, VARIANT
*p
)
185 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
186 FIXME("(%p)->(%p)\n", This
, p
);
190 static HRESULT WINAPI
HTMLFrameBase_put_frameBorder(IHTMLFrameBase
*iface
, BSTR v
)
192 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
196 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
198 if(!This
->nsframe
&& !This
->nsiframe
) {
199 ERR("No attached ns frame object\n");
203 nsAString_InitDepend(&nsstr
, v
);
205 nsres
= nsIDOMHTMLFrameElement_SetFrameBorder(This
->nsframe
, &nsstr
);
207 nsres
= nsIDOMHTMLIFrameElement_SetFrameBorder(This
->nsiframe
, &nsstr
);
208 nsAString_Finish(&nsstr
);
209 if(NS_FAILED(nsres
)) {
210 ERR("SetFrameBorder failed: %08x\n", nsres
);
217 static HRESULT WINAPI
HTMLFrameBase_get_frameBorder(IHTMLFrameBase
*iface
, BSTR
*p
)
219 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
223 TRACE("(%p)->(%p)\n", This
, p
);
225 if(!This
->nsframe
&& !This
->nsiframe
) {
226 ERR("No attached ns frame object\n");
230 nsAString_Init(&nsstr
, NULL
);
232 nsres
= nsIDOMHTMLFrameElement_GetFrameBorder(This
->nsframe
, &nsstr
);
234 nsres
= nsIDOMHTMLIFrameElement_GetFrameBorder(This
->nsiframe
, &nsstr
);
235 return return_nsstr(nsres
, &nsstr
, p
);
238 static HRESULT WINAPI
HTMLFrameBase_put_frameSpacing(IHTMLFrameBase
*iface
, VARIANT v
)
240 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
241 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
245 static HRESULT WINAPI
HTMLFrameBase_get_frameSpacing(IHTMLFrameBase
*iface
, VARIANT
*p
)
247 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
248 FIXME("(%p)->(%p)\n", This
, p
);
252 static HRESULT WINAPI
HTMLFrameBase_put_marginWidth(IHTMLFrameBase
*iface
, VARIANT v
)
254 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
255 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
259 static HRESULT WINAPI
HTMLFrameBase_get_marginWidth(IHTMLFrameBase
*iface
, VARIANT
*p
)
261 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
262 FIXME("(%p)->(%p)\n", This
, p
);
266 static HRESULT WINAPI
HTMLFrameBase_put_marginHeight(IHTMLFrameBase
*iface
, VARIANT v
)
268 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
269 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
273 static HRESULT WINAPI
HTMLFrameBase_get_marginHeight(IHTMLFrameBase
*iface
, VARIANT
*p
)
275 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
276 FIXME("(%p)->(%p)\n", This
, p
);
280 static HRESULT WINAPI
HTMLFrameBase_put_noResize(IHTMLFrameBase
*iface
, VARIANT_BOOL v
)
282 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
283 FIXME("(%p)->(%x)\n", This
, v
);
287 static HRESULT WINAPI
HTMLFrameBase_get_noResize(IHTMLFrameBase
*iface
, VARIANT_BOOL
*p
)
289 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
290 FIXME("(%p)->(%p)\n", This
, p
);
294 static HRESULT WINAPI
HTMLFrameBase_put_scrolling(IHTMLFrameBase
*iface
, BSTR v
)
296 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
300 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
302 if(!(!strcmpiW(v
, yesW
) || !strcmpiW(v
, noW
) || !strcmpiW(v
, autoW
)))
306 nsAString_InitDepend(&nsstr
, v
);
307 nsres
= nsIDOMHTMLFrameElement_SetScrolling(This
->nsframe
, &nsstr
);
308 }else if(This
->nsiframe
) {
309 nsAString_InitDepend(&nsstr
, v
);
310 nsres
= nsIDOMHTMLIFrameElement_SetScrolling(This
->nsiframe
, &nsstr
);
312 ERR("No attached ns frame object\n");
315 nsAString_Finish(&nsstr
);
317 if(NS_FAILED(nsres
)) {
318 ERR("SetScrolling failed: 0x%08x\n", nsres
);
325 static HRESULT WINAPI
HTMLFrameBase_get_scrolling(IHTMLFrameBase
*iface
, BSTR
*p
)
327 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
329 const PRUnichar
*strdata
;
332 TRACE("(%p)->(%p)\n", This
, p
);
335 nsAString_Init(&nsstr
, NULL
);
336 nsres
= nsIDOMHTMLFrameElement_GetScrolling(This
->nsframe
, &nsstr
);
337 }else if(This
->nsiframe
) {
338 nsAString_Init(&nsstr
, NULL
);
339 nsres
= nsIDOMHTMLIFrameElement_GetScrolling(This
->nsiframe
, &nsstr
);
341 ERR("No attached ns frame object\n");
345 if(NS_FAILED(nsres
)) {
346 ERR("GetScrolling failed: 0x%08x\n", nsres
);
347 nsAString_Finish(&nsstr
);
351 nsAString_GetData(&nsstr
, &strdata
);
354 *p
= SysAllocString(strdata
);
356 *p
= SysAllocString(autoW
);
358 nsAString_Finish(&nsstr
);
360 return *p
? S_OK
: E_OUTOFMEMORY
;
363 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl
= {
364 HTMLFrameBase_QueryInterface
,
365 HTMLFrameBase_AddRef
,
366 HTMLFrameBase_Release
,
367 HTMLFrameBase_GetTypeInfoCount
,
368 HTMLFrameBase_GetTypeInfo
,
369 HTMLFrameBase_GetIDsOfNames
,
370 HTMLFrameBase_Invoke
,
371 HTMLFrameBase_put_src
,
372 HTMLFrameBase_get_src
,
373 HTMLFrameBase_put_name
,
374 HTMLFrameBase_get_name
,
375 HTMLFrameBase_put_border
,
376 HTMLFrameBase_get_border
,
377 HTMLFrameBase_put_frameBorder
,
378 HTMLFrameBase_get_frameBorder
,
379 HTMLFrameBase_put_frameSpacing
,
380 HTMLFrameBase_get_frameSpacing
,
381 HTMLFrameBase_put_marginWidth
,
382 HTMLFrameBase_get_marginWidth
,
383 HTMLFrameBase_put_marginHeight
,
384 HTMLFrameBase_get_marginHeight
,
385 HTMLFrameBase_put_noResize
,
386 HTMLFrameBase_get_noResize
,
387 HTMLFrameBase_put_scrolling
,
388 HTMLFrameBase_get_scrolling
391 static inline HTMLFrameBase
*impl_from_IHTMLFrameBase2(IHTMLFrameBase2
*iface
)
393 return CONTAINING_RECORD(iface
, HTMLFrameBase
, IHTMLFrameBase2_iface
);
396 static HRESULT WINAPI
HTMLFrameBase2_QueryInterface(IHTMLFrameBase2
*iface
, REFIID riid
, void **ppv
)
398 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
400 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
403 static ULONG WINAPI
HTMLFrameBase2_AddRef(IHTMLFrameBase2
*iface
)
405 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
407 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
410 static ULONG WINAPI
HTMLFrameBase2_Release(IHTMLFrameBase2
*iface
)
412 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
414 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
417 static HRESULT WINAPI
HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2
*iface
, UINT
*pctinfo
)
419 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
420 FIXME("(%p)\n", This
);
424 static HRESULT WINAPI
HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2
*iface
, UINT iTInfo
,
425 LCID lcid
, ITypeInfo
**ppTInfo
)
427 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
428 FIXME("(%p)\n", This
);
432 static HRESULT WINAPI
HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2
*iface
, REFIID riid
,
433 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
435 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
436 FIXME("(%p)\n", This
);
440 static HRESULT WINAPI
HTMLFrameBase2_Invoke(IHTMLFrameBase2
*iface
, DISPID dispIdMember
,
441 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
442 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
444 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
445 FIXME("(%p)\n", This
);
449 static HRESULT WINAPI
HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2
*iface
, IHTMLWindow2
**p
)
451 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
453 TRACE("(%p)->(%p)\n", This
, p
);
455 if(This
->content_window
) {
456 IHTMLWindow2_AddRef(&This
->content_window
->base
.IHTMLWindow2_iface
);
457 *p
= &This
->content_window
->base
.IHTMLWindow2_iface
;
459 WARN("NULL content window\n");
465 static HRESULT WINAPI
HTMLFrameBase2_put_onload(IHTMLFrameBase2
*iface
, VARIANT v
)
467 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
468 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
472 static HRESULT WINAPI
HTMLFrameBase2_get_onload(IHTMLFrameBase2
*iface
, VARIANT
*p
)
474 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
475 FIXME("(%p)->(%p)\n", This
, p
);
479 static HRESULT WINAPI
HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT v
)
481 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
482 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
486 static HRESULT WINAPI
HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT
*p
)
488 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
489 FIXME("(%p)->(%p)\n", This
, p
);
493 static HRESULT WINAPI
HTMLFrameBase2_get_readyState(IHTMLFrameBase2
*iface
, BSTR
*p
)
495 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
497 TRACE("(%p)->(%p)\n", This
, p
);
499 if(!This
->content_window
|| !This
->content_window
->base
.inner_window
->doc
) {
500 FIXME("no document associated\n");
504 return IHTMLDocument2_get_readyState(&This
->content_window
->base
.inner_window
->doc
->basedoc
.IHTMLDocument2_iface
, p
);
507 static HRESULT WINAPI
HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL v
)
509 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
510 FIXME("(%p)->(%x)\n", This
, v
);
514 static HRESULT WINAPI
HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL
*p
)
516 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
517 FIXME("(%p)->(%p)\n", This
, p
);
521 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl
= {
522 HTMLFrameBase2_QueryInterface
,
523 HTMLFrameBase2_AddRef
,
524 HTMLFrameBase2_Release
,
525 HTMLFrameBase2_GetTypeInfoCount
,
526 HTMLFrameBase2_GetTypeInfo
,
527 HTMLFrameBase2_GetIDsOfNames
,
528 HTMLFrameBase2_Invoke
,
529 HTMLFrameBase2_get_contentWindow
,
530 HTMLFrameBase2_put_onload
,
531 HTMLFrameBase2_get_onload
,
532 HTMLFrameBase2_put_onreadystatechange
,
533 HTMLFrameBase2_get_onreadystatechange
,
534 HTMLFrameBase2_get_readyState
,
535 HTMLFrameBase2_put_allowTransparency
,
536 HTMLFrameBase2_get_allowTransparency
539 HRESULT
HTMLFrameBase_QI(HTMLFrameBase
*This
, REFIID riid
, void **ppv
)
541 if(IsEqualGUID(&IID_IHTMLFrameBase
, riid
)) {
542 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This
, ppv
);
543 *ppv
= &This
->IHTMLFrameBase_iface
;
544 }else if(IsEqualGUID(&IID_IHTMLFrameBase2
, riid
)) {
545 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This
, ppv
);
546 *ppv
= &This
->IHTMLFrameBase2_iface
;
548 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
551 IUnknown_AddRef((IUnknown
*)*ppv
);
555 void HTMLFrameBase_destructor(HTMLFrameBase
*This
)
557 if(This
->content_window
)
558 This
->content_window
->frame_element
= NULL
;
560 HTMLElement_destructor(&This
->element
.node
);
563 void HTMLFrameBase_Init(HTMLFrameBase
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
,
564 dispex_static_data_t
*dispex_data
)
568 This
->IHTMLFrameBase_iface
.lpVtbl
= &HTMLFrameBaseVtbl
;
569 This
->IHTMLFrameBase2_iface
.lpVtbl
= &HTMLFrameBase2Vtbl
;
571 HTMLElement_Init(&This
->element
, doc
, nselem
, dispex_data
);
573 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLFrameElement
, (void**)&This
->nsframe
);
574 if(NS_FAILED(nsres
)) {
575 This
->nsframe
= NULL
;
576 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLIFrameElement
, (void**)&This
->nsiframe
);
577 assert(nsres
== NS_OK
&& (nsIDOMNode
*)This
->nsiframe
== This
->element
.node
.nsnode
);
579 assert((nsIDOMNode
*)This
->nsframe
== This
->element
.node
.nsnode
);
580 This
->nsiframe
= NULL
;
583 /* Share the reference with nsnode */
584 nsIDOMNode_Release(This
->element
.node
.nsnode
);