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 const IHTMLBodyElementVtbl
*lpHTMLBodyElementVtbl
;
41 HTMLTextContainer text_container
;
43 ConnectionPointContainer cp_container
;
44 ConnectionPoint cp_propnotif
;
45 ConnectionPoint cp_txtcontevents
;
48 nsIDOMHTMLBodyElement
*nsbody
;
51 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
53 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
55 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
56 REFIID riid
, void **ppv
)
58 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
63 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
64 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
65 *ppv
= HTMLBODY(This
);
66 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
67 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
68 *ppv
= HTMLBODY(This
);
69 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
70 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
71 *ppv
= HTMLBODY(This
);
72 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
73 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
74 *ppv
= HTMLTEXTCONT(&This
->text_container
);
75 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
76 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
77 *ppv
= CONPTCONT(&This
->cp_container
);
81 IUnknown_AddRef((IUnknown
*)*ppv
);
85 hres
= HTMLElement_QI(This
->element
, riid
, ppv
);
87 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
92 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
94 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
96 TRACE("(%p)\n", This
);
98 return IHTMLDocument2_AddRef(HTMLDOC(This
->element
->node
->doc
));
101 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
103 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
105 TRACE("(%p)\n", This
);
107 return IHTMLDocument2_Release(HTMLDOC(This
->element
->node
->doc
));
110 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
112 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
113 FIXME("(%p)->(%p)\n", This
, pctinfo
);
117 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
118 LCID lcid
, ITypeInfo
**ppTInfo
)
120 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
121 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
125 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
126 LPOLESTR
*rgszNames
, UINT cNames
,
127 LCID lcid
, DISPID
*rgDispId
)
129 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
130 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
135 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
136 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
137 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
139 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
140 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
141 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
145 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
147 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
148 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
152 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
154 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
155 nsAString background_str
;
158 TRACE("(%p)->(%p)\n", This
, p
);
160 nsAString_Init(&background_str
, NULL
);
162 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
163 if(NS_SUCCEEDED(nsres
)) {
164 const PRUnichar
*background
;
165 nsAString_GetData(&background_str
, &background
, NULL
);
166 *p
= SysAllocString(background
);
168 ERR("GetBackground failed: %08x\n", nsres
);
172 nsAString_Finish(&background_str
);
174 TRACE("*p = %s\n", debugstr_w(*p
));
178 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
180 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
181 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
185 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
187 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
188 FIXME("(%p)->(%p)\n", This
, p
);
192 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
194 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
195 FIXME("(%p)->()\n", This
);
199 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
201 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
202 FIXME("(%p)->(%p)\n", This
, p
);
206 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
208 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
209 FIXME("(%p)->()\n", This
);
213 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
215 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
216 FIXME("(%p)->(%p)\n", This
, p
);
220 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
222 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
223 FIXME("(%p)->()\n", This
);
227 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
229 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
230 FIXME("(%p)->(%p)\n", This
, p
);
234 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
236 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
237 FIXME("(%p)->()\n", This
);
241 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
243 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
244 FIXME("(%p)->(%p)\n", This
, p
);
248 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
250 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
251 FIXME("(%p)->(%x)\n", This
, v
);
255 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
257 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
258 FIXME("(%p)->(%p)\n", This
, p
);
262 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
264 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
265 FIXME("(%p)->()\n", This
);
269 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
271 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
272 FIXME("(%p)->(%p)\n", This
, p
);
276 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
278 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
279 FIXME("(%p)->()\n", This
);
283 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
285 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
286 FIXME("(%p)->(%p)\n", This
, p
);
290 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
292 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
293 FIXME("(%p)->()\n", This
);
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
->element
->node
->doc
->nscontainer
) {
410 nsIDOMDocument
*nsdoc
;
411 nsIDOMDocumentRange
*nsdocrange
;
414 nsIWebNavigation_GetDocument(This
->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
->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(nsrange
);
434 static void HTMLBodyElement_destructor(IUnknown
*iface
)
436 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
438 ConnectionPointContainer_Destroy(&This
->cp_container
);
439 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
443 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
444 HTMLBodyElement_QueryInterface
,
445 HTMLBodyElement_AddRef
,
446 HTMLBodyElement_Release
,
447 HTMLBodyElement_GetTypeInfoCount
,
448 HTMLBodyElement_GetTypeInfo
,
449 HTMLBodyElement_GetIDsOfNames
,
450 HTMLBodyElement_Invoke
,
451 HTMLBodyElement_put_background
,
452 HTMLBodyElement_get_background
,
453 HTMLBodyElement_put_bgProperties
,
454 HTMLBodyElement_get_bgProperties
,
455 HTMLBodyElement_put_leftMargin
,
456 HTMLBodyElement_get_leftMargin
,
457 HTMLBodyElement_put_topMargin
,
458 HTMLBodyElement_get_topMargin
,
459 HTMLBodyElement_put_rightMargin
,
460 HTMLBodyElement_get_rightMargin
,
461 HTMLBodyElement_put_bottomMargin
,
462 HTMLBodyElement_get_bottomMargin
,
463 HTMLBodyElement_put_noWrap
,
464 HTMLBodyElement_get_noWrap
,
465 HTMLBodyElement_put_bgColor
,
466 HTMLBodyElement_get_bgColor
,
467 HTMLBodyElement_put_text
,
468 HTMLBodyElement_get_text
,
469 HTMLBodyElement_put_link
,
470 HTMLBodyElement_get_link
,
471 HTMLBodyElement_put_vLink
,
472 HTMLBodyElement_get_vLink
,
473 HTMLBodyElement_put_aLink
,
474 HTMLBodyElement_get_aLink
,
475 HTMLBodyElement_put_onload
,
476 HTMLBodyElement_get_onload
,
477 HTMLBodyElement_put_onunload
,
478 HTMLBodyElement_get_onunload
,
479 HTMLBodyElement_put_scroll
,
480 HTMLBodyElement_get_scroll
,
481 HTMLBodyElement_put_onselect
,
482 HTMLBodyElement_get_onselect
,
483 HTMLBodyElement_put_onbeforeunload
,
484 HTMLBodyElement_get_onbeforeunload
,
485 HTMLBodyElement_createTextRange
488 void HTMLBodyElement_Create(HTMLElement
*element
)
490 HTMLBodyElement
*ret
= mshtml_alloc(sizeof(HTMLBodyElement
));
493 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
494 ret
->element
= element
;
496 HTMLTextContainer_Init(&ret
->text_container
, element
);
498 ConnectionPoint_Init(&ret
->cp_propnotif
, CONPTCONT(&ret
->cp_container
),
499 &IID_IPropertyNotifySink
, NULL
);
500 ConnectionPoint_Init(&ret
->cp_txtcontevents
, CONPTCONT(&ret
->cp_container
),
501 &DIID_HTMLTextContainerEvents
, &ret
->cp_propnotif
);
502 ConnectionPointContainer_Init(&ret
->cp_container
, &ret
->cp_propnotif
, (IUnknown
*)HTMLBODY(ret
));
504 nsres
= nsIDOMHTMLElement_QueryInterface(element
->nselem
, &IID_nsIDOMHTMLBodyElement
,
505 (void**)&ret
->nsbody
);
507 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
509 element
->impl
= (IUnknown
*)HTMLBODY(ret
);
510 element
->destructor
= HTMLBodyElement_destructor
;