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 IHTMLSelectElementVtbl
*lpHTMLSelectElementVtbl
;
39 nsIDOMHTMLSelectElement
*nsselect
;
42 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
44 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
46 static HRESULT WINAPI
HTMLSelectElement_QueryInterface(IHTMLSelectElement
*iface
,
47 REFIID riid
, void **ppv
)
49 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
54 static ULONG WINAPI
HTMLSelectElement_AddRef(IHTMLSelectElement
*iface
)
56 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
61 static ULONG WINAPI
HTMLSelectElement_Release(IHTMLSelectElement
*iface
)
63 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
68 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement
*iface
, UINT
*pctinfo
)
70 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->element
.node
.dispex
), pctinfo
);
75 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfo(IHTMLSelectElement
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
80 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->element
.node
.dispex
), iTInfo
, lcid
, ppTInfo
);
83 static HRESULT WINAPI
HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
89 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->element
.node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
92 static HRESULT WINAPI
HTMLSelectElement_Invoke(IHTMLSelectElement
*iface
, DISPID dispIdMember
,
93 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
94 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
96 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
98 return IDispatchEx_Invoke(DISPATCHEX(&This
->element
.node
.dispex
), dispIdMember
, riid
, lcid
,
99 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLSelectElement_put_size(IHTMLSelectElement
*iface
, long v
)
104 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
105 FIXME("(%p)->(%ld)\n", This
, v
);
109 static HRESULT WINAPI
HTMLSelectElement_get_size(IHTMLSelectElement
*iface
, long *p
)
111 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
112 FIXME("(%p)->(%p)\n", This
, p
);
116 static HRESULT WINAPI
HTMLSelectElement_put_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
118 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
119 FIXME("(%p)->(%x)\n", This
, v
);
123 static HRESULT WINAPI
HTMLSelectElement_get_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
125 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
126 FIXME("(%p)->(%p)\n", This
, p
);
130 static HRESULT WINAPI
HTMLSelectElement_put_name(IHTMLSelectElement
*iface
, BSTR v
)
132 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
133 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
137 static HRESULT WINAPI
HTMLSelectElement_get_name(IHTMLSelectElement
*iface
, BSTR
*p
)
139 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
141 const PRUnichar
*name
= NULL
;
144 TRACE("(%p)->(%p)\n", This
, p
);
146 nsAString_Init(&name_str
, NULL
);
148 nsres
= nsIDOMHTMLSelectElement_GetName(This
->nsselect
, &name_str
);
149 if(NS_SUCCEEDED(nsres
)) {
150 static const WCHAR wszGarbage
[] = {'g','a','r','b','a','g','e',0};
152 nsAString_GetData(&name_str
, &name
);
155 * Native never returns empty string here. If an element has no name,
156 * name of previous element or ramdom data is returned.
158 *p
= SysAllocString(*name
? name
: wszGarbage
);
160 ERR("GetName failed: %08x\n", nsres
);
163 nsAString_Finish(&name_str
);
165 TRACE("name=%s\n", debugstr_w(*p
));
169 static HRESULT WINAPI
HTMLSelectElement_get_options(IHTMLSelectElement
*iface
, IDispatch
**p
)
171 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
172 FIXME("(%p)->(%p)\n", This
, p
);
176 static HRESULT WINAPI
HTMLSelectElement_put_onchange(IHTMLSelectElement
*iface
, VARIANT v
)
178 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
180 TRACE("(%p)->()\n", This
);
182 return set_node_event(&This
->element
.node
, EVENTID_CHANGE
, &v
);
185 static HRESULT WINAPI
HTMLSelectElement_get_onchange(IHTMLSelectElement
*iface
, VARIANT
*p
)
187 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
188 FIXME("(%p)->(%p)\n", This
, p
);
192 static HRESULT WINAPI
HTMLSelectElement_put_selectedIndex(IHTMLSelectElement
*iface
, long v
)
194 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
197 TRACE("(%p)->(%ld)\n", This
, v
);
199 nsres
= nsIDOMHTMLSelectElement_SetSelectedIndex(This
->nsselect
, v
);
201 ERR("SetSelectedIndex failed: %08x\n", nsres
);
206 static HRESULT WINAPI
HTMLSelectElement_get_selectedIndex(IHTMLSelectElement
*iface
, long *p
)
208 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
212 TRACE("(%p)->(%p)\n", This
, p
);
214 nsres
= nsIDOMHTMLSelectElement_GetSelectedIndex(This
->nsselect
, &idx
);
216 ERR("GetSelectedIndex failed: %08x\n", nsres
);
222 static HRESULT WINAPI
HTMLSelectElement_get_type(IHTMLSelectElement
*iface
, BSTR
*p
)
224 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
225 const PRUnichar
*type
;
230 TRACE("(%p)->(%p)\n", This
, p
);
232 nsAString_Init(&type_str
, NULL
);
233 nsres
= nsIDOMHTMLSelectElement_GetType(This
->nsselect
, &type_str
);
234 if(NS_SUCCEEDED(nsres
)) {
235 nsAString_GetData(&type_str
, &type
);
236 *p
= *type
? SysAllocString(type
) : NULL
;
238 ERR("GetType failed: %08x\n", nsres
);
242 nsAString_Finish(&type_str
);
247 static HRESULT WINAPI
HTMLSelectElement_put_value(IHTMLSelectElement
*iface
, BSTR v
)
249 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
253 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
255 nsAString_Init(&value_str
, v
);
256 nsres
= nsIDOMHTMLSelectElement_SetValue(This
->nsselect
, &value_str
);
257 nsAString_Finish(&value_str
);
259 ERR("SetValue failed: %08x\n", nsres
);
264 static HRESULT WINAPI
HTMLSelectElement_get_value(IHTMLSelectElement
*iface
, BSTR
*p
)
266 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
268 const PRUnichar
*value
= NULL
;
271 TRACE("(%p)->(%p)\n", This
, p
);
273 nsAString_Init(&value_str
, NULL
);
275 nsres
= nsIDOMHTMLSelectElement_GetValue(This
->nsselect
, &value_str
);
276 if(NS_SUCCEEDED(nsres
)) {
277 nsAString_GetData(&value_str
, &value
);
278 *p
= *value
? SysAllocString(value
) : NULL
;
280 ERR("GetValue failed: %08x\n", nsres
);
283 nsAString_Finish(&value_str
);
285 TRACE("value=%s\n", debugstr_w(*p
));
289 static HRESULT WINAPI
HTMLSelectElement_put_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
291 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
292 FIXME("(%p)->(%x)\n", This
, v
);
296 static HRESULT WINAPI
HTMLSelectElement_get_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
298 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
299 FIXME("(%p)->(%p)\n", This
, p
);
303 static HRESULT WINAPI
HTMLSelectElement_get_form(IHTMLSelectElement
*iface
, IHTMLFormElement
**p
)
305 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
306 FIXME("(%p)->(%p)\n", This
, p
);
310 static HRESULT WINAPI
HTMLSelectElement_add(IHTMLSelectElement
*iface
, IHTMLElement
*element
,
313 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
314 FIXME("(%p)->(%p v)\n", This
, element
);
318 static HRESULT WINAPI
HTMLSelectElement_remove(IHTMLSelectElement
*iface
, long index
)
320 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
321 FIXME("(%p)->(%ld)\n", This
, index
);
325 static HRESULT WINAPI
HTMLSelectElement_put_length(IHTMLSelectElement
*iface
, long v
)
327 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
328 FIXME("(%p)->(%ld)\n", This
, v
);
332 static HRESULT WINAPI
HTMLSelectElement_get_length(IHTMLSelectElement
*iface
, long *p
)
334 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
338 TRACE("(%p)->(%p)\n", This
, p
);
340 nsres
= nsIDOMHTMLSelectElement_GetLength(This
->nsselect
, &length
);
342 ERR("GetLength failed: %08x\n", nsres
);
346 TRACE("ret %ld\n", *p
);
350 static HRESULT WINAPI
HTMLSelectElement_get__newEnum(IHTMLSelectElement
*iface
, IUnknown
**p
)
352 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
353 FIXME("(%p)->(%p)\n", This
, p
);
357 static HRESULT WINAPI
HTMLSelectElement_item(IHTMLSelectElement
*iface
, VARIANT name
,
358 VARIANT index
, IDispatch
**pdisp
)
360 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
361 FIXME("(%p)->(v v %p)\n", This
, pdisp
);
365 static HRESULT WINAPI
HTMLSelectElement_tags(IHTMLSelectElement
*iface
, VARIANT tagName
,
368 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
369 FIXME("(%p)->(v %p)\n", This
, pdisp
);
373 #undef HTMLSELECT_THIS
375 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl
= {
376 HTMLSelectElement_QueryInterface
,
377 HTMLSelectElement_AddRef
,
378 HTMLSelectElement_Release
,
379 HTMLSelectElement_GetTypeInfoCount
,
380 HTMLSelectElement_GetTypeInfo
,
381 HTMLSelectElement_GetIDsOfNames
,
382 HTMLSelectElement_Invoke
,
383 HTMLSelectElement_put_size
,
384 HTMLSelectElement_get_size
,
385 HTMLSelectElement_put_multiple
,
386 HTMLSelectElement_get_multiple
,
387 HTMLSelectElement_put_name
,
388 HTMLSelectElement_get_name
,
389 HTMLSelectElement_get_options
,
390 HTMLSelectElement_put_onchange
,
391 HTMLSelectElement_get_onchange
,
392 HTMLSelectElement_put_selectedIndex
,
393 HTMLSelectElement_get_selectedIndex
,
394 HTMLSelectElement_get_type
,
395 HTMLSelectElement_put_value
,
396 HTMLSelectElement_get_value
,
397 HTMLSelectElement_put_disabled
,
398 HTMLSelectElement_get_disabled
,
399 HTMLSelectElement_get_form
,
400 HTMLSelectElement_add
,
401 HTMLSelectElement_remove
,
402 HTMLSelectElement_put_length
,
403 HTMLSelectElement_get_length
,
404 HTMLSelectElement_get__newEnum
,
405 HTMLSelectElement_item
,
406 HTMLSelectElement_tags
409 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
411 static HRESULT
HTMLSelectElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
413 HTMLSelectElement
*This
= HTMLSELECT_NODE_THIS(iface
);
417 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
418 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
419 *ppv
= HTMLSELECT(This
);
420 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
421 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
422 *ppv
= HTMLSELECT(This
);
423 }else if(IsEqualGUID(&IID_IHTMLSelectElement
, riid
)) {
424 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This
, ppv
);
425 *ppv
= HTMLSELECT(This
);
429 IUnknown_AddRef((IUnknown
*)*ppv
);
433 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
436 static void HTMLSelectElement_destructor(HTMLDOMNode
*iface
)
438 HTMLSelectElement
*This
= HTMLSELECT_NODE_THIS(iface
);
440 nsIDOMHTMLSelectElement_Release(This
->nsselect
);
442 HTMLElement_destructor(&This
->element
.node
);
445 #undef HTMLSELECT_NODE_THIS
447 static const NodeImplVtbl HTMLSelectElementImplVtbl
= {
448 HTMLSelectElement_QI
,
449 HTMLSelectElement_destructor
452 static const tid_t HTMLSelectElement_tids
[] = {
457 IHTMLSelectElement_tid
,
461 static dispex_static_data_t HTMLSelectElement_dispex
= {
463 DispHTMLSelectElement_tid
,
465 HTMLSelectElement_tids
468 HTMLElement
*HTMLSelectElement_Create(nsIDOMHTMLElement
*nselem
)
470 HTMLSelectElement
*ret
= heap_alloc_zero(sizeof(HTMLSelectElement
));
473 ret
->lpHTMLSelectElementVtbl
= &HTMLSelectElementVtbl
;
474 ret
->element
.node
.vtbl
= &HTMLSelectElementImplVtbl
;
476 init_dispex(&ret
->element
.node
.dispex
, (IUnknown
*)HTMLSELECT(ret
), &HTMLSelectElement_dispex
);
477 HTMLElement_Init(&ret
->element
);
479 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLSelectElement
,
480 (void**)&ret
->nsselect
);
482 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres
);
484 return &ret
->element
;