wininet: Support the Cache-Control max-age directive for setting url cache entry...
[wine/testsucceed.git] / dlls / mshtml / htmltextarea.c
blob3b7651da3bdb559b3a77332a602bb8f7f6677f30
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"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 HTMLElement element;
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(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
55 static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
57 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
59 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
62 static ULONG WINAPI HTMLTextAreaElement_Release(IHTMLTextAreaElement *iface)
64 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
66 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
69 static HRESULT WINAPI HTMLTextAreaElement_GetTypeInfoCount(IHTMLTextAreaElement *iface, UINT *pctinfo)
71 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, 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(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
80 ppTInfo);
83 static HRESULT WINAPI HTMLTextAreaElement_GetIDsOfNames(IHTMLTextAreaElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
88 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
89 cNames, lcid, rgDispId);
92 static HRESULT WINAPI HTMLTextAreaElement_Invoke(IHTMLTextAreaElement *iface, DISPID dispIdMember,
93 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
96 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
97 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
98 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
101 static HRESULT WINAPI HTMLTextAreaElement_get_type(IHTMLTextAreaElement *iface, BSTR *p)
103 static const WCHAR textareaW[] = {'t','e','x','t','a','r','e','a',0};
105 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
107 TRACE("(%p)->(%p)\n", This, p);
109 *p = SysAllocString(textareaW);
110 if(!*p)
111 return E_OUTOFMEMORY;
112 return S_OK;
115 static HRESULT WINAPI HTMLTextAreaElement_put_value(IHTMLTextAreaElement *iface, BSTR v)
117 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
118 nsAString value_str;
119 nsresult nsres;
121 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
123 nsAString_InitDepend(&value_str, v);
124 nsres = nsIDOMHTMLTextAreaElement_SetValue(This->nstextarea, &value_str);
125 nsAString_Finish(&value_str);
126 if(NS_FAILED(nsres)) {
127 ERR("SetValue failed: %08x\n", nsres);
128 return E_FAIL;
131 return S_OK;
134 static HRESULT WINAPI HTMLTextAreaElement_get_value(IHTMLTextAreaElement *iface, BSTR *p)
136 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
137 nsAString value_str;
138 const PRUnichar *value;
139 nsresult nsres;
140 HRESULT hres = S_OK;
142 TRACE("(%p)->(%p)\n", This, p);
144 nsAString_Init(&value_str, NULL);
146 nsres = nsIDOMHTMLTextAreaElement_GetValue(This->nstextarea, &value_str);
147 if(NS_SUCCEEDED(nsres)) {
148 nsAString_GetData(&value_str, &value);
149 *p = *value ? SysAllocString(value) : NULL;
150 }else {
151 ERR("GetValue failed: %08x\n", nsres);
152 hres = E_FAIL;
155 nsAString_Finish(&value_str);
156 return hres;
159 static HRESULT WINAPI HTMLTextAreaElement_put_name(IHTMLTextAreaElement *iface, BSTR v)
161 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
162 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
163 return E_NOTIMPL;
166 static HRESULT WINAPI HTMLTextAreaElement_get_name(IHTMLTextAreaElement *iface, BSTR *p)
168 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
169 nsAString name_str;
170 const PRUnichar *name;
171 nsresult nsres;
173 TRACE("(%p)->(%p)\n", This, p);
175 nsAString_Init(&name_str, NULL);
177 nsres = nsIDOMHTMLTextAreaElement_GetName(This->nstextarea, &name_str);
178 if(NS_SUCCEEDED(nsres)) {
179 nsAString_GetData(&name_str, &name);
180 *p = SysAllocString(name);
181 }else {
182 ERR("GetName failed: %08x\n", nsres);
185 nsAString_Finish(&name_str);
187 TRACE("%s\n", debugstr_w(*p));
188 return S_OK;
191 static HRESULT WINAPI HTMLTextAreaElement_put_status(IHTMLTextAreaElement *iface, VARIANT v)
193 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
194 FIXME("(%p)->()\n", This);
195 return E_NOTIMPL;
198 static HRESULT WINAPI HTMLTextAreaElement_get_status(IHTMLTextAreaElement *iface, VARIANT *p)
200 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
201 FIXME("(%p)->(%p)\n", This, p);
202 return E_NOTIMPL;
205 static HRESULT WINAPI HTMLTextAreaElement_put_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
207 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
208 FIXME("(%p)->(%x)\n", This, v);
209 return E_NOTIMPL;
212 static HRESULT WINAPI HTMLTextAreaElement_get_disabled(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
214 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
215 FIXME("(%p)->(%p)\n", This, p);
216 return E_NOTIMPL;
219 static HRESULT WINAPI HTMLTextAreaElement_get_form(IHTMLTextAreaElement *iface, IHTMLFormElement **p)
221 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
222 FIXME("(%p)->(%p)\n", This, p);
223 return E_NOTIMPL;
226 static HRESULT WINAPI HTMLTextAreaElement_put_defaultValue(IHTMLTextAreaElement *iface, BSTR v)
228 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
229 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
230 return E_NOTIMPL;
233 static HRESULT WINAPI HTMLTextAreaElement_get_defaultValue(IHTMLTextAreaElement *iface, BSTR *p)
235 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
236 FIXME("(%p)->(%p)\n", This, p);
237 return E_NOTIMPL;
240 static HRESULT WINAPI HTMLTextAreaElement_select(IHTMLTextAreaElement *iface)
242 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
243 FIXME("(%p)\n", This);
244 return E_NOTIMPL;
247 static HRESULT WINAPI HTMLTextAreaElement_put_onchange(IHTMLTextAreaElement *iface, VARIANT v)
249 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
250 FIXME("(%p)->()\n", This);
251 return E_NOTIMPL;
254 static HRESULT WINAPI HTMLTextAreaElement_get_onchange(IHTMLTextAreaElement *iface, VARIANT *p)
256 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
257 FIXME("(%p)->(%p)\n", This, p);
258 return E_NOTIMPL;
261 static HRESULT WINAPI HTMLTextAreaElement_put_onselect(IHTMLTextAreaElement *iface, VARIANT v)
263 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
264 FIXME("(%p)->()\n", This);
265 return E_NOTIMPL;
268 static HRESULT WINAPI HTMLTextAreaElement_get_onselect(IHTMLTextAreaElement *iface, VARIANT *p)
270 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
271 FIXME("(%p)->(%p)\n", This, p);
272 return E_NOTIMPL;
275 static HRESULT WINAPI HTMLTextAreaElement_put_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL v)
277 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
278 nsresult nsres;
280 TRACE("(%p)->(%x)\n", This, v);
282 nsres = nsIDOMHTMLTextAreaElement_SetReadOnly(This->nstextarea, v != VARIANT_FALSE);
283 if(NS_FAILED(nsres)) {
284 ERR("SetReadOnly failed: %08x\n", nsres);
285 return E_FAIL;
288 return S_OK;
291 static HRESULT WINAPI HTMLTextAreaElement_get_readOnly(IHTMLTextAreaElement *iface, VARIANT_BOOL *p)
293 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
294 PRBool b;
295 nsresult nsres;
297 TRACE("(%p)->(%p)\n", This, p);
299 nsres = nsIDOMHTMLTextAreaElement_GetReadOnly(This->nstextarea, &b);
300 if(NS_FAILED(nsres)) {
301 ERR("GetReadOnly failed: %08x\n", nsres);
302 return E_FAIL;
305 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
306 return S_OK;
309 static HRESULT WINAPI HTMLTextAreaElement_put_rows(IHTMLTextAreaElement *iface, LONG v)
311 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
312 FIXME("(%p)->(%d)\n", This, v);
313 return E_NOTIMPL;
316 static HRESULT WINAPI HTMLTextAreaElement_get_rows(IHTMLTextAreaElement *iface, LONG *p)
318 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
319 FIXME("(%p)->(%p)\n", This, p);
320 return E_NOTIMPL;
323 static HRESULT WINAPI HTMLTextAreaElement_put_cols(IHTMLTextAreaElement *iface, LONG v)
325 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
326 FIXME("(%p)->(%d)\n", This, v);
327 return E_NOTIMPL;
330 static HRESULT WINAPI HTMLTextAreaElement_get_cols(IHTMLTextAreaElement *iface, LONG *p)
332 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
333 FIXME("(%p)->(%p)\n", This, p);
334 return E_NOTIMPL;
337 static HRESULT WINAPI HTMLTextAreaElement_put_wrap(IHTMLTextAreaElement *iface, BSTR v)
339 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
340 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
341 return E_NOTIMPL;
344 static HRESULT WINAPI HTMLTextAreaElement_get_wrap(IHTMLTextAreaElement *iface, BSTR *p)
346 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
347 FIXME("(%p)->(%p)\n", This, p);
348 return E_NOTIMPL;
351 static HRESULT WINAPI HTMLTextAreaElement_createTextRange(IHTMLTextAreaElement *iface,
352 IHTMLTxtRange **range)
354 HTMLTextAreaElement *This = impl_from_IHTMLTextAreaElement(iface);
355 FIXME("(%p)->(%p)\n", This, range);
356 return E_NOTIMPL;
359 static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
360 HTMLTextAreaElement_QueryInterface,
361 HTMLTextAreaElement_AddRef,
362 HTMLTextAreaElement_Release,
363 HTMLTextAreaElement_GetTypeInfoCount,
364 HTMLTextAreaElement_GetTypeInfo,
365 HTMLTextAreaElement_GetIDsOfNames,
366 HTMLTextAreaElement_Invoke,
367 HTMLTextAreaElement_get_type,
368 HTMLTextAreaElement_put_value,
369 HTMLTextAreaElement_get_value,
370 HTMLTextAreaElement_put_name,
371 HTMLTextAreaElement_get_name,
372 HTMLTextAreaElement_put_status,
373 HTMLTextAreaElement_get_status,
374 HTMLTextAreaElement_put_disabled,
375 HTMLTextAreaElement_get_disabled,
376 HTMLTextAreaElement_get_form,
377 HTMLTextAreaElement_put_defaultValue,
378 HTMLTextAreaElement_get_defaultValue,
379 HTMLTextAreaElement_select,
380 HTMLTextAreaElement_put_onchange,
381 HTMLTextAreaElement_get_onchange,
382 HTMLTextAreaElement_put_onselect,
383 HTMLTextAreaElement_get_onselect,
384 HTMLTextAreaElement_put_readOnly,
385 HTMLTextAreaElement_get_readOnly,
386 HTMLTextAreaElement_put_rows,
387 HTMLTextAreaElement_get_rows,
388 HTMLTextAreaElement_put_cols,
389 HTMLTextAreaElement_get_cols,
390 HTMLTextAreaElement_put_wrap,
391 HTMLTextAreaElement_get_wrap,
392 HTMLTextAreaElement_createTextRange
395 static inline HTMLTextAreaElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
397 return CONTAINING_RECORD(iface, HTMLTextAreaElement, element.node);
400 static HRESULT HTMLTextAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
402 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
404 *ppv = NULL;
406 if(IsEqualGUID(&IID_IUnknown, riid)) {
407 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
408 *ppv = &This->IHTMLTextAreaElement_iface;
409 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
410 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
411 *ppv = &This->IHTMLTextAreaElement_iface;
412 }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
413 TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
414 *ppv = &This->IHTMLTextAreaElement_iface;
417 if(*ppv) {
418 IUnknown_AddRef((IUnknown*)*ppv);
419 return S_OK;
422 return HTMLElement_QI(&This->element.node, riid, ppv);
425 static void HTMLTextAreaElement_destructor(HTMLDOMNode *iface)
427 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
429 nsIDOMHTMLTextAreaElement_Release(This->nstextarea);
431 HTMLElement_destructor(&This->element.node);
434 static HRESULT HTMLTextAreaElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
436 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
437 return IHTMLTextAreaElement_put_disabled(&This->IHTMLTextAreaElement_iface, v);
440 static HRESULT HTMLTextAreaElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
442 HTMLTextAreaElement *This = impl_from_HTMLDOMNode(iface);
443 return IHTMLTextAreaElement_get_disabled(&This->IHTMLTextAreaElement_iface, p);
446 static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
447 HTMLTextAreaElement_QI,
448 HTMLTextAreaElement_destructor,
449 HTMLElement_clone,
450 NULL,
451 NULL,
452 HTMLTextAreaElementImpl_put_disabled,
453 HTMLTextAreaElementImpl_get_disabled
456 static const tid_t HTMLTextAreaElement_iface_tids[] = {
457 HTMLELEMENT_TIDS,
458 IHTMLTextAreaElement_tid,
462 static dispex_static_data_t HTMLTextAreaElement_dispex = {
463 NULL,
464 DispHTMLTextAreaElement_tid,
465 NULL,
466 HTMLTextAreaElement_iface_tids
469 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
471 HTMLTextAreaElement *ret;
472 nsresult nsres;
474 ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
475 if(!ret)
476 return E_OUTOFMEMORY;
478 ret->IHTMLTextAreaElement_iface.lpVtbl = &HTMLTextAreaElementVtbl;
479 ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
481 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement,
482 (void**)&ret->nstextarea);
483 if(NS_FAILED(nsres)) {
484 ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres);
485 heap_free(ret);
486 return E_FAIL;
489 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTextAreaElement_dispex);
491 *elem = &ret->element;
492 return S_OK;