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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 struct HTMLOptionElement
{
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 static HRESULT WINAPI
HTMLOptionElement_QueryInterface(IHTMLOptionElement
*iface
,
49 REFIID riid
, void **ppv
)
51 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLOptionElement_AddRef(IHTMLOptionElement
*iface
)
58 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLOptionElement_Release(IHTMLOptionElement
*iface
)
65 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLOptionElement_GetTypeInfoCount(IHTMLOptionElement
*iface
, UINT
*pctinfo
)
72 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLOptionElement_GetTypeInfo(IHTMLOptionElement
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLOptionElement_GetIDsOfNames(IHTMLOptionElement
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
,
86 LCID lcid
, DISPID
*rgDispId
)
88 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
90 cNames
, lcid
, rgDispId
);
93 static HRESULT WINAPI
HTMLOptionElement_Invoke(IHTMLOptionElement
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
98 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
99 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLOptionElement_put_selected(IHTMLOptionElement
*iface
, VARIANT_BOOL v
)
104 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
107 TRACE("(%p)->(%x)\n", This
, v
);
109 nsres
= nsIDOMHTMLOptionElement_SetSelected(This
->nsoption
, v
!= VARIANT_FALSE
);
110 if(NS_FAILED(nsres
)) {
111 ERR("SetSelected failed: %08lx\n", nsres
);
118 static HRESULT WINAPI
HTMLOptionElement_get_selected(IHTMLOptionElement
*iface
, VARIANT_BOOL
*p
)
120 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
124 TRACE("(%p)->(%p)\n", This
, p
);
126 nsres
= nsIDOMHTMLOptionElement_GetSelected(This
->nsoption
, &selected
);
127 if(NS_FAILED(nsres
)) {
128 ERR("GetSelected failed: %08lx\n", nsres
);
132 *p
= variant_bool(selected
);
136 static HRESULT WINAPI
HTMLOptionElement_put_value(IHTMLOptionElement
*iface
, BSTR v
)
138 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
142 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
144 nsAString_InitDepend(&value_str
, v
);
145 nsres
= nsIDOMHTMLOptionElement_SetValue(This
->nsoption
, &value_str
);
146 nsAString_Finish(&value_str
);
148 ERR("SetValue failed: %08lx\n", nsres
);
153 static HRESULT WINAPI
HTMLOptionElement_get_value(IHTMLOptionElement
*iface
, BSTR
*p
)
155 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
159 TRACE("(%p)->(%p)\n", This
, p
);
161 nsAString_Init(&value_str
, NULL
);
162 nsres
= nsIDOMHTMLOptionElement_GetValue(This
->nsoption
, &value_str
);
163 return return_nsstr(nsres
, &value_str
, p
);
166 static HRESULT WINAPI
HTMLOptionElement_put_defaultSelected(IHTMLOptionElement
*iface
, VARIANT_BOOL v
)
168 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
169 cpp_bool val
, selected
;
172 TRACE("(%p)->(%x)\n", This
, v
);
174 val
= (v
== VARIANT_TRUE
);
176 nsres
= nsIDOMHTMLOptionElement_GetSelected(This
->nsoption
, &selected
);
177 if(NS_FAILED(nsres
)) {
178 ERR("GetSelected failed: %08lx\n", nsres
);
182 nsres
= nsIDOMHTMLOptionElement_SetDefaultSelected(This
->nsoption
, val
);
183 if(NS_FAILED(nsres
)) {
184 ERR("SetDefaultSelected failed: %08lx\n", nsres
);
188 if(val
!= selected
) {
189 nsres
= nsIDOMHTMLOptionElement_SetSelected(This
->nsoption
, selected
); /* WinAPI will reserve selected property */
190 if(NS_FAILED(nsres
)) {
191 ERR("SetSelected failed: %08lx\n", nsres
);
199 static HRESULT WINAPI
HTMLOptionElement_get_defaultSelected(IHTMLOptionElement
*iface
, VARIANT_BOOL
*p
)
201 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
205 TRACE("(%p)->(%p)\n", This
, p
);
208 nsres
= nsIDOMHTMLOptionElement_GetDefaultSelected(This
->nsoption
, &val
);
209 if(NS_FAILED(nsres
)) {
210 ERR("GetDefaultSelected failed: %08lx\n", nsres
);
214 *p
= variant_bool(val
);
218 static HRESULT WINAPI
HTMLOptionElement_put_index(IHTMLOptionElement
*iface
, LONG v
)
220 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
221 FIXME("(%p)->(%ld)\n", This
, v
);
225 static HRESULT WINAPI
HTMLOptionElement_get_index(IHTMLOptionElement
*iface
, LONG
*p
)
227 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
231 TRACE("(%p)->(%p)\n", This
, p
);
236 nsres
= nsIDOMHTMLOptionElement_GetIndex(This
->nsoption
, &val
);
237 if(NS_FAILED(nsres
)) {
238 ERR("GetIndex failed: %08lx\n", nsres
);
245 static HRESULT WINAPI
HTMLOptionElement_put_text(IHTMLOptionElement
*iface
, BSTR v
)
247 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
248 nsIDOMText
*text_node
;
253 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
255 if(!This
->element
.node
.doc
->nsdoc
) {
256 WARN("NULL nsdoc\n");
263 nsres
= nsIDOMElement_GetFirstChild(This
->element
.dom_element
, &child
);
264 if(NS_FAILED(nsres
) || !child
)
267 nsres
= nsIDOMElement_RemoveChild(This
->element
.dom_element
, child
, &tmp
);
268 nsIDOMNode_Release(child
);
269 if(NS_SUCCEEDED(nsres
)) {
270 nsIDOMNode_Release(tmp
);
272 ERR("RemoveChild failed: %08lx\n", nsres
);
277 nsAString_InitDepend(&text_str
, v
);
278 nsres
= nsIDOMHTMLDocument_CreateTextNode(This
->element
.node
.doc
->nsdoc
, &text_str
, &text_node
);
279 nsAString_Finish(&text_str
);
280 if(NS_FAILED(nsres
)) {
281 ERR("CreateTextNode failed: %08lx\n", nsres
);
285 nsres
= nsIDOMElement_AppendChild(This
->element
.dom_element
, (nsIDOMNode
*)text_node
, &tmp
);
286 if(NS_SUCCEEDED(nsres
))
287 nsIDOMNode_Release(tmp
);
289 ERR("AppendChild failed: %08lx\n", nsres
);
294 static HRESULT WINAPI
HTMLOptionElement_get_text(IHTMLOptionElement
*iface
, BSTR
*p
)
296 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
300 TRACE("(%p)->(%p)\n", This
, p
);
302 nsAString_Init(&text_str
, NULL
);
303 nsres
= nsIDOMHTMLOptionElement_GetText(This
->nsoption
, &text_str
);
304 return return_nsstr(nsres
, &text_str
, p
);
307 static HRESULT WINAPI
HTMLOptionElement_get_form(IHTMLOptionElement
*iface
, IHTMLFormElement
**p
)
309 HTMLOptionElement
*This
= impl_from_IHTMLOptionElement(iface
);
310 nsIDOMHTMLFormElement
*nsform
;
313 TRACE("(%p)->(%p)\n", This
, p
);
318 nsres
= nsIDOMHTMLOptionElement_GetForm(This
->nsoption
, &nsform
);
319 return return_nsform(nsres
, nsform
, p
);
322 static const IHTMLOptionElementVtbl HTMLOptionElementVtbl
= {
323 HTMLOptionElement_QueryInterface
,
324 HTMLOptionElement_AddRef
,
325 HTMLOptionElement_Release
,
326 HTMLOptionElement_GetTypeInfoCount
,
327 HTMLOptionElement_GetTypeInfo
,
328 HTMLOptionElement_GetIDsOfNames
,
329 HTMLOptionElement_Invoke
,
330 HTMLOptionElement_put_selected
,
331 HTMLOptionElement_get_selected
,
332 HTMLOptionElement_put_value
,
333 HTMLOptionElement_get_value
,
334 HTMLOptionElement_put_defaultSelected
,
335 HTMLOptionElement_get_defaultSelected
,
336 HTMLOptionElement_put_index
,
337 HTMLOptionElement_get_index
,
338 HTMLOptionElement_put_text
,
339 HTMLOptionElement_get_text
,
340 HTMLOptionElement_get_form
343 static inline HTMLOptionElement
*HTMLOptionElement_from_HTMLDOMNode(HTMLDOMNode
*iface
)
345 return CONTAINING_RECORD(iface
, HTMLOptionElement
, element
.node
);
348 static HRESULT
HTMLOptionElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
350 HTMLOptionElement
*This
= HTMLOptionElement_from_HTMLDOMNode(iface
);
354 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
355 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
356 *ppv
= &This
->IHTMLOptionElement_iface
;
357 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
358 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
359 *ppv
= &This
->IHTMLOptionElement_iface
;
360 }else if(IsEqualGUID(&IID_IHTMLOptionElement
, riid
)) {
361 TRACE("(%p)->(IID_IHTMLOptionElement %p)\n", This
, ppv
);
362 *ppv
= &This
->IHTMLOptionElement_iface
;
366 IUnknown_AddRef((IUnknown
*)*ppv
);
370 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
373 static void HTMLOptionElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
375 HTMLOptionElement
*This
= HTMLOptionElement_from_HTMLDOMNode(iface
);
378 note_cc_edge((nsISupports
*)This
->nsoption
, "This->nsoption", cb
);
381 static void HTMLOptionElement_unlink(HTMLDOMNode
*iface
)
383 HTMLOptionElement
*This
= HTMLOptionElement_from_HTMLDOMNode(iface
);
386 nsIDOMHTMLOptionElement
*nsoption
= This
->nsoption
;
388 This
->nsoption
= NULL
;
389 nsIDOMHTMLOptionElement_Release(nsoption
);
393 static const NodeImplVtbl HTMLOptionElementImplVtbl
= {
394 &CLSID_HTMLOptionElement
,
395 HTMLOptionElement_QI
,
396 HTMLElement_destructor
,
399 HTMLElement_handle_event
,
400 HTMLElement_get_attr_col
,
410 HTMLOptionElement_traverse
,
411 HTMLOptionElement_unlink
414 static const tid_t HTMLOptionElement_iface_tids
[] = {
416 IHTMLOptionElement_tid
,
419 static dispex_static_data_t HTMLOptionElement_dispex
= {
420 L
"HTMLOptionElement",
422 DispHTMLOptionElement_tid
,
423 HTMLOptionElement_iface_tids
,
424 HTMLElement_init_dispex_info
427 HRESULT
HTMLOptionElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
429 HTMLOptionElement
*ret
;
432 ret
= heap_alloc_zero(sizeof(HTMLOptionElement
));
434 return E_OUTOFMEMORY
;
436 ret
->IHTMLOptionElement_iface
.lpVtbl
= &HTMLOptionElementVtbl
;
437 ret
->element
.node
.vtbl
= &HTMLOptionElementImplVtbl
;
439 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLOptionElement_dispex
);
441 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLOptionElement
, (void**)&ret
->nsoption
);
442 assert(nsres
== NS_OK
);
444 *elem
= &ret
->element
;
448 static inline HTMLOptionElementFactory
*impl_from_IHTMLOptionElementFactory(IHTMLOptionElementFactory
*iface
)
450 return CONTAINING_RECORD(iface
, HTMLOptionElementFactory
, IHTMLOptionElementFactory_iface
);
453 static HRESULT WINAPI
HTMLOptionElementFactory_QueryInterface(IHTMLOptionElementFactory
*iface
,
454 REFIID riid
, void **ppv
)
456 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
458 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
460 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
461 *ppv
= &This
->IHTMLOptionElementFactory_iface
;
462 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
463 *ppv
= &This
->IHTMLOptionElementFactory_iface
;
464 }else if(IsEqualGUID(&IID_IHTMLOptionElementFactory
, riid
)) {
465 *ppv
= &This
->IHTMLOptionElementFactory_iface
;
466 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
467 return *ppv
? S_OK
: E_NOINTERFACE
;
470 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
471 return E_NOINTERFACE
;
474 IUnknown_AddRef((IUnknown
*)*ppv
);
478 static ULONG WINAPI
HTMLOptionElementFactory_AddRef(IHTMLOptionElementFactory
*iface
)
480 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
481 LONG ref
= InterlockedIncrement(&This
->ref
);
483 TRACE("(%p) ref=%ld\n", This
, ref
);
488 static ULONG WINAPI
HTMLOptionElementFactory_Release(IHTMLOptionElementFactory
*iface
)
490 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
491 LONG ref
= InterlockedDecrement(&This
->ref
);
493 TRACE("(%p) ref=%ld\n", This
, ref
);
496 release_dispex(&This
->dispex
);
503 static HRESULT WINAPI
HTMLOptionElementFactory_GetTypeInfoCount(IHTMLOptionElementFactory
*iface
, UINT
*pctinfo
)
505 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
506 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
509 static HRESULT WINAPI
HTMLOptionElementFactory_GetTypeInfo(IHTMLOptionElementFactory
*iface
, UINT iTInfo
,
510 LCID lcid
, ITypeInfo
**ppTInfo
)
512 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
513 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
516 static HRESULT WINAPI
HTMLOptionElementFactory_GetIDsOfNames(IHTMLOptionElementFactory
*iface
, REFIID riid
,
517 LPOLESTR
*rgszNames
, UINT cNames
,
518 LCID lcid
, DISPID
*rgDispId
)
520 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
521 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
524 static HRESULT WINAPI
HTMLOptionElementFactory_Invoke(IHTMLOptionElementFactory
*iface
, DISPID dispIdMember
,
525 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
526 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
528 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
529 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
530 pVarResult
, pExcepInfo
, puArgErr
);
533 static HRESULT WINAPI
HTMLOptionElementFactory_create(IHTMLOptionElementFactory
*iface
,
534 VARIANT text
, VARIANT value
, VARIANT defaultselected
, VARIANT selected
,
535 IHTMLOptionElement
**optelem
)
537 HTMLOptionElementFactory
*This
= impl_from_IHTMLOptionElementFactory(iface
);
538 nsIDOMElement
*nselem
;
542 TRACE("(%p)->(%s %s %s %s %p)\n", This
, debugstr_variant(&text
), debugstr_variant(&value
),
543 debugstr_variant(&defaultselected
), debugstr_variant(&selected
), optelem
);
545 if(!This
->window
|| !This
->window
->doc
) {
552 hres
= create_nselem(This
->window
->doc
, L
"OPTION", &nselem
);
556 hres
= get_node((nsIDOMNode
*)nselem
, TRUE
, &node
);
557 nsIDOMElement_Release(nselem
);
561 hres
= IHTMLDOMNode_QueryInterface(&node
->IHTMLDOMNode_iface
,
562 &IID_IHTMLOptionElement
, (void**)optelem
);
565 if(V_VT(&text
) == VT_BSTR
)
566 IHTMLOptionElement_put_text(*optelem
, V_BSTR(&text
));
567 else if(V_VT(&text
) != VT_EMPTY
)
568 FIXME("Unsupported text %s\n", debugstr_variant(&text
));
570 if(V_VT(&value
) == VT_BSTR
)
571 IHTMLOptionElement_put_value(*optelem
, V_BSTR(&value
));
572 else if(V_VT(&value
) != VT_EMPTY
)
573 FIXME("Unsupported value %s\n", debugstr_variant(&value
));
575 if(V_VT(&defaultselected
) != VT_EMPTY
)
576 FIXME("Unsupported defaultselected %s\n", debugstr_variant(&defaultselected
));
577 if(V_VT(&selected
) != VT_EMPTY
)
578 FIXME("Unsupported selected %s\n", debugstr_variant(&selected
));
583 static const IHTMLOptionElementFactoryVtbl HTMLOptionElementFactoryVtbl
= {
584 HTMLOptionElementFactory_QueryInterface
,
585 HTMLOptionElementFactory_AddRef
,
586 HTMLOptionElementFactory_Release
,
587 HTMLOptionElementFactory_GetTypeInfoCount
,
588 HTMLOptionElementFactory_GetTypeInfo
,
589 HTMLOptionElementFactory_GetIDsOfNames
,
590 HTMLOptionElementFactory_Invoke
,
591 HTMLOptionElementFactory_create
594 static inline HTMLOptionElementFactory
*HTMLOptionElementFactory_from_DispatchEx(DispatchEx
*iface
)
596 return CONTAINING_RECORD(iface
, HTMLOptionElementFactory
, dispex
);
599 static HRESULT
HTMLOptionElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
600 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
601 IServiceProvider
*caller
)
603 HTMLOptionElementFactory
*This
= HTMLOptionElementFactory_from_DispatchEx(dispex
);
604 unsigned int i
, argc
= params
->cArgs
- params
->cNamedArgs
;
605 IHTMLOptionElement
*opt
;
606 VARIANT empty
, *arg
[4];
609 if(flags
!= DISPATCH_CONSTRUCT
) {
610 FIXME("flags %x not supported\n", flags
);
615 V_VT(&empty
) = VT_EMPTY
;
617 for(i
= 0; i
< ARRAY_SIZE(arg
); i
++)
618 arg
[i
] = argc
> i
? ¶ms
->rgvarg
[params
->cArgs
- 1 - i
] : &empty
;
620 hres
= IHTMLOptionElementFactory_create(&This
->IHTMLOptionElementFactory_iface
,
621 *arg
[0], *arg
[1], *arg
[2], *arg
[3], &opt
);
625 V_VT(res
) = VT_DISPATCH
;
626 V_DISPATCH(res
) = (IDispatch
*)opt
;
631 static const tid_t HTMLOptionElementFactory_iface_tids
[] = {
632 IHTMLOptionElementFactory_tid
,
636 static const dispex_static_data_vtbl_t HTMLOptionElementFactory_dispex_vtbl
= {
637 HTMLOptionElementFactory_value
,
643 static dispex_static_data_t HTMLOptionElementFactory_dispex
= {
645 &HTMLOptionElementFactory_dispex_vtbl
,
646 IHTMLOptionElementFactory_tid
,
647 HTMLOptionElementFactory_iface_tids
,
648 HTMLElement_init_dispex_info
651 HRESULT
HTMLOptionElementFactory_Create(HTMLInnerWindow
*window
, HTMLOptionElementFactory
**ret_ptr
)
653 HTMLOptionElementFactory
*ret
;
655 ret
= heap_alloc(sizeof(*ret
));
657 return E_OUTOFMEMORY
;
659 ret
->IHTMLOptionElementFactory_iface
.lpVtbl
= &HTMLOptionElementFactoryVtbl
;
661 ret
->window
= window
;
663 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLOptionElementFactory_iface
,
664 &HTMLOptionElementFactory_dispex
, dispex_compat_mode(&window
->event_target
.dispex
));
670 struct HTMLSelectElement
{
673 IHTMLSelectElement IHTMLSelectElement_iface
;
675 nsIDOMHTMLSelectElement
*nsselect
;
679 IEnumVARIANT IEnumVARIANT_iface
;
684 HTMLSelectElement
*elem
;
685 } HTMLSelectElementEnum
;
687 static inline HTMLSelectElement
*impl_from_IHTMLSelectElement(IHTMLSelectElement
*iface
)
689 return CONTAINING_RECORD(iface
, HTMLSelectElement
, IHTMLSelectElement_iface
);
692 static HRESULT
htmlselect_item(HTMLSelectElement
*This
, int i
, IDispatch
**ret
)
694 nsIDOMHTMLOptionsCollection
*nscol
;
699 nsres
= nsIDOMHTMLSelectElement_GetOptions(This
->nsselect
, &nscol
);
700 if(NS_FAILED(nsres
)) {
701 ERR("GetOptions failed: %08lx\n", nsres
);
705 nsres
= nsIDOMHTMLOptionsCollection_Item(nscol
, i
, &nsnode
);
706 nsIDOMHTMLOptionsCollection_Release(nscol
);
707 if(NS_FAILED(nsres
)) {
708 ERR("Item failed: %08lx\n", nsres
);
715 hres
= get_node(nsnode
, TRUE
, &node
);
716 nsIDOMNode_Release(nsnode
);
720 *ret
= (IDispatch
*)&node
->IHTMLDOMNode_iface
;
727 static inline HTMLSelectElementEnum
*impl_from_IEnumVARIANT(IEnumVARIANT
*iface
)
729 return CONTAINING_RECORD(iface
, HTMLSelectElementEnum
, IEnumVARIANT_iface
);
732 static HRESULT WINAPI
HTMLSelectElementEnum_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
734 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
736 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
738 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
739 *ppv
= &This
->IEnumVARIANT_iface
;
740 }else if(IsEqualGUID(riid
, &IID_IEnumVARIANT
)) {
741 *ppv
= &This
->IEnumVARIANT_iface
;
743 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
745 return E_NOINTERFACE
;
748 IUnknown_AddRef((IUnknown
*)*ppv
);
752 static ULONG WINAPI
HTMLSelectElementEnum_AddRef(IEnumVARIANT
*iface
)
754 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
755 LONG ref
= InterlockedIncrement(&This
->ref
);
757 TRACE("(%p) ref=%ld\n", This
, ref
);
762 static ULONG WINAPI
HTMLSelectElementEnum_Release(IEnumVARIANT
*iface
)
764 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
765 LONG ref
= InterlockedDecrement(&This
->ref
);
767 TRACE("(%p) ref=%ld\n", This
, ref
);
770 IHTMLSelectElement_Release(&This
->elem
->IHTMLSelectElement_iface
);
777 static HRESULT WINAPI
HTMLSelectElementEnum_Next(IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
779 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
785 TRACE("(%p)->(%lu %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
787 nsres
= nsIDOMHTMLSelectElement_GetLength(This
->elem
->nsselect
, &len
);
790 num
= min(len
- This
->iter
, celt
);
792 for(i
= 0; i
< num
; i
++) {
793 hres
= htmlselect_item(This
->elem
, This
->iter
+ i
, &V_DISPATCH(&rgVar
[i
]));
796 VariantClear(&rgVar
[i
]);
799 V_VT(&rgVar
[i
]) = VT_DISPATCH
;
805 return num
== celt
? S_OK
: S_FALSE
;
808 static HRESULT WINAPI
HTMLSelectElementEnum_Skip(IEnumVARIANT
*iface
, ULONG celt
)
810 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
814 TRACE("(%p)->(%lu)\n", This
, celt
);
816 nsres
= nsIDOMHTMLSelectElement_GetLength(This
->elem
->nsselect
, &len
);
820 if(This
->iter
+ celt
> len
) {
829 static HRESULT WINAPI
HTMLSelectElementEnum_Reset(IEnumVARIANT
*iface
)
831 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
833 TRACE("(%p)->()\n", This
);
839 static HRESULT WINAPI
HTMLSelectElementEnum_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
841 HTMLSelectElementEnum
*This
= impl_from_IEnumVARIANT(iface
);
842 FIXME("(%p)->(%p)\n", This
, ppEnum
);
846 static const IEnumVARIANTVtbl HTMLSelectElementEnumVtbl
= {
847 HTMLSelectElementEnum_QueryInterface
,
848 HTMLSelectElementEnum_AddRef
,
849 HTMLSelectElementEnum_Release
,
850 HTMLSelectElementEnum_Next
,
851 HTMLSelectElementEnum_Skip
,
852 HTMLSelectElementEnum_Reset
,
853 HTMLSelectElementEnum_Clone
856 static HRESULT WINAPI
HTMLSelectElement_QueryInterface(IHTMLSelectElement
*iface
,
857 REFIID riid
, void **ppv
)
859 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
861 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
864 static ULONG WINAPI
HTMLSelectElement_AddRef(IHTMLSelectElement
*iface
)
866 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
868 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
871 static ULONG WINAPI
HTMLSelectElement_Release(IHTMLSelectElement
*iface
)
873 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
875 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
878 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement
*iface
, UINT
*pctinfo
)
880 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
882 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
885 static HRESULT WINAPI
HTMLSelectElement_GetTypeInfo(IHTMLSelectElement
*iface
, UINT iTInfo
,
886 LCID lcid
, ITypeInfo
**ppTInfo
)
888 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
890 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
894 static HRESULT WINAPI
HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement
*iface
, REFIID riid
,
895 LPOLESTR
*rgszNames
, UINT cNames
,
896 LCID lcid
, DISPID
*rgDispId
)
898 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
900 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
901 cNames
, lcid
, rgDispId
);
904 static HRESULT WINAPI
HTMLSelectElement_Invoke(IHTMLSelectElement
*iface
, DISPID dispIdMember
,
905 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
906 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
908 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
910 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
911 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
914 static HRESULT WINAPI
HTMLSelectElement_put_size(IHTMLSelectElement
*iface
, LONG v
)
916 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
919 TRACE("(%p)->(%ld)\n", This
, v
);
921 return CTL_E_INVALIDPROPERTYVALUE
;
923 nsres
= nsIDOMHTMLSelectElement_SetSize(This
->nsselect
, v
);
924 if(NS_FAILED(nsres
)) {
925 ERR("SetSize failed: %08lx\n", nsres
);
931 static HRESULT WINAPI
HTMLSelectElement_get_size(IHTMLSelectElement
*iface
, LONG
*p
)
933 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
937 TRACE("(%p)->(%p)\n", This
, p
);
941 nsres
= nsIDOMHTMLSelectElement_GetSize(This
->nsselect
, &val
);
942 if(NS_FAILED(nsres
)) {
943 ERR("GetSize failed: %08lx\n", nsres
);
950 static HRESULT WINAPI
HTMLSelectElement_put_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
952 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
955 TRACE("(%p)->(%x)\n", This
, v
);
957 nsres
= nsIDOMHTMLSelectElement_SetMultiple(This
->nsselect
, !!v
);
958 assert(nsres
== NS_OK
);
962 static HRESULT WINAPI
HTMLSelectElement_get_multiple(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
964 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
968 TRACE("(%p)->(%p)\n", This
, p
);
970 nsres
= nsIDOMHTMLSelectElement_GetMultiple(This
->nsselect
, &val
);
971 assert(nsres
== NS_OK
);
973 *p
= variant_bool(val
);
977 static HRESULT WINAPI
HTMLSelectElement_put_name(IHTMLSelectElement
*iface
, BSTR v
)
979 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
983 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
984 nsAString_InitDepend(&str
, v
);
985 nsres
= nsIDOMHTMLSelectElement_SetName(This
->nsselect
, &str
);
986 nsAString_Finish(&str
);
988 if(NS_FAILED(nsres
)) {
989 ERR("SetName failed: %08lx\n", nsres
);
995 static HRESULT WINAPI
HTMLSelectElement_get_name(IHTMLSelectElement
*iface
, BSTR
*p
)
997 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1001 TRACE("(%p)->(%p)\n", This
, p
);
1003 nsAString_Init(&name_str
, NULL
);
1004 nsres
= nsIDOMHTMLSelectElement_GetName(This
->nsselect
, &name_str
);
1006 return return_nsstr(nsres
, &name_str
, p
);
1009 static HRESULT WINAPI
HTMLSelectElement_get_options(IHTMLSelectElement
*iface
, IDispatch
**p
)
1011 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1013 TRACE("(%p)->(%p)\n", This
, p
);
1015 *p
= (IDispatch
*)&This
->IHTMLSelectElement_iface
;
1016 IDispatch_AddRef(*p
);
1020 static HRESULT WINAPI
HTMLSelectElement_put_onchange(IHTMLSelectElement
*iface
, VARIANT v
)
1022 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1024 TRACE("(%p)->()\n", This
);
1026 return set_node_event(&This
->element
.node
, EVENTID_CHANGE
, &v
);
1029 static HRESULT WINAPI
HTMLSelectElement_get_onchange(IHTMLSelectElement
*iface
, VARIANT
*p
)
1031 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1032 FIXME("(%p)->(%p)\n", This
, p
);
1036 static HRESULT WINAPI
HTMLSelectElement_put_selectedIndex(IHTMLSelectElement
*iface
, LONG v
)
1038 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1041 TRACE("(%p)->(%ld)\n", This
, v
);
1043 nsres
= nsIDOMHTMLSelectElement_SetSelectedIndex(This
->nsselect
, v
);
1044 if(NS_FAILED(nsres
))
1045 ERR("SetSelectedIndex failed: %08lx\n", nsres
);
1050 static HRESULT WINAPI
HTMLSelectElement_get_selectedIndex(IHTMLSelectElement
*iface
, LONG
*p
)
1052 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1055 TRACE("(%p)->(%p)\n", This
, p
);
1057 nsres
= nsIDOMHTMLSelectElement_GetSelectedIndex(This
->nsselect
, p
);
1058 if(NS_FAILED(nsres
)) {
1059 ERR("GetSelectedIndex failed: %08lx\n", nsres
);
1066 static HRESULT WINAPI
HTMLSelectElement_get_type(IHTMLSelectElement
*iface
, BSTR
*p
)
1068 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1072 TRACE("(%p)->(%p)\n", This
, p
);
1074 nsAString_Init(&type_str
, NULL
);
1075 nsres
= nsIDOMHTMLSelectElement_GetType(This
->nsselect
, &type_str
);
1076 return return_nsstr(nsres
, &type_str
, p
);
1079 static HRESULT WINAPI
HTMLSelectElement_put_value(IHTMLSelectElement
*iface
, BSTR v
)
1081 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1082 nsAString value_str
;
1085 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1087 nsAString_InitDepend(&value_str
, v
);
1088 nsres
= nsIDOMHTMLSelectElement_SetValue(This
->nsselect
, &value_str
);
1089 nsAString_Finish(&value_str
);
1090 if(NS_FAILED(nsres
))
1091 ERR("SetValue failed: %08lx\n", nsres
);
1096 static HRESULT WINAPI
HTMLSelectElement_get_value(IHTMLSelectElement
*iface
, BSTR
*p
)
1098 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1099 nsAString value_str
;
1102 TRACE("(%p)->(%p)\n", This
, p
);
1104 nsAString_Init(&value_str
, NULL
);
1105 nsres
= nsIDOMHTMLSelectElement_GetValue(This
->nsselect
, &value_str
);
1106 return return_nsstr(nsres
, &value_str
, p
);
1109 static HRESULT WINAPI
HTMLSelectElement_put_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL v
)
1111 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1114 TRACE("(%p)->(%x)\n", This
, v
);
1116 nsres
= nsIDOMHTMLSelectElement_SetDisabled(This
->nsselect
, v
!= VARIANT_FALSE
);
1117 if(NS_FAILED(nsres
)) {
1118 ERR("SetDisabled failed: %08lx\n", nsres
);
1125 static HRESULT WINAPI
HTMLSelectElement_get_disabled(IHTMLSelectElement
*iface
, VARIANT_BOOL
*p
)
1127 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1128 cpp_bool disabled
= FALSE
;
1131 TRACE("(%p)->(%p)\n", This
, p
);
1133 nsres
= nsIDOMHTMLSelectElement_GetDisabled(This
->nsselect
, &disabled
);
1134 if(NS_FAILED(nsres
)) {
1135 ERR("GetDisabled failed: %08lx\n", nsres
);
1139 *p
= variant_bool(disabled
);
1143 static HRESULT WINAPI
HTMLSelectElement_get_form(IHTMLSelectElement
*iface
, IHTMLFormElement
**p
)
1145 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1146 nsIDOMHTMLFormElement
*nsform
;
1149 TRACE("(%p)->(%p)\n", This
, p
);
1154 nsres
= nsIDOMHTMLSelectElement_GetForm(This
->nsselect
, &nsform
);
1155 return return_nsform(nsres
, nsform
, p
);
1158 static HRESULT WINAPI
HTMLSelectElement_add(IHTMLSelectElement
*iface
, IHTMLElement
*element
,
1161 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1162 nsIWritableVariant
*nsvariant
;
1163 HTMLElement
*element_obj
;
1166 TRACE("(%p)->(%p %s)\n", This
, element
, debugstr_variant(&before
));
1168 element_obj
= unsafe_impl_from_IHTMLElement(element
);
1170 FIXME("External IHTMLElement implementation?\n");
1171 return E_INVALIDARG
;
1174 if(!element_obj
->html_element
) {
1175 FIXME("Not HTML element\n");
1179 nsvariant
= create_nsvariant();
1183 switch(V_VT(&before
)) {
1186 nsres
= nsIWritableVariant_SetAsEmpty(nsvariant
);
1189 nsres
= nsIWritableVariant_SetAsInt16(nsvariant
, V_I2(&before
));
1192 FIXME("unhandled before %s\n", debugstr_variant(&before
));
1193 nsIWritableVariant_Release(nsvariant
);
1197 if(NS_SUCCEEDED(nsres
))
1198 nsres
= nsIDOMHTMLSelectElement_Add(This
->nsselect
, element_obj
->html_element
, (nsIVariant
*)nsvariant
);
1199 nsIWritableVariant_Release(nsvariant
);
1200 if(NS_FAILED(nsres
)) {
1201 ERR("Add failed: %08lx\n", nsres
);
1208 static HRESULT WINAPI
HTMLSelectElement_remove(IHTMLSelectElement
*iface
, LONG index
)
1210 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1212 TRACE("(%p)->(%ld)\n", This
, index
);
1214 return E_INVALIDARG
;
1216 nsres
= nsIDOMHTMLSelectElement_select_Remove(This
->nsselect
, index
);
1217 if(NS_FAILED(nsres
)) {
1218 ERR("Remove failed: %08lx\n", nsres
);
1224 static HRESULT WINAPI
HTMLSelectElement_put_length(IHTMLSelectElement
*iface
, LONG v
)
1226 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1229 TRACE("(%p)->(%ld)\n", This
, v
);
1231 nsres
= nsIDOMHTMLSelectElement_SetLength(This
->nsselect
, v
);
1232 if(NS_FAILED(nsres
))
1233 ERR("SetLength failed: %08lx\n", nsres
);
1238 static HRESULT WINAPI
HTMLSelectElement_get_length(IHTMLSelectElement
*iface
, LONG
*p
)
1240 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1244 TRACE("(%p)->(%p)\n", This
, p
);
1246 nsres
= nsIDOMHTMLSelectElement_GetLength(This
->nsselect
, &length
);
1247 if(NS_FAILED(nsres
))
1248 ERR("GetLength failed: %08lx\n", nsres
);
1252 TRACE("ret %ld\n", *p
);
1256 static HRESULT WINAPI
HTMLSelectElement_get__newEnum(IHTMLSelectElement
*iface
, IUnknown
**p
)
1258 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1259 HTMLSelectElementEnum
*ret
;
1261 TRACE("(%p)->(%p)\n", This
, p
);
1263 ret
= heap_alloc(sizeof(*ret
));
1265 return E_OUTOFMEMORY
;
1267 ret
->IEnumVARIANT_iface
.lpVtbl
= &HTMLSelectElementEnumVtbl
;
1271 HTMLSelectElement_AddRef(&This
->IHTMLSelectElement_iface
);
1274 *p
= (IUnknown
*)&ret
->IEnumVARIANT_iface
;
1278 static HRESULT WINAPI
HTMLSelectElement_item(IHTMLSelectElement
*iface
, VARIANT name
,
1279 VARIANT index
, IDispatch
**pdisp
)
1281 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1283 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&name
), debugstr_variant(&index
), pdisp
);
1289 if(V_VT(&name
) == VT_I4
) {
1291 return E_INVALIDARG
;
1292 return htmlselect_item(This
, V_I4(&name
), pdisp
);
1295 FIXME("Unsupported args\n");
1299 static HRESULT WINAPI
HTMLSelectElement_tags(IHTMLSelectElement
*iface
, VARIANT tagName
,
1302 HTMLSelectElement
*This
= impl_from_IHTMLSelectElement(iface
);
1303 FIXME("(%p)->(v %p)\n", This
, pdisp
);
1307 static const IHTMLSelectElementVtbl HTMLSelectElementVtbl
= {
1308 HTMLSelectElement_QueryInterface
,
1309 HTMLSelectElement_AddRef
,
1310 HTMLSelectElement_Release
,
1311 HTMLSelectElement_GetTypeInfoCount
,
1312 HTMLSelectElement_GetTypeInfo
,
1313 HTMLSelectElement_GetIDsOfNames
,
1314 HTMLSelectElement_Invoke
,
1315 HTMLSelectElement_put_size
,
1316 HTMLSelectElement_get_size
,
1317 HTMLSelectElement_put_multiple
,
1318 HTMLSelectElement_get_multiple
,
1319 HTMLSelectElement_put_name
,
1320 HTMLSelectElement_get_name
,
1321 HTMLSelectElement_get_options
,
1322 HTMLSelectElement_put_onchange
,
1323 HTMLSelectElement_get_onchange
,
1324 HTMLSelectElement_put_selectedIndex
,
1325 HTMLSelectElement_get_selectedIndex
,
1326 HTMLSelectElement_get_type
,
1327 HTMLSelectElement_put_value
,
1328 HTMLSelectElement_get_value
,
1329 HTMLSelectElement_put_disabled
,
1330 HTMLSelectElement_get_disabled
,
1331 HTMLSelectElement_get_form
,
1332 HTMLSelectElement_add
,
1333 HTMLSelectElement_remove
,
1334 HTMLSelectElement_put_length
,
1335 HTMLSelectElement_get_length
,
1336 HTMLSelectElement_get__newEnum
,
1337 HTMLSelectElement_item
,
1338 HTMLSelectElement_tags
1341 static inline HTMLSelectElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
1343 return CONTAINING_RECORD(iface
, HTMLSelectElement
, element
.node
);
1346 static HRESULT
HTMLSelectElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
1348 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1352 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
1353 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
1354 *ppv
= &This
->IHTMLSelectElement_iface
;
1355 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
1356 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
1357 *ppv
= &This
->IHTMLSelectElement_iface
;
1358 }else if(IsEqualGUID(&IID_IHTMLSelectElement
, riid
)) {
1359 TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This
, ppv
);
1360 *ppv
= &This
->IHTMLSelectElement_iface
;
1364 IUnknown_AddRef((IUnknown
*)*ppv
);
1368 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
1371 static HRESULT
HTMLSelectElementImpl_put_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL v
)
1373 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1374 return IHTMLSelectElement_put_disabled(&This
->IHTMLSelectElement_iface
, v
);
1377 static HRESULT
HTMLSelectElementImpl_get_disabled(HTMLDOMNode
*iface
, VARIANT_BOOL
*p
)
1379 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1380 return IHTMLSelectElement_get_disabled(&This
->IHTMLSelectElement_iface
, p
);
1383 #define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
1385 static HRESULT
HTMLSelectElement_get_dispid(HTMLDOMNode
*iface
, BSTR name
, DWORD flags
, DISPID
*dispid
)
1390 for(ptr
= name
; *ptr
&& is_digit(*ptr
); ptr
++) {
1391 idx
= idx
*10 + (*ptr
-'0');
1392 if(idx
> MSHTML_CUSTOM_DISPID_CNT
) {
1393 WARN("too big idx\n");
1394 return DISP_E_UNKNOWNNAME
;
1398 return DISP_E_UNKNOWNNAME
;
1400 *dispid
= DISPID_OPTIONCOL_0
+ idx
;
1404 static HRESULT
HTMLSelectElement_dispex_get_name(HTMLDOMNode
*iface
, DISPID id
, BSTR
*name
)
1406 DWORD idx
= id
- DISPID_OPTIONCOL_0
;
1410 if(idx
> MSHTML_CUSTOM_DISPID_CNT
)
1411 return DISP_E_MEMBERNOTFOUND
;
1413 len
= swprintf(buf
, ARRAY_SIZE(buf
), L
"%u", idx
);
1414 return (*name
= SysAllocStringLen(buf
, len
)) ? S_OK
: E_OUTOFMEMORY
;
1417 static HRESULT
HTMLSelectElement_invoke(HTMLDOMNode
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1418 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1420 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1422 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
1425 case DISPATCH_PROPERTYGET
: {
1429 hres
= htmlselect_item(This
, id
-DISPID_OPTIONCOL_0
, &ret
);
1434 V_VT(res
) = VT_DISPATCH
;
1435 V_DISPATCH(res
) = ret
;
1437 V_VT(res
) = VT_NULL
;
1443 FIXME("unimplemented flags %x\n", flags
);
1450 static void HTMLSelectElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
1452 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1455 note_cc_edge((nsISupports
*)This
->nsselect
, "This->nsselect", cb
);
1458 static void HTMLSelectElement_unlink(HTMLDOMNode
*iface
)
1460 HTMLSelectElement
*This
= impl_from_HTMLDOMNode(iface
);
1462 if(This
->nsselect
) {
1463 nsIDOMHTMLSelectElement
*nsselect
= This
->nsselect
;
1465 This
->nsselect
= NULL
;
1466 nsIDOMHTMLSelectElement_Release(nsselect
);
1470 static const NodeImplVtbl HTMLSelectElementImplVtbl
= {
1471 &CLSID_HTMLSelectElement
,
1472 HTMLSelectElement_QI
,
1473 HTMLElement_destructor
,
1476 HTMLElement_handle_event
,
1477 HTMLElement_get_attr_col
,
1479 HTMLSelectElementImpl_put_disabled
,
1480 HTMLSelectElementImpl_get_disabled
,
1483 HTMLSelectElement_get_dispid
,
1484 HTMLSelectElement_dispex_get_name
,
1485 HTMLSelectElement_invoke
,
1487 HTMLSelectElement_traverse
,
1488 HTMLSelectElement_unlink
1491 static const tid_t HTMLSelectElement_tids
[] = {
1493 IHTMLSelectElement_tid
,
1497 static dispex_static_data_t HTMLSelectElement_dispex
= {
1498 L
"HTMLSelectElement",
1500 DispHTMLSelectElement_tid
,
1501 HTMLSelectElement_tids
,
1502 HTMLElement_init_dispex_info
1505 HRESULT
HTMLSelectElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
1507 HTMLSelectElement
*ret
;
1510 ret
= heap_alloc_zero(sizeof(HTMLSelectElement
));
1512 return E_OUTOFMEMORY
;
1514 ret
->IHTMLSelectElement_iface
.lpVtbl
= &HTMLSelectElementVtbl
;
1515 ret
->element
.node
.vtbl
= &HTMLSelectElementImplVtbl
;
1517 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLSelectElement_dispex
);
1519 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLSelectElement
, (void**)&ret
->nsselect
);
1520 assert(nsres
== NS_OK
);
1522 *elem
= &ret
->element
;