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
;
44 nsIDOMHTMLBodyElement
*nsbody
;
47 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
49 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
51 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
52 REFIID riid
, void **ppv
)
54 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
59 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
60 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
61 *ppv
= HTMLBODY(This
);
62 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
63 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
64 *ppv
= HTMLBODY(This
);
65 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
66 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
67 *ppv
= HTMLBODY(This
);
68 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
69 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
70 *ppv
= HTMLTEXTCONT(&This
->text_container
);
74 IUnknown_AddRef((IUnknown
*)*ppv
);
78 hres
= HTMLElement_QI(This
->element
, riid
, ppv
);
80 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
85 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
87 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
89 TRACE("(%p)\n", This
);
91 return IHTMLDocument2_AddRef(HTMLDOC(This
->element
->node
->doc
));
94 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
96 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
98 TRACE("(%p)\n", This
);
100 return IHTMLDocument2_Release(HTMLDOC(This
->element
->node
->doc
));
103 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
105 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
106 FIXME("(%p)->(%p)\n", This
, pctinfo
);
110 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
111 LCID lcid
, ITypeInfo
**ppTInfo
)
113 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
114 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
118 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
119 LPOLESTR
*rgszNames
, UINT cNames
,
120 LCID lcid
, DISPID
*rgDispId
)
122 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
123 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
128 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
129 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
130 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
132 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
133 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
134 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
138 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
140 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
141 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
145 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
147 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
148 nsAString background_str
;
151 TRACE("(%p)->(%p)\n", This
, p
);
153 nsAString_Init(&background_str
, NULL
);
155 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
156 if(NS_SUCCEEDED(nsres
)) {
157 const PRUnichar
*background
;
158 nsAString_GetData(&background_str
, &background
, NULL
);
159 *p
= SysAllocString(background
);
161 ERR("GetBackground failed: %08x\n", nsres
);
165 nsAString_Finish(&background_str
);
167 TRACE("*p = %s\n", debugstr_w(*p
));
171 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
173 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
174 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
178 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
180 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
181 FIXME("(%p)->(%p)\n", This
, p
);
185 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
187 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
188 FIXME("(%p)->()\n", This
);
192 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
194 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
195 FIXME("(%p)->(%p)\n", This
, p
);
199 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
201 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
202 FIXME("(%p)->()\n", This
);
206 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
208 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
209 FIXME("(%p)->(%p)\n", This
, p
);
213 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
215 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
216 FIXME("(%p)->()\n", This
);
220 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
222 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
223 FIXME("(%p)->(%p)\n", This
, p
);
227 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
229 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
230 FIXME("(%p)->()\n", This
);
234 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
236 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
237 FIXME("(%p)->(%p)\n", This
, p
);
241 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
243 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
244 FIXME("(%p)->(%x)\n", This
, v
);
248 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
250 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
251 FIXME("(%p)->(%p)\n", This
, p
);
255 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
257 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
258 FIXME("(%p)->()\n", This
);
262 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
264 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
265 FIXME("(%p)->(%p)\n", This
, p
);
269 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
271 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
272 FIXME("(%p)->()\n", This
);
276 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
278 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
279 FIXME("(%p)->(%p)\n", This
, p
);
283 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
285 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
286 FIXME("(%p)->()\n", This
);
290 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
292 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
293 FIXME("(%p)->(%p)\n", This
, p
);
297 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
299 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
300 FIXME("(%p)->()\n", This
);
304 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
306 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
307 FIXME("(%p)->(%p)\n", This
, p
);
311 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
313 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
314 FIXME("(%p)->()\n", This
);
318 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
320 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
321 FIXME("(%p)->(%p)\n", This
, p
);
325 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
327 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
328 FIXME("(%p)->()\n", This
);
332 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
334 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
335 FIXME("(%p)->(%p)\n", This
, p
);
339 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
341 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
342 FIXME("(%p)->()\n", This
);
346 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
348 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
349 FIXME("(%p)->(%p)\n", This
, p
);
353 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
355 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
356 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
360 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
362 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
363 FIXME("(%p)->(%p)\n", This
, p
);
367 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
369 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
370 FIXME("(%p)->()\n", This
);
374 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
376 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
377 FIXME("(%p)->(%p)\n", This
, p
);
381 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
383 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
384 FIXME("(%p)->()\n", This
);
388 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
390 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
391 FIXME("(%p)->(%p)\n", This
, p
);
395 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
397 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
398 nsIDOMRange
*nsrange
= NULL
;
400 TRACE("(%p)->(%p)\n", This
, range
);
402 if(This
->element
->node
->doc
->nscontainer
) {
403 nsIDOMDocument
*nsdoc
;
404 nsIDOMDocumentRange
*nsdocrange
;
407 nsIWebNavigation_GetDocument(This
->element
->node
->doc
->nscontainer
->navigation
, &nsdoc
);
408 nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
409 nsIDOMDocument_Release(nsdoc
);
411 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &nsrange
);
412 if(NS_SUCCEEDED(nsres
)) {
413 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->element
->node
->nsnode
);
415 ERR("SelectNodeContents failed: %08x\n", nsres
);
417 ERR("CreateRange failed: %08x\n", nsres
);
420 nsIDOMDocumentRange_Release(nsdocrange
);
423 *range
= HTMLTxtRange_Create(nsrange
);
427 static void HTMLBodyElement_destructor(IUnknown
*iface
)
429 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
431 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
435 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
436 HTMLBodyElement_QueryInterface
,
437 HTMLBodyElement_AddRef
,
438 HTMLBodyElement_Release
,
439 HTMLBodyElement_GetTypeInfoCount
,
440 HTMLBodyElement_GetTypeInfo
,
441 HTMLBodyElement_GetIDsOfNames
,
442 HTMLBodyElement_Invoke
,
443 HTMLBodyElement_put_background
,
444 HTMLBodyElement_get_background
,
445 HTMLBodyElement_put_bgProperties
,
446 HTMLBodyElement_get_bgProperties
,
447 HTMLBodyElement_put_leftMargin
,
448 HTMLBodyElement_get_leftMargin
,
449 HTMLBodyElement_put_topMargin
,
450 HTMLBodyElement_get_topMargin
,
451 HTMLBodyElement_put_rightMargin
,
452 HTMLBodyElement_get_rightMargin
,
453 HTMLBodyElement_put_bottomMargin
,
454 HTMLBodyElement_get_bottomMargin
,
455 HTMLBodyElement_put_noWrap
,
456 HTMLBodyElement_get_noWrap
,
457 HTMLBodyElement_put_bgColor
,
458 HTMLBodyElement_get_bgColor
,
459 HTMLBodyElement_put_text
,
460 HTMLBodyElement_get_text
,
461 HTMLBodyElement_put_link
,
462 HTMLBodyElement_get_link
,
463 HTMLBodyElement_put_vLink
,
464 HTMLBodyElement_get_vLink
,
465 HTMLBodyElement_put_aLink
,
466 HTMLBodyElement_get_aLink
,
467 HTMLBodyElement_put_onload
,
468 HTMLBodyElement_get_onload
,
469 HTMLBodyElement_put_onunload
,
470 HTMLBodyElement_get_onunload
,
471 HTMLBodyElement_put_scroll
,
472 HTMLBodyElement_get_scroll
,
473 HTMLBodyElement_put_onselect
,
474 HTMLBodyElement_get_onselect
,
475 HTMLBodyElement_put_onbeforeunload
,
476 HTMLBodyElement_get_onbeforeunload
,
477 HTMLBodyElement_createTextRange
480 void HTMLBodyElement_Create(HTMLElement
*element
)
482 HTMLBodyElement
*ret
= mshtml_alloc(sizeof(HTMLBodyElement
));
485 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
486 ret
->element
= element
;
488 HTMLTextContainer_Init(&ret
->text_container
, element
);
490 nsres
= nsIDOMHTMLElement_QueryInterface(element
->nselem
, &IID_nsIDOMHTMLBodyElement
,
491 (void**)&ret
->nsbody
);
493 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
495 element
->impl
= (IUnknown
*)HTMLBODY(ret
);
496 element
->destructor
= HTMLBodyElement_destructor
;