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
);
38 IHTMLTextAreaElement IHTMLTextAreaElement_iface
;
40 nsIDOMHTMLTextAreaElement
*nstextarea
;
41 } HTMLTextAreaElement
;
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
.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
.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
.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
.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
;
205 TRACE("(%p)->(%p)\n", This
, p
);
207 nsres
= nsIDOMHTMLTextAreaElement_GetForm(This
->nstextarea
, &nsform
);
208 assert(nsres
== NS_OK
);
215 nsres
= nsIDOMHTMLFormElement_QueryInterface(nsform
, &IID_nsIDOMNode
, (void**)&nsnode
);
216 nsIDOMHTMLFormElement_Release(nsform
);
217 assert(nsres
== NS_OK
);
219 hres
= get_node(This
->element
.node
.doc
, nsnode
, TRUE
, &node
);
220 nsIDOMNode_Release(nsnode
);
224 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
, &IID_IHTMLFormElement
, (void**)p
);
225 IHTMLDOMNode_Release(&node
->IHTMLDOMNode_iface
);
229 static HRESULT WINAPI
HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement
*iface
, BSTR v
)
231 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
232 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
236 static HRESULT WINAPI
HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement
*iface
, BSTR
*p
)
238 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
239 FIXME("(%p)->(%p)\n", This
, p
);
243 static HRESULT WINAPI
HTMLTextAreaElement_select(IHTMLTextAreaElement
*iface
)
245 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
246 FIXME("(%p)\n", This
);
250 static HRESULT WINAPI
HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement
*iface
, VARIANT v
)
252 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
253 FIXME("(%p)->()\n", This
);
257 static HRESULT WINAPI
HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
259 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
260 FIXME("(%p)->(%p)\n", This
, p
);
264 static HRESULT WINAPI
HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement
*iface
, VARIANT v
)
266 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
267 FIXME("(%p)->()\n", This
);
271 static HRESULT WINAPI
HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
273 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
280 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
283 TRACE("(%p)->(%x)\n", This
, v
);
285 nsres
= nsIDOMHTMLTextAreaElement_SetReadOnly(This
->nstextarea
, v
!= VARIANT_FALSE
);
286 if(NS_FAILED(nsres
)) {
287 ERR("SetReadOnly failed: %08x\n", nsres
);
294 static HRESULT WINAPI
HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
296 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
300 TRACE("(%p)->(%p)\n", This
, p
);
302 nsres
= nsIDOMHTMLTextAreaElement_GetReadOnly(This
->nstextarea
, &b
);
303 if(NS_FAILED(nsres
)) {
304 ERR("GetReadOnly failed: %08x\n", nsres
);
308 *p
= b
? VARIANT_TRUE
: VARIANT_FALSE
;
312 static HRESULT WINAPI
HTMLTextAreaElement_put_rows(IHTMLTextAreaElement
*iface
, LONG v
)
314 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
315 FIXME("(%p)->(%d)\n", This
, v
);
319 static HRESULT WINAPI
HTMLTextAreaElement_get_rows(IHTMLTextAreaElement
*iface
, LONG
*p
)
321 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
322 FIXME("(%p)->(%p)\n", This
, p
);
326 static HRESULT WINAPI
HTMLTextAreaElement_put_cols(IHTMLTextAreaElement
*iface
, LONG v
)
328 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
329 FIXME("(%p)->(%d)\n", This
, v
);
333 static HRESULT WINAPI
HTMLTextAreaElement_get_cols(IHTMLTextAreaElement
*iface
, LONG
*p
)
335 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
336 FIXME("(%p)->(%p)\n", This
, p
);
340 static HRESULT WINAPI
HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement
*iface
, BSTR v
)
342 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
343 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
347 static HRESULT WINAPI
HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement
*iface
, BSTR
*p
)
349 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
350 FIXME("(%p)->(%p)\n", This
, p
);
354 static HRESULT WINAPI
HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement
*iface
,
355 IHTMLTxtRange
**range
)
357 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
358 FIXME("(%p)->(%p)\n", This
, range
);
362 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl
= {
363 HTMLTextAreaElement_QueryInterface
,
364 HTMLTextAreaElement_AddRef
,
365 HTMLTextAreaElement_Release
,
366 HTMLTextAreaElement_GetTypeInfoCount
,
367 HTMLTextAreaElement_GetTypeInfo
,
368 HTMLTextAreaElement_GetIDsOfNames
,
369 HTMLTextAreaElement_Invoke
,
370 HTMLTextAreaElement_get_type
,
371 HTMLTextAreaElement_put_value
,
372 HTMLTextAreaElement_get_value
,
373 HTMLTextAreaElement_put_name
,
374 HTMLTextAreaElement_get_name
,
375 HTMLTextAreaElement_put_status
,
376 HTMLTextAreaElement_get_status
,
377 HTMLTextAreaElement_put_disabled
,
378 HTMLTextAreaElement_get_disabled
,
379 HTMLTextAreaElement_get_form
,
380 HTMLTextAreaElement_put_defaultValue
,
381 HTMLTextAreaElement_get_defaultValue
,
382 HTMLTextAreaElement_select
,
383 HTMLTextAreaElement_put_onchange
,
384 HTMLTextAreaElement_get_onchange
,
385 HTMLTextAreaElement_put_onselect
,
386 HTMLTextAreaElement_get_onselect
,
387 HTMLTextAreaElement_put_readOnly
,
388 HTMLTextAreaElement_get_readOnly
,
389 HTMLTextAreaElement_put_rows
,
390 HTMLTextAreaElement_get_rows
,
391 HTMLTextAreaElement_put_cols
,
392 HTMLTextAreaElement_get_cols
,
393 HTMLTextAreaElement_put_wrap
,
394 HTMLTextAreaElement_get_wrap
,
395 HTMLTextAreaElement_createTextRange
398 static inline HTMLTextAreaElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
400 return CONTAINING_RECORD(iface
, HTMLTextAreaElement
, element
.node
);
403 static HRESULT
HTMLTextAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
405 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
409 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
410 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
411 *ppv
= &This
->IHTMLTextAreaElement_iface
;
412 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
413 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
414 *ppv
= &This
->IHTMLTextAreaElement_iface
;
415 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement
, riid
)) {
416 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This
, ppv
);
417 *ppv
= &This
->IHTMLTextAreaElement_iface
;
421 IUnknown_AddRef((IUnknown
*)*ppv
);
425 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
428 static HRESULT
HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
430 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
431 return IHTMLTextAreaElement_put_disabled(&This
->IHTMLTextAreaElement_iface
, v
);
434 static HRESULT
HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
436 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
437 return IHTMLTextAreaElement_get_disabled(&This
->IHTMLTextAreaElement_iface
, p
);
440 static void HTMLTextAreaElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
442 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
445 note_cc_edge((nsISupports
*)This
->nstextarea
, "This->nstextarea", cb
);
448 static void HTMLTextAreaElement_unlink(HTMLDOMNode
*iface
)
450 HTMLTextAreaElement
*This
= impl_from_HTMLDOMNode(iface
);
452 if(This
->nstextarea
) {
453 nsIDOMHTMLTextAreaElement
*nstextarea
= This
->nstextarea
;
455 This
->nstextarea
= NULL
;
456 nsIDOMHTMLTextAreaElement_Release(nstextarea
);
460 static const NodeImplVtbl HTMLTextAreaElementImplVtbl
= {
461 HTMLTextAreaElement_QI
,
462 HTMLElement_destructor
,
465 HTMLElement_handle_event
,
466 HTMLElement_get_attr_col
,
469 HTMLTextAreaElementImpl_put_disabled
,
470 HTMLTextAreaElementImpl_get_disabled
,
476 HTMLTextAreaElement_traverse
,
477 HTMLTextAreaElement_unlink
480 static const tid_t HTMLTextAreaElement_iface_tids
[] = {
482 IHTMLTextAreaElement_tid
,
486 static dispex_static_data_t HTMLTextAreaElement_dispex
= {
488 DispHTMLTextAreaElement_tid
,
490 HTMLTextAreaElement_iface_tids
493 HRESULT
HTMLTextAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
495 HTMLTextAreaElement
*ret
;
498 ret
= heap_alloc_zero(sizeof(HTMLTextAreaElement
));
500 return E_OUTOFMEMORY
;
502 ret
->IHTMLTextAreaElement_iface
.lpVtbl
= &HTMLTextAreaElementVtbl
;
503 ret
->element
.node
.vtbl
= &HTMLTextAreaElementImplVtbl
;
505 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTextAreaElement_dispex
);
507 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTextAreaElement
, (void**)&ret
->nstextarea
);
508 assert(nsres
== NS_OK
);
510 *elem
= &ret
->element
;