push 65f191514f6da34cdfbbc73b8f5d66c351839600
[wine/hacks.git] / dlls / mshtml / htmlbody.c
blob0cbfc06be67713922aa882378f52c7016a2824c9
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) (&(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 HRESULT hr = S_OK;
144 nsAString nsstr;
145 nsresult nsres;
147 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
149 nsAString_Init(&nsstr, v);
151 nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
152 if(!NS_SUCCEEDED(nsres))
154 hr = E_FAIL;
157 nsAString_Finish(&nsstr);
159 return hr;
162 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
164 HTMLBodyElement *This = HTMLBODY_THIS(iface);
165 nsAString background_str;
166 nsresult nsres;
168 TRACE("(%p)->(%p)\n", This, p);
170 nsAString_Init(&background_str, NULL);
172 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
173 if(NS_SUCCEEDED(nsres)) {
174 const PRUnichar *background;
175 nsAString_GetData(&background_str, &background);
176 *p = *background ? SysAllocString(background) : NULL;
177 }else {
178 ERR("GetBackground failed: %08x\n", nsres);
179 *p = NULL;
182 nsAString_Finish(&background_str);
184 TRACE("*p = %s\n", debugstr_w(*p));
185 return S_OK;
188 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
190 HTMLBodyElement *This = HTMLBODY_THIS(iface);
191 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
192 return E_NOTIMPL;
195 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
197 HTMLBodyElement *This = HTMLBODY_THIS(iface);
198 FIXME("(%p)->(%p)\n", This, p);
199 return E_NOTIMPL;
202 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
204 HTMLBodyElement *This = HTMLBODY_THIS(iface);
205 FIXME("(%p)->()\n", This);
206 return E_NOTIMPL;
209 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
211 HTMLBodyElement *This = HTMLBODY_THIS(iface);
212 FIXME("(%p)->(%p)\n", This, p);
213 return E_NOTIMPL;
216 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
218 HTMLBodyElement *This = HTMLBODY_THIS(iface);
219 FIXME("(%p)->()\n", This);
220 return E_NOTIMPL;
223 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
225 HTMLBodyElement *This = HTMLBODY_THIS(iface);
226 FIXME("(%p)->(%p)\n", This, p);
227 return E_NOTIMPL;
230 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
232 HTMLBodyElement *This = HTMLBODY_THIS(iface);
233 FIXME("(%p)->()\n", This);
234 return E_NOTIMPL;
237 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
239 HTMLBodyElement *This = HTMLBODY_THIS(iface);
240 FIXME("(%p)->(%p)\n", This, p);
241 return E_NOTIMPL;
244 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
246 HTMLBodyElement *This = HTMLBODY_THIS(iface);
247 FIXME("(%p)->()\n", This);
248 return E_NOTIMPL;
251 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
253 HTMLBodyElement *This = HTMLBODY_THIS(iface);
254 FIXME("(%p)->(%p)\n", This, p);
255 return E_NOTIMPL;
258 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
260 HTMLBodyElement *This = HTMLBODY_THIS(iface);
261 FIXME("(%p)->(%x)\n", This, v);
262 return E_NOTIMPL;
265 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
267 HTMLBodyElement *This = HTMLBODY_THIS(iface);
268 FIXME("(%p)->(%p)\n", This, p);
269 return E_NOTIMPL;
272 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
274 HTMLBodyElement *This = HTMLBODY_THIS(iface);
275 nsAString strColor;
276 nsresult nsres;
278 TRACE("(%p)->()\n", This);
280 if(!variant_to_nscolor(&v, &strColor))
281 return S_OK;
283 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
284 nsAString_Finish(&strColor);
285 if(NS_FAILED(nsres))
286 ERR("SetBgColor failed: %08x\n", nsres);
288 return S_OK;
291 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
293 HTMLBodyElement *This = HTMLBODY_THIS(iface);
294 nsAString strColor;
295 nsresult nsres;
296 const PRUnichar *color;
298 TRACE("(%p)->(%p)\n", This, p);
300 nsAString_Init(&strColor, NULL);
301 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
302 if(NS_FAILED(nsres))
303 ERR("SetBgColor failed: %08x\n", nsres);
305 nsAString_GetData(&strColor, &color);
307 V_VT(p) = VT_BSTR;
308 V_BSTR(p) = SysAllocString(color);
310 nsAString_Finish(&strColor);
312 return S_OK;
315 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
317 HTMLBodyElement *This = HTMLBODY_THIS(iface);
318 nsAString text;
319 nsresult nsres;
321 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
323 if(!variant_to_nscolor(&v, &text))
324 return S_OK;
326 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
327 nsAString_Finish(&text);
329 return S_OK;
332 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
334 HTMLBodyElement *This = HTMLBODY_THIS(iface);
335 nsAString text;
336 nsresult nsres;
338 TRACE("(%p)->(%p)\n", This, p);
340 nsAString_Init(&text, NULL);
342 V_VT(p) = VT_BSTR;
343 V_BSTR(p) = NULL;
345 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
346 if(NS_SUCCEEDED(nsres))
348 const PRUnichar *sText;
349 nsAString_GetData(&text, &sText);
351 V_VT(p) = VT_BSTR;
352 V_BSTR(p) = SysAllocString(sText);
355 nsAString_Finish(&text);
357 return S_OK;
360 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
362 HTMLBodyElement *This = HTMLBODY_THIS(iface);
363 nsAString link_str;
364 nsresult nsres;
366 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
368 if(!variant_to_nscolor(&v, &link_str))
369 return S_OK;
371 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
372 nsAString_Finish(&link_str);
373 if(NS_FAILED(nsres))
374 ERR("SetLink failed: %08x\n", nsres);
376 return S_OK;
379 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
381 HTMLBodyElement *This = HTMLBODY_THIS(iface);
382 nsAString link_str;
383 nsresult nsres;
385 TRACE("(%p)->(%p)\n", This, p);
387 nsAString_Init(&link_str, NULL);
388 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
389 if(NS_FAILED(nsres))
390 ERR("GetLink failed: %08x\n", nsres);
392 nscolor_to_variant(&link_str, p);
393 nsAString_Finish(&link_str);
395 return S_OK;
398 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
400 HTMLBodyElement *This = HTMLBODY_THIS(iface);
401 nsAString vlink_str;
402 nsresult nsres;
404 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
406 if(!variant_to_nscolor(&v, &vlink_str))
407 return S_OK;
409 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
410 nsAString_Finish(&vlink_str);
411 if(NS_FAILED(nsres))
412 ERR("SetLink failed: %08x\n", nsres);
414 return S_OK;
417 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
419 HTMLBodyElement *This = HTMLBODY_THIS(iface);
420 nsAString vlink_str;
421 nsresult nsres;
423 TRACE("(%p)->(%p)\n", This, p);
425 nsAString_Init(&vlink_str, NULL);
426 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
427 if(NS_FAILED(nsres))
428 ERR("GetLink failed: %08x\n", nsres);
430 nscolor_to_variant(&vlink_str, p);
431 nsAString_Finish(&vlink_str);
433 return S_OK;
436 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
438 HTMLBodyElement *This = HTMLBODY_THIS(iface);
439 nsAString alink_str;
440 nsresult nsres;
442 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
444 if(!variant_to_nscolor(&v, &alink_str))
445 return S_OK;
447 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
448 nsAString_Finish(&alink_str);
449 if(NS_FAILED(nsres))
450 ERR("SetALink failed: %08x\n", nsres);
452 return S_OK;
455 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
457 HTMLBodyElement *This = HTMLBODY_THIS(iface);
458 nsAString alink_str;
459 nsresult nsres;
461 TRACE("(%p)->(%p)\n", This, p);
463 nsAString_Init(&alink_str, NULL);
464 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
465 if(NS_FAILED(nsres))
466 ERR("GetALink failed: %08x\n", nsres);
468 nscolor_to_variant(&alink_str, p);
469 nsAString_Finish(&alink_str);
471 return S_OK;
474 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
476 HTMLBodyElement *This = HTMLBODY_THIS(iface);
477 FIXME("(%p)->()\n", This);
478 return E_NOTIMPL;
481 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
483 HTMLBodyElement *This = HTMLBODY_THIS(iface);
484 FIXME("(%p)->(%p)\n", This, p);
485 return E_NOTIMPL;
488 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
490 HTMLBodyElement *This = HTMLBODY_THIS(iface);
491 FIXME("(%p)->()\n", This);
492 return E_NOTIMPL;
495 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
497 HTMLBodyElement *This = HTMLBODY_THIS(iface);
498 FIXME("(%p)->(%p)\n", This, p);
499 return E_NOTIMPL;
502 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
504 HTMLBodyElement *This = HTMLBODY_THIS(iface);
505 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
506 return E_NOTIMPL;
509 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
511 HTMLBodyElement *This = HTMLBODY_THIS(iface);
512 FIXME("(%p)->(%p)\n", This, p);
513 return E_NOTIMPL;
516 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
518 HTMLBodyElement *This = HTMLBODY_THIS(iface);
519 FIXME("(%p)->()\n", This);
520 return E_NOTIMPL;
523 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
525 HTMLBodyElement *This = HTMLBODY_THIS(iface);
526 FIXME("(%p)->(%p)\n", This, p);
527 return E_NOTIMPL;
530 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
532 HTMLBodyElement *This = HTMLBODY_THIS(iface);
533 FIXME("(%p)->()\n", This);
534 return E_NOTIMPL;
537 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
539 HTMLBodyElement *This = HTMLBODY_THIS(iface);
540 FIXME("(%p)->(%p)\n", This, p);
541 return E_NOTIMPL;
544 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
546 HTMLBodyElement *This = HTMLBODY_THIS(iface);
547 nsIDOMDocumentRange *nsdocrange;
548 nsIDOMRange *nsrange = NULL;
549 nsresult nsres;
551 TRACE("(%p)->(%p)\n", This, range);
553 if(!This->textcont.element.node.doc->nsdoc) {
554 WARN("No nsdoc\n");
555 return E_UNEXPECTED;
558 nsres = nsIDOMDocument_QueryInterface(This->textcont.element.node.doc->nsdoc, &IID_nsIDOMDocumentRange,
559 (void**)&nsdocrange);
560 if(NS_FAILED(nsres)) {
561 ERR("Could not get nsIDOMDocumentRabge iface: %08x\n", nsres);
562 return E_FAIL;
565 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
566 if(NS_SUCCEEDED(nsres)) {
567 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
568 if(NS_FAILED(nsres))
569 ERR("SelectNodeContents failed: %08x\n", nsres);
570 }else {
571 ERR("CreateRange failed: %08x\n", nsres);
574 nsIDOMDocumentRange_Release(nsdocrange);
576 *range = HTMLTxtRange_Create(This->textcont.element.node.doc, nsrange);
577 return S_OK;
580 #undef HTMLBODY_THIS
582 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
583 HTMLBodyElement_QueryInterface,
584 HTMLBodyElement_AddRef,
585 HTMLBodyElement_Release,
586 HTMLBodyElement_GetTypeInfoCount,
587 HTMLBodyElement_GetTypeInfo,
588 HTMLBodyElement_GetIDsOfNames,
589 HTMLBodyElement_Invoke,
590 HTMLBodyElement_put_background,
591 HTMLBodyElement_get_background,
592 HTMLBodyElement_put_bgProperties,
593 HTMLBodyElement_get_bgProperties,
594 HTMLBodyElement_put_leftMargin,
595 HTMLBodyElement_get_leftMargin,
596 HTMLBodyElement_put_topMargin,
597 HTMLBodyElement_get_topMargin,
598 HTMLBodyElement_put_rightMargin,
599 HTMLBodyElement_get_rightMargin,
600 HTMLBodyElement_put_bottomMargin,
601 HTMLBodyElement_get_bottomMargin,
602 HTMLBodyElement_put_noWrap,
603 HTMLBodyElement_get_noWrap,
604 HTMLBodyElement_put_bgColor,
605 HTMLBodyElement_get_bgColor,
606 HTMLBodyElement_put_text,
607 HTMLBodyElement_get_text,
608 HTMLBodyElement_put_link,
609 HTMLBodyElement_get_link,
610 HTMLBodyElement_put_vLink,
611 HTMLBodyElement_get_vLink,
612 HTMLBodyElement_put_aLink,
613 HTMLBodyElement_get_aLink,
614 HTMLBodyElement_put_onload,
615 HTMLBodyElement_get_onload,
616 HTMLBodyElement_put_onunload,
617 HTMLBodyElement_get_onunload,
618 HTMLBodyElement_put_scroll,
619 HTMLBodyElement_get_scroll,
620 HTMLBodyElement_put_onselect,
621 HTMLBodyElement_get_onselect,
622 HTMLBodyElement_put_onbeforeunload,
623 HTMLBodyElement_get_onbeforeunload,
624 HTMLBodyElement_createTextRange
627 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
629 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
631 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
633 *ppv = NULL;
635 if(IsEqualGUID(&IID_IUnknown, riid)) {
636 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
637 *ppv = HTMLBODY(This);
638 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
639 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
640 *ppv = HTMLBODY(This);
641 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
642 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
643 *ppv = HTMLBODY(This);
644 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
645 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
646 *ppv = HTMLTEXTCONT(&This->textcont);
649 if(*ppv) {
650 IUnknown_AddRef((IUnknown*)*ppv);
651 return S_OK;
654 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
657 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
659 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
661 nsIDOMHTMLBodyElement_Release(This->nsbody);
663 HTMLElement_destructor(&This->textcont.element.node);
666 #undef HTMLBODY_NODE_THIS
668 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
669 HTMLBodyElement_QI,
670 HTMLBodyElement_destructor
673 static const tid_t HTMLBodyElement_iface_tids[] = {
674 IHTMLBodyElement_tid,
675 IHTMLBodyElement2_tid,
676 IHTMLDOMNode_tid,
677 IHTMLDOMNode2_tid,
678 IHTMLElement_tid,
679 IHTMLElement2_tid,
680 IHTMLElement3_tid,
681 IHTMLElement4_tid,
682 IHTMLTextContainer_tid,
683 IHTMLUniqueName_tid,
687 static dispex_static_data_t HTMLBodyElement_dispex = {
688 NULL,
689 DispHTMLBody_tid,
690 NULL,
691 HTMLBodyElement_iface_tids
694 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
696 HTMLBodyElement *ret = heap_alloc_zero(sizeof(HTMLBodyElement));
697 nsresult nsres;
699 TRACE("(%p)->(%p)\n", ret, nselem);
701 HTMLTextContainer_Init(&ret->textcont);
703 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
705 init_dispex(&ret->textcont.element.node.dispex, (IUnknown*)HTMLBODY(ret), &HTMLBodyElement_dispex);
706 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
708 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink);
710 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
711 (void**)&ret->nsbody);
712 if(NS_FAILED(nsres))
713 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
715 return &ret->textcont.element;