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
;
41 HTMLOuterWindow
*window
;
45 if(frame
->content_window
)
48 nsres
= nsIDOMDocument_GetDefaultView(nsdoc
, &nswindow
);
49 if(NS_FAILED(nsres
) || !nswindow
)
52 window
= nswindow_to_window(nswindow
);
54 hres
= HTMLOuterWindow_Create(frame
->element
.node
.doc
->basedoc
.doc_obj
, nswindow
,
55 frame
->element
.node
.doc
->basedoc
.window
, &window
);
56 nsIDOMWindow_Release(nswindow
);
60 frame
->content_window
= window
;
61 window
->frame_element
= frame
;
65 static inline HTMLFrameBase
*impl_from_IHTMLFrameBase(IHTMLFrameBase
*iface
)
67 return CONTAINING_RECORD(iface
, HTMLFrameBase
, IHTMLFrameBase_iface
);
70 static HRESULT WINAPI
HTMLFrameBase_QueryInterface(IHTMLFrameBase
*iface
, REFIID riid
, void **ppv
)
72 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
74 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
77 static ULONG WINAPI
HTMLFrameBase_AddRef(IHTMLFrameBase
*iface
)
79 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
81 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
84 static ULONG WINAPI
HTMLFrameBase_Release(IHTMLFrameBase
*iface
)
86 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
88 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
91 static HRESULT WINAPI
HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase
*iface
, UINT
*pctinfo
)
93 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
95 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
98 static HRESULT WINAPI
HTMLFrameBase_GetTypeInfo(IHTMLFrameBase
*iface
, UINT iTInfo
,
99 LCID lcid
, ITypeInfo
**ppTInfo
)
101 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
103 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
107 static HRESULT WINAPI
HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase
*iface
, REFIID riid
,
108 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
110 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
112 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
113 cNames
, lcid
, rgDispId
);
116 static HRESULT WINAPI
HTMLFrameBase_Invoke(IHTMLFrameBase
*iface
, DISPID dispIdMember
,
117 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
118 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
120 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
122 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
123 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
126 static HRESULT WINAPI
HTMLFrameBase_put_src(IHTMLFrameBase
*iface
, BSTR v
)
128 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
130 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
132 if(!This
->content_window
|| !This
->element
.node
.doc
|| !This
->element
.node
.doc
->basedoc
.window
) {
133 FIXME("detached element\n");
137 return navigate_url(This
->content_window
, v
, This
->element
.node
.doc
->basedoc
.window
->url
);
140 static HRESULT WINAPI
HTMLFrameBase_get_src(IHTMLFrameBase
*iface
, BSTR
*p
)
142 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
143 FIXME("(%p)->(%p)\n", This
, p
);
147 static HRESULT WINAPI
HTMLFrameBase_put_name(IHTMLFrameBase
*iface
, BSTR v
)
149 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
150 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
154 static HRESULT WINAPI
HTMLFrameBase_get_name(IHTMLFrameBase
*iface
, BSTR
*p
)
156 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
160 TRACE("(%p)->(%p)\n", This
, p
);
162 if(!This
->nsframe
&& !This
->nsiframe
) {
163 ERR("No attached ns frame object\n");
167 nsAString_Init(&nsstr
, NULL
);
169 nsres
= nsIDOMHTMLFrameElement_GetName(This
->nsframe
, &nsstr
);
171 nsres
= nsIDOMHTMLIFrameElement_GetName(This
->nsiframe
, &nsstr
);
172 return return_nsstr(nsres
, &nsstr
, p
);
175 static HRESULT WINAPI
HTMLFrameBase_put_border(IHTMLFrameBase
*iface
, VARIANT v
)
177 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
178 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
182 static HRESULT WINAPI
HTMLFrameBase_get_border(IHTMLFrameBase
*iface
, VARIANT
*p
)
184 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
185 FIXME("(%p)->(%p)\n", This
, p
);
189 static HRESULT WINAPI
HTMLFrameBase_put_frameBorder(IHTMLFrameBase
*iface
, BSTR v
)
191 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
192 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
196 static HRESULT WINAPI
HTMLFrameBase_get_frameBorder(IHTMLFrameBase
*iface
, BSTR
*p
)
198 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLFrameBase_put_frameSpacing(IHTMLFrameBase
*iface
, VARIANT v
)
205 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
206 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
210 static HRESULT WINAPI
HTMLFrameBase_get_frameSpacing(IHTMLFrameBase
*iface
, VARIANT
*p
)
212 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
213 FIXME("(%p)->(%p)\n", This
, p
);
217 static HRESULT WINAPI
HTMLFrameBase_put_marginWidth(IHTMLFrameBase
*iface
, VARIANT v
)
219 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
220 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
224 static HRESULT WINAPI
HTMLFrameBase_get_marginWidth(IHTMLFrameBase
*iface
, VARIANT
*p
)
226 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
227 FIXME("(%p)->(%p)\n", This
, p
);
231 static HRESULT WINAPI
HTMLFrameBase_put_marginHeight(IHTMLFrameBase
*iface
, VARIANT v
)
233 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
234 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
238 static HRESULT WINAPI
HTMLFrameBase_get_marginHeight(IHTMLFrameBase
*iface
, VARIANT
*p
)
240 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
241 FIXME("(%p)->(%p)\n", This
, p
);
245 static HRESULT WINAPI
HTMLFrameBase_put_noResize(IHTMLFrameBase
*iface
, VARIANT_BOOL v
)
247 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
248 FIXME("(%p)->(%x)\n", This
, v
);
252 static HRESULT WINAPI
HTMLFrameBase_get_noResize(IHTMLFrameBase
*iface
, VARIANT_BOOL
*p
)
254 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
255 FIXME("(%p)->(%p)\n", This
, p
);
259 static HRESULT WINAPI
HTMLFrameBase_put_scrolling(IHTMLFrameBase
*iface
, BSTR v
)
261 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
265 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
267 if(!(!strcmpiW(v
, yesW
) || !strcmpiW(v
, noW
) || !strcmpiW(v
, autoW
)))
271 nsAString_InitDepend(&nsstr
, v
);
272 nsres
= nsIDOMHTMLFrameElement_SetScrolling(This
->nsframe
, &nsstr
);
273 }else if(This
->nsiframe
) {
274 nsAString_InitDepend(&nsstr
, v
);
275 nsres
= nsIDOMHTMLIFrameElement_SetScrolling(This
->nsiframe
, &nsstr
);
277 ERR("No attached ns frame object\n");
280 nsAString_Finish(&nsstr
);
282 if(NS_FAILED(nsres
)) {
283 ERR("SetScrolling failed: 0x%08x\n", nsres
);
290 static HRESULT WINAPI
HTMLFrameBase_get_scrolling(IHTMLFrameBase
*iface
, BSTR
*p
)
292 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase(iface
);
294 const PRUnichar
*strdata
;
297 TRACE("(%p)->(%p)\n", This
, p
);
300 nsAString_Init(&nsstr
, NULL
);
301 nsres
= nsIDOMHTMLFrameElement_GetScrolling(This
->nsframe
, &nsstr
);
302 }else if(This
->nsiframe
) {
303 nsAString_Init(&nsstr
, NULL
);
304 nsres
= nsIDOMHTMLIFrameElement_GetScrolling(This
->nsiframe
, &nsstr
);
306 ERR("No attached ns frame object\n");
310 if(NS_FAILED(nsres
)) {
311 ERR("GetScrolling failed: 0x%08x\n", nsres
);
312 nsAString_Finish(&nsstr
);
316 nsAString_GetData(&nsstr
, &strdata
);
319 *p
= SysAllocString(strdata
);
321 *p
= SysAllocString(autoW
);
323 nsAString_Finish(&nsstr
);
325 return *p
? S_OK
: E_OUTOFMEMORY
;
328 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl
= {
329 HTMLFrameBase_QueryInterface
,
330 HTMLFrameBase_AddRef
,
331 HTMLFrameBase_Release
,
332 HTMLFrameBase_GetTypeInfoCount
,
333 HTMLFrameBase_GetTypeInfo
,
334 HTMLFrameBase_GetIDsOfNames
,
335 HTMLFrameBase_Invoke
,
336 HTMLFrameBase_put_src
,
337 HTMLFrameBase_get_src
,
338 HTMLFrameBase_put_name
,
339 HTMLFrameBase_get_name
,
340 HTMLFrameBase_put_border
,
341 HTMLFrameBase_get_border
,
342 HTMLFrameBase_put_frameBorder
,
343 HTMLFrameBase_get_frameBorder
,
344 HTMLFrameBase_put_frameSpacing
,
345 HTMLFrameBase_get_frameSpacing
,
346 HTMLFrameBase_put_marginWidth
,
347 HTMLFrameBase_get_marginWidth
,
348 HTMLFrameBase_put_marginHeight
,
349 HTMLFrameBase_get_marginHeight
,
350 HTMLFrameBase_put_noResize
,
351 HTMLFrameBase_get_noResize
,
352 HTMLFrameBase_put_scrolling
,
353 HTMLFrameBase_get_scrolling
356 static inline HTMLFrameBase
*impl_from_IHTMLFrameBase2(IHTMLFrameBase2
*iface
)
358 return CONTAINING_RECORD(iface
, HTMLFrameBase
, IHTMLFrameBase2_iface
);
361 static HRESULT WINAPI
HTMLFrameBase2_QueryInterface(IHTMLFrameBase2
*iface
, REFIID riid
, void **ppv
)
363 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
365 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
368 static ULONG WINAPI
HTMLFrameBase2_AddRef(IHTMLFrameBase2
*iface
)
370 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
372 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
375 static ULONG WINAPI
HTMLFrameBase2_Release(IHTMLFrameBase2
*iface
)
377 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
379 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
382 static HRESULT WINAPI
HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2
*iface
, UINT
*pctinfo
)
384 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
385 FIXME("(%p)\n", This
);
389 static HRESULT WINAPI
HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2
*iface
, UINT iTInfo
,
390 LCID lcid
, ITypeInfo
**ppTInfo
)
392 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
393 FIXME("(%p)\n", This
);
397 static HRESULT WINAPI
HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2
*iface
, REFIID riid
,
398 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
400 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
401 FIXME("(%p)\n", This
);
405 static HRESULT WINAPI
HTMLFrameBase2_Invoke(IHTMLFrameBase2
*iface
, DISPID dispIdMember
,
406 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
407 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
409 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
410 FIXME("(%p)\n", This
);
414 static HRESULT WINAPI
HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2
*iface
, IHTMLWindow2
**p
)
416 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
418 TRACE("(%p)->(%p)\n", This
, p
);
420 if(This
->content_window
) {
421 IHTMLWindow2_AddRef(&This
->content_window
->base
.IHTMLWindow2_iface
);
422 *p
= &This
->content_window
->base
.IHTMLWindow2_iface
;
424 WARN("NULL content window\n");
430 static HRESULT WINAPI
HTMLFrameBase2_put_onload(IHTMLFrameBase2
*iface
, VARIANT v
)
432 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
433 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
437 static HRESULT WINAPI
HTMLFrameBase2_get_onload(IHTMLFrameBase2
*iface
, VARIANT
*p
)
439 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
440 FIXME("(%p)->(%p)\n", This
, p
);
444 static HRESULT WINAPI
HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT v
)
446 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
447 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
451 static HRESULT WINAPI
HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2
*iface
, VARIANT
*p
)
453 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
454 FIXME("(%p)->(%p)\n", This
, p
);
458 static HRESULT WINAPI
HTMLFrameBase2_get_readyState(IHTMLFrameBase2
*iface
, BSTR
*p
)
460 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
462 TRACE("(%p)->(%p)\n", This
, p
);
464 if(!This
->content_window
|| !This
->content_window
->doc
) {
465 FIXME("no document associated\n");
469 return IHTMLDocument2_get_readyState(&This
->content_window
->doc
->basedoc
.IHTMLDocument2_iface
, p
);
472 static HRESULT WINAPI
HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL v
)
474 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
475 FIXME("(%p)->(%x)\n", This
, v
);
479 static HRESULT WINAPI
HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2
*iface
, VARIANT_BOOL
*p
)
481 HTMLFrameBase
*This
= impl_from_IHTMLFrameBase2(iface
);
482 FIXME("(%p)->(%p)\n", This
, p
);
486 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl
= {
487 HTMLFrameBase2_QueryInterface
,
488 HTMLFrameBase2_AddRef
,
489 HTMLFrameBase2_Release
,
490 HTMLFrameBase2_GetTypeInfoCount
,
491 HTMLFrameBase2_GetTypeInfo
,
492 HTMLFrameBase2_GetIDsOfNames
,
493 HTMLFrameBase2_Invoke
,
494 HTMLFrameBase2_get_contentWindow
,
495 HTMLFrameBase2_put_onload
,
496 HTMLFrameBase2_get_onload
,
497 HTMLFrameBase2_put_onreadystatechange
,
498 HTMLFrameBase2_get_onreadystatechange
,
499 HTMLFrameBase2_get_readyState
,
500 HTMLFrameBase2_put_allowTransparency
,
501 HTMLFrameBase2_get_allowTransparency
504 HRESULT
HTMLFrameBase_QI(HTMLFrameBase
*This
, REFIID riid
, void **ppv
)
506 if(IsEqualGUID(&IID_IHTMLFrameBase
, riid
)) {
507 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This
, ppv
);
508 *ppv
= &This
->IHTMLFrameBase_iface
;
509 }else if(IsEqualGUID(&IID_IHTMLFrameBase2
, riid
)) {
510 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This
, ppv
);
511 *ppv
= &This
->IHTMLFrameBase2_iface
;
513 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
516 IUnknown_AddRef((IUnknown
*)*ppv
);
520 void HTMLFrameBase_destructor(HTMLFrameBase
*This
)
522 if(This
->content_window
)
523 This
->content_window
->frame_element
= NULL
;
526 nsIDOMHTMLFrameElement_Release(This
->nsframe
);
528 nsIDOMHTMLIFrameElement_Release(This
->nsiframe
);
530 HTMLElement_destructor(&This
->element
.node
);
533 void HTMLFrameBase_Init(HTMLFrameBase
*This
, HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
,
534 dispex_static_data_t
*dispex_data
)
538 This
->IHTMLFrameBase_iface
.lpVtbl
= &HTMLFrameBaseVtbl
;
539 This
->IHTMLFrameBase2_iface
.lpVtbl
= &HTMLFrameBase2Vtbl
;
541 HTMLElement_Init(&This
->element
, doc
, nselem
, dispex_data
);
543 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLFrameElement
, (void**)&This
->nsframe
);
544 if(NS_FAILED(nsres
)) {
545 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLIFrameElement
, (void**)&This
->nsiframe
);
547 ERR("Could not get nsIDOMHTML[I]Frame interface\n");
549 This
->nsiframe
= NULL
;