ntdll: Connect syscall frames across user callbacks on x86-64.
[wine.git] / dlls / mshtml / htmltextarea.c
blob6964c1c06a055a3ae1c8e7cd06a2f6938e6ec32e
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>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
31 #include "htmlevent.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 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
106 TRACE("(%p)->(%p)\n", This, p);
108 *p = SysAllocString(L"textarea");
109 if(!*p)
110 return E_OUTOFMEMORY;
111 return S_OK;
114 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
116 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
117 nsAString value_str;
118 nsresult nsres;
120 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
122 nsAString_InitDepend(&value_str, v);
123 nsres = nsIDOMHTMLTextAreaElement_SetValue(This->nstextarea, &value_str);
124 nsAString_Finish(&value_str);
125 if(NS_FAILED(nsres)) {
126 ERR("SetValue failed: %08lx\n", nsres);
127 return E_FAIL;
130 return S_OK;
133 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
135 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
136 nsAString value_str;
137 nsresult nsres;
139 TRACE("(%p)->(%p)\n", This, p);
141 nsAString_Init(&value_str, NULL);
142 nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
143 return return_nsstr(nsres, &value_str, p);
146 static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
148 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
149 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
150 return E_NOTIMPL;
153 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
155 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
156 nsAString name_str;
157 nsresult nsres;
159 TRACE("(%p)->(%p)\n", This, p);
161 nsAString_Init(&name_str, NULL);
162 nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
163 return return_nsstr(nsres, &name_str, p);
166 static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
168 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
169 FIXME("(%p)->()\n", This);
170 return E_NOTIMPL;
173 static HRESULT WINAPI HTMLTextAreaElement_get_status(IHTMLTextAreaElement *iface, VARIANT *p)
175 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
176 FIXME("(%p)->(%p)\n", This, p);
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
182 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
183 FIXME("(%p)->(%x)\n", This, v);
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
189 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
190 FIXME("(%p)->(%p)\n", This, p);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
196 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
197 nsIDOMHTMLFormElement *nsform;
198 nsresult nsres;
200 TRACE("(%p)->(%p)\n", This, p);
202 nsres = nsIDOMHTMLTextAreaElement_GetForm(This->nstextarea, &nsform);
203 return return_nsform(nsres, nsform, p);
206 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
208 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
209 nsAString nsstr;
210 nsresult nsres;
212 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
214 nsAString_InitDepend(&nsstr, v);
215 nsres = nsIDOMHTMLTextAreaElement_SetDefaultValue(This->nstextarea, &nsstr);
216 nsAString_Finish(&nsstr);
217 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
220 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
222 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
223 nsAString nsstr;
224 nsresult nsres;
226 TRACE("(%p)->(%p)\n", This, p);
228 nsAString_Init(&nsstr, NULL);
229 nsres = nsIDOMHTMLTextAreaElement_GetDefaultValue(This->nstextarea, &nsstr);
230 return return_nsstr(nsres, &nsstr, p);
233 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
235 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
236 FIXME("(%p)\n", This);
237 return E_NOTIMPL;
240 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
242 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
243 FIXME("(%p)->()\n", This);
244 return E_NOTIMPL;
247 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
249 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
250 FIXME("(%p)->(%p)\n", This, p);
251 return E_NOTIMPL;
254 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
256 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
257 FIXME("(%p)->()\n", This);
258 return E_NOTIMPL;
261 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
263 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
264 FIXME("(%p)->(%p)\n", This, p);
265 return E_NOTIMPL;
268 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
270 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
271 nsresult nsres;
273 TRACE("(%p)->(%x)\n", This, v);
275 nsres = nsIDOMHTMLTextAreaElement_SetReadOnly(This->nstextarea, v != VARIANT_FALSE);
276 if(NS_FAILED(nsres)) {
277 ERR("SetReadOnly failed: %08lx\n", nsres);
278 return E_FAIL;
281 return S_OK;
284 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
286 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
287 cpp_bool b;
288 nsresult nsres;
290 TRACE("(%p)->(%p)\n", This, p);
292 nsres = nsIDOMHTMLTextAreaElement_GetReadOnly(This->nstextarea, &b);
293 if(NS_FAILED(nsres)) {
294 ERR("GetReadOnly failed: %08lx\n", nsres);
295 return E_FAIL;
298 *p = variant_bool(b);
299 return S_OK;
302 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, LONG v)
304 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
305 FIXME("(%p)->(%ld)\n", This, v);
306 return E_NOTIMPL;
309 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, LONG *p)
311 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
312 FIXME("(%p)->(%p)\n", This, p);
313 return E_NOTIMPL;
316 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, LONG v)
318 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
319 FIXME("(%p)->(%ld)\n", This, v);
320 return E_NOTIMPL;
323 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, LONG *p)
325 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
326 FIXME("(%p)->(%p)\n", This, p);
327 return E_NOTIMPL;
330 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
332 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
333 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
334 return E_NOTIMPL;
337 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
339 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
340 FIXME("(%p)->(%p)\n", This, p);
341 return E_NOTIMPL;
344 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
345 IHTMLTxtRange **range)
347 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
348 FIXME("(%p)->(%p)\n", This, range);
349 return E_NOTIMPL;
352 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
353 HTMLTextAreaElement_QueryInterface,
354 HTMLTextAreaElement_AddRef,
355 HTMLTextAreaElement_Release,
356 HTMLTextAreaElement_GetTypeInfoCount,
357 HTMLTextAreaElement_GetTypeInfo,
358 HTMLTextAreaElement_GetIDsOfNames,
359 HTMLTextAreaElement_Invoke,
360 HTMLTextAreaElement_get_type,
361 HTMLTextAreaElement_put_value,
362 HTMLTextAreaElement_get_value,
363 HTMLTextAreaElement_put_name,
364 HTMLTextAreaElement_get_name,
365 HTMLTextAreaElement_put_status,
366 HTMLTextAreaElement_get_status,
367 HTMLTextAreaElement_put_disabled,
368 HTMLTextAreaElement_get_disabled,
369 HTMLTextAreaElement_get_form,
370 HTMLTextAreaElement_put_defaultValue,
371 HTMLTextAreaElement_get_defaultValue,
372 HTMLTextAreaElement_select,
373 HTMLTextAreaElement_put_onchange,
374 HTMLTextAreaElement_get_onchange,
375 HTMLTextAreaElement_put_onselect,
376 HTMLTextAreaElement_get_onselect,
377 HTMLTextAreaElement_put_readOnly,
378 HTMLTextAreaElement_get_readOnly,
379 HTMLTextAreaElement_put_rows,
380 HTMLTextAreaElement_get_rows,
381 HTMLTextAreaElement_put_cols,
382 HTMLTextAreaElement_get_cols,
383 HTMLTextAreaElement_put_wrap,
384 HTMLTextAreaElement_get_wrap,
385 HTMLTextAreaElement_createTextRange
388 static inline HTMLTextAreaElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
390 return CONTAINING_RECORD(iface, HTMLTextAreaElement, element.node);
393 static HRESULT HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
395 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
396 return IHTMLTextAreaElement_put_disabled(&This->IHTMLTextAreaElement_iface, v);
399 static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
401 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
402 return IHTMLTextAreaElement_get_disabled(&This->IHTMLTextAreaElement_iface, p);
405 static BOOL HTMLTextAreaElement_is_text_edit(HTMLDOMNode *iface)
407 return TRUE;
410 static inline HTMLTextAreaElement *impl_from_DispatchEx(DispatchEx *iface)
412 return CONTAINING_RECORD(iface, HTMLTextAreaElement, element.node.event_target.dispex);
415 static void *HTMLTextAreaElement_query_interface(DispatchEx *dispex, REFIID riid)
417 HTMLTextAreaElement *This = impl_from_DispatchEx(dispex);
419 if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid))
420 return &This->IHTMLTextAreaElement_iface;
422 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
425 static void HTMLTextAreaElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
427 HTMLTextAreaElement *This = impl_from_DispatchEx(dispex);
428 HTMLElement_traverse(dispex, cb);
430 if(This->nstextarea)
431 note_cc_edge((nsISupports*)This->nstextarea, "nstextarea", cb);
434 static void HTMLTextAreaElement_unlink(DispatchEx *dispex)
436 HTMLTextAreaElement *This = impl_from_DispatchEx(dispex);
437 HTMLElement_unlink(dispex);
438 unlink_ref(&This->nstextarea);
441 static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
442 .clsid = &CLSID_HTMLTextAreaElement,
443 .cpc_entries = HTMLElement_cpc,
444 .clone = HTMLElement_clone,
445 .get_attr_col = HTMLElement_get_attr_col,
446 .put_disabled = HTMLTextAreaElementImpl_put_disabled,
447 .get_disabled = HTMLTextAreaElementImpl_get_disabled,
448 .is_text_edit = HTMLTextAreaElement_is_text_edit
451 static const event_target_vtbl_t HTMLTextAreaElement_event_target_vtbl = {
453 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
454 .query_interface= HTMLTextAreaElement_query_interface,
455 .destructor = HTMLElement_destructor,
456 .traverse = HTMLTextAreaElement_traverse,
457 .unlink = HTMLTextAreaElement_unlink
459 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
460 .handle_event = HTMLElement_handle_event
463 static const tid_t HTMLTextAreaElement_iface_tids[] = {
464 HTMLELEMENT_TIDS,
465 IHTMLTextAreaElement_tid,
469 static dispex_static_data_t HTMLTextAreaElement_dispex = {
470 "HTMLTextAreaElement",
471 &HTMLTextAreaElement_event_target_vtbl.dispex_vtbl,
472 DispHTMLTextAreaElement_tid,
473 HTMLTextAreaElement_iface_tids,
474 HTMLElement_init_dispex_info
477 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
479 HTMLTextAreaElement *ret;
480 nsresult nsres;
482 ret = calloc(1, sizeof(HTMLTextAreaElement));
483 if(!ret)
484 return E_OUTOFMEMORY;
486 ret->IHTMLTextAreaElement_iface.lpVtbl = &HTMLTextAreaElementVtbl;
487 ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
489 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex);
491 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement, (void**)&ret->nstextarea);
492 assert(nsres == NS_OK);
494 *elem = &ret->element;
495 return S_OK;