msvcrt: Set the correct error number in pow(f).
[wine.git] / dlls / mshtml / htmlselect.c
blob7ae1ba3493c776f05931316e2fdb65670d7add11
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"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 struct HTMLSelectElement {
37 HTMLElement element;
39 IHTMLSelectElement IHTMLSelectElement_iface;
41 nsIDOMHTMLSelectElement *nsselect;
44 static inline HTMLSelectElement *impl_from_IHTMLSelectElement(IHTMLSelectElement *iface)
46 return CONTAINING_RECORD(iface, HTMLSelectElement, IHTMLSelectElement_iface);
49 static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
51 nsIDOMHTMLOptionsCollection *nscol;
52 nsIDOMNode *nsnode;
53 nsresult nsres;
54 HRESULT hres;
56 nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
57 if(NS_FAILED(nsres)) {
58 ERR("GetOptions failed: %08x\n", nsres);
59 return E_FAIL;
62 nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
63 nsIDOMHTMLOptionsCollection_Release(nscol);
64 if(NS_FAILED(nsres)) {
65 ERR("Item failed: %08x\n", nsres);
66 return E_FAIL;
69 if(nsnode) {
70 HTMLDOMNode *node;
72 hres = get_node(This->element.node.doc, nsnode, TRUE, &node);
73 nsIDOMNode_Release(nsnode);
74 if(FAILED(hres))
75 return hres;
77 *ret = (IDispatch*)&node->IHTMLDOMNode_iface;
78 }else {
79 *ret = NULL;
81 return S_OK;
84 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
85 REFIID riid, void **ppv)
87 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
89 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
92 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
94 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
96 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
99 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
101 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
103 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
106 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
108 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
110 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
113 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
114 LCID lcid, ITypeInfo **ppTInfo)
116 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
118 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
119 ppTInfo);
122 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
123 LPOLESTR *rgszNames, UINT cNames,
124 LCID lcid, DISPID *rgDispId)
126 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
128 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
129 cNames, lcid, rgDispId);
132 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
133 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
134 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
136 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
138 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
139 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
142 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, LONG v)
144 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
145 nsresult nsres;
147 TRACE("(%p)->(%d)\n", This, v);
148 if(v < 0)
149 return CTL_E_INVALIDPROPERTYVALUE;
151 nsres = nsIDOMHTMLSelectElement_SetSize(This->nsselect, v);
152 if(NS_FAILED(nsres)) {
153 ERR("SetSize failed: %08x\n", nsres);
154 return E_FAIL;
156 return S_OK;
159 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, LONG *p)
161 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
162 DWORD val;
163 nsresult nsres;
165 TRACE("(%p)->(%p)\n", This, p);
166 if(!p)
167 return E_INVALIDARG;
169 nsres = nsIDOMHTMLSelectElement_GetSize(This->nsselect, &val);
170 if(NS_FAILED(nsres)) {
171 ERR("GetSize failed: %08x\n", nsres);
172 return E_FAIL;
174 *p = val;
175 return S_OK;
178 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
180 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
181 nsresult nsres;
183 TRACE("(%p)->(%x)\n", This, v);
185 nsres = nsIDOMHTMLSelectElement_SetMultiple(This->nsselect, !!v);
186 assert(nsres == NS_OK);
187 return S_OK;
190 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
192 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
193 cpp_bool val;
194 nsresult nsres;
196 TRACE("(%p)->(%p)\n", This, p);
198 nsres = nsIDOMHTMLSelectElement_GetMultiple(This->nsselect, &val);
199 assert(nsres == NS_OK);
201 *p = val ? VARIANT_TRUE : VARIANT_FALSE;
202 return S_OK;
205 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
207 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
208 nsAString str;
209 nsresult nsres;
211 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
212 nsAString_InitDepend(&str, v);
213 nsres = nsIDOMHTMLSelectElement_SetName(This->nsselect, &str);
214 nsAString_Finish(&str);
216 if(NS_FAILED(nsres)) {
217 ERR("SetName failed: %08x\n", nsres);
218 return E_FAIL;
220 return S_OK;
223 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
225 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
226 nsAString name_str;
227 nsresult nsres;
229 TRACE("(%p)->(%p)\n", This, p);
231 nsAString_Init(&name_str, NULL);
232 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
234 return return_nsstr(nsres, &name_str, p);
237 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
239 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
241 TRACE("(%p)->(%p)\n", This, p);
243 *p = (IDispatch*)&This->IHTMLSelectElement_iface;
244 IDispatch_AddRef(*p);
245 return S_OK;
248 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
250 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
252 TRACE("(%p)->()\n", This);
254 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
257 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
259 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
260 FIXME("(%p)->(%p)\n", This, p);
261 return E_NOTIMPL;
264 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, LONG v)
266 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
267 nsresult nsres;
269 TRACE("(%p)->(%d)\n", This, v);
271 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
272 if(NS_FAILED(nsres))
273 ERR("SetSelectedIndex failed: %08x\n", nsres);
275 return S_OK;
278 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, LONG *p)
280 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
281 nsresult nsres;
283 TRACE("(%p)->(%p)\n", This, p);
285 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, p);
286 if(NS_FAILED(nsres)) {
287 ERR("GetSelectedIndex failed: %08x\n", nsres);
288 return E_FAIL;
291 return S_OK;
294 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
296 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
297 nsAString type_str;
298 nsresult nsres;
300 TRACE("(%p)->(%p)\n", This, p);
302 nsAString_Init(&type_str, NULL);
303 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
304 return return_nsstr(nsres, &type_str, p);
307 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
309 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
310 nsAString value_str;
311 nsresult nsres;
313 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
315 nsAString_InitDepend(&value_str, v);
316 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
317 nsAString_Finish(&value_str);
318 if(NS_FAILED(nsres))
319 ERR("SetValue failed: %08x\n", nsres);
321 return S_OK;
324 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
326 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
327 nsAString value_str;
328 nsresult nsres;
330 TRACE("(%p)->(%p)\n", This, p);
332 nsAString_Init(&value_str, NULL);
333 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
334 return return_nsstr(nsres, &value_str, p);
337 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
339 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
340 nsresult nsres;
342 TRACE("(%p)->(%x)\n", This, v);
344 nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
345 if(NS_FAILED(nsres)) {
346 ERR("SetDisabled failed: %08x\n", nsres);
347 return E_FAIL;
350 return S_OK;
353 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
355 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
356 cpp_bool disabled = FALSE;
357 nsresult nsres;
359 TRACE("(%p)->(%p)\n", This, p);
361 nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
362 if(NS_FAILED(nsres)) {
363 ERR("GetDisabled failed: %08x\n", nsres);
364 return E_FAIL;
367 *p = disabled ? VARIANT_TRUE : VARIANT_FALSE;
368 return S_OK;
371 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
373 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
374 nsIDOMHTMLFormElement *nsform;
375 nsIDOMNode *form_node;
376 HTMLDOMNode *node;
377 HRESULT hres;
378 nsresult nsres;
380 TRACE("(%p)->(%p)\n", This, p);
382 if(!p)
383 return E_POINTER;
385 nsres = nsIDOMHTMLSelectElement_GetForm(This->nsselect, &nsform);
386 if (NS_FAILED(nsres)) {
387 ERR("GetForm failed: %08x, nsform: %p\n", nsres, nsform);
388 *p = NULL;
389 return E_FAIL;
391 if (nsform == NULL) {
392 TRACE("nsform not found\n");
393 *p = NULL;
394 return S_OK;
397 nsres = nsIDOMHTMLFormElement_QueryInterface(nsform, &IID_nsIDOMNode, (void**)&form_node);
398 nsIDOMHTMLFormElement_Release(nsform);
399 assert(nsres == NS_OK);
401 hres = get_node(This->element.node.doc, form_node, TRUE, &node);
402 nsIDOMNode_Release(form_node);
403 if (FAILED(hres))
404 return hres;
406 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
408 node_release(node);
409 return hres;
412 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
413 VARIANT before)
415 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
416 nsIWritableVariant *nsvariant;
417 HTMLElement *element_obj;
418 nsresult nsres;
420 TRACE("(%p)->(%p %s)\n", This, element, debugstr_variant(&before));
422 element_obj = unsafe_impl_from_IHTMLElement(element);
423 if(!element_obj) {
424 FIXME("External IHTMLElement implementation?\n");
425 return E_INVALIDARG;
428 nsvariant = create_nsvariant();
429 if(!nsvariant)
430 return E_FAIL;
432 switch(V_VT(&before)) {
433 case VT_EMPTY:
434 case VT_ERROR:
435 nsres = nsIWritableVariant_SetAsEmpty(nsvariant);
436 break;
437 case VT_I2:
438 nsres = nsIWritableVariant_SetAsInt16(nsvariant, V_I2(&before));
439 break;
440 default:
441 FIXME("unhandled before %s\n", debugstr_variant(&before));
442 nsIWritableVariant_Release(nsvariant);
443 return E_NOTIMPL;
446 if(NS_SUCCEEDED(nsres))
447 nsres = nsIDOMHTMLSelectElement_Add(This->nsselect, element_obj->nselem, (nsIVariant*)nsvariant);
448 nsIWritableVariant_Release(nsvariant);
449 if(NS_FAILED(nsres)) {
450 ERR("Add failed: %08x\n", nsres);
451 return E_FAIL;
454 return S_OK;
457 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index)
459 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
460 nsresult nsres;
461 TRACE("(%p)->(%d)\n", This, index);
462 if(index < 0)
463 return E_INVALIDARG;
465 nsres = nsIDOMHTMLSelectElement_select_Remove(This->nsselect, index);
466 if(NS_FAILED(nsres)) {
467 ERR("Remove failed: %08x\n", nsres);
468 return E_FAIL;
470 return S_OK;
473 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, LONG v)
475 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
476 nsresult nsres;
478 TRACE("(%p)->(%d)\n", This, v);
480 nsres = nsIDOMHTMLSelectElement_SetLength(This->nsselect, v);
481 if(NS_FAILED(nsres))
482 ERR("SetLength failed: %08x\n", nsres);
484 return S_OK;
487 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, LONG *p)
489 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
490 UINT32 length = 0;
491 nsresult nsres;
493 TRACE("(%p)->(%p)\n", This, p);
495 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
496 if(NS_FAILED(nsres))
497 ERR("GetLength failed: %08x\n", nsres);
499 *p = length;
501 TRACE("ret %d\n", *p);
502 return S_OK;
505 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
507 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
508 FIXME("(%p)->(%p)\n", This, p);
509 return E_NOTIMPL;
512 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
513 VARIANT index, IDispatch **pdisp)
515 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
517 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
519 if(!pdisp)
520 return E_POINTER;
521 *pdisp = NULL;
523 if(V_VT(&name) == VT_I4) {
524 if(V_I4(&name) < 0)
525 return E_INVALIDARG;
526 return htmlselect_item(This, V_I4(&name), pdisp);
529 FIXME("Unsupported args\n");
530 return E_NOTIMPL;
533 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
534 IDispatch **pdisp)
536 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
537 FIXME("(%p)->(v %p)\n", This, pdisp);
538 return E_NOTIMPL;
541 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
542 HTMLSelectElement_QueryInterface,
543 HTMLSelectElement_AddRef,
544 HTMLSelectElement_Release,
545 HTMLSelectElement_GetTypeInfoCount,
546 HTMLSelectElement_GetTypeInfo,
547 HTMLSelectElement_GetIDsOfNames,
548 HTMLSelectElement_Invoke,
549 HTMLSelectElement_put_size,
550 HTMLSelectElement_get_size,
551 HTMLSelectElement_put_multiple,
552 HTMLSelectElement_get_multiple,
553 HTMLSelectElement_put_name,
554 HTMLSelectElement_get_name,
555 HTMLSelectElement_get_options,
556 HTMLSelectElement_put_onchange,
557 HTMLSelectElement_get_onchange,
558 HTMLSelectElement_put_selectedIndex,
559 HTMLSelectElement_get_selectedIndex,
560 HTMLSelectElement_get_type,
561 HTMLSelectElement_put_value,
562 HTMLSelectElement_get_value,
563 HTMLSelectElement_put_disabled,
564 HTMLSelectElement_get_disabled,
565 HTMLSelectElement_get_form,
566 HTMLSelectElement_add,
567 HTMLSelectElement_remove,
568 HTMLSelectElement_put_length,
569 HTMLSelectElement_get_length,
570 HTMLSelectElement_get__newEnum,
571 HTMLSelectElement_item,
572 HTMLSelectElement_tags
575 static inline HTMLSelectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
577 return CONTAINING_RECORD(iface, HTMLSelectElement, element.node);
580 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
582 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
584 *ppv = NULL;
586 if(IsEqualGUID(&IID_IUnknown, riid)) {
587 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
588 *ppv = &This->IHTMLSelectElement_iface;
589 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
590 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
591 *ppv = &This->IHTMLSelectElement_iface;
592 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
593 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
594 *ppv = &This->IHTMLSelectElement_iface;
597 if(*ppv) {
598 IUnknown_AddRef((IUnknown*)*ppv);
599 return S_OK;
602 return HTMLElement_QI(&This->element.node, riid, ppv);
605 static HRESULT HTMLSelectElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
607 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
608 return IHTMLSelectElement_put_disabled(&This->IHTMLSelectElement_iface, v);
611 static HRESULT HTMLSelectElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
613 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
614 return IHTMLSelectElement_get_disabled(&This->IHTMLSelectElement_iface, p);
617 #define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
619 static HRESULT HTMLSelectElement_get_dispid(HTMLDOMNode *iface, BSTR name, DWORD flags, DISPID *dispid)
621 const WCHAR *ptr;
622 DWORD idx = 0;
624 for(ptr = name; *ptr && isdigitW(*ptr); ptr++) {
625 idx = idx*10 + (*ptr-'0');
626 if(idx > MSHTML_CUSTOM_DISPID_CNT) {
627 WARN("too big idx\n");
628 return DISP_E_UNKNOWNNAME;
631 if(*ptr)
632 return DISP_E_UNKNOWNNAME;
634 *dispid = DISPID_OPTIONCOL_0 + idx;
635 return S_OK;
638 static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
639 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
641 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
643 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
645 switch(flags) {
646 case DISPATCH_PROPERTYGET: {
647 IDispatch *ret;
648 HRESULT hres;
650 hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
651 if(FAILED(hres))
652 return hres;
654 if(ret) {
655 V_VT(res) = VT_DISPATCH;
656 V_DISPATCH(res) = ret;
657 }else {
658 V_VT(res) = VT_NULL;
660 break;
663 default:
664 FIXME("unimplemented flags %x\n", flags);
665 return E_NOTIMPL;
668 return S_OK;
671 static void HTMLSelectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
673 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
675 if(This->nsselect)
676 note_cc_edge((nsISupports*)This->nsselect, "This->nsselect", cb);
679 static void HTMLSelectElement_unlink(HTMLDOMNode *iface)
681 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
683 if(This->nsselect) {
684 nsIDOMHTMLSelectElement *nsselect = This->nsselect;
686 This->nsselect = NULL;
687 nsIDOMHTMLSelectElement_Release(nsselect);
691 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
692 &CLSID_HTMLSelectElement,
693 HTMLSelectElement_QI,
694 HTMLElement_destructor,
695 HTMLElement_cpc,
696 HTMLElement_clone,
697 HTMLElement_handle_event,
698 HTMLElement_get_attr_col,
699 NULL,
700 NULL,
701 HTMLSelectElementImpl_put_disabled,
702 HTMLSelectElementImpl_get_disabled,
703 NULL,
704 NULL,
705 HTMLSelectElement_get_dispid,
706 HTMLSelectElement_invoke,
707 NULL,
708 HTMLSelectElement_traverse,
709 HTMLSelectElement_unlink
712 static const tid_t HTMLSelectElement_tids[] = {
713 HTMLELEMENT_TIDS,
714 IHTMLSelectElement_tid,
718 static dispex_static_data_t HTMLSelectElement_dispex = {
719 NULL,
720 DispHTMLSelectElement_tid,
721 HTMLSelectElement_tids,
722 HTMLElement_init_dispex_info
725 HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
727 HTMLSelectElement *ret;
728 nsresult nsres;
730 ret = heap_alloc_zero(sizeof(HTMLSelectElement));
731 if(!ret)
732 return E_OUTOFMEMORY;
734 ret->IHTMLSelectElement_iface.lpVtbl = &HTMLSelectElementVtbl;
735 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
737 HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
739 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
740 (void**)&ret->nsselect);
741 assert(nsres == NS_OK);
743 *elem = &ret->element;
744 return S_OK;