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(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
55 static ULONG WINAPI
HTMLTextAreaElement_AddRef(IHTMLTextAreaElement
*iface
)
57 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
59 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
62 static ULONG WINAPI
HTMLTextAreaElement_Release(IHTMLTextAreaElement
*iface
)
64 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
66 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
69 static HRESULT WINAPI
HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement
*iface
, UINT
*pctinfo
)
71 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->element
.node
.dispex
), 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(DISPATCHEX(&This
->element
.node
.dispex
), iTInfo
, lcid
, ppTInfo
);
82 static HRESULT WINAPI
HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement
*iface
, REFIID riid
,
83 LPOLESTR
*rgszNames
, UINT cNames
,
84 LCID lcid
, DISPID
*rgDispId
)
86 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
87 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->element
.node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
90 static HRESULT WINAPI
HTMLTextAreaElement_Invoke(IHTMLTextAreaElement
*iface
, DISPID dispIdMember
,
91 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
92 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
94 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
95 return IDispatchEx_Invoke(DISPATCHEX(&This
->element
.node
.dispex
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
96 pVarResult
, pExcepInfo
, puArgErr
);
99 static HRESULT WINAPI
HTMLTextAreaElement_get_type(IHTMLTextAreaElement
*iface
, BSTR
*p
)
101 static const WCHAR textareaW
[] = {'t','e','x','t','a','r','e','a',0};
103 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
105 TRACE("(%p)->(%p)\n", This
, p
);
107 *p
= SysAllocString(textareaW
);
109 return E_OUTOFMEMORY
;
113 static HRESULT WINAPI
HTMLTextAreaElement_put_value(IHTMLTextAreaElement
*iface
, BSTR v
)
115 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
119 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
121 nsAString_InitDepend(&value_str
, v
);
122 nsres
= nsIDOMHTMLTextAreaElement_SetValue(This
->nstextarea
, &value_str
);
123 nsAString_Finish(&value_str
);
124 if(NS_FAILED(nsres
)) {
125 ERR("SetValue failed: %08x\n", nsres
);
132 static HRESULT WINAPI
HTMLTextAreaElement_get_value(IHTMLTextAreaElement
*iface
, BSTR
*p
)
134 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
136 const PRUnichar
*value
;
140 TRACE("(%p)->(%p)\n", This
, p
);
142 nsAString_Init(&value_str
, NULL
);
144 nsres
= nsIDOMHTMLTextAreaElement_GetValue(This
->nstextarea
, &value_str
);
145 if(NS_SUCCEEDED(nsres
)) {
146 nsAString_GetData(&value_str
, &value
);
147 *p
= *value
? SysAllocString(value
) : NULL
;
149 ERR("GetValue failed: %08x\n", nsres
);
153 nsAString_Finish(&value_str
);
157 static HRESULT WINAPI
HTMLTextAreaElement_put_name(IHTMLTextAreaElement
*iface
, BSTR v
)
159 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
160 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
164 static HRESULT WINAPI
HTMLTextAreaElement_get_name(IHTMLTextAreaElement
*iface
, BSTR
*p
)
166 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
168 const PRUnichar
*name
;
171 TRACE("(%p)->(%p)\n", This
, p
);
173 nsAString_Init(&name_str
, NULL
);
175 nsres
= nsIDOMHTMLTextAreaElement_GetName(This
->nstextarea
, &name_str
);
176 if(NS_SUCCEEDED(nsres
)) {
177 nsAString_GetData(&name_str
, &name
);
178 *p
= SysAllocString(name
);
180 ERR("GetName failed: %08x\n", nsres
);
183 nsAString_Finish(&name_str
);
185 TRACE("%s\n", debugstr_w(*p
));
189 static HRESULT WINAPI
HTMLTextAreaElement_put_status(IHTMLTextAreaElement
*iface
, VARIANT v
)
191 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
192 FIXME("(%p)->()\n", This
);
196 static HRESULT WINAPI
HTMLTextAreaElement_get_status(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
198 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
205 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
206 FIXME("(%p)->(%x)\n", This
, v
);
210 static HRESULT WINAPI
HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
212 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
213 FIXME("(%p)->(%p)\n", This
, p
);
217 static HRESULT WINAPI
HTMLTextAreaElement_get_form(IHTMLTextAreaElement
*iface
, IHTMLFormElement
**p
)
219 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
220 FIXME("(%p)->(%p)\n", This
, p
);
224 static HRESULT WINAPI
HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement
*iface
, BSTR v
)
226 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
227 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
231 static HRESULT WINAPI
HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement
*iface
, BSTR
*p
)
233 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
234 FIXME("(%p)->(%p)\n", This
, p
);
238 static HRESULT WINAPI
HTMLTextAreaElement_select(IHTMLTextAreaElement
*iface
)
240 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
241 FIXME("(%p)\n", This
);
245 static HRESULT WINAPI
HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement
*iface
, VARIANT v
)
247 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
248 FIXME("(%p)->()\n", This
);
252 static HRESULT WINAPI
HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
254 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
255 FIXME("(%p)->(%p)\n", This
, p
);
259 static HRESULT WINAPI
HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement
*iface
, VARIANT v
)
261 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
262 FIXME("(%p)->()\n", This
);
266 static HRESULT WINAPI
HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement
*iface
, VARIANT
*p
)
268 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
269 FIXME("(%p)->(%p)\n", This
, p
);
273 static HRESULT WINAPI
HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL v
)
275 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
278 TRACE("(%p)->(%x)\n", This
, v
);
280 nsres
= nsIDOMHTMLTextAreaElement_SetReadOnly(This
->nstextarea
, v
!= VARIANT_FALSE
);
281 if(NS_FAILED(nsres
)) {
282 ERR("SetReadOnly failed: %08x\n", nsres
);
289 static HRESULT WINAPI
HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement
*iface
, VARIANT_BOOL
*p
)
291 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
295 TRACE("(%p)->(%p)\n", This
, p
);
297 nsres
= nsIDOMHTMLTextAreaElement_GetReadOnly(This
->nstextarea
, &b
);
298 if(NS_FAILED(nsres
)) {
299 ERR("GetReadOnly failed: %08x\n", nsres
);
303 *p
= b
? VARIANT_TRUE
: VARIANT_FALSE
;
307 static HRESULT WINAPI
HTMLTextAreaElement_put_rows(IHTMLTextAreaElement
*iface
, LONG v
)
309 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
310 FIXME("(%p)->(%d)\n", This
, v
);
314 static HRESULT WINAPI
HTMLTextAreaElement_get_rows(IHTMLTextAreaElement
*iface
, LONG
*p
)
316 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
317 FIXME("(%p)->(%p)\n", This
, p
);
321 static HRESULT WINAPI
HTMLTextAreaElement_put_cols(IHTMLTextAreaElement
*iface
, LONG v
)
323 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
324 FIXME("(%p)->(%d)\n", This
, v
);
328 static HRESULT WINAPI
HTMLTextAreaElement_get_cols(IHTMLTextAreaElement
*iface
, LONG
*p
)
330 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
331 FIXME("(%p)->(%p)\n", This
, p
);
335 static HRESULT WINAPI
HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement
*iface
, BSTR v
)
337 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
338 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
342 static HRESULT WINAPI
HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement
*iface
, BSTR
*p
)
344 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
345 FIXME("(%p)->(%p)\n", This
, p
);
349 static HRESULT WINAPI
HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement
*iface
,
350 IHTMLTxtRange
**range
)
352 HTMLTextAreaElement
*This
= impl_from_IHTMLTextAreaElement(iface
);
353 FIXME("(%p)->(%p)\n", This
, range
);
357 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl
= {
358 HTMLTextAreaElement_QueryInterface
,
359 HTMLTextAreaElement_AddRef
,
360 HTMLTextAreaElement_Release
,
361 HTMLTextAreaElement_GetTypeInfoCount
,
362 HTMLTextAreaElement_GetTypeInfo
,
363 HTMLTextAreaElement_GetIDsOfNames
,
364 HTMLTextAreaElement_Invoke
,
365 HTMLTextAreaElement_get_type
,
366 HTMLTextAreaElement_put_value
,
367 HTMLTextAreaElement_get_value
,
368 HTMLTextAreaElement_put_name
,
369 HTMLTextAreaElement_get_name
,
370 HTMLTextAreaElement_put_status
,
371 HTMLTextAreaElement_get_status
,
372 HTMLTextAreaElement_put_disabled
,
373 HTMLTextAreaElement_get_disabled
,
374 HTMLTextAreaElement_get_form
,
375 HTMLTextAreaElement_put_defaultValue
,
376 HTMLTextAreaElement_get_defaultValue
,
377 HTMLTextAreaElement_select
,
378 HTMLTextAreaElement_put_onchange
,
379 HTMLTextAreaElement_get_onchange
,
380 HTMLTextAreaElement_put_onselect
,
381 HTMLTextAreaElement_get_onselect
,
382 HTMLTextAreaElement_put_readOnly
,
383 HTMLTextAreaElement_get_readOnly
,
384 HTMLTextAreaElement_put_rows
,
385 HTMLTextAreaElement_get_rows
,
386 HTMLTextAreaElement_put_cols
,
387 HTMLTextAreaElement_get_cols
,
388 HTMLTextAreaElement_put_wrap
,
389 HTMLTextAreaElement_get_wrap
,
390 HTMLTextAreaElement_createTextRange
393 #define HTMLTXTAREA_NODE_THIS(iface) DEFINE_THIS2(HTMLTextAreaElement, element.node, iface)
395 static HRESULT
HTMLTextAreaElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
397 HTMLTextAreaElement
*This
= HTMLTXTAREA_NODE_THIS(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 void HTMLTextAreaElement_destructor(HTMLDOMNode
*iface
)
422 HTMLTextAreaElement
*This
= HTMLTXTAREA_NODE_THIS(iface
);
424 nsIDOMHTMLTextAreaElement_Release(This
->nstextarea
);
426 HTMLElement_destructor(&This
->element
.node
);
429 static HRESULT
HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
431 HTMLTextAreaElement
*This
= HTMLTXTAREA_NODE_THIS(iface
);
432 return IHTMLTextAreaElement_put_disabled(&This
->IHTMLTextAreaElement_iface
, v
);
435 static HRESULT
HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
437 HTMLTextAreaElement
*This
= HTMLTXTAREA_NODE_THIS(iface
);
438 return IHTMLTextAreaElement_get_disabled(&This
->IHTMLTextAreaElement_iface
, p
);
441 #undef HTMLTXTAREA_NODE_THIS
443 static const NodeImplVtbl HTMLTextAreaElementImplVtbl
= {
444 HTMLTextAreaElement_QI
,
445 HTMLTextAreaElement_destructor
,
449 HTMLTextAreaElementImpl_put_disabled
,
450 HTMLTextAreaElementImpl_get_disabled
453 static const tid_t HTMLTextAreaElement_iface_tids
[] = {
455 IHTMLTextAreaElement_tid
,
459 static dispex_static_data_t HTMLTextAreaElement_dispex
= {
461 DispHTMLTextAreaElement_tid
,
463 HTMLTextAreaElement_iface_tids
466 HRESULT
HTMLTextAreaElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
468 HTMLTextAreaElement
*ret
;
471 ret
= heap_alloc_zero(sizeof(HTMLTextAreaElement
));
473 return E_OUTOFMEMORY
;
475 ret
->IHTMLTextAreaElement_iface
.lpVtbl
= &HTMLTextAreaElementVtbl
;
476 ret
->element
.node
.vtbl
= &HTMLTextAreaElementImplVtbl
;
478 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLTextAreaElement
,
479 (void**)&ret
->nstextarea
);
480 if(NS_FAILED(nsres
)) {
481 ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres
);
486 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLTextAreaElement_dispex
);
488 *elem
= &ret
->element
;