d3d9/tests: Add test for regression in IDirect3DDevice9_Reset().
[wine.git] / dlls / mshtml / htmltextarea.c
blobe46481983a47dd3bf1f62108c4f771822f4b8e91
1 /*
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
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 typedef struct {
36 HTMLElement element;
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.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,
81 ppTInfo);
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);
111 if(!*p)
112 return E_OUTOFMEMORY;
113 return S_OK;
116 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
118 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
119 nsAString value_str;
120 nsresult nsres;
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);
129 return E_FAIL;
132 return S_OK;
135 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
137 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
138 nsAString value_str;
139 nsresult nsres;
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));
152 return E_NOTIMPL;
155 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
157 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
158 nsAString name_str;
159 nsresult nsres;
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);
172 return E_NOTIMPL;
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);
179 return E_NOTIMPL;
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);
186 return E_NOTIMPL;
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);
193 return E_NOTIMPL;
196 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
198 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
199 nsIDOMHTMLFormElement *nsform;
200 nsIDOMNode *nsnode;
201 HTMLDOMNode *node;
202 nsresult nsres;
203 HRESULT hres;
205 TRACE("(%p)->(%p)\n", This, p);
207 nsres = nsIDOMHTMLTextAreaElement_GetForm(This->nstextarea, &nsform);
208 assert(nsres == NS_OK);
210 if(!nsform) {
211 *p = NULL;
212 return S_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);
221 if(FAILED(hres))
222 return hres;
224 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLFormElement, (void**)p);
225 IHTMLDOMNode_Release(&node->IHTMLDOMNode_iface);
226 return hres;
229 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
231 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
232 nsAString nsstr;
233 nsresult nsres;
235 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
237 nsAString_InitDepend(&nsstr, v);
238 nsres = nsIDOMHTMLTextAreaElement_SetDefaultValue(This->nstextarea, &nsstr);
239 nsAString_Finish(&nsstr);
240 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
243 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
245 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
246 nsAString nsstr;
247 nsresult nsres;
249 TRACE("(%p)->(%p)\n", This, p);
251 nsAString_Init(&nsstr, NULL);
252 nsres = nsIDOMHTMLTextAreaElement_GetDefaultValue(This->nstextarea, &nsstr);
253 return return_nsstr(nsres, &nsstr, p);
256 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
258 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
259 FIXME("(%p)\n", This);
260 return E_NOTIMPL;
263 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
265 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
266 FIXME("(%p)->()\n", This);
267 return E_NOTIMPL;
270 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
272 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
273 FIXME("(%p)->(%p)\n", This, p);
274 return E_NOTIMPL;
277 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
279 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
280 FIXME("(%p)->()\n", This);
281 return E_NOTIMPL;
284 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
286 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
287 FIXME("(%p)->(%p)\n", This, p);
288 return E_NOTIMPL;
291 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
293 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
294 nsresult nsres;
296 TRACE("(%p)->(%x)\n", This, v);
298 nsres = nsIDOMHTMLTextAreaElement_SetReadOnly(This->nstextarea, v != VARIANT_FALSE);
299 if(NS_FAILED(nsres)) {
300 ERR("SetReadOnly failed: %08x\n", nsres);
301 return E_FAIL;
304 return S_OK;
307 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
309 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
310 cpp_bool b;
311 nsresult nsres;
313 TRACE("(%p)->(%p)\n", This, p);
315 nsres = nsIDOMHTMLTextAreaElement_GetReadOnly(This->nstextarea, &b);
316 if(NS_FAILED(nsres)) {
317 ERR("GetReadOnly failed: %08x\n", nsres);
318 return E_FAIL;
321 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
322 return S_OK;
325 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, LONG v)
327 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
328 FIXME("(%p)->(%d)\n", This, v);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, LONG *p)
334 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
335 FIXME("(%p)->(%p)\n", This, p);
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, LONG v)
341 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
342 FIXME("(%p)->(%d)\n", This, v);
343 return E_NOTIMPL;
346 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, LONG *p)
348 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
349 FIXME("(%p)->(%p)\n", This, p);
350 return E_NOTIMPL;
353 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
355 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
356 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
357 return E_NOTIMPL;
360 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
362 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
363 FIXME("(%p)->(%p)\n", This, p);
364 return E_NOTIMPL;
367 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
368 IHTMLTxtRange **range)
370 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
371 FIXME("(%p)->(%p)\n", This, range);
372 return E_NOTIMPL;
375 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
376 HTMLTextAreaElement_QueryInterface,
377 HTMLTextAreaElement_AddRef,
378 HTMLTextAreaElement_Release,
379 HTMLTextAreaElement_GetTypeInfoCount,
380 HTMLTextAreaElement_GetTypeInfo,
381 HTMLTextAreaElement_GetIDsOfNames,
382 HTMLTextAreaElement_Invoke,
383 HTMLTextAreaElement_get_type,
384 HTMLTextAreaElement_put_value,
385 HTMLTextAreaElement_get_value,
386 HTMLTextAreaElement_put_name,
387 HTMLTextAreaElement_get_name,
388 HTMLTextAreaElement_put_status,
389 HTMLTextAreaElement_get_status,
390 HTMLTextAreaElement_put_disabled,
391 HTMLTextAreaElement_get_disabled,
392 HTMLTextAreaElement_get_form,
393 HTMLTextAreaElement_put_defaultValue,
394 HTMLTextAreaElement_get_defaultValue,
395 HTMLTextAreaElement_select,
396 HTMLTextAreaElement_put_onchange,
397 HTMLTextAreaElement_get_onchange,
398 HTMLTextAreaElement_put_onselect,
399 HTMLTextAreaElement_get_onselect,
400 HTMLTextAreaElement_put_readOnly,
401 HTMLTextAreaElement_get_readOnly,
402 HTMLTextAreaElement_put_rows,
403 HTMLTextAreaElement_get_rows,
404 HTMLTextAreaElement_put_cols,
405 HTMLTextAreaElement_get_cols,
406 HTMLTextAreaElement_put_wrap,
407 HTMLTextAreaElement_get_wrap,
408 HTMLTextAreaElement_createTextRange
411 static inline HTMLTextAreaElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
413 return CONTAINING_RECORD(iface, HTMLTextAreaElement, element.node);
416 static HRESULT HTMLTextAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
418 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
420 *ppv = NULL;
422 if(IsEqualGUID(&IID_IUnknown, riid)) {
423 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
424 *ppv = &This->IHTMLTextAreaElement_iface;
425 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
426 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
427 *ppv = &This->IHTMLTextAreaElement_iface;
428 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
429 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
430 *ppv = &This->IHTMLTextAreaElement_iface;
433 if(*ppv) {
434 IUnknown_AddRef((IUnknown*)*ppv);
435 return S_OK;
438 return HTMLElement_QI(&This->element.node, riid, ppv);
441 static HRESULT HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
443 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
444 return IHTMLTextAreaElement_put_disabled(&This->IHTMLTextAreaElement_iface, v);
447 static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
449 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
450 return IHTMLTextAreaElement_get_disabled(&This->IHTMLTextAreaElement_iface, p);
453 static BOOL HTMLTextAreaElement_is_text_edit(HTMLDOMNode *iface)
455 return TRUE;
458 static void HTMLTextAreaElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
460 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
462 if(This->nstextarea)
463 note_cc_edge((nsISupports*)This->nstextarea, "This->nstextarea", cb);
466 static void HTMLTextAreaElement_unlink(HTMLDOMNode *iface)
468 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
470 if(This->nstextarea) {
471 nsIDOMHTMLTextAreaElement *nstextarea = This->nstextarea;
473 This->nstextarea = NULL;
474 nsIDOMHTMLTextAreaElement_Release(nstextarea);
478 static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
479 HTMLTextAreaElement_QI,
480 HTMLElement_destructor,
481 HTMLElement_cpc,
482 HTMLElement_clone,
483 HTMLElement_handle_event,
484 HTMLElement_get_attr_col,
485 NULL,
486 NULL,
487 HTMLTextAreaElementImpl_put_disabled,
488 HTMLTextAreaElementImpl_get_disabled,
489 NULL,
490 NULL,
491 NULL,
492 NULL,
493 NULL,
494 HTMLTextAreaElement_traverse,
495 HTMLTextAreaElement_unlink,
496 HTMLTextAreaElement_is_text_edit
499 static const tid_t HTMLTextAreaElement_iface_tids[] = {
500 HTMLELEMENT_TIDS,
501 IHTMLTextAreaElement_tid,
505 static dispex_static_data_t HTMLTextAreaElement_dispex = {
506 NULL,
507 DispHTMLTextAreaElement_tid,
508 HTMLTextAreaElement_iface_tids,
509 HTMLElement_init_dispex_info
512 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
514 HTMLTextAreaElement *ret;
515 nsresult nsres;
517 ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
518 if(!ret)
519 return E_OUTOFMEMORY;
521 ret->IHTMLTextAreaElement_iface.lpVtbl = &HTMLTextAreaElementVtbl;
522 ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
524 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex);
526 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement, (void**)&ret->nstextarea);
527 assert(nsres == NS_OK);
529 *elem = &ret->element;
530 return S_OK;