wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / mshtml / htmlframe.c
blob972ddc80a50403712dd470fc4097aeba1dc9ab90
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>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "mshtml_private.h"
30 #include "binding.h"
31 #include "htmlevent.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 static HRESULT set_frame_doc(HTMLFrameBase *frame, nsIDOMDocument *nsdoc)
39 mozIDOMWindowProxy *mozwindow;
40 HTMLOuterWindow *window;
41 nsresult nsres;
42 HRESULT hres = S_OK;
44 if(frame->content_window)
45 return S_OK;
47 nsres = nsIDOMDocument_GetDefaultView(nsdoc, &mozwindow);
48 if(NS_FAILED(nsres) || !mozwindow)
49 return E_FAIL;
51 window = mozwindow_to_window(mozwindow);
52 if(!window && frame->element.node.doc->browser)
53 hres = create_outer_window(frame->element.node.doc->browser, mozwindow,
54 frame->element.node.doc->basedoc.window, &window);
55 mozIDOMWindowProxy_Release(mozwindow);
56 if(FAILED(hres))
57 return hres;
59 frame->content_window = window;
60 window->frame_element = frame;
61 return S_OK;
64 static inline HTMLFrameBase *impl_from_IHTMLFrameBase(IHTMLFrameBase *iface)
66 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase_iface);
69 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
71 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
73 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
76 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
78 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
80 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
83 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
85 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
87 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
90 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
92 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
94 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
97 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
98 LCID lcid, ITypeInfo **ppTInfo)
100 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
102 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
103 ppTInfo);
106 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
107 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
109 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
111 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
112 cNames, lcid, rgDispId);
115 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
116 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
117 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
119 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
121 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
122 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
125 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
127 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
129 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
131 if(!This->content_window || !This->element.node.doc || !This->element.node.doc->basedoc.window) {
132 nsAString nsstr;
133 nsresult nsres;
135 nsAString_InitDepend(&nsstr, v);
136 if(This->nsframe)
137 nsres = nsIDOMHTMLFrameElement_SetSrc(This->nsframe, &nsstr);
138 else
139 nsres = nsIDOMHTMLIFrameElement_SetSrc(This->nsiframe, &nsstr);
140 nsAString_Finish(&nsstr);
141 if(NS_FAILED(nsres)) {
142 ERR("SetSrc failed: %08x\n", nsres);
143 return E_FAIL;
146 return S_OK;
149 return navigate_url(This->content_window, v, This->element.node.doc->basedoc.window->uri, BINDING_NAVIGATED);
152 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
154 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
155 nsAString nsstr;
156 nsresult nsres;
158 TRACE("(%p)->(%p)\n", This, p);
160 if(!This->nsframe && !This->nsiframe) {
161 ERR("No attached frame object\n");
162 return E_UNEXPECTED;
165 nsAString_Init(&nsstr, NULL);
166 if(This->nsframe)
167 nsres = nsIDOMHTMLFrameElement_GetSrc(This->nsframe, &nsstr);
168 else
169 nsres = nsIDOMHTMLIFrameElement_GetSrc(This->nsiframe, &nsstr);
170 return return_nsstr(nsres, &nsstr, p);
173 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
175 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
176 nsAString name_str;
177 nsresult nsres;
179 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
181 if(!This->nsframe && !This->nsiframe) {
182 ERR("No attached ns frame object\n");
183 return E_UNEXPECTED;
186 nsAString_InitDepend(&name_str, v);
187 if(This->nsframe)
188 nsres = nsIDOMHTMLFrameElement_SetName(This->nsframe, &name_str);
189 else
190 nsres = nsIDOMHTMLIFrameElement_SetName(This->nsiframe, &name_str);
191 nsAString_Finish(&name_str);
192 if(NS_FAILED(nsres)) {
193 ERR("SetName failed: %08x\n", nsres);
194 return E_FAIL;
197 return S_OK;
200 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
202 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
203 nsAString nsstr;
204 nsresult nsres;
206 TRACE("(%p)->(%p)\n", This, p);
208 if(!This->nsframe && !This->nsiframe) {
209 ERR("No attached ns frame object\n");
210 return E_UNEXPECTED;
213 nsAString_Init(&nsstr, NULL);
214 if(This->nsframe)
215 nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
216 else
217 nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
218 return return_nsstr(nsres, &nsstr, p);
221 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
223 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
224 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
225 return E_NOTIMPL;
228 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
230 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
231 FIXME("(%p)->(%p)\n", This, p);
232 return E_NOTIMPL;
235 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
237 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
238 nsAString nsstr;
239 nsresult nsres;
241 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
243 if(!This->nsframe && !This->nsiframe) {
244 ERR("No attached ns frame object\n");
245 return E_UNEXPECTED;
248 nsAString_InitDepend(&nsstr, v);
249 if(This->nsframe)
250 nsres = nsIDOMHTMLFrameElement_SetFrameBorder(This->nsframe, &nsstr);
251 else
252 nsres = nsIDOMHTMLIFrameElement_SetFrameBorder(This->nsiframe, &nsstr);
253 nsAString_Finish(&nsstr);
254 if(NS_FAILED(nsres)) {
255 ERR("SetFrameBorder failed: %08x\n", nsres);
256 return E_FAIL;
259 return S_OK;
262 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
264 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
265 nsAString nsstr;
266 nsresult nsres;
268 TRACE("(%p)->(%p)\n", This, p);
270 if(!This->nsframe && !This->nsiframe) {
271 ERR("No attached ns frame object\n");
272 return E_UNEXPECTED;
275 nsAString_Init(&nsstr, NULL);
276 if(This->nsframe)
277 nsres = nsIDOMHTMLFrameElement_GetFrameBorder(This->nsframe, &nsstr);
278 else
279 nsres = nsIDOMHTMLIFrameElement_GetFrameBorder(This->nsiframe, &nsstr);
280 return return_nsstr(nsres, &nsstr, p);
283 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
285 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
286 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
287 return E_NOTIMPL;
290 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
292 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
293 FIXME("(%p)->(%p)\n", This, p);
294 return E_NOTIMPL;
297 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
299 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
300 nsAString nsstr;
301 nsresult nsres;
303 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
305 if(V_VT(&v) != VT_BSTR) {
306 FIXME("unsupported %s\n", debugstr_variant(&v));
307 return E_NOTIMPL;
310 nsAString_InitDepend(&nsstr, V_BSTR(&v));
311 if(This->nsframe)
312 nsres = nsIDOMHTMLFrameElement_SetMarginWidth(This->nsframe, &nsstr);
313 else
314 nsres = nsIDOMHTMLIFrameElement_SetMarginWidth(This->nsiframe, &nsstr);
315 nsAString_Finish(&nsstr);
316 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
319 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
321 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
322 nsAString nsstr;
323 nsresult nsres;
324 HRESULT hres = S_OK;
326 TRACE("(%p)->(%p)\n", This, p);
328 nsAString_Init(&nsstr, NULL);
329 if(This->nsframe)
330 nsres = nsIDOMHTMLFrameElement_GetMarginWidth(This->nsframe, &nsstr);
331 else
332 nsres = nsIDOMHTMLIFrameElement_GetMarginWidth(This->nsiframe, &nsstr);
333 if(NS_SUCCEEDED(nsres)) {
334 const PRUnichar *str, *end;
336 nsAString_GetData(&nsstr, &str);
338 if(*str) {
339 BSTR ret;
341 end = wcsstr(str, L"px");
342 if(!end)
343 end = str+lstrlenW(str);
344 ret = SysAllocStringLen(str, end-str);
345 if(ret) {
346 V_VT(p) = VT_BSTR;
347 V_BSTR(p) = ret;
348 }else {
349 hres = E_OUTOFMEMORY;
351 }else {
352 V_VT(p) = VT_BSTR;
353 V_BSTR(p) = NULL;
355 }else {
356 ERR("GetMarginWidth failed: %08x\n", nsres);
357 hres = E_FAIL;
360 nsAString_Finish(&nsstr);
361 return hres;
364 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
366 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
367 nsAString nsstr;
368 nsresult nsres;
370 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
372 if(V_VT(&v) != VT_BSTR) {
373 FIXME("unsupported %s\n", debugstr_variant(&v));
374 return E_NOTIMPL;
377 nsAString_InitDepend(&nsstr, V_BSTR(&v));
378 if(This->nsframe)
379 nsres = nsIDOMHTMLFrameElement_SetMarginHeight(This->nsframe, &nsstr);
380 else
381 nsres = nsIDOMHTMLIFrameElement_SetMarginHeight(This->nsiframe, &nsstr);
382 nsAString_Finish(&nsstr);
383 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
386 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
388 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
389 nsAString nsstr;
390 nsresult nsres;
391 HRESULT hres = S_OK;
393 TRACE("(%p)->(%p)\n", This, p);
395 nsAString_Init(&nsstr, NULL);
396 if(This->nsframe)
397 nsres = nsIDOMHTMLFrameElement_GetMarginHeight(This->nsframe, &nsstr);
398 else
399 nsres = nsIDOMHTMLIFrameElement_GetMarginHeight(This->nsiframe, &nsstr);
400 if(NS_SUCCEEDED(nsres)) {
401 const PRUnichar *str, *end;
403 nsAString_GetData(&nsstr, &str);
405 if(*str) {
406 BSTR ret;
408 end = wcsstr(str, L"px");
409 if(!end)
410 end = str+lstrlenW(str);
411 ret = SysAllocStringLen(str, end-str);
412 if(ret) {
413 V_VT(p) = VT_BSTR;
414 V_BSTR(p) = ret;
415 }else {
416 hres = E_OUTOFMEMORY;
418 }else {
419 V_VT(p) = VT_BSTR;
420 V_BSTR(p) = NULL;
422 }else {
423 ERR("SetMarginHeight failed: %08x\n", nsres);
424 hres = E_FAIL;
427 nsAString_Finish(&nsstr);
428 return hres;
431 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
433 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
434 FIXME("(%p)->(%x)\n", This, v);
435 return E_NOTIMPL;
438 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
440 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
441 FIXME("(%p)->(%p)\n", This, p);
442 return E_NOTIMPL;
445 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
447 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
448 nsAString nsstr;
449 nsresult nsres;
451 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
453 if(!(!wcsicmp(v, L"yes") || !wcsicmp(v, L"no") || !wcsicmp(v, L"auto")))
454 return E_INVALIDARG;
456 if(This->nsframe) {
457 nsAString_InitDepend(&nsstr, v);
458 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
459 }else if(This->nsiframe) {
460 nsAString_InitDepend(&nsstr, v);
461 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
462 }else {
463 ERR("No attached ns frame object\n");
464 return E_UNEXPECTED;
466 nsAString_Finish(&nsstr);
468 if(NS_FAILED(nsres)) {
469 ERR("SetScrolling failed: 0x%08x\n", nsres);
470 return E_FAIL;
473 return S_OK;
476 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
478 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
479 nsAString nsstr;
480 const PRUnichar *strdata;
481 nsresult nsres;
483 TRACE("(%p)->(%p)\n", This, p);
485 if(This->nsframe) {
486 nsAString_Init(&nsstr, NULL);
487 nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
488 }else if(This->nsiframe) {
489 nsAString_Init(&nsstr, NULL);
490 nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
491 }else {
492 ERR("No attached ns frame object\n");
493 return E_UNEXPECTED;
496 if(NS_FAILED(nsres)) {
497 ERR("GetScrolling failed: 0x%08x\n", nsres);
498 nsAString_Finish(&nsstr);
499 return E_FAIL;
502 nsAString_GetData(&nsstr, &strdata);
504 if(*strdata)
505 *p = SysAllocString(strdata);
506 else
507 *p = SysAllocString(L"auto");
509 nsAString_Finish(&nsstr);
511 return *p ? S_OK : E_OUTOFMEMORY;
514 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
515 HTMLFrameBase_QueryInterface,
516 HTMLFrameBase_AddRef,
517 HTMLFrameBase_Release,
518 HTMLFrameBase_GetTypeInfoCount,
519 HTMLFrameBase_GetTypeInfo,
520 HTMLFrameBase_GetIDsOfNames,
521 HTMLFrameBase_Invoke,
522 HTMLFrameBase_put_src,
523 HTMLFrameBase_get_src,
524 HTMLFrameBase_put_name,
525 HTMLFrameBase_get_name,
526 HTMLFrameBase_put_border,
527 HTMLFrameBase_get_border,
528 HTMLFrameBase_put_frameBorder,
529 HTMLFrameBase_get_frameBorder,
530 HTMLFrameBase_put_frameSpacing,
531 HTMLFrameBase_get_frameSpacing,
532 HTMLFrameBase_put_marginWidth,
533 HTMLFrameBase_get_marginWidth,
534 HTMLFrameBase_put_marginHeight,
535 HTMLFrameBase_get_marginHeight,
536 HTMLFrameBase_put_noResize,
537 HTMLFrameBase_get_noResize,
538 HTMLFrameBase_put_scrolling,
539 HTMLFrameBase_get_scrolling
542 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
544 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
547 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
549 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
551 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
554 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
556 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
558 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
561 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
563 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
565 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
568 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
570 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
571 FIXME("(%p)\n", This);
572 return E_NOTIMPL;
575 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
576 LCID lcid, ITypeInfo **ppTInfo)
578 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
579 FIXME("(%p)\n", This);
580 return E_NOTIMPL;
583 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
584 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
586 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
587 FIXME("(%p)\n", This);
588 return E_NOTIMPL;
591 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
592 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
593 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
595 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
596 FIXME("(%p)\n", This);
597 return E_NOTIMPL;
600 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
602 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
604 TRACE("(%p)->(%p)\n", This, p);
606 if(This->content_window) {
607 IHTMLWindow2_AddRef(&This->content_window->base.IHTMLWindow2_iface);
608 *p = &This->content_window->base.IHTMLWindow2_iface;
609 }else {
610 WARN("NULL content window\n");
611 *p = NULL;
613 return S_OK;
616 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
618 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
620 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
622 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
625 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
627 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
629 TRACE("(%p)->(%p)\n", This, p);
631 return get_node_event(&This->element.node, EVENTID_LOAD, p);
634 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
636 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
637 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
638 return E_NOTIMPL;
641 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
643 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
644 FIXME("(%p)->(%p)\n", This, p);
645 return E_NOTIMPL;
648 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
650 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
652 TRACE("(%p)->(%p)\n", This, p);
654 if(!This->content_window || !This->content_window->base.inner_window->doc) {
655 FIXME("no document associated\n");
656 return E_FAIL;
659 return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface, p);
662 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
664 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
666 FIXME("(%p)->(%x) semi-stub\n", This, v);
668 return S_OK;
671 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
673 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
675 FIXME("(%p)->(%p) semi-stub\n", This, p);
677 *p = VARIANT_TRUE;
678 return S_OK;
681 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
682 HTMLFrameBase2_QueryInterface,
683 HTMLFrameBase2_AddRef,
684 HTMLFrameBase2_Release,
685 HTMLFrameBase2_GetTypeInfoCount,
686 HTMLFrameBase2_GetTypeInfo,
687 HTMLFrameBase2_GetIDsOfNames,
688 HTMLFrameBase2_Invoke,
689 HTMLFrameBase2_get_contentWindow,
690 HTMLFrameBase2_put_onload,
691 HTMLFrameBase2_get_onload,
692 HTMLFrameBase2_put_onreadystatechange,
693 HTMLFrameBase2_get_onreadystatechange,
694 HTMLFrameBase2_get_readyState,
695 HTMLFrameBase2_put_allowTransparency,
696 HTMLFrameBase2_get_allowTransparency
699 static HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
701 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
702 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
703 *ppv = &This->IHTMLFrameBase_iface;
704 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
705 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
706 *ppv = &This->IHTMLFrameBase2_iface;
707 }else {
708 return HTMLElement_QI(&This->element.node, riid, ppv);
711 IUnknown_AddRef((IUnknown*)*ppv);
712 return S_OK;
715 static void HTMLFrameBase_destructor(HTMLFrameBase *This)
717 if(This->content_window)
718 This->content_window->frame_element = NULL;
720 HTMLElement_destructor(&This->element.node);
723 static void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMElement *nselem,
724 dispex_static_data_t *dispex_data)
726 nsresult nsres;
728 This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
729 This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
731 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
733 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
734 if(NS_FAILED(nsres)) {
735 This->nsframe = NULL;
736 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
737 assert(nsres == NS_OK);
738 }else {
739 This->nsiframe = NULL;
743 struct HTMLFrameElement {
744 HTMLFrameBase framebase;
745 IHTMLFrameElement3 IHTMLFrameElement3_iface;
748 static inline HTMLFrameElement *impl_from_IHTMLFrameElement3(IHTMLFrameElement3 *iface)
750 return CONTAINING_RECORD(iface, HTMLFrameElement, IHTMLFrameElement3_iface);
753 static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface,
754 REFIID riid, void **ppv)
756 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
758 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
761 static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface)
763 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
765 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
768 static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface)
770 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
772 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
775 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo)
777 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
778 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
779 pctinfo);
782 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo,
783 LCID lcid, ITypeInfo **ppTInfo)
785 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
786 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
787 lcid, ppTInfo);
790 static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid,
791 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
793 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
794 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
795 rgszNames, cNames, lcid, rgDispId);
798 static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember,
799 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
800 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
802 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
803 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
804 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
807 static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p)
809 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
810 IHTMLDocument2 *doc;
811 HRESULT hres;
813 TRACE("(%p)->(%p)\n", This, p);
815 if(!This->framebase.content_window) {
816 FIXME("NULL window\n");
817 return E_FAIL;
820 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
821 if(FAILED(hres))
822 return hres;
824 *p = doc ? (IDispatch*)doc : NULL;
825 return S_OK;
828 static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v)
830 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
831 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
832 return E_NOTIMPL;
835 static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p)
837 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
838 FIXME("(%p)->(%p)\n", This, p);
839 return E_NOTIMPL;
842 static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v)
844 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
845 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
846 return E_NOTIMPL;
849 static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p)
851 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
852 FIXME("(%p)->(%p)\n", This, p);
853 return E_NOTIMPL;
856 static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v)
858 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
859 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
860 return E_NOTIMPL;
863 static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p)
865 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
866 FIXME("(%p)->(%p)\n", This, p);
867 return E_NOTIMPL;
870 static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = {
871 HTMLFrameElement3_QueryInterface,
872 HTMLFrameElement3_AddRef,
873 HTMLFrameElement3_Release,
874 HTMLFrameElement3_GetTypeInfoCount,
875 HTMLFrameElement3_GetTypeInfo,
876 HTMLFrameElement3_GetIDsOfNames,
877 HTMLFrameElement3_Invoke,
878 HTMLFrameElement3_get_contentDocument,
879 HTMLFrameElement3_put_src,
880 HTMLFrameElement3_get_src,
881 HTMLFrameElement3_put_longDesc,
882 HTMLFrameElement3_get_longDesc,
883 HTMLFrameElement3_put_frameBorder,
884 HTMLFrameElement3_get_frameBorder
887 static inline HTMLFrameElement *frame_from_HTMLDOMNode(HTMLDOMNode *iface)
889 return CONTAINING_RECORD(iface, HTMLFrameElement, framebase.element.node);
892 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
894 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
896 if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) {
897 TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv);
898 *ppv = &This->IHTMLFrameElement3_iface;
899 }else {
900 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
903 IUnknown_AddRef((IUnknown*)*ppv);
904 return S_OK;
907 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
909 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
911 HTMLFrameBase_destructor(&This->framebase);
914 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
916 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
918 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
919 *p = NULL;
920 return S_OK;
923 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->basedoc.IHTMLDocument2_iface;
924 IDispatch_AddRef(*p);
925 return S_OK;
928 static HRESULT HTMLFrameElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
930 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
932 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
935 static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
936 DWORD grfdex, DISPID *pid)
938 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
940 if(!This->framebase.content_window)
941 return DISP_E_UNKNOWNNAME;
943 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
946 static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
947 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
949 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
951 if(!This->framebase.content_window) {
952 ERR("no content window to invoke on\n");
953 return E_FAIL;
956 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
957 flags, params, res, ei, caller);
960 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
962 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
963 nsIDOMDocument *nsdoc;
964 nsresult nsres;
965 HRESULT hres;
967 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
968 if(NS_FAILED(nsres) || !nsdoc) {
969 ERR("GetContentDocument failed: %08x\n", nsres);
970 return E_FAIL;
973 hres = set_frame_doc(&This->framebase, nsdoc);
974 nsIDOMDocument_Release(nsdoc);
975 return hres;
978 static void HTMLFrameElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
980 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
982 if(This->framebase.nsframe)
983 note_cc_edge((nsISupports*)This->framebase.nsframe, "This->nsframe", cb);
986 static void HTMLFrameElement_unlink(HTMLDOMNode *iface)
988 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
990 if(This->framebase.nsframe) {
991 nsIDOMHTMLFrameElement *nsframe = This->framebase.nsframe;
993 This->framebase.nsframe = NULL;
994 nsIDOMHTMLFrameElement_Release(nsframe);
998 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
999 &CLSID_HTMLFrameElement,
1000 HTMLFrameElement_QI,
1001 HTMLFrameElement_destructor,
1002 HTMLElement_cpc,
1003 HTMLElement_clone,
1004 HTMLElement_handle_event,
1005 HTMLElement_get_attr_col,
1006 NULL,
1007 NULL,
1008 NULL,
1009 HTMLFrameElement_get_document,
1010 HTMLFrameElement_get_readystate,
1011 HTMLFrameElement_get_dispid,
1012 HTMLFrameElement_invoke,
1013 HTMLFrameElement_bind_to_tree,
1014 HTMLFrameElement_traverse,
1015 HTMLFrameElement_unlink
1018 static const tid_t HTMLFrameElement_iface_tids[] = {
1019 HTMLELEMENT_TIDS,
1020 IHTMLFrameBase_tid,
1021 IHTMLFrameBase2_tid,
1022 IHTMLFrameElement3_tid,
1026 static dispex_static_data_t HTMLFrameElement_dispex = {
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)->(%d)\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)->(%d)\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: %08x\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: %08x\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: %08x\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 NULL,
1608 DispHTMLIFrame_tid,
1609 HTMLIFrame_iface_tids,
1610 HTMLElement_init_dispex_info
1613 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1615 HTMLIFrame *ret;
1617 ret = heap_alloc_zero(sizeof(HTMLIFrame));
1618 if(!ret)
1619 return E_OUTOFMEMORY;
1621 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
1622 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
1623 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
1624 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
1626 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
1628 *elem = &ret->framebase.element;
1629 return S_OK;