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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 HTMLTextContainer textcont;
38 IHTMLBodyElement IHTMLBodyElement_iface;
40 ConnectionPoint cp_propnotif;
42 nsIDOMHTMLBodyElement *nsbody;
45 static const WCHAR aquaW[] = {'a','q','u','a',0};
46 static const WCHAR blackW[] = {'b','l','a','c','k',0};
47 static const WCHAR blueW[] = {'b','l','u','e',0};
48 static const WCHAR fuchsiaW[] = {'f','u','s','h','s','i','a',0};
49 static const WCHAR grayW[] = {'g','r','a','y',0};
50 static const WCHAR greenW[] = {'g','r','e','e','n',0};
51 static const WCHAR limeW[] = {'l','i','m','e',0};
52 static const WCHAR maroonW[] = {'m','a','r','o','o','n',0};
53 static const WCHAR navyW[] = {'n','a','v','y',0};
54 static const WCHAR oliveW[] = {'o','l','i','v','e',0};
55 static const WCHAR purpleW[] = {'p','u','r','p','l','e',0};
56 static const WCHAR redW[] = {'r','e','d',0};
57 static const WCHAR silverW[] = {'s','i','l','v','e','r',0};
58 static const WCHAR tealW[] = {'t','e','a','l',0};
59 static const WCHAR whiteW[] = {'w','h','i','t','e',0};
60 static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
84 static int comp_value(const WCHAR *ptr, int dpc)
95 else if(isdigitW(ch = *ptr++))
96 ret = ret*16 + (ch-'0');
97 else if('a' <= ch && ch <= 'f')
98 ret = ret*16 + (ch-'a') + 10;
99 else if('A' <= ch && ch <= 'F')
100 ret = ret*16 + (ch-'A') + 10;
108 /* Based on Gecko NS_LooseHexToRGB */
109 static int loose_hex_to_rgb(const WCHAR *hex)
121 dpc = min(len/3 + (len%3 ? 1 : 0), 4);
122 return (comp_value(hex, dpc) << 16)
123 | (comp_value(hex+dpc, dpc) << 8)
124 | comp_value(hex+2*dpc, dpc);
127 static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
131 static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
133 if(!color || !*color) {
139 for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
140 if(!strcmpiW(color, keyword_table[i].keyword))
141 rgb = keyword_table[i].rgb;
145 rgb = loose_hex_to_rgb(color);
147 *ret = SysAllocStringLen(NULL, 7);
149 return E_OUTOFMEMORY;
151 sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
153 TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
157 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
161 nsAString_Init(nsstr, V_BSTR(v));
166 static const WCHAR formatW[] = {'#','%','x',0};
168 wsprintfW(buf, formatW, V_I4(v));
169 nsAString_Init(nsstr, buf);
174 FIXME("invalid color %s\n", debugstr_variant(v));
181 static HRESULT return_nscolor(nsresult nsres, nsAString *nsstr, VARIANT *p)
183 const PRUnichar *color;
185 if(NS_FAILED(nsres)) {
186 ERR("failed: %08x\n", nsres);
187 nsAString_Finish(nsstr);
191 nsAString_GetData(nsstr, &color);
195 V_I4(p) = strtolW(color+1, NULL, 16);
198 V_BSTR(p) = SysAllocString(color);
200 nsAString_Finish(nsstr);
201 return E_OUTOFMEMORY;
205 nsAString_Finish(nsstr);
206 TRACE("ret %s\n", debugstr_variant(p));
210 static inline HTMLBodyElement *impl_from_IHTMLBodyElement(IHTMLBodyElement *iface)
212 return CONTAINING_RECORD(iface, HTMLBodyElement, IHTMLBodyElement_iface);
215 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
216 REFIID riid, void **ppv)
218 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
220 return IHTMLDOMNode_QueryInterface(&This->textcont.element.node.IHTMLDOMNode_iface, riid, ppv);
223 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
225 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
227 return IHTMLDOMNode_AddRef(&This->textcont.element.node.IHTMLDOMNode_iface);
230 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
232 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
234 return IHTMLDOMNode_Release(&This->textcont.element.node.IHTMLDOMNode_iface);
237 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
239 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
240 return IDispatchEx_GetTypeInfoCount(&This->textcont.element.node.dispex.IDispatchEx_iface,
244 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
245 LCID lcid, ITypeInfo **ppTInfo)
247 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
248 return IDispatchEx_GetTypeInfo(&This->textcont.element.node.dispex.IDispatchEx_iface, iTInfo,
252 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
253 LPOLESTR *rgszNames, UINT cNames,
254 LCID lcid, DISPID *rgDispId)
256 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
257 return IDispatchEx_GetIDsOfNames(&This->textcont.element.node.dispex.IDispatchEx_iface, riid,
258 rgszNames, cNames, lcid, rgDispId);
261 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
262 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
263 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
265 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
266 return IDispatchEx_Invoke(&This->textcont.element.node.dispex.IDispatchEx_iface, dispIdMember,
267 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
270 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
272 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
276 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
278 nsAString_InitDepend(&nsstr, v);
279 nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
280 nsAString_Finish(&nsstr);
287 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
289 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
290 nsAString background_str;
293 TRACE("(%p)->(%p)\n", This, p);
295 nsAString_Init(&background_str, NULL);
296 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
297 return return_nsstr(nsres, &background_str, p);
300 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
302 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
303 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
307 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
309 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
310 FIXME("(%p)->(%p)\n", This, p);
314 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
316 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
317 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
321 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
323 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
324 FIXME("(%p)->(%p)\n", This, p);
328 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
330 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
331 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
335 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
337 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
338 FIXME("(%p)->(%p)\n", This, p);
342 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
344 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
345 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
349 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
351 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
352 FIXME("(%p)->(%p)\n", This, p);
356 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
358 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
359 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
363 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
365 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
366 FIXME("(%p)->(%p)\n", This, p);
370 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
372 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
373 FIXME("(%p)->(%x)\n", This, v);
377 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
379 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
380 FIXME("(%p)->(%p)\n", This, p);
384 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
386 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
390 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
392 if(!variant_to_nscolor(&v, &strColor))
395 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
396 nsAString_Finish(&strColor);
398 ERR("SetBgColor failed: %08x\n", nsres);
403 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
405 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
410 TRACE("(%p)->(%p)\n", This, p);
412 nsAString_Init(&strColor, NULL);
413 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
414 if(NS_SUCCEEDED(nsres)) {
415 const PRUnichar *color;
417 nsAString_GetData(&strColor, &color);
419 hres = nscolor_to_str(color, &V_BSTR(p));
421 ERR("SetBgColor failed: %08x\n", nsres);
425 nsAString_Finish(&strColor);
429 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
431 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
435 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
437 if(!variant_to_nscolor(&v, &text))
440 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
441 nsAString_Finish(&text);
442 if(NS_FAILED(nsres)) {
443 ERR("SetText failed: %08x\n", nsres);
450 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
452 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
457 TRACE("(%p)->(%p)\n", This, p);
459 nsAString_Init(&text, NULL);
460 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
461 if(NS_SUCCEEDED(nsres)) {
462 const PRUnichar *color;
464 nsAString_GetData(&text, &color);
466 hres = nscolor_to_str(color, &V_BSTR(p));
468 ERR("GetText failed: %08x\n", nsres);
472 nsAString_Finish(&text);
477 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
479 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
483 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
485 if(!variant_to_nscolor(&v, &link_str))
488 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
489 nsAString_Finish(&link_str);
491 ERR("SetLink failed: %08x\n", nsres);
496 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
498 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
502 TRACE("(%p)->(%p)\n", This, p);
504 nsAString_Init(&link_str, NULL);
505 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
506 return return_nscolor(nsres, &link_str, p);
509 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
511 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
515 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
517 if(!variant_to_nscolor(&v, &vlink_str))
520 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
521 nsAString_Finish(&vlink_str);
523 ERR("SetLink failed: %08x\n", nsres);
528 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
530 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
534 TRACE("(%p)->(%p)\n", This, p);
536 nsAString_Init(&vlink_str, NULL);
537 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
538 return return_nscolor(nsres, &vlink_str, p);
541 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
543 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
547 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
549 if(!variant_to_nscolor(&v, &alink_str))
552 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
553 nsAString_Finish(&alink_str);
555 ERR("SetALink failed: %08x\n", nsres);
560 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
562 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
566 TRACE("(%p)->(%p)\n", This, p);
568 nsAString_Init(&alink_str, NULL);
569 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
570 return return_nscolor(nsres, &alink_str, p);
573 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
575 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
576 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
580 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
582 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
583 FIXME("(%p)->(%p)\n", This, p);
587 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
589 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
590 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
594 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
596 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
597 FIXME("(%p)->(%p)\n", This, p);
601 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
603 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
604 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
608 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
610 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
611 FIXME("(%p)->(%p)\n", This, p);
615 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
617 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
618 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
622 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
624 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
625 FIXME("(%p)->(%p)\n", This, p);
629 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
631 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
632 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
636 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
638 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
639 FIXME("(%p)->(%p)\n", This, p);
643 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
645 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
646 nsIDOMRange *nsrange = NULL;
650 TRACE("(%p)->(%p)\n", This, range);
652 if(!This->textcont.element.node.doc->nsdoc) {
657 nsres = nsIDOMHTMLDocument_CreateRange(This->textcont.element.node.doc->nsdoc, &nsrange);
658 if(NS_SUCCEEDED(nsres)) {
659 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
661 ERR("SelectNodeContents failed: %08x\n", nsres);
663 ERR("CreateRange failed: %08x\n", nsres);
666 hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, nsrange, range);
668 nsIDOMRange_Release(nsrange);
672 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
673 HTMLBodyElement_QueryInterface,
674 HTMLBodyElement_AddRef,
675 HTMLBodyElement_Release,
676 HTMLBodyElement_GetTypeInfoCount,
677 HTMLBodyElement_GetTypeInfo,
678 HTMLBodyElement_GetIDsOfNames,
679 HTMLBodyElement_Invoke,
680 HTMLBodyElement_put_background,
681 HTMLBodyElement_get_background,
682 HTMLBodyElement_put_bgProperties,
683 HTMLBodyElement_get_bgProperties,
684 HTMLBodyElement_put_leftMargin,
685 HTMLBodyElement_get_leftMargin,
686 HTMLBodyElement_put_topMargin,
687 HTMLBodyElement_get_topMargin,
688 HTMLBodyElement_put_rightMargin,
689 HTMLBodyElement_get_rightMargin,
690 HTMLBodyElement_put_bottomMargin,
691 HTMLBodyElement_get_bottomMargin,
692 HTMLBodyElement_put_noWrap,
693 HTMLBodyElement_get_noWrap,
694 HTMLBodyElement_put_bgColor,
695 HTMLBodyElement_get_bgColor,
696 HTMLBodyElement_put_text,
697 HTMLBodyElement_get_text,
698 HTMLBodyElement_put_link,
699 HTMLBodyElement_get_link,
700 HTMLBodyElement_put_vLink,
701 HTMLBodyElement_get_vLink,
702 HTMLBodyElement_put_aLink,
703 HTMLBodyElement_get_aLink,
704 HTMLBodyElement_put_onload,
705 HTMLBodyElement_get_onload,
706 HTMLBodyElement_put_onunload,
707 HTMLBodyElement_get_onunload,
708 HTMLBodyElement_put_scroll,
709 HTMLBodyElement_get_scroll,
710 HTMLBodyElement_put_onselect,
711 HTMLBodyElement_get_onselect,
712 HTMLBodyElement_put_onbeforeunload,
713 HTMLBodyElement_get_onbeforeunload,
714 HTMLBodyElement_createTextRange
717 static inline HTMLBodyElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
719 return CONTAINING_RECORD(iface, HTMLBodyElement, textcont.element.node);
722 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
724 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
728 if(IsEqualGUID(&IID_IUnknown, riid)) {
729 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
730 *ppv = &This->IHTMLBodyElement_iface;
731 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
732 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
733 *ppv = &This->IHTMLBodyElement_iface;
734 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
735 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
736 *ppv = &This->IHTMLBodyElement_iface;
737 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
738 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
739 *ppv = &This->textcont.IHTMLTextContainer_iface;
743 IUnknown_AddRef((IUnknown*)*ppv);
747 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
750 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
752 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
754 nsIDOMHTMLBodyElement_Release(This->nsbody);
756 HTMLElement_destructor(&This->textcont.element.node);
759 static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
761 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
763 return This->textcont.element.node.doc
764 ? &This->textcont.element.node.doc->body_event_target
765 : &This->textcont.element.node.event_target;
768 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
770 HTMLBodyElement_destructor,
772 HTMLElement_get_attr_col,
773 HTMLBodyElement_get_event_target
776 static const tid_t HTMLBodyElement_iface_tids[] = {
777 IHTMLBodyElement_tid,
778 IHTMLBodyElement2_tid,
780 IHTMLTextContainer_tid,
785 static dispex_static_data_t HTMLBodyElement_dispex = {
789 HTMLBodyElement_iface_tids
792 HRESULT HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
794 HTMLBodyElement *ret;
797 ret = heap_alloc_zero(sizeof(HTMLBodyElement));
799 return E_OUTOFMEMORY;
801 ret->IHTMLBodyElement_iface.lpVtbl = &HTMLBodyElementVtbl;
802 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
804 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement, (void**)&ret->nsbody);
805 if(NS_FAILED(nsres)) {
806 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
808 return E_OUTOFMEMORY;
811 HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
813 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink, NULL);
815 *elem = &ret->textcont.element;