wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / mshtml / htmlselect.c
blob301d9fa5dc3acb90b6f06c76b1995a1a5b83fc98
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 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_variant(&text), debugstr_variant(&value),
542 debugstr_variant(&defaultselected), debugstr_variant(&selected), optelem);
544 if(!This->window || !This->window->doc) {
545 WARN("NULL doc\n");
546 return E_UNEXPECTED;
549 *optelem = NULL;
551 hres = create_nselem(This->window->doc, L"OPTION", &nselem);
552 if(FAILED(hres))
553 return hres;
555 hres = get_node((nsIDOMNode*)nselem, TRUE, &node);
556 nsIDOMElement_Release(nselem);
557 if(FAILED(hres))
558 return hres;
560 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface,
561 &IID_IHTMLOptionElement, (void**)optelem);
562 node_release(node);
564 if(V_VT(&text) == VT_BSTR)
565 IHTMLOptionElement_put_text(*optelem, V_BSTR(&text));
566 else if(V_VT(&text) != VT_EMPTY)
567 FIXME("Unsupported text %s\n", debugstr_variant(&text));
569 if(V_VT(&value) == VT_BSTR)
570 IHTMLOptionElement_put_value(*optelem, V_BSTR(&value));
571 else if(V_VT(&value) != VT_EMPTY)
572 FIXME("Unsupported value %s\n", debugstr_variant(&value));
574 if(V_VT(&defaultselected) != VT_EMPTY)
575 FIXME("Unsupported defaultselected %s\n", debugstr_variant(&defaultselected));
576 if(V_VT(&selected) != VT_EMPTY)
577 FIXME("Unsupported selected %s\n", debugstr_variant(&selected));
579 return S_OK;
582 static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl = {
583 HTMLOptionElementFactory_QueryInterface,
584 HTMLOptionElementFactory_AddRef,
585 HTMLOptionElementFactory_Release,
586 HTMLOptionElementFactory_GetTypeInfoCount,
587 HTMLOptionElementFactory_GetTypeInfo,
588 HTMLOptionElementFactory_GetIDsOfNames,
589 HTMLOptionElementFactory_Invoke,
590 HTMLOptionElementFactory_create
593 static const tid_t HTMLOptionElementFactory_iface_tids[] = {
594 IHTMLOptionElementFactory_tid,
598 static dispex_static_data_t HTMLOptionElementFactory_dispex = {
599 NULL,
600 IHTMLOptionElementFactory_tid,
601 HTMLOptionElementFactory_iface_tids,
602 HTMLElement_init_dispex_info
605 HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow *window, HTMLOptionElementFactory **ret_ptr)
607 HTMLOptionElementFactory *ret;
609 ret = heap_alloc(sizeof(*ret));
610 if(!ret)
611 return E_OUTOFMEMORY;
613 ret->IHTMLOptionElementFactory_iface.lpVtbl = &HTMLOptionElementFactoryVtbl;
614 ret->ref = 1;
615 ret->window = window;
617 init_dispatch(&ret->dispex, (IUnknown*)&ret->IHTMLOptionElementFactory_iface,
618 &HTMLOptionElementFactory_dispex, dispex_compat_mode(&window->event_target.dispex));
620 *ret_ptr = ret;
621 return S_OK;
624 struct HTMLSelectElement {
625 HTMLElement element;
627 IHTMLSelectElement IHTMLSelectElement_iface;
629 nsIDOMHTMLSelectElement *nsselect;
632 static inline HTMLSelectElement *impl_from_IHTMLSelectElement(IHTMLSelectElement *iface)
634 return CONTAINING_RECORD(iface, HTMLSelectElement, IHTMLSelectElement_iface);
637 static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
639 nsIDOMHTMLOptionsCollection *nscol;
640 nsIDOMNode *nsnode;
641 nsresult nsres;
642 HRESULT hres;
644 nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
645 if(NS_FAILED(nsres)) {
646 ERR("GetOptions failed: %08x\n", nsres);
647 return E_FAIL;
650 nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
651 nsIDOMHTMLOptionsCollection_Release(nscol);
652 if(NS_FAILED(nsres)) {
653 ERR("Item failed: %08x\n", nsres);
654 return E_FAIL;
657 if(nsnode) {
658 HTMLDOMNode *node;
660 hres = get_node(nsnode, TRUE, &node);
661 nsIDOMNode_Release(nsnode);
662 if(FAILED(hres))
663 return hres;
665 *ret = (IDispatch*)&node->IHTMLDOMNode_iface;
666 }else {
667 *ret = NULL;
669 return S_OK;
672 static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
673 REFIID riid, void **ppv)
675 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
677 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
680 static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
682 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
684 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
687 static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
689 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
691 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
694 static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
696 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
698 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
701 static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
702 LCID lcid, ITypeInfo **ppTInfo)
704 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
706 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
707 ppTInfo);
710 static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
711 LPOLESTR *rgszNames, UINT cNames,
712 LCID lcid, DISPID *rgDispId)
714 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
716 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
717 cNames, lcid, rgDispId);
720 static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
721 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
722 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
724 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
726 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
727 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
730 static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, LONG v)
732 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
733 nsresult nsres;
735 TRACE("(%p)->(%d)\n", This, v);
736 if(v < 0)
737 return CTL_E_INVALIDPROPERTYVALUE;
739 nsres = nsIDOMHTMLSelectElement_SetSize(This->nsselect, v);
740 if(NS_FAILED(nsres)) {
741 ERR("SetSize failed: %08x\n", nsres);
742 return E_FAIL;
744 return S_OK;
747 static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, LONG *p)
749 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
750 DWORD val;
751 nsresult nsres;
753 TRACE("(%p)->(%p)\n", This, p);
754 if(!p)
755 return E_INVALIDARG;
757 nsres = nsIDOMHTMLSelectElement_GetSize(This->nsselect, &val);
758 if(NS_FAILED(nsres)) {
759 ERR("GetSize failed: %08x\n", nsres);
760 return E_FAIL;
762 *p = val;
763 return S_OK;
766 static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
768 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
769 nsresult nsres;
771 TRACE("(%p)->(%x)\n", This, v);
773 nsres = nsIDOMHTMLSelectElement_SetMultiple(This->nsselect, !!v);
774 assert(nsres == NS_OK);
775 return S_OK;
778 static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
780 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
781 cpp_bool val;
782 nsresult nsres;
784 TRACE("(%p)->(%p)\n", This, p);
786 nsres = nsIDOMHTMLSelectElement_GetMultiple(This->nsselect, &val);
787 assert(nsres == NS_OK);
789 *p = variant_bool(val);
790 return S_OK;
793 static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
795 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
796 nsAString str;
797 nsresult nsres;
799 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
800 nsAString_InitDepend(&str, v);
801 nsres = nsIDOMHTMLSelectElement_SetName(This->nsselect, &str);
802 nsAString_Finish(&str);
804 if(NS_FAILED(nsres)) {
805 ERR("SetName failed: %08x\n", nsres);
806 return E_FAIL;
808 return S_OK;
811 static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
813 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
814 nsAString name_str;
815 nsresult nsres;
817 TRACE("(%p)->(%p)\n", This, p);
819 nsAString_Init(&name_str, NULL);
820 nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
822 return return_nsstr(nsres, &name_str, p);
825 static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
827 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
829 TRACE("(%p)->(%p)\n", This, p);
831 *p = (IDispatch*)&This->IHTMLSelectElement_iface;
832 IDispatch_AddRef(*p);
833 return S_OK;
836 static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
838 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
840 TRACE("(%p)->()\n", This);
842 return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
845 static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
847 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
848 FIXME("(%p)->(%p)\n", This, p);
849 return E_NOTIMPL;
852 static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, LONG v)
854 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
855 nsresult nsres;
857 TRACE("(%p)->(%d)\n", This, v);
859 nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
860 if(NS_FAILED(nsres))
861 ERR("SetSelectedIndex failed: %08x\n", nsres);
863 return S_OK;
866 static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, LONG *p)
868 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
869 nsresult nsres;
871 TRACE("(%p)->(%p)\n", This, p);
873 nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, p);
874 if(NS_FAILED(nsres)) {
875 ERR("GetSelectedIndex failed: %08x\n", nsres);
876 return E_FAIL;
879 return S_OK;
882 static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
884 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
885 nsAString type_str;
886 nsresult nsres;
888 TRACE("(%p)->(%p)\n", This, p);
890 nsAString_Init(&type_str, NULL);
891 nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
892 return return_nsstr(nsres, &type_str, p);
895 static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
897 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
898 nsAString value_str;
899 nsresult nsres;
901 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
903 nsAString_InitDepend(&value_str, v);
904 nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
905 nsAString_Finish(&value_str);
906 if(NS_FAILED(nsres))
907 ERR("SetValue failed: %08x\n", nsres);
909 return S_OK;
912 static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
914 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
915 nsAString value_str;
916 nsresult nsres;
918 TRACE("(%p)->(%p)\n", This, p);
920 nsAString_Init(&value_str, NULL);
921 nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
922 return return_nsstr(nsres, &value_str, p);
925 static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
927 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
928 nsresult nsres;
930 TRACE("(%p)->(%x)\n", This, v);
932 nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
933 if(NS_FAILED(nsres)) {
934 ERR("SetDisabled failed: %08x\n", nsres);
935 return E_FAIL;
938 return S_OK;
941 static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
943 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
944 cpp_bool disabled = FALSE;
945 nsresult nsres;
947 TRACE("(%p)->(%p)\n", This, p);
949 nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
950 if(NS_FAILED(nsres)) {
951 ERR("GetDisabled failed: %08x\n", nsres);
952 return E_FAIL;
955 *p = variant_bool(disabled);
956 return S_OK;
959 static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
961 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
962 nsIDOMHTMLFormElement *nsform;
963 nsresult nsres;
965 TRACE("(%p)->(%p)\n", This, p);
967 if(!p)
968 return E_POINTER;
970 nsres = nsIDOMHTMLSelectElement_GetForm(This->nsselect, &nsform);
971 return return_nsform(nsres, nsform, p);
974 static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
975 VARIANT before)
977 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
978 nsIWritableVariant *nsvariant;
979 HTMLElement *element_obj;
980 nsresult nsres;
982 TRACE("(%p)->(%p %s)\n", This, element, debugstr_variant(&before));
984 element_obj = unsafe_impl_from_IHTMLElement(element);
985 if(!element_obj) {
986 FIXME("External IHTMLElement implementation?\n");
987 return E_INVALIDARG;
990 if(!element_obj->html_element) {
991 FIXME("Not HTML element\n");
992 return E_NOTIMPL;
995 nsvariant = create_nsvariant();
996 if(!nsvariant)
997 return E_FAIL;
999 switch(V_VT(&before)) {
1000 case VT_EMPTY:
1001 case VT_ERROR:
1002 nsres = nsIWritableVariant_SetAsEmpty(nsvariant);
1003 break;
1004 case VT_I2:
1005 nsres = nsIWritableVariant_SetAsInt16(nsvariant, V_I2(&before));
1006 break;
1007 default:
1008 FIXME("unhandled before %s\n", debugstr_variant(&before));
1009 nsIWritableVariant_Release(nsvariant);
1010 return E_NOTIMPL;
1013 if(NS_SUCCEEDED(nsres))
1014 nsres = nsIDOMHTMLSelectElement_Add(This->nsselect, element_obj->html_element, (nsIVariant*)nsvariant);
1015 nsIWritableVariant_Release(nsvariant);
1016 if(NS_FAILED(nsres)) {
1017 ERR("Add failed: %08x\n", nsres);
1018 return E_FAIL;
1021 return S_OK;
1024 static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index)
1026 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1027 nsresult nsres;
1028 TRACE("(%p)->(%d)\n", This, index);
1029 if(index < 0)
1030 return E_INVALIDARG;
1032 nsres = nsIDOMHTMLSelectElement_select_Remove(This->nsselect, index);
1033 if(NS_FAILED(nsres)) {
1034 ERR("Remove failed: %08x\n", nsres);
1035 return E_FAIL;
1037 return S_OK;
1040 static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, LONG v)
1042 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1043 nsresult nsres;
1045 TRACE("(%p)->(%d)\n", This, v);
1047 nsres = nsIDOMHTMLSelectElement_SetLength(This->nsselect, v);
1048 if(NS_FAILED(nsres))
1049 ERR("SetLength failed: %08x\n", nsres);
1051 return S_OK;
1054 static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, LONG *p)
1056 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1057 UINT32 length = 0;
1058 nsresult nsres;
1060 TRACE("(%p)->(%p)\n", This, p);
1062 nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
1063 if(NS_FAILED(nsres))
1064 ERR("GetLength failed: %08x\n", nsres);
1066 *p = length;
1068 TRACE("ret %d\n", *p);
1069 return S_OK;
1072 static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
1074 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1075 FIXME("(%p)->(%p)\n", This, p);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
1080 VARIANT index, IDispatch **pdisp)
1082 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1084 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
1086 if(!pdisp)
1087 return E_POINTER;
1088 *pdisp = NULL;
1090 if(V_VT(&name) == VT_I4) {
1091 if(V_I4(&name) < 0)
1092 return E_INVALIDARG;
1093 return htmlselect_item(This, V_I4(&name), pdisp);
1096 FIXME("Unsupported args\n");
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
1101 IDispatch **pdisp)
1103 HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
1104 FIXME("(%p)->(v %p)\n", This, pdisp);
1105 return E_NOTIMPL;
1108 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
1109 HTMLSelectElement_QueryInterface,
1110 HTMLSelectElement_AddRef,
1111 HTMLSelectElement_Release,
1112 HTMLSelectElement_GetTypeInfoCount,
1113 HTMLSelectElement_GetTypeInfo,
1114 HTMLSelectElement_GetIDsOfNames,
1115 HTMLSelectElement_Invoke,
1116 HTMLSelectElement_put_size,
1117 HTMLSelectElement_get_size,
1118 HTMLSelectElement_put_multiple,
1119 HTMLSelectElement_get_multiple,
1120 HTMLSelectElement_put_name,
1121 HTMLSelectElement_get_name,
1122 HTMLSelectElement_get_options,
1123 HTMLSelectElement_put_onchange,
1124 HTMLSelectElement_get_onchange,
1125 HTMLSelectElement_put_selectedIndex,
1126 HTMLSelectElement_get_selectedIndex,
1127 HTMLSelectElement_get_type,
1128 HTMLSelectElement_put_value,
1129 HTMLSelectElement_get_value,
1130 HTMLSelectElement_put_disabled,
1131 HTMLSelectElement_get_disabled,
1132 HTMLSelectElement_get_form,
1133 HTMLSelectElement_add,
1134 HTMLSelectElement_remove,
1135 HTMLSelectElement_put_length,
1136 HTMLSelectElement_get_length,
1137 HTMLSelectElement_get__newEnum,
1138 HTMLSelectElement_item,
1139 HTMLSelectElement_tags
1142 static inline HTMLSelectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
1144 return CONTAINING_RECORD(iface, HTMLSelectElement, element.node);
1147 static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
1149 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1151 *ppv = NULL;
1153 if(IsEqualGUID(&IID_IUnknown, riid)) {
1154 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
1155 *ppv = &This->IHTMLSelectElement_iface;
1156 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
1157 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
1158 *ppv = &This->IHTMLSelectElement_iface;
1159 }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
1160 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
1161 *ppv = &This->IHTMLSelectElement_iface;
1164 if(*ppv) {
1165 IUnknown_AddRef((IUnknown*)*ppv);
1166 return S_OK;
1169 return HTMLElement_QI(&This->element.node, riid, ppv);
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 #define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
1186 static HRESULT HTMLSelectElement_get_dispid(HTMLDOMNode *iface, BSTR name, DWORD flags, DISPID *dispid)
1188 const WCHAR *ptr;
1189 DWORD idx = 0;
1191 for(ptr = name; *ptr && is_digit(*ptr); ptr++) {
1192 idx = idx*10 + (*ptr-'0');
1193 if(idx > MSHTML_CUSTOM_DISPID_CNT) {
1194 WARN("too big idx\n");
1195 return DISP_E_UNKNOWNNAME;
1198 if(*ptr)
1199 return DISP_E_UNKNOWNNAME;
1201 *dispid = DISPID_OPTIONCOL_0 + idx;
1202 return S_OK;
1205 static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
1206 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
1208 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1210 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
1212 switch(flags) {
1213 case DISPATCH_PROPERTYGET: {
1214 IDispatch *ret;
1215 HRESULT hres;
1217 hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
1218 if(FAILED(hres))
1219 return hres;
1221 if(ret) {
1222 V_VT(res) = VT_DISPATCH;
1223 V_DISPATCH(res) = ret;
1224 }else {
1225 V_VT(res) = VT_NULL;
1227 break;
1230 default:
1231 FIXME("unimplemented flags %x\n", flags);
1232 return E_NOTIMPL;
1235 return S_OK;
1238 static void HTMLSelectElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1240 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1242 if(This->nsselect)
1243 note_cc_edge((nsISupports*)This->nsselect, "This->nsselect", cb);
1246 static void HTMLSelectElement_unlink(HTMLDOMNode *iface)
1248 HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
1250 if(This->nsselect) {
1251 nsIDOMHTMLSelectElement *nsselect = This->nsselect;
1253 This->nsselect = NULL;
1254 nsIDOMHTMLSelectElement_Release(nsselect);
1258 static const NodeImplVtbl HTMLSelectElementImplVtbl = {
1259 &CLSID_HTMLSelectElement,
1260 HTMLSelectElement_QI,
1261 HTMLElement_destructor,
1262 HTMLElement_cpc,
1263 HTMLElement_clone,
1264 HTMLElement_handle_event,
1265 HTMLElement_get_attr_col,
1266 NULL,
1267 HTMLSelectElementImpl_put_disabled,
1268 HTMLSelectElementImpl_get_disabled,
1269 NULL,
1270 NULL,
1271 HTMLSelectElement_get_dispid,
1272 HTMLSelectElement_invoke,
1273 NULL,
1274 HTMLSelectElement_traverse,
1275 HTMLSelectElement_unlink
1278 static const tid_t HTMLSelectElement_tids[] = {
1279 HTMLELEMENT_TIDS,
1280 IHTMLSelectElement_tid,
1284 static dispex_static_data_t HTMLSelectElement_dispex = {
1285 NULL,
1286 DispHTMLSelectElement_tid,
1287 HTMLSelectElement_tids,
1288 HTMLElement_init_dispex_info
1291 HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1293 HTMLSelectElement *ret;
1294 nsresult nsres;
1296 ret = heap_alloc_zero(sizeof(HTMLSelectElement));
1297 if(!ret)
1298 return E_OUTOFMEMORY;
1300 ret->IHTMLSelectElement_iface.lpVtbl = &HTMLSelectElementVtbl;
1301 ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
1303 HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
1305 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement, (void**)&ret->nsselect);
1306 assert(nsres == NS_OK);
1308 *elem = &ret->element;
1309 return S_OK;