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 ConnectionPointContainer cp_container
;
44 ConnectionPoint cp_propnotif
;
45 ConnectionPoint cp_txtcontevents
;
47 nsIDOMHTMLBodyElement
*nsbody
;
50 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
52 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
54 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
55 REFIID riid
, void **ppv
)
57 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
59 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->textcont
.element
.node
), riid
, ppv
);
62 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
64 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
66 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->textcont
.element
.node
));
69 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
71 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
73 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->textcont
.element
.node
));
76 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
78 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
79 FIXME("(%p)->(%p)\n", This
, pctinfo
);
83 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
84 LCID lcid
, ITypeInfo
**ppTInfo
)
86 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
87 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
91 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
92 LPOLESTR
*rgszNames
, UINT cNames
,
93 LCID lcid
, DISPID
*rgDispId
)
95 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
96 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
101 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
102 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
103 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
105 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
106 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
107 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
111 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
113 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
114 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
118 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
120 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
121 nsAString background_str
;
124 TRACE("(%p)->(%p)\n", This
, p
);
126 nsAString_Init(&background_str
, NULL
);
128 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
129 if(NS_SUCCEEDED(nsres
)) {
130 const PRUnichar
*background
;
131 nsAString_GetData(&background_str
, &background
, NULL
);
132 *p
= SysAllocString(background
);
134 ERR("GetBackground failed: %08x\n", nsres
);
138 nsAString_Finish(&background_str
);
140 TRACE("*p = %s\n", debugstr_w(*p
));
144 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
146 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
147 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
151 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
153 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
154 FIXME("(%p)->(%p)\n", This
, p
);
158 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
160 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
161 FIXME("(%p)->()\n", This
);
165 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
167 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
168 FIXME("(%p)->(%p)\n", This
, p
);
172 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
174 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
175 FIXME("(%p)->()\n", This
);
179 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
181 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
182 FIXME("(%p)->(%p)\n", This
, p
);
186 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
188 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
189 FIXME("(%p)->()\n", This
);
193 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
195 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
196 FIXME("(%p)->(%p)\n", This
, p
);
200 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
202 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
203 FIXME("(%p)->()\n", This
);
207 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
209 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
210 FIXME("(%p)->(%p)\n", This
, p
);
214 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
216 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
217 FIXME("(%p)->(%x)\n", This
, v
);
221 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
223 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
224 FIXME("(%p)->(%p)\n", This
, p
);
228 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
230 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
231 FIXME("(%p)->()\n", This
);
235 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
237 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
238 FIXME("(%p)->(%p)\n", This
, p
);
242 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
244 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
245 FIXME("(%p)->()\n", This
);
249 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
251 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
252 FIXME("(%p)->(%p)\n", This
, p
);
256 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
258 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
259 FIXME("(%p)->()\n", This
);
263 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
265 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
266 FIXME("(%p)->(%p)\n", This
, p
);
270 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
272 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
273 FIXME("(%p)->()\n", This
);
277 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
279 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
280 FIXME("(%p)->(%p)\n", This
, p
);
284 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
286 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
287 FIXME("(%p)->()\n", This
);
291 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
293 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
294 FIXME("(%p)->(%p)\n", This
, p
);
298 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
300 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
301 FIXME("(%p)->()\n", This
);
305 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
307 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
308 FIXME("(%p)->(%p)\n", This
, p
);
312 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
314 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
315 FIXME("(%p)->()\n", This
);
319 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
321 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
322 FIXME("(%p)->(%p)\n", This
, p
);
326 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
328 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
329 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
333 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
335 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
336 FIXME("(%p)->(%p)\n", This
, p
);
340 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
342 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
343 FIXME("(%p)->()\n", This
);
347 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
349 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
350 FIXME("(%p)->(%p)\n", This
, p
);
354 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
356 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
357 FIXME("(%p)->()\n", This
);
361 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
363 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
364 FIXME("(%p)->(%p)\n", This
, p
);
368 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
370 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
371 nsIDOMRange
*nsrange
= NULL
;
373 TRACE("(%p)->(%p)\n", This
, range
);
375 if(This
->textcont
.element
.node
.doc
->nscontainer
) {
376 nsIDOMDocument
*nsdoc
;
377 nsIDOMDocumentRange
*nsdocrange
;
380 nsIWebNavigation_GetDocument(This
->textcont
.element
.node
.doc
->nscontainer
->navigation
, &nsdoc
);
381 nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
382 nsIDOMDocument_Release(nsdoc
);
384 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &nsrange
);
385 if(NS_SUCCEEDED(nsres
)) {
386 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
388 ERR("SelectNodeContents failed: %08x\n", nsres
);
390 ERR("CreateRange failed: %08x\n", nsres
);
393 nsIDOMDocumentRange_Release(nsdocrange
);
396 *range
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
, nsrange
);
402 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
403 HTMLBodyElement_QueryInterface
,
404 HTMLBodyElement_AddRef
,
405 HTMLBodyElement_Release
,
406 HTMLBodyElement_GetTypeInfoCount
,
407 HTMLBodyElement_GetTypeInfo
,
408 HTMLBodyElement_GetIDsOfNames
,
409 HTMLBodyElement_Invoke
,
410 HTMLBodyElement_put_background
,
411 HTMLBodyElement_get_background
,
412 HTMLBodyElement_put_bgProperties
,
413 HTMLBodyElement_get_bgProperties
,
414 HTMLBodyElement_put_leftMargin
,
415 HTMLBodyElement_get_leftMargin
,
416 HTMLBodyElement_put_topMargin
,
417 HTMLBodyElement_get_topMargin
,
418 HTMLBodyElement_put_rightMargin
,
419 HTMLBodyElement_get_rightMargin
,
420 HTMLBodyElement_put_bottomMargin
,
421 HTMLBodyElement_get_bottomMargin
,
422 HTMLBodyElement_put_noWrap
,
423 HTMLBodyElement_get_noWrap
,
424 HTMLBodyElement_put_bgColor
,
425 HTMLBodyElement_get_bgColor
,
426 HTMLBodyElement_put_text
,
427 HTMLBodyElement_get_text
,
428 HTMLBodyElement_put_link
,
429 HTMLBodyElement_get_link
,
430 HTMLBodyElement_put_vLink
,
431 HTMLBodyElement_get_vLink
,
432 HTMLBodyElement_put_aLink
,
433 HTMLBodyElement_get_aLink
,
434 HTMLBodyElement_put_onload
,
435 HTMLBodyElement_get_onload
,
436 HTMLBodyElement_put_onunload
,
437 HTMLBodyElement_get_onunload
,
438 HTMLBodyElement_put_scroll
,
439 HTMLBodyElement_get_scroll
,
440 HTMLBodyElement_put_onselect
,
441 HTMLBodyElement_get_onselect
,
442 HTMLBodyElement_put_onbeforeunload
,
443 HTMLBodyElement_get_onbeforeunload
,
444 HTMLBodyElement_createTextRange
447 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
449 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
451 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
455 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
456 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
457 *ppv
= HTMLBODY(This
);
458 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
459 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
460 *ppv
= HTMLBODY(This
);
461 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
462 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
463 *ppv
= HTMLBODY(This
);
464 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
465 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This
->textcont
, ppv
);
466 *ppv
= HTMLTEXTCONT(&This
->textcont
);
467 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
468 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
469 *ppv
= CONPTCONT(&This
->cp_container
);
473 IUnknown_AddRef((IUnknown
*)*ppv
);
477 return HTMLElement_QI(&This
->textcont
.element
.node
, riid
, ppv
);
480 static void HTMLBodyElement_destructor(HTMLDOMNode
*iface
)
482 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
484 ConnectionPointContainer_Destroy(&This
->cp_container
);
485 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
487 HTMLElement_destructor(&This
->textcont
.element
.node
);
490 #undef HTMLBODY_NODE_THIS
492 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
494 HTMLBodyElement_destructor
497 HTMLElement
*HTMLBodyElement_Create(nsIDOMHTMLElement
*nselem
)
499 HTMLBodyElement
*ret
= mshtml_alloc(sizeof(HTMLBodyElement
));
502 TRACE("(%p)->(%p)\n", ret
, nselem
);
504 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
505 ret
->textcont
.element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
507 HTMLTextContainer_Init(&ret
->textcont
);
509 ConnectionPoint_Init(&ret
->cp_propnotif
, CONPTCONT(&ret
->cp_container
),
510 &IID_IPropertyNotifySink
, NULL
);
511 ConnectionPoint_Init(&ret
->cp_txtcontevents
, CONPTCONT(&ret
->cp_container
),
512 &DIID_HTMLTextContainerEvents
, &ret
->cp_propnotif
);
513 ConnectionPointContainer_Init(&ret
->cp_container
, &ret
->cp_propnotif
, (IUnknown
*)HTMLBODY(ret
));
515 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
,
516 (void**)&ret
->nsbody
);
518 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
520 return &ret
->textcont
.element
;