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 HTMLTextContainer text_container
;
45 ConnectionPointContainer cp_container
;
46 ConnectionPoint cp_propnotif
;
47 ConnectionPoint cp_txtcontevents
;
49 nsIDOMHTMLBodyElement
*nsbody
;
52 #define HTMLBODY(x) ((IHTMLBodyElement*) &(x)->lpHTMLBodyElementVtbl)
54 #define HTMLBODY_THIS(iface) DEFINE_THIS(HTMLBodyElement, HTMLBodyElement, iface)
56 static HRESULT WINAPI
HTMLBodyElement_QueryInterface(IHTMLBodyElement
*iface
,
57 REFIID riid
, void **ppv
)
59 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
64 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
65 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
66 *ppv
= HTMLBODY(This
);
67 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
68 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
69 *ppv
= HTMLBODY(This
);
70 }else if(IsEqualGUID(&IID_IHTMLBodyElement
, riid
)) {
71 TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This
, ppv
);
72 *ppv
= HTMLBODY(This
);
73 }else if(IsEqualGUID(&IID_IHTMLTextContainer
, riid
)) {
74 TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", This
, ppv
);
75 *ppv
= HTMLTEXTCONT(&This
->text_container
);
76 }else if(IsEqualGUID(&IID_IConnectionPointContainer
, riid
)) {
77 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This
, ppv
);
78 *ppv
= CONPTCONT(&This
->cp_container
);
82 IUnknown_AddRef((IUnknown
*)*ppv
);
86 hres
= HTMLElement_QI(&This
->textcont
.element
, riid
, ppv
);
88 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
93 static ULONG WINAPI
HTMLBodyElement_AddRef(IHTMLBodyElement
*iface
)
95 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
97 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->textcont
.element
.node
));
100 static ULONG WINAPI
HTMLBodyElement_Release(IHTMLBodyElement
*iface
)
102 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
104 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->textcont
.element
.node
));
107 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement
*iface
, UINT
*pctinfo
)
109 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
110 FIXME("(%p)->(%p)\n", This
, pctinfo
);
114 static HRESULT WINAPI
HTMLBodyElement_GetTypeInfo(IHTMLBodyElement
*iface
, UINT iTInfo
,
115 LCID lcid
, ITypeInfo
**ppTInfo
)
117 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
118 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
122 static HRESULT WINAPI
HTMLBodyElement_GetIDsOfNames(IHTMLBodyElement
*iface
, REFIID riid
,
123 LPOLESTR
*rgszNames
, UINT cNames
,
124 LCID lcid
, DISPID
*rgDispId
)
126 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
127 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
132 static HRESULT WINAPI
HTMLBodyElement_Invoke(IHTMLBodyElement
*iface
, DISPID dispIdMember
,
133 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
134 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
136 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
137 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
138 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
142 static HRESULT WINAPI
HTMLBodyElement_put_background(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_background(IHTMLBodyElement
*iface
, BSTR
*p
)
151 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
152 nsAString background_str
;
155 TRACE("(%p)->(%p)\n", This
, p
);
157 nsAString_Init(&background_str
, NULL
);
159 nsres
= nsIDOMHTMLBodyElement_GetBackground(This
->nsbody
, &background_str
);
160 if(NS_SUCCEEDED(nsres
)) {
161 const PRUnichar
*background
;
162 nsAString_GetData(&background_str
, &background
, NULL
);
163 *p
= SysAllocString(background
);
165 ERR("GetBackground failed: %08x\n", nsres
);
169 nsAString_Finish(&background_str
);
171 TRACE("*p = %s\n", debugstr_w(*p
));
175 static HRESULT WINAPI
HTMLBodyElement_put_bgProperties(IHTMLBodyElement
*iface
, BSTR v
)
177 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
178 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
182 static HRESULT WINAPI
HTMLBodyElement_get_bgProperties(IHTMLBodyElement
*iface
, BSTR
*p
)
184 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
185 FIXME("(%p)->(%p)\n", This
, p
);
189 static HRESULT WINAPI
HTMLBodyElement_put_leftMargin(IHTMLBodyElement
*iface
, VARIANT v
)
191 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
192 FIXME("(%p)->()\n", This
);
196 static HRESULT WINAPI
HTMLBodyElement_get_leftMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
198 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLBodyElement_put_topMargin(IHTMLBodyElement
*iface
, VARIANT v
)
205 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
206 FIXME("(%p)->()\n", This
);
210 static HRESULT WINAPI
HTMLBodyElement_get_topMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
212 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
213 FIXME("(%p)->(%p)\n", This
, p
);
217 static HRESULT WINAPI
HTMLBodyElement_put_rightMargin(IHTMLBodyElement
*iface
, VARIANT v
)
219 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
220 FIXME("(%p)->()\n", This
);
224 static HRESULT WINAPI
HTMLBodyElement_get_rightMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
226 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
227 FIXME("(%p)->(%p)\n", This
, p
);
231 static HRESULT WINAPI
HTMLBodyElement_put_bottomMargin(IHTMLBodyElement
*iface
, VARIANT v
)
233 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
234 FIXME("(%p)->()\n", This
);
238 static HRESULT WINAPI
HTMLBodyElement_get_bottomMargin(IHTMLBodyElement
*iface
, VARIANT
*p
)
240 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
241 FIXME("(%p)->(%p)\n", This
, p
);
245 static HRESULT WINAPI
HTMLBodyElement_put_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL v
)
247 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
248 FIXME("(%p)->(%x)\n", This
, v
);
252 static HRESULT WINAPI
HTMLBodyElement_get_noWrap(IHTMLBodyElement
*iface
, VARIANT_BOOL
*p
)
254 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
255 FIXME("(%p)->(%p)\n", This
, p
);
259 static HRESULT WINAPI
HTMLBodyElement_put_bgColor(IHTMLBodyElement
*iface
, VARIANT v
)
261 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
262 FIXME("(%p)->()\n", This
);
266 static HRESULT WINAPI
HTMLBodyElement_get_bgColor(IHTMLBodyElement
*iface
, VARIANT
*p
)
268 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
269 FIXME("(%p)->(%p)\n", This
, p
);
273 static HRESULT WINAPI
HTMLBodyElement_put_text(IHTMLBodyElement
*iface
, VARIANT v
)
275 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
276 FIXME("(%p)->()\n", This
);
280 static HRESULT WINAPI
HTMLBodyElement_get_text(IHTMLBodyElement
*iface
, VARIANT
*p
)
282 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
283 FIXME("(%p)->(%p)\n", This
, p
);
287 static HRESULT WINAPI
HTMLBodyElement_put_link(IHTMLBodyElement
*iface
, VARIANT v
)
289 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
290 FIXME("(%p)->()\n", This
);
294 static HRESULT WINAPI
HTMLBodyElement_get_link(IHTMLBodyElement
*iface
, VARIANT
*p
)
296 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
297 FIXME("(%p)->(%p)\n", This
, p
);
301 static HRESULT WINAPI
HTMLBodyElement_put_vLink(IHTMLBodyElement
*iface
, VARIANT v
)
303 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
304 FIXME("(%p)->()\n", This
);
308 static HRESULT WINAPI
HTMLBodyElement_get_vLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
310 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
311 FIXME("(%p)->(%p)\n", This
, p
);
315 static HRESULT WINAPI
HTMLBodyElement_put_aLink(IHTMLBodyElement
*iface
, VARIANT v
)
317 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
318 FIXME("(%p)->()\n", This
);
322 static HRESULT WINAPI
HTMLBodyElement_get_aLink(IHTMLBodyElement
*iface
, VARIANT
*p
)
324 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
325 FIXME("(%p)->(%p)\n", This
, p
);
329 static HRESULT WINAPI
HTMLBodyElement_put_onload(IHTMLBodyElement
*iface
, VARIANT v
)
331 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
332 FIXME("(%p)->()\n", This
);
336 static HRESULT WINAPI
HTMLBodyElement_get_onload(IHTMLBodyElement
*iface
, VARIANT
*p
)
338 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
339 FIXME("(%p)->(%p)\n", This
, p
);
343 static HRESULT WINAPI
HTMLBodyElement_put_onunload(IHTMLBodyElement
*iface
, VARIANT v
)
345 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
346 FIXME("(%p)->()\n", This
);
350 static HRESULT WINAPI
HTMLBodyElement_get_onunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
352 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
353 FIXME("(%p)->(%p)\n", This
, p
);
357 static HRESULT WINAPI
HTMLBodyElement_put_scroll(IHTMLBodyElement
*iface
, BSTR v
)
359 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
360 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
364 static HRESULT WINAPI
HTMLBodyElement_get_scroll(IHTMLBodyElement
*iface
, BSTR
*p
)
366 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
367 FIXME("(%p)->(%p)\n", This
, p
);
371 static HRESULT WINAPI
HTMLBodyElement_put_onselect(IHTMLBodyElement
*iface
, VARIANT v
)
373 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
374 FIXME("(%p)->()\n", This
);
378 static HRESULT WINAPI
HTMLBodyElement_get_onselect(IHTMLBodyElement
*iface
, VARIANT
*p
)
380 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
381 FIXME("(%p)->(%p)\n", This
, p
);
385 static HRESULT WINAPI
HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT v
)
387 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
388 FIXME("(%p)->()\n", This
);
392 static HRESULT WINAPI
HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement
*iface
, VARIANT
*p
)
394 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
395 FIXME("(%p)->(%p)\n", This
, p
);
399 static HRESULT WINAPI
HTMLBodyElement_createTextRange(IHTMLBodyElement
*iface
, IHTMLTxtRange
**range
)
401 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
402 nsIDOMRange
*nsrange
= NULL
;
404 TRACE("(%p)->(%p)\n", This
, range
);
406 if(This
->textcont
.element
.node
.doc
->nscontainer
) {
407 nsIDOMDocument
*nsdoc
;
408 nsIDOMDocumentRange
*nsdocrange
;
411 nsIWebNavigation_GetDocument(This
->textcont
.element
.node
.doc
->nscontainer
->navigation
, &nsdoc
);
412 nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentRange
, (void**)&nsdocrange
);
413 nsIDOMDocument_Release(nsdoc
);
415 nsres
= nsIDOMDocumentRange_CreateRange(nsdocrange
, &nsrange
);
416 if(NS_SUCCEEDED(nsres
)) {
417 nsres
= nsIDOMRange_SelectNodeContents(nsrange
, This
->textcont
.element
.node
.nsnode
);
419 ERR("SelectNodeContents failed: %08x\n", nsres
);
421 ERR("CreateRange failed: %08x\n", nsres
);
424 nsIDOMDocumentRange_Release(nsdocrange
);
427 *range
= HTMLTxtRange_Create(This
->textcont
.element
.node
.doc
, nsrange
);
431 static void HTMLBodyElement_destructor(IUnknown
*iface
)
433 HTMLBodyElement
*This
= HTMLBODY_THIS(iface
);
435 ConnectionPointContainer_Destroy(&This
->cp_container
);
436 nsIDOMHTMLBodyElement_Release(This
->nsbody
);
440 static const IHTMLBodyElementVtbl HTMLBodyElementVtbl
= {
441 HTMLBodyElement_QueryInterface
,
442 HTMLBodyElement_AddRef
,
443 HTMLBodyElement_Release
,
444 HTMLBodyElement_GetTypeInfoCount
,
445 HTMLBodyElement_GetTypeInfo
,
446 HTMLBodyElement_GetIDsOfNames
,
447 HTMLBodyElement_Invoke
,
448 HTMLBodyElement_put_background
,
449 HTMLBodyElement_get_background
,
450 HTMLBodyElement_put_bgProperties
,
451 HTMLBodyElement_get_bgProperties
,
452 HTMLBodyElement_put_leftMargin
,
453 HTMLBodyElement_get_leftMargin
,
454 HTMLBodyElement_put_topMargin
,
455 HTMLBodyElement_get_topMargin
,
456 HTMLBodyElement_put_rightMargin
,
457 HTMLBodyElement_get_rightMargin
,
458 HTMLBodyElement_put_bottomMargin
,
459 HTMLBodyElement_get_bottomMargin
,
460 HTMLBodyElement_put_noWrap
,
461 HTMLBodyElement_get_noWrap
,
462 HTMLBodyElement_put_bgColor
,
463 HTMLBodyElement_get_bgColor
,
464 HTMLBodyElement_put_text
,
465 HTMLBodyElement_get_text
,
466 HTMLBodyElement_put_link
,
467 HTMLBodyElement_get_link
,
468 HTMLBodyElement_put_vLink
,
469 HTMLBodyElement_get_vLink
,
470 HTMLBodyElement_put_aLink
,
471 HTMLBodyElement_get_aLink
,
472 HTMLBodyElement_put_onload
,
473 HTMLBodyElement_get_onload
,
474 HTMLBodyElement_put_onunload
,
475 HTMLBodyElement_get_onunload
,
476 HTMLBodyElement_put_scroll
,
477 HTMLBodyElement_get_scroll
,
478 HTMLBodyElement_put_onselect
,
479 HTMLBodyElement_get_onselect
,
480 HTMLBodyElement_put_onbeforeunload
,
481 HTMLBodyElement_get_onbeforeunload
,
482 HTMLBodyElement_createTextRange
485 HTMLElement
*HTMLBodyElement_Create(nsIDOMHTMLElement
*nselem
)
487 HTMLBodyElement
*ret
= mshtml_alloc(sizeof(HTMLBodyElement
));
490 ret
->lpHTMLBodyElementVtbl
= &HTMLBodyElementVtbl
;
492 HTMLTextContainer_Init(&ret
->text_container
);
494 ConnectionPoint_Init(&ret
->cp_propnotif
, CONPTCONT(&ret
->cp_container
),
495 &IID_IPropertyNotifySink
, NULL
);
496 ConnectionPoint_Init(&ret
->cp_txtcontevents
, CONPTCONT(&ret
->cp_container
),
497 &DIID_HTMLTextContainerEvents
, &ret
->cp_propnotif
);
498 ConnectionPointContainer_Init(&ret
->cp_container
, &ret
->cp_propnotif
, (IUnknown
*)HTMLBODY(ret
));
500 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLBodyElement
,
501 (void**)&ret
->nsbody
);
503 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres
);
505 ret
->textcont
.element
.impl
= (IUnknown
*)HTMLBODY(ret
);
506 ret
->textcont
.element
.destructor
= HTMLBodyElement_destructor
;
508 return &ret
->textcont
.element
;