dwmapi: Clear DWM_TIMING_INFO structure before returning.
[wine.git] / dlls / mshtml / htmlframe.c
blob7a49e60bf8f1caf46f4cbbb33977f728c03b1752
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: %08lx\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: %08lx\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: %08lx\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: %08lx\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: %08lx\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%08lx\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%08lx\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: %08lx\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 L"HTMLFrameElement",
1027 NULL,
1028 DispHTMLFrameElement_tid,
1029 HTMLFrameElement_iface_tids,
1030 HTMLElement_init_dispex_info
1033 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1035 HTMLFrameElement *ret;
1037 ret = heap_alloc_zero(sizeof(HTMLFrameElement));
1038 if(!ret)
1039 return E_OUTOFMEMORY;
1041 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
1042 ret->IHTMLFrameElement3_iface.lpVtbl = &HTMLFrameElement3Vtbl;
1044 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex);
1046 *elem = &ret->framebase.element;
1047 return S_OK;
1050 struct HTMLIFrame {
1051 HTMLFrameBase framebase;
1052 IHTMLIFrameElement IHTMLIFrameElement_iface;
1053 IHTMLIFrameElement2 IHTMLIFrameElement2_iface;
1054 IHTMLIFrameElement3 IHTMLIFrameElement3_iface;
1057 static inline HTMLIFrame *impl_from_IHTMLIFrameElement(IHTMLIFrameElement *iface)
1059 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement_iface);
1062 static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface,
1063 REFIID riid, void **ppv)
1065 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1067 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1070 static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface)
1072 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1074 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1077 static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface)
1079 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1081 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1084 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo)
1086 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1087 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1088 pctinfo);
1091 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo,
1092 LCID lcid, ITypeInfo **ppTInfo)
1094 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1095 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1096 lcid, ppTInfo);
1099 static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid,
1100 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1102 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1103 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1104 rgszNames, cNames, lcid, rgDispId);
1107 static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember,
1108 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1109 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1111 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1112 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1113 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1116 static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v)
1118 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1119 FIXME("(%p)->(%ld)\n", This, v);
1120 return E_NOTIMPL;
1123 static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p)
1125 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1126 FIXME("(%p)->(%p)\n", This, p);
1127 return E_NOTIMPL;
1130 static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v)
1132 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1133 FIXME("(%p)->(%ld)\n", This, v);
1134 return E_NOTIMPL;
1137 static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p)
1139 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1140 FIXME("(%p)->(%p)\n", This, p);
1141 return E_NOTIMPL;
1144 static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v)
1146 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1147 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1148 return E_NOTIMPL;
1151 static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p)
1153 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1154 FIXME("(%p)->(%p)\n", This, p);
1155 return E_NOTIMPL;
1158 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = {
1159 HTMLIFrameElement_QueryInterface,
1160 HTMLIFrameElement_AddRef,
1161 HTMLIFrameElement_Release,
1162 HTMLIFrameElement_GetTypeInfoCount,
1163 HTMLIFrameElement_GetTypeInfo,
1164 HTMLIFrameElement_GetIDsOfNames,
1165 HTMLIFrameElement_Invoke,
1166 HTMLIFrameElement_put_vspace,
1167 HTMLIFrameElement_get_vspace,
1168 HTMLIFrameElement_put_hspace,
1169 HTMLIFrameElement_get_hspace,
1170 HTMLIFrameElement_put_align,
1171 HTMLIFrameElement_get_align
1174 static inline HTMLIFrame *impl_from_IHTMLIFrameElement2(IHTMLIFrameElement2 *iface)
1176 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement2_iface);
1179 static HRESULT WINAPI HTMLIFrameElement2_QueryInterface(IHTMLIFrameElement2 *iface,
1180 REFIID riid, void **ppv)
1182 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1184 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1187 static ULONG WINAPI HTMLIFrameElement2_AddRef(IHTMLIFrameElement2 *iface)
1189 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1191 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1194 static ULONG WINAPI HTMLIFrameElement2_Release(IHTMLIFrameElement2 *iface)
1196 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1198 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1201 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfoCount(IHTMLIFrameElement2 *iface, UINT *pctinfo)
1203 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1204 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1205 pctinfo);
1208 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfo(IHTMLIFrameElement2 *iface, UINT iTInfo,
1209 LCID lcid, ITypeInfo **ppTInfo)
1211 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1212 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1213 lcid, ppTInfo);
1216 static HRESULT WINAPI HTMLIFrameElement2_GetIDsOfNames(IHTMLIFrameElement2 *iface, REFIID riid,
1217 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1219 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1220 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1221 rgszNames, cNames, lcid, rgDispId);
1224 static HRESULT WINAPI HTMLIFrameElement2_Invoke(IHTMLIFrameElement2 *iface, DISPID dispIdMember,
1225 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1226 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1228 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1229 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1230 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1233 static HRESULT WINAPI HTMLIFrameElement2_put_height(IHTMLIFrameElement2 *iface, VARIANT v)
1235 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1236 nsAString nsstr;
1237 nsresult nsres;
1238 HRESULT hres;
1240 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1242 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1243 if(FAILED(hres))
1244 return hres;
1246 nsres = nsIDOMHTMLIFrameElement_SetHeight(This->framebase.nsiframe, &nsstr);
1247 nsAString_Finish(&nsstr);
1248 if(NS_FAILED(nsres)) {
1249 ERR("SetHeight failed: %08lx\n", nsres);
1250 return E_FAIL;
1253 return S_OK;
1256 static HRESULT WINAPI HTMLIFrameElement2_get_height(IHTMLIFrameElement2 *iface, VARIANT *p)
1258 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1259 nsAString nsstr;
1260 nsresult nsres;
1262 TRACE("(%p)->(%p)\n", This, p);
1264 nsAString_Init(&nsstr, NULL);
1265 nsres = nsIDOMHTMLIFrameElement_GetHeight(This->framebase.nsiframe, &nsstr);
1267 V_VT(p) = VT_BSTR;
1268 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1271 static HRESULT WINAPI HTMLIFrameElement2_put_width(IHTMLIFrameElement2 *iface, VARIANT v)
1273 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1274 nsAString nsstr;
1275 nsresult nsres;
1276 HRESULT hres;
1278 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1280 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1281 if(FAILED(hres))
1282 return hres;
1284 nsres = nsIDOMHTMLIFrameElement_SetWidth(This->framebase.nsiframe, &nsstr);
1285 nsAString_Finish(&nsstr);
1286 if(NS_FAILED(nsres)) {
1287 ERR("SetWidth failed: %08lx\n", nsres);
1288 return E_FAIL;
1291 return S_OK;
1294 static HRESULT WINAPI HTMLIFrameElement2_get_width(IHTMLIFrameElement2 *iface, VARIANT *p)
1296 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1297 nsAString nsstr;
1298 nsresult nsres;
1300 TRACE("(%p)->(%p)\n", This, p);
1302 nsAString_Init(&nsstr, NULL);
1303 nsres = nsIDOMHTMLIFrameElement_GetWidth(This->framebase.nsiframe, &nsstr);
1305 V_VT(p) = VT_BSTR;
1306 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1309 static const IHTMLIFrameElement2Vtbl HTMLIFrameElement2Vtbl = {
1310 HTMLIFrameElement2_QueryInterface,
1311 HTMLIFrameElement2_AddRef,
1312 HTMLIFrameElement2_Release,
1313 HTMLIFrameElement2_GetTypeInfoCount,
1314 HTMLIFrameElement2_GetTypeInfo,
1315 HTMLIFrameElement2_GetIDsOfNames,
1316 HTMLIFrameElement2_Invoke,
1317 HTMLIFrameElement2_put_height,
1318 HTMLIFrameElement2_get_height,
1319 HTMLIFrameElement2_put_width,
1320 HTMLIFrameElement2_get_width
1323 static inline HTMLIFrame *impl_from_IHTMLIFrameElement3(IHTMLIFrameElement3 *iface)
1325 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement3_iface);
1328 static HRESULT WINAPI HTMLIFrameElement3_QueryInterface(IHTMLIFrameElement3 *iface,
1329 REFIID riid, void **ppv)
1331 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1333 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1336 static ULONG WINAPI HTMLIFrameElement3_AddRef(IHTMLIFrameElement3 *iface)
1338 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1340 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1343 static ULONG WINAPI HTMLIFrameElement3_Release(IHTMLIFrameElement3 *iface)
1345 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1347 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1350 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfoCount(IHTMLIFrameElement3 *iface, UINT *pctinfo)
1352 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1353 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1354 pctinfo);
1357 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfo(IHTMLIFrameElement3 *iface, UINT iTInfo,
1358 LCID lcid, ITypeInfo **ppTInfo)
1360 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1361 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1362 lcid, ppTInfo);
1365 static HRESULT WINAPI HTMLIFrameElement3_GetIDsOfNames(IHTMLIFrameElement3 *iface, REFIID riid,
1366 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1368 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1369 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1370 rgszNames, cNames, lcid, rgDispId);
1373 static HRESULT WINAPI HTMLIFrameElement3_Invoke(IHTMLIFrameElement3 *iface, DISPID dispIdMember,
1374 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1375 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1377 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1378 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1379 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1382 static HRESULT WINAPI HTMLIFrameElement3_get_contentDocument(IHTMLIFrameElement3 *iface, IDispatch **p)
1384 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1385 IHTMLDocument2 *doc;
1386 HRESULT hres;
1388 TRACE("(%p)->(%p)\n", This, p);
1390 if(!This->framebase.content_window) {
1391 *p = NULL;
1392 return S_OK;
1395 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
1396 *p = (IDispatch*)doc;
1397 return hres;
1400 static HRESULT WINAPI HTMLIFrameElement3_put_src(IHTMLIFrameElement3 *iface, BSTR v)
1402 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1403 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1404 return E_NOTIMPL;
1407 static HRESULT WINAPI HTMLIFrameElement3_get_src(IHTMLIFrameElement3 *iface, BSTR *p)
1409 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1410 FIXME("(%p)->(%p)\n", This, p);
1411 return E_NOTIMPL;
1414 static HRESULT WINAPI HTMLIFrameElement3_put_longDesc(IHTMLIFrameElement3 *iface, BSTR v)
1416 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1417 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1418 return E_NOTIMPL;
1421 static HRESULT WINAPI HTMLIFrameElement3_get_longDesc(IHTMLIFrameElement3 *iface, BSTR *p)
1423 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1424 FIXME("(%p)->(%p)\n", This, p);
1425 return E_NOTIMPL;
1428 static HRESULT WINAPI HTMLIFrameElement3_put_frameBorder(IHTMLIFrameElement3 *iface, BSTR v)
1430 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1431 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1432 return E_NOTIMPL;
1435 static HRESULT WINAPI HTMLIFrameElement3_get_frameBorder(IHTMLIFrameElement3 *iface, BSTR *p)
1437 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1438 FIXME("(%p)->(%p)\n", This, p);
1439 return E_NOTIMPL;
1442 static const IHTMLIFrameElement3Vtbl HTMLIFrameElement3Vtbl = {
1443 HTMLIFrameElement3_QueryInterface,
1444 HTMLIFrameElement3_AddRef,
1445 HTMLIFrameElement3_Release,
1446 HTMLIFrameElement3_GetTypeInfoCount,
1447 HTMLIFrameElement3_GetTypeInfo,
1448 HTMLIFrameElement3_GetIDsOfNames,
1449 HTMLIFrameElement3_Invoke,
1450 HTMLIFrameElement3_get_contentDocument,
1451 HTMLIFrameElement3_put_src,
1452 HTMLIFrameElement3_get_src,
1453 HTMLIFrameElement3_put_longDesc,
1454 HTMLIFrameElement3_get_longDesc,
1455 HTMLIFrameElement3_put_frameBorder,
1456 HTMLIFrameElement3_get_frameBorder
1459 static inline HTMLIFrame *iframe_from_HTMLDOMNode(HTMLDOMNode *iface)
1461 return CONTAINING_RECORD(iface, HTMLIFrame, framebase.element.node);
1464 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1466 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1468 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
1469 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
1470 *ppv = &This->IHTMLIFrameElement_iface;
1471 }else if(IsEqualGUID(&IID_IHTMLIFrameElement2, riid)) {
1472 TRACE("(%p)->(IID_IHTMLIFrameElement2 %p)\n", This, ppv);
1473 *ppv = &This->IHTMLIFrameElement2_iface;
1474 }else if(IsEqualGUID(&IID_IHTMLIFrameElement3, riid)) {
1475 TRACE("(%p)->(IID_IHTMLIFrameElement3 %p)\n", This, ppv);
1476 *ppv = &This->IHTMLIFrameElement3_iface;
1477 }else {
1478 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
1481 IUnknown_AddRef((IUnknown*)*ppv);
1482 return S_OK;
1485 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
1487 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1489 HTMLFrameBase_destructor(&This->framebase);
1492 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
1494 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1496 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
1497 *p = NULL;
1498 return S_OK;
1501 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
1502 IDispatch_AddRef(*p);
1503 return S_OK;
1506 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
1507 DWORD grfdex, DISPID *pid)
1509 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1511 if(!This->framebase.content_window)
1512 return DISP_E_UNKNOWNNAME;
1514 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
1517 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
1518 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1520 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1522 if(!This->framebase.content_window) {
1523 ERR("no content window to invoke on\n");
1524 return E_FAIL;
1527 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
1528 flags, params, res, ei, caller);
1531 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
1533 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1535 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
1538 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
1540 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1541 nsIDOMDocument *nsdoc;
1542 nsresult nsres;
1543 HRESULT hres;
1545 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
1546 if(NS_FAILED(nsres) || !nsdoc) {
1547 ERR("GetContentDocument failed: %08lx\n", nsres);
1548 return E_FAIL;
1551 hres = set_frame_doc(&This->framebase, nsdoc);
1552 nsIDOMDocument_Release(nsdoc);
1553 return hres;
1556 static void HTMLIFrame_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1558 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1560 if(This->framebase.nsiframe)
1561 note_cc_edge((nsISupports*)This->framebase.nsiframe, "This->nsiframe", cb);
1564 static void HTMLIFrame_unlink(HTMLDOMNode *iface)
1566 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1568 if(This->framebase.nsiframe) {
1569 nsIDOMHTMLIFrameElement *nsiframe = This->framebase.nsiframe;
1571 This->framebase.nsiframe = NULL;
1572 nsIDOMHTMLIFrameElement_Release(nsiframe);
1576 static const NodeImplVtbl HTMLIFrameImplVtbl = {
1577 &CLSID_HTMLIFrame,
1578 HTMLIFrame_QI,
1579 HTMLIFrame_destructor,
1580 HTMLElement_cpc,
1581 HTMLElement_clone,
1582 HTMLElement_handle_event,
1583 HTMLElement_get_attr_col,
1584 NULL,
1585 NULL,
1586 NULL,
1587 HTMLIFrame_get_document,
1588 HTMLIFrame_get_readystate,
1589 HTMLIFrame_get_dispid,
1590 HTMLIFrame_invoke,
1591 HTMLIFrame_bind_to_tree,
1592 HTMLIFrame_traverse,
1593 HTMLIFrame_unlink
1596 static const tid_t HTMLIFrame_iface_tids[] = {
1597 HTMLELEMENT_TIDS,
1598 IHTMLFrameBase_tid,
1599 IHTMLFrameBase2_tid,
1600 IHTMLIFrameElement_tid,
1601 IHTMLIFrameElement2_tid,
1602 IHTMLIFrameElement3_tid,
1606 static dispex_static_data_t HTMLIFrame_dispex = {
1607 L"HTMLIFrameElement",
1608 NULL,
1609 DispHTMLIFrame_tid,
1610 HTMLIFrame_iface_tids,
1611 HTMLElement_init_dispex_info
1614 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1616 HTMLIFrame *ret;
1618 ret = heap_alloc_zero(sizeof(HTMLIFrame));
1619 if(!ret)
1620 return E_OUTOFMEMORY;
1622 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
1623 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
1624 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
1625 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
1627 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
1629 *elem = &ret->framebase.element;
1630 return S_OK;