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 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
52 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
53 REFIID riid
, void **ppv
)
55 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
57 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->textcont
.element
.node
), riid
, ppv
);
60 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
62 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
64 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->textcont
.element
.node
));
67 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
69 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
71 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->textcont
.element
.node
));
74 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
76 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
77 FIXME("(%p)->(%p)\n", This
, pctinfo
);
81 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
82 LCID lcid
, ITypeInfo
**ppTInfo
)
84 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
85 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
89 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
90 LPOLESTR
*rgszNames
, UINT cNames
,
91 LCID lcid
, DISPID
*rgDispId
)
93 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
94 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
99 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
100 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
101 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
103 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
104 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
105 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
109 static HRESULT WINAPI
HTMLBodyElement_put_background(IHTMLBodyElement
*iface
, BSTR v
)
111 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
112 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
116 static HRESULT WINAPI
HTMLBodyElement_get_background(IHTMLBodyElement
*iface
, BSTR
*p
)
118 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
119 nsAString background_str
;
122 TRACE("(%p)->(%p)\n", This
, p
);
124 nsAString_Init(&background_str
, NULL
);
126 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
127 if(NS_SUCCEEDED(nsres
)) {
128 const PRUnichar
*background
;
129 nsAString_GetData(&background_str
, &background
);
130 *p
= *background
? SysAllocString(background
) : NULL
;
132 ERR("GetBackground failed: %08x\n", nsres
);
136 nsAString_Finish(&background_str
);
138 TRACE("*p = %s\n", debugstr_w(*p
));
142 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
144 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
145 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
149 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
151 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
152 FIXME("(%p)->(%p)\n", This
, p
);
156 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
158 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
159 FIXME("(%p)->()\n", This
);
163 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
165 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
166 FIXME("(%p)->(%p)\n", This
, p
);
170 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
172 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
173 FIXME("(%p)->()\n", This
);
177 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
179 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
180 FIXME("(%p)->(%p)\n", This
, p
);
184 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
186 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
187 FIXME("(%p)->()\n", This
);
191 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
193 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
194 FIXME("(%p)->(%p)\n", This
, p
);
198 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
200 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
201 FIXME("(%p)->()\n", This
);
205 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
207 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
208 FIXME("(%p)->(%p)\n", This
, p
);
212 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
214 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
215 FIXME("(%p)->(%x)\n", This
, v
);
219 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
221 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
222 FIXME("(%p)->(%p)\n", This
, p
);
226 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
228 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
229 FIXME("(%p)->()\n", This
);
233 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
235 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
236 FIXME("(%p)->(%p)\n", This
, p
);
240 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
242 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
243 FIXME("(%p)->()\n", This
);
247 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
249 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
250 FIXME("(%p)->(%p)\n", This
, p
);
254 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
256 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
257 FIXME("(%p)->()\n", This
);
261 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
263 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
264 FIXME("(%p)->(%p)\n", This
, p
);
268 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
270 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
271 FIXME("(%p)->()\n", This
);
275 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
277 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
278 FIXME("(%p)->(%p)\n", This
, p
);
282 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
284 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
285 FIXME("(%p)->()\n", This
);
289 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
291 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
292 FIXME("(%p)->(%p)\n", This
, p
);
296 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
298 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
299 FIXME("(%p)->()\n", This
);
303 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
305 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
306 FIXME("(%p)->(%p)\n", This
, p
);
310 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
312 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
313 FIXME("(%p)->()\n", This
);
317 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
319 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
320 FIXME("(%p)->(%p)\n", This
, p
);
324 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
326 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
327 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
331 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
333 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
334 FIXME("(%p)->(%p)\n", This
, p
);
338 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
340 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
341 FIXME("(%p)->()\n", This
);
345 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
347 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
348 FIXME("(%p)->(%p)\n", This
, p
);
352 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
354 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
355 FIXME("(%p)->()\n", This
);
359 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
361 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
362 FIXME("(%p)->(%p)\n", This
, p
);
366 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
368 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
369 nsIDOMRange
*nsrange
= NULL
;
371 TRACE("(%p)->(%p)\n", This
, range
);
373 if(This
->textcont
.element
.node
.doc
->nscontainer
) {
374 nsIDOMDocument
*nsdoc
;
375 nsIDOMDocumentRange
*nsdocrange
;
378 nsIWebNavigation_GetDocument(This
->textcont
.element
.node
.doc
->nscontainer
->navigation
, &nsdoc
);
379 nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
380 nsIDOMDocument_Release(nsdoc
);
382 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &nsrange
);
383 if(NS_SUCCEEDED(nsres
)) {
384 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
386 ERR("SelectNodeContents failed: %08x\n", nsres
);
388 ERR("CreateRange failed: %08x\n", nsres
);
391 nsIDOMDocumentRange_Release(nsdocrange
);
394 *range
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
, nsrange
);
400 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
401 HTMLBodyElement_QueryInterface
,
402 HTMLBodyElement_AddRef
,
403 HTMLBodyElement_Release
,
404 HTMLBodyElement_GetTypeInfoCount
,
405 HTMLBodyElement_GetTypeInfo
,
406 HTMLBodyElement_GetIDsOfNames
,
407 HTMLBodyElement_Invoke
,
408 HTMLBodyElement_put_background
,
409 HTMLBodyElement_get_background
,
410 HTMLBodyElement_put_bgProperties
,
411 HTMLBodyElement_get_bgProperties
,
412 HTMLBodyElement_put_leftMargin
,
413 HTMLBodyElement_get_leftMargin
,
414 HTMLBodyElement_put_topMargin
,
415 HTMLBodyElement_get_topMargin
,
416 HTMLBodyElement_put_rightMargin
,
417 HTMLBodyElement_get_rightMargin
,
418 HTMLBodyElement_put_bottomMargin
,
419 HTMLBodyElement_get_bottomMargin
,
420 HTMLBodyElement_put_noWrap
,
421 HTMLBodyElement_get_noWrap
,
422 HTMLBodyElement_put_bgColor
,
423 HTMLBodyElement_get_bgColor
,
424 HTMLBodyElement_put_text
,
425 HTMLBodyElement_get_text
,
426 HTMLBodyElement_put_link
,
427 HTMLBodyElement_get_link
,
428 HTMLBodyElement_put_vLink
,
429 HTMLBodyElement_get_vLink
,
430 HTMLBodyElement_put_aLink
,
431 HTMLBodyElement_get_aLink
,
432 HTMLBodyElement_put_onload
,
433 HTMLBodyElement_get_onload
,
434 HTMLBodyElement_put_onunload
,
435 HTMLBodyElement_get_onunload
,
436 HTMLBodyElement_put_scroll
,
437 HTMLBodyElement_get_scroll
,
438 HTMLBodyElement_put_onselect
,
439 HTMLBodyElement_get_onselect
,
440 HTMLBodyElement_put_onbeforeunload
,
441 HTMLBodyElement_get_onbeforeunload
,
442 HTMLBodyElement_createTextRange
445 #define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
447 static HRESULT
HTMLBodyElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
449 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
453 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
454 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
455 *ppv
= HTMLBODY(This
);
456 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
457 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
458 *ppv
= HTMLBODY(This
);
459 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
460 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
461 *ppv
= HTMLBODY(This
);
462 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
463 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This
->textcont
, ppv
);
464 *ppv
= HTMLTEXTCONT(&This
->textcont
);
468 IUnknown_AddRef((IUnknown
*)*ppv
);
472 return HTMLElement_QI(&This
->textcont
.element
.node
, riid
, ppv
);
475 static void HTMLBodyElement_destructor(HTMLDOMNode
*iface
)
477 HTMLBodyElement
*This
= HTMLBODY_NODE_THIS(iface
);
479 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
481 HTMLElement_destructor(&This
->textcont
.element
.node
);
484 #undef HTMLBODY_NODE_THIS
486 static const NodeImplVtbl HTMLBodyElementImplVtbl
= {
488 HTMLBodyElement_destructor
491 HTMLElement
*HTMLBodyElement_Create(nsIDOMHTMLElement
*nselem
)
493 HTMLBodyElement
*ret
= heap_alloc(sizeof(HTMLBodyElement
));
496 TRACE("(%p)->(%p)\n", ret
, nselem
);
498 HTMLTextContainer_Init(&ret
->textcont
);
500 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
501 ret
->textcont
.element
.node
.vtbl
= &HTMLBodyElementImplVtbl
;
503 ConnectionPoint_Init(&ret
->cp_propnotif
, &ret
->textcont
.element
.cp_container
, &IID_IPropertyNotifySink
);
505 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
,
506 (void**)&ret
->nsbody
);
508 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
510 return &ret
->textcont
.element
;