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 const IHTMLTextAreaElementVtbl *lpHTMLTextAreaElementVtbl;
39 nsIDOMHTMLTextAreaElement *nstextarea;
40 } HTMLTextAreaElement;
42 #define HTMLTXTAREA(x) ((IHTMLTextAreaElement*) &(x)->lpHTMLTextAreaElementVtbl)
44 #define HTMLTXTAREA_THIS(iface) DEFINE_THIS(HTMLTextAreaElement, HTMLTextAreaElement, iface)
46 static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *iface,
47 REFIID riid, void **ppv)
49 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
56 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 static ULONG WINAPI HTMLTextAreaElement_Release(IHTMLTextAreaElement *iface)
63 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement *iface, UINT *pctinfo)
70 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
71 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
74 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfo(IHTMLTextAreaElement *iface, UINT iTInfo,
75 LCID lcid, ITypeInfo **ppTInfo)
77 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
78 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
81 static HRESULT WINAPI HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement *iface, REFIID riid,
82 LPOLESTR *rgszNames, UINT cNames,
83 LCID lcid, DISPID *rgDispId)
85 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
86 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLTextAreaElement_Invoke(IHTMLTextAreaElement *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
94 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
95 pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLTextAreaElement_get_type(IHTMLTextAreaElement *iface, BSTR *p)
100 static const WCHAR textareaW[] = {'t','e','x','t','a','r','e','a',0};
102 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
104 TRACE("(%p)->(%p)\n", This, p);
106 *p = SysAllocString(textareaW);
108 return E_OUTOFMEMORY;
112 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
114 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
118 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
120 nsAString_InitDepend(&value_str, v);
121 nsres = nsIDOMHTMLTextAreaElement_SetValue(This->nstextarea, &value_str);
122 nsAString_Finish(&value_str);
123 if(NS_FAILED(nsres)) {
124 ERR("SetValue failed: %08x\n", nsres);
131 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
133 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
135 const PRUnichar *value;
139 TRACE("(%p)->(%p)\n", This, p);
141 nsAString_Init(&value_str, NULL);
143 nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
144 if(NS_SUCCEEDED(nsres)) {
145 nsAString_GetData(&value_str, &value);
146 *p = *value ? SysAllocString(value) : NULL;
148 ERR("GetValue failed: %08x\n", nsres);
152 nsAString_Finish(&value_str);
156 static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
158 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
159 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
163 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
165 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
167 const PRUnichar *name;
170 TRACE("(%p)->(%p)\n", This, p);
172 nsAString_Init(&name_str, NULL);
174 nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
175 if(NS_SUCCEEDED(nsres)) {
176 nsAString_GetData(&name_str, &name);
177 *p = SysAllocString(name);
179 ERR("GetName failed: %08x\n", nsres);
182 nsAString_Finish(&name_str);
184 TRACE("%s\n", debugstr_w(*p));
188 static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
190 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
191 FIXME("(%p)->()\n", This);
195 static HRESULT WINAPI HTMLTextAreaElement_get_status(IHTMLTextAreaElement *iface, VARIANT *p)
197 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
198 FIXME("(%p)->(%p)\n", This, p);
202 static HRESULT WINAPI HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
204 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
205 FIXME("(%p)->(%x)\n", This, v);
209 static HRESULT WINAPI HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
211 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
212 FIXME("(%p)->(%p)\n", This, p);
216 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
218 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
219 FIXME("(%p)->(%p)\n", This, p);
223 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
225 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
226 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
230 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
232 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
233 FIXME("(%p)->(%p)\n", This, p);
237 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
239 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
240 FIXME("(%p)\n", This);
244 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
246 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
247 FIXME("(%p)->()\n", This);
251 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
253 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
254 FIXME("(%p)->(%p)\n", This, p);
258 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
260 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
261 FIXME("(%p)->()\n", This);
265 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
267 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
268 FIXME("(%p)->(%p)\n", This, p);
272 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
274 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
277 TRACE("(%p)->(%x)\n", This, v);
279 nsres = nsIDOMHTMLTextAreaElement_SetReadOnly(This->nstextarea, v != VARIANT_FALSE);
280 if(NS_FAILED(nsres)) {
281 ERR("SetReadOnly failed: %08x\n", nsres);
288 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
290 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
294 TRACE("(%p)->(%p)\n", This, p);
296 nsres = nsIDOMHTMLTextAreaElement_GetReadOnly(This->nstextarea, &b);
297 if(NS_FAILED(nsres)) {
298 ERR("GetReadOnly failed: %08x\n", nsres);
302 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
306 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, LONG v)
308 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
309 FIXME("(%p)->(%d)\n", This, v);
313 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, LONG *p)
315 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, p);
320 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, LONG v)
322 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
323 FIXME("(%p)->(%d)\n", This, v);
327 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, LONG *p)
329 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
330 FIXME("(%p)->(%p)\n", This, p);
334 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
336 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
337 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
341 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
343 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
344 FIXME("(%p)->(%p)\n", This, p);
348 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
349 IHTMLTxtRange **range)
351 HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
352 FIXME("(%p)->(%p)\n", This, range);
356 #undef HTMLTXTAREA_THIS
358 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
359 HTMLTextAreaElement_QueryInterface,
360 HTMLTextAreaElement_AddRef,
361 HTMLTextAreaElement_Release,
362 HTMLTextAreaElement_GetTypeInfoCount,
363 HTMLTextAreaElement_GetTypeInfo,
364 HTMLTextAreaElement_GetIDsOfNames,
365 HTMLTextAreaElement_Invoke,
366 HTMLTextAreaElement_get_type,
367 HTMLTextAreaElement_put_value,
368 HTMLTextAreaElement_get_value,
369 HTMLTextAreaElement_put_name,
370 HTMLTextAreaElement_get_name,
371 HTMLTextAreaElement_put_status,
372 HTMLTextAreaElement_get_status,
373 HTMLTextAreaElement_put_disabled,
374 HTMLTextAreaElement_get_disabled,
375 HTMLTextAreaElement_get_form,
376 HTMLTextAreaElement_put_defaultValue,
377 HTMLTextAreaElement_get_defaultValue,
378 HTMLTextAreaElement_select,
379 HTMLTextAreaElement_put_onchange,
380 HTMLTextAreaElement_get_onchange,
381 HTMLTextAreaElement_put_onselect,
382 HTMLTextAreaElement_get_onselect,
383 HTMLTextAreaElement_put_readOnly,
384 HTMLTextAreaElement_get_readOnly,
385 HTMLTextAreaElement_put_rows,
386 HTMLTextAreaElement_get_rows,
387 HTMLTextAreaElement_put_cols,
388 HTMLTextAreaElement_get_cols,
389 HTMLTextAreaElement_put_wrap,
390 HTMLTextAreaElement_get_wrap,
391 HTMLTextAreaElement_createTextRange
394 #define HTMLTXTAREA_NODE_THIS(iface) DEFINE_THIS2(HTMLTextAreaElement, element.node, iface)
396 static HRESULT HTMLTextAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
398 HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
402 if(IsEqualGUID(&IID_IUnknown, riid)) {
403 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
404 *ppv = HTMLTXTAREA(This);
405 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
406 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
407 *ppv = HTMLTXTAREA(This);
408 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
409 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
410 *ppv = HTMLTXTAREA(This);
414 IUnknown_AddRef((IUnknown*)*ppv);
418 return HTMLElement_QI(&This->element.node, riid, ppv);
421 static void HTMLTextAreaElement_destructor(HTMLDOMNode *iface)
423 HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
425 nsIDOMHTMLTextAreaElement_Release(This->nstextarea);
427 HTMLElement_destructor(&This->element.node);
430 static HRESULT HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
432 HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
433 return IHTMLTextAreaElement_put_disabled(HTMLTXTAREA(This), v);
436 static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
438 HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
439 return IHTMLTextAreaElement_get_disabled(HTMLTXTAREA(This), p);
442 #undef HTMLTXTAREA_NODE_THIS
444 static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
445 HTMLTextAreaElement_QI,
446 HTMLTextAreaElement_destructor,
450 HTMLTextAreaElementImpl_put_disabled,
451 HTMLTextAreaElementImpl_get_disabled
454 static const tid_t HTMLTextAreaElement_iface_tids[] = {
456 IHTMLTextAreaElement_tid,
460 static dispex_static_data_t HTMLTextAreaElement_dispex = {
462 DispHTMLTextAreaElement_tid,
464 HTMLTextAreaElement_iface_tids
467 HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
469 HTMLTextAreaElement *ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
472 ret->lpHTMLTextAreaElementVtbl = &HTMLTextAreaElementVtbl;
473 ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
475 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex);
477 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement,
478 (void**)&ret->nstextarea);
480 ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres);
482 return &ret->element;