Release 6.15.
[wine.git] / dlls / mshtml / htmlframe.c
blob7118ea86b57a6ccba684df8a5f5cdef673073b93
1 /*
2 * Copyright 2008,2010 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"
29 #include "binding.h"
30 #include "htmlevent.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 static HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
38 mozIDOMWindowProxy *mozwindow;
39 HTMLOuterWindow *window;
40 nsresult nsres;
41 HRESULT hres = S_OK;
43 if(frame->content_window)
44 return S_OK;
46 nsres = nsIDOMDocument_GetDefaultView(nsdoc, &mozwindow);
47 if(NS_FAILED(nsres) || !mozwindow)
48 return E_FAIL;
50 window = mozwindow_to_window(mozwindow);
51 if(!window && frame->element.node.doc->browser)
52 hres = create_outer_window(frame->element.node.doc->browser, mozwindow,
53 frame->element.node.doc->basedoc.window, &window);
54 mozIDOMWindowProxy_Release(mozwindow);
55 if(FAILED(hres))
56 return hres;
58 frame->content_window = window;
59 window->frame_element = frame;
60 return S_OK;
63 static inline HTMLFrameBase *impl_from_IHTMLFrameBase(IHTMLFrameBase *iface)
65 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase_iface);
68 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
70 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
72 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
75 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
77 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
79 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
82 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
84 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
86 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
89 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
91 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
93 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
96 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
97 LCID lcid, ITypeInfo **ppTInfo)
99 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
101 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
102 ppTInfo);
105 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
106 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
108 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
110 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
111 cNames, lcid, rgDispId);
114 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
115 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
116 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
118 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
120 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
121 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
124 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
126 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
128 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
130 if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
131 nsAString nsstr;
132 nsresult nsres;
134 nsAString_InitDepend(&nsstr, v);
135 if(This->nsframe)
136 nsres = nsIDOMHTMLFrameElement_SetSrc(This->nsframe, &nsstr);
137 else
138 nsres = nsIDOMHTMLIFrameElement_SetSrc(This->nsiframe, &nsstr);
139 nsAString_Finish(&nsstr);
140 if(NS_FAILED(nsres)) {
141 ERR("SetSrc failed: %08x\n", nsres);
142 return E_FAIL;
145 return S_OK;
148 return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->uri, BINDING_NAVIGATED);
151 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
153 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
154 nsAString nsstr;
155 nsresult nsres;
157 TRACE("(%p)->(%p)\n", This, p);
159 if(!This->nsframe && !This->nsiframe) {
160 ERR("No attached frame object\n");
161 return E_UNEXPECTED;
164 nsAString_Init(&nsstr, NULL);
165 if(This->nsframe)
166 nsres = nsIDOMHTMLFrameElement_GetSrc(This->nsframe, &nsstr);
167 else
168 nsres = nsIDOMHTMLIFrameElement_GetSrc(This->nsiframe, &nsstr);
169 return return_nsstr(nsres, &nsstr, p);
172 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
174 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
175 nsAString name_str;
176 nsresult nsres;
178 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
180 if(!This->nsframe && !This->nsiframe) {
181 ERR("No attached ns frame object\n");
182 return E_UNEXPECTED;
185 nsAString_InitDepend(&name_str, v);
186 if(This->nsframe)
187 nsres = nsIDOMHTMLFrameElement_SetName(This->nsframe, &name_str);
188 else
189 nsres = nsIDOMHTMLIFrameElement_SetName(This->nsiframe, &name_str);
190 nsAString_Finish(&name_str);
191 if(NS_FAILED(nsres)) {
192 ERR("SetName failed: %08x\n", nsres);
193 return E_FAIL;
196 return S_OK;
199 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
201 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
202 nsAString nsstr;
203 nsresult nsres;
205 TRACE("(%p)->(%p)\n", This, p);
207 if(!This->nsframe && !This->nsiframe) {
208 ERR("No attached ns frame object\n");
209 return E_UNEXPECTED;
212 nsAString_Init(&nsstr, NULL);
213 if(This->nsframe)
214 nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
215 else
216 nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
217 return return_nsstr(nsres, &nsstr, p);
220 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
222 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
223 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
224 return E_NOTIMPL;
227 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
229 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
230 FIXME("(%p)->(%p)\n", This, p);
231 return E_NOTIMPL;
234 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
236 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
237 nsAString nsstr;
238 nsresult nsres;
240 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
242 if(!This->nsframe && !This->nsiframe) {
243 ERR("No attached ns frame object\n");
244 return E_UNEXPECTED;
247 nsAString_InitDepend(&nsstr, v);
248 if(This->nsframe)
249 nsres = nsIDOMHTMLFrameElement_SetFrameBorder(This->nsframe, &nsstr);
250 else
251 nsres = nsIDOMHTMLIFrameElement_SetFrameBorder(This->nsiframe, &nsstr);
252 nsAString_Finish(&nsstr);
253 if(NS_FAILED(nsres)) {
254 ERR("SetFrameBorder failed: %08x\n", nsres);
255 return E_FAIL;
258 return S_OK;
261 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
263 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
264 nsAString nsstr;
265 nsresult nsres;
267 TRACE("(%p)->(%p)\n", This, p);
269 if(!This->nsframe && !This->nsiframe) {
270 ERR("No attached ns frame object\n");
271 return E_UNEXPECTED;
274 nsAString_Init(&nsstr, NULL);
275 if(This->nsframe)
276 nsres = nsIDOMHTMLFrameElement_GetFrameBorder(This->nsframe, &nsstr);
277 else
278 nsres = nsIDOMHTMLIFrameElement_GetFrameBorder(This->nsiframe, &nsstr);
279 return return_nsstr(nsres, &nsstr, p);
282 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
284 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
285 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
286 return E_NOTIMPL;
289 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
291 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
292 FIXME("(%p)->(%p)\n", This, p);
293 return E_NOTIMPL;
296 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
298 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
299 nsAString nsstr;
300 nsresult nsres;
302 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
304 if(V_VT(&v) != VT_BSTR) {
305 FIXME("unsupported %s\n", debugstr_variant(&v));
306 return E_NOTIMPL;
309 nsAString_InitDepend(&nsstr, V_BSTR(&v));
310 if(This->nsframe)
311 nsres = nsIDOMHTMLFrameElement_SetMarginWidth(This->nsframe, &nsstr);
312 else
313 nsres = nsIDOMHTMLIFrameElement_SetMarginWidth(This->nsiframe, &nsstr);
314 nsAString_Finish(&nsstr);
315 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
318 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
320 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
321 nsAString nsstr;
322 nsresult nsres;
323 HRESULT hres = S_OK;
325 TRACE("(%p)->(%p)\n", This, p);
327 nsAString_Init(&nsstr, NULL);
328 if(This->nsframe)
329 nsres = nsIDOMHTMLFrameElement_GetMarginWidth(This->nsframe, &nsstr);
330 else
331 nsres = nsIDOMHTMLIFrameElement_GetMarginWidth(This->nsiframe, &nsstr);
332 if(NS_SUCCEEDED(nsres)) {
333 const PRUnichar *str, *end;
335 nsAString_GetData(&nsstr, &str);
337 if(*str) {
338 BSTR ret;
340 end = wcsstr(str, L"px");
341 if(!end)
342 end = str+lstrlenW(str);
343 ret = SysAllocStringLen(str, end-str);
344 if(ret) {
345 V_VT(p) = VT_BSTR;
346 V_BSTR(p) = ret;
347 }else {
348 hres = E_OUTOFMEMORY;
350 }else {
351 V_VT(p) = VT_BSTR;
352 V_BSTR(p) = NULL;
354 }else {
355 ERR("GetMarginWidth failed: %08x\n", nsres);
356 hres = E_FAIL;
359 nsAString_Finish(&nsstr);
360 return hres;
363 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
365 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
366 nsAString nsstr;
367 nsresult nsres;
369 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
371 if(V_VT(&v) != VT_BSTR) {
372 FIXME("unsupported %s\n", debugstr_variant(&v));
373 return E_NOTIMPL;
376 nsAString_InitDepend(&nsstr, V_BSTR(&v));
377 if(This->nsframe)
378 nsres = nsIDOMHTMLFrameElement_SetMarginHeight(This->nsframe, &nsstr);
379 else
380 nsres = nsIDOMHTMLIFrameElement_SetMarginHeight(This->nsiframe, &nsstr);
381 nsAString_Finish(&nsstr);
382 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
385 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
387 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
388 nsAString nsstr;
389 nsresult nsres;
390 HRESULT hres = S_OK;
392 TRACE("(%p)->(%p)\n", This, p);
394 nsAString_Init(&nsstr, NULL);
395 if(This->nsframe)
396 nsres = nsIDOMHTMLFrameElement_GetMarginHeight(This->nsframe, &nsstr);
397 else
398 nsres = nsIDOMHTMLIFrameElement_GetMarginHeight(This->nsiframe, &nsstr);
399 if(NS_SUCCEEDED(nsres)) {
400 const PRUnichar *str, *end;
402 nsAString_GetData(&nsstr, &str);
404 if(*str) {
405 BSTR ret;
407 end = wcsstr(str, L"px");
408 if(!end)
409 end = str+lstrlenW(str);
410 ret = SysAllocStringLen(str, end-str);
411 if(ret) {
412 V_VT(p) = VT_BSTR;
413 V_BSTR(p) = ret;
414 }else {
415 hres = E_OUTOFMEMORY;
417 }else {
418 V_VT(p) = VT_BSTR;
419 V_BSTR(p) = NULL;
421 }else {
422 ERR("SetMarginHeight failed: %08x\n", nsres);
423 hres = E_FAIL;
426 nsAString_Finish(&nsstr);
427 return hres;
430 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
432 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
433 FIXME("(%p)->(%x)\n", This, v);
434 return E_NOTIMPL;
437 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
439 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
440 FIXME("(%p)->(%p)\n", This, p);
441 return E_NOTIMPL;
444 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
446 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
447 nsAString nsstr;
448 nsresult nsres;
450 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
452 if(!(!wcsicmp(v, L"yes") || !wcsicmp(v, L"no") || !wcsicmp(v, L"auto")))
453 return E_INVALIDARG;
455 if(This->nsframe) {
456 nsAString_InitDepend(&nsstr, v);
457 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
458 }else if(This->nsiframe) {
459 nsAString_InitDepend(&nsstr, v);
460 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
461 }else {
462 ERR("No attached ns frame object\n");
463 return E_UNEXPECTED;
465 nsAString_Finish(&nsstr);
467 if(NS_FAILED(nsres)) {
468 ERR("SetScrolling failed: 0x%08x\n", nsres);
469 return E_FAIL;
472 return S_OK;
475 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
477 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
478 nsAString nsstr;
479 const PRUnichar *strdata;
480 nsresult nsres;
482 TRACE("(%p)->(%p)\n", This, p);
484 if(This->nsframe) {
485 nsAString_Init(&nsstr, NULL);
486 nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
487 }else if(This->nsiframe) {
488 nsAString_Init(&nsstr, NULL);
489 nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
490 }else {
491 ERR("No attached ns frame object\n");
492 return E_UNEXPECTED;
495 if(NS_FAILED(nsres)) {
496 ERR("GetScrolling failed: 0x%08x\n", nsres);
497 nsAString_Finish(&nsstr);
498 return E_FAIL;
501 nsAString_GetData(&nsstr, &strdata);
503 if(*strdata)
504 *p = SysAllocString(strdata);
505 else
506 *p = SysAllocString(L"auto");
508 nsAString_Finish(&nsstr);
510 return *p ? S_OK : E_OUTOFMEMORY;
513 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
514 HTMLFrameBase_QueryInterface,
515 HTMLFrameBase_AddRef,
516 HTMLFrameBase_Release,
517 HTMLFrameBase_GetTypeInfoCount,
518 HTMLFrameBase_GetTypeInfo,
519 HTMLFrameBase_GetIDsOfNames,
520 HTMLFrameBase_Invoke,
521 HTMLFrameBase_put_src,
522 HTMLFrameBase_get_src,
523 HTMLFrameBase_put_name,
524 HTMLFrameBase_get_name,
525 HTMLFrameBase_put_border,
526 HTMLFrameBase_get_border,
527 HTMLFrameBase_put_frameBorder,
528 HTMLFrameBase_get_frameBorder,
529 HTMLFrameBase_put_frameSpacing,
530 HTMLFrameBase_get_frameSpacing,
531 HTMLFrameBase_put_marginWidth,
532 HTMLFrameBase_get_marginWidth,
533 HTMLFrameBase_put_marginHeight,
534 HTMLFrameBase_get_marginHeight,
535 HTMLFrameBase_put_noResize,
536 HTMLFrameBase_get_noResize,
537 HTMLFrameBase_put_scrolling,
538 HTMLFrameBase_get_scrolling
541 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
543 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
546 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
548 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
550 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
553 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
555 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
557 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
560 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
562 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
564 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
567 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
569 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
570 FIXME("(%p)\n", This);
571 return E_NOTIMPL;
574 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
575 LCID lcid, ITypeInfo **ppTInfo)
577 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
578 FIXME("(%p)\n", This);
579 return E_NOTIMPL;
582 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
583 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
585 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
586 FIXME("(%p)\n", This);
587 return E_NOTIMPL;
590 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
591 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
592 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
594 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
595 FIXME("(%p)\n", This);
596 return E_NOTIMPL;
599 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
601 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
603 TRACE("(%p)->(%p)\n", This, p);
605 if(This->content_window) {
606 IHTMLWindow2_AddRef(&This->content_window->base.IHTMLWindow2_iface);
607 *p = &This->content_window->base.IHTMLWindow2_iface;
608 }else {
609 WARN("NULL content window\n");
610 *p = NULL;
612 return S_OK;
615 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
617 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
619 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
621 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
624 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
626 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
628 TRACE("(%p)->(%p)\n", This, p);
630 return get_node_event(&This->element.node, EVENTID_LOAD, p);
633 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
635 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
636 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
637 return E_NOTIMPL;
640 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
642 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
643 FIXME("(%p)->(%p)\n", This, p);
644 return E_NOTIMPL;
647 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
649 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
651 TRACE("(%p)->(%p)\n", This, p);
653 if(!This->content_window || !This->content_window->base.inner_window->doc) {
654 FIXME("no document associated\n");
655 return E_FAIL;
658 return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface, p);
661 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
663 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
665 FIXME("(%p)->(%x) semi-stub\n", This, v);
667 return S_OK;
670 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
672 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
674 FIXME("(%p)->(%p) semi-stub\n", This, p);
676 *p = VARIANT_TRUE;
677 return S_OK;
680 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
681 HTMLFrameBase2_QueryInterface,
682 HTMLFrameBase2_AddRef,
683 HTMLFrameBase2_Release,
684 HTMLFrameBase2_GetTypeInfoCount,
685 HTMLFrameBase2_GetTypeInfo,
686 HTMLFrameBase2_GetIDsOfNames,
687 HTMLFrameBase2_Invoke,
688 HTMLFrameBase2_get_contentWindow,
689 HTMLFrameBase2_put_onload,
690 HTMLFrameBase2_get_onload,
691 HTMLFrameBase2_put_onreadystatechange,
692 HTMLFrameBase2_get_onreadystatechange,
693 HTMLFrameBase2_get_readyState,
694 HTMLFrameBase2_put_allowTransparency,
695 HTMLFrameBase2_get_allowTransparency
698 static HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
700 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
701 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
702 *ppv = &This->IHTMLFrameBase_iface;
703 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
704 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
705 *ppv = &This->IHTMLFrameBase2_iface;
706 }else {
707 return HTMLElement_QI(&This->element.node, riid, ppv);
710 IUnknown_AddRef((IUnknown*)*ppv);
711 return S_OK;
714 static void HTMLFrameBase_destructor(HTMLFrameBase *This)
716 if(This->content_window)
717 This->content_window->frame_element = NULL;
719 HTMLElement_destructor(&This->element.node);
722 static void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMElement *nselem,
723 dispex_static_data_t *dispex_data)
725 nsresult nsres;
727 This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
728 This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
730 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
732 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
733 if(NS_FAILED(nsres)) {
734 This->nsframe = NULL;
735 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
736 assert(nsres == NS_OK);
737 }else {
738 This->nsiframe = NULL;
742 struct HTMLFrameElement {
743 HTMLFrameBase framebase;
744 IHTMLFrameElement3 IHTMLFrameElement3_iface;
747 static inline HTMLFrameElement *impl_from_IHTMLFrameElement3(IHTMLFrameElement3 *iface)
749 return CONTAINING_RECORD(iface, HTMLFrameElement, IHTMLFrameElement3_iface);
752 static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface,
753 REFIID riid, void **ppv)
755 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
757 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
760 static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface)
762 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
764 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
767 static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface)
769 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
771 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
774 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo)
776 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
777 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
778 pctinfo);
781 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo,
782 LCID lcid, ITypeInfo **ppTInfo)
784 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
785 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
786 lcid, ppTInfo);
789 static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid,
790 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
792 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
793 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
794 rgszNames, cNames, lcid, rgDispId);
797 static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember,
798 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
799 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
801 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
802 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
803 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
806 static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p)
808 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
809 IHTMLDocument2 *doc;
810 HRESULT hres;
812 TRACE("(%p)->(%p)\n", This, p);
814 if(!This->framebase.content_window) {
815 FIXME("NULL window\n");
816 return E_FAIL;
819 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
820 if(FAILED(hres))
821 return hres;
823 *p = doc ? (IDispatch*)doc : NULL;
824 return S_OK;
827 static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v)
829 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
830 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
831 return E_NOTIMPL;
834 static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p)
836 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
837 FIXME("(%p)->(%p)\n", This, p);
838 return E_NOTIMPL;
841 static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v)
843 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
844 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
845 return E_NOTIMPL;
848 static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p)
850 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
851 FIXME("(%p)->(%p)\n", This, p);
852 return E_NOTIMPL;
855 static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v)
857 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
858 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
859 return E_NOTIMPL;
862 static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p)
864 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
865 FIXME("(%p)->(%p)\n", This, p);
866 return E_NOTIMPL;
869 static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = {
870 HTMLFrameElement3_QueryInterface,
871 HTMLFrameElement3_AddRef,
872 HTMLFrameElement3_Release,
873 HTMLFrameElement3_GetTypeInfoCount,
874 HTMLFrameElement3_GetTypeInfo,
875 HTMLFrameElement3_GetIDsOfNames,
876 HTMLFrameElement3_Invoke,
877 HTMLFrameElement3_get_contentDocument,
878 HTMLFrameElement3_put_src,
879 HTMLFrameElement3_get_src,
880 HTMLFrameElement3_put_longDesc,
881 HTMLFrameElement3_get_longDesc,
882 HTMLFrameElement3_put_frameBorder,
883 HTMLFrameElement3_get_frameBorder
886 static inline HTMLFrameElement *frame_from_HTMLDOMNode(HTMLDOMNode *iface)
888 return CONTAINING_RECORD(iface, HTMLFrameElement, framebase.element.node);
891 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
893 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
895 if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) {
896 TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv);
897 *ppv = &This->IHTMLFrameElement3_iface;
898 }else {
899 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
902 IUnknown_AddRef((IUnknown*)*ppv);
903 return S_OK;
906 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
908 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
910 HTMLFrameBase_destructor(&This->framebase);
913 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
915 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
917 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
918 *p = NULL;
919 return S_OK;
922 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
923 IDispatch_AddRef(*p);
924 return S_OK;
927 static HRESULT HTMLFrameElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
929 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
931 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
934 static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
935 DWORD grfdex, DISPID *pid)
937 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
939 if(!This->framebase.content_window)
940 return DISP_E_UNKNOWNNAME;
942 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
945 static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
946 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
948 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
950 if(!This->framebase.content_window) {
951 ERR("no content window to invoke on\n");
952 return E_FAIL;
955 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
956 flags, params, res, ei, caller);
959 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
961 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
962 nsIDOMDocument *nsdoc;
963 nsresult nsres;
964 HRESULT hres;
966 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
967 if(NS_FAILED(nsres) || !nsdoc) {
968 ERR("GetContentDocument failed: %08x\n", nsres);
969 return E_FAIL;
972 hres = set_frame_doc(&This->framebase, nsdoc);
973 nsIDOMDocument_Release(nsdoc);
974 return hres;
977 static void HTMLFrameElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
979 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
981 if(This->framebase.nsframe)
982 note_cc_edge((nsISupports*)This->framebase.nsframe, "This->nsframe", cb);
985 static void HTMLFrameElement_unlink(HTMLDOMNode *iface)
987 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
989 if(This->framebase.nsframe) {
990 nsIDOMHTMLFrameElement *nsframe = This->framebase.nsframe;
992 This->framebase.nsframe = NULL;
993 nsIDOMHTMLFrameElement_Release(nsframe);
997 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
998 &CLSID_HTMLFrameElement,
999 HTMLFrameElement_QI,
1000 HTMLFrameElement_destructor,
1001 HTMLElement_cpc,
1002 HTMLElement_clone,
1003 HTMLElement_handle_event,
1004 HTMLElement_get_attr_col,
1005 NULL,
1006 NULL,
1007 NULL,
1008 HTMLFrameElement_get_document,
1009 HTMLFrameElement_get_readystate,
1010 HTMLFrameElement_get_dispid,
1011 HTMLFrameElement_invoke,
1012 HTMLFrameElement_bind_to_tree,
1013 HTMLFrameElement_traverse,
1014 HTMLFrameElement_unlink
1017 static const tid_t HTMLFrameElement_iface_tids[] = {
1018 HTMLELEMENT_TIDS,
1019 IHTMLFrameBase_tid,
1020 IHTMLFrameBase2_tid,
1021 IHTMLFrameElement3_tid,
1025 static dispex_static_data_t HTMLFrameElement_dispex = {
1026 NULL,
1027 DispHTMLFrameElement_tid,
1028 HTMLFrameElement_iface_tids,
1029 HTMLElement_init_dispex_info
1032 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1034 HTMLFrameElement *ret;
1036 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
1037 if(!ret)
1038 return E_OUTOFMEMORY;
1040 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
1041 ret->IHTMLFrameElement3_iface.lpVtbl = &HTMLFrameElement3Vtbl;
1043 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex);
1045 *elem = &ret->framebase.element;
1046 return S_OK;
1049 struct HTMLIFrame {
1050 HTMLFrameBase framebase;
1051 IHTMLIFrameElement IHTMLIFrameElement_iface;
1052 IHTMLIFrameElement2 IHTMLIFrameElement2_iface;
1053 IHTMLIFrameElement3 IHTMLIFrameElement3_iface;
1056 static inline HTMLIFrame *impl_from_IHTMLIFrameElement(IHTMLIFrameElement *iface)
1058 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement_iface);
1061 static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface,
1062 REFIID riid, void **ppv)
1064 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1066 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1069 static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface)
1071 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1073 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1076 static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface)
1078 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1080 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1083 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo)
1085 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1086 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1087 pctinfo);
1090 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo,
1091 LCID lcid, ITypeInfo **ppTInfo)
1093 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1094 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1095 lcid, ppTInfo);
1098 static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid,
1099 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1101 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1102 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1103 rgszNames, cNames, lcid, rgDispId);
1106 static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember,
1107 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1108 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1110 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1111 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1112 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1115 static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v)
1117 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1118 FIXME("(%p)->(%d)\n", This, v);
1119 return E_NOTIMPL;
1122 static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p)
1124 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1125 FIXME("(%p)->(%p)\n", This, p);
1126 return E_NOTIMPL;
1129 static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v)
1131 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1132 FIXME("(%p)->(%d)\n", This, v);
1133 return E_NOTIMPL;
1136 static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p)
1138 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1139 FIXME("(%p)->(%p)\n", This, p);
1140 return E_NOTIMPL;
1143 static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v)
1145 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1146 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1147 return E_NOTIMPL;
1150 static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p)
1152 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1153 FIXME("(%p)->(%p)\n", This, p);
1154 return E_NOTIMPL;
1157 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = {
1158 HTMLIFrameElement_QueryInterface,
1159 HTMLIFrameElement_AddRef,
1160 HTMLIFrameElement_Release,
1161 HTMLIFrameElement_GetTypeInfoCount,
1162 HTMLIFrameElement_GetTypeInfo,
1163 HTMLIFrameElement_GetIDsOfNames,
1164 HTMLIFrameElement_Invoke,
1165 HTMLIFrameElement_put_vspace,
1166 HTMLIFrameElement_get_vspace,
1167 HTMLIFrameElement_put_hspace,
1168 HTMLIFrameElement_get_hspace,
1169 HTMLIFrameElement_put_align,
1170 HTMLIFrameElement_get_align
1173 static inline HTMLIFrame *impl_from_IHTMLIFrameElement2(IHTMLIFrameElement2 *iface)
1175 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement2_iface);
1178 static HRESULT WINAPI HTMLIFrameElement2_QueryInterface(IHTMLIFrameElement2 *iface,
1179 REFIID riid, void **ppv)
1181 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1183 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1186 static ULONG WINAPI HTMLIFrameElement2_AddRef(IHTMLIFrameElement2 *iface)
1188 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1190 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1193 static ULONG WINAPI HTMLIFrameElement2_Release(IHTMLIFrameElement2 *iface)
1195 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1197 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1200 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfoCount(IHTMLIFrameElement2 *iface, UINT *pctinfo)
1202 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1203 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1204 pctinfo);
1207 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfo(IHTMLIFrameElement2 *iface, UINT iTInfo,
1208 LCID lcid, ITypeInfo **ppTInfo)
1210 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1211 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1212 lcid, ppTInfo);
1215 static HRESULT WINAPI HTMLIFrameElement2_GetIDsOfNames(IHTMLIFrameElement2 *iface, REFIID riid,
1216 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1218 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1219 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1220 rgszNames, cNames, lcid, rgDispId);
1223 static HRESULT WINAPI HTMLIFrameElement2_Invoke(IHTMLIFrameElement2 *iface, DISPID dispIdMember,
1224 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1225 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1227 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1228 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1229 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1232 static HRESULT WINAPI HTMLIFrameElement2_put_height(IHTMLIFrameElement2 *iface, VARIANT v)
1234 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1235 nsAString nsstr;
1236 nsresult nsres;
1237 HRESULT hres;
1239 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1241 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1242 if(FAILED(hres))
1243 return hres;
1245 nsres = nsIDOMHTMLIFrameElement_SetHeight(This->framebase.nsiframe, &nsstr);
1246 nsAString_Finish(&nsstr);
1247 if(NS_FAILED(nsres)) {
1248 ERR("SetHeight failed: %08x\n", nsres);
1249 return E_FAIL;
1252 return S_OK;
1255 static HRESULT WINAPI HTMLIFrameElement2_get_height(IHTMLIFrameElement2 *iface, VARIANT *p)
1257 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1258 nsAString nsstr;
1259 nsresult nsres;
1261 TRACE("(%p)->(%p)\n", This, p);
1263 nsAString_Init(&nsstr, NULL);
1264 nsres = nsIDOMHTMLIFrameElement_GetHeight(This->framebase.nsiframe, &nsstr);
1266 V_VT(p) = VT_BSTR;
1267 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1270 static HRESULT WINAPI HTMLIFrameElement2_put_width(IHTMLIFrameElement2 *iface, VARIANT v)
1272 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1273 nsAString nsstr;
1274 nsresult nsres;
1275 HRESULT hres;
1277 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1279 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1280 if(FAILED(hres))
1281 return hres;
1283 nsres = nsIDOMHTMLIFrameElement_SetWidth(This->framebase.nsiframe, &nsstr);
1284 nsAString_Finish(&nsstr);
1285 if(NS_FAILED(nsres)) {
1286 ERR("SetWidth failed: %08x\n", nsres);
1287 return E_FAIL;
1290 return S_OK;
1293 static HRESULT WINAPI HTMLIFrameElement2_get_width(IHTMLIFrameElement2 *iface, VARIANT *p)
1295 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1296 nsAString nsstr;
1297 nsresult nsres;
1299 TRACE("(%p)->(%p)\n", This, p);
1301 nsAString_Init(&nsstr, NULL);
1302 nsres = nsIDOMHTMLIFrameElement_GetWidth(This->framebase.nsiframe, &nsstr);
1304 V_VT(p) = VT_BSTR;
1305 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1308 static const IHTMLIFrameElement2Vtbl HTMLIFrameElement2Vtbl = {
1309 HTMLIFrameElement2_QueryInterface,
1310 HTMLIFrameElement2_AddRef,
1311 HTMLIFrameElement2_Release,
1312 HTMLIFrameElement2_GetTypeInfoCount,
1313 HTMLIFrameElement2_GetTypeInfo,
1314 HTMLIFrameElement2_GetIDsOfNames,
1315 HTMLIFrameElement2_Invoke,
1316 HTMLIFrameElement2_put_height,
1317 HTMLIFrameElement2_get_height,
1318 HTMLIFrameElement2_put_width,
1319 HTMLIFrameElement2_get_width
1322 static inline HTMLIFrame *impl_from_IHTMLIFrameElement3(IHTMLIFrameElement3 *iface)
1324 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement3_iface);
1327 static HRESULT WINAPI HTMLIFrameElement3_QueryInterface(IHTMLIFrameElement3 *iface,
1328 REFIID riid, void **ppv)
1330 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1332 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1335 static ULONG WINAPI HTMLIFrameElement3_AddRef(IHTMLIFrameElement3 *iface)
1337 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1339 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1342 static ULONG WINAPI HTMLIFrameElement3_Release(IHTMLIFrameElement3 *iface)
1344 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1346 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1349 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfoCount(IHTMLIFrameElement3 *iface, UINT *pctinfo)
1351 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1352 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1353 pctinfo);
1356 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfo(IHTMLIFrameElement3 *iface, UINT iTInfo,
1357 LCID lcid, ITypeInfo **ppTInfo)
1359 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1360 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1361 lcid, ppTInfo);
1364 static HRESULT WINAPI HTMLIFrameElement3_GetIDsOfNames(IHTMLIFrameElement3 *iface, REFIID riid,
1365 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1367 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1368 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1369 rgszNames, cNames, lcid, rgDispId);
1372 static HRESULT WINAPI HTMLIFrameElement3_Invoke(IHTMLIFrameElement3 *iface, DISPID dispIdMember,
1373 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1374 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1376 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1377 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1378 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1381 static HRESULT WINAPI HTMLIFrameElement3_get_contentDocument(IHTMLIFrameElement3 *iface, IDispatch **p)
1383 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1384 IHTMLDocument2 *doc;
1385 HRESULT hres;
1387 TRACE("(%p)->(%p)\n", This, p);
1389 if(!This->framebase.content_window) {
1390 *p = NULL;
1391 return S_OK;
1394 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
1395 *p = (IDispatch*)doc;
1396 return hres;
1399 static HRESULT WINAPI HTMLIFrameElement3_put_src(IHTMLIFrameElement3 *iface, BSTR v)
1401 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1402 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1403 return E_NOTIMPL;
1406 static HRESULT WINAPI HTMLIFrameElement3_get_src(IHTMLIFrameElement3 *iface, BSTR *p)
1408 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1409 FIXME("(%p)->(%p)\n", This, p);
1410 return E_NOTIMPL;
1413 static HRESULT WINAPI HTMLIFrameElement3_put_longDesc(IHTMLIFrameElement3 *iface, BSTR v)
1415 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1416 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1417 return E_NOTIMPL;
1420 static HRESULT WINAPI HTMLIFrameElement3_get_longDesc(IHTMLIFrameElement3 *iface, BSTR *p)
1422 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1423 FIXME("(%p)->(%p)\n", This, p);
1424 return E_NOTIMPL;
1427 static HRESULT WINAPI HTMLIFrameElement3_put_frameBorder(IHTMLIFrameElement3 *iface, BSTR v)
1429 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1430 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1431 return E_NOTIMPL;
1434 static HRESULT WINAPI HTMLIFrameElement3_get_frameBorder(IHTMLIFrameElement3 *iface, BSTR *p)
1436 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1437 FIXME("(%p)->(%p)\n", This, p);
1438 return E_NOTIMPL;
1441 static const IHTMLIFrameElement3Vtbl HTMLIFrameElement3Vtbl = {
1442 HTMLIFrameElement3_QueryInterface,
1443 HTMLIFrameElement3_AddRef,
1444 HTMLIFrameElement3_Release,
1445 HTMLIFrameElement3_GetTypeInfoCount,
1446 HTMLIFrameElement3_GetTypeInfo,
1447 HTMLIFrameElement3_GetIDsOfNames,
1448 HTMLIFrameElement3_Invoke,
1449 HTMLIFrameElement3_get_contentDocument,
1450 HTMLIFrameElement3_put_src,
1451 HTMLIFrameElement3_get_src,
1452 HTMLIFrameElement3_put_longDesc,
1453 HTMLIFrameElement3_get_longDesc,
1454 HTMLIFrameElement3_put_frameBorder,
1455 HTMLIFrameElement3_get_frameBorder
1458 static inline HTMLIFrame *iframe_from_HTMLDOMNode(HTMLDOMNode *iface)
1460 return CONTAINING_RECORD(iface, HTMLIFrame, framebase.element.node);
1463 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1465 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1467 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
1468 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
1469 *ppv = &This->IHTMLIFrameElement_iface;
1470 }else if(IsEqualGUID(&IID_IHTMLIFrameElement2, riid)) {
1471 TRACE("(%p)->(IID_IHTMLIFrameElement2 %p)\n", This, ppv);
1472 *ppv = &This->IHTMLIFrameElement2_iface;
1473 }else if(IsEqualGUID(&IID_IHTMLIFrameElement3, riid)) {
1474 TRACE("(%p)->(IID_IHTMLIFrameElement3 %p)\n", This, ppv);
1475 *ppv = &This->IHTMLIFrameElement3_iface;
1476 }else {
1477 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
1480 IUnknown_AddRef((IUnknown*)*ppv);
1481 return S_OK;
1484 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
1486 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1488 HTMLFrameBase_destructor(&This->framebase);
1491 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
1493 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1495 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
1496 *p = NULL;
1497 return S_OK;
1500 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
1501 IDispatch_AddRef(*p);
1502 return S_OK;
1505 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
1506 DWORD grfdex, DISPID *pid)
1508 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1510 if(!This->framebase.content_window)
1511 return DISP_E_UNKNOWNNAME;
1513 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
1516 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
1517 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1519 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1521 if(!This->framebase.content_window) {
1522 ERR("no content window to invoke on\n");
1523 return E_FAIL;
1526 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
1527 flags, params, res, ei, caller);
1530 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
1532 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1534 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
1537 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
1539 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1540 nsIDOMDocument *nsdoc;
1541 nsresult nsres;
1542 HRESULT hres;
1544 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
1545 if(NS_FAILED(nsres) || !nsdoc) {
1546 ERR("GetContentDocument failed: %08x\n", nsres);
1547 return E_FAIL;
1550 hres = set_frame_doc(&This->framebase, nsdoc);
1551 nsIDOMDocument_Release(nsdoc);
1552 return hres;
1555 static void HTMLIFrame_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1557 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1559 if(This->framebase.nsiframe)
1560 note_cc_edge((nsISupports*)This->framebase.nsiframe, "This->nsiframe", cb);
1563 static void HTMLIFrame_unlink(HTMLDOMNode *iface)
1565 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1567 if(This->framebase.nsiframe) {
1568 nsIDOMHTMLIFrameElement *nsiframe = This->framebase.nsiframe;
1570 This->framebase.nsiframe = NULL;
1571 nsIDOMHTMLIFrameElement_Release(nsiframe);
1575 static const NodeImplVtbl HTMLIFrameImplVtbl = {
1576 &CLSID_HTMLIFrame,
1577 HTMLIFrame_QI,
1578 HTMLIFrame_destructor,
1579 HTMLElement_cpc,
1580 HTMLElement_clone,
1581 HTMLElement_handle_event,
1582 HTMLElement_get_attr_col,
1583 NULL,
1584 NULL,
1585 NULL,
1586 HTMLIFrame_get_document,
1587 HTMLIFrame_get_readystate,
1588 HTMLIFrame_get_dispid,
1589 HTMLIFrame_invoke,
1590 HTMLIFrame_bind_to_tree,
1591 HTMLIFrame_traverse,
1592 HTMLIFrame_unlink
1595 static const tid_t HTMLIFrame_iface_tids[] = {
1596 HTMLELEMENT_TIDS,
1597 IHTMLFrameBase_tid,
1598 IHTMLFrameBase2_tid,
1599 IHTMLIFrameElement_tid,
1600 IHTMLIFrameElement2_tid,
1601 IHTMLIFrameElement3_tid,
1605 static dispex_static_data_t HTMLIFrame_dispex = {
1606 NULL,
1607 DispHTMLIFrame_tid,
1608 HTMLIFrame_iface_tids,
1609 HTMLElement_init_dispex_info
1612 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1614 HTMLIFrame *ret;
1616 ret = heap_alloc_zero(sizeof(HTMLIFrame));
1617 if(!ret)
1618 return E_OUTOFMEMORY;
1620 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
1621 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
1622 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
1623 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
1625 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
1627 *elem = &ret->framebase.element;
1628 return S_OK;