d3d9: Hold the lock in stateblock methods.
[wine.git] / dlls / mshtml / htmlbody.c
blobee23922ed4df2dda4ba77227bf0b6835e17255ff
1 /*
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "winnls.h"
30 #include "ole2.h"
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 typedef struct {
39 const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
41 HTMLTextContainer text_container;
43 HTMLElement *element;
44 nsIDOMHTMLBodyElement *nsbody;
45 } HTMLBodyElement;
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);
55 HRESULT hres;
57 *ppv = NULL;
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);
73 if(*ppv) {
74 IUnknown_AddRef((IUnknown*)*ppv);
75 return S_OK;
78 hres = HTMLElement_QI(This->element, riid, ppv);
79 if(FAILED(hres))
80 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
82 return hres;
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);
107 return E_NOTIMPL;
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);
115 return E_NOTIMPL;
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,
124 lcid, rgDispId);
125 return E_NOTIMPL;
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);
135 return E_NOTIMPL;
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));
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLBodyElement_get_background(IHTMLBodyElement *iface, BSTR *p)
147 HTMLBodyElement *This = HTMLBODY_THIS(iface);
148 nsAString background_str;
149 nsresult nsres;
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);
160 }else {
161 ERR("GetBackground failed: %08x\n", nsres);
162 *p = NULL;
165 nsAString_Finish(&background_str);
167 TRACE("*p = %s\n", debugstr_w(*p));
168 return S_OK;
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));
175 return E_NOTIMPL;
178 static HRESULT WINAPI HTMLBodyElement_get_bgProperties(IHTMLBodyElement *iface, BSTR *p)
180 HTMLBodyElement *This = HTMLBODY_THIS(iface);
181 FIXME("(%p)->(%p)\n", This, p);
182 return E_NOTIMPL;
185 static HRESULT WINAPI HTMLBodyElement_put_leftMargin(IHTMLBodyElement *iface, VARIANT v)
187 HTMLBodyElement *This = HTMLBODY_THIS(iface);
188 FIXME("(%p)->()\n", This);
189 return E_NOTIMPL;
192 static HRESULT WINAPI HTMLBodyElement_get_leftMargin(IHTMLBodyElement *iface, VARIANT *p)
194 HTMLBodyElement *This = HTMLBODY_THIS(iface);
195 FIXME("(%p)->(%p)\n", This, p);
196 return E_NOTIMPL;
199 static HRESULT WINAPI HTMLBodyElement_put_topMargin(IHTMLBodyElement *iface, VARIANT v)
201 HTMLBodyElement *This = HTMLBODY_THIS(iface);
202 FIXME("(%p)->()\n", This);
203 return E_NOTIMPL;
206 static HRESULT WINAPI HTMLBodyElement_get_topMargin(IHTMLBodyElement *iface, VARIANT *p)
208 HTMLBodyElement *This = HTMLBODY_THIS(iface);
209 FIXME("(%p)->(%p)\n", This, p);
210 return E_NOTIMPL;
213 static HRESULT WINAPI HTMLBodyElement_put_rightMargin(IHTMLBodyElement *iface, VARIANT v)
215 HTMLBodyElement *This = HTMLBODY_THIS(iface);
216 FIXME("(%p)->()\n", This);
217 return E_NOTIMPL;
220 static HRESULT WINAPI HTMLBodyElement_get_rightMargin(IHTMLBodyElement *iface, VARIANT *p)
222 HTMLBodyElement *This = HTMLBODY_THIS(iface);
223 FIXME("(%p)->(%p)\n", This, p);
224 return E_NOTIMPL;
227 static HRESULT WINAPI HTMLBodyElement_put_bottomMargin(IHTMLBodyElement *iface, VARIANT v)
229 HTMLBodyElement *This = HTMLBODY_THIS(iface);
230 FIXME("(%p)->()\n", This);
231 return E_NOTIMPL;
234 static HRESULT WINAPI HTMLBodyElement_get_bottomMargin(IHTMLBodyElement *iface, VARIANT *p)
236 HTMLBodyElement *This = HTMLBODY_THIS(iface);
237 FIXME("(%p)->(%p)\n", This, p);
238 return E_NOTIMPL;
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);
245 return E_NOTIMPL;
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);
252 return E_NOTIMPL;
255 static HRESULT WINAPI HTMLBodyElement_put_bgColor(IHTMLBodyElement *iface, VARIANT v)
257 HTMLBodyElement *This = HTMLBODY_THIS(iface);
258 FIXME("(%p)->()\n", This);
259 return E_NOTIMPL;
262 static HRESULT WINAPI HTMLBodyElement_get_bgColor(IHTMLBodyElement *iface, VARIANT *p)
264 HTMLBodyElement *This = HTMLBODY_THIS(iface);
265 FIXME("(%p)->(%p)\n", This, p);
266 return E_NOTIMPL;
269 static HRESULT WINAPI HTMLBodyElement_put_text(IHTMLBodyElement *iface, VARIANT v)
271 HTMLBodyElement *This = HTMLBODY_THIS(iface);
272 FIXME("(%p)->()\n", This);
273 return E_NOTIMPL;
276 static HRESULT WINAPI HTMLBodyElement_get_text(IHTMLBodyElement *iface, VARIANT *p)
278 HTMLBodyElement *This = HTMLBODY_THIS(iface);
279 FIXME("(%p)->(%p)\n", This, p);
280 return E_NOTIMPL;
283 static HRESULT WINAPI HTMLBodyElement_put_link(IHTMLBodyElement *iface, VARIANT v)
285 HTMLBodyElement *This = HTMLBODY_THIS(iface);
286 FIXME("(%p)->()\n", This);
287 return E_NOTIMPL;
290 static HRESULT WINAPI HTMLBodyElement_get_link(IHTMLBodyElement *iface, VARIANT *p)
292 HTMLBodyElement *This = HTMLBODY_THIS(iface);
293 FIXME("(%p)->(%p)\n", This, p);
294 return E_NOTIMPL;
297 static HRESULT WINAPI HTMLBodyElement_put_vLink(IHTMLBodyElement *iface, VARIANT v)
299 HTMLBodyElement *This = HTMLBODY_THIS(iface);
300 FIXME("(%p)->()\n", This);
301 return E_NOTIMPL;
304 static HRESULT WINAPI HTMLBodyElement_get_vLink(IHTMLBodyElement *iface, VARIANT *p)
306 HTMLBodyElement *This = HTMLBODY_THIS(iface);
307 FIXME("(%p)->(%p)\n", This, p);
308 return E_NOTIMPL;
311 static HRESULT WINAPI HTMLBodyElement_put_aLink(IHTMLBodyElement *iface, VARIANT v)
313 HTMLBodyElement *This = HTMLBODY_THIS(iface);
314 FIXME("(%p)->()\n", This);
315 return E_NOTIMPL;
318 static HRESULT WINAPI HTMLBodyElement_get_aLink(IHTMLBodyElement *iface, VARIANT *p)
320 HTMLBodyElement *This = HTMLBODY_THIS(iface);
321 FIXME("(%p)->(%p)\n", This, p);
322 return E_NOTIMPL;
325 static HRESULT WINAPI HTMLBodyElement_put_onload(IHTMLBodyElement *iface, VARIANT v)
327 HTMLBodyElement *This = HTMLBODY_THIS(iface);
328 FIXME("(%p)->()\n", This);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLBodyElement_get_onload(IHTMLBodyElement *iface, VARIANT *p)
334 HTMLBodyElement *This = HTMLBODY_THIS(iface);
335 FIXME("(%p)->(%p)\n", This, p);
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLBodyElement_put_onunload(IHTMLBodyElement *iface, VARIANT v)
341 HTMLBodyElement *This = HTMLBODY_THIS(iface);
342 FIXME("(%p)->()\n", This);
343 return E_NOTIMPL;
346 static HRESULT WINAPI HTMLBodyElement_get_onunload(IHTMLBodyElement *iface, VARIANT *p)
348 HTMLBodyElement *This = HTMLBODY_THIS(iface);
349 FIXME("(%p)->(%p)\n", This, p);
350 return E_NOTIMPL;
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));
357 return E_NOTIMPL;
360 static HRESULT WINAPI HTMLBodyElement_get_scroll(IHTMLBodyElement *iface, BSTR *p)
362 HTMLBodyElement *This = HTMLBODY_THIS(iface);
363 FIXME("(%p)->(%p)\n", This, p);
364 return E_NOTIMPL;
367 static HRESULT WINAPI HTMLBodyElement_put_onselect(IHTMLBodyElement *iface, VARIANT v)
369 HTMLBodyElement *This = HTMLBODY_THIS(iface);
370 FIXME("(%p)->()\n", This);
371 return E_NOTIMPL;
374 static HRESULT WINAPI HTMLBodyElement_get_onselect(IHTMLBodyElement *iface, VARIANT *p)
376 HTMLBodyElement *This = HTMLBODY_THIS(iface);
377 FIXME("(%p)->(%p)\n", This, p);
378 return E_NOTIMPL;
381 static HRESULT WINAPI HTMLBodyElement_put_onbeforeunload(IHTMLBodyElement *iface, VARIANT v)
383 HTMLBodyElement *This = HTMLBODY_THIS(iface);
384 FIXME("(%p)->()\n", This);
385 return E_NOTIMPL;
388 static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface, VARIANT *p)
390 HTMLBodyElement *This = HTMLBODY_THIS(iface);
391 FIXME("(%p)->(%p)\n", This, p);
392 return E_NOTIMPL;
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;
405 nsresult nsres;
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);
414 if(NS_FAILED(nsres))
415 ERR("SelectNodeContents failed: %08x\n", nsres);
416 }else {
417 ERR("CreateRange failed: %08x\n", nsres);
420 nsIDOMDocumentRange_Release(nsdocrange);
423 *range = HTMLTxtRange_Create(nsrange);
424 return S_OK;
427 static void HTMLBodyElement_destructor(IUnknown *iface)
429 HTMLBodyElement *This = HTMLBODY_THIS(iface);
431 nsIDOMHTMLBodyElement_Release(This->nsbody);
432 mshtml_free(This);
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));
483 nsresult nsres;
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);
492 if(NS_FAILED(nsres))
493 ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
495 element->impl = (IUnknown*)HTMLBODY(ret);
496 element->destructor = HTMLBodyElement_destructor;