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
;
48 static const WCHAR aquaW
[] = {'a','q','u','a',0};
49 static const WCHAR blackW
[] = {'b','l','a','c','k',0};
50 static const WCHAR blueW
[] = {'b','l','u','e',0};
51 static const WCHAR fuchsiaW
[] = {'f','u','s','h','s','i','a',0};
52 static const WCHAR grayW
[] = {'g','r','a','y',0};
53 static const WCHAR greenW
[] = {'g','r','e','e','n',0};
54 static const WCHAR limeW
[] = {'l','i','m','e',0};
55 static const WCHAR maroonW
[] = {'m','a','r','o','o','n',0};
56 static const WCHAR navyW
[] = {'n','a','v','y',0};
57 static const WCHAR oliveW
[] = {'o','l','i','v','e',0};
58 static const WCHAR purpleW
[] = {'p','u','r','p','l','e',0};
59 static const WCHAR redW
[] = {'r','e','d',0};
60 static const WCHAR silverW
[] = {'s','i','l','v','e','r',0};
61 static const WCHAR tealW
[] = {'t','e','a','l',0};
62 static const WCHAR whiteW
[] = {'w','h','i','t','e',0};
63 static const WCHAR yellowW
[] = {'y','e','l','l','o','w',0};
87 static int comp_value(const WCHAR
*ptr
, int dpc
)
98 else if(isdigitW(ch
= *ptr
++))
99 ret
= ret
*16 + (ch
-'0');
100 else if('a' <= ch
&& ch
<= 'f')
101 ret
= ret
*16 + (ch
-'a') + 10;
102 else if('A' <= ch
&& ch
<= 'F')
103 ret
= ret
*16 + (ch
-'A') + 10;
111 /* Based on Gecko NS_LooseHexToRGB */
112 static int loose_hex_to_rgb(const WCHAR
*hex
)
124 dpc
= min(len
/3 + (len
%3 ? 1 : 0), 4);
125 return (comp_value(hex
, dpc
) << 16)
126 | (comp_value(hex
+dpc
, dpc
) << 8)
127 | comp_value(hex
+2*dpc
, dpc
);
130 HRESULT
nscolor_to_str(LPCWSTR color
, BSTR
*ret
)
135 static const WCHAR formatW
[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
137 if(!color
|| !*color
) {
143 for(i
=0; i
< ARRAY_SIZE(keyword_table
); i
++) {
144 if(!strcmpiW(color
, keyword_table
[i
].keyword
))
145 rgb
= keyword_table
[i
].rgb
;
149 rgb
= loose_hex_to_rgb(color
);
151 *ret
= SysAllocStringLen(NULL
, 7);
153 return E_OUTOFMEMORY
;
155 sprintfW(*ret
, formatW
, rgb
>>16, (rgb
>>8)&0xff, rgb
&0xff);
157 TRACE("%s -> %s\n", debugstr_w(color
), debugstr_w(*ret
));
161 BOOL
variant_to_nscolor(const VARIANT
*v
, nsAString
*nsstr
)
165 nsAString_Init(nsstr
, V_BSTR(v
));
170 static const WCHAR formatW
[] = {'#','%','x',0};
172 wsprintfW(buf
, formatW
, V_I4(v
));
173 nsAString_Init(nsstr
, buf
);
178 FIXME("invalid color %s\n", debugstr_variant(v
));
185 static HRESULT
return_nscolor(nsresult nsres
, nsAString
*nsstr
, VARIANT
*p
)
187 const PRUnichar
*color
;
189 if(NS_FAILED(nsres
)) {
190 ERR("failed: %08x\n", nsres
);
191 nsAString_Finish(nsstr
);
195 nsAString_GetData(nsstr
, &color
);
199 V_I4(p
) = strtolW(color
+1, NULL
, 16);
202 V_BSTR(p
) = SysAllocString(color
);
204 nsAString_Finish(nsstr
);
205 return E_OUTOFMEMORY
;
209 nsAString_Finish(nsstr
);
210 TRACE("ret %s\n", debugstr_variant(p
));
214 static inline HTMLBodyElement
*impl_from_IHTMLBodyElement(IHTMLBodyElement
*iface
)
216 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLBodyElement_iface
);
219 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
220 REFIID riid
, void **ppv
)
222 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
224 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
227 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
229 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
231 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
234 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
236 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
238 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
241 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
243 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
244 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
,
248 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
249 LCID lcid
, ITypeInfo
**ppTInfo
)
251 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
252 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
,
256 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
257 LPOLESTR
*rgszNames
, UINT cNames
,
258 LCID lcid
, DISPID
*rgDispId
)
260 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
261 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
,
262 rgszNames
, cNames
, lcid
, rgDispId
);
265 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
266 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
267 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
269 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
270 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
,
271 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
274 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
276 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
280 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
282 nsAString_InitDepend(&nsstr
, v
);
283 nsres
= nsIDOMHTMLBodyElement_SetBackground(This
->nsbody
, &nsstr
);
284 nsAString_Finish(&nsstr
);
291 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
293 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
294 nsAString background_str
;
297 TRACE("(%p)->(%p)\n", This
, p
);
299 nsAString_Init(&background_str
, NULL
);
300 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
301 return return_nsstr(nsres
, &background_str
, p
);
304 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
306 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
307 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
311 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
313 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
314 FIXME("(%p)->(%p)\n", This
, p
);
318 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
320 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
321 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
325 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
327 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
328 FIXME("(%p)->(%p)\n", This
, p
);
332 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
334 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
335 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
339 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
341 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
342 FIXME("(%p)->(%p)\n", This
, p
);
346 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
348 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
349 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
353 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
355 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
356 FIXME("(%p)->(%p)\n", This
, p
);
360 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
362 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
363 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
367 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
369 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
370 FIXME("(%p)->(%p)\n", This
, p
);
374 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
376 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
377 FIXME("(%p)->(%x)\n", This
, v
);
381 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
383 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
384 FIXME("(%p)->(%p)\n", This
, p
);
388 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
390 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
394 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
396 if(!variant_to_nscolor(&v
, &strColor
))
399 nsres
= nsIDOMHTMLBodyElement_SetBgColor(This
->nsbody
, &strColor
);
400 nsAString_Finish(&strColor
);
402 ERR("SetBgColor failed: %08x\n", nsres
);
407 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
409 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
414 TRACE("(%p)->(%p)\n", This
, p
);
416 nsAString_Init(&strColor
, NULL
);
417 nsres
= nsIDOMHTMLBodyElement_GetBgColor(This
->nsbody
, &strColor
);
418 if(NS_SUCCEEDED(nsres
)) {
419 const PRUnichar
*color
;
421 nsAString_GetData(&strColor
, &color
);
423 hres
= nscolor_to_str(color
, &V_BSTR(p
));
425 ERR("SetBgColor failed: %08x\n", nsres
);
429 nsAString_Finish(&strColor
);
433 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
435 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
439 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
441 if(!variant_to_nscolor(&v
, &text
))
444 nsres
= nsIDOMHTMLBodyElement_SetText(This
->nsbody
, &text
);
445 nsAString_Finish(&text
);
446 if(NS_FAILED(nsres
)) {
447 ERR("SetText failed: %08x\n", nsres
);
454 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
456 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
461 TRACE("(%p)->(%p)\n", This
, p
);
463 nsAString_Init(&text
, NULL
);
464 nsres
= nsIDOMHTMLBodyElement_GetText(This
->nsbody
, &text
);
465 if(NS_SUCCEEDED(nsres
)) {
466 const PRUnichar
*color
;
468 nsAString_GetData(&text
, &color
);
470 hres
= nscolor_to_str(color
, &V_BSTR(p
));
472 ERR("GetText failed: %08x\n", nsres
);
476 nsAString_Finish(&text
);
481 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
483 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
487 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
489 if(!variant_to_nscolor(&v
, &link_str
))
492 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
493 nsAString_Finish(&link_str
);
495 ERR("SetLink failed: %08x\n", nsres
);
500 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
502 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
506 TRACE("(%p)->(%p)\n", This
, p
);
508 nsAString_Init(&link_str
, NULL
);
509 nsres
= nsIDOMHTMLBodyElement_GetLink(This
->nsbody
, &link_str
);
510 return return_nscolor(nsres
, &link_str
, p
);
513 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
515 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
519 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
521 if(!variant_to_nscolor(&v
, &vlink_str
))
524 nsres
= nsIDOMHTMLBodyElement_SetVLink(This
->nsbody
, &vlink_str
);
525 nsAString_Finish(&vlink_str
);
527 ERR("SetLink failed: %08x\n", nsres
);
532 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
534 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
538 TRACE("(%p)->(%p)\n", This
, p
);
540 nsAString_Init(&vlink_str
, NULL
);
541 nsres
= nsIDOMHTMLBodyElement_GetVLink(This
->nsbody
, &vlink_str
);
542 return return_nscolor(nsres
, &vlink_str
, p
);
545 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
547 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
551 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
553 if(!variant_to_nscolor(&v
, &alink_str
))
556 nsres
= nsIDOMHTMLBodyElement_SetALink(This
->nsbody
, &alink_str
);
557 nsAString_Finish(&alink_str
);
559 ERR("SetALink failed: %08x\n", nsres
);
564 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
566 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
570 TRACE("(%p)->(%p)\n", This
, p
);
572 nsAString_Init(&alink_str
, NULL
);
573 nsres
= nsIDOMHTMLBodyElement_GetALink(This
->nsbody
, &alink_str
);
574 return return_nscolor(nsres
, &alink_str
, p
);
577 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
579 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
581 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
583 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
586 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
588 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
590 TRACE("(%p)->(%p)\n", This
, p
);
592 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
595 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
597 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
598 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
602 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
604 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
605 FIXME("(%p)->(%p)\n", This
, p
);
609 static const WCHAR autoW
[] = {'a','u','t','o',0};
610 static const WCHAR hiddenW
[] = {'h','i','d','d','e','n',0};
611 static const WCHAR scrollW
[] = {'s','c','r','o','l','l',0};
612 static const WCHAR visibleW
[] = {'v','i','s','i','b','l','e',0};
613 static const WCHAR yesW
[] = {'y','e','s',0};
614 static const WCHAR noW
[] = {'n','o',0};
616 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
618 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
619 static const WCHAR
*val
;
621 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
623 /* Emulate with CSS visibility attribute */
624 if(!strcmpW(v
, yesW
)) {
626 }else if(!strcmpW(v
, autoW
)) {
628 }else if(!strcmpW(v
, noW
)) {
631 WARN("Invalid argument %s\n", debugstr_w(v
));
635 return set_elem_style(&This
->element
, STYLEID_OVERFLOW
, val
);
638 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
640 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
641 const WCHAR
*ret
= NULL
;
645 TRACE("(%p)->(%p)\n", This
, p
);
647 /* Emulate with CSS visibility attribute */
648 hres
= get_elem_style(&This
->element
, STYLEID_OVERFLOW
, &overflow
);
652 if(!overflow
|| !*overflow
) {
655 }else if(!strcmpW(overflow
, visibleW
) || !strcmpW(overflow
, autoW
)) {
657 }else if(!strcmpW(overflow
, scrollW
)) {
659 }else if(!strcmpW(overflow
, hiddenW
)) {
662 TRACE("Defaulting %s to NULL\n", debugstr_w(overflow
));
667 SysFreeString(overflow
);
669 *p
= SysAllocString(ret
);
670 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
676 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
678 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
679 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
683 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
685 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
686 FIXME("(%p)->(%p)\n", This
, p
);
690 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
692 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
693 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
697 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
699 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
700 FIXME("(%p)->(%p)\n", This
, p
);
704 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
706 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
707 nsIDOMRange
*nsrange
= NULL
;
711 TRACE("(%p)->(%p)\n", This
, range
);
713 if(!This
->element
.node
.doc
->nsdoc
) {
718 nsres
= nsIDOMHTMLDocument_CreateRange(This
->element
.node
.doc
->nsdoc
, &nsrange
);
719 if(NS_SUCCEEDED(nsres
)) {
720 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->element
.node
.nsnode
);
722 ERR("SelectNodeContents failed: %08x\n", nsres
);
724 ERR("CreateRange failed: %08x\n", nsres
);
727 hres
= HTMLTxtRange_Create(This
->element
.node
.doc
->basedoc
.doc_node
, nsrange
, range
);
729 nsIDOMRange_Release(nsrange
);
733 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
734 HTMLBodyElement_QueryInterface
,
735 HTMLBodyElement_AddRef
,
736 HTMLBodyElement_Release
,
737 HTMLBodyElement_GetTypeInfoCount
,
738 HTMLBodyElement_GetTypeInfo
,
739 HTMLBodyElement_GetIDsOfNames
,
740 HTMLBodyElement_Invoke
,
741 HTMLBodyElement_put_background
,
742 HTMLBodyElement_get_background
,
743 HTMLBodyElement_put_bgProperties
,
744 HTMLBodyElement_get_bgProperties
,
745 HTMLBodyElement_put_leftMargin
,
746 HTMLBodyElement_get_leftMargin
,
747 HTMLBodyElement_put_topMargin
,
748 HTMLBodyElement_get_topMargin
,
749 HTMLBodyElement_put_rightMargin
,
750 HTMLBodyElement_get_rightMargin
,
751 HTMLBodyElement_put_bottomMargin
,
752 HTMLBodyElement_get_bottomMargin
,
753 HTMLBodyElement_put_noWrap
,
754 HTMLBodyElement_get_noWrap
,
755 HTMLBodyElement_put_bgColor
,
756 HTMLBodyElement_get_bgColor
,
757 HTMLBodyElement_put_text
,
758 HTMLBodyElement_get_text
,
759 HTMLBodyElement_put_link
,
760 HTMLBodyElement_get_link
,
761 HTMLBodyElement_put_vLink
,
762 HTMLBodyElement_get_vLink
,
763 HTMLBodyElement_put_aLink
,
764 HTMLBodyElement_get_aLink
,
765 HTMLBodyElement_put_onload
,
766 HTMLBodyElement_get_onload
,
767 HTMLBodyElement_put_onunload
,
768 HTMLBodyElement_get_onunload
,
769 HTMLBodyElement_put_scroll
,
770 HTMLBodyElement_get_scroll
,
771 HTMLBodyElement_put_onselect
,
772 HTMLBodyElement_get_onselect
,
773 HTMLBodyElement_put_onbeforeunload
,
774 HTMLBodyElement_get_onbeforeunload
,
775 HTMLBodyElement_createTextRange
778 static inline HTMLBodyElement
*impl_from_IHTMLTextContainer(IHTMLTextContainer
*iface
)
780 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLTextContainer_iface
);
783 static HRESULT WINAPI
HTMLTextContainer_QueryInterface(IHTMLTextContainer
*iface
,
784 REFIID riid
, void **ppv
)
786 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
787 return IHTMLElement_QueryInterface(&This
->element
.IHTMLElement_iface
, riid
, ppv
);
790 static ULONG WINAPI
HTMLTextContainer_AddRef(IHTMLTextContainer
*iface
)
792 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
793 return IHTMLElement_AddRef(&This
->element
.IHTMLElement_iface
);
796 static ULONG WINAPI
HTMLTextContainer_Release(IHTMLTextContainer
*iface
)
798 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
799 return IHTMLElement_Release(&This
->element
.IHTMLElement_iface
);
802 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer
*iface
, UINT
*pctinfo
)
804 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
805 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
808 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfo(IHTMLTextContainer
*iface
, UINT iTInfo
,
809 LCID lcid
, ITypeInfo
**ppTInfo
)
811 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
812 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
816 static HRESULT WINAPI
HTMLTextContainer_GetIDsOfNames(IHTMLTextContainer
*iface
, REFIID riid
,
817 LPOLESTR
*rgszNames
, UINT cNames
,
818 LCID lcid
, DISPID
*rgDispId
)
820 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
821 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
822 cNames
, lcid
, rgDispId
);
825 static HRESULT WINAPI
HTMLTextContainer_Invoke(IHTMLTextContainer
*iface
, DISPID dispIdMember
,
826 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
827 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
829 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
830 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
831 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
834 static HRESULT WINAPI
HTMLTextContainer_createControlRange(IHTMLTextContainer
*iface
,
837 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
838 FIXME("(%p)->(%p)\n", This
, range
);
842 static HRESULT WINAPI
HTMLTextContainer_get_scrollHeight(IHTMLTextContainer
*iface
, LONG
*p
)
844 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
846 TRACE("(%p)->(%p)\n", This
, p
);
848 return IHTMLElement2_get_scrollHeight(&This
->element
.IHTMLElement2_iface
, p
);
851 static HRESULT WINAPI
HTMLTextContainer_get_scrollWidth(IHTMLTextContainer
*iface
, LONG
*p
)
853 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
855 TRACE("(%p)->(%p)\n", This
, p
);
857 return IHTMLElement2_get_scrollWidth(&This
->element
.IHTMLElement2_iface
, p
);
860 static HRESULT WINAPI
HTMLTextContainer_put_scrollTop(IHTMLTextContainer
*iface
, LONG v
)
862 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
864 TRACE("(%p)->(%d)\n", This
, v
);
866 return IHTMLElement2_put_scrollTop(&This
->element
.IHTMLElement2_iface
, v
);
869 static HRESULT WINAPI
HTMLTextContainer_get_scrollTop(IHTMLTextContainer
*iface
, LONG
*p
)
871 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
873 TRACE("(%p)->(%p)\n", This
, p
);
875 return IHTMLElement2_get_scrollTop(&This
->element
.IHTMLElement2_iface
, p
);
878 static HRESULT WINAPI
HTMLTextContainer_put_scrollLeft(IHTMLTextContainer
*iface
, LONG v
)
880 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
882 TRACE("(%p)->(%d)\n", This
, v
);
884 return IHTMLElement2_put_scrollLeft(&This
->element
.IHTMLElement2_iface
, v
);
887 static HRESULT WINAPI
HTMLTextContainer_get_scrollLeft(IHTMLTextContainer
*iface
, LONG
*p
)
889 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
891 TRACE("(%p)->(%p)\n", This
, p
);
893 return IHTMLElement2_get_scrollLeft(&This
->element
.IHTMLElement2_iface
, p
);
896 static HRESULT WINAPI
HTMLTextContainer_put_onscroll(IHTMLTextContainer
*iface
, VARIANT v
)
898 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
899 FIXME("(%p)->()\n", This
);
903 static HRESULT WINAPI
HTMLTextContainer_get_onscroll(IHTMLTextContainer
*iface
, VARIANT
*p
)
905 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
906 FIXME("(%p)->(%p)\n", This
, p
);
910 static const IHTMLTextContainerVtbl HTMLTextContainerVtbl
= {
911 HTMLTextContainer_QueryInterface
,
912 HTMLTextContainer_AddRef
,
913 HTMLTextContainer_Release
,
914 HTMLTextContainer_GetTypeInfoCount
,
915 HTMLTextContainer_GetTypeInfo
,
916 HTMLTextContainer_GetIDsOfNames
,
917 HTMLTextContainer_Invoke
,
918 HTMLTextContainer_createControlRange
,
919 HTMLTextContainer_get_scrollHeight
,
920 HTMLTextContainer_get_scrollWidth
,
921 HTMLTextContainer_put_scrollTop
,
922 HTMLTextContainer_get_scrollTop
,
923 HTMLTextContainer_put_scrollLeft
,
924 HTMLTextContainer_get_scrollLeft
,
925 HTMLTextContainer_put_onscroll
,
926 HTMLTextContainer_get_onscroll
929 static inline HTMLBodyElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
931 return CONTAINING_RECORD(iface
, HTMLBodyElement
, element
.node
);
934 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
936 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
940 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
941 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
942 *ppv
= &This
->IHTMLBodyElement_iface
;
943 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
944 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
945 *ppv
= &This
->IHTMLBodyElement_iface
;
946 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
947 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
948 *ppv
= &This
->IHTMLBodyElement_iface
;
949 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
950 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
951 *ppv
= &This
->IHTMLTextContainer_iface
;
955 IUnknown_AddRef((IUnknown
*)*ppv
);
959 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
962 static void HTMLBodyElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
964 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
967 note_cc_edge((nsISupports
*)This
->nsbody
, "This->nsbody", cb
);
970 static void HTMLBodyElement_unlink(HTMLDOMNode
*iface
)
972 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
975 nsIDOMHTMLBodyElement
*nsbody
= This
->nsbody
;
977 nsIDOMHTMLBodyElement_Release(nsbody
);
981 static EventTarget
*HTMLBodyElement_get_event_prop_target(HTMLDOMNode
*iface
, int event_id
)
983 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
991 return This
->element
.node
.doc
&& This
->element
.node
.doc
->window
992 ? &This
->element
.node
.doc
->window
->event_target
993 : &This
->element
.node
.event_target
;
995 return &This
->element
.node
.event_target
;
999 static BOOL
HTMLBodyElement_is_text_edit(HTMLDOMNode
*iface
)
1004 static BOOL
HTMLBodyElement_is_settable(HTMLDOMNode
*iface
, DISPID dispid
)
1007 case DISPID_IHTMLELEMENT_OUTERTEXT
:
1014 static const cpc_entry_t HTMLBodyElement_cpc
[] = {
1015 {&DIID_HTMLTextContainerEvents
},
1016 {&IID_IPropertyNotifySink
},
1021 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
1024 HTMLElement_destructor
,
1025 HTMLBodyElement_cpc
,
1027 HTMLElement_handle_event
,
1028 HTMLElement_get_attr_col
,
1029 HTMLBodyElement_get_event_prop_target
,
1037 HTMLBodyElement_traverse
,
1038 HTMLBodyElement_unlink
,
1039 HTMLBodyElement_is_text_edit
,
1040 HTMLBodyElement_is_settable
1043 static const tid_t HTMLBodyElement_iface_tids
[] = {
1044 IHTMLBodyElement_tid
,
1045 IHTMLBodyElement2_tid
,
1047 IHTMLTextContainer_tid
,
1051 static dispex_static_data_t HTMLBodyElement_dispex
= {
1054 HTMLBodyElement_iface_tids
,
1055 HTMLElement_init_dispex_info
1058 HRESULT
HTMLBodyElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
1060 HTMLBodyElement
*ret
;
1063 ret
= heap_alloc_zero(sizeof(HTMLBodyElement
));
1065 return E_OUTOFMEMORY
;
1067 ret
->IHTMLBodyElement_iface
.lpVtbl
= &HTMLBodyElementVtbl
;
1068 ret
->IHTMLTextContainer_iface
.lpVtbl
= &HTMLTextContainerVtbl
;
1069 ret
->element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
1071 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLBodyElement_dispex
);
1073 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
, (void**)&ret
->nsbody
);
1074 assert(nsres
== NS_OK
);
1076 *elem
= &ret
->element
;