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
29 #include "wine/debug.h"
31 #include "mshtml_private.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 static const WCHAR textareaW
[] = {'t','e','x','t','a','r','e','a',0};
106 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
108 TRACE("(%p)->(%p)\n", This
, p
);
110 *p
= SysAllocString(textareaW
);
112 return E_OUTOFMEMORY
;
116 static HRESULT WINAPI
HTMLTextAreaElement_put_value(IHTMLTextAreaElement
*iface
, BSTR v
)
118 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
122 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
124 nsAString_InitDepend(&value_str
, v
);
125 nsres
= nsIDOMHTMLTextAreaElement_SetValue(This
->nstextarea
, &value_str
);
126 nsAString_Finish(&value_str
);
127 if(NS_FAILED(nsres
)) {
128 ERR("SetValue failed: %08x\n", nsres
);
135 static HRESULT WINAPI
HTMLTextAreaElement_get_value(IHTMLTextAreaElement
*iface
, BSTR
*p
)
137 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
141 TRACE("(%p)->(%p)\n", This
, p
);
143 nsAString_Init(&value_str
, NULL
);
144 nsres
= nsIDOMHTMLTextAreaElement_GetValue(This
->nstextarea
, &value_str
);
145 return return_nsstr(nsres
, &value_str
, p
);
148 static HRESULT WINAPI
HTMLTextAreaElement_put_name(IHTMLTextAreaElement
*iface
, BSTR v
)
150 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
151 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
155 static HRESULT WINAPI
HTMLTextAreaElement_get_name(IHTMLTextAreaElement
*iface
, BSTR
*p
)
157 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
161 TRACE("(%p)->(%p)\n", This
, p
);
163 nsAString_Init(&name_str
, NULL
);
164 nsres
= nsIDOMHTMLTextAreaElement_GetName(This
->nstextarea
, &name_str
);
165 return return_nsstr(nsres
, &name_str
, p
);
168 static HRESULT WINAPI
HTMLTextAreaElement_put_status(IHTMLTextAreaElement
*iface
, VARIANT v
)
170 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
171 FIXME("(%p)->()\n", This
);
175 static HRESULT WINAPI
HTMLTextAreaElement_get_status(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
177 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
178 FIXME("(%p)->(%p)\n", This
, p
);
182 static HRESULT WINAPI
HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
184 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
185 FIXME("(%p)->(%x)\n", This
, v
);
189 static HRESULT WINAPI
HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
191 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
192 FIXME("(%p)->(%p)\n", This
, p
);
196 static HRESULT WINAPI
HTMLTextAreaElement_get_form(IHTMLTextAreaElement
*iface
, IHTMLFormElement
**p
)
198 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
199 nsIDOMHTMLFormElement
*nsform
;
202 TRACE("(%p)->(%p)\n", This
, p
);
204 nsres
= nsIDOMHTMLTextAreaElement_GetForm(This
->nstextarea
, &nsform
);
205 return return_nsform(nsres
, nsform
, p
);
208 static HRESULT WINAPI
HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement
*iface
, BSTR v
)
210 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
214 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
216 nsAString_InitDepend(&nsstr
, v
);
217 nsres
= nsIDOMHTMLTextAreaElement_SetDefaultValue(This
->nstextarea
, &nsstr
);
218 nsAString_Finish(&nsstr
);
219 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
222 static HRESULT WINAPI
HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement
*iface
, BSTR
*p
)
224 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
228 TRACE("(%p)->(%p)\n", This
, p
);
230 nsAString_Init(&nsstr
, NULL
);
231 nsres
= nsIDOMHTMLTextAreaElement_GetDefaultValue(This
->nstextarea
, &nsstr
);
232 return return_nsstr(nsres
, &nsstr
, p
);
235 static HRESULT WINAPI
HTMLTextAreaElement_select(IHTMLTextAreaElement
*iface
)
237 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
238 FIXME("(%p)\n", This
);
242 static HRESULT WINAPI
HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement
*iface
, VARIANT v
)
244 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
245 FIXME("(%p)->()\n", This
);
249 static HRESULT WINAPI
HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
251 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
252 FIXME("(%p)->(%p)\n", This
, p
);
256 static HRESULT WINAPI
HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement
*iface
, VARIANT v
)
258 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
259 FIXME("(%p)->()\n", This
);
263 static HRESULT WINAPI
HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
265 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
266 FIXME("(%p)->(%p)\n", This
, p
);
270 static HRESULT WINAPI
HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
272 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
275 TRACE("(%p)->(%x)\n", This
, v
);
277 nsres
= nsIDOMHTMLTextAreaElement_SetReadOnly(This
->nstextarea
, v
!= VARIANT_FALSE
);
278 if(NS_FAILED(nsres
)) {
279 ERR("SetReadOnly failed: %08x\n", nsres
);
286 static HRESULT WINAPI
HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
288 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
292 TRACE("(%p)->(%p)\n", This
, p
);
294 nsres
= nsIDOMHTMLTextAreaElement_GetReadOnly(This
->nstextarea
, &b
);
295 if(NS_FAILED(nsres
)) {
296 ERR("GetReadOnly failed: %08x\n", nsres
);
300 *p
= variant_bool(b
);
304 static HRESULT WINAPI
HTMLTextAreaElement_put_rows(IHTMLTextAreaElement
*iface
, LONG v
)
306 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
307 FIXME("(%p)->(%d)\n", This
, v
);
311 static HRESULT WINAPI
HTMLTextAreaElement_get_rows(IHTMLTextAreaElement
*iface
, LONG
*p
)
313 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
314 FIXME("(%p)->(%p)\n", This
, p
);
318 static HRESULT WINAPI
HTMLTextAreaElement_put_cols(IHTMLTextAreaElement
*iface
, LONG v
)
320 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
321 FIXME("(%p)->(%d)\n", This
, v
);
325 static HRESULT WINAPI
HTMLTextAreaElement_get_cols(IHTMLTextAreaElement
*iface
, LONG
*p
)
327 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
328 FIXME("(%p)->(%p)\n", This
, p
);
332 static HRESULT WINAPI
HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement
*iface
, BSTR v
)
334 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
335 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
339 static HRESULT WINAPI
HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement
*iface
, BSTR
*p
)
341 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
342 FIXME("(%p)->(%p)\n", This
, p
);
346 static HRESULT WINAPI
HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement
*iface
,
347 IHTMLTxtRange
**range
)
349 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
350 FIXME("(%p)->(%p)\n", This
, range
);
354 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl
= {
355 HTMLTextAreaElement_QueryInterface
,
356 HTMLTextAreaElement_AddRef
,
357 HTMLTextAreaElement_Release
,
358 HTMLTextAreaElement_GetTypeInfoCount
,
359 HTMLTextAreaElement_GetTypeInfo
,
360 HTMLTextAreaElement_GetIDsOfNames
,
361 HTMLTextAreaElement_Invoke
,
362 HTMLTextAreaElement_get_type
,
363 HTMLTextAreaElement_put_value
,
364 HTMLTextAreaElement_get_value
,
365 HTMLTextAreaElement_put_name
,
366 HTMLTextAreaElement_get_name
,
367 HTMLTextAreaElement_put_status
,
368 HTMLTextAreaElement_get_status
,
369 HTMLTextAreaElement_put_disabled
,
370 HTMLTextAreaElement_get_disabled
,
371 HTMLTextAreaElement_get_form
,
372 HTMLTextAreaElement_put_defaultValue
,
373 HTMLTextAreaElement_get_defaultValue
,
374 HTMLTextAreaElement_select
,
375 HTMLTextAreaElement_put_onchange
,
376 HTMLTextAreaElement_get_onchange
,
377 HTMLTextAreaElement_put_onselect
,
378 HTMLTextAreaElement_get_onselect
,
379 HTMLTextAreaElement_put_readOnly
,
380 HTMLTextAreaElement_get_readOnly
,
381 HTMLTextAreaElement_put_rows
,
382 HTMLTextAreaElement_get_rows
,
383 HTMLTextAreaElement_put_cols
,
384 HTMLTextAreaElement_get_cols
,
385 HTMLTextAreaElement_put_wrap
,
386 HTMLTextAreaElement_get_wrap
,
387 HTMLTextAreaElement_createTextRange
390 static inline HTMLTextAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
392 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, element
.node
);
395 static HRESULT
HTMLTextAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
397 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
401 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
402 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
403 *ppv
= &This
->IHTMLTextAreaElement_iface
;
404 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
405 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
406 *ppv
= &This
->IHTMLTextAreaElement_iface
;
407 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement
, riid
)) {
408 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This
, ppv
);
409 *ppv
= &This
->IHTMLTextAreaElement_iface
;
413 IUnknown_AddRef((IUnknown
*)*ppv
);
417 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
420 static HRESULT
HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
422 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
423 return IHTMLTextAreaElement_put_disabled(&This
->IHTMLTextAreaElement_iface
, v
);
426 static HRESULT
HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
428 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
429 return IHTMLTextAreaElement_get_disabled(&This
->IHTMLTextAreaElement_iface
, p
);
432 static BOOL
HTMLTextAreaElement_is_text_edit(HTMLDOMNode
*iface
)
437 static void HTMLTextAreaElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
439 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
442 note_cc_edge((nsISupports
*)This
->nstextarea
, "This->nstextarea", cb
);
445 static void HTMLTextAreaElement_unlink(HTMLDOMNode
*iface
)
447 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
449 if(This
->nstextarea
) {
450 nsIDOMHTMLTextAreaElement
*nstextarea
= This
->nstextarea
;
452 This
->nstextarea
= NULL
;
453 nsIDOMHTMLTextAreaElement_Release(nstextarea
);
457 static const NodeImplVtbl HTMLTextAreaElementImplVtbl
= {
458 &CLSID_HTMLTextAreaElement
,
459 HTMLTextAreaElement_QI
,
460 HTMLElement_destructor
,
463 HTMLElement_handle_event
,
464 HTMLElement_get_attr_col
,
466 HTMLTextAreaElementImpl_put_disabled
,
467 HTMLTextAreaElementImpl_get_disabled
,
473 HTMLTextAreaElement_traverse
,
474 HTMLTextAreaElement_unlink
,
475 HTMLTextAreaElement_is_text_edit
478 static const tid_t HTMLTextAreaElement_iface_tids
[] = {
480 IHTMLTextAreaElement_tid
,
484 static dispex_static_data_t HTMLTextAreaElement_dispex
= {
486 DispHTMLTextAreaElement_tid
,
487 HTMLTextAreaElement_iface_tids
,
488 HTMLElement_init_dispex_info
491 HRESULT
HTMLTextAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
493 HTMLTextAreaElement
*ret
;
496 ret
= heap_alloc_zero(sizeof(HTMLTextAreaElement
));
498 return E_OUTOFMEMORY
;
500 ret
->IHTMLTextAreaElement_iface
.lpVtbl
= &HTMLTextAreaElementVtbl
;
501 ret
->element
.node
.vtbl
= &HTMLTextAreaElementImplVtbl
;
503 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTextAreaElement_dispex
);
505 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTextAreaElement
, (void**)&ret
->nstextarea
);
506 assert(nsres
== NS_OK
);
508 *elem
= &ret
->element
;