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(is_digit(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(!wcsicmp(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 swprintf(*ret
, 8, 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
) = wcstol(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
);
413 TRACE("(%p)->(%p)\n", This
, p
);
415 nsAString_Init(&nsstr
, NULL
);
416 nsres
= nsIDOMHTMLBodyElement_GetBgColor(This
->nsbody
, &nsstr
);
417 return return_nsstr_variant(nsres
, &nsstr
, NSSTR_COLOR
, p
);
420 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
422 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
426 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
428 if(!variant_to_nscolor(&v
, &text
))
431 nsres
= nsIDOMHTMLBodyElement_SetText(This
->nsbody
, &text
);
432 nsAString_Finish(&text
);
433 if(NS_FAILED(nsres
)) {
434 ERR("SetText failed: %08x\n", nsres
);
441 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
443 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
448 TRACE("(%p)->(%p)\n", This
, p
);
450 nsAString_Init(&text
, NULL
);
451 nsres
= nsIDOMHTMLBodyElement_GetText(This
->nsbody
, &text
);
452 if(NS_SUCCEEDED(nsres
)) {
453 const PRUnichar
*color
;
455 nsAString_GetData(&text
, &color
);
457 hres
= nscolor_to_str(color
, &V_BSTR(p
));
459 ERR("GetText failed: %08x\n", nsres
);
463 nsAString_Finish(&text
);
468 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
470 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
474 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
476 if(!variant_to_nscolor(&v
, &link_str
))
479 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
480 nsAString_Finish(&link_str
);
482 ERR("SetLink failed: %08x\n", nsres
);
487 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
489 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
493 TRACE("(%p)->(%p)\n", This
, p
);
495 nsAString_Init(&link_str
, NULL
);
496 nsres
= nsIDOMHTMLBodyElement_GetLink(This
->nsbody
, &link_str
);
497 return return_nscolor(nsres
, &link_str
, p
);
500 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
502 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
506 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
508 if(!variant_to_nscolor(&v
, &vlink_str
))
511 nsres
= nsIDOMHTMLBodyElement_SetVLink(This
->nsbody
, &vlink_str
);
512 nsAString_Finish(&vlink_str
);
514 ERR("SetLink failed: %08x\n", nsres
);
519 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
521 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
525 TRACE("(%p)->(%p)\n", This
, p
);
527 nsAString_Init(&vlink_str
, NULL
);
528 nsres
= nsIDOMHTMLBodyElement_GetVLink(This
->nsbody
, &vlink_str
);
529 return return_nscolor(nsres
, &vlink_str
, p
);
532 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
534 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
538 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
540 if(!variant_to_nscolor(&v
, &alink_str
))
543 nsres
= nsIDOMHTMLBodyElement_SetALink(This
->nsbody
, &alink_str
);
544 nsAString_Finish(&alink_str
);
546 ERR("SetALink failed: %08x\n", nsres
);
551 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
553 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
557 TRACE("(%p)->(%p)\n", This
, p
);
559 nsAString_Init(&alink_str
, NULL
);
560 nsres
= nsIDOMHTMLBodyElement_GetALink(This
->nsbody
, &alink_str
);
561 return return_nscolor(nsres
, &alink_str
, p
);
564 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
566 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
568 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
570 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
573 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
575 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
577 TRACE("(%p)->(%p)\n", This
, p
);
579 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
582 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
584 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
585 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
589 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
591 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
592 FIXME("(%p)->(%p)\n", This
, p
);
596 static const WCHAR autoW
[] = {'a','u','t','o',0};
597 static const WCHAR hiddenW
[] = {'h','i','d','d','e','n',0};
598 static const WCHAR scrollW
[] = {'s','c','r','o','l','l',0};
599 static const WCHAR visibleW
[] = {'v','i','s','i','b','l','e',0};
600 static const WCHAR yesW
[] = {'y','e','s',0};
601 static const WCHAR noW
[] = {'n','o',0};
603 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
605 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
606 static const WCHAR
*val
;
608 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
610 /* Emulate with CSS visibility attribute */
611 if(!wcscmp(v
, yesW
)) {
613 }else if(!wcscmp(v
, autoW
)) {
615 }else if(!wcscmp(v
, noW
)) {
618 WARN("Invalid argument %s\n", debugstr_w(v
));
622 return set_elem_style(&This
->element
, STYLEID_OVERFLOW
, val
);
625 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
627 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
628 const WCHAR
*ret
= NULL
;
632 TRACE("(%p)->(%p)\n", This
, p
);
634 /* Emulate with CSS visibility attribute */
635 hres
= get_elem_style(&This
->element
, STYLEID_OVERFLOW
, &overflow
);
639 if(!overflow
|| !*overflow
) {
642 }else if(!wcscmp(overflow
, visibleW
) || !wcscmp(overflow
, autoW
)) {
644 }else if(!wcscmp(overflow
, scrollW
)) {
646 }else if(!wcscmp(overflow
, hiddenW
)) {
649 TRACE("Defaulting %s to NULL\n", debugstr_w(overflow
));
654 SysFreeString(overflow
);
656 *p
= SysAllocString(ret
);
657 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
663 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
665 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
666 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
670 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
672 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
673 FIXME("(%p)->(%p)\n", This
, p
);
677 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
679 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
680 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
684 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
686 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
687 FIXME("(%p)->(%p)\n", This
, p
);
691 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
693 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
694 nsIDOMRange
*nsrange
= NULL
;
698 TRACE("(%p)->(%p)\n", This
, range
);
700 if(!This
->element
.node
.doc
->nsdoc
) {
705 nsres
= nsIDOMHTMLDocument_CreateRange(This
->element
.node
.doc
->nsdoc
, &nsrange
);
706 if(NS_SUCCEEDED(nsres
)) {
707 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->element
.node
.nsnode
);
709 ERR("SelectNodeContents failed: %08x\n", nsres
);
711 ERR("CreateRange failed: %08x\n", nsres
);
714 hres
= HTMLTxtRange_Create(This
->element
.node
.doc
->basedoc
.doc_node
, nsrange
, range
);
716 nsIDOMRange_Release(nsrange
);
720 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
721 HTMLBodyElement_QueryInterface
,
722 HTMLBodyElement_AddRef
,
723 HTMLBodyElement_Release
,
724 HTMLBodyElement_GetTypeInfoCount
,
725 HTMLBodyElement_GetTypeInfo
,
726 HTMLBodyElement_GetIDsOfNames
,
727 HTMLBodyElement_Invoke
,
728 HTMLBodyElement_put_background
,
729 HTMLBodyElement_get_background
,
730 HTMLBodyElement_put_bgProperties
,
731 HTMLBodyElement_get_bgProperties
,
732 HTMLBodyElement_put_leftMargin
,
733 HTMLBodyElement_get_leftMargin
,
734 HTMLBodyElement_put_topMargin
,
735 HTMLBodyElement_get_topMargin
,
736 HTMLBodyElement_put_rightMargin
,
737 HTMLBodyElement_get_rightMargin
,
738 HTMLBodyElement_put_bottomMargin
,
739 HTMLBodyElement_get_bottomMargin
,
740 HTMLBodyElement_put_noWrap
,
741 HTMLBodyElement_get_noWrap
,
742 HTMLBodyElement_put_bgColor
,
743 HTMLBodyElement_get_bgColor
,
744 HTMLBodyElement_put_text
,
745 HTMLBodyElement_get_text
,
746 HTMLBodyElement_put_link
,
747 HTMLBodyElement_get_link
,
748 HTMLBodyElement_put_vLink
,
749 HTMLBodyElement_get_vLink
,
750 HTMLBodyElement_put_aLink
,
751 HTMLBodyElement_get_aLink
,
752 HTMLBodyElement_put_onload
,
753 HTMLBodyElement_get_onload
,
754 HTMLBodyElement_put_onunload
,
755 HTMLBodyElement_get_onunload
,
756 HTMLBodyElement_put_scroll
,
757 HTMLBodyElement_get_scroll
,
758 HTMLBodyElement_put_onselect
,
759 HTMLBodyElement_get_onselect
,
760 HTMLBodyElement_put_onbeforeunload
,
761 HTMLBodyElement_get_onbeforeunload
,
762 HTMLBodyElement_createTextRange
765 static inline HTMLBodyElement
*impl_from_IHTMLTextContainer(IHTMLTextContainer
*iface
)
767 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLTextContainer_iface
);
770 static HRESULT WINAPI
HTMLTextContainer_QueryInterface(IHTMLTextContainer
*iface
,
771 REFIID riid
, void **ppv
)
773 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
774 return IHTMLElement_QueryInterface(&This
->element
.IHTMLElement_iface
, riid
, ppv
);
777 static ULONG WINAPI
HTMLTextContainer_AddRef(IHTMLTextContainer
*iface
)
779 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
780 return IHTMLElement_AddRef(&This
->element
.IHTMLElement_iface
);
783 static ULONG WINAPI
HTMLTextContainer_Release(IHTMLTextContainer
*iface
)
785 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
786 return IHTMLElement_Release(&This
->element
.IHTMLElement_iface
);
789 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfoCount(IHTMLTextContainer
*iface
, UINT
*pctinfo
)
791 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
792 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
795 static HRESULT WINAPI
HTMLTextContainer_GetTypeInfo(IHTMLTextContainer
*iface
, UINT iTInfo
,
796 LCID lcid
, ITypeInfo
**ppTInfo
)
798 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
799 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
803 static HRESULT WINAPI
HTMLTextContainer_GetIDsOfNames(IHTMLTextContainer
*iface
, REFIID riid
,
804 LPOLESTR
*rgszNames
, UINT cNames
,
805 LCID lcid
, DISPID
*rgDispId
)
807 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
808 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
809 cNames
, lcid
, rgDispId
);
812 static HRESULT WINAPI
HTMLTextContainer_Invoke(IHTMLTextContainer
*iface
, DISPID dispIdMember
,
813 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
814 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
816 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
817 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
818 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
821 static HRESULT WINAPI
HTMLTextContainer_createControlRange(IHTMLTextContainer
*iface
,
824 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
825 FIXME("(%p)->(%p)\n", This
, range
);
829 static HRESULT WINAPI
HTMLTextContainer_get_scrollHeight(IHTMLTextContainer
*iface
, LONG
*p
)
831 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
833 TRACE("(%p)->(%p)\n", This
, p
);
835 return IHTMLElement2_get_scrollHeight(&This
->element
.IHTMLElement2_iface
, p
);
838 static HRESULT WINAPI
HTMLTextContainer_get_scrollWidth(IHTMLTextContainer
*iface
, LONG
*p
)
840 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
842 TRACE("(%p)->(%p)\n", This
, p
);
844 return IHTMLElement2_get_scrollWidth(&This
->element
.IHTMLElement2_iface
, p
);
847 static HRESULT WINAPI
HTMLTextContainer_put_scrollTop(IHTMLTextContainer
*iface
, LONG v
)
849 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
851 TRACE("(%p)->(%d)\n", This
, v
);
853 return IHTMLElement2_put_scrollTop(&This
->element
.IHTMLElement2_iface
, v
);
856 static HRESULT WINAPI
HTMLTextContainer_get_scrollTop(IHTMLTextContainer
*iface
, LONG
*p
)
858 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
860 TRACE("(%p)->(%p)\n", This
, p
);
862 return IHTMLElement2_get_scrollTop(&This
->element
.IHTMLElement2_iface
, p
);
865 static HRESULT WINAPI
HTMLTextContainer_put_scrollLeft(IHTMLTextContainer
*iface
, LONG v
)
867 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
869 TRACE("(%p)->(%d)\n", This
, v
);
871 return IHTMLElement2_put_scrollLeft(&This
->element
.IHTMLElement2_iface
, v
);
874 static HRESULT WINAPI
HTMLTextContainer_get_scrollLeft(IHTMLTextContainer
*iface
, LONG
*p
)
876 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
878 TRACE("(%p)->(%p)\n", This
, p
);
880 return IHTMLElement2_get_scrollLeft(&This
->element
.IHTMLElement2_iface
, p
);
883 static HRESULT WINAPI
HTMLTextContainer_put_onscroll(IHTMLTextContainer
*iface
, VARIANT v
)
885 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
886 FIXME("(%p)->()\n", This
);
890 static HRESULT WINAPI
HTMLTextContainer_get_onscroll(IHTMLTextContainer
*iface
, VARIANT
*p
)
892 HTMLBodyElement
*This
= impl_from_IHTMLTextContainer(iface
);
893 FIXME("(%p)->(%p)\n", This
, p
);
897 static const IHTMLTextContainerVtbl HTMLTextContainerVtbl
= {
898 HTMLTextContainer_QueryInterface
,
899 HTMLTextContainer_AddRef
,
900 HTMLTextContainer_Release
,
901 HTMLTextContainer_GetTypeInfoCount
,
902 HTMLTextContainer_GetTypeInfo
,
903 HTMLTextContainer_GetIDsOfNames
,
904 HTMLTextContainer_Invoke
,
905 HTMLTextContainer_createControlRange
,
906 HTMLTextContainer_get_scrollHeight
,
907 HTMLTextContainer_get_scrollWidth
,
908 HTMLTextContainer_put_scrollTop
,
909 HTMLTextContainer_get_scrollTop
,
910 HTMLTextContainer_put_scrollLeft
,
911 HTMLTextContainer_get_scrollLeft
,
912 HTMLTextContainer_put_onscroll
,
913 HTMLTextContainer_get_onscroll
916 static inline HTMLBodyElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
918 return CONTAINING_RECORD(iface
, HTMLBodyElement
, element
.node
);
921 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
923 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
927 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
928 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
929 *ppv
= &This
->IHTMLBodyElement_iface
;
930 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
931 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
932 *ppv
= &This
->IHTMLBodyElement_iface
;
933 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
934 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
935 *ppv
= &This
->IHTMLBodyElement_iface
;
936 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
937 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
938 *ppv
= &This
->IHTMLTextContainer_iface
;
942 IUnknown_AddRef((IUnknown
*)*ppv
);
946 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
949 static void HTMLBodyElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
951 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
954 note_cc_edge((nsISupports
*)This
->nsbody
, "This->nsbody", cb
);
957 static void HTMLBodyElement_unlink(HTMLDOMNode
*iface
)
959 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
962 nsIDOMHTMLBodyElement
*nsbody
= This
->nsbody
;
964 nsIDOMHTMLBodyElement_Release(nsbody
);
968 static EventTarget
*HTMLBodyElement_get_event_prop_target(HTMLDOMNode
*iface
, int event_id
)
970 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
978 return This
->element
.node
.doc
&& This
->element
.node
.doc
->window
979 ? &This
->element
.node
.doc
->window
->event_target
980 : &This
->element
.node
.event_target
;
982 return &This
->element
.node
.event_target
;
986 static BOOL
HTMLBodyElement_is_text_edit(HTMLDOMNode
*iface
)
991 static BOOL
HTMLBodyElement_is_settable(HTMLDOMNode
*iface
, DISPID dispid
)
994 case DISPID_IHTMLELEMENT_OUTERTEXT
:
1001 static const cpc_entry_t HTMLBodyElement_cpc
[] = {
1002 {&DIID_HTMLTextContainerEvents
},
1003 {&IID_IPropertyNotifySink
},
1008 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
1011 HTMLElement_destructor
,
1012 HTMLBodyElement_cpc
,
1014 HTMLElement_handle_event
,
1015 HTMLElement_get_attr_col
,
1016 HTMLBodyElement_get_event_prop_target
,
1024 HTMLBodyElement_traverse
,
1025 HTMLBodyElement_unlink
,
1026 HTMLBodyElement_is_text_edit
,
1027 HTMLBodyElement_is_settable
1030 static const tid_t HTMLBodyElement_iface_tids
[] = {
1031 IHTMLBodyElement_tid
,
1032 IHTMLBodyElement2_tid
,
1034 IHTMLTextContainer_tid
,
1038 static dispex_static_data_t HTMLBodyElement_dispex
= {
1041 HTMLBodyElement_iface_tids
,
1042 HTMLElement_init_dispex_info
1045 HRESULT
HTMLBodyElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
1047 HTMLBodyElement
*ret
;
1050 ret
= heap_alloc_zero(sizeof(HTMLBodyElement
));
1052 return E_OUTOFMEMORY
;
1054 ret
->IHTMLBodyElement_iface
.lpVtbl
= &HTMLBodyElementVtbl
;
1055 ret
->IHTMLTextContainer_iface
.lpVtbl
= &HTMLTextContainerVtbl
;
1056 ret
->element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
1058 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLBodyElement_dispex
);
1060 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
, (void**)&ret
->nsbody
);
1061 assert(nsres
== NS_OK
);
1063 *elem
= &ret
->element
;