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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
37 IHTMLTextAreaElement IHTMLTextAreaElement_iface
;
39 nsIDOMHTMLTextAreaElement
*nstextarea
;
40 } HTMLTextAreaElement
;
42 static inline HTMLTextAreaElement
*impl_from_IHTMLTextAreaElement(IHTMLTextAreaElement
*iface
)
44 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, IHTMLTextAreaElement_iface
);
47 static HRESULT WINAPI
HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement
*iface
,
48 REFIID riid
, void **ppv
)
50 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
52 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
55 static ULONG WINAPI
HTMLTextAreaElement_AddRef(IHTMLTextAreaElement
*iface
)
57 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
59 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
62 static ULONG WINAPI
HTMLTextAreaElement_Release(IHTMLTextAreaElement
*iface
)
64 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
66 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
69 static HRESULT WINAPI
HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement
*iface
, UINT
*pctinfo
)
71 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
75 static HRESULT WINAPI
HTMLTextAreaElement_GetTypeInfo(IHTMLTextAreaElement
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
79 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
83 static HRESULT WINAPI
HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
88 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
89 cNames
, lcid
, rgDispId
);
92 static HRESULT WINAPI
HTMLTextAreaElement_Invoke(IHTMLTextAreaElement
*iface
, DISPID dispIdMember
,
93 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
94 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
96 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
97 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
98 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
101 static HRESULT WINAPI
HTMLTextAreaElement_get_type(IHTMLTextAreaElement
*iface
, BSTR
*p
)
103 static const WCHAR textareaW
[] = {'t','e','x','t','a','r','e','a',0};
105 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
107 TRACE("(%p)->(%p)\n", This
, p
);
109 *p
= SysAllocString(textareaW
);
111 return E_OUTOFMEMORY
;
115 static HRESULT WINAPI
HTMLTextAreaElement_put_value(IHTMLTextAreaElement
*iface
, BSTR v
)
117 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
121 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
123 nsAString_InitDepend(&value_str
, v
);
124 nsres
= nsIDOMHTMLTextAreaElement_SetValue(This
->nstextarea
, &value_str
);
125 nsAString_Finish(&value_str
);
126 if(NS_FAILED(nsres
)) {
127 ERR("SetValue failed: %08x\n", nsres
);
134 static HRESULT WINAPI
HTMLTextAreaElement_get_value(IHTMLTextAreaElement
*iface
, BSTR
*p
)
136 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
138 const PRUnichar
*value
;
142 TRACE("(%p)->(%p)\n", This
, p
);
144 nsAString_Init(&value_str
, NULL
);
146 nsres
= nsIDOMHTMLTextAreaElement_GetValue(This
->nstextarea
, &value_str
);
147 if(NS_SUCCEEDED(nsres
)) {
148 nsAString_GetData(&value_str
, &value
);
149 *p
= *value
? SysAllocString(value
) : NULL
;
151 ERR("GetValue failed: %08x\n", nsres
);
155 nsAString_Finish(&value_str
);
159 static HRESULT WINAPI
HTMLTextAreaElement_put_name(IHTMLTextAreaElement
*iface
, BSTR v
)
161 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
162 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
166 static HRESULT WINAPI
HTMLTextAreaElement_get_name(IHTMLTextAreaElement
*iface
, BSTR
*p
)
168 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
170 const PRUnichar
*name
;
173 TRACE("(%p)->(%p)\n", This
, p
);
175 nsAString_Init(&name_str
, NULL
);
177 nsres
= nsIDOMHTMLTextAreaElement_GetName(This
->nstextarea
, &name_str
);
178 if(NS_SUCCEEDED(nsres
)) {
179 nsAString_GetData(&name_str
, &name
);
180 *p
= SysAllocString(name
);
182 ERR("GetName failed: %08x\n", nsres
);
185 nsAString_Finish(&name_str
);
187 TRACE("%s\n", debugstr_w(*p
));
191 static HRESULT WINAPI
HTMLTextAreaElement_put_status(IHTMLTextAreaElement
*iface
, VARIANT v
)
193 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
194 FIXME("(%p)->()\n", This
);
198 static HRESULT WINAPI
HTMLTextAreaElement_get_status(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
200 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
201 FIXME("(%p)->(%p)\n", This
, p
);
205 static HRESULT WINAPI
HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
207 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
208 FIXME("(%p)->(%x)\n", This
, v
);
212 static HRESULT WINAPI
HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
214 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
215 FIXME("(%p)->(%p)\n", This
, p
);
219 static HRESULT WINAPI
HTMLTextAreaElement_get_form(IHTMLTextAreaElement
*iface
, IHTMLFormElement
**p
)
221 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
222 FIXME("(%p)->(%p)\n", This
, p
);
226 static HRESULT WINAPI
HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement
*iface
, BSTR v
)
228 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
229 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
233 static HRESULT WINAPI
HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement
*iface
, BSTR
*p
)
235 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
236 FIXME("(%p)->(%p)\n", This
, p
);
240 static HRESULT WINAPI
HTMLTextAreaElement_select(IHTMLTextAreaElement
*iface
)
242 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
243 FIXME("(%p)\n", This
);
247 static HRESULT WINAPI
HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement
*iface
, VARIANT v
)
249 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
250 FIXME("(%p)->()\n", This
);
254 static HRESULT WINAPI
HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
256 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
257 FIXME("(%p)->(%p)\n", This
, p
);
261 static HRESULT WINAPI
HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement
*iface
, VARIANT v
)
263 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
264 FIXME("(%p)->()\n", This
);
268 static HRESULT WINAPI
HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
270 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
271 FIXME("(%p)->(%p)\n", This
, p
);
275 static HRESULT WINAPI
HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
277 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
280 TRACE("(%p)->(%x)\n", This
, v
);
282 nsres
= nsIDOMHTMLTextAreaElement_SetReadOnly(This
->nstextarea
, v
!= VARIANT_FALSE
);
283 if(NS_FAILED(nsres
)) {
284 ERR("SetReadOnly failed: %08x\n", nsres
);
291 static HRESULT WINAPI
HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
293 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
297 TRACE("(%p)->(%p)\n", This
, p
);
299 nsres
= nsIDOMHTMLTextAreaElement_GetReadOnly(This
->nstextarea
, &b
);
300 if(NS_FAILED(nsres
)) {
301 ERR("GetReadOnly failed: %08x\n", nsres
);
305 *p
= b
? VARIANT_TRUE
: VARIANT_FALSE
;
309 static HRESULT WINAPI
HTMLTextAreaElement_put_rows(IHTMLTextAreaElement
*iface
, LONG v
)
311 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
312 FIXME("(%p)->(%d)\n", This
, v
);
316 static HRESULT WINAPI
HTMLTextAreaElement_get_rows(IHTMLTextAreaElement
*iface
, LONG
*p
)
318 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
319 FIXME("(%p)->(%p)\n", This
, p
);
323 static HRESULT WINAPI
HTMLTextAreaElement_put_cols(IHTMLTextAreaElement
*iface
, LONG v
)
325 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
326 FIXME("(%p)->(%d)\n", This
, v
);
330 static HRESULT WINAPI
HTMLTextAreaElement_get_cols(IHTMLTextAreaElement
*iface
, LONG
*p
)
332 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
333 FIXME("(%p)->(%p)\n", This
, p
);
337 static HRESULT WINAPI
HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement
*iface
, BSTR v
)
339 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
340 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
344 static HRESULT WINAPI
HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement
*iface
, BSTR
*p
)
346 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
347 FIXME("(%p)->(%p)\n", This
, p
);
351 static HRESULT WINAPI
HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement
*iface
,
352 IHTMLTxtRange
**range
)
354 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
355 FIXME("(%p)->(%p)\n", This
, range
);
359 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl
= {
360 HTMLTextAreaElement_QueryInterface
,
361 HTMLTextAreaElement_AddRef
,
362 HTMLTextAreaElement_Release
,
363 HTMLTextAreaElement_GetTypeInfoCount
,
364 HTMLTextAreaElement_GetTypeInfo
,
365 HTMLTextAreaElement_GetIDsOfNames
,
366 HTMLTextAreaElement_Invoke
,
367 HTMLTextAreaElement_get_type
,
368 HTMLTextAreaElement_put_value
,
369 HTMLTextAreaElement_get_value
,
370 HTMLTextAreaElement_put_name
,
371 HTMLTextAreaElement_get_name
,
372 HTMLTextAreaElement_put_status
,
373 HTMLTextAreaElement_get_status
,
374 HTMLTextAreaElement_put_disabled
,
375 HTMLTextAreaElement_get_disabled
,
376 HTMLTextAreaElement_get_form
,
377 HTMLTextAreaElement_put_defaultValue
,
378 HTMLTextAreaElement_get_defaultValue
,
379 HTMLTextAreaElement_select
,
380 HTMLTextAreaElement_put_onchange
,
381 HTMLTextAreaElement_get_onchange
,
382 HTMLTextAreaElement_put_onselect
,
383 HTMLTextAreaElement_get_onselect
,
384 HTMLTextAreaElement_put_readOnly
,
385 HTMLTextAreaElement_get_readOnly
,
386 HTMLTextAreaElement_put_rows
,
387 HTMLTextAreaElement_get_rows
,
388 HTMLTextAreaElement_put_cols
,
389 HTMLTextAreaElement_get_cols
,
390 HTMLTextAreaElement_put_wrap
,
391 HTMLTextAreaElement_get_wrap
,
392 HTMLTextAreaElement_createTextRange
395 static inline HTMLTextAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
397 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, element
.node
);
400 static HRESULT
HTMLTextAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
402 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
406 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
407 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
408 *ppv
= &This
->IHTMLTextAreaElement_iface
;
409 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
410 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
411 *ppv
= &This
->IHTMLTextAreaElement_iface
;
412 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement
, riid
)) {
413 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This
, ppv
);
414 *ppv
= &This
->IHTMLTextAreaElement_iface
;
418 IUnknown_AddRef((IUnknown
*)*ppv
);
422 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
425 static void HTMLTextAreaElement_destructor(HTMLDOMNode
*iface
)
427 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
429 nsIDOMHTMLTextAreaElement_Release(This
->nstextarea
);
431 HTMLElement_destructor(&This
->element
.node
);
434 static HRESULT
HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
436 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
437 return IHTMLTextAreaElement_put_disabled(&This
->IHTMLTextAreaElement_iface
, v
);
440 static HRESULT
HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
442 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
443 return IHTMLTextAreaElement_get_disabled(&This
->IHTMLTextAreaElement_iface
, p
);
446 static const NodeImplVtbl HTMLTextAreaElementImplVtbl
= {
447 HTMLTextAreaElement_QI
,
448 HTMLTextAreaElement_destructor
,
450 HTMLElement_get_attr_col
,
454 HTMLTextAreaElementImpl_put_disabled
,
455 HTMLTextAreaElementImpl_get_disabled
458 static const tid_t HTMLTextAreaElement_iface_tids
[] = {
460 IHTMLTextAreaElement_tid
,
464 static dispex_static_data_t HTMLTextAreaElement_dispex
= {
466 DispHTMLTextAreaElement_tid
,
468 HTMLTextAreaElement_iface_tids
471 HRESULT
HTMLTextAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
473 HTMLTextAreaElement
*ret
;
476 ret
= heap_alloc_zero(sizeof(HTMLTextAreaElement
));
478 return E_OUTOFMEMORY
;
480 ret
->IHTMLTextAreaElement_iface
.lpVtbl
= &HTMLTextAreaElementVtbl
;
481 ret
->element
.node
.vtbl
= &HTMLTextAreaElementImplVtbl
;
483 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTextAreaElement
,
484 (void**)&ret
->nstextarea
);
485 if(NS_FAILED(nsres
)) {
486 ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres
);
491 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTextAreaElement_dispex
);
493 *elem
= &ret
->element
;