mshtml: Moved whole element initialization to HTMLElement_Init.
[wine/wine-gecko.git] / dlls / mshtml / htmlbody.c
blob4da3373eba1f9f492bba90d6c254bb3fac2dca8b
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 const WCHAR aquaW[] = {'a','q','u','a',0};
48 static const WCHAR blackW[] = {'b','l','a','c','k',0};
49 static const WCHAR blueW[] = {'b','l','u','e',0};
50 static const WCHAR fuchsiaW[] = {'f','u','s','h','s','i','a',0};
51 static const WCHAR grayW[] = {'g','r','a','y',0};
52 static const WCHAR greenW[] = {'g','r','e','e','n',0};
53 static const WCHAR limeW[] = {'l','i','m','e',0};
54 static const WCHAR maroonW[] = {'m','a','r','o','o','n',0};
55 static const WCHAR navyW[] = {'n','a','v','y',0};
56 static const WCHAR oliveW[] = {'o','l','i','v','e',0};
57 static const WCHAR purpleW[] = {'p','u','r','p','l','e',0};
58 static const WCHAR redW[] = {'r','e','d',0};
59 static const WCHAR silverW[] = {'s','i','l','v','e','r',0};
60 static const WCHAR tealW[] = {'t','e','a','l',0};
61 static const WCHAR whiteW[] = {'w','h','i','t','e',0};
62 static const WCHAR yellowW[] = {'y','e','l','l','o','w',0};
64 static const struct {
65 LPCWSTR keyword;
66 const WCHAR hexstr[8];
67 } keyword_table[] = {
68 {aquaW, {'#','0','0','f','f','f','f',0}},
69 {blackW, {'#','0','0','0','0','0','0',0}},
70 {blueW, {'#','0','0','0','0','f','f',0}},
71 {fuchsiaW, {'#','f','f','0','0','f','f',0}},
72 {grayW, {'#','8','0','8','0','8','0',0}},
73 {greenW, {'#','0','0','8','0','0','0',0}},
74 {limeW, {'#','0','0','f','f','0','0',0}},
75 {maroonW, {'#','8','0','0','0','0','0',0}},
76 {navyW, {'#','0','0','0','0','8','0',0}},
77 {oliveW, {'#','8','0','8','0','0','0',0}},
78 {purpleW, {'#','8','0','0','0','8','0',0}},
79 {redW, {'#','f','f','0','0','0','0',0}},
80 {silverW, {'#','c','0','c','0','c','0',0}},
81 {tealW, {'#','0','0','8','0','8','0',0}},
82 {whiteW, {'#','f','f','f','f','f','f',0}},
83 {yellowW, {'#','f','f','f','f','0','0',0}}
86 static BSTR nscolor_to_str(LPCWSTR color)
88 int i;
90 if(!color || *color == '#')
91 return SysAllocString(color);
93 for(i=0; i < sizeof(keyword_table)/sizeof(keyword_table[0]); i++) {
94 if(!strcmpiW(color, keyword_table[i].keyword))
95 return SysAllocString(keyword_table[i].hexstr);
98 WARN("unknown color %s\n", debugstr_w(color));
99 return SysAllocString(color);
102 static BOOL variant_to_nscolor(const VARIANT *v, nsAString *nsstr)
104 switch(V_VT(v)) {
105 case VT_BSTR:
106 nsAString_Init(nsstr, V_BSTR(v));
107 return TRUE;
109 case VT_I4: {
110 PRUnichar buf[10];
111 static const WCHAR formatW[] = {'#','%','x',0};
113 wsprintfW(buf, formatW, V_I4(v));
114 nsAString_Init(nsstr, buf);
115 return TRUE;
118 default:
119 FIXME("invalid vt=%d\n", V_VT(v));
122 return FALSE;
126 static void nscolor_to_variant(const nsAString *nsstr, VARIANT *p)
128 const PRUnichar *color;
130 nsAString_GetData(nsstr, &color);
132 if(*color == '#') {
133 V_VT(p) = VT_I4;
134 V_I4(p) = strtolW(color+1, NULL, 16);
135 }else {
136 V_VT(p) = VT_BSTR;
137 V_BSTR(p) = SysAllocString(color);
141 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
143 static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
144 REFIID riid, void **ppv)
146 HTMLBodyElement *This = HTMLBODY_THIS(iface);
148 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->textcont.element.node), riid, ppv);
151 static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
153 HTMLBodyElement *This = HTMLBODY_THIS(iface);
155 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->textcont.element.node));
158 static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
160 HTMLBodyElement *This = HTMLBODY_THIS(iface);
162 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->textcont.element.node));
165 static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
167 HTMLBodyElement *This = HTMLBODY_THIS(iface);
168 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->textcont.element.node.dispex), pctinfo);
171 static HRESULT WINAPI HTMLBodyElement_GetTypeInfo(IHTMLBodyElement *iface, UINT iTInfo,
172 LCID lcid, ITypeInfo **ppTInfo)
174 HTMLBodyElement *This = HTMLBODY_THIS(iface);
175 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->textcont.element.node.dispex), iTInfo, lcid, ppTInfo);
178 static HRESULT WINAPI HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement *iface, REFIID riid,
179 LPOLESTR *rgszNames, UINT cNames,
180 LCID lcid, DISPID *rgDispId)
182 HTMLBodyElement *This = HTMLBODY_THIS(iface);
183 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->textcont.element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
186 static HRESULT WINAPI HTMLBodyElement_Invoke(IHTMLBodyElement *iface, DISPID dispIdMember,
187 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
188 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
190 HTMLBodyElement *This = HTMLBODY_THIS(iface);
191 return IDispatchEx_Invoke(DISPATCHEX(&This->textcont.element.node.dispex), dispIdMember, riid, lcid,
192 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
195 static HRESULT WINAPI HTMLBodyElement_put_background(IHTMLBodyElement *iface, BSTR v)
197 HTMLBodyElement *This = HTMLBODY_THIS(iface);
198 HRESULT hr = S_OK;
199 nsAString nsstr;
200 nsresult nsres;
202 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
204 nsAString_Init(&nsstr, v);
206 nsres = nsIDOMHTMLBodyElement_SetBackground(This->nsbody, &nsstr);
207 if(!NS_SUCCEEDED(nsres))
209 hr = E_FAIL;
212 nsAString_Finish(&nsstr);
214 return hr;
217 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
219 HTMLBodyElement *This = HTMLBODY_THIS(iface);
220 nsAString background_str;
221 nsresult nsres;
223 TRACE("(%p)->(%p)\n", This, p);
225 nsAString_Init(&background_str, NULL);
227 nsres = nsIDOMHTMLBodyElement_GetBackground(This->nsbody, &background_str);
228 if(NS_SUCCEEDED(nsres)) {
229 const PRUnichar *background;
230 nsAString_GetData(&background_str, &background);
231 *p = *background ? SysAllocString(background) : NULL;
232 }else {
233 ERR("GetBackground failed: %08x\n", nsres);
234 *p = NULL;
237 nsAString_Finish(&background_str);
239 TRACE("*p = %s\n", debugstr_w(*p));
240 return S_OK;
243 static HRESULT WINAPI HTMLBodyElement_put_bgProperties(IHTMLBodyElement *iface, BSTR v)
245 HTMLBodyElement *This = HTMLBODY_THIS(iface);
246 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
247 return E_NOTIMPL;
250 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
252 HTMLBodyElement *This = HTMLBODY_THIS(iface);
253 FIXME("(%p)->(%p)\n", This, p);
254 return E_NOTIMPL;
257 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
259 HTMLBodyElement *This = HTMLBODY_THIS(iface);
260 FIXME("(%p)->()\n", This);
261 return E_NOTIMPL;
264 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
266 HTMLBodyElement *This = HTMLBODY_THIS(iface);
267 FIXME("(%p)->(%p)\n", This, p);
268 return E_NOTIMPL;
271 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
273 HTMLBodyElement *This = HTMLBODY_THIS(iface);
274 FIXME("(%p)->()\n", This);
275 return E_NOTIMPL;
278 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
280 HTMLBodyElement *This = HTMLBODY_THIS(iface);
281 FIXME("(%p)->(%p)\n", This, p);
282 return E_NOTIMPL;
285 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
287 HTMLBodyElement *This = HTMLBODY_THIS(iface);
288 FIXME("(%p)->()\n", This);
289 return E_NOTIMPL;
292 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
294 HTMLBodyElement *This = HTMLBODY_THIS(iface);
295 FIXME("(%p)->(%p)\n", This, p);
296 return E_NOTIMPL;
299 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
301 HTMLBodyElement *This = HTMLBODY_THIS(iface);
302 FIXME("(%p)->()\n", This);
303 return E_NOTIMPL;
306 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
308 HTMLBodyElement *This = HTMLBODY_THIS(iface);
309 FIXME("(%p)->(%p)\n", This, p);
310 return E_NOTIMPL;
313 static HRESULT WINAPI HTMLBodyElement_put_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL v)
315 HTMLBodyElement *This = HTMLBODY_THIS(iface);
316 FIXME("(%p)->(%x)\n", This, v);
317 return E_NOTIMPL;
320 static HRESULT WINAPI HTMLBodyElement_get_noWrap(IHTMLBodyElement *iface, VARIANT_BOOL *p)
322 HTMLBodyElement *This = HTMLBODY_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, p);
324 return E_NOTIMPL;
327 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
329 HTMLBodyElement *This = HTMLBODY_THIS(iface);
330 nsAString strColor;
331 nsresult nsres;
333 TRACE("(%p)->()\n", This);
335 if(!variant_to_nscolor(&v, &strColor))
336 return S_OK;
338 nsres = nsIDOMHTMLBodyElement_SetBgColor(This->nsbody, &strColor);
339 nsAString_Finish(&strColor);
340 if(NS_FAILED(nsres))
341 ERR("SetBgColor failed: %08x\n", nsres);
343 return S_OK;
346 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
348 HTMLBodyElement *This = HTMLBODY_THIS(iface);
349 nsAString strColor;
350 nsresult nsres;
351 const PRUnichar *color;
353 TRACE("(%p)->(%p)\n", This, p);
355 nsAString_Init(&strColor, NULL);
356 nsres = nsIDOMHTMLBodyElement_GetBgColor(This->nsbody, &strColor);
357 if(NS_FAILED(nsres))
358 ERR("SetBgColor failed: %08x\n", nsres);
360 nsAString_GetData(&strColor, &color);
362 V_VT(p) = VT_BSTR;
363 V_BSTR(p) = nscolor_to_str(color);
365 nsAString_Finish(&strColor);
367 return S_OK;
370 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
372 HTMLBodyElement *This = HTMLBODY_THIS(iface);
373 nsAString text;
374 nsresult nsres;
376 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
378 if(!variant_to_nscolor(&v, &text))
379 return S_OK;
381 nsres = nsIDOMHTMLBodyElement_SetText(This->nsbody, &text);
382 nsAString_Finish(&text);
384 return S_OK;
387 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
389 HTMLBodyElement *This = HTMLBODY_THIS(iface);
390 nsAString text;
391 nsresult nsres;
393 TRACE("(%p)->(%p)\n", This, p);
395 nsAString_Init(&text, NULL);
397 V_VT(p) = VT_BSTR;
398 V_BSTR(p) = NULL;
400 nsres = nsIDOMHTMLBodyElement_GetText(This->nsbody, &text);
401 if(NS_SUCCEEDED(nsres))
403 const PRUnichar *sText;
404 nsAString_GetData(&text, &sText);
406 V_VT(p) = VT_BSTR;
407 V_BSTR(p) = SysAllocString(sText);
410 nsAString_Finish(&text);
412 return S_OK;
415 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
417 HTMLBodyElement *This = HTMLBODY_THIS(iface);
418 nsAString link_str;
419 nsresult nsres;
421 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
423 if(!variant_to_nscolor(&v, &link_str))
424 return S_OK;
426 nsres = nsIDOMHTMLBodyElement_SetLink(This->nsbody, &link_str);
427 nsAString_Finish(&link_str);
428 if(NS_FAILED(nsres))
429 ERR("SetLink failed: %08x\n", nsres);
431 return S_OK;
434 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
436 HTMLBodyElement *This = HTMLBODY_THIS(iface);
437 nsAString link_str;
438 nsresult nsres;
440 TRACE("(%p)->(%p)\n", This, p);
442 nsAString_Init(&link_str, NULL);
443 nsres = nsIDOMHTMLBodyElement_GetLink(This->nsbody, &link_str);
444 if(NS_FAILED(nsres))
445 ERR("GetLink failed: %08x\n", nsres);
447 nscolor_to_variant(&link_str, p);
448 nsAString_Finish(&link_str);
450 return S_OK;
453 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
455 HTMLBodyElement *This = HTMLBODY_THIS(iface);
456 nsAString vlink_str;
457 nsresult nsres;
459 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
461 if(!variant_to_nscolor(&v, &vlink_str))
462 return S_OK;
464 nsres = nsIDOMHTMLBodyElement_SetVLink(This->nsbody, &vlink_str);
465 nsAString_Finish(&vlink_str);
466 if(NS_FAILED(nsres))
467 ERR("SetLink failed: %08x\n", nsres);
469 return S_OK;
472 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
474 HTMLBodyElement *This = HTMLBODY_THIS(iface);
475 nsAString vlink_str;
476 nsresult nsres;
478 TRACE("(%p)->(%p)\n", This, p);
480 nsAString_Init(&vlink_str, NULL);
481 nsres = nsIDOMHTMLBodyElement_GetVLink(This->nsbody, &vlink_str);
482 if(NS_FAILED(nsres))
483 ERR("GetLink failed: %08x\n", nsres);
485 nscolor_to_variant(&vlink_str, p);
486 nsAString_Finish(&vlink_str);
488 return S_OK;
491 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
493 HTMLBodyElement *This = HTMLBODY_THIS(iface);
494 nsAString alink_str;
495 nsresult nsres;
497 TRACE("(%p)->(v%d)\n", This, V_VT(&v));
499 if(!variant_to_nscolor(&v, &alink_str))
500 return S_OK;
502 nsres = nsIDOMHTMLBodyElement_SetALink(This->nsbody, &alink_str);
503 nsAString_Finish(&alink_str);
504 if(NS_FAILED(nsres))
505 ERR("SetALink failed: %08x\n", nsres);
507 return S_OK;
510 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
512 HTMLBodyElement *This = HTMLBODY_THIS(iface);
513 nsAString alink_str;
514 nsresult nsres;
516 TRACE("(%p)->(%p)\n", This, p);
518 nsAString_Init(&alink_str, NULL);
519 nsres = nsIDOMHTMLBodyElement_GetALink(This->nsbody, &alink_str);
520 if(NS_FAILED(nsres))
521 ERR("GetALink failed: %08x\n", nsres);
523 nscolor_to_variant(&alink_str, p);
524 nsAString_Finish(&alink_str);
526 return S_OK;
529 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
531 HTMLBodyElement *This = HTMLBODY_THIS(iface);
532 FIXME("(%p)->()\n", This);
533 return E_NOTIMPL;
536 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
538 HTMLBodyElement *This = HTMLBODY_THIS(iface);
539 FIXME("(%p)->(%p)\n", This, p);
540 return E_NOTIMPL;
543 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
545 HTMLBodyElement *This = HTMLBODY_THIS(iface);
546 FIXME("(%p)->()\n", This);
547 return E_NOTIMPL;
550 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
552 HTMLBodyElement *This = HTMLBODY_THIS(iface);
553 FIXME("(%p)->(%p)\n", This, p);
554 return E_NOTIMPL;
557 static HRESULT WINAPI HTMLBodyElement_put_scroll(IHTMLBodyElement *iface, BSTR v)
559 HTMLBodyElement *This = HTMLBODY_THIS(iface);
560 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
561 return E_NOTIMPL;
564 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
566 HTMLBodyElement *This = HTMLBODY_THIS(iface);
567 FIXME("(%p)->(%p)\n", This, p);
568 return E_NOTIMPL;
571 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
573 HTMLBodyElement *This = HTMLBODY_THIS(iface);
574 FIXME("(%p)->()\n", This);
575 return E_NOTIMPL;
578 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
580 HTMLBodyElement *This = HTMLBODY_THIS(iface);
581 FIXME("(%p)->(%p)\n", This, p);
582 return E_NOTIMPL;
585 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
587 HTMLBodyElement *This = HTMLBODY_THIS(iface);
588 FIXME("(%p)->()\n", This);
589 return E_NOTIMPL;
592 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
594 HTMLBodyElement *This = HTMLBODY_THIS(iface);
595 FIXME("(%p)->(%p)\n", This, p);
596 return E_NOTIMPL;
599 static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range)
601 HTMLBodyElement *This = HTMLBODY_THIS(iface);
602 nsIDOMDocumentRange *nsdocrange;
603 nsIDOMRange *nsrange = NULL;
604 nsresult nsres;
605 HRESULT hres;
607 TRACE("(%p)->(%p)\n", This, range);
609 if(!This->textcont.element.node.doc->nsdoc) {
610 WARN("No nsdoc\n");
611 return E_UNEXPECTED;
614 nsres = nsIDOMDocument_QueryInterface(This->textcont.element.node.doc->nsdoc, &IID_nsIDOMDocumentRange,
615 (void**)&nsdocrange);
616 if(NS_FAILED(nsres)) {
617 ERR("Could not get nsIDOMDocumentRabge iface: %08x\n", nsres);
618 return E_FAIL;
621 nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
622 if(NS_SUCCEEDED(nsres)) {
623 nsres = nsIDOMRange_SelectNodeContents(nsrange, This->textcont.element.node.nsnode);
624 if(NS_FAILED(nsres))
625 ERR("SelectNodeContents failed: %08x\n", nsres);
626 }else {
627 ERR("CreateRange failed: %08x\n", nsres);
630 nsIDOMDocumentRange_Release(nsdocrange);
632 hres = HTMLTxtRange_Create(This->textcont.element.node.doc->basedoc.doc_node, nsrange, range);
634 nsIDOMRange_Release(nsrange);
635 return hres;
638 #undef HTMLBODY_THIS
640 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
641 HTMLBodyElement_QueryInterface,
642 HTMLBodyElement_AddRef,
643 HTMLBodyElement_Release,
644 HTMLBodyElement_GetTypeInfoCount,
645 HTMLBodyElement_GetTypeInfo,
646 HTMLBodyElement_GetIDsOfNames,
647 HTMLBodyElement_Invoke,
648 HTMLBodyElement_put_background,
649 HTMLBodyElement_get_background,
650 HTMLBodyElement_put_bgProperties,
651 HTMLBodyElement_get_bgProperties,
652 HTMLBodyElement_put_leftMargin,
653 HTMLBodyElement_get_leftMargin,
654 HTMLBodyElement_put_topMargin,
655 HTMLBodyElement_get_topMargin,
656 HTMLBodyElement_put_rightMargin,
657 HTMLBodyElement_get_rightMargin,
658 HTMLBodyElement_put_bottomMargin,
659 HTMLBodyElement_get_bottomMargin,
660 HTMLBodyElement_put_noWrap,
661 HTMLBodyElement_get_noWrap,
662 HTMLBodyElement_put_bgColor,
663 HTMLBodyElement_get_bgColor,
664 HTMLBodyElement_put_text,
665 HTMLBodyElement_get_text,
666 HTMLBodyElement_put_link,
667 HTMLBodyElement_get_link,
668 HTMLBodyElement_put_vLink,
669 HTMLBodyElement_get_vLink,
670 HTMLBodyElement_put_aLink,
671 HTMLBodyElement_get_aLink,
672 HTMLBodyElement_put_onload,
673 HTMLBodyElement_get_onload,
674 HTMLBodyElement_put_onunload,
675 HTMLBodyElement_get_onunload,
676 HTMLBodyElement_put_scroll,
677 HTMLBodyElement_get_scroll,
678 HTMLBodyElement_put_onselect,
679 HTMLBodyElement_get_onselect,
680 HTMLBodyElement_put_onbeforeunload,
681 HTMLBodyElement_get_onbeforeunload,
682 HTMLBodyElement_createTextRange
685 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
687 static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
689 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
691 *ppv = NULL;
693 if(IsEqualGUID(&IID_IUnknown, riid)) {
694 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
695 *ppv = HTMLBODY(This);
696 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
697 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
698 *ppv = HTMLBODY(This);
699 }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
700 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
701 *ppv = HTMLBODY(This);
702 }else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
703 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
704 *ppv = HTMLTEXTCONT(&This->textcont);
707 if(*ppv) {
708 IUnknown_AddRef((IUnknown*)*ppv);
709 return S_OK;
712 return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
715 static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
717 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
719 nsIDOMHTMLBodyElement_Release(This->nsbody);
721 HTMLElement_destructor(&This->textcont.element.node);
724 static event_target_t **HTMLBodyElement_get_event_target(HTMLDOMNode *iface)
726 HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
728 return This->textcont.element.node.doc && This->textcont.element.node.doc->basedoc.window
729 ? &This->textcont.element.node.doc->basedoc.window->event_target
730 : &This->textcont.element.node.event_target;
733 #undef HTMLBODY_NODE_THIS
735 static const NodeImplVtbl HTMLBodyElementImplVtbl = {
736 HTMLBodyElement_QI,
737 HTMLBodyElement_destructor,
738 HTMLBodyElement_get_event_target
741 static const tid_t HTMLBodyElement_iface_tids[] = {
742 IHTMLBodyElement_tid,
743 IHTMLBodyElement2_tid,
744 IHTMLDOMNode_tid,
745 IHTMLDOMNode2_tid,
746 IHTMLElement_tid,
747 IHTMLElement2_tid,
748 IHTMLElement3_tid,
749 IHTMLElement4_tid,
750 IHTMLTextContainer_tid,
751 IHTMLUniqueName_tid,
755 static dispex_static_data_t HTMLBodyElement_dispex = {
756 NULL,
757 DispHTMLBody_tid,
758 NULL,
759 HTMLBodyElement_iface_tids
762 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
764 HTMLBodyElement *ret = heap_alloc_zero(sizeof(HTMLBodyElement));
765 nsresult nsres;
767 TRACE("(%p)->(%p)\n", ret, nselem);
769 ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
770 ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
772 HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
774 ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink);
776 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
777 (void**)&ret->nsbody);
778 if(NS_FAILED(nsres))
779 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
781 return &ret->textcont.element;