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
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 HTMLTextContainer textcont
;
41 const IHTMLBodyElementVtbl
*lpHTMLBodyElementVtbl
;
43 ConnectionPoint cp_propnotif
;
45 nsIDOMHTMLBodyElement
*nsbody
;
48 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
50 static BOOL
variant_to_nscolor(const VARIANT
*v
, nsAString
*nsstr
)
54 nsAString_Init(nsstr
, V_BSTR(v
));
59 static const WCHAR formatW
[] = {'#','%','x',0};
61 wsprintfW(buf
, formatW
, V_I4(v
));
62 nsAString_Init(nsstr
, buf
);
67 FIXME("invalid vt=%d\n", V_VT(v
));
74 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
76 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
77 REFIID riid
, void **ppv
)
79 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
81 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->textcont
.element
.node
), riid
, ppv
);
84 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
86 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
88 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->textcont
.element
.node
));
91 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
93 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
95 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->textcont
.element
.node
));
98 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
100 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
101 FIXME("(%p)->(%p)\n", This
, pctinfo
);
105 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
106 LCID lcid
, ITypeInfo
**ppTInfo
)
108 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
109 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
113 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
114 LPOLESTR
*rgszNames
, UINT cNames
,
115 LCID lcid
, DISPID
*rgDispId
)
117 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
118 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
123 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
124 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
125 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
127 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
128 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
129 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
133 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
135 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
136 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
140 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
142 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
143 nsAString background_str
;
146 TRACE("(%p)->(%p)\n", This
, p
);
148 nsAString_Init(&background_str
, NULL
);
150 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
151 if(NS_SUCCEEDED(nsres
)) {
152 const PRUnichar
*background
;
153 nsAString_GetData(&background_str
, &background
);
154 *p
= *background
? SysAllocString(background
) : NULL
;
156 ERR("GetBackground failed: %08x\n", nsres
);
160 nsAString_Finish(&background_str
);
162 TRACE("*p = %s\n", debugstr_w(*p
));
166 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
168 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
169 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
173 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
175 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
176 FIXME("(%p)->(%p)\n", This
, p
);
180 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
182 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
183 FIXME("(%p)->()\n", This
);
187 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
189 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
190 FIXME("(%p)->(%p)\n", This
, p
);
194 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
196 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
197 FIXME("(%p)->()\n", This
);
201 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
203 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
204 FIXME("(%p)->(%p)\n", This
, p
);
208 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
210 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
211 FIXME("(%p)->()\n", This
);
215 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
217 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
218 FIXME("(%p)->(%p)\n", This
, p
);
222 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
224 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
225 FIXME("(%p)->()\n", This
);
229 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
231 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
232 FIXME("(%p)->(%p)\n", This
, p
);
236 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
238 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
239 FIXME("(%p)->(%x)\n", This
, v
);
243 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
245 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
246 FIXME("(%p)->(%p)\n", This
, p
);
250 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
252 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
253 FIXME("(%p)->()\n", This
);
257 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
259 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
260 FIXME("(%p)->(%p)\n", This
, p
);
264 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
266 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
267 FIXME("(%p)->()\n", This
);
271 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
273 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
280 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
284 TRACE("(%p)->(v%d)\n", This
, V_VT(&v
));
286 if(!variant_to_nscolor(&v
, &link_str
))
289 nsres
= nsIDOMHTMLBodyElement_SetLink(This
->nsbody
, &link_str
);
290 nsAString_Finish(&link_str
);
292 ERR("SetLink failed: %08x\n", nsres
);
297 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
299 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
300 FIXME("(%p)->(%p)\n", This
, p
);
304 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
306 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
307 FIXME("(%p)->()\n", This
);
311 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
313 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
314 FIXME("(%p)->(%p)\n", This
, p
);
318 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
320 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
321 FIXME("(%p)->()\n", This
);
325 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
327 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
328 FIXME("(%p)->(%p)\n", This
, p
);
332 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
334 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
335 FIXME("(%p)->()\n", This
);
339 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
341 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
342 FIXME("(%p)->(%p)\n", This
, p
);
346 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
348 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
349 FIXME("(%p)->()\n", This
);
353 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
355 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
356 FIXME("(%p)->(%p)\n", This
, p
);
360 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
362 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
363 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
367 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
369 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
370 FIXME("(%p)->(%p)\n", This
, p
);
374 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
376 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
377 FIXME("(%p)->()\n", This
);
381 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
383 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
384 FIXME("(%p)->(%p)\n", This
, p
);
388 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
390 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
391 FIXME("(%p)->()\n", This
);
395 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
397 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
398 FIXME("(%p)->(%p)\n", This
, p
);
402 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
404 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
405 nsIDOMRange
*nsrange
= NULL
;
407 TRACE("(%p)->(%p)\n", This
, range
);
409 if(This
->textcont
.element
.node
.doc
->nscontainer
) {
410 nsIDOMDocument
*nsdoc
;
411 nsIDOMDocumentRange
*nsdocrange
;
414 nsIWebNavigation_GetDocument(This
->textcont
.element
.node
.doc
->nscontainer
->navigation
, &nsdoc
);
415 nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
416 nsIDOMDocument_Release(nsdoc
);
418 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &nsrange
);
419 if(NS_SUCCEEDED(nsres
)) {
420 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
422 ERR("SelectNodeContents failed: %08x\n", nsres
);
424 ERR("CreateRange failed: %08x\n", nsres
);
427 nsIDOMDocumentRange_Release(nsdocrange
);
430 *range
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
, nsrange
);
436 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
437 HTMLBodyElement_QueryInterface
,
438 HTMLBodyElement_AddRef
,
439 HTMLBodyElement_Release
,
440 HTMLBodyElement_GetTypeInfoCount
,
441 HTMLBodyElement_GetTypeInfo
,
442 HTMLBodyElement_GetIDsOfNames
,
443 HTMLBodyElement_Invoke
,
444 HTMLBodyElement_put_background
,
445 HTMLBodyElement_get_background
,
446 HTMLBodyElement_put_bgProperties
,
447 HTMLBodyElement_get_bgProperties
,
448 HTMLBodyElement_put_leftMargin
,
449 HTMLBodyElement_get_leftMargin
,
450 HTMLBodyElement_put_topMargin
,
451 HTMLBodyElement_get_topMargin
,
452 HTMLBodyElement_put_rightMargin
,
453 HTMLBodyElement_get_rightMargin
,
454 HTMLBodyElement_put_bottomMargin
,
455 HTMLBodyElement_get_bottomMargin
,
456 HTMLBodyElement_put_noWrap
,
457 HTMLBodyElement_get_noWrap
,
458 HTMLBodyElement_put_bgColor
,
459 HTMLBodyElement_get_bgColor
,
460 HTMLBodyElement_put_text
,
461 HTMLBodyElement_get_text
,
462 HTMLBodyElement_put_link
,
463 HTMLBodyElement_get_link
,
464 HTMLBodyElement_put_vLink
,
465 HTMLBodyElement_get_vLink
,
466 HTMLBodyElement_put_aLink
,
467 HTMLBodyElement_get_aLink
,
468 HTMLBodyElement_put_onload
,
469 HTMLBodyElement_get_onload
,
470 HTMLBodyElement_put_onunload
,
471 HTMLBodyElement_get_onunload
,
472 HTMLBodyElement_put_scroll
,
473 HTMLBodyElement_get_scroll
,
474 HTMLBodyElement_put_onselect
,
475 HTMLBodyElement_get_onselect
,
476 HTMLBodyElement_put_onbeforeunload
,
477 HTMLBodyElement_get_onbeforeunload
,
478 HTMLBodyElement_createTextRange
481 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
483 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
485 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
489 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
490 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
491 *ppv
= HTMLBODY(This
);
492 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
493 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
494 *ppv
= HTMLBODY(This
);
495 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
496 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
497 *ppv
= HTMLBODY(This
);
498 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
499 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This
->textcont
, ppv
);
500 *ppv
= HTMLTEXTCONT(&This
->textcont
);
504 IUnknown_AddRef((IUnknown
*)*ppv
);
508 return HTMLElement_QI(&This
->textcont
.element
.node
, riid
, ppv
);
511 static void HTMLBodyElement_destructor(HTMLDOMNode
*iface
)
513 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
515 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
517 HTMLElement_destructor(&This
->textcont
.element
.node
);
520 #undef HTMLBODY_NODE_THIS
522 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
524 HTMLBodyElement_destructor
527 HTMLElement
*HTMLBodyElement_Create(nsIDOMHTMLElement
*nselem
)
529 HTMLBodyElement
*ret
= heap_alloc(sizeof(HTMLBodyElement
));
532 TRACE("(%p)->(%p)\n", ret
, nselem
);
534 HTMLTextContainer_Init(&ret
->textcont
);
536 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
537 ret
->textcont
.element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
539 ConnectionPoint_Init(&ret
->cp_propnotif
, &ret
->textcont
.element
.cp_container
, &IID_IPropertyNotifySink
);
541 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
,
542 (void**)&ret
->nsbody
);
544 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
546 return &ret
->textcont
.element
;