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 "mshtml_private.h"
22 HTMLTextContainer textcont
;
24 IHTMLBodyElement IHTMLBodyElement_iface
;
26 nsIDOMHTMLBodyElement
*nsbody
;
29 static const WCHAR aquaW
[] = {'a','q','u','a',0};
30 static const WCHAR blackW
[] = {'b','l','a','c','k',0};
31 static const WCHAR blueW
[] = {'b','l','u','e',0};
32 static const WCHAR fuchsiaW
[] = {'f','u','s','h','s','i','a',0};
33 static const WCHAR grayW
[] = {'g','r','a','y',0};
34 static const WCHAR greenW
[] = {'g','r','e','e','n',0};
35 static const WCHAR limeW
[] = {'l','i','m','e',0};
36 static const WCHAR maroonW
[] = {'m','a','r','o','o','n',0};
37 static const WCHAR navyW
[] = {'n','a','v','y',0};
38 static const WCHAR oliveW
[] = {'o','l','i','v','e',0};
39 static const WCHAR purpleW
[] = {'p','u','r','p','l','e',0};
40 static const WCHAR redW
[] = {'r','e','d',0};
41 static const WCHAR silverW
[] = {'s','i','l','v','e','r',0};
42 static const WCHAR tealW
[] = {'t','e','a','l',0};
43 static const WCHAR whiteW
[] = {'w','h','i','t','e',0};
44 static const WCHAR yellowW
[] = {'y','e','l','l','o','w',0};
68 static int comp_value(const WCHAR
*ptr
, int dpc
)
79 else if(isdigitW(ch
= *ptr
++))
80 ret
= ret
*16 + (ch
-'0');
81 else if('a' <= ch
&& ch
<= 'f')
82 ret
= ret
*16 + (ch
-'a') + 10;
83 else if('A' <= ch
&& ch
<= 'F')
84 ret
= ret
*16 + (ch
-'A') + 10;
92 /* Based on Gecko NS_LooseHexToRGB */
93 static int loose_hex_to_rgb(const WCHAR
*hex
)
105 dpc
= min(len
/3 + (len
%3 ? 1 : 0), 4);
106 return (comp_value(hex
, dpc
) << 16)
107 | (comp_value(hex
+dpc
, dpc
) << 8)
108 | comp_value(hex
+2*dpc
, dpc
);
111 HRESULT
nscolor_to_str(LPCWSTR color
, BSTR
*ret
)
116 static const WCHAR formatW
[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
118 if(!color
|| !*color
) {
124 for(i
=0; i
< sizeof(keyword_table
)/sizeof(keyword_table
[0]); i
++) {
125 if(!strcmpiW(color
, keyword_table
[i
].keyword
))
126 rgb
= keyword_table
[i
].rgb
;
130 rgb
= loose_hex_to_rgb(color
);
132 *ret
= SysAllocStringLen(NULL
, 7);
134 return E_OUTOFMEMORY
;
136 sprintfW(*ret
, formatW
, rgb
>>16, (rgb
>>8)&0xff, rgb
&0xff);
138 TRACE("%s -> %s\n", debugstr_w(color
), debugstr_w(*ret
));
142 BOOL
variant_to_nscolor(const VARIANT
*v
, nsAString
*nsstr
)
146 nsAString_Init(nsstr
, V_BSTR(v
));
151 static const WCHAR formatW
[] = {'#','%','x',0};
153 wsprintfW(buf
, formatW
, V_I4(v
));
154 nsAString_Init(nsstr
, buf
);
159 FIXME("invalid color %s\n", debugstr_variant(v
));
166 static HRESULT
return_nscolor(nsresult nsres
, nsAString
*nsstr
, VARIANT
*p
)
168 const PRUnichar
*color
;
170 if(NS_FAILED(nsres
)) {
171 ERR("failed: %08x\n", nsres
);
172 nsAString_Finish(nsstr
);
176 nsAString_GetData(nsstr
, &color
);
180 V_I4(p
) = strtolW(color
+1, NULL
, 16);
183 V_BSTR(p
) = SysAllocString(color
);
185 nsAString_Finish(nsstr
);
186 return E_OUTOFMEMORY
;
190 nsAString_Finish(nsstr
);
191 TRACE("ret %s\n", debugstr_variant(p
));
195 static inline HTMLBodyElement
*impl_from_IHTMLBodyElement(IHTMLBodyElement
*iface
)
197 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLBodyElement_iface
);
200 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
201 REFIID riid
, void **ppv
)
203 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
205 return IHTMLDOMNode_QueryInterface(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
208 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
210 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
212 return IHTMLDOMNode_AddRef(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
);
215 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
217 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
219 return IHTMLDOMNode_Release(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
);
222 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
224 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
225 return IDispatchEx_GetTypeInfoCount(&This
->textcont
.element
.node
.dispex
.IDispatchEx_iface
,
229 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
230 LCID lcid
, ITypeInfo
**ppTInfo
)
232 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
233 return IDispatchEx_GetTypeInfo(&This
->textcont
.element
.node
.dispex
.IDispatchEx_iface
, iTInfo
,
237 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
238 LPOLESTR
*rgszNames
, UINT cNames
,
239 LCID lcid
, DISPID
*rgDispId
)
241 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
242 return IDispatchEx_GetIDsOfNames(&This
->textcont
.element
.node
.dispex
.IDispatchEx_iface
, riid
,
243 rgszNames
, cNames
, lcid
, rgDispId
);
246 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
247 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
248 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
250 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
251 return IDispatchEx_Invoke(&This
->textcont
.element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
,
252 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
255 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
257 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
261 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
263 nsAString_InitDepend(&nsstr
, v
);
264 nsres
= nsIDOMHTMLBodyElement_SetBackground(This
->nsbody
, &nsstr
);
265 nsAString_Finish(&nsstr
);
272 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
274 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
275 nsAString background_str
;
278 TRACE("(%p)->(%p)\n", This
, p
);
280 nsAString_Init(&background_str
, NULL
);
281 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
282 return return_nsstr(nsres
, &background_str
, p
);
285 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
287 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
288 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
292 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
294 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
295 FIXME("(%p)->(%p)\n", This
, p
);
299 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
301 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
302 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
306 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
308 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
309 FIXME("(%p)->(%p)\n", This
, p
);
313 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
315 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
316 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
320 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
322 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
323 FIXME("(%p)->(%p)\n", This
, p
);
327 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
329 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
330 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
334 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
336 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
337 FIXME("(%p)->(%p)\n", This
, p
);
341 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
343 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
344 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
348 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
350 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
351 FIXME("(%p)->(%p)\n", This
, p
);
355 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
357 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
358 FIXME("(%p)->(%x)\n", This
, v
);
362 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
364 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
365 FIXME("(%p)->(%p)\n", This
, p
);
369 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
371 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
375 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
377 if(!variant_to_nscolor(&v
, &strColor
))
380 nsres
= nsIDOMHTMLBodyElement_SetBgColor(This
->nsbody
, &strColor
);
381 nsAString_Finish(&strColor
);
383 ERR("SetBgColor failed: %08x\n", nsres
);
388 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
390 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
395 TRACE("(%p)->(%p)\n", This
, p
);
397 nsAString_Init(&strColor
, NULL
);
398 nsres
= nsIDOMHTMLBodyElement_GetBgColor(This
->nsbody
, &strColor
);
399 if(NS_SUCCEEDED(nsres
)) {
400 const PRUnichar
*color
;
402 nsAString_GetData(&strColor
, &color
);
404 hres
= nscolor_to_str(color
, &V_BSTR(p
));
406 ERR("SetBgColor failed: %08x\n", nsres
);
410 nsAString_Finish(&strColor
);
414 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
416 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
420 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
422 if(!variant_to_nscolor(&v
, &text
))
425 nsres
= nsIDOMHTMLBodyElement_SetText(This
->nsbody
, &text
);
426 nsAString_Finish(&text
);
427 if(NS_FAILED(nsres
)) {
428 ERR("SetText failed: %08x\n", nsres
);
435 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
437 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
442 TRACE("(%p)->(%p)\n", This
, p
);
444 nsAString_Init(&text
, NULL
);
445 nsres
= nsIDOMHTMLBodyElement_GetText(This
->nsbody
, &text
);
446 if(NS_SUCCEEDED(nsres
)) {
447 const PRUnichar
*color
;
449 nsAString_GetData(&text
, &color
);
451 hres
= nscolor_to_str(color
, &V_BSTR(p
));
453 ERR("GetText failed: %08x\n", nsres
);
457 nsAString_Finish(&text
);
462 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
464 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
468 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
470 if(!variant_to_nscolor(&v
, &link_str
))
473 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
474 nsAString_Finish(&link_str
);
476 ERR("SetLink failed: %08x\n", nsres
);
481 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
483 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
487 TRACE("(%p)->(%p)\n", This
, p
);
489 nsAString_Init(&link_str
, NULL
);
490 nsres
= nsIDOMHTMLBodyElement_GetLink(This
->nsbody
, &link_str
);
491 return return_nscolor(nsres
, &link_str
, p
);
494 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
496 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
500 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
502 if(!variant_to_nscolor(&v
, &vlink_str
))
505 nsres
= nsIDOMHTMLBodyElement_SetVLink(This
->nsbody
, &vlink_str
);
506 nsAString_Finish(&vlink_str
);
508 ERR("SetLink failed: %08x\n", nsres
);
513 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
515 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
519 TRACE("(%p)->(%p)\n", This
, p
);
521 nsAString_Init(&vlink_str
, NULL
);
522 nsres
= nsIDOMHTMLBodyElement_GetVLink(This
->nsbody
, &vlink_str
);
523 return return_nscolor(nsres
, &vlink_str
, p
);
526 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
528 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
532 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
534 if(!variant_to_nscolor(&v
, &alink_str
))
537 nsres
= nsIDOMHTMLBodyElement_SetALink(This
->nsbody
, &alink_str
);
538 nsAString_Finish(&alink_str
);
540 ERR("SetALink failed: %08x\n", nsres
);
545 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
547 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
551 TRACE("(%p)->(%p)\n", This
, p
);
553 nsAString_Init(&alink_str
, NULL
);
554 nsres
= nsIDOMHTMLBodyElement_GetALink(This
->nsbody
, &alink_str
);
555 return return_nscolor(nsres
, &alink_str
, p
);
558 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
560 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
562 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
564 return set_node_event(&This
->textcont
.element
.node
, EVENTID_LOAD
, &v
);
567 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
569 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
571 TRACE("(%p)->(%p)\n", This
, p
);
573 return get_node_event(&This
->textcont
.element
.node
, EVENTID_LOAD
, p
);
576 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
578 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
579 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
583 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
585 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
586 FIXME("(%p)->(%p)\n", This
, p
);
590 static const WCHAR autoW
[] = {'a','u','t','o',0};
591 static const WCHAR hiddenW
[] = {'h','i','d','d','e','n',0};
592 static const WCHAR scrollW
[] = {'s','c','r','o','l','l',0};
593 static const WCHAR visibleW
[] = {'v','i','s','i','b','l','e',0};
594 static const WCHAR yesW
[] = {'y','e','s',0};
595 static const WCHAR noW
[] = {'n','o',0};
597 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
599 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
600 static const WCHAR
*val
;
602 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
604 /* Emulate with CSS visibility attribute */
605 if(!strcmpW(v
, yesW
)) {
607 }else if(!strcmpW(v
, autoW
)) {
609 }else if(!strcmpW(v
, noW
)) {
612 WARN("Invalid argument %s\n", debugstr_w(v
));
616 return set_elem_style(&This
->textcont
.element
, STYLEID_OVERFLOW
, val
);
619 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
621 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
622 const WCHAR
*ret
= NULL
;
626 TRACE("(%p)->(%p)\n", This
, p
);
628 /* Emulate with CSS visibility attribute */
629 hres
= get_elem_style(&This
->textcont
.element
, STYLEID_OVERFLOW
, &overflow
);
633 if(!overflow
|| !*overflow
) {
636 }else if(!strcmpW(overflow
, visibleW
) || !strcmpW(overflow
, autoW
)) {
638 }else if(!strcmpW(overflow
, scrollW
)) {
640 }else if(!strcmpW(overflow
, hiddenW
)) {
643 TRACE("Defaulting %s to NULL\n", debugstr_w(overflow
));
648 SysFreeString(overflow
);
650 *p
= SysAllocString(ret
);
651 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
657 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
659 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
660 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
664 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
666 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
667 FIXME("(%p)->(%p)\n", This
, p
);
671 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
673 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
674 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
678 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
680 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
681 FIXME("(%p)->(%p)\n", This
, p
);
685 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
687 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
688 nsIDOMRange
*nsrange
= NULL
;
692 TRACE("(%p)->(%p)\n", This
, range
);
694 if(!This
->textcont
.element
.node
.doc
->nsdoc
) {
699 nsres
= nsIDOMHTMLDocument_CreateRange(This
->textcont
.element
.node
.doc
->nsdoc
, &nsrange
);
700 if(NS_SUCCEEDED(nsres
)) {
701 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
703 ERR("SelectNodeContents failed: %08x\n", nsres
);
705 ERR("CreateRange failed: %08x\n", nsres
);
708 hres
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
->basedoc
.doc_node
, nsrange
, range
);
710 nsIDOMRange_Release(nsrange
);
714 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
715 HTMLBodyElement_QueryInterface
,
716 HTMLBodyElement_AddRef
,
717 HTMLBodyElement_Release
,
718 HTMLBodyElement_GetTypeInfoCount
,
719 HTMLBodyElement_GetTypeInfo
,
720 HTMLBodyElement_GetIDsOfNames
,
721 HTMLBodyElement_Invoke
,
722 HTMLBodyElement_put_background
,
723 HTMLBodyElement_get_background
,
724 HTMLBodyElement_put_bgProperties
,
725 HTMLBodyElement_get_bgProperties
,
726 HTMLBodyElement_put_leftMargin
,
727 HTMLBodyElement_get_leftMargin
,
728 HTMLBodyElement_put_topMargin
,
729 HTMLBodyElement_get_topMargin
,
730 HTMLBodyElement_put_rightMargin
,
731 HTMLBodyElement_get_rightMargin
,
732 HTMLBodyElement_put_bottomMargin
,
733 HTMLBodyElement_get_bottomMargin
,
734 HTMLBodyElement_put_noWrap
,
735 HTMLBodyElement_get_noWrap
,
736 HTMLBodyElement_put_bgColor
,
737 HTMLBodyElement_get_bgColor
,
738 HTMLBodyElement_put_text
,
739 HTMLBodyElement_get_text
,
740 HTMLBodyElement_put_link
,
741 HTMLBodyElement_get_link
,
742 HTMLBodyElement_put_vLink
,
743 HTMLBodyElement_get_vLink
,
744 HTMLBodyElement_put_aLink
,
745 HTMLBodyElement_get_aLink
,
746 HTMLBodyElement_put_onload
,
747 HTMLBodyElement_get_onload
,
748 HTMLBodyElement_put_onunload
,
749 HTMLBodyElement_get_onunload
,
750 HTMLBodyElement_put_scroll
,
751 HTMLBodyElement_get_scroll
,
752 HTMLBodyElement_put_onselect
,
753 HTMLBodyElement_get_onselect
,
754 HTMLBodyElement_put_onbeforeunload
,
755 HTMLBodyElement_get_onbeforeunload
,
756 HTMLBodyElement_createTextRange
759 static inline HTMLBodyElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
761 return CONTAINING_RECORD(iface
, HTMLBodyElement
, textcont
.element
.node
);
764 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
766 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
770 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
771 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
772 *ppv
= &This
->IHTMLBodyElement_iface
;
773 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
774 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
775 *ppv
= &This
->IHTMLBodyElement_iface
;
776 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
777 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
778 *ppv
= &This
->IHTMLBodyElement_iface
;
779 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
780 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This
->textcont
, ppv
);
781 *ppv
= &This
->textcont
.IHTMLTextContainer_iface
;
785 IUnknown_AddRef((IUnknown
*)*ppv
);
789 return HTMLElement_QI(&This
->textcont
.element
.node
, riid
, ppv
);
792 static void HTMLBodyElement_destructor(HTMLDOMNode
*iface
)
794 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
796 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
798 HTMLElement_destructor(&This
->textcont
.element
.node
);
801 static event_target_t
**HTMLBodyElement_get_event_target(HTMLDOMNode
*iface
)
803 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
805 return This
->textcont
.element
.node
.doc
806 ? &This
->textcont
.element
.node
.doc
->body_event_target
807 : &This
->textcont
.element
.node
.event_target
;
810 static const cpc_entry_t HTMLBodyElement_cpc
[] = {
811 {&DIID_HTMLTextContainerEvents
},
812 {&IID_IPropertyNotifySink
},
817 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
819 HTMLBodyElement_destructor
,
822 HTMLElement_handle_event
,
823 HTMLElement_get_attr_col
,
824 HTMLBodyElement_get_event_target
827 static const tid_t HTMLBodyElement_iface_tids
[] = {
828 IHTMLBodyElement_tid
,
829 IHTMLBodyElement2_tid
,
831 IHTMLTextContainer_tid
,
836 static dispex_static_data_t HTMLBodyElement_dispex
= {
840 HTMLBodyElement_iface_tids
843 HRESULT
HTMLBodyElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
845 HTMLBodyElement
*ret
;
848 ret
= heap_alloc_zero(sizeof(HTMLBodyElement
));
850 return E_OUTOFMEMORY
;
852 ret
->IHTMLBodyElement_iface
.lpVtbl
= &HTMLBodyElementVtbl
;
853 ret
->textcont
.element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
855 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
, (void**)&ret
->nsbody
);
856 if(NS_FAILED(nsres
)) {
857 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
859 return E_OUTOFMEMORY
;
862 HTMLTextContainer_Init(&ret
->textcont
, doc
, nselem
, &HTMLBodyElement_dispex
);
864 *elem
= &ret
->textcont
.element
;