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
32 #include "wine/debug.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 const IHTMLSelectElementVtbl
*lpHTMLSelectElementVtbl
;
43 nsIDOMHTMLSelectElement
*nsselect
;
46 #define HTMLSELECT(x) ((IHTMLSelectElement*) &(x)->lpHTMLSelectElementVtbl)
48 #define HTMLSELECT_THIS(iface) DEFINE_THIS(HTMLSelectElement, HTMLSelectElement, iface)
50 static HRESULT WINAPI
HTMLSelectElement_QueryInterface(IHTMLSelectElement
*iface
,
51 REFIID riid
, void **ppv
)
53 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
55 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
58 static ULONG WINAPI
HTMLSelectElement_AddRef(IHTMLSelectElement
*iface
)
60 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
62 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
65 static ULONG WINAPI
HTMLSelectElement_Release(IHTMLSelectElement
*iface
)
67 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
69 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
72 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement
*iface
, UINT
*pctinfo
)
74 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
75 FIXME("(%p)->(%p)\n", This
, pctinfo
);
79 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfo(IHTMLSelectElement
*iface
, UINT iTInfo
,
80 LCID lcid
, ITypeInfo
**ppTInfo
)
82 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
83 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
87 static HRESULT WINAPI
HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement
*iface
, REFIID riid
,
88 LPOLESTR
*rgszNames
, UINT cNames
,
89 LCID lcid
, DISPID
*rgDispId
)
91 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
92 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
97 static HRESULT WINAPI
HTMLSelectElement_Invoke(IHTMLSelectElement
*iface
, DISPID dispIdMember
,
98 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
99 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
101 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
102 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
103 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
107 static HRESULT WINAPI
HTMLSelectElement_put_size(IHTMLSelectElement
*iface
, long v
)
109 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
110 FIXME("(%p)->(%ld)\n", This
, v
);
114 static HRESULT WINAPI
HTMLSelectElement_get_size(IHTMLSelectElement
*iface
, long *p
)
116 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
117 FIXME("(%p)->(%p)\n", This
, p
);
121 static HRESULT WINAPI
HTMLSelectElement_put_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
123 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
124 FIXME("(%p)->(%x)\n", This
, v
);
128 static HRESULT WINAPI
HTMLSelectElement_get_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
130 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
131 FIXME("(%p)->(%p)\n", This
, p
);
135 static HRESULT WINAPI
HTMLSelectElement_put_name(IHTMLSelectElement
*iface
, BSTR v
)
137 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
138 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
142 static HRESULT WINAPI
HTMLSelectElement_get_name(IHTMLSelectElement
*iface
, BSTR
*p
)
144 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
146 const PRUnichar
*name
= NULL
;
149 TRACE("(%p)->(%p)\n", This
, p
);
151 nsAString_Init(&name_str
, NULL
);
153 nsres
= nsIDOMHTMLSelectElement_GetName(This
->nsselect
, &name_str
);
154 if(NS_SUCCEEDED(nsres
)) {
155 static const WCHAR wszGarbage
[] = {'g','a','r','b','a','g','e',0};
157 nsAString_GetData(&name_str
, &name
);
160 * Native never returns empty string here. If an element has no name,
161 * name of previous element or ramdom data is returned.
163 *p
= SysAllocString(*name
? name
: wszGarbage
);
165 ERR("GetName failed: %08x\n", nsres
);
168 nsAString_Finish(&name_str
);
170 TRACE("name=%s\n", debugstr_w(*p
));
174 static HRESULT WINAPI
HTMLSelectElement_get_options(IHTMLSelectElement
*iface
, IDispatch
**p
)
176 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
177 FIXME("(%p)->(%p)\n", This
, p
);
181 static HRESULT WINAPI
HTMLSelectElement_put_onchange(IHTMLSelectElement
*iface
, VARIANT v
)
183 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
184 FIXME("(%p)->()\n", This
);
188 static HRESULT WINAPI
HTMLSelectElement_get_onchange(IHTMLSelectElement
*iface
, VARIANT
*p
)
190 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
191 FIXME("(%p)->(%p)\n", This
, p
);
195 static HRESULT WINAPI
HTMLSelectElement_put_selectedIndex(IHTMLSelectElement
*iface
, long v
)
197 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
200 TRACE("(%p)->(%ld)\n", This
, v
);
202 nsres
= nsIDOMHTMLSelectElement_SetSelectedIndex(This
->nsselect
, v
);
204 ERR("SetSelectedIndex failed: %08x\n", nsres
);
209 static HRESULT WINAPI
HTMLSelectElement_get_selectedIndex(IHTMLSelectElement
*iface
, long *p
)
211 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
215 TRACE("(%p)->(%p)\n", This
, p
);
217 nsres
= nsIDOMHTMLSelectElement_GetSelectedIndex(This
->nsselect
, &idx
);
219 ERR("GetSelectedIndex failed: %08x\n", nsres
);
225 static HRESULT WINAPI
HTMLSelectElement_get_type(IHTMLSelectElement
*iface
, BSTR
*p
)
227 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
228 FIXME("(%p)->(%p)\n", This
, p
);
232 static HRESULT WINAPI
HTMLSelectElement_put_value(IHTMLSelectElement
*iface
, BSTR v
)
234 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
235 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
239 static HRESULT WINAPI
HTMLSelectElement_get_value(IHTMLSelectElement
*iface
, BSTR
*p
)
241 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
243 const PRUnichar
*value
= NULL
;
246 TRACE("(%p)->(%p)\n", This
, p
);
248 nsAString_Init(&value_str
, NULL
);
250 nsres
= nsIDOMHTMLSelectElement_GetValue(This
->nsselect
, &value_str
);
251 if(NS_SUCCEEDED(nsres
)) {
252 nsAString_GetData(&value_str
, &value
);
253 *p
= SysAllocString(value
);
255 ERR("GetValue failed: %08x\n", nsres
);
258 nsAString_Finish(&value_str
);
260 TRACE("value=%s\n", debugstr_w(*p
));
264 static HRESULT WINAPI
HTMLSelectElement_put_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
266 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
267 FIXME("(%p)->(%x)\n", This
, v
);
271 static HRESULT WINAPI
HTMLSelectElement_get_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
273 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLSelectElement_get_form(IHTMLSelectElement
*iface
, IHTMLFormElement
**p
)
280 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
281 FIXME("(%p)->(%p)\n", This
, p
);
285 static HRESULT WINAPI
HTMLSelectElement_add(IHTMLSelectElement
*iface
, IHTMLElement
*element
,
288 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
289 FIXME("(%p)->(%p v)\n", This
, element
);
293 static HRESULT WINAPI
HTMLSelectElement_remove(IHTMLSelectElement
*iface
, long index
)
295 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
296 FIXME("(%p)->(%ld)\n", This
, index
);
300 static HRESULT WINAPI
HTMLSelectElement_put_length(IHTMLSelectElement
*iface
, long v
)
302 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
303 FIXME("(%p)->(%ld)\n", This
, v
);
307 static HRESULT WINAPI
HTMLSelectElement_get_length(IHTMLSelectElement
*iface
, long *p
)
309 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
313 TRACE("(%p)->(%p)\n", This
, p
);
315 nsres
= nsIDOMHTMLSelectElement_GetLength(This
->nsselect
, &length
);
317 ERR("GetLength failed: %08x\n", nsres
);
321 TRACE("ret %ld\n", *p
);
325 static HRESULT WINAPI
HTMLSelectElement_get__newEnum(IHTMLSelectElement
*iface
, IUnknown
**p
)
327 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
328 FIXME("(%p)->(%p)\n", This
, p
);
332 static HRESULT WINAPI
HTMLSelectElement_item(IHTMLSelectElement
*iface
, VARIANT name
,
333 VARIANT index
, IDispatch
**pdisp
)
335 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
336 FIXME("(%p)->(v v %p)\n", This
, pdisp
);
340 static HRESULT WINAPI
HTMLSelectElement_tags(IHTMLSelectElement
*iface
, VARIANT tagName
,
343 HTMLSelectElement
*This
= HTMLSELECT_THIS(iface
);
344 FIXME("(%p)->(v %p)\n", This
, pdisp
);
348 #undef HTMLSELECT_THIS
350 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl
= {
351 HTMLSelectElement_QueryInterface
,
352 HTMLSelectElement_AddRef
,
353 HTMLSelectElement_Release
,
354 HTMLSelectElement_GetTypeInfoCount
,
355 HTMLSelectElement_GetTypeInfo
,
356 HTMLSelectElement_GetIDsOfNames
,
357 HTMLSelectElement_Invoke
,
358 HTMLSelectElement_put_size
,
359 HTMLSelectElement_get_size
,
360 HTMLSelectElement_put_multiple
,
361 HTMLSelectElement_get_multiple
,
362 HTMLSelectElement_put_name
,
363 HTMLSelectElement_get_name
,
364 HTMLSelectElement_get_options
,
365 HTMLSelectElement_put_onchange
,
366 HTMLSelectElement_get_onchange
,
367 HTMLSelectElement_put_selectedIndex
,
368 HTMLSelectElement_get_selectedIndex
,
369 HTMLSelectElement_get_type
,
370 HTMLSelectElement_put_value
,
371 HTMLSelectElement_get_value
,
372 HTMLSelectElement_put_disabled
,
373 HTMLSelectElement_get_disabled
,
374 HTMLSelectElement_get_form
,
375 HTMLSelectElement_add
,
376 HTMLSelectElement_remove
,
377 HTMLSelectElement_put_length
,
378 HTMLSelectElement_get_length
,
379 HTMLSelectElement_get__newEnum
,
380 HTMLSelectElement_item
,
381 HTMLSelectElement_tags
384 #define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
386 static HRESULT
HTMLSelectElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
388 HTMLSelectElement
*This
= HTMLSELECT_NODE_THIS(iface
);
392 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
393 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
394 *ppv
= HTMLSELECT(This
);
395 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
396 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
397 *ppv
= HTMLSELECT(This
);
398 }else if(IsEqualGUID(&IID_IHTMLSelectElement
, riid
)) {
399 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This
, ppv
);
400 *ppv
= HTMLSELECT(This
);
404 IUnknown_AddRef((IUnknown
*)*ppv
);
408 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
411 static void HTMLSelectElement_destructor(HTMLDOMNode
*iface
)
413 HTMLSelectElement
*This
= HTMLSELECT_NODE_THIS(iface
);
415 nsIDOMHTMLSelectElement_Release(This
->nsselect
);
417 HTMLElement_destructor(&This
->element
.node
);
420 #undef HTMLSELECT_NODE_THIS
422 static const NodeImplVtbl HTMLSelectElementImplVtbl
= {
423 HTMLSelectElement_QI
,
424 HTMLSelectElement_destructor
427 HTMLElement
*HTMLSelectElement_Create(nsIDOMHTMLElement
*nselem
)
429 HTMLSelectElement
*ret
= heap_alloc(sizeof(HTMLSelectElement
));
432 HTMLElement_Init(&ret
->element
);
434 ret
->lpHTMLSelectElementVtbl
= &HTMLSelectElementVtbl
;
435 ret
->element
.node
.vtbl
= &HTMLSelectElementImplVtbl
;
437 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLSelectElement
,
438 (void**)&ret
->nsselect
);
440 ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres
);
442 return &ret
->element
;