shell32/autocomplete: Remove the property after replacing the callback instead of...
[wine.git] / dlls / mshtml / htmlselect.c
blob47325aea3126cba28fa082f08742cc5d2324b84c
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>
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 HTMLOptionElement {
37 HTMLElement element;
39 IHTMLOptionElement IHTMLOptionElement_iface;
41 nsIDOMHTMLOptionElement *nsoption;
44 static inline HTMLOptionElement *impl_from_IHTMLOptionElement(IHTMLOptionElement *iface)
46 return CONTAINING_RECORD(iface, HTMLOptionElement, IHTMLOptionElement_iface);
49 static HRESULT WINAPI HTMLOptionElement_QueryInterface(IHTMLOptionElement *iface,
50 REFIID riid, void **ppv)
52 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
54 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
57 static ULONG WINAPI HTMLOptionElement_AddRef(IHTMLOptionElement *iface)
59 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
61 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
64 static ULONG WINAPI HTMLOptionElement_Release(IHTMLOptionElement *iface)
66 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
68 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
71 static HRESULT WINAPI HTMLOptionElement_GetTypeInfoCount(IHTMLOptionElement *iface, UINT *pctinfo)
73 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
74 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
77 static HRESULT WINAPI HTMLOptionElement_GetTypeInfo(IHTMLOptionElement *iface, UINT iTInfo,
78 LCID lcid, ITypeInfo **ppTInfo)
80 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
81 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
82 ppTInfo);
85 static HRESULT WINAPI HTMLOptionElement_GetIDsOfNames(IHTMLOptionElement *iface, REFIID riid,
86 LPOLESTR *rgszNames, UINT cNames,
87 LCID lcid, DISPID *rgDispId)
89 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
90 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
91 cNames, lcid, rgDispId);
94 static HRESULT WINAPI HTMLOptionElement_Invoke(IHTMLOptionElement *iface, DISPID dispIdMember,
95 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
96 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
98 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
99 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
100 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
103 static HRESULT WINAPI HTMLOptionElement_put_selected(IHTMLOptionElement *iface, VARIANT_BOOL v)
105 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
106 nsresult nsres;
108 TRACE("(%p)->(%x)\n", This, v);
110 nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, v != VARIANT_FALSE);
111 if(NS_FAILED(nsres)) {
112 ERR("SetSelected failed: %08x\n", nsres);
113 return E_FAIL;
116 return S_OK;
119 static HRESULT WINAPI HTMLOptionElement_get_selected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
121 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
122 cpp_bool selected;
123 nsresult nsres;
125 TRACE("(%p)->(%p)\n", This, p);
127 nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
128 if(NS_FAILED(nsres)) {
129 ERR("GetSelected failed: %08x\n", nsres);
130 return E_FAIL;
133 *p = variant_bool(selected);
134 return S_OK;
137 static HRESULT WINAPI HTMLOptionElement_put_value(IHTMLOptionElement *iface, BSTR v)
139 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
140 nsAString value_str;
141 nsresult nsres;
143 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
145 nsAString_InitDepend(&value_str, v);
146 nsres = nsIDOMHTMLOptionElement_SetValue(This->nsoption, &value_str);
147 nsAString_Finish(&value_str);
148 if(NS_FAILED(nsres))
149 ERR("SetValue failed: %08x\n", nsres);
151 return S_OK;
154 static HRESULT WINAPI HTMLOptionElement_get_value(IHTMLOptionElement *iface, BSTR *p)
156 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
157 nsAString value_str;
158 nsresult nsres;
160 TRACE("(%p)->(%p)\n", This, p);
162 nsAString_Init(&value_str, NULL);
163 nsres = nsIDOMHTMLOptionElement_GetValue(This->nsoption, &value_str);
164 return return_nsstr(nsres, &value_str, p);
167 static HRESULT WINAPI HTMLOptionElement_put_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL v)
169 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
170 cpp_bool val, selected;
171 nsresult nsres;
173 TRACE("(%p)->(%x)\n", This, v);
175 val = (v == VARIANT_TRUE);
177 nsres = nsIDOMHTMLOptionElement_GetSelected(This->nsoption, &selected);
178 if(NS_FAILED(nsres)) {
179 ERR("GetSelected failed: %08x\n", nsres);
180 return E_FAIL;
183 nsres = nsIDOMHTMLOptionElement_SetDefaultSelected(This->nsoption, val);
184 if(NS_FAILED(nsres)) {
185 ERR("SetDefaultSelected failed: %08x\n", nsres);
186 return E_FAIL;
189 if(val != selected) {
190 nsres = nsIDOMHTMLOptionElement_SetSelected(This->nsoption, selected); /* WinAPI will reserve selected property */
191 if(NS_FAILED(nsres)) {
192 ERR("SetSelected failed: %08x\n", nsres);
193 return E_FAIL;
197 return S_OK;
200 static HRESULT WINAPI HTMLOptionElement_get_defaultSelected(IHTMLOptionElement *iface, VARIANT_BOOL *p)
202 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
203 cpp_bool val;
204 nsresult nsres;
206 TRACE("(%p)->(%p)\n", This, p);
207 if(!p)
208 return E_POINTER;
209 nsres = nsIDOMHTMLOptionElement_GetDefaultSelected(This->nsoption, &val);
210 if(NS_FAILED(nsres)) {
211 ERR("GetDefaultSelected failed: %08x\n", nsres);
212 return E_FAIL;
215 *p = variant_bool(val);
216 return S_OK;
219 static HRESULT WINAPI HTMLOptionElement_put_index(IHTMLOptionElement *iface, LONG v)
221 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
222 FIXME("(%p)->(%d)\n", This, v);
223 return E_NOTIMPL;
226 static HRESULT WINAPI HTMLOptionElement_get_index(IHTMLOptionElement *iface, LONG *p)
228 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
229 LONG val;
230 nsresult nsres;
232 TRACE("(%p)->(%p)\n", This, p);
234 if(!p)
235 return E_INVALIDARG;
237 nsres = nsIDOMHTMLOptionElement_GetIndex(This->nsoption, &val);
238 if(NS_FAILED(nsres)) {
239 ERR("GetIndex failed: %08x\n", nsres);
240 return E_FAIL;
242 *p = val;
243 return S_OK;
246 static HRESULT WINAPI HTMLOptionElement_put_text(IHTMLOptionElement *iface, BSTR v)
248 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
249 nsIDOMText *text_node;
250 nsAString text_str;
251 nsIDOMNode *tmp;
252 nsresult nsres;
254 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
256 if(!This->element.node.doc->nsdoc) {
257 WARN("NULL nsdoc\n");
258 return E_UNEXPECTED;
261 while(1) {
262 nsIDOMNode *child;
264 nsres = nsIDOMElement_GetFirstChild(This->element.dom_element, &child);
265 if(NS_FAILED(nsres) || !child)
266 break;
268 nsres = nsIDOMElement_RemoveChild(This->element.dom_element, child, &tmp);
269 nsIDOMNode_Release(child);
270 if(NS_SUCCEEDED(nsres)) {
271 nsIDOMNode_Release(tmp);
272 }else {
273 ERR("RemoveChild failed: %08x\n", nsres);
274 break;
278 nsAString_InitDepend(&text_str, v);
279 nsres = nsIDOMHTMLDocument_CreateTextNode(This->element.node.doc->nsdoc, &text_str, &text_node);
280 nsAString_Finish(&text_str);
281 if(NS_FAILED(nsres)) {
282 ERR("CreateTextNode failed: %08x\n", nsres);
283 return E_FAIL;
286 nsres = nsIDOMElement_AppendChild(This->element.dom_element, (nsIDOMNode*)text_node, &tmp);
287 if(NS_SUCCEEDED(nsres))
288 nsIDOMNode_Release(tmp);
289 else
290 ERR("AppendChild failed: %08x\n", nsres);
292 return S_OK;
295 static HRESULT WINAPI HTMLOptionElement_get_text(IHTMLOptionElement *iface, BSTR *p)
297 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
298 nsAString text_str;
299 nsresult nsres;
301 TRACE("(%p)->(%p)\n", This, p);
303 nsAString_Init(&text_str, NULL);
304 nsres = nsIDOMHTMLOptionElement_GetText(This->nsoption, &text_str);
305 return return_nsstr(nsres, &text_str, p);
308 static HRESULT WINAPI HTMLOptionElement_get_form(IHTMLOptionElement *iface, IHTMLFormElement **p)
310 HTMLOptionElement *This = impl_from_IHTMLOptionElement(iface);
311 nsIDOMHTMLFormElement *nsform;
312 nsresult nsres;
314 TRACE("(%p)->(%p)\n", This, p);
316 if(!p)
317 return E_POINTER;
319 nsres = nsIDOMHTMLOptionElement_GetForm(This->nsoption, &nsform);
320 return return_nsform(nsres, nsform, p);
323 static const IHTMLOptionElementVtbl HTMLOptionElementVtbl = {
324 HTMLOptionElement_QueryInterface,
325 HTMLOptionElement_AddRef,
326 HTMLOptionElement_Release,
327 HTMLOptionElement_GetTypeInfoCount,
328 HTMLOptionElement_GetTypeInfo,
329 HTMLOptionElement_GetIDsOfNames,
330 HTMLOptionElement_Invoke,
331 HTMLOptionElement_put_selected,
332 HTMLOptionElement_get_selected,
333 HTMLOptionElement_put_value,
334 HTMLOptionElement_get_value,
335 HTMLOptionElement_put_defaultSelected,
336 HTMLOptionElement_get_defaultSelected,
337 HTMLOptionElement_put_index,
338 HTMLOptionElement_get_index,
339 HTMLOptionElement_put_text,
340 HTMLOptionElement_get_text,
341 HTMLOptionElement_get_form
344 static inline HTMLOptionElement *HTMLOptionElement_from_HTMLDOMNode(HTMLDOMNode *iface)
346 return CONTAINING_RECORD(iface, HTMLOptionElement, element.node);
349 static HRESULT HTMLOptionElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
351 HTMLOptionElement *This = HTMLOptionElement_from_HTMLDOMNode(iface);
353 *ppv = NULL;
355 if(IsEqualGUID(&IID_IUnknown, riid)) {
356 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
357 *ppv = &This->IHTMLOptionElement_iface;
358 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
359 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
360 *ppv = &This->IHTMLOptionElement_iface;
361 }else if(IsEqualGUID(&IID_IHTMLOptionElement, riid)) {
362 TRACE("(%p)->(IID_IHTMLOptionElement %p)\n", This, ppv);
363 *ppv = &This->IHTMLOptionElement_iface;
366 if(*ppv) {
367 IUnknown_AddRef((IUnknown*)*ppv);
368 return S_OK;
371 return HTMLElement_QI(&This->element.node, riid, ppv);
374 static void HTMLOptionElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
376 HTMLOptionElement *This = HTMLOptionElement_from_HTMLDOMNode(iface);
378 if(This->nsoption)
379 note_cc_edge((nsISupports*)This->nsoption, "This->nsoption", cb);
382 static void HTMLOptionElement_unlink(HTMLDOMNode *iface)
384 HTMLOptionElement *This = HTMLOptionElement_from_HTMLDOMNode(iface);
386 if(This->nsoption) {
387 nsIDOMHTMLOptionElement *nsoption = This->nsoption;
389 This->nsoption = NULL;
390 nsIDOMHTMLOptionElement_Release(nsoption);
394 static const NodeImplVtbl HTMLOptionElementImplVtbl = {
395 &CLSID_HTMLOptionElement,
396 HTMLOptionElement_QI,
397 HTMLElement_destructor,
398 HTMLElement_cpc,
399 HTMLElement_clone,
400 HTMLElement_handle_event,
401 HTMLElement_get_attr_col,
402 NULL,
403 NULL,
404 NULL,
405 NULL,
406 NULL,
407 NULL,
408 NULL,
409 NULL,
410 HTMLOptionElement_traverse,
411 HTMLOptionElement_unlink
414 static const tid_t HTMLOptionElement_iface_tids[] = {
415 HTMLELEMENT_TIDS,
416 IHTMLOptionElement_tid,
419 static dispex_static_data_t HTMLOptionElement_dispex = {
420 NULL,
421 DispHTMLOptionElement_tid,
422 HTMLOptionElement_iface_tids,
423 HTMLElement_init_dispex_info
426 HRESULT HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
428 HTMLOptionElement *ret;
429 nsresult nsres;
431 ret = heap_alloc_zero(sizeof(HTMLOptionElement));
432 if(!ret)
433 return E_OUTOFMEMORY;
435 ret->IHTMLOptionElement_iface.lpVtbl = &HTMLOptionElementVtbl;
436 ret->element.node.vtbl = &HTMLOptionElementImplVtbl;
438 HTMLElement_Init(&ret->element, doc, nselem, &HTMLOptionElement_dispex);
440 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLOptionElement, (void**)&ret->nsoption);
441 assert(nsres == NS_OK);
443 *elem = &ret->element;
444 return S_OK;
447 static inline HTMLOptionElementFactory *impl_from_IHTMLOptionElementFactory(IHTMLOptionElementFactory *iface)
449 return CONTAINING_RECORD(iface, HTMLOptionElementFactory, IHTMLOptionElementFactory_iface);
452 static HRESULT WINAPI HTMLOptionElementFactory_QueryInterface(IHTMLOptionElementFactory *iface,
453 REFIID riid, void **ppv)
455 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
457 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
459 if(IsEqualGUID(&IID_IUnknown, riid)) {
460 *ppv = &This->IHTMLOptionElementFactory_iface;
461 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
462 *ppv = &This->IHTMLOptionElementFactory_iface;
463 }else if(IsEqualGUID(&IID_IHTMLOptionElementFactory, riid)) {
464 *ppv = &This->IHTMLOptionElementFactory_iface;
465 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
466 return *ppv ? S_OK : E_NOINTERFACE;
467 }else {
468 *ppv = NULL;
469 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
470 return E_NOINTERFACE;
473 IUnknown_AddRef((IUnknown*)*ppv);
474 return S_OK;
477 static ULONG WINAPI HTMLOptionElementFactory_AddRef(IHTMLOptionElementFactory *iface)
479 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
480 LONG ref = InterlockedIncrement(&This->ref);
482 TRACE("(%p) ref=%d\n", This, ref);
484 return ref;
487 static ULONG WINAPI HTMLOptionElementFactory_Release(IHTMLOptionElementFactory *iface)
489 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
490 LONG ref = InterlockedDecrement(&This->ref);
492 TRACE("(%p) ref=%d\n", This, ref);
494 if(!ref) {
495 release_dispex(&This->dispex);
496 heap_free(This);
499 return ref;
502 static HRESULT WINAPI HTMLOptionElementFactory_GetTypeInfoCount(IHTMLOptionElementFactory *iface, UINT *pctinfo)
504 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
505 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
508 static HRESULT WINAPI HTMLOptionElementFactory_GetTypeInfo(IHTMLOptionElementFactory *iface, UINT iTInfo,
509 LCID lcid, ITypeInfo **ppTInfo)
511 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
512 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
515 static HRESULT WINAPI HTMLOptionElementFactory_GetIDsOfNames(IHTMLOptionElementFactory *iface, REFIID riid,
516 LPOLESTR *rgszNames, UINT cNames,
517 LCID lcid, DISPID *rgDispId)
519 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
520 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
523 static HRESULT WINAPI HTMLOptionElementFactory_Invoke(IHTMLOptionElementFactory *iface, DISPID dispIdMember,
524 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
525 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
527 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
528 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
529 pVarResult, pExcepInfo, puArgErr);
532 static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory *iface,
533 VARIANT text, VARIANT value, VARIANT defaultselected, VARIANT selected,
534 IHTMLOptionElement **optelem)
536 HTMLOptionElementFactory *This = impl_from_IHTMLOptionElementFactory(iface);
537 nsIDOMElement *nselem;
538 HTMLDOMNode *node;
539 HRESULT hres;
541 static const PRUnichar optionW[] = {'O','P','T','I','O','N',0};
543 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
544 debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
546 if(!This->window || !This->window->doc) {
547 WARN("NULL doc\n");
548 return E_UNEXPECTED;
551 *optelem = NULL;
553 hres = create_nselem(This->window->doc, optionW, &nselem);
554 if(FAILED(hres))
555 return hres;
557 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
558 nsIDOMElement_Release(nselem);
559 if(FAILED(hres))
560 return hres;
562 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface,
563 &IID_IHTMLOptionElement, (void**)optelem);
564 node_release(node);
566 if(V_VT(&text) == VT_BSTR)
567 IHTMLOptionElement_put_text(*optelem, V_BSTR(&text));
568 else if(V_VT(&text) != VT_EMPTY)
569 FIXME("Unsupported text %s\n", debugstr_variant(&text));
571 if(V_VT(&value) == VT_BSTR)
572 IHTMLOptionElement_put_value(*optelem, V_BSTR(&value));
573 else if(V_VT(&value) != VT_EMPTY)
574 FIXME("Unsupported value %s\n", debugstr_variant(&value));
576 if(V_VT(&defaultselected) != VT_EMPTY)
577 FIXME("Unsupported defaultselected %s\n", debugstr_variant(&defaultselected));
578 if(V_VT(&selected) != VT_EMPTY)
579 FIXME("Unsupported selected %s\n", debugstr_variant(&selected));
581 return S_OK;
584 static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
585 HTMLOptionElementFactory_QueryInterface,
586 HTMLOptionElementFactory_AddRef,
587 HTMLOptionElementFactory_Release,
588 HTMLOptionElementFactory_GetTypeInfoCount,
589 HTMLOptionElementFactory_GetTypeInfo,
590 HTMLOptionElementFactory_GetIDsOfNames,
591 HTMLOptionElementFactory_Invoke,
592 HTMLOptionElementFactory_create
595 static const tid_t HTMLOptionElementFactory_iface_tids[] = {
596 IHTMLOptionElementFactory_tid,
600 static dispex_static_data_t HTMLOptionElementFactory_dispex = {
601 NULL,
602 IHTMLOptionElementFactory_tid,
603 HTMLOptionElementFactory_iface_tids,
604 HTMLElement_init_dispex_info
607 HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionElementFactory **ret_ptr)
609 HTMLOptionElementFactory *ret;
611 ret = heap_alloc(sizeof(*ret));
612 if(!ret)
613 return E_OUTOFMEMORY;
615 ret->IHTMLOptionElementFactory_iface.lpVtbl = &HTMLOptionElementFactoryVtbl;
616 ret->ref = 1;
617 ret->window = window;
619 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLOptionElementFactory_iface,
620 &HTMLOptionElementFactory_dispex);
622 *ret_ptr = ret;
623 return S_OK;
626 struct HTMLSelectElement {
627 HTMLElement element;
629 IHTMLSelectElement IHTMLSelectElement_iface;
631 nsIDOMHTMLSelectElement *nsselect;
634 static inline HTMLSelectElement *impl_from_IHTMLSelectElement(IHTMLSelectElement *iface)
636 return CONTAINING_RECORD(iface, HTMLSelectElement, IHTMLSelectElement_iface);
639 static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
641 nsIDOMHTMLOptionsCollection *nscol;
642 nsIDOMNode *nsnode;
643 nsresult nsres;
644 HRESULT hres;
646 nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
647 if(NS_FAILED(nsres)) {
648 ERR("GetOptions failed: %08x\n", nsres);
649 return E_FAIL;
652 nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
653 nsIDOMHTMLOptionsCollection_Release(nscol);
654 if(NS_FAILED(nsres)) {
655 ERR("Item failed: %08x\n", nsres);
656 return E_FAIL;
659 if(nsnode) {
660 HTMLDOMNode *node;
662 hres = get_node(nsnode, TRUE, &node);
663 nsIDOMNode_Release(nsnode);
664 if(FAILED(hres))
665 return hres;
667 *ret = (IDispatch*)&node->IHTMLDOMNode_iface;
668 }else {
669 *ret = NULL;
671 return S_OK;
674 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
675 REFIID riid, void **ppv)
677 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
679 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
682 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
684 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
686 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
689 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
691 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
693 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
696 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
698 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
700 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
703 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
704 LCID lcid, ITypeInfo **ppTInfo)
706 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
708 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
709 ppTInfo);
712 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
713 LPOLESTR *rgszNames, UINT cNames,
714 LCID lcid, DISPID *rgDispId)
716 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
718 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
719 cNames, lcid, rgDispId);
722 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
723 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
724 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
726 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
728 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
729 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
732 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, LONG v)
734 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
735 nsresult nsres;
737 TRACE("(%p)->(%d)\n", This, v);
738 if(v < 0)
739 return CTL_E_INVALIDPROPERTYVALUE;
741 nsres = nsIDOMHTMLSelectElement_SetSize(This->nsselect, v);
742 if(NS_FAILED(nsres)) {
743 ERR("SetSize failed: %08x\n", nsres);
744 return E_FAIL;
746 return S_OK;
749 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, LONG *p)
751 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
752 DWORD val;
753 nsresult nsres;
755 TRACE("(%p)->(%p)\n", This, p);
756 if(!p)
757 return E_INVALIDARG;
759 nsres = nsIDOMHTMLSelectElement_GetSize(This->nsselect, &val);
760 if(NS_FAILED(nsres)) {
761 ERR("GetSize failed: %08x\n", nsres);
762 return E_FAIL;
764 *p = val;
765 return S_OK;
768 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
770 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
771 nsresult nsres;
773 TRACE("(%p)->(%x)\n", This, v);
775 nsres = nsIDOMHTMLSelectElement_SetMultiple(This->nsselect, !!v);
776 assert(nsres == NS_OK);
777 return S_OK;
780 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
782 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
783 cpp_bool val;
784 nsresult nsres;
786 TRACE("(%p)->(%p)\n", This, p);
788 nsres = nsIDOMHTMLSelectElement_GetMultiple(This->nsselect, &val);
789 assert(nsres == NS_OK);
791 *p = variant_bool(val);
792 return S_OK;
795 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
797 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
798 nsAString str;
799 nsresult nsres;
801 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
802 nsAString_InitDepend(&str, v);
803 nsres = nsIDOMHTMLSelectElement_SetName(This->nsselect, &str);
804 nsAString_Finish(&str);
806 if(NS_FAILED(nsres)) {
807 ERR("SetName failed: %08x\n", nsres);
808 return E_FAIL;
810 return S_OK;
813 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
815 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
816 nsAString name_str;
817 nsresult nsres;
819 TRACE("(%p)->(%p)\n", This, p);
821 nsAString_Init(&name_str, NULL);
822 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
824 return return_nsstr(nsres, &name_str, p);
827 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
829 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
831 TRACE("(%p)->(%p)\n", This, p);
833 *p = (IDispatch*)&This->IHTMLSelectElement_iface;
834 IDispatch_AddRef(*p);
835 return S_OK;
838 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
840 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
842 TRACE("(%p)->()\n", This);
844 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
847 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
849 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
850 FIXME("(%p)->(%p)\n", This, p);
851 return E_NOTIMPL;
854 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, LONG v)
856 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
857 nsresult nsres;
859 TRACE("(%p)->(%d)\n", This, v);
861 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
862 if(NS_FAILED(nsres))
863 ERR("SetSelectedIndex failed: %08x\n", nsres);
865 return S_OK;
868 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, LONG *p)
870 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
871 nsresult nsres;
873 TRACE("(%p)->(%p)\n", This, p);
875 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, p);
876 if(NS_FAILED(nsres)) {
877 ERR("GetSelectedIndex failed: %08x\n", nsres);
878 return E_FAIL;
881 return S_OK;
884 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
886 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
887 nsAString type_str;
888 nsresult nsres;
890 TRACE("(%p)->(%p)\n", This, p);
892 nsAString_Init(&type_str, NULL);
893 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
894 return return_nsstr(nsres, &type_str, p);
897 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
899 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
900 nsAString value_str;
901 nsresult nsres;
903 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
905 nsAString_InitDepend(&value_str, v);
906 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
907 nsAString_Finish(&value_str);
908 if(NS_FAILED(nsres))
909 ERR("SetValue failed: %08x\n", nsres);
911 return S_OK;
914 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
916 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
917 nsAString value_str;
918 nsresult nsres;
920 TRACE("(%p)->(%p)\n", This, p);
922 nsAString_Init(&value_str, NULL);
923 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
924 return return_nsstr(nsres, &value_str, p);
927 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
929 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
930 nsresult nsres;
932 TRACE("(%p)->(%x)\n", This, v);
934 nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
935 if(NS_FAILED(nsres)) {
936 ERR("SetDisabled failed: %08x\n", nsres);
937 return E_FAIL;
940 return S_OK;
943 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
945 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
946 cpp_bool disabled = FALSE;
947 nsresult nsres;
949 TRACE("(%p)->(%p)\n", This, p);
951 nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
952 if(NS_FAILED(nsres)) {
953 ERR("GetDisabled failed: %08x\n", nsres);
954 return E_FAIL;
957 *p = variant_bool(disabled);
958 return S_OK;
961 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
963 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
964 nsIDOMHTMLFormElement *nsform;
965 nsresult nsres;
967 TRACE("(%p)->(%p)\n", This, p);
969 if(!p)
970 return E_POINTER;
972 nsres = nsIDOMHTMLSelectElement_GetForm(This->nsselect, &nsform);
973 return return_nsform(nsres, nsform, p);
976 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
977 VARIANT before)
979 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
980 nsIWritableVariant *nsvariant;
981 HTMLElement *element_obj;
982 nsresult nsres;
984 TRACE("(%p)->(%p %s)\n", This, element, debugstr_variant(&before));
986 element_obj = unsafe_impl_from_IHTMLElement(element);
987 if(!element_obj) {
988 FIXME("External IHTMLElement implementation?\n");
989 return E_INVALIDARG;
992 if(!element_obj->html_element) {
993 FIXME("Not HTML element\n");
994 return E_NOTIMPL;
997 nsvariant = create_nsvariant();
998 if(!nsvariant)
999 return E_FAIL;
1001 switch(V_VT(&before)) {
1002 case VT_EMPTY:
1003 case VT_ERROR:
1004 nsres = nsIWritableVariant_SetAsEmpty(nsvariant);
1005 break;
1006 case VT_I2:
1007 nsres = nsIWritableVariant_SetAsInt16(nsvariant, V_I2(&before));
1008 break;
1009 default:
1010 FIXME("unhandled before %s\n", debugstr_variant(&before));
1011 nsIWritableVariant_Release(nsvariant);
1012 return E_NOTIMPL;
1015 if(NS_SUCCEEDED(nsres))
1016 nsres = nsIDOMHTMLSelectElement_Add(This->nsselect, element_obj->html_element, (nsIVariant*)nsvariant);
1017 nsIWritableVariant_Release(nsvariant);
1018 if(NS_FAILED(nsres)) {
1019 ERR("Add failed: %08x\n", nsres);
1020 return E_FAIL;
1023 return S_OK;
1026 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index)
1028 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1029 nsresult nsres;
1030 TRACE("(%p)->(%d)\n", This, index);
1031 if(index < 0)
1032 return E_INVALIDARG;
1034 nsres = nsIDOMHTMLSelectElement_select_Remove(This->nsselect, index);
1035 if(NS_FAILED(nsres)) {
1036 ERR("Remove failed: %08x\n", nsres);
1037 return E_FAIL;
1039 return S_OK;
1042 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, LONG v)
1044 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1045 nsresult nsres;
1047 TRACE("(%p)->(%d)\n", This, v);
1049 nsres = nsIDOMHTMLSelectElement_SetLength(This->nsselect, v);
1050 if(NS_FAILED(nsres))
1051 ERR("SetLength failed: %08x\n", nsres);
1053 return S_OK;
1056 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, LONG *p)
1058 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1059 UINT32 length = 0;
1060 nsresult nsres;
1062 TRACE("(%p)->(%p)\n", This, p);
1064 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
1065 if(NS_FAILED(nsres))
1066 ERR("GetLength failed: %08x\n", nsres);
1068 *p = length;
1070 TRACE("ret %d\n", *p);
1071 return S_OK;
1074 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
1076 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1077 FIXME("(%p)->(%p)\n", This, p);
1078 return E_NOTIMPL;
1081 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
1082 VARIANT index, IDispatch **pdisp)
1084 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1086 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
1088 if(!pdisp)
1089 return E_POINTER;
1090 *pdisp = NULL;
1092 if(V_VT(&name) == VT_I4) {
1093 if(V_I4(&name) < 0)
1094 return E_INVALIDARG;
1095 return htmlselect_item(This, V_I4(&name), pdisp);
1098 FIXME("Unsupported args\n");
1099 return E_NOTIMPL;
1102 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
1103 IDispatch **pdisp)
1105 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1106 FIXME("(%p)->(v %p)\n", This, pdisp);
1107 return E_NOTIMPL;
1110 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
1111 HTMLSelectElement_QueryInterface,
1112 HTMLSelectElement_AddRef,
1113 HTMLSelectElement_Release,
1114 HTMLSelectElement_GetTypeInfoCount,
1115 HTMLSelectElement_GetTypeInfo,
1116 HTMLSelectElement_GetIDsOfNames,
1117 HTMLSelectElement_Invoke,
1118 HTMLSelectElement_put_size,
1119 HTMLSelectElement_get_size,
1120 HTMLSelectElement_put_multiple,
1121 HTMLSelectElement_get_multiple,
1122 HTMLSelectElement_put_name,
1123 HTMLSelectElement_get_name,
1124 HTMLSelectElement_get_options,
1125 HTMLSelectElement_put_onchange,
1126 HTMLSelectElement_get_onchange,
1127 HTMLSelectElement_put_selectedIndex,
1128 HTMLSelectElement_get_selectedIndex,
1129 HTMLSelectElement_get_type,
1130 HTMLSelectElement_put_value,
1131 HTMLSelectElement_get_value,
1132 HTMLSelectElement_put_disabled,
1133 HTMLSelectElement_get_disabled,
1134 HTMLSelectElement_get_form,
1135 HTMLSelectElement_add,
1136 HTMLSelectElement_remove,
1137 HTMLSelectElement_put_length,
1138 HTMLSelectElement_get_length,
1139 HTMLSelectElement_get__newEnum,
1140 HTMLSelectElement_item,
1141 HTMLSelectElement_tags
1144 static inline HTMLSelectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1146 return CONTAINING_RECORD(iface, HTMLSelectElement, element.node);
1149 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1151 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1153 *ppv = NULL;
1155 if(IsEqualGUID(&IID_IUnknown, riid)) {
1156 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1157 *ppv = &This->IHTMLSelectElement_iface;
1158 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1159 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1160 *ppv = &This->IHTMLSelectElement_iface;
1161 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
1162 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
1163 *ppv = &This->IHTMLSelectElement_iface;
1166 if(*ppv) {
1167 IUnknown_AddRef((IUnknown*)*ppv);
1168 return S_OK;
1171 return HTMLElement_QI(&This->element.node, riid, ppv);
1174 static HRESULT HTMLSelectElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
1176 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1177 return IHTMLSelectElement_put_disabled(&This->IHTMLSelectElement_iface, v);
1180 static HRESULT HTMLSelectElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
1182 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1183 return IHTMLSelectElement_get_disabled(&This->IHTMLSelectElement_iface, p);
1186 #define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
1188 static HRESULT HTMLSelectElement_get_dispid(HTMLDOMNode *iface, BSTR name, DWORD flags, DISPID *dispid)
1190 const WCHAR *ptr;
1191 DWORD idx = 0;
1193 for(ptr = name; *ptr && isdigitW(*ptr); ptr++) {
1194 idx = idx*10 + (*ptr-'0');
1195 if(idx > MSHTML_CUSTOM_DISPID_CNT) {
1196 WARN("too big idx\n");
1197 return DISP_E_UNKNOWNNAME;
1200 if(*ptr)
1201 return DISP_E_UNKNOWNNAME;
1203 *dispid = DISPID_OPTIONCOL_0 + idx;
1204 return S_OK;
1207 static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1208 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1210 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1212 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1214 switch(flags) {
1215 case DISPATCH_PROPERTYGET: {
1216 IDispatch *ret;
1217 HRESULT hres;
1219 hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
1220 if(FAILED(hres))
1221 return hres;
1223 if(ret) {
1224 V_VT(res) = VT_DISPATCH;
1225 V_DISPATCH(res) = ret;
1226 }else {
1227 V_VT(res) = VT_NULL;
1229 break;
1232 default:
1233 FIXME("unimplemented flags %x\n", flags);
1234 return E_NOTIMPL;
1237 return S_OK;
1240 static void HTMLSelectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1242 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1244 if(This->nsselect)
1245 note_cc_edge((nsISupports*)This->nsselect, "This->nsselect", cb);
1248 static void HTMLSelectElement_unlink(HTMLDOMNode *iface)
1250 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1252 if(This->nsselect) {
1253 nsIDOMHTMLSelectElement *nsselect = This->nsselect;
1255 This->nsselect = NULL;
1256 nsIDOMHTMLSelectElement_Release(nsselect);
1260 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
1261 &CLSID_HTMLSelectElement,
1262 HTMLSelectElement_QI,
1263 HTMLElement_destructor,
1264 HTMLElement_cpc,
1265 HTMLElement_clone,
1266 HTMLElement_handle_event,
1267 HTMLElement_get_attr_col,
1268 NULL,
1269 HTMLSelectElementImpl_put_disabled,
1270 HTMLSelectElementImpl_get_disabled,
1271 NULL,
1272 NULL,
1273 HTMLSelectElement_get_dispid,
1274 HTMLSelectElement_invoke,
1275 NULL,
1276 HTMLSelectElement_traverse,
1277 HTMLSelectElement_unlink
1280 static const tid_t HTMLSelectElement_tids[] = {
1281 HTMLELEMENT_TIDS,
1282 IHTMLSelectElement_tid,
1286 static dispex_static_data_t HTMLSelectElement_dispex = {
1287 NULL,
1288 DispHTMLSelectElement_tid,
1289 HTMLSelectElement_tids,
1290 HTMLElement_init_dispex_info
1293 HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1295 HTMLSelectElement *ret;
1296 nsresult nsres;
1298 ret = heap_alloc_zero(sizeof(HTMLSelectElement));
1299 if(!ret)
1300 return E_OUTOFMEMORY;
1302 ret->IHTMLSelectElement_iface.lpVtbl = &HTMLSelectElementVtbl;
1303 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
1305 HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
1307 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement, (void**)&ret->nsselect);
1308 assert(nsres == NS_OK);
1310 *elem = &ret->element;
1311 return S_OK;