2006-03-06 22:37:10 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2006 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-03-06 22:37:10 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2008-10-09 22:36:01 +02:00
|
|
|
#include "htmlevent.h"
|
2006-03-06 22:37:10 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
typedef struct {
|
2007-09-15 16:07:01 +02:00
|
|
|
HTMLElement element;
|
|
|
|
|
2010-12-06 23:31:55 +01:00
|
|
|
IHTMLSelectElement IHTMLSelectElement_iface;
|
2006-03-06 22:37:10 +01:00
|
|
|
|
|
|
|
nsIDOMHTMLSelectElement *nsselect;
|
|
|
|
} HTMLSelectElement;
|
|
|
|
|
2010-12-06 23:31:55 +01:00
|
|
|
static inline HTMLSelectElement *impl_from_IHTMLSelectElement(IHTMLSelectElement *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLSelectElement, IHTMLSelectElement_iface);
|
|
|
|
}
|
2006-03-06 22:37:10 +01:00
|
|
|
|
2010-05-11 17:57:27 +02:00
|
|
|
static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
|
|
|
|
{
|
|
|
|
nsIDOMHTMLOptionsCollection *nscol;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2010-05-11 17:57:27 +02:00
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetOptions failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLOptionsCollection_Item(nscol, i, &nsnode);
|
|
|
|
nsIDOMHTMLOptionsCollection_Release(nscol);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Item failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(nsnode) {
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->element.node.doc, nsnode, TRUE, &node);
|
2010-05-11 17:57:27 +02:00
|
|
|
nsIDOMNode_Release(nsnode);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2010-05-11 17:57:27 +02:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
IHTMLDOMNode_AddRef(&node->IHTMLDOMNode_iface);
|
|
|
|
*ret = (IDispatch*)&node->IHTMLDOMNode_iface;
|
2010-05-11 17:57:27 +02:00
|
|
|
}else {
|
|
|
|
*ret = NULL;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-03-06 22:37:10 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLSelectElement_Release(IHTMLSelectElement *iface)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_GetTypeInfoCount(IHTMLSelectElement *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:25:19 +02:00
|
|
|
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_GetTypeInfo(IHTMLSelectElement *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:25:19 +02:00
|
|
|
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
|
|
|
|
ppTInfo);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_GetIDsOfNames(IHTMLSelectElement *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:25:19 +02:00
|
|
|
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
|
|
|
|
cNames, lcid, rgDispId);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_Invoke(IHTMLSelectElement *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:25:19 +02:00
|
|
|
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_size(IHTMLSelectElement *iface, LONG v)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2009-03-12 01:43:18 +01:00
|
|
|
FIXME("(%p)->(%d)\n", This, v);
|
2006-03-06 22:37:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_size(IHTMLSelectElement *iface, LONG *p)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_multiple(IHTMLSelectElement *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%x)\n", This, v);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_multiple(IHTMLSelectElement *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_name(IHTMLSelectElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_name(IHTMLSelectElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-07 23:11:41 +01:00
|
|
|
nsAString name_str;
|
2006-04-08 20:00:09 +02:00
|
|
|
const PRUnichar *name = NULL;
|
2006-03-07 23:11:41 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&name_str, NULL);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetName(This->nsselect, &name_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2006-10-20 15:38:13 +02:00
|
|
|
static const WCHAR wszGarbage[] = {'g','a','r','b','a','g','e',0};
|
|
|
|
|
2007-12-17 01:38:30 +01:00
|
|
|
nsAString_GetData(&name_str, &name);
|
2006-10-20 15:38:13 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Native never returns empty string here. If an element has no name,
|
|
|
|
* name of previous element or ramdom data is returned.
|
|
|
|
*/
|
|
|
|
*p = SysAllocString(*name ? name : wszGarbage);
|
2006-03-07 23:11:41 +01:00
|
|
|
}else {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("GetName failed: %08x\n", nsres);
|
2006-03-07 23:11:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&name_str);
|
|
|
|
|
2006-10-19 23:26:46 +02:00
|
|
|
TRACE("name=%s\n", debugstr_w(*p));
|
2006-03-07 23:11:41 +01:00
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_options(IHTMLSelectElement *iface, IDispatch **p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2010-04-29 18:28:57 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2010-12-06 23:31:55 +01:00
|
|
|
*p = (IDispatch*)&This->IHTMLSelectElement_iface;
|
2010-04-29 18:28:57 +02:00
|
|
|
IDispatch_AddRef(*p);
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_onchange(IHTMLSelectElement *iface, VARIANT v)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:23:30 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
return set_node_event(&This->element.node, EVENTID_CHANGE, &v);
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_onchange(IHTMLSelectElement *iface, VARIANT *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_selectedIndex(IHTMLSelectElement *iface, LONG v)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2007-10-14 00:11:48 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, v);
|
2007-10-14 00:11:48 +02:00
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_SetSelectedIndex(This->nsselect, v);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("SetSelectedIndex failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_selectedIndex(IHTMLSelectElement *iface, LONG *p)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2007-10-14 00:11:48 +02:00
|
|
|
PRInt32 idx = 0;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetSelectedIndex(This->nsselect, &idx);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("GetSelectedIndex failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
*p = idx;
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_type(IHTMLSelectElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:24:59 +02:00
|
|
|
const PRUnichar *type;
|
|
|
|
nsAString type_str;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&type_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetType(This->nsselect, &type_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsAString_GetData(&type_str, &type);
|
|
|
|
*p = *type ? SysAllocString(type) : NULL;
|
|
|
|
}else {
|
|
|
|
ERR("GetType failed: %08x\n", nsres);
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&type_str);
|
|
|
|
|
|
|
|
return hres;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_value(IHTMLSelectElement *iface, BSTR v)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-06-24 22:22:54 +02:00
|
|
|
nsAString value_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
|
2010-01-28 23:56:31 +01:00
|
|
|
nsAString_InitDepend(&value_str, v);
|
2008-06-24 22:22:54 +02:00
|
|
|
nsres = nsIDOMHTMLSelectElement_SetValue(This->nsselect, &value_str);
|
|
|
|
nsAString_Finish(&value_str);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("SetValue failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_value(IHTMLSelectElement *iface, BSTR *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-07 23:11:41 +01:00
|
|
|
nsAString value_str;
|
2006-04-08 20:00:09 +02:00
|
|
|
const PRUnichar *value = NULL;
|
2006-03-07 23:11:41 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&value_str, NULL);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetValue(This->nsselect, &value_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2007-12-17 01:38:30 +01:00
|
|
|
nsAString_GetData(&value_str, &value);
|
2008-06-24 22:23:12 +02:00
|
|
|
*p = *value ? SysAllocString(value) : NULL;
|
2006-03-07 23:11:41 +01:00
|
|
|
}else {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("GetValue failed: %08x\n", nsres);
|
2006-03-07 23:11:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&value_str);
|
|
|
|
|
2006-10-19 23:26:46 +02:00
|
|
|
TRACE("value=%s\n", debugstr_w(*p));
|
2006-03-07 23:11:41 +01:00
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_disabled(IHTMLSelectElement *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-10-09 22:32:55 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, v);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_SetDisabled(This->nsselect, v != VARIANT_FALSE);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetDisabled failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_disabled(IHTMLSelectElement *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2008-10-09 22:32:55 +02:00
|
|
|
PRBool disabled = FALSE;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetDisabled(This->nsselect, &disabled);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetDisabled failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = disabled ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_form(IHTMLSelectElement *iface, IHTMLFormElement **p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_add(IHTMLSelectElement *iface, IHTMLElement *element,
|
|
|
|
VARIANT before)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2012-01-27 17:45:39 +01:00
|
|
|
nsIWritableVariant *nsvariant;
|
|
|
|
HTMLElement *element_obj;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s)\n", This, element, debugstr_variant(&before));
|
2010-01-24 21:38:20 +01:00
|
|
|
|
2012-01-27 17:45:39 +01:00
|
|
|
element_obj = unsafe_impl_from_IHTMLElement(element);
|
|
|
|
if(!element_obj) {
|
|
|
|
FIXME("External IHTMLElement implementation?\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsvariant = create_nsvariant();
|
|
|
|
if(!nsvariant)
|
|
|
|
return E_FAIL;
|
2010-01-24 21:38:20 +01:00
|
|
|
|
2012-01-27 17:45:39 +01:00
|
|
|
switch(V_VT(&before)) {
|
|
|
|
case VT_EMPTY:
|
|
|
|
nsres = nsIWritableVariant_SetAsEmpty(nsvariant);
|
|
|
|
break;
|
|
|
|
case VT_I2:
|
|
|
|
nsres = nsIWritableVariant_SetAsInt16(nsvariant, V_I2(&before));
|
|
|
|
break;
|
|
|
|
default:
|
2010-01-24 21:38:20 +01:00
|
|
|
FIXME("unhandled before %s\n", debugstr_variant(&before));
|
2012-01-27 17:45:39 +01:00
|
|
|
nsIWritableVariant_Release(nsvariant);
|
2010-01-24 21:38:20 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2012-01-27 17:45:39 +01:00
|
|
|
if(NS_SUCCEEDED(nsres))
|
|
|
|
nsres = nsIDOMHTMLSelectElement_Add(This->nsselect, element_obj->nselem, (nsIVariant*)nsvariant);
|
|
|
|
nsIWritableVariant_Release(nsvariant);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Add failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2010-01-24 21:38:20 +01:00
|
|
|
|
2012-01-27 17:45:39 +01:00
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_remove(IHTMLSelectElement *iface, LONG index)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2009-03-12 01:43:18 +01:00
|
|
|
FIXME("(%p)->(%d)\n", This, index);
|
2006-03-06 22:37:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_put_length(IHTMLSelectElement *iface, LONG v)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2010-04-29 18:28:38 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, v);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_SetLength(This->nsselect, v);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("SetLength failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
static HRESULT WINAPI HTMLSelectElement_get_length(IHTMLSelectElement *iface, LONG *p)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2007-10-04 02:15:09 +02:00
|
|
|
PRUint32 length = 0;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLSelectElement_GetLength(This->nsselect, &length);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("GetLength failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
*p = length;
|
|
|
|
|
2009-03-12 01:43:18 +01:00
|
|
|
TRACE("ret %d\n", *p);
|
2007-10-04 02:15:09 +02:00
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_get__newEnum(IHTMLSelectElement *iface, IUnknown **p)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_item(IHTMLSelectElement *iface, VARIANT name,
|
|
|
|
VARIANT index, IDispatch **pdisp)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2010-05-11 17:57:39 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
|
|
|
|
|
|
|
|
if(!pdisp)
|
|
|
|
return E_POINTER;
|
|
|
|
*pdisp = NULL;
|
|
|
|
|
|
|
|
if(V_VT(&name) == VT_I4) {
|
|
|
|
if(V_I4(&name) < 0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
return htmlselect_item(This, V_I4(&name), pdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unsupported args\n");
|
2006-03-06 22:37:10 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLSelectElement_tags(IHTMLSelectElement *iface, VARIANT tagName,
|
|
|
|
IDispatch **pdisp)
|
|
|
|
{
|
2010-12-06 23:31:55 +01:00
|
|
|
HTMLSelectElement *This = impl_from_IHTMLSelectElement(iface);
|
2006-03-06 22:37:10 +01:00
|
|
|
FIXME("(%p)->(v %p)\n", This, pdisp);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
|
|
|
|
HTMLSelectElement_QueryInterface,
|
|
|
|
HTMLSelectElement_AddRef,
|
|
|
|
HTMLSelectElement_Release,
|
|
|
|
HTMLSelectElement_GetTypeInfoCount,
|
|
|
|
HTMLSelectElement_GetTypeInfo,
|
|
|
|
HTMLSelectElement_GetIDsOfNames,
|
|
|
|
HTMLSelectElement_Invoke,
|
|
|
|
HTMLSelectElement_put_size,
|
|
|
|
HTMLSelectElement_get_size,
|
|
|
|
HTMLSelectElement_put_multiple,
|
|
|
|
HTMLSelectElement_get_multiple,
|
|
|
|
HTMLSelectElement_put_name,
|
|
|
|
HTMLSelectElement_get_name,
|
|
|
|
HTMLSelectElement_get_options,
|
|
|
|
HTMLSelectElement_put_onchange,
|
|
|
|
HTMLSelectElement_get_onchange,
|
|
|
|
HTMLSelectElement_put_selectedIndex,
|
|
|
|
HTMLSelectElement_get_selectedIndex,
|
|
|
|
HTMLSelectElement_get_type,
|
|
|
|
HTMLSelectElement_put_value,
|
|
|
|
HTMLSelectElement_get_value,
|
|
|
|
HTMLSelectElement_put_disabled,
|
|
|
|
HTMLSelectElement_get_disabled,
|
|
|
|
HTMLSelectElement_get_form,
|
|
|
|
HTMLSelectElement_add,
|
|
|
|
HTMLSelectElement_remove,
|
|
|
|
HTMLSelectElement_put_length,
|
|
|
|
HTMLSelectElement_get_length,
|
|
|
|
HTMLSelectElement_get__newEnum,
|
|
|
|
HTMLSelectElement_item,
|
|
|
|
HTMLSelectElement_tags
|
|
|
|
};
|
|
|
|
|
2010-12-27 20:13:09 +01:00
|
|
|
static inline HTMLSelectElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLSelectElement, element.node);
|
|
|
|
}
|
2007-10-04 02:08:56 +02:00
|
|
|
|
2007-10-04 02:10:36 +02:00
|
|
|
static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
|
2007-10-04 02:10:36 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-12-06 23:31:55 +01:00
|
|
|
*ppv = &This->IHTMLSelectElement_iface;
|
2007-10-04 02:10:36 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2010-12-06 23:31:55 +01:00
|
|
|
*ppv = &This->IHTMLSelectElement_iface;
|
2007-10-04 02:10:36 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
|
2010-12-06 23:31:55 +01:00
|
|
|
*ppv = &This->IHTMLSelectElement_iface;
|
2007-10-04 02:10:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLElement_QI(&This->element.node, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2007-10-04 02:08:56 +02:00
|
|
|
static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
|
2007-10-04 02:08:56 +02:00
|
|
|
|
|
|
|
nsIDOMHTMLSelectElement_Release(This->nsselect);
|
2007-10-04 02:09:48 +02:00
|
|
|
|
|
|
|
HTMLElement_destructor(&This->element.node);
|
2007-10-04 02:08:56 +02:00
|
|
|
}
|
|
|
|
|
2008-10-09 22:26:41 +02:00
|
|
|
static HRESULT HTMLSelectElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
|
2010-12-06 23:31:55 +01:00
|
|
|
return IHTMLSelectElement_put_disabled(&This->IHTMLSelectElement_iface, v);
|
2008-10-09 22:26:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT HTMLSelectElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
|
2010-12-06 23:31:55 +01:00
|
|
|
return IHTMLSelectElement_get_disabled(&This->IHTMLSelectElement_iface, p);
|
2008-10-09 22:26:41 +02:00
|
|
|
}
|
|
|
|
|
2010-04-29 18:29:23 +02:00
|
|
|
#define DISPID_OPTIONCOL_0 MSHTML_DISPID_CUSTOM_MIN
|
|
|
|
|
|
|
|
static HRESULT HTMLSelectElement_get_dispid(HTMLDOMNode *iface, BSTR name, DWORD flags, DISPID *dispid)
|
|
|
|
{
|
|
|
|
const WCHAR *ptr;
|
|
|
|
DWORD idx = 0;
|
|
|
|
|
|
|
|
for(ptr = name; *ptr && isdigitW(*ptr); ptr++) {
|
|
|
|
idx = idx*10 + (*ptr-'0');
|
|
|
|
if(idx > MSHTML_CUSTOM_DISPID_CNT) {
|
|
|
|
WARN("too big idx\n");
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(*ptr)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
*dispid = DISPID_OPTIONCOL_0 + idx;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT HTMLSelectElement_invoke(HTMLDOMNode *iface, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
|
|
|
|
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLSelectElement *This = impl_from_HTMLDOMNode(iface);
|
2010-04-29 18:29:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
|
|
|
|
|
|
|
|
switch(flags) {
|
|
|
|
case DISPATCH_PROPERTYGET: {
|
2010-05-11 17:57:27 +02:00
|
|
|
IDispatch *ret;
|
|
|
|
HRESULT hres;
|
2010-04-29 18:29:23 +02:00
|
|
|
|
2010-05-11 17:57:27 +02:00
|
|
|
hres = htmlselect_item(This, id-DISPID_OPTIONCOL_0, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2010-04-29 18:29:23 +02:00
|
|
|
|
2010-05-11 17:57:27 +02:00
|
|
|
if(ret) {
|
2010-04-29 18:29:23 +02:00
|
|
|
V_VT(res) = VT_DISPATCH;
|
2010-05-11 17:57:27 +02:00
|
|
|
V_DISPATCH(res) = ret;
|
2010-04-29 18:29:23 +02:00
|
|
|
}else {
|
|
|
|
V_VT(res) = VT_NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unimplemented flags %x\n", flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-04 02:09:48 +02:00
|
|
|
static const NodeImplVtbl HTMLSelectElementImplVtbl = {
|
2007-10-04 02:10:36 +02:00
|
|
|
HTMLSelectElement_QI,
|
2008-10-09 22:26:41 +02:00
|
|
|
HTMLSelectElement_destructor,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLElement_clone,
|
2011-08-25 15:23:35 +02:00
|
|
|
HTMLElement_get_attr_col,
|
2009-09-08 22:29:39 +02:00
|
|
|
NULL,
|
2009-10-13 00:42:22 +02:00
|
|
|
NULL,
|
2011-08-02 11:07:56 +02:00
|
|
|
NULL,
|
2008-10-09 22:26:41 +02:00
|
|
|
HTMLSelectElementImpl_put_disabled,
|
2010-04-29 18:29:23 +02:00
|
|
|
HTMLSelectElementImpl_get_disabled,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
HTMLSelectElement_get_dispid,
|
|
|
|
HTMLSelectElement_invoke
|
2007-10-04 02:09:48 +02:00
|
|
|
};
|
|
|
|
|
2008-06-18 00:09:53 +02:00
|
|
|
static const tid_t HTMLSelectElement_tids[] = {
|
2010-01-28 02:09:02 +01:00
|
|
|
HTMLELEMENT_TIDS,
|
2008-06-18 00:09:53 +02:00
|
|
|
IHTMLSelectElement_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static dispex_static_data_t HTMLSelectElement_dispex = {
|
|
|
|
NULL,
|
|
|
|
DispHTMLSelectElement_tid,
|
|
|
|
NULL,
|
|
|
|
HTMLSelectElement_tids
|
|
|
|
};
|
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
HRESULT HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
|
2006-03-06 22:37:10 +01:00
|
|
|
{
|
2010-12-01 22:43:14 +01:00
|
|
|
HTMLSelectElement *ret;
|
2006-03-06 22:37:10 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
ret = heap_alloc_zero(sizeof(HTMLSelectElement));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2010-12-06 23:31:55 +01:00
|
|
|
ret->IHTMLSelectElement_iface.lpVtbl = &HTMLSelectElementVtbl;
|
2007-10-04 02:09:48 +02:00
|
|
|
ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
|
2008-06-18 00:09:53 +02:00
|
|
|
|
2007-09-15 16:07:01 +02:00
|
|
|
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
|
2006-03-06 22:37:10 +01:00
|
|
|
(void**)&ret->nsselect);
|
2010-12-01 22:43:14 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
|
2010-12-01 22:43:14 +01:00
|
|
|
heap_free(ret);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2006-03-06 22:37:10 +01:00
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
|
|
|
|
|
|
|
|
*elem = &ret->element;
|
|
|
|
return S_OK;
|
2006-03-06 22:37:10 +01:00
|
|
|
}
|