mshtml: Fix classList toggle() when return value pointer is NULL.
[wine.git] / dlls / mshtml / htmlframe.c
blob9be69c29f9a697a2093ce96d8c12733de70004c8
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->outer_window, &window);
55 /* Don't hold ref to the created window; the parent keeps ref to it */
56 if(SUCCEEDED(hres))
57 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
59 mozIDOMWindowProxy_Release(mozwindow);
60 if(FAILED(hres))
61 return hres;
63 frame->content_window = window;
64 window->frame_element = frame;
65 return S_OK;
68 static inline HTMLFrameBase *impl_from_IHTMLFrameBase(IHTMLFrameBase *iface)
70 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase_iface);
73 static HRESULT WINAPI HTMLFrameBase_QueryInterface(IHTMLFrameBase *iface, REFIID riid, void **ppv)
75 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
77 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
80 static ULONG WINAPI HTMLFrameBase_AddRef(IHTMLFrameBase *iface)
82 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
84 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
87 static ULONG WINAPI HTMLFrameBase_Release(IHTMLFrameBase *iface)
89 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
91 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
94 static HRESULT WINAPI HTMLFrameBase_GetTypeInfoCount(IHTMLFrameBase *iface, UINT *pctinfo)
96 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
98 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
101 static HRESULT WINAPI HTMLFrameBase_GetTypeInfo(IHTMLFrameBase *iface, UINT iTInfo,
102 LCID lcid, ITypeInfo **ppTInfo)
104 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
106 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
107 ppTInfo);
110 static HRESULT WINAPI HTMLFrameBase_GetIDsOfNames(IHTMLFrameBase *iface, REFIID riid,
111 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
113 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
115 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
116 cNames, lcid, rgDispId);
119 static HRESULT WINAPI HTMLFrameBase_Invoke(IHTMLFrameBase *iface, DISPID dispIdMember,
120 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
121 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
123 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
125 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
126 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
129 static HRESULT WINAPI HTMLFrameBase_put_src(IHTMLFrameBase *iface, BSTR v)
131 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
133 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
135 if(!This->content_window || !This->element.node.doc || !This->element.node.doc->outer_window) {
136 nsAString nsstr;
137 nsresult nsres;
139 nsAString_InitDepend(&nsstr, v);
140 if(This->nsframe)
141 nsres = nsIDOMHTMLFrameElement_SetSrc(This->nsframe, &nsstr);
142 else
143 nsres = nsIDOMHTMLIFrameElement_SetSrc(This->nsiframe, &nsstr);
144 nsAString_Finish(&nsstr);
145 if(NS_FAILED(nsres)) {
146 ERR("SetSrc failed: %08lx\n", nsres);
147 return E_FAIL;
150 return S_OK;
153 return navigate_url(This->content_window, v, This->element.node.doc->outer_window->uri, BINDING_NAVIGATED);
156 static HRESULT WINAPI HTMLFrameBase_get_src(IHTMLFrameBase *iface, BSTR *p)
158 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
159 nsAString nsstr;
160 nsresult nsres;
162 TRACE("(%p)->(%p)\n", This, p);
164 if(!This->nsframe && !This->nsiframe) {
165 ERR("No attached frame object\n");
166 return E_UNEXPECTED;
169 nsAString_Init(&nsstr, NULL);
170 if(This->nsframe)
171 nsres = nsIDOMHTMLFrameElement_GetSrc(This->nsframe, &nsstr);
172 else
173 nsres = nsIDOMHTMLIFrameElement_GetSrc(This->nsiframe, &nsstr);
174 return return_nsstr(nsres, &nsstr, p);
177 static HRESULT WINAPI HTMLFrameBase_put_name(IHTMLFrameBase *iface, BSTR v)
179 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
180 nsAString name_str;
181 nsresult nsres;
183 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
185 if(!This->nsframe && !This->nsiframe) {
186 ERR("No attached ns frame object\n");
187 return E_UNEXPECTED;
190 nsAString_InitDepend(&name_str, v);
191 if(This->nsframe)
192 nsres = nsIDOMHTMLFrameElement_SetName(This->nsframe, &name_str);
193 else
194 nsres = nsIDOMHTMLIFrameElement_SetName(This->nsiframe, &name_str);
195 nsAString_Finish(&name_str);
196 if(NS_FAILED(nsres)) {
197 ERR("SetName failed: %08lx\n", nsres);
198 return E_FAIL;
201 return S_OK;
204 static HRESULT WINAPI HTMLFrameBase_get_name(IHTMLFrameBase *iface, BSTR *p)
206 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
207 nsAString nsstr;
208 nsresult nsres;
210 TRACE("(%p)->(%p)\n", This, p);
212 if(!This->nsframe && !This->nsiframe) {
213 ERR("No attached ns frame object\n");
214 return E_UNEXPECTED;
217 nsAString_Init(&nsstr, NULL);
218 if(This->nsframe)
219 nsres = nsIDOMHTMLFrameElement_GetName(This->nsframe, &nsstr);
220 else
221 nsres = nsIDOMHTMLIFrameElement_GetName(This->nsiframe, &nsstr);
222 return return_nsstr(nsres, &nsstr, p);
225 static HRESULT WINAPI HTMLFrameBase_put_border(IHTMLFrameBase *iface, VARIANT v)
227 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
228 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
229 return E_NOTIMPL;
232 static HRESULT WINAPI HTMLFrameBase_get_border(IHTMLFrameBase *iface, VARIANT *p)
234 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
235 FIXME("(%p)->(%p)\n", This, p);
236 return E_NOTIMPL;
239 static HRESULT WINAPI HTMLFrameBase_put_frameBorder(IHTMLFrameBase *iface, BSTR v)
241 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
242 nsAString nsstr;
243 nsresult nsres;
245 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
247 if(!This->nsframe && !This->nsiframe) {
248 ERR("No attached ns frame object\n");
249 return E_UNEXPECTED;
252 nsAString_InitDepend(&nsstr, v);
253 if(This->nsframe)
254 nsres = nsIDOMHTMLFrameElement_SetFrameBorder(This->nsframe, &nsstr);
255 else
256 nsres = nsIDOMHTMLIFrameElement_SetFrameBorder(This->nsiframe, &nsstr);
257 nsAString_Finish(&nsstr);
258 if(NS_FAILED(nsres)) {
259 ERR("SetFrameBorder failed: %08lx\n", nsres);
260 return E_FAIL;
263 return S_OK;
266 static HRESULT WINAPI HTMLFrameBase_get_frameBorder(IHTMLFrameBase *iface, BSTR *p)
268 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
269 nsAString nsstr;
270 nsresult nsres;
272 TRACE("(%p)->(%p)\n", This, p);
274 if(!This->nsframe && !This->nsiframe) {
275 ERR("No attached ns frame object\n");
276 return E_UNEXPECTED;
279 nsAString_Init(&nsstr, NULL);
280 if(This->nsframe)
281 nsres = nsIDOMHTMLFrameElement_GetFrameBorder(This->nsframe, &nsstr);
282 else
283 nsres = nsIDOMHTMLIFrameElement_GetFrameBorder(This->nsiframe, &nsstr);
284 return return_nsstr(nsres, &nsstr, p);
287 static HRESULT WINAPI HTMLFrameBase_put_frameSpacing(IHTMLFrameBase *iface, VARIANT v)
289 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
290 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
291 return E_NOTIMPL;
294 static HRESULT WINAPI HTMLFrameBase_get_frameSpacing(IHTMLFrameBase *iface, VARIANT *p)
296 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
297 FIXME("(%p)->(%p)\n", This, p);
298 return E_NOTIMPL;
301 static HRESULT WINAPI HTMLFrameBase_put_marginWidth(IHTMLFrameBase *iface, VARIANT v)
303 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
304 nsAString nsstr;
305 nsresult nsres;
307 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
309 if(V_VT(&v) != VT_BSTR) {
310 FIXME("unsupported %s\n", debugstr_variant(&v));
311 return E_NOTIMPL;
314 nsAString_InitDepend(&nsstr, V_BSTR(&v));
315 if(This->nsframe)
316 nsres = nsIDOMHTMLFrameElement_SetMarginWidth(This->nsframe, &nsstr);
317 else
318 nsres = nsIDOMHTMLIFrameElement_SetMarginWidth(This->nsiframe, &nsstr);
319 nsAString_Finish(&nsstr);
320 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
323 static HRESULT WINAPI HTMLFrameBase_get_marginWidth(IHTMLFrameBase *iface, VARIANT *p)
325 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
326 nsAString nsstr;
327 nsresult nsres;
328 HRESULT hres = S_OK;
330 TRACE("(%p)->(%p)\n", This, p);
332 nsAString_Init(&nsstr, NULL);
333 if(This->nsframe)
334 nsres = nsIDOMHTMLFrameElement_GetMarginWidth(This->nsframe, &nsstr);
335 else
336 nsres = nsIDOMHTMLIFrameElement_GetMarginWidth(This->nsiframe, &nsstr);
337 if(NS_SUCCEEDED(nsres)) {
338 const PRUnichar *str, *end;
340 nsAString_GetData(&nsstr, &str);
342 if(*str) {
343 BSTR ret;
345 end = wcsstr(str, L"px");
346 if(!end)
347 end = str+lstrlenW(str);
348 ret = SysAllocStringLen(str, end-str);
349 if(ret) {
350 V_VT(p) = VT_BSTR;
351 V_BSTR(p) = ret;
352 }else {
353 hres = E_OUTOFMEMORY;
355 }else {
356 V_VT(p) = VT_BSTR;
357 V_BSTR(p) = NULL;
359 }else {
360 ERR("GetMarginWidth failed: %08lx\n", nsres);
361 hres = E_FAIL;
364 nsAString_Finish(&nsstr);
365 return hres;
368 static HRESULT WINAPI HTMLFrameBase_put_marginHeight(IHTMLFrameBase *iface, VARIANT v)
370 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
371 nsAString nsstr;
372 nsresult nsres;
374 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
376 if(V_VT(&v) != VT_BSTR) {
377 FIXME("unsupported %s\n", debugstr_variant(&v));
378 return E_NOTIMPL;
381 nsAString_InitDepend(&nsstr, V_BSTR(&v));
382 if(This->nsframe)
383 nsres = nsIDOMHTMLFrameElement_SetMarginHeight(This->nsframe, &nsstr);
384 else
385 nsres = nsIDOMHTMLIFrameElement_SetMarginHeight(This->nsiframe, &nsstr);
386 nsAString_Finish(&nsstr);
387 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
390 static HRESULT WINAPI HTMLFrameBase_get_marginHeight(IHTMLFrameBase *iface, VARIANT *p)
392 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
393 nsAString nsstr;
394 nsresult nsres;
395 HRESULT hres = S_OK;
397 TRACE("(%p)->(%p)\n", This, p);
399 nsAString_Init(&nsstr, NULL);
400 if(This->nsframe)
401 nsres = nsIDOMHTMLFrameElement_GetMarginHeight(This->nsframe, &nsstr);
402 else
403 nsres = nsIDOMHTMLIFrameElement_GetMarginHeight(This->nsiframe, &nsstr);
404 if(NS_SUCCEEDED(nsres)) {
405 const PRUnichar *str, *end;
407 nsAString_GetData(&nsstr, &str);
409 if(*str) {
410 BSTR ret;
412 end = wcsstr(str, L"px");
413 if(!end)
414 end = str+lstrlenW(str);
415 ret = SysAllocStringLen(str, end-str);
416 if(ret) {
417 V_VT(p) = VT_BSTR;
418 V_BSTR(p) = ret;
419 }else {
420 hres = E_OUTOFMEMORY;
422 }else {
423 V_VT(p) = VT_BSTR;
424 V_BSTR(p) = NULL;
426 }else {
427 ERR("SetMarginHeight failed: %08lx\n", nsres);
428 hres = E_FAIL;
431 nsAString_Finish(&nsstr);
432 return hres;
435 static HRESULT WINAPI HTMLFrameBase_put_noResize(IHTMLFrameBase *iface, VARIANT_BOOL v)
437 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
438 FIXME("(%p)->(%x)\n", This, v);
439 return E_NOTIMPL;
442 static HRESULT WINAPI HTMLFrameBase_get_noResize(IHTMLFrameBase *iface, VARIANT_BOOL *p)
444 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
445 FIXME("(%p)->(%p)\n", This, p);
446 return E_NOTIMPL;
449 static HRESULT WINAPI HTMLFrameBase_put_scrolling(IHTMLFrameBase *iface, BSTR v)
451 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
452 nsAString nsstr;
453 nsresult nsres;
455 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
457 if(!(!wcsicmp(v, L"yes") || !wcsicmp(v, L"no") || !wcsicmp(v, L"auto")))
458 return E_INVALIDARG;
460 if(This->nsframe) {
461 nsAString_InitDepend(&nsstr, v);
462 nsres = nsIDOMHTMLFrameElement_SetScrolling(This->nsframe, &nsstr);
463 }else if(This->nsiframe) {
464 nsAString_InitDepend(&nsstr, v);
465 nsres = nsIDOMHTMLIFrameElement_SetScrolling(This->nsiframe, &nsstr);
466 }else {
467 ERR("No attached ns frame object\n");
468 return E_UNEXPECTED;
470 nsAString_Finish(&nsstr);
472 if(NS_FAILED(nsres)) {
473 ERR("SetScrolling failed: 0x%08lx\n", nsres);
474 return E_FAIL;
477 return S_OK;
480 static HRESULT WINAPI HTMLFrameBase_get_scrolling(IHTMLFrameBase *iface, BSTR *p)
482 HTMLFrameBase *This = impl_from_IHTMLFrameBase(iface);
483 nsAString nsstr;
484 const PRUnichar *strdata;
485 nsresult nsres;
487 TRACE("(%p)->(%p)\n", This, p);
489 if(This->nsframe) {
490 nsAString_Init(&nsstr, NULL);
491 nsres = nsIDOMHTMLFrameElement_GetScrolling(This->nsframe, &nsstr);
492 }else if(This->nsiframe) {
493 nsAString_Init(&nsstr, NULL);
494 nsres = nsIDOMHTMLIFrameElement_GetScrolling(This->nsiframe, &nsstr);
495 }else {
496 ERR("No attached ns frame object\n");
497 return E_UNEXPECTED;
500 if(NS_FAILED(nsres)) {
501 ERR("GetScrolling failed: 0x%08lx\n", nsres);
502 nsAString_Finish(&nsstr);
503 return E_FAIL;
506 nsAString_GetData(&nsstr, &strdata);
508 if(*strdata)
509 *p = SysAllocString(strdata);
510 else
511 *p = SysAllocString(L"auto");
513 nsAString_Finish(&nsstr);
515 return *p ? S_OK : E_OUTOFMEMORY;
518 static const IHTMLFrameBaseVtbl HTMLFrameBaseVtbl = {
519 HTMLFrameBase_QueryInterface,
520 HTMLFrameBase_AddRef,
521 HTMLFrameBase_Release,
522 HTMLFrameBase_GetTypeInfoCount,
523 HTMLFrameBase_GetTypeInfo,
524 HTMLFrameBase_GetIDsOfNames,
525 HTMLFrameBase_Invoke,
526 HTMLFrameBase_put_src,
527 HTMLFrameBase_get_src,
528 HTMLFrameBase_put_name,
529 HTMLFrameBase_get_name,
530 HTMLFrameBase_put_border,
531 HTMLFrameBase_get_border,
532 HTMLFrameBase_put_frameBorder,
533 HTMLFrameBase_get_frameBorder,
534 HTMLFrameBase_put_frameSpacing,
535 HTMLFrameBase_get_frameSpacing,
536 HTMLFrameBase_put_marginWidth,
537 HTMLFrameBase_get_marginWidth,
538 HTMLFrameBase_put_marginHeight,
539 HTMLFrameBase_get_marginHeight,
540 HTMLFrameBase_put_noResize,
541 HTMLFrameBase_get_noResize,
542 HTMLFrameBase_put_scrolling,
543 HTMLFrameBase_get_scrolling
546 static inline HTMLFrameBase *impl_from_IHTMLFrameBase2(IHTMLFrameBase2 *iface)
548 return CONTAINING_RECORD(iface, HTMLFrameBase, IHTMLFrameBase2_iface);
551 static HRESULT WINAPI HTMLFrameBase2_QueryInterface(IHTMLFrameBase2 *iface, REFIID riid, void **ppv)
553 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
555 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
558 static ULONG WINAPI HTMLFrameBase2_AddRef(IHTMLFrameBase2 *iface)
560 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
562 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
565 static ULONG WINAPI HTMLFrameBase2_Release(IHTMLFrameBase2 *iface)
567 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
569 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
572 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfoCount(IHTMLFrameBase2 *iface, UINT *pctinfo)
574 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
575 FIXME("(%p)\n", This);
576 return E_NOTIMPL;
579 static HRESULT WINAPI HTMLFrameBase2_GetTypeInfo(IHTMLFrameBase2 *iface, UINT iTInfo,
580 LCID lcid, ITypeInfo **ppTInfo)
582 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
583 FIXME("(%p)\n", This);
584 return E_NOTIMPL;
587 static HRESULT WINAPI HTMLFrameBase2_GetIDsOfNames(IHTMLFrameBase2 *iface, REFIID riid,
588 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
590 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
591 FIXME("(%p)\n", This);
592 return E_NOTIMPL;
595 static HRESULT WINAPI HTMLFrameBase2_Invoke(IHTMLFrameBase2 *iface, DISPID dispIdMember,
596 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
597 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
599 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
600 FIXME("(%p)\n", This);
601 return E_NOTIMPL;
604 static HRESULT WINAPI HTMLFrameBase2_get_contentWindow(IHTMLFrameBase2 *iface, IHTMLWindow2 **p)
606 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
608 TRACE("(%p)->(%p)\n", This, p);
610 if(This->content_window) {
611 IHTMLWindow2_AddRef(&This->content_window->base.IHTMLWindow2_iface);
612 *p = &This->content_window->base.IHTMLWindow2_iface;
613 }else {
614 WARN("NULL content window\n");
615 *p = NULL;
617 return S_OK;
620 static HRESULT WINAPI HTMLFrameBase2_put_onload(IHTMLFrameBase2 *iface, VARIANT v)
622 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
624 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
626 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
629 static HRESULT WINAPI HTMLFrameBase2_get_onload(IHTMLFrameBase2 *iface, VARIANT *p)
631 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
633 TRACE("(%p)->(%p)\n", This, p);
635 return get_node_event(&This->element.node, EVENTID_LOAD, p);
638 static HRESULT WINAPI HTMLFrameBase2_put_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT v)
640 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
641 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
642 return E_NOTIMPL;
645 static HRESULT WINAPI HTMLFrameBase2_get_onreadystatechange(IHTMLFrameBase2 *iface, VARIANT *p)
647 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
648 FIXME("(%p)->(%p)\n", This, p);
649 return E_NOTIMPL;
652 static HRESULT WINAPI HTMLFrameBase2_get_readyState(IHTMLFrameBase2 *iface, BSTR *p)
654 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
656 TRACE("(%p)->(%p)\n", This, p);
658 if(!This->content_window || !This->content_window->base.inner_window->doc) {
659 FIXME("no document associated\n");
660 return E_FAIL;
663 return IHTMLDocument2_get_readyState(&This->content_window->base.inner_window->doc->IHTMLDocument2_iface, p);
666 static HRESULT WINAPI HTMLFrameBase2_put_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL v)
668 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
670 FIXME("(%p)->(%x) semi-stub\n", This, v);
672 return S_OK;
675 static HRESULT WINAPI HTMLFrameBase2_get_allowTransparency(IHTMLFrameBase2 *iface, VARIANT_BOOL *p)
677 HTMLFrameBase *This = impl_from_IHTMLFrameBase2(iface);
679 FIXME("(%p)->(%p) semi-stub\n", This, p);
681 *p = VARIANT_TRUE;
682 return S_OK;
685 static const IHTMLFrameBase2Vtbl HTMLFrameBase2Vtbl = {
686 HTMLFrameBase2_QueryInterface,
687 HTMLFrameBase2_AddRef,
688 HTMLFrameBase2_Release,
689 HTMLFrameBase2_GetTypeInfoCount,
690 HTMLFrameBase2_GetTypeInfo,
691 HTMLFrameBase2_GetIDsOfNames,
692 HTMLFrameBase2_Invoke,
693 HTMLFrameBase2_get_contentWindow,
694 HTMLFrameBase2_put_onload,
695 HTMLFrameBase2_get_onload,
696 HTMLFrameBase2_put_onreadystatechange,
697 HTMLFrameBase2_get_onreadystatechange,
698 HTMLFrameBase2_get_readyState,
699 HTMLFrameBase2_put_allowTransparency,
700 HTMLFrameBase2_get_allowTransparency
703 static HRESULT HTMLFrameBase_QI(HTMLFrameBase *This, REFIID riid, void **ppv)
705 if(IsEqualGUID(&IID_IHTMLFrameBase, riid)) {
706 TRACE("(%p)->(IID_IHTMLFrameBase %p)\n", This, ppv);
707 *ppv = &This->IHTMLFrameBase_iface;
708 }else if(IsEqualGUID(&IID_IHTMLFrameBase2, riid)) {
709 TRACE("(%p)->(IID_IHTMLFrameBase2 %p)\n", This, ppv);
710 *ppv = &This->IHTMLFrameBase2_iface;
711 }else {
712 return HTMLElement_QI(&This->element.node, riid, ppv);
715 IUnknown_AddRef((IUnknown*)*ppv);
716 return S_OK;
719 static void HTMLFrameBase_destructor(HTMLFrameBase *This)
721 if(This->content_window)
722 This->content_window->frame_element = NULL;
724 HTMLElement_destructor(&This->element.node);
727 static void HTMLFrameBase_Init(HTMLFrameBase *This, HTMLDocumentNode *doc, nsIDOMElement *nselem,
728 dispex_static_data_t *dispex_data)
730 nsresult nsres;
732 This->IHTMLFrameBase_iface.lpVtbl = &HTMLFrameBaseVtbl;
733 This->IHTMLFrameBase2_iface.lpVtbl = &HTMLFrameBase2Vtbl;
735 HTMLElement_Init(&This->element, doc, nselem, dispex_data);
737 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLFrameElement, (void**)&This->nsframe);
738 if(NS_FAILED(nsres)) {
739 This->nsframe = NULL;
740 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&This->nsiframe);
741 assert(nsres == NS_OK);
742 }else {
743 This->nsiframe = NULL;
747 struct HTMLFrameElement {
748 HTMLFrameBase framebase;
749 IHTMLFrameElement3 IHTMLFrameElement3_iface;
752 static inline HTMLFrameElement *impl_from_IHTMLFrameElement3(IHTMLFrameElement3 *iface)
754 return CONTAINING_RECORD(iface, HTMLFrameElement, IHTMLFrameElement3_iface);
757 static HRESULT WINAPI HTMLFrameElement3_QueryInterface(IHTMLFrameElement3 *iface,
758 REFIID riid, void **ppv)
760 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
762 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
765 static ULONG WINAPI HTMLFrameElement3_AddRef(IHTMLFrameElement3 *iface)
767 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
769 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
772 static ULONG WINAPI HTMLFrameElement3_Release(IHTMLFrameElement3 *iface)
774 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
776 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
779 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfoCount(IHTMLFrameElement3 *iface, UINT *pctinfo)
781 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
782 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
783 pctinfo);
786 static HRESULT WINAPI HTMLFrameElement3_GetTypeInfo(IHTMLFrameElement3 *iface, UINT iTInfo,
787 LCID lcid, ITypeInfo **ppTInfo)
789 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
790 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
791 lcid, ppTInfo);
794 static HRESULT WINAPI HTMLFrameElement3_GetIDsOfNames(IHTMLFrameElement3 *iface, REFIID riid,
795 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
797 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
798 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
799 rgszNames, cNames, lcid, rgDispId);
802 static HRESULT WINAPI HTMLFrameElement3_Invoke(IHTMLFrameElement3 *iface, DISPID dispIdMember,
803 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
804 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
806 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
807 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
808 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
811 static HRESULT WINAPI HTMLFrameElement3_get_contentDocument(IHTMLFrameElement3 *iface, IDispatch **p)
813 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
814 IHTMLDocument2 *doc;
815 HRESULT hres;
817 TRACE("(%p)->(%p)\n", This, p);
819 if(!This->framebase.content_window) {
820 FIXME("NULL window\n");
821 return E_FAIL;
824 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
825 if(FAILED(hres))
826 return hres;
828 *p = doc ? (IDispatch*)doc : NULL;
829 return S_OK;
832 static HRESULT WINAPI HTMLFrameElement3_put_src(IHTMLFrameElement3 *iface, BSTR v)
834 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
835 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
836 return E_NOTIMPL;
839 static HRESULT WINAPI HTMLFrameElement3_get_src(IHTMLFrameElement3 *iface, BSTR *p)
841 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
842 FIXME("(%p)->(%p)\n", This, p);
843 return E_NOTIMPL;
846 static HRESULT WINAPI HTMLFrameElement3_put_longDesc(IHTMLFrameElement3 *iface, BSTR v)
848 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
849 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
850 return E_NOTIMPL;
853 static HRESULT WINAPI HTMLFrameElement3_get_longDesc(IHTMLFrameElement3 *iface, BSTR *p)
855 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
856 FIXME("(%p)->(%p)\n", This, p);
857 return E_NOTIMPL;
860 static HRESULT WINAPI HTMLFrameElement3_put_frameBorder(IHTMLFrameElement3 *iface, BSTR v)
862 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
863 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
864 return E_NOTIMPL;
867 static HRESULT WINAPI HTMLFrameElement3_get_frameBorder(IHTMLFrameElement3 *iface, BSTR *p)
869 HTMLFrameElement *This = impl_from_IHTMLFrameElement3(iface);
870 FIXME("(%p)->(%p)\n", This, p);
871 return E_NOTIMPL;
874 static const IHTMLFrameElement3Vtbl HTMLFrameElement3Vtbl = {
875 HTMLFrameElement3_QueryInterface,
876 HTMLFrameElement3_AddRef,
877 HTMLFrameElement3_Release,
878 HTMLFrameElement3_GetTypeInfoCount,
879 HTMLFrameElement3_GetTypeInfo,
880 HTMLFrameElement3_GetIDsOfNames,
881 HTMLFrameElement3_Invoke,
882 HTMLFrameElement3_get_contentDocument,
883 HTMLFrameElement3_put_src,
884 HTMLFrameElement3_get_src,
885 HTMLFrameElement3_put_longDesc,
886 HTMLFrameElement3_get_longDesc,
887 HTMLFrameElement3_put_frameBorder,
888 HTMLFrameElement3_get_frameBorder
891 static inline HTMLFrameElement *frame_from_HTMLDOMNode(HTMLDOMNode *iface)
893 return CONTAINING_RECORD(iface, HTMLFrameElement, framebase.element.node);
896 static HRESULT HTMLFrameElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
898 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
900 if(IsEqualGUID(&IID_IHTMLFrameElement3, riid)) {
901 TRACE("(%p)->(IID_IHTMLFrameElement3 %p)\n", This, ppv);
902 *ppv = &This->IHTMLFrameElement3_iface;
903 }else {
904 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
907 IUnknown_AddRef((IUnknown*)*ppv);
908 return S_OK;
911 static void HTMLFrameElement_destructor(HTMLDOMNode *iface)
913 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
915 HTMLFrameBase_destructor(&This->framebase);
918 static HRESULT HTMLFrameElement_get_document(HTMLDOMNode *iface, IDispatch **p)
920 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
922 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
923 *p = NULL;
924 return S_OK;
927 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->IHTMLDocument2_iface;
928 IDispatch_AddRef(*p);
929 return S_OK;
932 static HRESULT HTMLFrameElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
934 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
936 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
939 static HRESULT HTMLFrameElement_get_dispid(HTMLDOMNode *iface, BSTR name,
940 DWORD grfdex, DISPID *pid)
942 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
944 if(!This->framebase.content_window)
945 return DISP_E_UNKNOWNNAME;
947 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
950 static HRESULT HTMLFrameElement_get_name(HTMLDOMNode *iface, DISPID id, BSTR *name)
952 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
953 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
955 if(!This->framebase.content_window ||
956 idx >= This->framebase.content_window->base.inner_window->global_prop_cnt)
957 return DISP_E_MEMBERNOTFOUND;
959 *name = SysAllocString(This->framebase.content_window->base.inner_window->global_props[idx].name);
960 return *name ? S_OK : E_OUTOFMEMORY;
963 static HRESULT HTMLFrameElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
964 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
966 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
968 if(!This->framebase.content_window) {
969 ERR("no content window to invoke on\n");
970 return E_FAIL;
973 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
974 flags, params, res, ei, caller);
977 static HRESULT HTMLFrameElement_bind_to_tree(HTMLDOMNode *iface)
979 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
980 nsIDOMDocument *nsdoc;
981 nsresult nsres;
982 HRESULT hres;
984 nsres = nsIDOMHTMLFrameElement_GetContentDocument(This->framebase.nsframe, &nsdoc);
985 if(NS_FAILED(nsres) || !nsdoc) {
986 ERR("GetContentDocument failed: %08lx\n", nsres);
987 return E_FAIL;
990 hres = set_frame_doc(&This->framebase, nsdoc);
991 nsIDOMDocument_Release(nsdoc);
992 return hres;
995 static void HTMLFrameElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
997 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
999 if(This->framebase.nsframe)
1000 note_cc_edge((nsISupports*)This->framebase.nsframe, "This->nsframe", cb);
1003 static void HTMLFrameElement_unlink(HTMLDOMNode *iface)
1005 HTMLFrameElement *This = frame_from_HTMLDOMNode(iface);
1007 if(This->framebase.nsframe) {
1008 nsIDOMHTMLFrameElement *nsframe = This->framebase.nsframe;
1010 This->framebase.nsframe = NULL;
1011 nsIDOMHTMLFrameElement_Release(nsframe);
1015 static const NodeImplVtbl HTMLFrameElementImplVtbl = {
1016 &CLSID_HTMLFrameElement,
1017 HTMLFrameElement_QI,
1018 HTMLFrameElement_destructor,
1019 HTMLElement_cpc,
1020 HTMLElement_clone,
1021 HTMLElement_handle_event,
1022 HTMLElement_get_attr_col,
1023 NULL,
1024 NULL,
1025 NULL,
1026 HTMLFrameElement_get_document,
1027 HTMLFrameElement_get_readystate,
1028 HTMLFrameElement_get_dispid,
1029 HTMLFrameElement_get_name,
1030 HTMLFrameElement_invoke,
1031 HTMLFrameElement_bind_to_tree,
1032 HTMLFrameElement_traverse,
1033 HTMLFrameElement_unlink
1036 static const tid_t HTMLFrameElement_iface_tids[] = {
1037 HTMLELEMENT_TIDS,
1038 IHTMLFrameBase_tid,
1039 IHTMLFrameBase2_tid,
1040 IHTMLFrameElement3_tid,
1044 static dispex_static_data_t HTMLFrameElement_dispex = {
1045 L"HTMLFrameElement",
1046 NULL,
1047 DispHTMLFrameElement_tid,
1048 HTMLFrameElement_iface_tids,
1049 HTMLElement_init_dispex_info
1052 HRESULT HTMLFrameElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1054 HTMLFrameElement *ret;
1056 ret = calloc(1, sizeof(HTMLFrameElement));
1057 if(!ret)
1058 return E_OUTOFMEMORY;
1060 ret->framebase.element.node.vtbl = &HTMLFrameElementImplVtbl;
1061 ret->IHTMLFrameElement3_iface.lpVtbl = &HTMLFrameElement3Vtbl;
1063 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLFrameElement_dispex);
1065 *elem = &ret->framebase.element;
1066 return S_OK;
1069 struct HTMLIFrame {
1070 HTMLFrameBase framebase;
1071 IHTMLIFrameElement IHTMLIFrameElement_iface;
1072 IHTMLIFrameElement2 IHTMLIFrameElement2_iface;
1073 IHTMLIFrameElement3 IHTMLIFrameElement3_iface;
1076 static inline HTMLIFrame *impl_from_IHTMLIFrameElement(IHTMLIFrameElement *iface)
1078 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement_iface);
1081 static HRESULT WINAPI HTMLIFrameElement_QueryInterface(IHTMLIFrameElement *iface,
1082 REFIID riid, void **ppv)
1084 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1086 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1089 static ULONG WINAPI HTMLIFrameElement_AddRef(IHTMLIFrameElement *iface)
1091 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1093 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1096 static ULONG WINAPI HTMLIFrameElement_Release(IHTMLIFrameElement *iface)
1098 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1100 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1103 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfoCount(IHTMLIFrameElement *iface, UINT *pctinfo)
1105 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1106 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1107 pctinfo);
1110 static HRESULT WINAPI HTMLIFrameElement_GetTypeInfo(IHTMLIFrameElement *iface, UINT iTInfo,
1111 LCID lcid, ITypeInfo **ppTInfo)
1113 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1114 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1115 lcid, ppTInfo);
1118 static HRESULT WINAPI HTMLIFrameElement_GetIDsOfNames(IHTMLIFrameElement *iface, REFIID riid,
1119 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1121 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1122 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1123 rgszNames, cNames, lcid, rgDispId);
1126 static HRESULT WINAPI HTMLIFrameElement_Invoke(IHTMLIFrameElement *iface, DISPID dispIdMember,
1127 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1128 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1130 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1131 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1132 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1135 static HRESULT WINAPI HTMLIFrameElement_put_vspace(IHTMLIFrameElement *iface, LONG v)
1137 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1138 FIXME("(%p)->(%ld)\n", This, v);
1139 return E_NOTIMPL;
1142 static HRESULT WINAPI HTMLIFrameElement_get_vspace(IHTMLIFrameElement *iface, LONG *p)
1144 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1145 FIXME("(%p)->(%p)\n", This, p);
1146 return E_NOTIMPL;
1149 static HRESULT WINAPI HTMLIFrameElement_put_hspace(IHTMLIFrameElement *iface, LONG v)
1151 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1152 FIXME("(%p)->(%ld)\n", This, v);
1153 return E_NOTIMPL;
1156 static HRESULT WINAPI HTMLIFrameElement_get_hspace(IHTMLIFrameElement *iface, LONG *p)
1158 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1159 FIXME("(%p)->(%p)\n", This, p);
1160 return E_NOTIMPL;
1163 static HRESULT WINAPI HTMLIFrameElement_put_align(IHTMLIFrameElement *iface, BSTR v)
1165 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1166 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1167 return E_NOTIMPL;
1170 static HRESULT WINAPI HTMLIFrameElement_get_align(IHTMLIFrameElement *iface, BSTR *p)
1172 HTMLIFrame *This = impl_from_IHTMLIFrameElement(iface);
1173 FIXME("(%p)->(%p)\n", This, p);
1174 return E_NOTIMPL;
1177 static const IHTMLIFrameElementVtbl HTMLIFrameElementVtbl = {
1178 HTMLIFrameElement_QueryInterface,
1179 HTMLIFrameElement_AddRef,
1180 HTMLIFrameElement_Release,
1181 HTMLIFrameElement_GetTypeInfoCount,
1182 HTMLIFrameElement_GetTypeInfo,
1183 HTMLIFrameElement_GetIDsOfNames,
1184 HTMLIFrameElement_Invoke,
1185 HTMLIFrameElement_put_vspace,
1186 HTMLIFrameElement_get_vspace,
1187 HTMLIFrameElement_put_hspace,
1188 HTMLIFrameElement_get_hspace,
1189 HTMLIFrameElement_put_align,
1190 HTMLIFrameElement_get_align
1193 static inline HTMLIFrame *impl_from_IHTMLIFrameElement2(IHTMLIFrameElement2 *iface)
1195 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement2_iface);
1198 static HRESULT WINAPI HTMLIFrameElement2_QueryInterface(IHTMLIFrameElement2 *iface,
1199 REFIID riid, void **ppv)
1201 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1203 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1206 static ULONG WINAPI HTMLIFrameElement2_AddRef(IHTMLIFrameElement2 *iface)
1208 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1210 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1213 static ULONG WINAPI HTMLIFrameElement2_Release(IHTMLIFrameElement2 *iface)
1215 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1217 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1220 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfoCount(IHTMLIFrameElement2 *iface, UINT *pctinfo)
1222 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1223 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1224 pctinfo);
1227 static HRESULT WINAPI HTMLIFrameElement2_GetTypeInfo(IHTMLIFrameElement2 *iface, UINT iTInfo,
1228 LCID lcid, ITypeInfo **ppTInfo)
1230 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1231 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1232 lcid, ppTInfo);
1235 static HRESULT WINAPI HTMLIFrameElement2_GetIDsOfNames(IHTMLIFrameElement2 *iface, REFIID riid,
1236 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1238 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1239 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1240 rgszNames, cNames, lcid, rgDispId);
1243 static HRESULT WINAPI HTMLIFrameElement2_Invoke(IHTMLIFrameElement2 *iface, DISPID dispIdMember,
1244 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1245 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1247 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1248 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1249 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1252 static HRESULT WINAPI HTMLIFrameElement2_put_height(IHTMLIFrameElement2 *iface, VARIANT v)
1254 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1255 nsAString nsstr;
1256 nsresult nsres;
1257 HRESULT hres;
1259 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1261 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1262 if(FAILED(hres))
1263 return hres;
1265 nsres = nsIDOMHTMLIFrameElement_SetHeight(This->framebase.nsiframe, &nsstr);
1266 nsAString_Finish(&nsstr);
1267 if(NS_FAILED(nsres)) {
1268 ERR("SetHeight failed: %08lx\n", nsres);
1269 return E_FAIL;
1272 return S_OK;
1275 static HRESULT WINAPI HTMLIFrameElement2_get_height(IHTMLIFrameElement2 *iface, VARIANT *p)
1277 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1278 nsAString nsstr;
1279 nsresult nsres;
1281 TRACE("(%p)->(%p)\n", This, p);
1283 nsAString_Init(&nsstr, NULL);
1284 nsres = nsIDOMHTMLIFrameElement_GetHeight(This->framebase.nsiframe, &nsstr);
1286 V_VT(p) = VT_BSTR;
1287 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1290 static HRESULT WINAPI HTMLIFrameElement2_put_width(IHTMLIFrameElement2 *iface, VARIANT v)
1292 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1293 nsAString nsstr;
1294 nsresult nsres;
1295 HRESULT hres;
1297 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1299 hres = variant_to_nsstr(&v, FALSE, &nsstr);
1300 if(FAILED(hres))
1301 return hres;
1303 nsres = nsIDOMHTMLIFrameElement_SetWidth(This->framebase.nsiframe, &nsstr);
1304 nsAString_Finish(&nsstr);
1305 if(NS_FAILED(nsres)) {
1306 ERR("SetWidth failed: %08lx\n", nsres);
1307 return E_FAIL;
1310 return S_OK;
1313 static HRESULT WINAPI HTMLIFrameElement2_get_width(IHTMLIFrameElement2 *iface, VARIANT *p)
1315 HTMLIFrame *This = impl_from_IHTMLIFrameElement2(iface);
1316 nsAString nsstr;
1317 nsresult nsres;
1319 TRACE("(%p)->(%p)\n", This, p);
1321 nsAString_Init(&nsstr, NULL);
1322 nsres = nsIDOMHTMLIFrameElement_GetWidth(This->framebase.nsiframe, &nsstr);
1324 V_VT(p) = VT_BSTR;
1325 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1328 static const IHTMLIFrameElement2Vtbl HTMLIFrameElement2Vtbl = {
1329 HTMLIFrameElement2_QueryInterface,
1330 HTMLIFrameElement2_AddRef,
1331 HTMLIFrameElement2_Release,
1332 HTMLIFrameElement2_GetTypeInfoCount,
1333 HTMLIFrameElement2_GetTypeInfo,
1334 HTMLIFrameElement2_GetIDsOfNames,
1335 HTMLIFrameElement2_Invoke,
1336 HTMLIFrameElement2_put_height,
1337 HTMLIFrameElement2_get_height,
1338 HTMLIFrameElement2_put_width,
1339 HTMLIFrameElement2_get_width
1342 static inline HTMLIFrame *impl_from_IHTMLIFrameElement3(IHTMLIFrameElement3 *iface)
1344 return CONTAINING_RECORD(iface, HTMLIFrame, IHTMLIFrameElement3_iface);
1347 static HRESULT WINAPI HTMLIFrameElement3_QueryInterface(IHTMLIFrameElement3 *iface,
1348 REFIID riid, void **ppv)
1350 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1352 return IHTMLDOMNode_QueryInterface(&This->framebase.element.node.IHTMLDOMNode_iface, riid, ppv);
1355 static ULONG WINAPI HTMLIFrameElement3_AddRef(IHTMLIFrameElement3 *iface)
1357 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1359 return IHTMLDOMNode_AddRef(&This->framebase.element.node.IHTMLDOMNode_iface);
1362 static ULONG WINAPI HTMLIFrameElement3_Release(IHTMLIFrameElement3 *iface)
1364 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1366 return IHTMLDOMNode_Release(&This->framebase.element.node.IHTMLDOMNode_iface);
1369 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfoCount(IHTMLIFrameElement3 *iface, UINT *pctinfo)
1371 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1372 return IDispatchEx_GetTypeInfoCount(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface,
1373 pctinfo);
1376 static HRESULT WINAPI HTMLIFrameElement3_GetTypeInfo(IHTMLIFrameElement3 *iface, UINT iTInfo,
1377 LCID lcid, ITypeInfo **ppTInfo)
1379 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1380 return IDispatchEx_GetTypeInfo(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, iTInfo,
1381 lcid, ppTInfo);
1384 static HRESULT WINAPI HTMLIFrameElement3_GetIDsOfNames(IHTMLIFrameElement3 *iface, REFIID riid,
1385 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1387 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1388 return IDispatchEx_GetIDsOfNames(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, riid,
1389 rgszNames, cNames, lcid, rgDispId);
1392 static HRESULT WINAPI HTMLIFrameElement3_Invoke(IHTMLIFrameElement3 *iface, DISPID dispIdMember,
1393 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1394 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1396 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1397 return IDispatchEx_Invoke(&This->framebase.element.node.event_target.dispex.IDispatchEx_iface, dispIdMember,
1398 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1401 static HRESULT WINAPI HTMLIFrameElement3_get_contentDocument(IHTMLIFrameElement3 *iface, IDispatch **p)
1403 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1404 IHTMLDocument2 *doc;
1405 HRESULT hres;
1407 TRACE("(%p)->(%p)\n", This, p);
1409 if(!This->framebase.content_window) {
1410 *p = NULL;
1411 return S_OK;
1414 hres = IHTMLWindow2_get_document(&This->framebase.content_window->base.IHTMLWindow2_iface, &doc);
1415 *p = (IDispatch*)doc;
1416 return hres;
1419 static HRESULT WINAPI HTMLIFrameElement3_put_src(IHTMLIFrameElement3 *iface, BSTR v)
1421 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1422 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1423 return E_NOTIMPL;
1426 static HRESULT WINAPI HTMLIFrameElement3_get_src(IHTMLIFrameElement3 *iface, BSTR *p)
1428 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1429 FIXME("(%p)->(%p)\n", This, p);
1430 return E_NOTIMPL;
1433 static HRESULT WINAPI HTMLIFrameElement3_put_longDesc(IHTMLIFrameElement3 *iface, BSTR v)
1435 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1436 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1437 return E_NOTIMPL;
1440 static HRESULT WINAPI HTMLIFrameElement3_get_longDesc(IHTMLIFrameElement3 *iface, BSTR *p)
1442 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1443 FIXME("(%p)->(%p)\n", This, p);
1444 return E_NOTIMPL;
1447 static HRESULT WINAPI HTMLIFrameElement3_put_frameBorder(IHTMLIFrameElement3 *iface, BSTR v)
1449 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1450 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1451 return E_NOTIMPL;
1454 static HRESULT WINAPI HTMLIFrameElement3_get_frameBorder(IHTMLIFrameElement3 *iface, BSTR *p)
1456 HTMLIFrame *This = impl_from_IHTMLIFrameElement3(iface);
1457 FIXME("(%p)->(%p)\n", This, p);
1458 return E_NOTIMPL;
1461 static const IHTMLIFrameElement3Vtbl HTMLIFrameElement3Vtbl = {
1462 HTMLIFrameElement3_QueryInterface,
1463 HTMLIFrameElement3_AddRef,
1464 HTMLIFrameElement3_Release,
1465 HTMLIFrameElement3_GetTypeInfoCount,
1466 HTMLIFrameElement3_GetTypeInfo,
1467 HTMLIFrameElement3_GetIDsOfNames,
1468 HTMLIFrameElement3_Invoke,
1469 HTMLIFrameElement3_get_contentDocument,
1470 HTMLIFrameElement3_put_src,
1471 HTMLIFrameElement3_get_src,
1472 HTMLIFrameElement3_put_longDesc,
1473 HTMLIFrameElement3_get_longDesc,
1474 HTMLIFrameElement3_put_frameBorder,
1475 HTMLIFrameElement3_get_frameBorder
1478 static inline HTMLIFrame *iframe_from_HTMLDOMNode(HTMLDOMNode *iface)
1480 return CONTAINING_RECORD(iface, HTMLIFrame, framebase.element.node);
1483 static HRESULT HTMLIFrame_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1485 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1487 if(IsEqualGUID(&IID_IHTMLIFrameElement, riid)) {
1488 TRACE("(%p)->(IID_IHTMLIFrameElement %p)\n", This, ppv);
1489 *ppv = &This->IHTMLIFrameElement_iface;
1490 }else if(IsEqualGUID(&IID_IHTMLIFrameElement2, riid)) {
1491 TRACE("(%p)->(IID_IHTMLIFrameElement2 %p)\n", This, ppv);
1492 *ppv = &This->IHTMLIFrameElement2_iface;
1493 }else if(IsEqualGUID(&IID_IHTMLIFrameElement3, riid)) {
1494 TRACE("(%p)->(IID_IHTMLIFrameElement3 %p)\n", This, ppv);
1495 *ppv = &This->IHTMLIFrameElement3_iface;
1496 }else {
1497 return HTMLFrameBase_QI(&This->framebase, riid, ppv);
1500 IUnknown_AddRef((IUnknown*)*ppv);
1501 return S_OK;
1504 static void HTMLIFrame_destructor(HTMLDOMNode *iface)
1506 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1508 HTMLFrameBase_destructor(&This->framebase);
1511 static HRESULT HTMLIFrame_get_document(HTMLDOMNode *iface, IDispatch **p)
1513 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1515 if(!This->framebase.content_window || !This->framebase.content_window->base.inner_window->doc) {
1516 *p = NULL;
1517 return S_OK;
1520 *p = (IDispatch*)&This->framebase.content_window->base.inner_window->doc->IHTMLDocument2_iface;
1521 IDispatch_AddRef(*p);
1522 return S_OK;
1525 static HRESULT HTMLIFrame_get_dispid(HTMLDOMNode *iface, BSTR name,
1526 DWORD grfdex, DISPID *pid)
1528 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1530 if(!This->framebase.content_window)
1531 return DISP_E_UNKNOWNNAME;
1533 return search_window_props(This->framebase.content_window->base.inner_window, name, grfdex, pid);
1536 static HRESULT HTMLIFrame_get_name(HTMLDOMNode *iface, DISPID id, BSTR *name)
1538 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1539 DWORD idx = id - MSHTML_DISPID_CUSTOM_MIN;
1541 if(!This->framebase.content_window ||
1542 idx >= This->framebase.content_window->base.inner_window->global_prop_cnt)
1543 return DISP_E_MEMBERNOTFOUND;
1545 *name = SysAllocString(This->framebase.content_window->base.inner_window->global_props[idx].name);
1546 return *name ? S_OK : E_OUTOFMEMORY;
1549 static HRESULT HTMLIFrame_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid,
1550 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1552 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1554 if(!This->framebase.content_window) {
1555 ERR("no content window to invoke on\n");
1556 return E_FAIL;
1559 return IDispatchEx_InvokeEx(&This->framebase.content_window->base.IDispatchEx_iface, id, lcid,
1560 flags, params, res, ei, caller);
1563 static HRESULT HTMLIFrame_get_readystate(HTMLDOMNode *iface, BSTR *p)
1565 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1567 return IHTMLFrameBase2_get_readyState(&This->framebase.IHTMLFrameBase2_iface, p);
1570 static HRESULT HTMLIFrame_bind_to_tree(HTMLDOMNode *iface)
1572 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1573 nsIDOMDocument *nsdoc;
1574 nsresult nsres;
1575 HRESULT hres;
1577 nsres = nsIDOMHTMLIFrameElement_GetContentDocument(This->framebase.nsiframe, &nsdoc);
1578 if(NS_FAILED(nsres) || !nsdoc) {
1579 ERR("GetContentDocument failed: %08lx\n", nsres);
1580 return E_FAIL;
1583 hres = set_frame_doc(&This->framebase, nsdoc);
1584 nsIDOMDocument_Release(nsdoc);
1585 return hres;
1588 static void HTMLIFrame_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1590 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1592 if(This->framebase.nsiframe)
1593 note_cc_edge((nsISupports*)This->framebase.nsiframe, "This->nsiframe", cb);
1596 static void HTMLIFrame_unlink(HTMLDOMNode *iface)
1598 HTMLIFrame *This = iframe_from_HTMLDOMNode(iface);
1600 if(This->framebase.nsiframe) {
1601 nsIDOMHTMLIFrameElement *nsiframe = This->framebase.nsiframe;
1603 This->framebase.nsiframe = NULL;
1604 nsIDOMHTMLIFrameElement_Release(nsiframe);
1608 static const NodeImplVtbl HTMLIFrameImplVtbl = {
1609 &CLSID_HTMLIFrame,
1610 HTMLIFrame_QI,
1611 HTMLIFrame_destructor,
1612 HTMLElement_cpc,
1613 HTMLElement_clone,
1614 HTMLElement_handle_event,
1615 HTMLElement_get_attr_col,
1616 NULL,
1617 NULL,
1618 NULL,
1619 HTMLIFrame_get_document,
1620 HTMLIFrame_get_readystate,
1621 HTMLIFrame_get_dispid,
1622 HTMLIFrame_get_name,
1623 HTMLIFrame_invoke,
1624 HTMLIFrame_bind_to_tree,
1625 HTMLIFrame_traverse,
1626 HTMLIFrame_unlink
1629 static const tid_t HTMLIFrame_iface_tids[] = {
1630 HTMLELEMENT_TIDS,
1631 IHTMLFrameBase_tid,
1632 IHTMLFrameBase2_tid,
1633 IHTMLIFrameElement_tid,
1634 IHTMLIFrameElement2_tid,
1635 IHTMLIFrameElement3_tid,
1639 static dispex_static_data_t HTMLIFrame_dispex = {
1640 L"HTMLIFrameElement",
1641 NULL,
1642 DispHTMLIFrame_tid,
1643 HTMLIFrame_iface_tids,
1644 HTMLElement_init_dispex_info
1647 HRESULT HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1649 HTMLIFrame *ret;
1651 ret = calloc(1, sizeof(HTMLIFrame));
1652 if(!ret)
1653 return E_OUTOFMEMORY;
1655 ret->IHTMLIFrameElement_iface.lpVtbl = &HTMLIFrameElementVtbl;
1656 ret->IHTMLIFrameElement2_iface.lpVtbl = &HTMLIFrameElement2Vtbl;
1657 ret->IHTMLIFrameElement3_iface.lpVtbl = &HTMLIFrameElement3Vtbl;
1658 ret->framebase.element.node.vtbl = &HTMLIFrameImplVtbl;
1660 HTMLFrameBase_Init(&ret->framebase, doc, nselem, &HTMLIFrame_dispex);
1662 *elem = &ret->framebase.element;
1663 return S_OK;