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"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 struct HTMLTextAreaElement
{
38 IHTMLTextAreaElement IHTMLTextAreaElement_iface
;
40 nsIDOMHTMLTextAreaElement
*nstextarea
;
43 static inline HTMLTextAreaElement
*impl_from_IHTMLTextAreaElement(IHTMLTextAreaElement
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, IHTMLTextAreaElement_iface
);
48 static HRESULT WINAPI
HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement
*iface
,
49 REFIID riid
, void **ppv
)
51 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLTextAreaElement_AddRef(IHTMLTextAreaElement
*iface
)
58 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLTextAreaElement_Release(IHTMLTextAreaElement
*iface
)
65 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement
*iface
, UINT
*pctinfo
)
72 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLTextAreaElement_GetTypeInfo(IHTMLTextAreaElement
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
,
86 LCID lcid
, DISPID
*rgDispId
)
88 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
90 cNames
, lcid
, rgDispId
);
93 static HRESULT WINAPI
HTMLTextAreaElement_Invoke(IHTMLTextAreaElement
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
98 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
99 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLTextAreaElement_get_type(IHTMLTextAreaElement
*iface
, BSTR
*p
)
104 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
106 TRACE("(%p)->(%p)\n", This
, p
);
108 *p
= SysAllocString(L
"textarea");
110 return E_OUTOFMEMORY
;
114 static HRESULT WINAPI
HTMLTextAreaElement_put_value(IHTMLTextAreaElement
*iface
, BSTR v
)
116 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
120 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
122 nsAString_InitDepend(&value_str
, v
);
123 nsres
= nsIDOMHTMLTextAreaElement_SetValue(This
->nstextarea
, &value_str
);
124 nsAString_Finish(&value_str
);
125 if(NS_FAILED(nsres
)) {
126 ERR("SetValue failed: %08lx\n", nsres
);
133 static HRESULT WINAPI
HTMLTextAreaElement_get_value(IHTMLTextAreaElement
*iface
, BSTR
*p
)
135 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
139 TRACE("(%p)->(%p)\n", This
, p
);
141 nsAString_Init(&value_str
, NULL
);
142 nsres
= nsIDOMHTMLTextAreaElement_GetValue(This
->nstextarea
, &value_str
);
143 return return_nsstr(nsres
, &value_str
, p
);
146 static HRESULT WINAPI
HTMLTextAreaElement_put_name(IHTMLTextAreaElement
*iface
, BSTR v
)
148 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
149 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
153 static HRESULT WINAPI
HTMLTextAreaElement_get_name(IHTMLTextAreaElement
*iface
, BSTR
*p
)
155 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
159 TRACE("(%p)->(%p)\n", This
, p
);
161 nsAString_Init(&name_str
, NULL
);
162 nsres
= nsIDOMHTMLTextAreaElement_GetName(This
->nstextarea
, &name_str
);
163 return return_nsstr(nsres
, &name_str
, p
);
166 static HRESULT WINAPI
HTMLTextAreaElement_put_status(IHTMLTextAreaElement
*iface
, VARIANT v
)
168 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
169 FIXME("(%p)->()\n", This
);
173 static HRESULT WINAPI
HTMLTextAreaElement_get_status(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
175 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
176 FIXME("(%p)->(%p)\n", This
, p
);
180 static HRESULT WINAPI
HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
182 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
183 FIXME("(%p)->(%x)\n", This
, v
);
187 static HRESULT WINAPI
HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
189 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
190 FIXME("(%p)->(%p)\n", This
, p
);
194 static HRESULT WINAPI
HTMLTextAreaElement_get_form(IHTMLTextAreaElement
*iface
, IHTMLFormElement
**p
)
196 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
197 nsIDOMHTMLFormElement
*nsform
;
200 TRACE("(%p)->(%p)\n", This
, p
);
202 nsres
= nsIDOMHTMLTextAreaElement_GetForm(This
->nstextarea
, &nsform
);
203 return return_nsform(nsres
, nsform
, p
);
206 static HRESULT WINAPI
HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement
*iface
, BSTR v
)
208 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
212 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
214 nsAString_InitDepend(&nsstr
, v
);
215 nsres
= nsIDOMHTMLTextAreaElement_SetDefaultValue(This
->nstextarea
, &nsstr
);
216 nsAString_Finish(&nsstr
);
217 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
220 static HRESULT WINAPI
HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement
*iface
, BSTR
*p
)
222 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
226 TRACE("(%p)->(%p)\n", This
, p
);
228 nsAString_Init(&nsstr
, NULL
);
229 nsres
= nsIDOMHTMLTextAreaElement_GetDefaultValue(This
->nstextarea
, &nsstr
);
230 return return_nsstr(nsres
, &nsstr
, p
);
233 static HRESULT WINAPI
HTMLTextAreaElement_select(IHTMLTextAreaElement
*iface
)
235 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
236 FIXME("(%p)\n", This
);
240 static HRESULT WINAPI
HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement
*iface
, VARIANT v
)
242 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
243 FIXME("(%p)->()\n", This
);
247 static HRESULT WINAPI
HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
249 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
250 FIXME("(%p)->(%p)\n", This
, p
);
254 static HRESULT WINAPI
HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement
*iface
, VARIANT v
)
256 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
257 FIXME("(%p)->()\n", This
);
261 static HRESULT WINAPI
HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
263 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
264 FIXME("(%p)->(%p)\n", This
, p
);
268 static HRESULT WINAPI
HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
270 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
273 TRACE("(%p)->(%x)\n", This
, v
);
275 nsres
= nsIDOMHTMLTextAreaElement_SetReadOnly(This
->nstextarea
, v
!= VARIANT_FALSE
);
276 if(NS_FAILED(nsres
)) {
277 ERR("SetReadOnly failed: %08lx\n", nsres
);
284 static HRESULT WINAPI
HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
286 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
290 TRACE("(%p)->(%p)\n", This
, p
);
292 nsres
= nsIDOMHTMLTextAreaElement_GetReadOnly(This
->nstextarea
, &b
);
293 if(NS_FAILED(nsres
)) {
294 ERR("GetReadOnly failed: %08lx\n", nsres
);
298 *p
= variant_bool(b
);
302 static HRESULT WINAPI
HTMLTextAreaElement_put_rows(IHTMLTextAreaElement
*iface
, LONG v
)
304 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
305 FIXME("(%p)->(%ld)\n", This
, v
);
309 static HRESULT WINAPI
HTMLTextAreaElement_get_rows(IHTMLTextAreaElement
*iface
, LONG
*p
)
311 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
312 FIXME("(%p)->(%p)\n", This
, p
);
316 static HRESULT WINAPI
HTMLTextAreaElement_put_cols(IHTMLTextAreaElement
*iface
, LONG v
)
318 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
319 FIXME("(%p)->(%ld)\n", This
, v
);
323 static HRESULT WINAPI
HTMLTextAreaElement_get_cols(IHTMLTextAreaElement
*iface
, LONG
*p
)
325 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
326 FIXME("(%p)->(%p)\n", This
, p
);
330 static HRESULT WINAPI
HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement
*iface
, BSTR v
)
332 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
333 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
337 static HRESULT WINAPI
HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement
*iface
, BSTR
*p
)
339 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
340 FIXME("(%p)->(%p)\n", This
, p
);
344 static HRESULT WINAPI
HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement
*iface
,
345 IHTMLTxtRange
**range
)
347 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
348 FIXME("(%p)->(%p)\n", This
, range
);
352 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl
= {
353 HTMLTextAreaElement_QueryInterface
,
354 HTMLTextAreaElement_AddRef
,
355 HTMLTextAreaElement_Release
,
356 HTMLTextAreaElement_GetTypeInfoCount
,
357 HTMLTextAreaElement_GetTypeInfo
,
358 HTMLTextAreaElement_GetIDsOfNames
,
359 HTMLTextAreaElement_Invoke
,
360 HTMLTextAreaElement_get_type
,
361 HTMLTextAreaElement_put_value
,
362 HTMLTextAreaElement_get_value
,
363 HTMLTextAreaElement_put_name
,
364 HTMLTextAreaElement_get_name
,
365 HTMLTextAreaElement_put_status
,
366 HTMLTextAreaElement_get_status
,
367 HTMLTextAreaElement_put_disabled
,
368 HTMLTextAreaElement_get_disabled
,
369 HTMLTextAreaElement_get_form
,
370 HTMLTextAreaElement_put_defaultValue
,
371 HTMLTextAreaElement_get_defaultValue
,
372 HTMLTextAreaElement_select
,
373 HTMLTextAreaElement_put_onchange
,
374 HTMLTextAreaElement_get_onchange
,
375 HTMLTextAreaElement_put_onselect
,
376 HTMLTextAreaElement_get_onselect
,
377 HTMLTextAreaElement_put_readOnly
,
378 HTMLTextAreaElement_get_readOnly
,
379 HTMLTextAreaElement_put_rows
,
380 HTMLTextAreaElement_get_rows
,
381 HTMLTextAreaElement_put_cols
,
382 HTMLTextAreaElement_get_cols
,
383 HTMLTextAreaElement_put_wrap
,
384 HTMLTextAreaElement_get_wrap
,
385 HTMLTextAreaElement_createTextRange
388 static inline HTMLTextAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
390 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, element
.node
);
393 static HRESULT
HTMLTextAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
395 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
399 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
400 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
401 *ppv
= &This
->IHTMLTextAreaElement_iface
;
402 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
403 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
404 *ppv
= &This
->IHTMLTextAreaElement_iface
;
405 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement
, riid
)) {
406 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This
, ppv
);
407 *ppv
= &This
->IHTMLTextAreaElement_iface
;
411 IUnknown_AddRef((IUnknown
*)*ppv
);
415 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
418 static HRESULT
HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
420 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
421 return IHTMLTextAreaElement_put_disabled(&This
->IHTMLTextAreaElement_iface
, v
);
424 static HRESULT
HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
426 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
427 return IHTMLTextAreaElement_get_disabled(&This
->IHTMLTextAreaElement_iface
, p
);
430 static BOOL
HTMLTextAreaElement_is_text_edit(HTMLDOMNode
*iface
)
435 static void HTMLTextAreaElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
437 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
440 note_cc_edge((nsISupports
*)This
->nstextarea
, "This->nstextarea", cb
);
443 static void HTMLTextAreaElement_unlink(HTMLDOMNode
*iface
)
445 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
446 unlink_ref(&This
->nstextarea
);
449 static const NodeImplVtbl HTMLTextAreaElementImplVtbl
= {
450 .clsid
= &CLSID_HTMLTextAreaElement
,
451 .qi
= HTMLTextAreaElement_QI
,
452 .destructor
= HTMLElement_destructor
,
453 .cpc_entries
= HTMLElement_cpc
,
454 .clone
= HTMLElement_clone
,
455 .handle_event
= HTMLElement_handle_event
,
456 .get_attr_col
= HTMLElement_get_attr_col
,
457 .put_disabled
= HTMLTextAreaElementImpl_put_disabled
,
458 .get_disabled
= HTMLTextAreaElementImpl_get_disabled
,
459 .traverse
= HTMLTextAreaElement_traverse
,
460 .unlink
= HTMLTextAreaElement_unlink
,
461 .is_text_edit
= HTMLTextAreaElement_is_text_edit
464 static const tid_t HTMLTextAreaElement_iface_tids
[] = {
466 IHTMLTextAreaElement_tid
,
470 static dispex_static_data_t HTMLTextAreaElement_dispex
= {
471 "HTMLTextAreaElement",
472 &HTMLElement_event_target_vtbl
.dispex_vtbl
,
473 DispHTMLTextAreaElement_tid
,
474 HTMLTextAreaElement_iface_tids
,
475 HTMLElement_init_dispex_info
478 HRESULT
HTMLTextAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
480 HTMLTextAreaElement
*ret
;
483 ret
= calloc(1, sizeof(HTMLTextAreaElement
));
485 return E_OUTOFMEMORY
;
487 ret
->IHTMLTextAreaElement_iface
.lpVtbl
= &HTMLTextAreaElementVtbl
;
488 ret
->element
.node
.vtbl
= &HTMLTextAreaElementImplVtbl
;
490 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTextAreaElement_dispex
);
492 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTextAreaElement
, (void**)&ret
->nstextarea
);
493 assert(nsres
== NS_OK
);
495 *elem
= &ret
->element
;