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)
132 static const WCHAR formatW[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
134 if(!color || !*color) {
140 for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
141 if(!strcmpiW(color, keyword_table[i].keyword))
142 rgb = keyword_table[i].rgb;
146 rgb = loose_hex_to_rgb(color);
148 *ret = SysAllocStringLen(NULL, 7);
150 return E_OUTOFMEMORY;
152 sprintfW(*ret, formatW, rgb>>16, (rgb>>8)&0xff, rgb&0xff);
154 TRACE("%s -> %s\n", debugstr_w(color), debugstr_w(*ret));
158 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
162 nsAString_Init(nsstr, V_BSTR(v));
167 static const WCHAR formatW[] = {'#','%','x',0};
169 wsprintfW(buf, formatW, V_I4(v));
170 nsAString_Init(nsstr, buf);
175 FIXME("invalid color %s\n", debugstr_variant(v));
182 static HRESULT return_nscolor(nsresult nsres, nsAString *nsstr, VARIANT *p)
184 const PRUnichar *color;
186 if(NS_FAILED(nsres)) {
187 ERR("failed: %08x\n", nsres);
188 nsAString_Finish(nsstr);
192 nsAString_GetData(nsstr, &color);
196 V_I4(p) = strtolW(color+1, NULL, 16);
199 V_BSTR(p) = SysAllocString(color);
201 nsAString_Finish(nsstr);
202 return E_OUTOFMEMORY;
206 nsAString_Finish(nsstr);
207 TRACE("ret %s\n", debugstr_variant(p));
211 static inline HTMLBodyElement *impl_from_IHTMLBodyElement(IHTMLBodyElement *iface)
213 return CONTAINING_RECORD(iface, HTMLBodyElement, IHTMLBodyElement_iface);
216 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
217 REFIID riid, void **ppv)
219 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
221 return IHTMLDOMNode_QueryInterface(&This->textcont.element.node.IHTMLDOMNode_iface, riid, ppv);
224 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
226 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
228 return IHTMLDOMNode_AddRef(&This->textcont.element.node.IHTMLDOMNode_iface);
231 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
233 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
235 return IHTMLDOMNode_Release(&This->textcont.element.node.IHTMLDOMNode_iface);
238 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
240 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
241 return IDispatchEx_GetTypeInfoCount(&This->textcont.element.node.dispex.IDispatchEx_iface,
245 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
246 LCID lcid, ITypeInfo **ppTInfo)
248 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
249 return IDispatchEx_GetTypeInfo(&This->textcont.element.node.dispex.IDispatchEx_iface, iTInfo,
253 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
254 LPOLESTR *rgszNames, UINT cNames,
255 LCID lcid, DISPID *rgDispId)
257 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
258 return IDispatchEx_GetIDsOfNames(&This->textcont.element.node.dispex.IDispatchEx_iface, riid,
259 rgszNames, cNames, lcid, rgDispId);
262 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
263 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
264 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
266 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
267 return IDispatchEx_Invoke(&This->textcont.element.node.dispex.IDispatchEx_iface, dispIdMember,
268 riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
271 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
273 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
277 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
279 nsAString_InitDepend(&nsstr, v);
280 nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
281 nsAString_Finish(&nsstr);
288 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
290 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
291 nsAString background_str;
294 TRACE("(%p)->(%p)\n", This, p);
296 nsAString_Init(&background_str, NULL);
297 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
298 return return_nsstr(nsres, &background_str, p);
301 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
303 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
304 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
308 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
310 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
311 FIXME("(%p)->(%p)\n", This, p);
315 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
317 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
318 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
322 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
324 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
325 FIXME("(%p)->(%p)\n", This, p);
329 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
331 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
332 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
336 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
338 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
339 FIXME("(%p)->(%p)\n", This, p);
343 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
345 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
346 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
350 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
352 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
353 FIXME("(%p)->(%p)\n", This, p);
357 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
359 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
360 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
364 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
366 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
367 FIXME("(%p)->(%p)\n", This, p);
371 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
373 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
374 FIXME("(%p)->(%x)\n", This, v);
378 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
380 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
381 FIXME("(%p)->(%p)\n", This, p);
385 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
387 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
391 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
393 if(!variant_to_nscolor(&v, &strColor))
396 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
397 nsAString_Finish(&strColor);
399 ERR("SetBgColor failed: %08x\n", nsres);
404 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
406 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
411 TRACE("(%p)->(%p)\n", This, p);
413 nsAString_Init(&strColor, NULL);
414 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
415 if(NS_SUCCEEDED(nsres)) {
416 const PRUnichar *color;
418 nsAString_GetData(&strColor, &color);
420 hres = nscolor_to_str(color, &V_BSTR(p));
422 ERR("SetBgColor failed: %08x\n", nsres);
426 nsAString_Finish(&strColor);
430 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
432 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
436 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
438 if(!variant_to_nscolor(&v, &text))
441 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
442 nsAString_Finish(&text);
443 if(NS_FAILED(nsres)) {
444 ERR("SetText failed: %08x\n", nsres);
451 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
453 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
458 TRACE("(%p)->(%p)\n", This, p);
460 nsAString_Init(&text, NULL);
461 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
462 if(NS_SUCCEEDED(nsres)) {
463 const PRUnichar *color;
465 nsAString_GetData(&text, &color);
467 hres = nscolor_to_str(color, &V_BSTR(p));
469 ERR("GetText failed: %08x\n", nsres);
473 nsAString_Finish(&text);
478 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
480 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
484 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
486 if(!variant_to_nscolor(&v, &link_str))
489 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
490 nsAString_Finish(&link_str);
492 ERR("SetLink failed: %08x\n", nsres);
497 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
499 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
503 TRACE("(%p)->(%p)\n", This, p);
505 nsAString_Init(&link_str, NULL);
506 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
507 return return_nscolor(nsres, &link_str, p);
510 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
512 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
516 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
518 if(!variant_to_nscolor(&v, &vlink_str))
521 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
522 nsAString_Finish(&vlink_str);
524 ERR("SetLink failed: %08x\n", nsres);
529 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
531 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
535 TRACE("(%p)->(%p)\n", This, p);
537 nsAString_Init(&vlink_str, NULL);
538 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
539 return return_nscolor(nsres, &vlink_str, p);
542 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
544 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
548 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
550 if(!variant_to_nscolor(&v, &alink_str))
553 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
554 nsAString_Finish(&alink_str);
556 ERR("SetALink failed: %08x\n", nsres);
561 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
563 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
567 TRACE("(%p)->(%p)\n", This, p);
569 nsAString_Init(&alink_str, NULL);
570 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
571 return return_nscolor(nsres, &alink_str, p);
574 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
576 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
578 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
580 return set_node_event(&This->textcont.element.node, EVENTID_LOAD, &v);
583 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
585 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
587 TRACE("(%p)->(%p)\n", This, p);
589 return get_node_event(&This->textcont.element.node, EVENTID_LOAD, p);
592 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
594 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
595 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
599 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
601 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
602 FIXME("(%p)->(%p)\n", This, p);
606 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
608 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
609 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
613 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
615 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
616 FIXME("(%p)->(%p)\n", This, p);
620 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
622 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
623 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
627 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
629 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
630 FIXME("(%p)->(%p)\n", This, p);
634 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
636 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
637 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
641 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
643 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
644 FIXME("(%p)->(%p)\n", This, p);
648 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
650 HTMLBodyElement *This = impl_from_IHTMLBodyElement(iface);
651 nsIDOMRange *nsrange = NULL;
655 TRACE("(%p)->(%p)\n", This, range);
657 if(!This->textcont.element.node.doc->nsdoc) {
662 nsres = nsIDOMHTMLDocument_CreateRange(This->textcont.element.node.doc->nsdoc, &nsrange);
663 if(NS_SUCCEEDED(nsres)) {
664 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
666 ERR("SelectNodeContents failed: %08x\n", nsres);
668 ERR("CreateRange failed: %08x\n", nsres);
671 hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, nsrange, range);
673 nsIDOMRange_Release(nsrange);
677 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
678 HTMLBodyElement_QueryInterface,
679 HTMLBodyElement_AddRef,
680 HTMLBodyElement_Release,
681 HTMLBodyElement_GetTypeInfoCount,
682 HTMLBodyElement_GetTypeInfo,
683 HTMLBodyElement_GetIDsOfNames,
684 HTMLBodyElement_Invoke,
685 HTMLBodyElement_put_background,
686 HTMLBodyElement_get_background,
687 HTMLBodyElement_put_bgProperties,
688 HTMLBodyElement_get_bgProperties,
689 HTMLBodyElement_put_leftMargin,
690 HTMLBodyElement_get_leftMargin,
691 HTMLBodyElement_put_topMargin,
692 HTMLBodyElement_get_topMargin,
693 HTMLBodyElement_put_rightMargin,
694 HTMLBodyElement_get_rightMargin,
695 HTMLBodyElement_put_bottomMargin,
696 HTMLBodyElement_get_bottomMargin,
697 HTMLBodyElement_put_noWrap,
698 HTMLBodyElement_get_noWrap,
699 HTMLBodyElement_put_bgColor,
700 HTMLBodyElement_get_bgColor,
701 HTMLBodyElement_put_text,
702 HTMLBodyElement_get_text,
703 HTMLBodyElement_put_link,
704 HTMLBodyElement_get_link,
705 HTMLBodyElement_put_vLink,
706 HTMLBodyElement_get_vLink,
707 HTMLBodyElement_put_aLink,
708 HTMLBodyElement_get_aLink,
709 HTMLBodyElement_put_onload,
710 HTMLBodyElement_get_onload,
711 HTMLBodyElement_put_onunload,
712 HTMLBodyElement_get_onunload,
713 HTMLBodyElement_put_scroll,
714 HTMLBodyElement_get_scroll,
715 HTMLBodyElement_put_onselect,
716 HTMLBodyElement_get_onselect,
717 HTMLBodyElement_put_onbeforeunload,
718 HTMLBodyElement_get_onbeforeunload,
719 HTMLBodyElement_createTextRange
722 static inline HTMLBodyElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
724 return CONTAINING_RECORD(iface, HTMLBodyElement, textcont.element.node);
727 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
729 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
733 if(IsEqualGUID(&IID_IUnknown, riid)) {
734 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
735 *ppv = &This->IHTMLBodyElement_iface;
736 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
737 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
738 *ppv = &This->IHTMLBodyElement_iface;
739 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
740 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
741 *ppv = &This->IHTMLBodyElement_iface;
742 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
743 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
744 *ppv = &This->textcont.IHTMLTextContainer_iface;
748 IUnknown_AddRef((IUnknown*)*ppv);
752 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
755 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
757 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
759 nsIDOMHTMLBodyElement_Release(This->nsbody);
761 HTMLElement_destructor(&This->textcont.element.node);
764 static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
766 HTMLBodyElement *This = impl_from_HTMLDOMNode(iface);
768 return This->textcont.element.node.doc
769 ? &This->textcont.element.node.doc->body_event_target
770 : &This->textcont.element.node.event_target;
773 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
775 HTMLBodyElement_destructor,
777 HTMLElement_handle_event,
778 HTMLElement_get_attr_col,
779 HTMLBodyElement_get_event_target
782 static const tid_t HTMLBodyElement_iface_tids[] = {
783 IHTMLBodyElement_tid,
784 IHTMLBodyElement2_tid,
786 IHTMLTextContainer_tid,
791 static dispex_static_data_t HTMLBodyElement_dispex = {
795 HTMLBodyElement_iface_tids
798 HRESULT HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
800 HTMLBodyElement *ret;
803 ret = heap_alloc_zero(sizeof(HTMLBodyElement));
805 return E_OUTOFMEMORY;
807 ret->IHTMLBodyElement_iface.lpVtbl = &HTMLBodyElementVtbl;
808 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
810 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement, (void**)&ret->nsbody);
811 if(NS_FAILED(nsres)) {
812 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
814 return E_OUTOFMEMORY;
817 HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
819 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink, NULL);
821 *elem = &ret->textcont.element;