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
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
35 #include "htmlstyle.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
42 IHTMLBodyElement IHTMLBodyElement_iface
;
43 IHTMLTextContainer IHTMLTextContainer_iface
;
45 nsIDOMHTMLBodyElement
*nsbody
;
55 {L
"fuchsia", 0xff00ff},
59 {L
"maroon", 0x800000},
62 {L
"purple", 0x800080},
64 {L
"silver", 0xc0c0c0},
70 static int comp_value(const WCHAR
*ptr
, int dpc
)
81 else if(is_digit(ch
= *ptr
++))
82 ret
= ret
*16 + (ch
-'0');
83 else if('a' <= ch
&& ch
<= 'f')
84 ret
= ret
*16 + (ch
-'a') + 10;
85 else if('A' <= ch
&& ch
<= 'F')
86 ret
= ret
*16 + (ch
-'A') + 10;
94 /* Based on Gecko NS_LooseHexToRGB */
95 static int loose_hex_to_rgb(const WCHAR
*hex
)
107 dpc
= min(len
/3 + (len
%3 ? 1 : 0), 4);
108 return (comp_value(hex
, dpc
) << 16)
109 | (comp_value(hex
+dpc
, dpc
) << 8)
110 | comp_value(hex
+2*dpc
, dpc
);
113 HRESULT
nscolor_to_str(LPCWSTR color
, BSTR
*ret
)
118 if(!color
|| !*color
) {
124 for(i
=0; i
< ARRAY_SIZE(keyword_table
); i
++) {
125 if(!wcsicmp(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 swprintf(*ret
, 8, L
"#%02x%02x%02x", 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
));
152 wsprintfW(buf
, L
"#%x", V_I4(v
));
153 nsAString_Init(nsstr
, buf
);
158 FIXME("invalid color %s\n", debugstr_variant(v
));
165 static HRESULT
return_nscolor(nsresult nsres
, nsAString
*nsstr
, VARIANT
*p
)
167 const PRUnichar
*color
;
169 if(NS_FAILED(nsres
)) {
170 ERR("failed: %08x\n", nsres
);
171 nsAString_Finish(nsstr
);
175 nsAString_GetData(nsstr
, &color
);
179 V_I4(p
) = wcstol(color
+1, NULL
, 16);
182 V_BSTR(p
) = SysAllocString(color
);
184 nsAString_Finish(nsstr
);
185 return E_OUTOFMEMORY
;
189 nsAString_Finish(nsstr
);
190 TRACE("ret %s\n", debugstr_variant(p
));
194 static inline HTMLBodyElement
*impl_from_IHTMLBodyElement(IHTMLBodyElement
*iface
)
196 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLBodyElement_iface
);
199 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
200 REFIID riid
, void **ppv
)
202 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
204 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
207 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
209 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
211 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
214 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
216 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
218 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
221 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
223 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
224 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
,
228 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
229 LCID lcid
, ITypeInfo
**ppTInfo
)
231 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
232 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
,
236 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
237 LPOLESTR
*rgszNames
, UINT cNames
,
238 LCID lcid
, DISPID
*rgDispId
)
240 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
241 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
,
242 rgszNames
, cNames
, lcid
, rgDispId
);
245 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
246 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
247 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
249 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
250 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
,
251 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
254 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
256 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
260 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
262 nsAString_InitDepend(&nsstr
, v
);
263 nsres
= nsIDOMHTMLBodyElement_SetBackground(This
->nsbody
, &nsstr
);
264 nsAString_Finish(&nsstr
);
271 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
273 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
274 nsAString background_str
;
277 TRACE("(%p)->(%p)\n", This
, p
);
279 nsAString_Init(&background_str
, NULL
);
280 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
281 return return_nsstr(nsres
, &background_str
, p
);
284 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
286 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
287 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
291 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
293 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
294 FIXME("(%p)->(%p)\n", This
, p
);
298 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
300 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
301 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
305 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
307 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
308 FIXME("(%p)->(%p)\n", This
, p
);
312 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
314 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
315 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
319 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
321 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
322 FIXME("(%p)->(%p)\n", This
, p
);
326 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
328 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
329 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
333 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
335 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
336 FIXME("(%p)->(%p)\n", This
, p
);
340 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
342 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
343 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
347 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
349 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
350 FIXME("(%p)->(%p)\n", This
, p
);
354 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
356 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
357 FIXME("(%p)->(%x)\n", This
, v
);
361 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
363 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
364 FIXME("(%p)->(%p)\n", This
, p
);
368 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
370 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
374 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
376 if(!variant_to_nscolor(&v
, &strColor
))
379 nsres
= nsIDOMHTMLBodyElement_SetBgColor(This
->nsbody
, &strColor
);
380 nsAString_Finish(&strColor
);
382 ERR("SetBgColor failed: %08x\n", nsres
);
387 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
389 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
393 TRACE("(%p)->(%p)\n", This
, p
);
395 nsAString_Init(&nsstr
, NULL
);
396 nsres
= nsIDOMHTMLBodyElement_GetBgColor(This
->nsbody
, &nsstr
);
397 return return_nsstr_variant(nsres
, &nsstr
, NSSTR_COLOR
, p
);
400 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
402 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
406 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
408 if(!variant_to_nscolor(&v
, &text
))
411 nsres
= nsIDOMHTMLBodyElement_SetText(This
->nsbody
, &text
);
412 nsAString_Finish(&text
);
413 if(NS_FAILED(nsres
)) {
414 ERR("SetText failed: %08x\n", nsres
);
421 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
423 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
428 TRACE("(%p)->(%p)\n", This
, p
);
430 nsAString_Init(&text
, NULL
);
431 nsres
= nsIDOMHTMLBodyElement_GetText(This
->nsbody
, &text
);
432 if(NS_SUCCEEDED(nsres
)) {
433 const PRUnichar
*color
;
435 nsAString_GetData(&text
, &color
);
437 hres
= nscolor_to_str(color
, &V_BSTR(p
));
439 ERR("GetText failed: %08x\n", nsres
);
443 nsAString_Finish(&text
);
448 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
450 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
454 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
456 if(!variant_to_nscolor(&v
, &link_str
))
459 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
460 nsAString_Finish(&link_str
);
462 ERR("SetLink failed: %08x\n", nsres
);
467 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
469 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
473 TRACE("(%p)->(%p)\n", This
, p
);
475 nsAString_Init(&link_str
, NULL
);
476 nsres
= nsIDOMHTMLBodyElement_GetLink(This
->nsbody
, &link_str
);
477 return return_nscolor(nsres
, &link_str
, p
);
480 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
482 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
486 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
488 if(!variant_to_nscolor(&v
, &vlink_str
))
491 nsres
= nsIDOMHTMLBodyElement_SetVLink(This
->nsbody
, &vlink_str
);
492 nsAString_Finish(&vlink_str
);
494 ERR("SetLink failed: %08x\n", nsres
);
499 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
501 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
505 TRACE("(%p)->(%p)\n", This
, p
);
507 nsAString_Init(&vlink_str
, NULL
);
508 nsres
= nsIDOMHTMLBodyElement_GetVLink(This
->nsbody
, &vlink_str
);
509 return return_nscolor(nsres
, &vlink_str
, p
);
512 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
514 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
518 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
520 if(!variant_to_nscolor(&v
, &alink_str
))
523 nsres
= nsIDOMHTMLBodyElement_SetALink(This
->nsbody
, &alink_str
);
524 nsAString_Finish(&alink_str
);
526 ERR("SetALink failed: %08x\n", nsres
);
531 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
533 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
537 TRACE("(%p)->(%p)\n", This
, p
);
539 nsAString_Init(&alink_str
, NULL
);
540 nsres
= nsIDOMHTMLBodyElement_GetALink(This
->nsbody
, &alink_str
);
541 return return_nscolor(nsres
, &alink_str
, p
);
544 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
546 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
548 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
550 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
553 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
555 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
557 TRACE("(%p)->(%p)\n", This
, p
);
559 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
562 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
564 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
565 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
569 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
571 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
572 FIXME("(%p)->(%p)\n", This
, p
);
576 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
578 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
579 static const WCHAR
*val
;
581 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
583 /* Emulate with CSS visibility attribute */
584 if(!wcscmp(v
, L
"yes")) {
586 }else if(!wcscmp(v
, L
"auto")) {
588 }else if(!wcscmp(v
, L
"no")) {
591 WARN("Invalid argument %s\n", debugstr_w(v
));
595 return set_elem_style(&This
->element
, STYLEID_OVERFLOW
, val
);
598 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
600 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
601 const WCHAR
*ret
= NULL
;
605 TRACE("(%p)->(%p)\n", This
, p
);
607 /* Emulate with CSS visibility attribute */
608 hres
= get_elem_style(&This
->element
, STYLEID_OVERFLOW
, &overflow
);
612 if(!overflow
|| !*overflow
) {
615 }else if(!wcscmp(overflow
, L
"visible") || !wcscmp(overflow
, L
"auto")) {
617 }else if(!wcscmp(overflow
, L
"scroll")) {
619 }else if(!wcscmp(overflow
, L
"hidden")) {
622 TRACE("Defaulting %s to NULL\n", debugstr_w(overflow
));
627 SysFreeString(overflow
);
629 *p
= SysAllocString(ret
);
630 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
636 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
638 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
639 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
643 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
645 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
646 FIXME("(%p)->(%p)\n", This
, p
);
650 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
652 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
653 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
657 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
659 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
660 FIXME("(%p)->(%p)\n", This
, p
);
664 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
666 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
667 nsIDOMRange
*nsrange
= NULL
;
671 TRACE("(%p)->(%p)\n", This
, range
);
673 if(!This
->element
.node
.doc
->nsdoc
) {
678 nsres
= nsIDOMHTMLDocument_CreateRange(This
->element
.node
.doc
->nsdoc
, &nsrange
);
679 if(NS_SUCCEEDED(nsres
)) {
680 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->element
.node
.nsnode
);
682 ERR("SelectNodeContents failed: %08x\n", nsres
);
684 ERR("CreateRange failed: %08x\n", nsres
);
687 hres
= HTMLTxtRange_Create(This
->element
.node
.doc
->basedoc
.doc_node
, nsrange
, range
);
689 nsIDOMRange_Release(nsrange
);
693 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
694 HTMLBodyElement_QueryInterface
,
695 HTMLBodyElement_AddRef
,
696 HTMLBodyElement_Release
,
697 HTMLBodyElement_GetTypeInfoCount
,
698 HTMLBodyElement_GetTypeInfo
,
699 HTMLBodyElement_GetIDsOfNames
,
700 HTMLBodyElement_Invoke
,
701 HTMLBodyElement_put_background
,
702 HTMLBodyElement_get_background
,
703 HTMLBodyElement_put_bgProperties
,
704 HTMLBodyElement_get_bgProperties
,
705 HTMLBodyElement_put_leftMargin
,
706 HTMLBodyElement_get_leftMargin
,
707 HTMLBodyElement_put_topMargin
,
708 HTMLBodyElement_get_topMargin
,
709 HTMLBodyElement_put_rightMargin
,
710 HTMLBodyElement_get_rightMargin
,
711 HTMLBodyElement_put_bottomMargin
,
712 HTMLBodyElement_get_bottomMargin
,
713 HTMLBodyElement_put_noWrap
,
714 HTMLBodyElement_get_noWrap
,
715 HTMLBodyElement_put_bgColor
,
716 HTMLBodyElement_get_bgColor
,
717 HTMLBodyElement_put_text
,
718 HTMLBodyElement_get_text
,
719 HTMLBodyElement_put_link
,
720 HTMLBodyElement_get_link
,
721 HTMLBodyElement_put_vLink
,
722 HTMLBodyElement_get_vLink
,
723 HTMLBodyElement_put_aLink
,
724 HTMLBodyElement_get_aLink
,
725 HTMLBodyElement_put_onload
,
726 HTMLBodyElement_get_onload
,
727 HTMLBodyElement_put_onunload
,
728 HTMLBodyElement_get_onunload
,
729 HTMLBodyElement_put_scroll
,
730 HTMLBodyElement_get_scroll
,
731 HTMLBodyElement_put_onselect
,
732 HTMLBodyElement_get_onselect
,
733 HTMLBodyElement_put_onbeforeunload
,
734 HTMLBodyElement_get_onbeforeunload
,
735 HTMLBodyElement_createTextRange
738 static inline HTMLBodyElement
*impl_from_IHTMLTextContainer(IHTMLTextContainer
*iface
)
740 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLTextContainer_iface
);
743 static HRESULT WINAPI
HTMLTextContainer_QueryInterface(IHTMLTextContainer
*iface
,
744 REFIID riid
, void **ppv
)
746 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
747 return IHTMLElement_QueryInterface(&This
->element
.IHTMLElement_iface
, riid
, ppv
);
750 static ULONG WINAPI
HTMLTextContainer_AddRef(IHTMLTextContainer
*iface
)
752 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
753 return IHTMLElement_AddRef(&This
->element
.IHTMLElement_iface
);
756 static ULONG WINAPI
HTMLTextContainer_Release(IHTMLTextContainer
*iface
)
758 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
759 return IHTMLElement_Release(&This
->element
.IHTMLElement_iface
);
762 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer
*iface
, UINT
*pctinfo
)
764 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
765 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
768 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfo(IHTMLTextContainer
*iface
, UINT iTInfo
,
769 LCID lcid
, ITypeInfo
**ppTInfo
)
771 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
772 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
776 static HRESULT WINAPI
HTMLTextContainer_GetIDsOfNames(IHTMLTextContainer
*iface
, REFIID riid
,
777 LPOLESTR
*rgszNames
, UINT cNames
,
778 LCID lcid
, DISPID
*rgDispId
)
780 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
781 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
782 cNames
, lcid
, rgDispId
);
785 static HRESULT WINAPI
HTMLTextContainer_Invoke(IHTMLTextContainer
*iface
, DISPID dispIdMember
,
786 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
787 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
789 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
790 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
791 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
794 static HRESULT WINAPI
HTMLTextContainer_createControlRange(IHTMLTextContainer
*iface
,
797 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
798 FIXME("(%p)->(%p)\n", This
, range
);
802 static HRESULT WINAPI
HTMLTextContainer_get_scrollHeight(IHTMLTextContainer
*iface
, LONG
*p
)
804 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
806 TRACE("(%p)->(%p)\n", This
, p
);
808 return IHTMLElement2_get_scrollHeight(&This
->element
.IHTMLElement2_iface
, p
);
811 static HRESULT WINAPI
HTMLTextContainer_get_scrollWidth(IHTMLTextContainer
*iface
, LONG
*p
)
813 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
815 TRACE("(%p)->(%p)\n", This
, p
);
817 return IHTMLElement2_get_scrollWidth(&This
->element
.IHTMLElement2_iface
, p
);
820 static HRESULT WINAPI
HTMLTextContainer_put_scrollTop(IHTMLTextContainer
*iface
, LONG v
)
822 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
824 TRACE("(%p)->(%d)\n", This
, v
);
826 return IHTMLElement2_put_scrollTop(&This
->element
.IHTMLElement2_iface
, v
);
829 static HRESULT WINAPI
HTMLTextContainer_get_scrollTop(IHTMLTextContainer
*iface
, LONG
*p
)
831 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
833 TRACE("(%p)->(%p)\n", This
, p
);
835 return IHTMLElement2_get_scrollTop(&This
->element
.IHTMLElement2_iface
, p
);
838 static HRESULT WINAPI
HTMLTextContainer_put_scrollLeft(IHTMLTextContainer
*iface
, LONG v
)
840 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
842 TRACE("(%p)->(%d)\n", This
, v
);
844 return IHTMLElement2_put_scrollLeft(&This
->element
.IHTMLElement2_iface
, v
);
847 static HRESULT WINAPI
HTMLTextContainer_get_scrollLeft(IHTMLTextContainer
*iface
, LONG
*p
)
849 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
851 TRACE("(%p)->(%p)\n", This
, p
);
853 return IHTMLElement2_get_scrollLeft(&This
->element
.IHTMLElement2_iface
, p
);
856 static HRESULT WINAPI
HTMLTextContainer_put_onscroll(IHTMLTextContainer
*iface
, VARIANT v
)
858 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
859 FIXME("(%p)->()\n", This
);
863 static HRESULT WINAPI
HTMLTextContainer_get_onscroll(IHTMLTextContainer
*iface
, VARIANT
*p
)
865 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
866 FIXME("(%p)->(%p)\n", This
, p
);
870 static const IHTMLTextContainerVtbl HTMLTextContainerVtbl
= {
871 HTMLTextContainer_QueryInterface
,
872 HTMLTextContainer_AddRef
,
873 HTMLTextContainer_Release
,
874 HTMLTextContainer_GetTypeInfoCount
,
875 HTMLTextContainer_GetTypeInfo
,
876 HTMLTextContainer_GetIDsOfNames
,
877 HTMLTextContainer_Invoke
,
878 HTMLTextContainer_createControlRange
,
879 HTMLTextContainer_get_scrollHeight
,
880 HTMLTextContainer_get_scrollWidth
,
881 HTMLTextContainer_put_scrollTop
,
882 HTMLTextContainer_get_scrollTop
,
883 HTMLTextContainer_put_scrollLeft
,
884 HTMLTextContainer_get_scrollLeft
,
885 HTMLTextContainer_put_onscroll
,
886 HTMLTextContainer_get_onscroll
889 static inline HTMLBodyElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
891 return CONTAINING_RECORD(iface
, HTMLBodyElement
, element
.node
);
894 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
896 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
900 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
901 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
902 *ppv
= &This
->IHTMLBodyElement_iface
;
903 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
904 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
905 *ppv
= &This
->IHTMLBodyElement_iface
;
906 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
907 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
908 *ppv
= &This
->IHTMLBodyElement_iface
;
909 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
910 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
911 *ppv
= &This
->IHTMLTextContainer_iface
;
915 IUnknown_AddRef((IUnknown
*)*ppv
);
919 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
922 static void HTMLBodyElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
924 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
927 note_cc_edge((nsISupports
*)This
->nsbody
, "This->nsbody", cb
);
930 static void HTMLBodyElement_unlink(HTMLDOMNode
*iface
)
932 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
935 nsIDOMHTMLBodyElement
*nsbody
= This
->nsbody
;
937 nsIDOMHTMLBodyElement_Release(nsbody
);
941 static EventTarget
*HTMLBodyElement_get_event_prop_target(HTMLDOMNode
*iface
, int event_id
)
943 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
951 return This
->element
.node
.doc
&& This
->element
.node
.doc
->window
952 ? &This
->element
.node
.doc
->window
->event_target
953 : &This
->element
.node
.event_target
;
955 return &This
->element
.node
.event_target
;
959 static BOOL
HTMLBodyElement_is_text_edit(HTMLDOMNode
*iface
)
964 static BOOL
HTMLBodyElement_is_settable(HTMLDOMNode
*iface
, DISPID dispid
)
967 case DISPID_IHTMLELEMENT_OUTERTEXT
:
974 static const cpc_entry_t HTMLBodyElement_cpc
[] = {
975 {&DIID_HTMLTextContainerEvents
},
976 {&IID_IPropertyNotifySink
},
981 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
984 HTMLElement_destructor
,
987 HTMLElement_handle_event
,
988 HTMLElement_get_attr_col
,
989 HTMLBodyElement_get_event_prop_target
,
997 HTMLBodyElement_traverse
,
998 HTMLBodyElement_unlink
,
999 HTMLBodyElement_is_text_edit
,
1000 HTMLBodyElement_is_settable
1003 static const tid_t HTMLBodyElement_iface_tids
[] = {
1004 IHTMLBodyElement_tid
,
1005 IHTMLBodyElement2_tid
,
1007 IHTMLTextContainer_tid
,
1011 static dispex_static_data_t HTMLBodyElement_dispex
= {
1014 HTMLBodyElement_iface_tids
,
1015 HTMLElement_init_dispex_info
1018 HRESULT
HTMLBodyElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
1020 HTMLBodyElement
*ret
;
1023 ret
= heap_alloc_zero(sizeof(HTMLBodyElement
));
1025 return E_OUTOFMEMORY
;
1027 ret
->IHTMLBodyElement_iface
.lpVtbl
= &HTMLBodyElementVtbl
;
1028 ret
->IHTMLTextContainer_iface
.lpVtbl
= &HTMLTextContainerVtbl
;
1029 ret
->element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
1031 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLBodyElement_dispex
);
1033 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
, (void**)&ret
->nsbody
);
1034 assert(nsres
== NS_OK
);
1036 *elem
= &ret
->element
;