msxml3/tests: Added invalid host XHR tests.
[wine.git] / dlls / mshtml / htmltextarea.c
blobcaf5d85f7495c0612ba12ba639463899dc018bb0
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 struct HTMLTextAreaElement {
36 HTMLElement element;
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,
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 nsresult nsres;
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);
211 nsAString nsstr;
212 nsresult nsres;
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);
225 nsAString nsstr;
226 nsresult nsres;
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);
239 return E_NOTIMPL;
242 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
244 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
245 FIXME("(%p)->()\n", This);
246 return E_NOTIMPL;
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);
253 return E_NOTIMPL;
256 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
258 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
259 FIXME("(%p)->()\n", This);
260 return E_NOTIMPL;
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);
267 return E_NOTIMPL;
270 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
272 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
273 nsresult nsres;
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);
280 return E_FAIL;
283 return S_OK;
286 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
288 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
289 cpp_bool b;
290 nsresult nsres;
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);
297 return E_FAIL;
300 *p = variant_bool(b);
301 return S_OK;
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);
308 return E_NOTIMPL;
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);
315 return E_NOTIMPL;
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);
322 return E_NOTIMPL;
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);
329 return E_NOTIMPL;
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));
336 return E_NOTIMPL;
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);
343 return E_NOTIMPL;
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);
351 return E_NOTIMPL;
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);
399 *ppv = NULL;
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;
412 if(*ppv) {
413 IUnknown_AddRef((IUnknown*)*ppv);
414 return S_OK;
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)
434 return TRUE;
437 static void HTMLTextAreaElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
439 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
441 if(This->nstextarea)
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,
461 HTMLElement_cpc,
462 HTMLElement_clone,
463 HTMLElement_handle_event,
464 HTMLElement_get_attr_col,
465 NULL,
466 HTMLTextAreaElementImpl_put_disabled,
467 HTMLTextAreaElementImpl_get_disabled,
468 NULL,
469 NULL,
470 NULL,
471 NULL,
472 NULL,
473 HTMLTextAreaElement_traverse,
474 HTMLTextAreaElement_unlink,
475 HTMLTextAreaElement_is_text_edit
478 static const tid_t HTMLTextAreaElement_iface_tids[] = {
479 HTMLELEMENT_TIDS,
480 IHTMLTextAreaElement_tid,
484 static dispex_static_data_t HTMLTextAreaElement_dispex = {
485 NULL,
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;
494 nsresult nsres;
496 ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
497 if(!ret)
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;
509 return S_OK;