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"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 HTMLTextContainer textcont;
39 IHTMLBodyElement IHTMLBodyElement_iface;
41 ConnectionPoint cp_propnotif;
43 nsIDOMHTMLBodyElement *nsbody;
46 static const WCHAR aquaW[] = {'a','q','u','a',0};
47 static const WCHAR blackW[] = {'b','l','a','c','k',0};
48 static const WCHAR blueW[] = {'b','l','u','e',0};
49 static const WCHAR fuchsiaW[] = {'f','u','s','h','s','i','a',0};
50 static const WCHAR grayW[] = {'g','r','a','y',0};
51 static const WCHAR greenW[] = {'g','r','e','e','n',0};
52 static const WCHAR limeW[] = {'l','i','m','e',0};
53 static const WCHAR maroonW[] = {'m','a','r','o','o','n',0};
54 static const WCHAR navyW[] = {'n','a','v','y',0};
55 static const WCHAR oliveW[] = {'o','l','i','v','e',0};
56 static const WCHAR purpleW[] = {'p','u','r','p','l','e',0};
57 static const WCHAR redW[] = {'r','e','d',0};
58 static const WCHAR silverW[] = {'s','i','l','v','e','r',0};
59 static const WCHAR tealW[] = {'t','e','a','l',0};
60 static const WCHAR whiteW[] = {'w','h','i','t','e',0};
61 static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
85 static int comp_value(const WCHAR *ptr, int dpc)
96 else if(isdigitW(ch = *ptr++))
97 ret = ret*16 + (ch-'0');
98 else if('a' <= ch && ch <= 'f')
99 ret = ret*16 + (ch-'a') + 10;
100 else if('A' <= ch && ch <= 'F')
101 ret = ret*16 + (ch-'A') + 10;
109 /* Based on Gecko NS_LooseHexToRGB */
110 static int loose_hex_to_rgb(const WCHAR *hex)
122 dpc = min(len/3 + (len%3 ? 1 : 0), 4);
123 return (comp_value(hex, dpc) << 16)
124 | (comp_value(hex+dpc, dpc) << 8)
125 | comp_value(hex+2*dpc, dpc);
128 static HRESULT nscolor_to_str(LPCWSTR color, BSTR *ret)
133 static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
135 if(!color || !*color) {
141 for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
142 if(!strcmpiW(color, keyword_table[i].keyword))
143 rgb = keyword_table[i].rgb;
147 rgb = loose_hex_to_rgb(color);
149 *ret = SysAllocStringLen(NULL, 7);
151 return E_OUTOFMEMORY;
153 sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
155 TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
159 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
163 nsAString_Init(nsstr, V_BSTR(v));
168 static const WCHAR formatW[] = {'#','%','x',0};
170 wsprintfW(buf, formatW, V_I4(v));
171 nsAString_Init(nsstr, buf);
176 FIXME("invalid color %s\n", debugstr_variant(v));
183 static HRESULT return_nscolor(nsresult nsres, nsAString *nsstr, VARIANT *p)
185 const PRUnichar *color;
187 if(NS_FAILED(nsres)) {
188 ERR("failed: %08x\n", nsres);
189 nsAString_Finish(nsstr);
193 nsAString_GetData(nsstr, &color);
197 V_I4(p) = strtolW(color+1, NULL, 16);
200 V_BSTR(p) = SysAllocString(color);
202 nsAString_Finish(nsstr);
203 return E_OUTOFMEMORY;
207 nsAString_Finish(nsstr);
208 TRACE("ret %s\n", debugstr_variant(p));
212 static inline HTMLBodyElement *impl_from_IHTMLBodyElement(IHTMLBodyElement *iface)
214 return CONTAINING_RECORD(iface, HTMLBodyElement, IHTMLBodyElement_iface);
217 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
218 REFIID riid, void **ppv)
220 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
222 return IHTMLDOMNode_QueryInterface(&This->textcont.element.node.IHTMLDOMNode_iface, riid, ppv);
225 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
227 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
229 return IHTMLDOMNode_AddRef(&This->textcont.element.node.IHTMLDOMNode_iface);
232 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
234 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
236 return IHTMLDOMNode_Release(&This->textcont.element.node.IHTMLDOMNode_iface);
239 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
241 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
242 return IDispatchEx_GetTypeInfoCount(&This->textcont.element.node.dispex.IDispatchEx_iface,
246 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
247 LCID lcid, ITypeInfo **ppTInfo)
249 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
250 return IDispatchEx_GetTypeInfo(&This->textcont.element.node.dispex.IDispatchEx_iface, iTInfo,
254 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
255 LPOLESTR *rgszNames, UINT cNames,
256 LCID lcid, DISPID *rgDispId)
258 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
259 return IDispatchEx_GetIDsOfNames(&This->textcont.element.node.dispex.IDispatchEx_iface, riid,
260 rgszNames, cNames, lcid, rgDispId);
263 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
264 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
265 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
267 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
268 return IDispatchEx_Invoke(&This->textcont.element.node.dispex.IDispatchEx_iface, dispIdMember,
269 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
272 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
274 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
278 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
280 nsAString_InitDepend(&nsstr, v);
281 nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
282 nsAString_Finish(&nsstr);
289 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
291 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
292 nsAString background_str;
295 TRACE("(%p)->(%p)\n", This, p);
297 nsAString_Init(&background_str, NULL);
298 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
299 return return_nsstr(nsres, &background_str, p);
302 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
304 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
305 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
309 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
311 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
312 FIXME("(%p)->(%p)\n", This, p);
316 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
318 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
319 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
323 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
325 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
326 FIXME("(%p)->(%p)\n", This, p);
330 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
332 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
333 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
337 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
339 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
340 FIXME("(%p)->(%p)\n", This, p);
344 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
346 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
347 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
351 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
353 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
354 FIXME("(%p)->(%p)\n", This, p);
358 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
360 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
361 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
365 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
367 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
368 FIXME("(%p)->(%p)\n", This, p);
372 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
374 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
375 FIXME("(%p)->(%x)\n", This, v);
379 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
381 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
382 FIXME("(%p)->(%p)\n", This, p);
386 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
388 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
392 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
394 if(!variant_to_nscolor(&v, &strColor))
397 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
398 nsAString_Finish(&strColor);
400 ERR("SetBgColor failed: %08x\n", nsres);
405 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
407 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
412 TRACE("(%p)->(%p)\n", This, p);
414 nsAString_Init(&strColor, NULL);
415 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
416 if(NS_SUCCEEDED(nsres)) {
417 const PRUnichar *color;
419 nsAString_GetData(&strColor, &color);
421 hres = nscolor_to_str(color, &V_BSTR(p));
423 ERR("SetBgColor failed: %08x\n", nsres);
427 nsAString_Finish(&strColor);
431 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
433 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
437 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
439 if(!variant_to_nscolor(&v, &text))
442 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
443 nsAString_Finish(&text);
444 if(NS_FAILED(nsres)) {
445 ERR("SetText failed: %08x\n", nsres);
452 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
454 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
459 TRACE("(%p)->(%p)\n", This, p);
461 nsAString_Init(&text, NULL);
462 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
463 if(NS_SUCCEEDED(nsres)) {
464 const PRUnichar *color;
466 nsAString_GetData(&text, &color);
468 hres = nscolor_to_str(color, &V_BSTR(p));
470 ERR("GetText failed: %08x\n", nsres);
474 nsAString_Finish(&text);
479 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
481 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
485 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
487 if(!variant_to_nscolor(&v, &link_str))
490 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
491 nsAString_Finish(&link_str);
493 ERR("SetLink failed: %08x\n", nsres);
498 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
500 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
504 TRACE("(%p)->(%p)\n", This, p);
506 nsAString_Init(&link_str, NULL);
507 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
508 return return_nscolor(nsres, &link_str, p);
511 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
513 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
517 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
519 if(!variant_to_nscolor(&v, &vlink_str))
522 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
523 nsAString_Finish(&vlink_str);
525 ERR("SetLink failed: %08x\n", nsres);
530 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
532 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
536 TRACE("(%p)->(%p)\n", This, p);
538 nsAString_Init(&vlink_str, NULL);
539 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
540 return return_nscolor(nsres, &vlink_str, p);
543 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
545 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
549 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
551 if(!variant_to_nscolor(&v, &alink_str))
554 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
555 nsAString_Finish(&alink_str);
557 ERR("SetALink failed: %08x\n", nsres);
562 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
564 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
568 TRACE("(%p)->(%p)\n", This, p);
570 nsAString_Init(&alink_str, NULL);
571 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
572 return return_nscolor(nsres, &alink_str, p);
575 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
577 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
579 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
581 return set_node_event(&This->textcont.element.node, EVENTID_LOAD, &v);
584 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
586 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
588 TRACE("(%p)->(%p)\n", This, p);
590 return get_node_event(&This->textcont.element.node, EVENTID_LOAD, p);
593 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
595 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
596 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
600 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
602 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
603 FIXME("(%p)->(%p)\n", This, p);
607 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
609 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
610 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
614 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
616 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
617 FIXME("(%p)->(%p)\n", This, p);
621 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
623 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
624 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
628 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
630 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
631 FIXME("(%p)->(%p)\n", This, p);
635 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
637 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
638 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
642 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
644 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
645 FIXME("(%p)->(%p)\n", This, p);
649 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
651 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
652 nsIDOMRange *nsrange = NULL;
656 TRACE("(%p)->(%p)\n", This, range);
658 if(!This->textcont.element.node.doc->nsdoc) {
663 nsres = nsIDOMHTMLDocument_CreateRange(This->textcont.element.node.doc->nsdoc, &nsrange);
664 if(NS_SUCCEEDED(nsres)) {
665 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
667 ERR("SelectNodeContents failed: %08x\n", nsres);
669 ERR("CreateRange failed: %08x\n", nsres);
672 hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, nsrange, range);
674 nsIDOMRange_Release(nsrange);
678 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
679 HTMLBodyElement_QueryInterface,
680 HTMLBodyElement_AddRef,
681 HTMLBodyElement_Release,
682 HTMLBodyElement_GetTypeInfoCount,
683 HTMLBodyElement_GetTypeInfo,
684 HTMLBodyElement_GetIDsOfNames,
685 HTMLBodyElement_Invoke,
686 HTMLBodyElement_put_background,
687 HTMLBodyElement_get_background,
688 HTMLBodyElement_put_bgProperties,
689 HTMLBodyElement_get_bgProperties,
690 HTMLBodyElement_put_leftMargin,
691 HTMLBodyElement_get_leftMargin,
692 HTMLBodyElement_put_topMargin,
693 HTMLBodyElement_get_topMargin,
694 HTMLBodyElement_put_rightMargin,
695 HTMLBodyElement_get_rightMargin,
696 HTMLBodyElement_put_bottomMargin,
697 HTMLBodyElement_get_bottomMargin,
698 HTMLBodyElement_put_noWrap,
699 HTMLBodyElement_get_noWrap,
700 HTMLBodyElement_put_bgColor,
701 HTMLBodyElement_get_bgColor,
702 HTMLBodyElement_put_text,
703 HTMLBodyElement_get_text,
704 HTMLBodyElement_put_link,
705 HTMLBodyElement_get_link,
706 HTMLBodyElement_put_vLink,
707 HTMLBodyElement_get_vLink,
708 HTMLBodyElement_put_aLink,
709 HTMLBodyElement_get_aLink,
710 HTMLBodyElement_put_onload,
711 HTMLBodyElement_get_onload,
712 HTMLBodyElement_put_onunload,
713 HTMLBodyElement_get_onunload,
714 HTMLBodyElement_put_scroll,
715 HTMLBodyElement_get_scroll,
716 HTMLBodyElement_put_onselect,
717 HTMLBodyElement_get_onselect,
718 HTMLBodyElement_put_onbeforeunload,
719 HTMLBodyElement_get_onbeforeunload,
720 HTMLBodyElement_createTextRange
723 static inline HTMLBodyElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
725 return CONTAINING_RECORD(iface, HTMLBodyElement, textcont.element.node);
728 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
730 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
734 if(IsEqualGUID(&IID_IUnknown, riid)) {
735 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
736 *ppv = &This->IHTMLBodyElement_iface;
737 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
738 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
739 *ppv = &This->IHTMLBodyElement_iface;
740 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
741 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
742 *ppv = &This->IHTMLBodyElement_iface;
743 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
744 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
745 *ppv = &This->textcont.IHTMLTextContainer_iface;
749 IUnknown_AddRef((IUnknown*)*ppv);
753 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
756 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
758 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
760 nsIDOMHTMLBodyElement_Release(This->nsbody);
762 HTMLElement_destructor(&This->textcont.element.node);
765 static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
767 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
769 return This->textcont.element.node.doc
770 ? &This->textcont.element.node.doc->body_event_target
771 : &This->textcont.element.node.event_target;
774 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
776 HTMLBodyElement_destructor,
778 HTMLElement_handle_event,
779 HTMLElement_get_attr_col,
780 HTMLBodyElement_get_event_target
783 static const tid_t HTMLBodyElement_iface_tids[] = {
784 IHTMLBodyElement_tid,
785 IHTMLBodyElement2_tid,
787 IHTMLTextContainer_tid,
792 static dispex_static_data_t HTMLBodyElement_dispex = {
796 HTMLBodyElement_iface_tids
799 HRESULT HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
801 HTMLBodyElement *ret;
804 ret = heap_alloc_zero(sizeof(HTMLBodyElement));
806 return E_OUTOFMEMORY;
808 ret->IHTMLBodyElement_iface.lpVtbl = &HTMLBodyElementVtbl;
809 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
811 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement, (void**)&ret->nsbody);
812 if(NS_FAILED(nsres)) {
813 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
815 return E_OUTOFMEMORY;
818 HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
820 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink, NULL);
822 *elem = &ret->textcont.element;