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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
33 #include "htmlstyle.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 HTMLTextContainer textcont
;
40 IHTMLBodyElement IHTMLBodyElement_iface
;
42 nsIDOMHTMLBodyElement
*nsbody
;
45 static const WCHAR aquaW
[] = {'a','q','u','a',0};
46 static const WCHAR blackW
[] = {'b','l','a','c','k',0};
47 static const WCHAR blueW
[] = {'b','l','u','e',0};
48 static const WCHAR fuchsiaW
[] = {'f','u','s','h','s','i','a',0};
49 static const WCHAR grayW
[] = {'g','r','a','y',0};
50 static const WCHAR greenW
[] = {'g','r','e','e','n',0};
51 static const WCHAR limeW
[] = {'l','i','m','e',0};
52 static const WCHAR maroonW
[] = {'m','a','r','o','o','n',0};
53 static const WCHAR navyW
[] = {'n','a','v','y',0};
54 static const WCHAR oliveW
[] = {'o','l','i','v','e',0};
55 static const WCHAR purpleW
[] = {'p','u','r','p','l','e',0};
56 static const WCHAR redW
[] = {'r','e','d',0};
57 static const WCHAR silverW
[] = {'s','i','l','v','e','r',0};
58 static const WCHAR tealW
[] = {'t','e','a','l',0};
59 static const WCHAR whiteW
[] = {'w','h','i','t','e',0};
60 static const WCHAR yellowW
[] = {'y','e','l','l','o','w',0};
84 static int comp_value(const WCHAR
*ptr
, int dpc
)
95 else if(isdigitW(ch
= *ptr
++))
96 ret
= ret
*16 + (ch
-'0');
97 else if('a' <= ch
&& ch
<= 'f')
98 ret
= ret
*16 + (ch
-'a') + 10;
99 else if('A' <= ch
&& ch
<= 'F')
100 ret
= ret
*16 + (ch
-'A') + 10;
108 /* Based on Gecko NS_LooseHexToRGB */
109 static int loose_hex_to_rgb(const WCHAR
*hex
)
121 dpc
= min(len
/3 + (len
%3 ? 1 : 0), 4);
122 return (comp_value(hex
, dpc
) << 16)
123 | (comp_value(hex
+dpc
, dpc
) << 8)
124 | comp_value(hex
+2*dpc
, dpc
);
127 HRESULT
nscolor_to_str(LPCWSTR color
, BSTR
*ret
)
132 static const WCHAR formatW
[] = {'#','%','0','2','x','%','0','2','x','%','0','2','x',0};
134 if(!color
|| !*color
) {
140 for(i
=0; i
< sizeof(keyword_table
)/sizeof(keyword_table
[0]); i
++) {
141 if(!strcmpiW(color
, keyword_table
[i
].keyword
))
142 rgb
= keyword_table
[i
].rgb
;
146 rgb
= loose_hex_to_rgb(color
);
148 *ret
= SysAllocStringLen(NULL
, 7);
150 return E_OUTOFMEMORY
;
152 sprintfW(*ret
, formatW
, rgb
>>16, (rgb
>>8)&0xff, rgb
&0xff);
154 TRACE("%s -> %s\n", debugstr_w(color
), debugstr_w(*ret
));
158 BOOL
variant_to_nscolor(const VARIANT
*v
, nsAString
*nsstr
)
162 nsAString_Init(nsstr
, V_BSTR(v
));
167 static const WCHAR formatW
[] = {'#','%','x',0};
169 wsprintfW(buf
, formatW
, V_I4(v
));
170 nsAString_Init(nsstr
, buf
);
175 FIXME("invalid color %s\n", debugstr_variant(v
));
182 static HRESULT
return_nscolor(nsresult nsres
, nsAString
*nsstr
, VARIANT
*p
)
184 const PRUnichar
*color
;
186 if(NS_FAILED(nsres
)) {
187 ERR("failed: %08x\n", nsres
);
188 nsAString_Finish(nsstr
);
192 nsAString_GetData(nsstr
, &color
);
196 V_I4(p
) = strtolW(color
+1, NULL
, 16);
199 V_BSTR(p
) = SysAllocString(color
);
201 nsAString_Finish(nsstr
);
202 return E_OUTOFMEMORY
;
206 nsAString_Finish(nsstr
);
207 TRACE("ret %s\n", debugstr_variant(p
));
211 static inline HTMLBodyElement
*impl_from_IHTMLBodyElement(IHTMLBodyElement
*iface
)
213 return CONTAINING_RECORD(iface
, HTMLBodyElement
, IHTMLBodyElement_iface
);
216 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
217 REFIID riid
, void **ppv
)
219 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
221 return IHTMLDOMNode_QueryInterface(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
224 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
226 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
228 return IHTMLDOMNode_AddRef(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
);
231 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
233 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
235 return IHTMLDOMNode_Release(&This
->textcont
.element
.node
.IHTMLDOMNode_iface
);
238 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
240 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
241 return IDispatchEx_GetTypeInfoCount(&This
->textcont
.element
.node
.event_target
.dispex
.IDispatchEx_iface
,
245 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
246 LCID lcid
, ITypeInfo
**ppTInfo
)
248 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
249 return IDispatchEx_GetTypeInfo(&This
->textcont
.element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
,
253 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
254 LPOLESTR
*rgszNames
, UINT cNames
,
255 LCID lcid
, DISPID
*rgDispId
)
257 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
258 return IDispatchEx_GetIDsOfNames(&This
->textcont
.element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
,
259 rgszNames
, cNames
, lcid
, rgDispId
);
262 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
263 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
264 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
266 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
267 return IDispatchEx_Invoke(&This
->textcont
.element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
,
268 riid
, lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
271 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
273 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
277 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
279 nsAString_InitDepend(&nsstr
, v
);
280 nsres
= nsIDOMHTMLBodyElement_SetBackground(This
->nsbody
, &nsstr
);
281 nsAString_Finish(&nsstr
);
288 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
290 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
291 nsAString background_str
;
294 TRACE("(%p)->(%p)\n", This
, p
);
296 nsAString_Init(&background_str
, NULL
);
297 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
298 return return_nsstr(nsres
, &background_str
, p
);
301 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
303 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
304 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
308 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
310 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
311 FIXME("(%p)->(%p)\n", This
, p
);
315 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
317 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
318 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
322 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
324 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
325 FIXME("(%p)->(%p)\n", This
, p
);
329 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
331 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
332 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
336 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
338 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
339 FIXME("(%p)->(%p)\n", This
, p
);
343 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
345 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
346 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
350 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
352 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
353 FIXME("(%p)->(%p)\n", This
, p
);
357 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
359 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
360 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
364 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
366 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
367 FIXME("(%p)->(%p)\n", This
, p
);
371 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
373 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
374 FIXME("(%p)->(%x)\n", This
, v
);
378 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
380 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
381 FIXME("(%p)->(%p)\n", This
, p
);
385 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
387 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
391 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
393 if(!variant_to_nscolor(&v
, &strColor
))
396 nsres
= nsIDOMHTMLBodyElement_SetBgColor(This
->nsbody
, &strColor
);
397 nsAString_Finish(&strColor
);
399 ERR("SetBgColor failed: %08x\n", nsres
);
404 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
406 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
411 TRACE("(%p)->(%p)\n", This
, p
);
413 nsAString_Init(&strColor
, NULL
);
414 nsres
= nsIDOMHTMLBodyElement_GetBgColor(This
->nsbody
, &strColor
);
415 if(NS_SUCCEEDED(nsres
)) {
416 const PRUnichar
*color
;
418 nsAString_GetData(&strColor
, &color
);
420 hres
= nscolor_to_str(color
, &V_BSTR(p
));
422 ERR("SetBgColor failed: %08x\n", nsres
);
426 nsAString_Finish(&strColor
);
430 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
432 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
436 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
438 if(!variant_to_nscolor(&v
, &text
))
441 nsres
= nsIDOMHTMLBodyElement_SetText(This
->nsbody
, &text
);
442 nsAString_Finish(&text
);
443 if(NS_FAILED(nsres
)) {
444 ERR("SetText failed: %08x\n", nsres
);
451 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
453 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
458 TRACE("(%p)->(%p)\n", This
, p
);
460 nsAString_Init(&text
, NULL
);
461 nsres
= nsIDOMHTMLBodyElement_GetText(This
->nsbody
, &text
);
462 if(NS_SUCCEEDED(nsres
)) {
463 const PRUnichar
*color
;
465 nsAString_GetData(&text
, &color
);
467 hres
= nscolor_to_str(color
, &V_BSTR(p
));
469 ERR("GetText failed: %08x\n", nsres
);
473 nsAString_Finish(&text
);
478 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
480 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
484 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
486 if(!variant_to_nscolor(&v
, &link_str
))
489 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
490 nsAString_Finish(&link_str
);
492 ERR("SetLink failed: %08x\n", nsres
);
497 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
499 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
503 TRACE("(%p)->(%p)\n", This
, p
);
505 nsAString_Init(&link_str
, NULL
);
506 nsres
= nsIDOMHTMLBodyElement_GetLink(This
->nsbody
, &link_str
);
507 return return_nscolor(nsres
, &link_str
, p
);
510 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
512 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
516 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
518 if(!variant_to_nscolor(&v
, &vlink_str
))
521 nsres
= nsIDOMHTMLBodyElement_SetVLink(This
->nsbody
, &vlink_str
);
522 nsAString_Finish(&vlink_str
);
524 ERR("SetLink failed: %08x\n", nsres
);
529 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
531 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
535 TRACE("(%p)->(%p)\n", This
, p
);
537 nsAString_Init(&vlink_str
, NULL
);
538 nsres
= nsIDOMHTMLBodyElement_GetVLink(This
->nsbody
, &vlink_str
);
539 return return_nscolor(nsres
, &vlink_str
, p
);
542 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
544 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
548 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
550 if(!variant_to_nscolor(&v
, &alink_str
))
553 nsres
= nsIDOMHTMLBodyElement_SetALink(This
->nsbody
, &alink_str
);
554 nsAString_Finish(&alink_str
);
556 ERR("SetALink failed: %08x\n", nsres
);
561 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
563 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
567 TRACE("(%p)->(%p)\n", This
, p
);
569 nsAString_Init(&alink_str
, NULL
);
570 nsres
= nsIDOMHTMLBodyElement_GetALink(This
->nsbody
, &alink_str
);
571 return return_nscolor(nsres
, &alink_str
, p
);
574 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
576 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
578 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
580 return set_node_event(&This
->textcont
.element
.node
, EVENTID_LOAD
, &v
);
583 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
585 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
587 TRACE("(%p)->(%p)\n", This
, p
);
589 return get_node_event(&This
->textcont
.element
.node
, EVENTID_LOAD
, p
);
592 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
594 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
595 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
599 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
601 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
602 FIXME("(%p)->(%p)\n", This
, p
);
606 static const WCHAR autoW
[] = {'a','u','t','o',0};
607 static const WCHAR hiddenW
[] = {'h','i','d','d','e','n',0};
608 static const WCHAR scrollW
[] = {'s','c','r','o','l','l',0};
609 static const WCHAR visibleW
[] = {'v','i','s','i','b','l','e',0};
610 static const WCHAR yesW
[] = {'y','e','s',0};
611 static const WCHAR noW
[] = {'n','o',0};
613 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
615 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
616 static const WCHAR
*val
;
618 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
620 /* Emulate with CSS visibility attribute */
621 if(!strcmpW(v
, yesW
)) {
623 }else if(!strcmpW(v
, autoW
)) {
625 }else if(!strcmpW(v
, noW
)) {
628 WARN("Invalid argument %s\n", debugstr_w(v
));
632 return set_elem_style(&This
->textcont
.element
, STYLEID_OVERFLOW
, val
);
635 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
637 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
638 const WCHAR
*ret
= NULL
;
642 TRACE("(%p)->(%p)\n", This
, p
);
644 /* Emulate with CSS visibility attribute */
645 hres
= get_elem_style(&This
->textcont
.element
, STYLEID_OVERFLOW
, &overflow
);
649 if(!overflow
|| !*overflow
) {
652 }else if(!strcmpW(overflow
, visibleW
) || !strcmpW(overflow
, autoW
)) {
654 }else if(!strcmpW(overflow
, scrollW
)) {
656 }else if(!strcmpW(overflow
, hiddenW
)) {
659 TRACE("Defaulting %s to NULL\n", debugstr_w(overflow
));
664 SysFreeString(overflow
);
666 *p
= SysAllocString(ret
);
667 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
673 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
675 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
676 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
680 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
682 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
683 FIXME("(%p)->(%p)\n", This
, p
);
687 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
689 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
690 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
694 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
696 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
697 FIXME("(%p)->(%p)\n", This
, p
);
701 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
703 HTMLBodyElement
*This
= impl_from_IHTMLBodyElement(iface
);
704 nsIDOMRange
*nsrange
= NULL
;
708 TRACE("(%p)->(%p)\n", This
, range
);
710 if(!This
->textcont
.element
.node
.doc
->nsdoc
) {
715 nsres
= nsIDOMHTMLDocument_CreateRange(This
->textcont
.element
.node
.doc
->nsdoc
, &nsrange
);
716 if(NS_SUCCEEDED(nsres
)) {
717 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
719 ERR("SelectNodeContents failed: %08x\n", nsres
);
721 ERR("CreateRange failed: %08x\n", nsres
);
724 hres
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
->basedoc
.doc_node
, nsrange
, range
);
726 nsIDOMRange_Release(nsrange
);
730 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
731 HTMLBodyElement_QueryInterface
,
732 HTMLBodyElement_AddRef
,
733 HTMLBodyElement_Release
,
734 HTMLBodyElement_GetTypeInfoCount
,
735 HTMLBodyElement_GetTypeInfo
,
736 HTMLBodyElement_GetIDsOfNames
,
737 HTMLBodyElement_Invoke
,
738 HTMLBodyElement_put_background
,
739 HTMLBodyElement_get_background
,
740 HTMLBodyElement_put_bgProperties
,
741 HTMLBodyElement_get_bgProperties
,
742 HTMLBodyElement_put_leftMargin
,
743 HTMLBodyElement_get_leftMargin
,
744 HTMLBodyElement_put_topMargin
,
745 HTMLBodyElement_get_topMargin
,
746 HTMLBodyElement_put_rightMargin
,
747 HTMLBodyElement_get_rightMargin
,
748 HTMLBodyElement_put_bottomMargin
,
749 HTMLBodyElement_get_bottomMargin
,
750 HTMLBodyElement_put_noWrap
,
751 HTMLBodyElement_get_noWrap
,
752 HTMLBodyElement_put_bgColor
,
753 HTMLBodyElement_get_bgColor
,
754 HTMLBodyElement_put_text
,
755 HTMLBodyElement_get_text
,
756 HTMLBodyElement_put_link
,
757 HTMLBodyElement_get_link
,
758 HTMLBodyElement_put_vLink
,
759 HTMLBodyElement_get_vLink
,
760 HTMLBodyElement_put_aLink
,
761 HTMLBodyElement_get_aLink
,
762 HTMLBodyElement_put_onload
,
763 HTMLBodyElement_get_onload
,
764 HTMLBodyElement_put_onunload
,
765 HTMLBodyElement_get_onunload
,
766 HTMLBodyElement_put_scroll
,
767 HTMLBodyElement_get_scroll
,
768 HTMLBodyElement_put_onselect
,
769 HTMLBodyElement_get_onselect
,
770 HTMLBodyElement_put_onbeforeunload
,
771 HTMLBodyElement_get_onbeforeunload
,
772 HTMLBodyElement_createTextRange
775 static inline HTMLBodyElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
777 return CONTAINING_RECORD(iface
, HTMLBodyElement
, textcont
.element
.node
);
780 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
782 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
786 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
787 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
788 *ppv
= &This
->IHTMLBodyElement_iface
;
789 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
790 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
791 *ppv
= &This
->IHTMLBodyElement_iface
;
792 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
793 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
794 *ppv
= &This
->IHTMLBodyElement_iface
;
795 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
796 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This
->textcont
, ppv
);
797 *ppv
= &This
->textcont
.IHTMLTextContainer_iface
;
801 IUnknown_AddRef((IUnknown
*)*ppv
);
805 return HTMLElement_QI(&This
->textcont
.element
.node
, riid
, ppv
);
808 static void HTMLBodyElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
810 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
813 note_cc_edge((nsISupports
*)This
->nsbody
, "This->nsbody", cb
);
816 static void HTMLBodyElement_unlink(HTMLDOMNode
*iface
)
818 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
821 nsIDOMHTMLBodyElement
*nsbody
= This
->nsbody
;
823 nsIDOMHTMLBodyElement_Release(nsbody
);
827 static event_target_t
**HTMLBodyElement_get_event_target_ptr(HTMLDOMNode
*iface
)
829 HTMLBodyElement
*This
= impl_from_HTMLDOMNode(iface
);
831 return This
->textcont
.element
.node
.doc
832 ? &This
->textcont
.element
.node
.doc
->body_event_target
833 : &This
->textcont
.element
.node
.event_target
.ptr
;
836 static BOOL
HTMLBodyElement_is_text_edit(HTMLDOMNode
*iface
)
841 static const cpc_entry_t HTMLBodyElement_cpc
[] = {
842 {&DIID_HTMLTextContainerEvents
},
843 {&IID_IPropertyNotifySink
},
848 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
850 HTMLElement_destructor
,
853 HTMLElement_handle_event
,
854 HTMLElement_get_attr_col
,
855 HTMLBodyElement_get_event_target_ptr
,
864 HTMLBodyElement_traverse
,
865 HTMLBodyElement_unlink
,
866 HTMLBodyElement_is_text_edit
869 static const tid_t HTMLBodyElement_iface_tids
[] = {
870 IHTMLBodyElement_tid
,
871 IHTMLBodyElement2_tid
,
873 IHTMLTextContainer_tid
,
878 static dispex_static_data_t HTMLBodyElement_dispex
= {
882 HTMLBodyElement_iface_tids
885 HRESULT
HTMLBodyElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
887 HTMLBodyElement
*ret
;
890 ret
= heap_alloc_zero(sizeof(HTMLBodyElement
));
892 return E_OUTOFMEMORY
;
894 ret
->IHTMLBodyElement_iface
.lpVtbl
= &HTMLBodyElementVtbl
;
895 ret
->textcont
.element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
897 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
, (void**)&ret
->nsbody
);
898 if(NS_FAILED(nsres
)) {
899 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
901 return E_OUTOFMEMORY
;
904 HTMLTextContainer_Init(&ret
->textcont
, doc
, nselem
, &HTMLBodyElement_dispex
);
906 *elem
= &ret
->textcont
.element
;