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;
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 = HTMLWindow_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);
158 const PRUnichar *strdata;
161 TRACE("(%p)->(%p)\n", This, p);
164 nsAString_Init(&nsstr, NULL);
165 nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
166 }else if(This->nsiframe) {
167 nsAString_Init(&nsstr, NULL);
168 nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
170 ERR("No attached ns frame object\n");
174 if(NS_FAILED(nsres)) {
175 ERR("GetName failed: 0x%08x\n", nsres);
176 nsAString_Finish(&nsstr);
180 nsAString_GetData(&nsstr, &strdata);
182 *p = SysAllocString(strdata);
184 nsAString_Finish(&nsstr);
185 return E_OUTOFMEMORY;
190 nsAString_Finish(&nsstr);
195 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
197 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
198 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
202 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
204 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
205 FIXME("(%p)->(%p)\n", This, p);
209 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
211 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
212 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
216 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
218 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
219 FIXME("(%p)->(%p)\n", This, p);
223 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
225 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
226 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
230 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
232 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
233 FIXME("(%p)->(%p)\n", This, p);
237 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
239 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
240 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
244 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
246 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
247 FIXME("(%p)->(%p)\n", This, p);
251 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
253 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
254 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
258 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
260 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
261 FIXME("(%p)->(%p)\n", This, p);
265 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
267 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
268 FIXME("(%p)->(%x)\n", This, v);
272 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
274 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
275 FIXME("(%p)->(%p)\n", This, p);
279 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
281 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
285 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
287 if(!(!strcmpiW(v, yesW) || !strcmpiW(v, noW) || !strcmpiW(v, autoW)))
291 nsAString_InitDepend(&nsstr, v);
292 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
293 }else if(This->nsiframe) {
294 nsAString_InitDepend(&nsstr, v);
295 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
297 ERR("No attached ns frame object\n");
300 nsAString_Finish(&nsstr);
302 if(NS_FAILED(nsres)) {
303 ERR("SetScrolling failed: 0x%08x\n", nsres);
310 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
312 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
314 const PRUnichar *strdata;
317 TRACE("(%p)->(%p)\n", This, p);
320 nsAString_Init(&nsstr, NULL);
321 nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
322 }else if(This->nsiframe) {
323 nsAString_Init(&nsstr, NULL);
324 nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
326 ERR("No attached ns frame object\n");
330 if(NS_FAILED(nsres)) {
331 ERR("GetScrolling failed: 0x%08x\n", nsres);
332 nsAString_Finish(&nsstr);
336 nsAString_GetData(&nsstr, &strdata);
339 *p = SysAllocString(strdata);
341 *p = SysAllocString(autoW);
343 nsAString_Finish(&nsstr);
345 return *p ? S_OK : E_OUTOFMEMORY;
348 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
349 HTMLFrameBase_QueryInterface,
350 HTMLFrameBase_AddRef,
351 HTMLFrameBase_Release,
352 HTMLFrameBase_GetTypeInfoCount,
353 HTMLFrameBase_GetTypeInfo,
354 HTMLFrameBase_GetIDsOfNames,
355 HTMLFrameBase_Invoke,
356 HTMLFrameBase_put_src,
357 HTMLFrameBase_get_src,
358 HTMLFrameBase_put_name,
359 HTMLFrameBase_get_name,
360 HTMLFrameBase_put_border,
361 HTMLFrameBase_get_border,
362 HTMLFrameBase_put_frameBorder,
363 HTMLFrameBase_get_frameBorder,
364 HTMLFrameBase_put_frameSpacing,
365 HTMLFrameBase_get_frameSpacing,
366 HTMLFrameBase_put_marginWidth,
367 HTMLFrameBase_get_marginWidth,
368 HTMLFrameBase_put_marginHeight,
369 HTMLFrameBase_get_marginHeight,
370 HTMLFrameBase_put_noResize,
371 HTMLFrameBase_get_noResize,
372 HTMLFrameBase_put_scrolling,
373 HTMLFrameBase_get_scrolling
376 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
378 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
381 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
383 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
385 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
388 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
390 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
392 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
395 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
397 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
399 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
402 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
404 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
405 FIXME("(%p)\n", This);
409 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
410 LCID lcid, ITypeInfo **ppTInfo)
412 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
413 FIXME("(%p)\n", This);
417 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
418 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
420 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
421 FIXME("(%p)\n", This);
425 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
426 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
427 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
429 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
430 FIXME("(%p)\n", This);
434 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
436 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
438 TRACE("(%p)->(%p)\n", This, p);
440 if(This->content_window) {
441 IHTMLWindow2_AddRef(&This->content_window->IHTMLWindow2_iface);
442 *p = &This->content_window->IHTMLWindow2_iface;
444 WARN("NULL content window\n");
450 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
452 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
453 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
457 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
459 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
460 FIXME("(%p)->(%p)\n", This, p);
464 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
466 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
467 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
471 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
473 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
474 FIXME("(%p)->(%p)\n", This, p);
478 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
480 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
482 TRACE("(%p)->(%p)\n", This, p);
484 if(!This->content_window || !This->content_window->doc) {
485 FIXME("no document associated\n");
489 return IHTMLDocument2_get_readyState(&This->content_window->doc->basedoc.IHTMLDocument2_iface, p);
492 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
494 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
495 FIXME("(%p)->(%x)\n", This, v);
499 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
501 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
502 FIXME("(%p)->(%p)\n", This, p);
506 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
507 HTMLFrameBase2_QueryInterface,
508 HTMLFrameBase2_AddRef,
509 HTMLFrameBase2_Release,
510 HTMLFrameBase2_GetTypeInfoCount,
511 HTMLFrameBase2_GetTypeInfo,
512 HTMLFrameBase2_GetIDsOfNames,
513 HTMLFrameBase2_Invoke,
514 HTMLFrameBase2_get_contentWindow,
515 HTMLFrameBase2_put_onload,
516 HTMLFrameBase2_get_onload,
517 HTMLFrameBase2_put_onreadystatechange,
518 HTMLFrameBase2_get_onreadystatechange,
519 HTMLFrameBase2_get_readyState,
520 HTMLFrameBase2_put_allowTransparency,
521 HTMLFrameBase2_get_allowTransparency
524 HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
526 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
527 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
528 *ppv = &This->IHTMLFrameBase_iface;
529 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
530 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
531 *ppv = &This->IHTMLFrameBase2_iface;
533 return HTMLElement_QI(&This->element.node, riid, ppv);
536 IUnknown_AddRef((IUnknown*)*ppv);
540 void HTMLFrameBase_destructor(HTMLFrameBase *This)
542 if(This->content_window)
543 This->content_window->frame_element = NULL;
546 nsIDOMHTMLFrameElement_Release(This->nsframe);
548 nsIDOMHTMLIFrameElement_Release(This->nsiframe);
550 HTMLElement_destructor(&This->element.node);
553 void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
554 dispex_static_data_t *dispex_data)
558 This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
559 This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
561 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
563 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
564 if(NS_FAILED(nsres)) {
565 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
567 ERR("Could not get nsIDOMHTML[I]Frame interface\n");
569 This->nsiframe = NULL;