mshtml: Implement IHTMLBody get/put_Text.
[wine/hacks.git] / dlls / mshtml / htmlbody.c
blob9fad1874ca7dc647c9bcae35277855425cfd16bf
1 /*
2 * Copyright 2006 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 <stdio.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 HTMLTextContainer textcont;
38 const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
40 ConnectionPoint cp_propnotif;
42 nsIDOMHTMLBodyElement *nsbody;
43 } HTMLBodyElement;
45 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
47 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
49 switch(V_VT(v)) {
50 case VT_BSTR:
51 nsAString_Init(nsstr, V_BSTR(v));
52 return TRUE;
54 case VT_I4: {
55 PRUnichar buf[10];
56 static const WCHAR formatW[] = {'#','%','x',0};
58 wsprintfW(buf, formatW, V_I4(v));
59 nsAString_Init(nsstr, buf);
60 return TRUE;
63 default:
64 FIXME("invalid vt=%d\n", V_VT(v));
67 return FALSE;
71 static void nscolor_to_variant(const nsAString *nsstr, VARIANT *p)
73 const PRUnichar *color;
75 nsAString_GetData(nsstr, &color);
77 if(*color == '#') {
78 V_VT(p) = VT_I4;
79 V_I4(p) = strtolW(color+1, NULL, 16);
80 }else {
81 V_VT(p) = VT_BSTR;
82 V_BSTR(p) = SysAllocString(color);
86 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
88 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
89 REFIID riid, void **ppv)
91 HTMLBodyElement *This = HTMLBODY_THIS(iface);
93 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->textcont.element.node), riid, ppv);
96 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
98 HTMLBodyElement *This = HTMLBODY_THIS(iface);
100 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->textcont.element.node));
103 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
105 HTMLBodyElement *This = HTMLBODY_THIS(iface);
107 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->textcont.element.node));
110 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
112 HTMLBodyElement *This = HTMLBODY_THIS(iface);
113 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->textcont.element.node.dispex), pctinfo);
116 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
117 LCID lcid, ITypeInfo **ppTInfo)
119 HTMLBodyElement *This = HTMLBODY_THIS(iface);
120 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->textcont.element.node.dispex), iTInfo, lcid, ppTInfo);
123 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
124 LPOLESTR *rgszNames, UINT cNames,
125 LCID lcid, DISPID *rgDispId)
127 HTMLBodyElement *This = HTMLBODY_THIS(iface);
128 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->textcont.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
131 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
132 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
133 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
135 HTMLBodyElement *This = HTMLBODY_THIS(iface);
136 return IDispatchEx_Invoke(DISPATCHEX(&This->textcont.element.node.dispex), dispIdMember, riid, lcid,
137 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
140 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
142 HTMLBodyElement *This = HTMLBODY_THIS(iface);
143 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
144 return E_NOTIMPL;
147 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
149 HTMLBodyElement *This = HTMLBODY_THIS(iface);
150 nsAString background_str;
151 nsresult nsres;
153 TRACE("(%p)->(%p)\n", This, p);
155 nsAString_Init(&background_str, NULL);
157 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
158 if(NS_SUCCEEDED(nsres)) {
159 const PRUnichar *background;
160 nsAString_GetData(&background_str, &background);
161 *p = *background ? SysAllocString(background) : NULL;
162 }else {
163 ERR("GetBackground failed: %08x\n", nsres);
164 *p = NULL;
167 nsAString_Finish(&background_str);
169 TRACE("*p = %s\n", debugstr_w(*p));
170 return S_OK;
173 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
175 HTMLBodyElement *This = HTMLBODY_THIS(iface);
176 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
182 HTMLBodyElement *This = HTMLBODY_THIS(iface);
183 FIXME("(%p)->(%p)\n", This, p);
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
189 HTMLBodyElement *This = HTMLBODY_THIS(iface);
190 FIXME("(%p)->()\n", This);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
196 HTMLBodyElement *This = HTMLBODY_THIS(iface);
197 FIXME("(%p)->(%p)\n", This, p);
198 return E_NOTIMPL;
201 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
203 HTMLBodyElement *This = HTMLBODY_THIS(iface);
204 FIXME("(%p)->()\n", This);
205 return E_NOTIMPL;
208 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
210 HTMLBodyElement *This = HTMLBODY_THIS(iface);
211 FIXME("(%p)->(%p)\n", This, p);
212 return E_NOTIMPL;
215 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
217 HTMLBodyElement *This = HTMLBODY_THIS(iface);
218 FIXME("(%p)->()\n", This);
219 return E_NOTIMPL;
222 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
224 HTMLBodyElement *This = HTMLBODY_THIS(iface);
225 FIXME("(%p)->(%p)\n", This, p);
226 return E_NOTIMPL;
229 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
231 HTMLBodyElement *This = HTMLBODY_THIS(iface);
232 FIXME("(%p)->()\n", This);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
238 HTMLBodyElement *This = HTMLBODY_THIS(iface);
239 FIXME("(%p)->(%p)\n", This, p);
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
245 HTMLBodyElement *This = HTMLBODY_THIS(iface);
246 FIXME("(%p)->(%x)\n", This, v);
247 return E_NOTIMPL;
250 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
252 HTMLBodyElement *This = HTMLBODY_THIS(iface);
253 FIXME("(%p)->(%p)\n", This, p);
254 return E_NOTIMPL;
257 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
259 HTMLBodyElement *This = HTMLBODY_THIS(iface);
260 nsAString strColor;
261 nsresult nsres;
263 TRACE("(%p)->()\n", This);
265 if(!variant_to_nscolor(&v, &strColor))
266 return S_OK;
268 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
269 nsAString_Finish(&strColor);
270 if(NS_FAILED(nsres))
271 ERR("SetBgColor failed: %08x\n", nsres);
273 return S_OK;
276 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
278 HTMLBodyElement *This = HTMLBODY_THIS(iface);
279 nsAString strColor;
280 nsresult nsres;
281 const PRUnichar *color;
283 TRACE("(%p)->(%p)\n", This, p);
285 nsAString_Init(&strColor, NULL);
286 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
287 if(NS_FAILED(nsres))
288 ERR("SetBgColor failed: %08x\n", nsres);
290 nsAString_GetData(&strColor, &color);
292 V_VT(p) = VT_BSTR;
293 V_BSTR(p) = SysAllocString(color);
295 nsAString_Finish(&strColor);
297 return S_OK;
300 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
302 HTMLBodyElement *This = HTMLBODY_THIS(iface);
303 nsAString text;
304 nsresult nsres;
306 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
308 if(!variant_to_nscolor(&v, &text))
309 return S_OK;
311 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
312 nsAString_Finish(&text);
314 return S_OK;
317 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
319 HTMLBodyElement *This = HTMLBODY_THIS(iface);
320 nsAString text;
321 nsresult nsres;
323 TRACE("(%p)->(%p)\n", This, p);
325 nsAString_Init(&text, NULL);
327 V_VT(p) = VT_BSTR;
328 V_BSTR(p) = NULL;
330 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
331 if(NS_SUCCEEDED(nsres))
333 const PRUnichar *sText;
334 nsAString_GetData(&text, &sText);
336 V_VT(p) = VT_BSTR;
337 V_BSTR(p) = SysAllocString(sText);
340 nsAString_Finish(&text);
342 return S_OK;
345 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
347 HTMLBodyElement *This = HTMLBODY_THIS(iface);
348 nsAString link_str;
349 nsresult nsres;
351 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
353 if(!variant_to_nscolor(&v, &link_str))
354 return S_OK;
356 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
357 nsAString_Finish(&link_str);
358 if(NS_FAILED(nsres))
359 ERR("SetLink failed: %08x\n", nsres);
361 return S_OK;
364 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
366 HTMLBodyElement *This = HTMLBODY_THIS(iface);
367 nsAString link_str;
368 nsresult nsres;
370 TRACE("(%p)->(%p)\n", This, p);
372 nsAString_Init(&link_str, NULL);
373 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
374 if(NS_FAILED(nsres))
375 ERR("GetLink failed: %08x\n", nsres);
377 nscolor_to_variant(&link_str, p);
378 nsAString_Finish(&link_str);
380 return S_OK;
383 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
385 HTMLBodyElement *This = HTMLBODY_THIS(iface);
386 nsAString vlink_str;
387 nsresult nsres;
389 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
391 if(!variant_to_nscolor(&v, &vlink_str))
392 return S_OK;
394 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
395 nsAString_Finish(&vlink_str);
396 if(NS_FAILED(nsres))
397 ERR("SetLink failed: %08x\n", nsres);
399 return S_OK;
402 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
404 HTMLBodyElement *This = HTMLBODY_THIS(iface);
405 nsAString vlink_str;
406 nsresult nsres;
408 TRACE("(%p)->(%p)\n", This, p);
410 nsAString_Init(&vlink_str, NULL);
411 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
412 if(NS_FAILED(nsres))
413 ERR("GetLink failed: %08x\n", nsres);
415 nscolor_to_variant(&vlink_str, p);
416 nsAString_Finish(&vlink_str);
418 return S_OK;
421 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
423 HTMLBodyElement *This = HTMLBODY_THIS(iface);
424 nsAString alink_str;
425 nsresult nsres;
427 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
429 if(!variant_to_nscolor(&v, &alink_str))
430 return S_OK;
432 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
433 nsAString_Finish(&alink_str);
434 if(NS_FAILED(nsres))
435 ERR("SetALink failed: %08x\n", nsres);
437 return S_OK;
440 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
442 HTMLBodyElement *This = HTMLBODY_THIS(iface);
443 nsAString alink_str;
444 nsresult nsres;
446 TRACE("(%p)->(%p)\n", This, p);
448 nsAString_Init(&alink_str, NULL);
449 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
450 if(NS_FAILED(nsres))
451 ERR("GetALink failed: %08x\n", nsres);
453 nscolor_to_variant(&alink_str, p);
454 nsAString_Finish(&alink_str);
456 return S_OK;
459 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
461 HTMLBodyElement *This = HTMLBODY_THIS(iface);
462 FIXME("(%p)->()\n", This);
463 return E_NOTIMPL;
466 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
468 HTMLBodyElement *This = HTMLBODY_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
470 return E_NOTIMPL;
473 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
475 HTMLBodyElement *This = HTMLBODY_THIS(iface);
476 FIXME("(%p)->()\n", This);
477 return E_NOTIMPL;
480 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
482 HTMLBodyElement *This = HTMLBODY_THIS(iface);
483 FIXME("(%p)->(%p)\n", This, p);
484 return E_NOTIMPL;
487 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
489 HTMLBodyElement *This = HTMLBODY_THIS(iface);
490 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
491 return E_NOTIMPL;
494 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
496 HTMLBodyElement *This = HTMLBODY_THIS(iface);
497 FIXME("(%p)->(%p)\n", This, p);
498 return E_NOTIMPL;
501 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
503 HTMLBodyElement *This = HTMLBODY_THIS(iface);
504 FIXME("(%p)->()\n", This);
505 return E_NOTIMPL;
508 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
510 HTMLBodyElement *This = HTMLBODY_THIS(iface);
511 FIXME("(%p)->(%p)\n", This, p);
512 return E_NOTIMPL;
515 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
517 HTMLBodyElement *This = HTMLBODY_THIS(iface);
518 FIXME("(%p)->()\n", This);
519 return E_NOTIMPL;
522 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
524 HTMLBodyElement *This = HTMLBODY_THIS(iface);
525 FIXME("(%p)->(%p)\n", This, p);
526 return E_NOTIMPL;
529 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
531 HTMLBodyElement *This = HTMLBODY_THIS(iface);
532 nsIDOMRange *nsrange = NULL;
534 TRACE("(%p)->(%p)\n", This, range);
536 if(This->textcont.element.node.doc->nscontainer) {
537 nsIDOMDocument *nsdoc;
538 nsIDOMDocumentRange *nsdocrange;
539 nsresult nsres;
541 nsIWebNavigation_GetDocument(This->textcont.element.node.doc->nscontainer->navigation, &nsdoc);
542 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
543 nsIDOMDocument_Release(nsdoc);
545 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
546 if(NS_SUCCEEDED(nsres)) {
547 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
548 if(NS_FAILED(nsres))
549 ERR("SelectNodeContents failed: %08x\n", nsres);
550 }else {
551 ERR("CreateRange failed: %08x\n", nsres);
554 nsIDOMDocumentRange_Release(nsdocrange);
557 *range = HTMLTxtRange_Create(This->textcont.element.node.doc, nsrange);
558 return S_OK;
561 #undef HTMLBODY_THIS
563 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
564 HTMLBodyElement_QueryInterface,
565 HTMLBodyElement_AddRef,
566 HTMLBodyElement_Release,
567 HTMLBodyElement_GetTypeInfoCount,
568 HTMLBodyElement_GetTypeInfo,
569 HTMLBodyElement_GetIDsOfNames,
570 HTMLBodyElement_Invoke,
571 HTMLBodyElement_put_background,
572 HTMLBodyElement_get_background,
573 HTMLBodyElement_put_bgProperties,
574 HTMLBodyElement_get_bgProperties,
575 HTMLBodyElement_put_leftMargin,
576 HTMLBodyElement_get_leftMargin,
577 HTMLBodyElement_put_topMargin,
578 HTMLBodyElement_get_topMargin,
579 HTMLBodyElement_put_rightMargin,
580 HTMLBodyElement_get_rightMargin,
581 HTMLBodyElement_put_bottomMargin,
582 HTMLBodyElement_get_bottomMargin,
583 HTMLBodyElement_put_noWrap,
584 HTMLBodyElement_get_noWrap,
585 HTMLBodyElement_put_bgColor,
586 HTMLBodyElement_get_bgColor,
587 HTMLBodyElement_put_text,
588 HTMLBodyElement_get_text,
589 HTMLBodyElement_put_link,
590 HTMLBodyElement_get_link,
591 HTMLBodyElement_put_vLink,
592 HTMLBodyElement_get_vLink,
593 HTMLBodyElement_put_aLink,
594 HTMLBodyElement_get_aLink,
595 HTMLBodyElement_put_onload,
596 HTMLBodyElement_get_onload,
597 HTMLBodyElement_put_onunload,
598 HTMLBodyElement_get_onunload,
599 HTMLBodyElement_put_scroll,
600 HTMLBodyElement_get_scroll,
601 HTMLBodyElement_put_onselect,
602 HTMLBodyElement_get_onselect,
603 HTMLBodyElement_put_onbeforeunload,
604 HTMLBodyElement_get_onbeforeunload,
605 HTMLBodyElement_createTextRange
608 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
610 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
612 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
614 *ppv = NULL;
616 if(IsEqualGUID(&IID_IUnknown, riid)) {
617 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
618 *ppv = HTMLBODY(This);
619 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
620 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
621 *ppv = HTMLBODY(This);
622 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
623 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
624 *ppv = HTMLBODY(This);
625 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
626 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
627 *ppv = HTMLTEXTCONT(&This->textcont);
630 if(*ppv) {
631 IUnknown_AddRef((IUnknown*)*ppv);
632 return S_OK;
635 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
638 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
640 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
642 nsIDOMHTMLBodyElement_Release(This->nsbody);
644 HTMLElement_destructor(&This->textcont.element.node);
647 #undef HTMLBODY_NODE_THIS
649 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
650 HTMLBodyElement_QI,
651 HTMLBodyElement_destructor
654 static const tid_t HTMLBodyElement_iface_tids[] = {
655 IHTMLBodyElement_tid,
656 IHTMLBodyElement2_tid,
657 IHTMLControlElement_tid,
658 IHTMLDOMNode_tid,
659 IHTMLDOMNode2_tid,
660 IHTMLElement_tid,
661 IHTMLElement2_tid,
662 IHTMLElement3_tid,
663 IHTMLElement4_tid,
664 IHTMLTextContainer_tid,
665 IHTMLUniqueName_tid,
669 static dispex_static_data_t HTMLBodyElement_dispex = {
670 NULL,
671 DispHTMLBody_tid,
672 NULL,
673 HTMLBodyElement_iface_tids
676 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
678 HTMLBodyElement *ret = heap_alloc_zero(sizeof(HTMLBodyElement));
679 nsresult nsres;
681 TRACE("(%p)->(%p)\n", ret, nselem);
683 HTMLTextContainer_Init(&ret->textcont);
685 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
687 init_dispex(&ret->textcont.element.node.dispex, (IUnknown*)HTMLBODY(ret), &HTMLBodyElement_dispex);
688 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
690 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink);
692 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
693 (void**)&ret->nsbody);
694 if(NS_FAILED(nsres))
695 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
697 return &ret->textcont.element;