ucrtbase: Store exception record in ExceptionInformation[6] during unwinding.
[wine.git] / dlls / mshtml / htmlselect.c
blob24affaea4ca8cda10d780236572d07d61e782266
1 /*
2 * Copyright 2006,2007 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 HTMLOptionElement {
36 HTMLElement element;
38 IHTMLOptionElement IHTMLOptionElement_iface;
40 nsIDOMHTMLOptionElement *nsoption;
43 static inline HTMLOptionElement *impl_from_IHTMLOptionElement(IHTMLOptionElement *iface)
45 return CONTAINING_RECORD(iface, HTMLOptionElement, IHTMLOptionElement_iface);
48 DISPEX_IDISPATCH_IMPL(HTMLOptionElement, IHTMLOptionElement,
49 impl_from_IHTMLOptionElement(iface)->element.node.event_target.dispex)
51 static HRESULT WINAPI HTMLOptionElement_put_selected(IHTMLOptionElement *iface, VARIANT_BOOL v)
53 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
54 nsresult nsres;
56 TRACE("(%p)->(%x)\n", This, v);
58 nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, v != VARIANT_FALSE);
59 if(NS_FAILED(nsres)) {
60 ERR("SetSelected failed: %08lx\n", nsres);
61 return E_FAIL;
64 return S_OK;
67 static HRESULT WINAPI HTMLOptionElement_get_selected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
69 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
70 cpp_bool selected;
71 nsresult nsres;
73 TRACE("(%p)->(%p)\n", This, p);
75 nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
76 if(NS_FAILED(nsres)) {
77 ERR("GetSelected failed: %08lx\n", nsres);
78 return E_FAIL;
81 *p = variant_bool(selected);
82 return S_OK;
85 static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BSTR v)
87 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
88 nsAString value_str;
89 nsresult nsres;
91 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
93 nsAString_InitDepend(&value_str, v);
94 nsres = nsIDOMHTMLOptionElement_SetValue(This->nsoption, &value_str);
95 nsAString_Finish(&value_str);
96 if(NS_FAILED(nsres))
97 ERR("SetValue failed: %08lx\n", nsres);
99 return S_OK;
102 static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BSTR *p)
104 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
105 nsAString value_str;
106 nsresult nsres;
108 TRACE("(%p)->(%p)\n", This, p);
110 nsAString_Init(&value_str, NULL);
111 nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str);
112 return return_nsstr(nsres, &value_str, p);
115 static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
117 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
118 cpp_bool val, selected;
119 nsresult nsres;
121 TRACE("(%p)->(%x)\n", This, v);
123 val = (v == VARIANT_TRUE);
125 nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
126 if(NS_FAILED(nsres)) {
127 ERR("GetSelected failed: %08lx\n", nsres);
128 return E_FAIL;
131 nsres = nsIDOMHTMLOptionElement_SetDefaultSelected(This->nsoption, val);
132 if(NS_FAILED(nsres)) {
133 ERR("SetDefaultSelected failed: %08lx\n", nsres);
134 return E_FAIL;
137 if(val != selected) {
138 nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, selected); /* WinAPI will reserve selected property */
139 if(NS_FAILED(nsres)) {
140 ERR("SetSelected failed: %08lx\n", nsres);
141 return E_FAIL;
145 return S_OK;
148 static HRESULT WINAPI HTMLOptionElement_get_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
150 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
151 cpp_bool val;
152 nsresult nsres;
154 TRACE("(%p)->(%p)\n", This, p);
155 if(!p)
156 return E_POINTER;
157 nsres = nsIDOMHTMLOptionElement_GetDefaultSelected(This->nsoption, &val);
158 if(NS_FAILED(nsres)) {
159 ERR("GetDefaultSelected failed: %08lx\n", nsres);
160 return E_FAIL;
163 *p = variant_bool(val);
164 return S_OK;
167 static HRESULT WINAPI HTMLOptionElement_put_index(IHTMLOptionElement *iface, LONG v)
169 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
170 FIXME("(%p)->(%ld)\n", This, v);
171 return E_NOTIMPL;
174 static HRESULT WINAPI HTMLOptionElement_get_index(IHTMLOptionElement *iface, LONG *p)
176 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
177 LONG val;
178 nsresult nsres;
180 TRACE("(%p)->(%p)\n", This, p);
182 if(!p)
183 return E_INVALIDARG;
185 nsres = nsIDOMHTMLOptionElement_GetIndex(This->nsoption, &val);
186 if(NS_FAILED(nsres)) {
187 ERR("GetIndex failed: %08lx\n", nsres);
188 return E_FAIL;
190 *p = val;
191 return S_OK;
194 static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR v)
196 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
197 nsIDOMText *text_node;
198 nsAString text_str;
199 nsIDOMNode *tmp;
200 nsresult nsres;
202 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
204 if(!This->element.node.doc->dom_document) {
205 WARN("NULL dom_document\n");
206 return E_UNEXPECTED;
209 while(1) {
210 nsIDOMNode *child;
212 nsres = nsIDOMElement_GetFirstChild(This->element.dom_element, &child);
213 if(NS_FAILED(nsres) || !child)
214 break;
216 nsres = nsIDOMElement_RemoveChild(This->element.dom_element, child, &tmp);
217 nsIDOMNode_Release(child);
218 if(NS_SUCCEEDED(nsres)) {
219 nsIDOMNode_Release(tmp);
220 }else {
221 ERR("RemoveChild failed: %08lx\n", nsres);
222 break;
226 nsAString_InitDepend(&text_str, v);
227 nsres = nsIDOMDocument_CreateTextNode(This->element.node.doc->dom_document, &text_str, &text_node);
228 nsAString_Finish(&text_str);
229 if(NS_FAILED(nsres)) {
230 ERR("CreateTextNode failed: %08lx\n", nsres);
231 return E_FAIL;
234 nsres = nsIDOMElement_AppendChild(This->element.dom_element, (nsIDOMNode*)text_node, &tmp);
235 nsIDOMText_Release(text_node);
236 if(NS_SUCCEEDED(nsres))
237 nsIDOMNode_Release(tmp);
238 else
239 ERR("AppendChild failed: %08lx\n", nsres);
241 return S_OK;
244 static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR *p)
246 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
247 nsAString text_str;
248 nsresult nsres;
250 TRACE("(%p)->(%p)\n", This, p);
252 nsAString_Init(&text_str, NULL);
253 nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str);
254 return return_nsstr(nsres, &text_str, p);
257 static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)
259 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
260 nsIDOMHTMLFormElement *nsform;
261 nsresult nsres;
263 TRACE("(%p)->(%p)\n", This, p);
265 if(!p)
266 return E_POINTER;
268 nsres = nsIDOMHTMLOptionElement_GetForm(This->nsoption, &nsform);
269 return return_nsform(nsres, nsform, p);
272 static const IHTMLOptionElementVtbl HTMLOptionElementVtbl = {
273 HTMLOptionElement_QueryInterface,
274 HTMLOptionElement_AddRef,
275 HTMLOptionElement_Release,
276 HTMLOptionElement_GetTypeInfoCount,
277 HTMLOptionElement_GetTypeInfo,
278 HTMLOptionElement_GetIDsOfNames,
279 HTMLOptionElement_Invoke,
280 HTMLOptionElement_put_selected,
281 HTMLOptionElement_get_selected,
282 HTMLOptionElement_put_value,
283 HTMLOptionElement_get_value,
284 HTMLOptionElement_put_defaultSelected,
285 HTMLOptionElement_get_defaultSelected,
286 HTMLOptionElement_put_index,
287 HTMLOptionElement_get_index,
288 HTMLOptionElement_put_text,
289 HTMLOptionElement_get_text,
290 HTMLOptionElement_get_form
293 static inline HTMLOptionElement *HTMLOptionElement_from_DispatchEx(DispatchEx *iface)
295 return CONTAINING_RECORD(iface, HTMLOptionElement, element.node.event_target.dispex);
298 static void *HTMLOptionElement_query_interface(DispatchEx *dispex, REFIID riid)
300 HTMLOptionElement *This = HTMLOptionElement_from_DispatchEx(dispex);
302 if(IsEqualGUID(&IID_IHTMLOptionElement, riid))
303 return &This->IHTMLOptionElement_iface;
305 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
308 static void HTMLOptionElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
310 HTMLOptionElement *This = HTMLOptionElement_from_DispatchEx(dispex);
311 HTMLElement_traverse(dispex, cb);
313 if(This->nsoption)
314 note_cc_edge((nsISupports*)This->nsoption, "nsoption", cb);
317 static void HTMLOptionElement_unlink(DispatchEx *dispex)
319 HTMLOptionElement *This = HTMLOptionElement_from_DispatchEx(dispex);
320 HTMLElement_unlink(dispex);
321 unlink_ref(&This->nsoption);
324 static const NodeImplVtbl HTMLOptionElementImplVtbl = {
325 .clsid = &CLSID_HTMLOptionElement,
326 .cpc_entries = HTMLElement_cpc,
327 .clone = HTMLElement_clone,
328 .get_attr_col = HTMLElement_get_attr_col,
331 static const event_target_vtbl_t HTMLOptionElement_event_target_vtbl = {
333 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
334 .query_interface= HTMLOptionElement_query_interface,
335 .destructor = HTMLElement_destructor,
336 .traverse = HTMLOptionElement_traverse,
337 .unlink = HTMLOptionElement_unlink
339 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
340 .handle_event = HTMLElement_handle_event
343 static const tid_t HTMLOptionElement_iface_tids[] = {
344 HTMLELEMENT_TIDS,
345 IHTMLOptionElement_tid,
348 static dispex_static_data_t HTMLOptionElement_dispex = {
349 "HTMLOptionElement",
350 &HTMLOptionElement_event_target_vtbl.dispex_vtbl,
351 DispHTMLOptionElement_tid,
352 HTMLOptionElement_iface_tids,
353 HTMLElement_init_dispex_info
356 HRESULT HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
358 HTMLOptionElement *ret;
359 nsresult nsres;
361 ret = calloc(1, sizeof(HTMLOptionElement));
362 if(!ret)
363 return E_OUTOFMEMORY;
365 ret->IHTMLOptionElement_iface.lpVtbl = &HTMLOptionElementVtbl;
366 ret->element.node.vtbl = &HTMLOptionElementImplVtbl;
368 HTMLElement_Init(&ret->element, doc, nselem, &HTMLOptionElement_dispex);
370 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLOptionElement, (void**)&ret->nsoption);
371 assert(nsres == NS_OK);
373 *elem = &ret->element;
374 return S_OK;
377 static inline HTMLOptionElementFactory *impl_from_IHTMLOptionElementFactory(IHTMLOptionElementFactory *iface)
379 return CONTAINING_RECORD(iface, HTMLOptionElementFactory, IHTMLOptionElementFactory_iface);
382 DISPEX_IDISPATCH_IMPL(HTMLOptionElementFactory, IHTMLOptionElementFactory,
383 impl_from_IHTMLOptionElementFactory(iface)->dispex)
385 static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory *iface,
386 VARIANT text, VARIANT value, VARIANT defaultselected, VARIANT selected,
387 IHTMLOptionElement **optelem)
389 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
390 nsIDOMElement *nselem;
391 HTMLDOMNode *node;
392 HRESULT hres;
394 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
395 debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
397 *optelem = NULL;
399 hres = create_nselem(This->window->doc, L"OPTION", &nselem);
400 if(FAILED(hres))
401 return hres;
403 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
404 nsIDOMElement_Release(nselem);
405 if(FAILED(hres))
406 return hres;
408 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface,
409 &IID_IHTMLOptionElement, (void**)optelem);
410 node_release(node);
412 if(V_VT(&text) == VT_BSTR)
413 IHTMLOptionElement_put_text(*optelem, V_BSTR(&text));
414 else if(V_VT(&text) != VT_EMPTY)
415 FIXME("Unsupported text %s\n", debugstr_variant(&text));
417 if(V_VT(&value) == VT_BSTR)
418 IHTMLOptionElement_put_value(*optelem, V_BSTR(&value));
419 else if(V_VT(&value) != VT_EMPTY)
420 FIXME("Unsupported value %s\n", debugstr_variant(&value));
422 if(V_VT(&defaultselected) != VT_EMPTY)
423 FIXME("Unsupported defaultselected %s\n", debugstr_variant(&defaultselected));
424 if(V_VT(&selected) != VT_EMPTY)
425 FIXME("Unsupported selected %s\n", debugstr_variant(&selected));
427 return S_OK;
430 static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
431 HTMLOptionElementFactory_QueryInterface,
432 HTMLOptionElementFactory_AddRef,
433 HTMLOptionElementFactory_Release,
434 HTMLOptionElementFactory_GetTypeInfoCount,
435 HTMLOptionElementFactory_GetTypeInfo,
436 HTMLOptionElementFactory_GetIDsOfNames,
437 HTMLOptionElementFactory_Invoke,
438 HTMLOptionElementFactory_create
441 static inline HTMLOptionElementFactory *HTMLOptionElementFactory_from_DispatchEx(DispatchEx *iface)
443 return CONTAINING_RECORD(iface, HTMLOptionElementFactory, dispex);
446 static void *HTMLOptionElementFactory_query_interface(DispatchEx *dispex, REFIID riid)
448 HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
450 if(IsEqualGUID(&IID_IHTMLOptionElementFactory, riid))
451 return &This->IHTMLOptionElementFactory_iface;
453 return NULL;
456 static void HTMLOptionElementFactory_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
458 HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
460 if(This->window)
461 note_cc_edge((nsISupports*)&This->window->base.IHTMLWindow2_iface, "window", cb);
464 static void HTMLOptionElementFactory_unlink(DispatchEx *dispex)
466 HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
468 if(This->window) {
469 HTMLInnerWindow *window = This->window;
470 This->window = NULL;
471 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
475 static void HTMLOptionElementFactory_destructor(DispatchEx *dispex)
477 HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
478 free(This);
481 static HRESULT HTMLOptionElementFactory_value(DispatchEx *dispex, LCID lcid,
482 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
483 IServiceProvider *caller)
485 HTMLOptionElementFactory *This = HTMLOptionElementFactory_from_DispatchEx(dispex);
486 unsigned int i, argc = params->cArgs - params->cNamedArgs;
487 IHTMLOptionElement *opt;
488 VARIANT empty, *arg[4];
489 HRESULT hres;
491 if(flags != DISPATCH_CONSTRUCT) {
492 FIXME("flags %x not supported\n", flags);
493 return E_NOTIMPL;
496 V_VT(res) = VT_NULL;
497 V_VT(&empty) = VT_EMPTY;
499 for(i = 0; i < ARRAY_SIZE(arg); i++)
500 arg[i] = argc > i ? &params->rgvarg[params->cArgs - 1 - i] : &empty;
502 hres = IHTMLOptionElementFactory_create(&This->IHTMLOptionElementFactory_iface,
503 *arg[0], *arg[1], *arg[2], *arg[3], &opt);
504 if(FAILED(hres))
505 return hres;
507 V_VT(res) = VT_DISPATCH;
508 V_DISPATCH(res) = (IDispatch*)opt;
510 return S_OK;
513 static const tid_t HTMLOptionElementFactory_iface_tids[] = {
514 IHTMLOptionElementFactory_tid,
518 static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl = {
519 .query_interface = HTMLOptionElementFactory_query_interface,
520 .destructor = HTMLOptionElementFactory_destructor,
521 .traverse = HTMLOptionElementFactory_traverse,
522 .unlink = HTMLOptionElementFactory_unlink,
523 .value = HTMLOptionElementFactory_value,
526 static dispex_static_data_t HTMLOptionElementFactory_dispex = {
527 "Function",
528 &HTMLOptionElementFactory_dispex_vtbl,
529 IHTMLOptionElementFactory_tid,
530 HTMLOptionElementFactory_iface_tids,
533 HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionElementFactory **ret_ptr)
535 HTMLOptionElementFactory *ret;
537 ret = malloc(sizeof(*ret));
538 if(!ret)
539 return E_OUTOFMEMORY;
541 ret->IHTMLOptionElementFactory_iface.lpVtbl = &HTMLOptionElementFactoryVtbl;
542 ret->window = window;
543 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
545 init_dispatch(&ret->dispex, &HTMLOptionElementFactory_dispex, dispex_compat_mode(&window->event_target.dispex));
547 *ret_ptr = ret;
548 return S_OK;
551 struct HTMLSelectElement {
552 HTMLElement element;
554 IHTMLSelectElement IHTMLSelectElement_iface;
556 nsIDOMHTMLSelectElement *nsselect;
559 typedef struct {
560 IEnumVARIANT IEnumVARIANT_iface;
562 LONG ref;
564 ULONG iter;
565 HTMLSelectElement *elem;
566 } HTMLSelectElementEnum;
568 static inline HTMLSelectElement *impl_from_IHTMLSelectElement(IHTMLSelectElement *iface)
570 return CONTAINING_RECORD(iface, HTMLSelectElement, IHTMLSelectElement_iface);
573 static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
575 nsIDOMHTMLOptionsCollection *nscol;
576 nsIDOMNode *nsnode;
577 nsresult nsres;
578 HRESULT hres;
580 nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
581 if(NS_FAILED(nsres)) {
582 ERR("GetOptions failed: %08lx\n", nsres);
583 return E_FAIL;
586 nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
587 nsIDOMHTMLOptionsCollection_Release(nscol);
588 if(NS_FAILED(nsres)) {
589 ERR("Item failed: %08lx\n", nsres);
590 return E_FAIL;
593 if(nsnode) {
594 HTMLDOMNode *node;
596 hres = get_node(nsnode, TRUE, &node);
597 nsIDOMNode_Release(nsnode);
598 if(FAILED(hres))
599 return hres;
601 *ret = (IDispatch*)&node->IHTMLDOMNode_iface;
602 }else {
603 *ret = NULL;
605 return S_OK;
608 static inline HTMLSelectElementEnum *impl_from_IEnumVARIANT(IEnumVARIANT *iface)
610 return CONTAINING_RECORD(iface, HTMLSelectElementEnum, IEnumVARIANT_iface);
613 static HRESULT WINAPI HTMLSelectElementEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
615 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
617 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
619 if(IsEqualGUID(riid, &IID_IUnknown)) {
620 *ppv = &This->IEnumVARIANT_iface;
621 }else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
622 *ppv = &This->IEnumVARIANT_iface;
623 }else {
624 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
625 *ppv = NULL;
626 return E_NOINTERFACE;
629 IUnknown_AddRef((IUnknown*)*ppv);
630 return S_OK;
633 static ULONG WINAPI HTMLSelectElementEnum_AddRef(IEnumVARIANT *iface)
635 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
636 LONG ref = InterlockedIncrement(&This->ref);
638 TRACE("(%p) ref=%ld\n", This, ref);
640 return ref;
643 static ULONG WINAPI HTMLSelectElementEnum_Release(IEnumVARIANT *iface)
645 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
646 LONG ref = InterlockedDecrement(&This->ref);
648 TRACE("(%p) ref=%ld\n", This, ref);
650 if(!ref) {
651 IHTMLSelectElement_Release(&This->elem->IHTMLSelectElement_iface);
652 free(This);
655 return ref;
658 static HRESULT WINAPI HTMLSelectElementEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
660 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
661 nsresult nsres;
662 HRESULT hres;
663 ULONG num, i;
664 UINT32 len;
666 TRACE("(%p)->(%lu %p %p)\n", This, celt, rgVar, pCeltFetched);
668 nsres = nsIDOMHTMLSelectElement_GetLength(This->elem->nsselect, &len);
669 if(NS_FAILED(nsres))
670 return E_FAIL;
671 num = min(len - This->iter, celt);
673 for(i = 0; i < num; i++) {
674 hres = htmlselect_item(This->elem, This->iter + i, &V_DISPATCH(&rgVar[i]));
675 if(FAILED(hres)) {
676 while(i--)
677 VariantClear(&rgVar[i]);
678 return hres;
680 V_VT(&rgVar[i]) = VT_DISPATCH;
683 This->iter += num;
684 if(pCeltFetched)
685 *pCeltFetched = num;
686 return num == celt ? S_OK : S_FALSE;
689 static HRESULT WINAPI HTMLSelectElementEnum_Skip(IEnumVARIANT *iface, ULONG celt)
691 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
692 nsresult nsres;
693 UINT32 len;
695 TRACE("(%p)->(%lu)\n", This, celt);
697 nsres = nsIDOMHTMLSelectElement_GetLength(This->elem->nsselect, &len);
698 if(NS_FAILED(nsres))
699 return E_FAIL;
701 if(This->iter + celt > len) {
702 This->iter = len;
703 return S_FALSE;
706 This->iter += celt;
707 return S_OK;
710 static HRESULT WINAPI HTMLSelectElementEnum_Reset(IEnumVARIANT *iface)
712 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
714 TRACE("(%p)->()\n", This);
716 This->iter = 0;
717 return S_OK;
720 static HRESULT WINAPI HTMLSelectElementEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
722 HTMLSelectElementEnum *This = impl_from_IEnumVARIANT(iface);
723 FIXME("(%p)->(%p)\n", This, ppEnum);
724 return E_NOTIMPL;
727 static const IEnumVARIANTVtbl HTMLSelectElementEnumVtbl = {
728 HTMLSelectElementEnum_QueryInterface,
729 HTMLSelectElementEnum_AddRef,
730 HTMLSelectElementEnum_Release,
731 HTMLSelectElementEnum_Next,
732 HTMLSelectElementEnum_Skip,
733 HTMLSelectElementEnum_Reset,
734 HTMLSelectElementEnum_Clone
737 DISPEX_IDISPATCH_IMPL(HTMLSelectElement, IHTMLSelectElement,
738 impl_from_IHTMLSelectElement(iface)->element.node.event_target.dispex)
740 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, LONG v)
742 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
743 nsresult nsres;
745 TRACE("(%p)->(%ld)\n", This, v);
746 if(v < 0)
747 return CTL_E_INVALIDPROPERTYVALUE;
749 nsres = nsIDOMHTMLSelectElement_SetSize(This->nsselect, v);
750 if(NS_FAILED(nsres)) {
751 ERR("SetSize failed: %08lx\n", nsres);
752 return E_FAIL;
754 return S_OK;
757 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, LONG *p)
759 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
760 UINT32 val;
761 nsresult nsres;
763 TRACE("(%p)->(%p)\n", This, p);
764 if(!p)
765 return E_INVALIDARG;
767 nsres = nsIDOMHTMLSelectElement_GetSize(This->nsselect, &val);
768 if(NS_FAILED(nsres)) {
769 ERR("GetSize failed: %08lx\n", nsres);
770 return E_FAIL;
772 *p = val;
773 return S_OK;
776 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
778 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
779 nsresult nsres;
781 TRACE("(%p)->(%x)\n", This, v);
783 nsres = nsIDOMHTMLSelectElement_SetMultiple(This->nsselect, !!v);
784 assert(nsres == NS_OK);
785 return S_OK;
788 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
790 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
791 cpp_bool val;
792 nsresult nsres;
794 TRACE("(%p)->(%p)\n", This, p);
796 nsres = nsIDOMHTMLSelectElement_GetMultiple(This->nsselect, &val);
797 assert(nsres == NS_OK);
799 *p = variant_bool(val);
800 return S_OK;
803 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
805 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
806 nsAString str;
807 nsresult nsres;
809 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
810 nsAString_InitDepend(&str, v);
811 nsres = nsIDOMHTMLSelectElement_SetName(This->nsselect, &str);
812 nsAString_Finish(&str);
814 if(NS_FAILED(nsres)) {
815 ERR("SetName failed: %08lx\n", nsres);
816 return E_FAIL;
818 return S_OK;
821 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
823 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
824 nsAString name_str;
825 nsresult nsres;
827 TRACE("(%p)->(%p)\n", This, p);
829 nsAString_Init(&name_str, NULL);
830 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
832 return return_nsstr(nsres, &name_str, p);
835 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
837 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
839 TRACE("(%p)->(%p)\n", This, p);
841 *p = (IDispatch*)&This->IHTMLSelectElement_iface;
842 IDispatch_AddRef(*p);
843 return S_OK;
846 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
848 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
850 TRACE("(%p)->()\n", This);
852 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
855 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
857 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
858 FIXME("(%p)->(%p)\n", This, p);
859 return E_NOTIMPL;
862 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, LONG v)
864 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
865 nsresult nsres;
867 TRACE("(%p)->(%ld)\n", This, v);
869 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
870 if(NS_FAILED(nsres))
871 ERR("SetSelectedIndex failed: %08lx\n", nsres);
873 return S_OK;
876 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, LONG *p)
878 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
879 nsresult nsres;
881 TRACE("(%p)->(%p)\n", This, p);
883 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, p);
884 if(NS_FAILED(nsres)) {
885 ERR("GetSelectedIndex failed: %08lx\n", nsres);
886 return E_FAIL;
889 return S_OK;
892 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
894 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
895 nsAString type_str;
896 nsresult nsres;
898 TRACE("(%p)->(%p)\n", This, p);
900 nsAString_Init(&type_str, NULL);
901 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
902 return return_nsstr(nsres, &type_str, p);
905 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
907 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
908 nsAString value_str;
909 nsresult nsres;
911 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
913 nsAString_InitDepend(&value_str, v);
914 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
915 nsAString_Finish(&value_str);
916 if(NS_FAILED(nsres))
917 ERR("SetValue failed: %08lx\n", nsres);
919 return S_OK;
922 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
924 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
925 nsAString value_str;
926 nsresult nsres;
928 TRACE("(%p)->(%p)\n", This, p);
930 nsAString_Init(&value_str, NULL);
931 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
932 return return_nsstr(nsres, &value_str, p);
935 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
937 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
938 nsresult nsres;
940 TRACE("(%p)->(%x)\n", This, v);
942 nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
943 if(NS_FAILED(nsres)) {
944 ERR("SetDisabled failed: %08lx\n", nsres);
945 return E_FAIL;
948 return S_OK;
951 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
953 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
954 cpp_bool disabled = FALSE;
955 nsresult nsres;
957 TRACE("(%p)->(%p)\n", This, p);
959 nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
960 if(NS_FAILED(nsres)) {
961 ERR("GetDisabled failed: %08lx\n", nsres);
962 return E_FAIL;
965 *p = variant_bool(disabled);
966 return S_OK;
969 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
971 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
972 nsIDOMHTMLFormElement *nsform;
973 nsresult nsres;
975 TRACE("(%p)->(%p)\n", This, p);
977 if(!p)
978 return E_POINTER;
980 nsres = nsIDOMHTMLSelectElement_GetForm(This->nsselect, &nsform);
981 return return_nsform(nsres, nsform, p);
984 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
985 VARIANT before)
987 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
988 nsIWritableVariant *nsvariant;
989 HTMLElement *element_obj;
990 nsresult nsres;
992 TRACE("(%p)->(%p %s)\n", This, element, debugstr_variant(&before));
994 element_obj = unsafe_impl_from_IHTMLElement(element);
995 if(!element_obj) {
996 FIXME("External IHTMLElement implementation?\n");
997 return E_INVALIDARG;
1000 if(!element_obj->html_element) {
1001 FIXME("Not HTML element\n");
1002 return E_NOTIMPL;
1005 nsvariant = create_nsvariant();
1006 if(!nsvariant)
1007 return E_FAIL;
1009 switch(V_VT(&before)) {
1010 case VT_EMPTY:
1011 case VT_ERROR:
1012 nsres = nsIWritableVariant_SetAsEmpty(nsvariant);
1013 break;
1014 case VT_I2:
1015 nsres = nsIWritableVariant_SetAsInt16(nsvariant, V_I2(&before));
1016 break;
1017 default:
1018 FIXME("unhandled before %s\n", debugstr_variant(&before));
1019 nsIWritableVariant_Release(nsvariant);
1020 return E_NOTIMPL;
1023 if(NS_SUCCEEDED(nsres))
1024 nsres = nsIDOMHTMLSelectElement_Add(This->nsselect, element_obj->html_element, (nsIVariant*)nsvariant);
1025 nsIWritableVariant_Release(nsvariant);
1026 if(NS_FAILED(nsres)) {
1027 ERR("Add failed: %08lx\n", nsres);
1028 return E_FAIL;
1031 return S_OK;
1034 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index)
1036 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1037 nsresult nsres;
1038 TRACE("(%p)->(%ld)\n", This, index);
1039 if(index < 0)
1040 return E_INVALIDARG;
1042 nsres = nsIDOMHTMLSelectElement_select_Remove(This->nsselect, index);
1043 if(NS_FAILED(nsres)) {
1044 ERR("Remove failed: %08lx\n", nsres);
1045 return E_FAIL;
1047 return S_OK;
1050 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, LONG v)
1052 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1053 nsresult nsres;
1055 TRACE("(%p)->(%ld)\n", This, v);
1057 nsres = nsIDOMHTMLSelectElement_SetLength(This->nsselect, v);
1058 if(NS_FAILED(nsres))
1059 ERR("SetLength failed: %08lx\n", nsres);
1061 return S_OK;
1064 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, LONG *p)
1066 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1067 UINT32 length = 0;
1068 nsresult nsres;
1070 TRACE("(%p)->(%p)\n", This, p);
1072 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
1073 if(NS_FAILED(nsres))
1074 ERR("GetLength failed: %08lx\n", nsres);
1076 *p = length;
1078 TRACE("ret %ld\n", *p);
1079 return S_OK;
1082 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
1084 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1085 HTMLSelectElementEnum *ret;
1087 TRACE("(%p)->(%p)\n", This, p);
1089 ret = malloc(sizeof(*ret));
1090 if(!ret)
1091 return E_OUTOFMEMORY;
1093 ret->IEnumVARIANT_iface.lpVtbl = &HTMLSelectElementEnumVtbl;
1094 ret->ref = 1;
1095 ret->iter = 0;
1097 HTMLSelectElement_AddRef(&This->IHTMLSelectElement_iface);
1098 ret->elem = This;
1100 *p = (IUnknown*)&ret->IEnumVARIANT_iface;
1101 return S_OK;
1104 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
1105 VARIANT index, IDispatch **pdisp)
1107 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1109 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
1111 if(!pdisp)
1112 return E_POINTER;
1113 *pdisp = NULL;
1115 if(V_VT(&name) == VT_I4) {
1116 if(V_I4(&name) < 0)
1117 return E_INVALIDARG;
1118 return htmlselect_item(This, V_I4(&name), pdisp);
1121 FIXME("Unsupported args\n");
1122 return E_NOTIMPL;
1125 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
1126 IDispatch **pdisp)
1128 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1129 FIXME("(%p)->(v %p)\n", This, pdisp);
1130 return E_NOTIMPL;
1133 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
1134 HTMLSelectElement_QueryInterface,
1135 HTMLSelectElement_AddRef,
1136 HTMLSelectElement_Release,
1137 HTMLSelectElement_GetTypeInfoCount,
1138 HTMLSelectElement_GetTypeInfo,
1139 HTMLSelectElement_GetIDsOfNames,
1140 HTMLSelectElement_Invoke,
1141 HTMLSelectElement_put_size,
1142 HTMLSelectElement_get_size,
1143 HTMLSelectElement_put_multiple,
1144 HTMLSelectElement_get_multiple,
1145 HTMLSelectElement_put_name,
1146 HTMLSelectElement_get_name,
1147 HTMLSelectElement_get_options,
1148 HTMLSelectElement_put_onchange,
1149 HTMLSelectElement_get_onchange,
1150 HTMLSelectElement_put_selectedIndex,
1151 HTMLSelectElement_get_selectedIndex,
1152 HTMLSelectElement_get_type,
1153 HTMLSelectElement_put_value,
1154 HTMLSelectElement_get_value,
1155 HTMLSelectElement_put_disabled,
1156 HTMLSelectElement_get_disabled,
1157 HTMLSelectElement_get_form,
1158 HTMLSelectElement_add,
1159 HTMLSelectElement_remove,
1160 HTMLSelectElement_put_length,
1161 HTMLSelectElement_get_length,
1162 HTMLSelectElement_get__newEnum,
1163 HTMLSelectElement_item,
1164 HTMLSelectElement_tags
1167 static inline HTMLSelectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1169 return CONTAINING_RECORD(iface, HTMLSelectElement, element.node);
1172 static HRESULT HTMLSelectElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
1174 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1175 return IHTMLSelectElement_put_disabled(&This->IHTMLSelectElement_iface, v);
1178 static HRESULT HTMLSelectElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
1180 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1181 return IHTMLSelectElement_get_disabled(&This->IHTMLSelectElement_iface, p);
1184 static inline HTMLSelectElement *impl_from_DispatchEx(DispatchEx *iface)
1186 return CONTAINING_RECORD(iface, HTMLSelectElement, element.node.event_target.dispex);
1189 static void *HTMLSelectElement_query_interface(DispatchEx *dispex, REFIID riid)
1191 HTMLSelectElement *This = impl_from_DispatchEx(dispex);
1193 if(IsEqualGUID(&IID_IHTMLSelectElement, riid))
1194 return &This->IHTMLSelectElement_iface;
1196 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
1199 static void HTMLSelectElement_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
1201 HTMLSelectElement *This = impl_from_DispatchEx(dispex);
1202 HTMLElement_traverse(dispex, cb);
1204 if(This->nsselect)
1205 note_cc_edge((nsISupports*)This->nsselect, "nsselect", cb);
1208 static void HTMLSelectElement_unlink(DispatchEx *dispex)
1210 HTMLSelectElement *This = impl_from_DispatchEx(dispex);
1211 HTMLElement_unlink(dispex);
1212 unlink_ref(&This->nsselect);
1215 #define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
1217 static HRESULT HTMLSelectElement_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
1219 const WCHAR *ptr;
1220 DWORD idx = 0;
1222 for(ptr = name; *ptr && is_digit(*ptr); ptr++) {
1223 idx = idx*10 + (*ptr-'0');
1224 if(idx > MSHTML_CUSTOM_DISPID_CNT) {
1225 WARN("too big idx\n");
1226 return DISP_E_UNKNOWNNAME;
1229 if(*ptr)
1230 return DISP_E_UNKNOWNNAME;
1232 *dispid = DISPID_OPTIONCOL_0 + idx;
1233 return S_OK;
1236 static HRESULT HTMLSelectElement_dispex_get_name(DispatchEx *dispex, DISPID id, BSTR *name)
1238 DWORD idx = id - DISPID_OPTIONCOL_0;
1239 WCHAR buf[11];
1240 UINT len;
1242 if(idx > MSHTML_CUSTOM_DISPID_CNT)
1243 return DISP_E_MEMBERNOTFOUND;
1245 len = swprintf(buf, ARRAY_SIZE(buf), L"%u", idx);
1246 return (*name = SysAllocStringLen(buf, len)) ? S_OK : E_OUTOFMEMORY;
1249 static HRESULT HTMLSelectElement_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1250 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1252 HTMLSelectElement *This = impl_from_DispatchEx(dispex);
1254 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1256 switch(flags) {
1257 case DISPATCH_PROPERTYGET: {
1258 IDispatch *ret;
1259 HRESULT hres;
1261 hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
1262 if(FAILED(hres))
1263 return hres;
1265 if(ret) {
1266 V_VT(res) = VT_DISPATCH;
1267 V_DISPATCH(res) = ret;
1268 }else {
1269 V_VT(res) = VT_NULL;
1271 break;
1274 default:
1275 FIXME("unimplemented flags %x\n", flags);
1276 return E_NOTIMPL;
1279 return S_OK;
1282 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
1283 .clsid = &CLSID_HTMLSelectElement,
1284 .cpc_entries = HTMLElement_cpc,
1285 .clone = HTMLElement_clone,
1286 .get_attr_col = HTMLElement_get_attr_col,
1287 .put_disabled = HTMLSelectElementImpl_put_disabled,
1288 .get_disabled = HTMLSelectElementImpl_get_disabled,
1291 static const event_target_vtbl_t HTMLSelectElement_event_target_vtbl = {
1293 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
1294 .query_interface= HTMLSelectElement_query_interface,
1295 .destructor = HTMLElement_destructor,
1296 .traverse = HTMLSelectElement_traverse,
1297 .unlink = HTMLSelectElement_unlink,
1298 .get_dispid = HTMLSelectElement_get_dispid,
1299 .get_name = HTMLSelectElement_dispex_get_name,
1300 .invoke = HTMLSelectElement_invoke
1302 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
1303 .handle_event = HTMLElement_handle_event
1306 static const tid_t HTMLSelectElement_tids[] = {
1307 HTMLELEMENT_TIDS,
1308 IHTMLSelectElement_tid,
1312 static dispex_static_data_t HTMLSelectElement_dispex = {
1313 "HTMLSelectElement",
1314 &HTMLSelectElement_event_target_vtbl.dispex_vtbl,
1315 DispHTMLSelectElement_tid,
1316 HTMLSelectElement_tids,
1317 HTMLElement_init_dispex_info
1320 HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1322 HTMLSelectElement *ret;
1323 nsresult nsres;
1325 ret = calloc(1, sizeof(HTMLSelectElement));
1326 if(!ret)
1327 return E_OUTOFMEMORY;
1329 ret->IHTMLSelectElement_iface.lpVtbl = &HTMLSelectElementVtbl;
1330 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
1332 HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
1334 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement, (void**)&ret->nsselect);
1335 assert(nsres == NS_OK);
1337 *elem = &ret->element;
1338 return S_OK;