2009-11-30 18:40:06 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Andrew Eikum 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2012-06-27 10:56:00 +02:00
|
|
|
#include <assert.h>
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2011-02-28 13:13:49 +01:00
|
|
|
#include "htmlevent.h"
|
2013-09-27 15:22:30 +02:00
|
|
|
#include "binding.h"
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
|
|
|
struct HTMLFormElement {
|
|
|
|
HTMLElement element;
|
|
|
|
|
2011-01-04 01:44:12 +01:00
|
|
|
IHTMLFormElement IHTMLFormElement_iface;
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
nsIDOMHTMLFormElement *nsform;
|
|
|
|
};
|
|
|
|
|
2018-02-20 13:25:44 +01:00
|
|
|
HRESULT return_nsform(nsresult nsres, nsIDOMHTMLFormElement *form, IHTMLFormElement **p)
|
|
|
|
{
|
|
|
|
nsIDOMNode *form_node;
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (NS_FAILED(nsres)) {
|
|
|
|
ERR("GetForm failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!form) {
|
|
|
|
*p = NULL;
|
|
|
|
TRACE("NULL\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLFormElement_QueryInterface(form, &IID_nsIDOMNode, (void**)&form_node);
|
|
|
|
nsIDOMHTMLFormElement_Release(form);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
hres = get_node(form_node, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(form_node);
|
|
|
|
if (FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
TRACE("node %p\n", node);
|
|
|
|
hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLFormElement, (void**)p);
|
|
|
|
node_release(node);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2010-05-11 17:57:54 +02:00
|
|
|
static HRESULT htmlform_item(HTMLFormElement *This, int i, IDispatch **ret)
|
|
|
|
{
|
|
|
|
nsIDOMHTMLCollection *elements;
|
|
|
|
nsIDOMNode *item;
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2010-05-11 17:57:54 +02:00
|
|
|
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("GetElements failed: 0x%08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLCollection_Item(elements, i, &item);
|
|
|
|
nsIDOMHTMLCollection_Release(elements);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("Item failed: 0x%08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(item) {
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(item, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2010-05-11 17:57:54 +02:00
|
|
|
|
|
|
|
nsIDOMNode_Release(item);
|
2010-12-30 01:39:16 +01:00
|
|
|
*ret = (IDispatch*)&node->IHTMLDOMNode_iface;
|
2010-05-11 17:57:54 +02:00
|
|
|
}else {
|
|
|
|
*ret = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-04 01:44:12 +01:00
|
|
|
static inline HTMLFormElement *impl_from_IHTMLFormElement(IHTMLFormElement *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLFormElement, IHTMLFormElement_iface);
|
|
|
|
}
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_QueryInterface(IHTMLFormElement *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLFormElement_AddRef(IHTMLFormElement *iface)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLFormElement_Release(IHTMLFormElement *iface)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_GetTypeInfoCount(IHTMLFormElement *iface, UINT *pctinfo)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_GetTypeInfo(IHTMLFormElement *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
|
2010-12-31 11:07:33 +01:00
|
|
|
ppTInfo);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_GetIDsOfNames(IHTMLFormElement *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
|
2010-12-31 11:07:33 +01:00
|
|
|
cNames, lcid, rgDispId);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_Invoke(IHTMLFormElement *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
|
2010-12-31 11:07:33 +01:00
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_action(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-05-11 17:58:24 +02:00
|
|
|
nsAString action_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
|
|
|
|
nsAString_InitDepend(&action_str, v);
|
|
|
|
nsres = nsIDOMHTMLFormElement_SetAction(This->nsform, &action_str);
|
|
|
|
nsAString_Finish(&action_str);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetAction failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_action(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-05-11 17:58:24 +02:00
|
|
|
nsAString action_str;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&action_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetAction(This->nsform, &action_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
const PRUnichar *action;
|
|
|
|
nsAString_GetData(&action_str, &action);
|
|
|
|
hres = nsuri_to_url(action, FALSE, p);
|
|
|
|
}else {
|
|
|
|
ERR("GetAction failed: %08x\n", nsres);
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
|
|
|
|
2011-02-28 13:13:59 +01:00
|
|
|
nsAString_Finish(&action_str);
|
2010-05-11 17:58:24 +02:00
|
|
|
return hres;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_dir(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_dir(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_encoding(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2010-10-28 00:42:20 +02:00
|
|
|
static const WCHAR urlencodedW[] = {'a','p','p','l','i','c','a','t','i','o','n','/',
|
|
|
|
'x','-','w','w','w','-','f','o','r','m','-','u','r','l','e','n','c','o','d','e','d',0};
|
|
|
|
static const WCHAR dataW[] = {'m','u','l','t','i','p','a','r','t','/',
|
|
|
|
'f','o','r','m','-','d','a','t','a',0};
|
|
|
|
static const WCHAR plainW[] = {'t','e','x','t','/','p','l','a','i','n',0};
|
|
|
|
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:42:20 +02:00
|
|
|
nsAString encoding_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
|
|
|
|
if(lstrcmpiW(v, urlencodedW) && lstrcmpiW(v, dataW) && lstrcmpiW(v, plainW)) {
|
|
|
|
WARN("incorrect enctype\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_InitDepend(&encoding_str, v);
|
|
|
|
nsres = nsIDOMHTMLFormElement_SetEnctype(This->nsform, &encoding_str);
|
|
|
|
nsAString_Finish(&encoding_str);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_encoding(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:42:20 +02:00
|
|
|
nsAString encoding_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&encoding_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetEnctype(This->nsform, &encoding_str);
|
2011-01-20 11:48:56 +01:00
|
|
|
return return_nsstr(nsres, &encoding_str, p);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_method(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2010-10-28 00:42:03 +02:00
|
|
|
static const WCHAR postW[] = {'P','O','S','T',0};
|
|
|
|
static const WCHAR getW[] = {'G','E','T',0};
|
|
|
|
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:42:03 +02:00
|
|
|
nsAString method_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
|
|
|
|
if(lstrcmpiW(v, postW) && lstrcmpiW(v, getW)) {
|
|
|
|
WARN("unrecognized method\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_InitDepend(&method_str, v);
|
|
|
|
nsres = nsIDOMHTMLFormElement_SetMethod(This->nsform, &method_str);
|
|
|
|
nsAString_Finish(&method_str);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_method(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:42:03 +02:00
|
|
|
nsAString method_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&method_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetMethod(This->nsform, &method_str);
|
2011-01-20 11:48:56 +01:00
|
|
|
return return_nsstr(nsres, &method_str, p);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDispatch **p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2018-02-08 20:53:41 +01:00
|
|
|
nsIDOMHTMLCollection *elements;
|
|
|
|
nsresult nsres;
|
2011-03-01 11:33:03 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2018-02-08 20:53:41 +01:00
|
|
|
if(dispex_compat_mode(&This->element.node.event_target.dispex) < COMPAT_MODE_IE9) {
|
|
|
|
IDispatch_AddRef(*p = (IDispatch*)&This->IHTMLFormElement_iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetElements failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2018-02-20 13:25:06 +01:00
|
|
|
*p = (IDispatch*)create_collection_from_htmlcol(elements, dispex_compat_mode(&This->element.node.event_target.dispex));
|
2018-02-08 20:53:41 +01:00
|
|
|
nsIDOMHTMLCollection_Release(elements);
|
2011-03-01 11:33:03 +01:00
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_target(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2014-07-21 16:51:11 +02:00
|
|
|
nsAString str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
|
|
|
|
nsAString_InitDepend(&str, v);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLFormElement_SetTarget(This->nsform, &str);
|
|
|
|
|
|
|
|
nsAString_Finish(&str);
|
|
|
|
if (NS_FAILED(nsres)) {
|
|
|
|
ERR("Set Target(%s) failed: %08x\n", wine_dbgstr_w(v), nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_target(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2014-07-21 16:51:11 +02:00
|
|
|
nsAString str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetTarget(This->nsform, &str);
|
|
|
|
|
|
|
|
return return_nsstr(nsres, &str, p);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_name(IHTMLFormElement *iface, BSTR v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:30:33 +02:00
|
|
|
nsAString name_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, wine_dbgstr_w(v));
|
|
|
|
|
|
|
|
nsAString_InitDepend(&name_str, v);
|
|
|
|
nsres = nsIDOMHTMLFormElement_SetName(This->nsform, &name_str);
|
|
|
|
nsAString_Finish(&name_str);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_name(IHTMLFormElement *iface, BSTR *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-10-28 00:30:33 +02:00
|
|
|
nsAString name_str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&name_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetName(This->nsform, &name_str);
|
2011-01-20 11:48:56 +01:00
|
|
|
return return_nsstr(nsres, &name_str, p);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_onsubmit(IHTMLFormElement *iface, VARIANT v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2011-02-28 13:13:49 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
|
|
|
|
return set_node_event(&This->element.node, EVENTID_SUBMIT, &v);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_onsubmit(IHTMLFormElement *iface, VARIANT *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2011-02-28 13:13:49 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return get_node_event(&This->element.node, EVENTID_SUBMIT, p);
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_onreset(IHTMLFormElement *iface, VARIANT v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
|
2009-11-30 18:40:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_onreset(IHTMLFormElement *iface, VARIANT *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_submit(IHTMLFormElement *iface)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2014-03-13 14:47:14 +01:00
|
|
|
HTMLOuterWindow *window = NULL, *this_window = NULL;
|
2015-02-02 13:43:49 +01:00
|
|
|
nsAString action_uri_str, target_str, method_str;
|
2013-09-27 15:22:30 +02:00
|
|
|
nsIInputStream *post_stream;
|
2015-02-02 13:43:49 +01:00
|
|
|
BOOL is_post_submit = FALSE;
|
2013-09-27 15:22:30 +02:00
|
|
|
IUri *uri;
|
2012-04-06 14:58:53 +02:00
|
|
|
nsresult nsres;
|
2013-09-27 15:22:30 +02:00
|
|
|
HRESULT hres;
|
2015-02-07 09:50:58 +01:00
|
|
|
BOOL use_new_window = FALSE;
|
2012-04-06 14:58:53 +02:00
|
|
|
|
2015-02-02 13:43:49 +01:00
|
|
|
TRACE("(%p)\n", This);
|
2012-04-06 14:58:53 +02:00
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
if(This->element.node.doc) {
|
|
|
|
HTMLDocumentNode *doc = This->element.node.doc;
|
|
|
|
if(doc->window && doc->window->base.outer_window)
|
2014-03-13 14:47:14 +01:00
|
|
|
this_window = doc->window->base.outer_window;
|
2013-09-27 15:22:30 +02:00
|
|
|
}
|
2014-03-13 14:47:14 +01:00
|
|
|
if(!this_window) {
|
2013-09-27 15:22:30 +02:00
|
|
|
TRACE("No outer window\n");
|
|
|
|
return S_OK;
|
2012-04-06 14:58:53 +02:00
|
|
|
}
|
|
|
|
|
2014-03-13 14:47:14 +01:00
|
|
|
nsAString_Init(&target_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetTarget(This->nsform, &target_str);
|
2014-12-16 16:13:05 +01:00
|
|
|
if(NS_SUCCEEDED(nsres))
|
2014-03-13 14:47:14 +01:00
|
|
|
window = get_target_window(this_window, &target_str, &use_new_window);
|
2014-12-16 16:13:05 +01:00
|
|
|
|
|
|
|
if(!window && !use_new_window) {
|
|
|
|
nsAString_Finish(&target_str);
|
2014-03-13 14:47:14 +01:00
|
|
|
return S_OK;
|
2014-12-16 16:13:05 +01:00
|
|
|
}
|
2014-03-13 14:47:14 +01:00
|
|
|
|
2015-02-02 13:43:49 +01:00
|
|
|
nsAString_Init(&method_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetMethod(This->nsform, &method_str);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
const PRUnichar *method;
|
|
|
|
|
|
|
|
static const PRUnichar postW[] = {'p','o','s','t',0};
|
|
|
|
|
|
|
|
nsAString_GetData(&method_str, &method);
|
|
|
|
TRACE("method is %s\n", debugstr_w(method));
|
|
|
|
is_post_submit = !strcmpiW(method, postW);
|
|
|
|
}
|
|
|
|
nsAString_Finish(&method_str);
|
|
|
|
|
2013-09-27 15:22:30 +02:00
|
|
|
/*
|
2015-02-02 13:43:49 +01:00
|
|
|
* FIXME: We currently use our submit implementation for POST submit. We should always use it.
|
2013-09-27 15:22:30 +02:00
|
|
|
*/
|
2015-02-02 13:43:49 +01:00
|
|
|
if(window && !is_post_submit) {
|
2013-09-27 15:22:30 +02:00
|
|
|
nsres = nsIDOMHTMLFormElement_Submit(This->nsform);
|
2014-12-16 16:13:05 +01:00
|
|
|
nsAString_Finish(&target_str);
|
2014-03-13 14:47:14 +01:00
|
|
|
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
|
2013-09-27 15:22:30 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Submit failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Init(&action_uri_str, NULL);
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetFormData(This->nsform, NULL, &action_uri_str, &post_stream);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
const PRUnichar *action_uri;
|
|
|
|
|
|
|
|
nsAString_GetData(&action_uri_str, &action_uri);
|
|
|
|
hres = create_uri(action_uri, 0, &uri);
|
|
|
|
}else {
|
|
|
|
ERR("GetFormData failed: %08x\n", nsres);
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
|
|
|
nsAString_Finish(&action_uri_str);
|
|
|
|
if(SUCCEEDED(hres)) {
|
2014-12-16 16:13:05 +01:00
|
|
|
const PRUnichar *target;
|
|
|
|
|
|
|
|
nsAString_GetData(&target_str, &target);
|
|
|
|
hres = submit_form(window, target, uri, post_stream);
|
2013-09-27 15:22:30 +02:00
|
|
|
IUri_Release(uri);
|
|
|
|
}
|
|
|
|
|
2014-12-16 16:13:05 +01:00
|
|
|
nsAString_Finish(&target_str);
|
|
|
|
if(window)
|
|
|
|
IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
|
2013-09-27 15:22:30 +02:00
|
|
|
if(post_stream)
|
|
|
|
nsIInputStream_Release(post_stream);
|
|
|
|
return hres;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_reset(IHTMLFormElement *iface)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2014-07-17 17:48:36 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
nsres = nsIDOMHTMLFormElement_Reset(This->nsform);
|
|
|
|
if (NS_FAILED(nsres)) {
|
|
|
|
ERR("Reset failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_put_length(IHTMLFormElement *iface, LONG v)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(%d)\n", This, v);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_get_length(IHTMLFormElement *iface, LONG *p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-05-07 15:19:48 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2013-01-18 14:05:50 +01:00
|
|
|
nsres = nsIDOMHTMLFormElement_GetLength(This->nsform, p);
|
2010-05-07 15:19:48 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetLength failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement__newEnum(IHTMLFormElement *iface, IUnknown **p)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_item(IHTMLFormElement *iface, VARIANT name,
|
|
|
|
VARIANT index, IDispatch **pdisp)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2010-05-11 17:58:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&name), debugstr_variant(&index), pdisp);
|
|
|
|
|
|
|
|
if(!pdisp)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
*pdisp = NULL;
|
|
|
|
|
|
|
|
if(V_VT(&name) == VT_I4) {
|
2018-02-08 20:53:48 +01:00
|
|
|
if(V_I4(&name) < 0) {
|
|
|
|
*pdisp = NULL;
|
|
|
|
return dispex_compat_mode(&This->element.node.event_target.dispex) >= COMPAT_MODE_IE9
|
|
|
|
? S_OK : E_INVALIDARG;
|
|
|
|
}
|
2010-05-11 17:58:09 +02:00
|
|
|
return htmlform_item(This, V_I4(&name), pdisp);
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unsupported args\n");
|
2009-11-30 18:40:06 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLFormElement_tags(IHTMLFormElement *iface, VARIANT tagName,
|
|
|
|
IDispatch **pdisp)
|
|
|
|
{
|
2011-01-04 01:44:12 +01:00
|
|
|
HTMLFormElement *This = impl_from_IHTMLFormElement(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
FIXME("(%p)->(v %p)\n", This, pdisp);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLFormElementVtbl HTMLFormElementVtbl = {
|
|
|
|
HTMLFormElement_QueryInterface,
|
|
|
|
HTMLFormElement_AddRef,
|
|
|
|
HTMLFormElement_Release,
|
|
|
|
HTMLFormElement_GetTypeInfoCount,
|
|
|
|
HTMLFormElement_GetTypeInfo,
|
|
|
|
HTMLFormElement_GetIDsOfNames,
|
|
|
|
HTMLFormElement_Invoke,
|
|
|
|
HTMLFormElement_put_action,
|
|
|
|
HTMLFormElement_get_action,
|
|
|
|
HTMLFormElement_put_dir,
|
|
|
|
HTMLFormElement_get_dir,
|
|
|
|
HTMLFormElement_put_encoding,
|
|
|
|
HTMLFormElement_get_encoding,
|
|
|
|
HTMLFormElement_put_method,
|
|
|
|
HTMLFormElement_get_method,
|
|
|
|
HTMLFormElement_get_elements,
|
|
|
|
HTMLFormElement_put_target,
|
|
|
|
HTMLFormElement_get_target,
|
|
|
|
HTMLFormElement_put_name,
|
|
|
|
HTMLFormElement_get_name,
|
|
|
|
HTMLFormElement_put_onsubmit,
|
|
|
|
HTMLFormElement_get_onsubmit,
|
|
|
|
HTMLFormElement_put_onreset,
|
|
|
|
HTMLFormElement_get_onreset,
|
|
|
|
HTMLFormElement_submit,
|
|
|
|
HTMLFormElement_reset,
|
|
|
|
HTMLFormElement_put_length,
|
|
|
|
HTMLFormElement_get_length,
|
|
|
|
HTMLFormElement__newEnum,
|
|
|
|
HTMLFormElement_item,
|
|
|
|
HTMLFormElement_tags
|
|
|
|
};
|
|
|
|
|
2010-12-27 20:13:09 +01:00
|
|
|
static inline HTMLFormElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLFormElement, element.node);
|
|
|
|
}
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
static HRESULT HTMLFormElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
2009-11-30 18:40:06 +01:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2011-01-04 01:44:12 +01:00
|
|
|
*ppv = &This->IHTMLFormElement_iface;
|
2009-11-30 18:40:06 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2011-01-04 01:44:12 +01:00
|
|
|
*ppv = &This->IHTMLFormElement_iface;
|
2009-11-30 18:40:06 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLFormElement, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLFormElement %p)\n", This, ppv);
|
2011-01-04 01:44:12 +01:00
|
|
|
*ppv = &This->IHTMLFormElement_iface;
|
2014-10-11 03:18:36 +02:00
|
|
|
}else if(IsEqualGUID(&DIID_DispHTMLFormElement, riid)) {
|
|
|
|
TRACE("(%p)->(DIID_DispHTMLFormElement %p)\n", This, ppv);
|
|
|
|
*ppv = &This->IHTMLFormElement_iface;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLElement_QI(&This->element.node, riid, ppv);
|
|
|
|
}
|
|
|
|
|
2009-12-01 21:18:07 +01:00
|
|
|
static HRESULT HTMLFormElement_get_dispid(HTMLDOMNode *iface,
|
|
|
|
BSTR name, DWORD grfdex, DISPID *pid)
|
|
|
|
{
|
2010-12-27 20:13:09 +01:00
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
2009-12-01 21:18:07 +01:00
|
|
|
nsIDOMHTMLCollection *elements;
|
2014-05-27 11:29:48 +02:00
|
|
|
nsAString nsstr, name_str;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 len, i;
|
2009-12-01 21:18:07 +01:00
|
|
|
nsresult nsres;
|
2010-01-29 14:56:19 +01:00
|
|
|
HRESULT hres = DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
static const PRUnichar nameW[] = {'n','a','m','e',0};
|
2009-12-01 21:18:07 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %x %p)\n", This, wine_dbgstr_w(name), grfdex, pid);
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("GetElements failed: 0x%08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLCollection_GetLength(elements, &len);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("GetLength failed: 0x%08x\n", nsres);
|
|
|
|
nsIDOMHTMLCollection_Release(elements);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2011-03-03 15:18:26 +01:00
|
|
|
if(len > MSHTML_CUSTOM_DISPID_CNT)
|
|
|
|
len = MSHTML_CUSTOM_DISPID_CNT;
|
|
|
|
|
|
|
|
/* FIXME: Implement in more generic way */
|
|
|
|
if('0' <= *name && *name <= '9') {
|
|
|
|
WCHAR *end_ptr;
|
|
|
|
|
|
|
|
i = strtoulW(name, &end_ptr, 10);
|
|
|
|
if(!*end_ptr && i < len) {
|
|
|
|
*pid = MSHTML_DISPID_CUSTOM_MIN + i;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-29 14:56:19 +01:00
|
|
|
nsAString_Init(&nsstr, NULL);
|
2009-12-01 21:18:07 +01:00
|
|
|
for(i = 0; i < len; ++i) {
|
|
|
|
nsIDOMNode *nsitem;
|
2018-02-12 01:28:00 +01:00
|
|
|
nsIDOMElement *elem;
|
2009-12-01 21:18:07 +01:00
|
|
|
const PRUnichar *str;
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLCollection_Item(elements, i, &nsitem);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("Item failed: 0x%08x\n", nsres);
|
2010-01-29 14:56:19 +01:00
|
|
|
hres = E_FAIL;
|
|
|
|
break;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
|
2018-02-12 01:28:00 +01:00
|
|
|
nsres = nsIDOMNode_QueryInterface(nsitem, &IID_nsIDOMElement, (void**)&elem);
|
2009-12-01 21:18:07 +01:00
|
|
|
nsIDOMNode_Release(nsitem);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("Failed to get nsIDOMHTMLNode interface: 0x%08x\n", nsres);
|
2010-01-29 14:56:19 +01:00
|
|
|
hres = E_FAIL;
|
|
|
|
break;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* compare by id attr */
|
2018-02-12 01:28:00 +01:00
|
|
|
nsres = nsIDOMElement_GetId(elem, &nsstr);
|
2009-12-01 21:18:07 +01:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
FIXME("GetId failed: 0x%08x\n", nsres);
|
2018-02-12 01:28:00 +01:00
|
|
|
nsIDOMElement_Release(elem);
|
2010-01-29 14:56:19 +01:00
|
|
|
hres = E_FAIL;
|
|
|
|
break;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
nsAString_GetData(&nsstr, &str);
|
|
|
|
if(!strcmpiW(str, name)) {
|
2018-02-12 01:28:00 +01:00
|
|
|
nsIDOMElement_Release(elem);
|
2009-12-01 21:18:07 +01:00
|
|
|
/* FIXME: using index for dispid */
|
|
|
|
*pid = MSHTML_DISPID_CUSTOM_MIN + i;
|
2010-01-29 14:56:19 +01:00
|
|
|
hres = S_OK;
|
|
|
|
break;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* compare by name attr */
|
2018-02-12 01:28:00 +01:00
|
|
|
nsres = get_elem_attr_value(elem, nameW, &name_str, &str);
|
|
|
|
nsIDOMElement_Release(elem);
|
2014-05-27 11:29:48 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
if(!strcmpiW(str, name)) {
|
|
|
|
nsAString_Finish(&name_str);
|
|
|
|
/* FIXME: using index for dispid */
|
|
|
|
*pid = MSHTML_DISPID_CUSTOM_MIN + i;
|
|
|
|
hres = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
nsAString_Finish(&name_str);
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-27 11:29:48 +02:00
|
|
|
nsAString_Finish(&nsstr);
|
2009-12-01 21:18:07 +01:00
|
|
|
nsIDOMHTMLCollection_Release(elements);
|
2010-01-29 14:56:19 +01:00
|
|
|
return hres;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT HTMLFormElement_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
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
2010-05-11 17:57:54 +02:00
|
|
|
IDispatch *ret;
|
|
|
|
HRESULT hres;
|
2009-12-01 21:18:07 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
|
|
|
|
|
2010-05-11 17:57:54 +02:00
|
|
|
hres = htmlform_item(This, id - MSHTML_DISPID_CUSTOM_MIN, &ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2009-12-01 21:18:07 +01:00
|
|
|
|
2010-05-11 17:57:54 +02:00
|
|
|
if(ret) {
|
|
|
|
V_VT(res) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(res) = ret;
|
|
|
|
}else {
|
|
|
|
V_VT(res) = VT_NULL;
|
2009-12-01 21:18:07 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-08-20 13:04:28 +02:00
|
|
|
static HRESULT HTMLFormElement_handle_event(HTMLDOMNode *iface, eventid_t eid, nsIDOMEvent *event, BOOL *prevent_default)
|
|
|
|
{
|
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
if(eid == EVENTID_SUBMIT) {
|
|
|
|
*prevent_default = TRUE;
|
|
|
|
return IHTMLFormElement_submit(&This->IHTMLFormElement_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
return HTMLElement_handle_event(&This->element.node, eid, event, prevent_default);
|
|
|
|
}
|
|
|
|
|
2014-09-24 16:05:12 +02:00
|
|
|
static void HTMLFormElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
|
|
|
|
{
|
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
if(This->nsform)
|
|
|
|
note_cc_edge((nsISupports*)This->nsform, "This->nsform", cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void HTMLFormElement_unlink(HTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
HTMLFormElement *This = impl_from_HTMLDOMNode(iface);
|
|
|
|
|
|
|
|
if(This->nsform) {
|
|
|
|
nsIDOMHTMLFormElement *nsform = This->nsform;
|
|
|
|
|
|
|
|
This->nsform = NULL;
|
|
|
|
nsIDOMHTMLFormElement_Release(nsform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-30 18:40:06 +01:00
|
|
|
static const NodeImplVtbl HTMLFormElementImplVtbl = {
|
2017-04-21 13:50:49 +02:00
|
|
|
&CLSID_HTMLFormElement,
|
2009-11-30 18:40:06 +01:00
|
|
|
HTMLFormElement_QI,
|
2012-06-27 10:56:00 +02:00
|
|
|
HTMLElement_destructor,
|
2013-03-15 15:01:53 +01:00
|
|
|
HTMLElement_cpc,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLElement_clone,
|
2014-08-20 13:04:28 +02:00
|
|
|
HTMLFormElement_handle_event,
|
2011-08-25 15:23:35 +02:00
|
|
|
HTMLElement_get_attr_col,
|
2009-12-01 21:18:07 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
HTMLFormElement_get_dispid,
|
2014-09-24 16:05:12 +02:00
|
|
|
HTMLFormElement_invoke,
|
|
|
|
NULL,
|
|
|
|
HTMLFormElement_traverse,
|
|
|
|
HTMLFormElement_unlink
|
2009-11-30 18:40:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static const tid_t HTMLFormElement_iface_tids[] = {
|
2010-01-28 02:09:02 +01:00
|
|
|
HTMLELEMENT_TIDS,
|
2009-11-30 18:40:06 +01:00
|
|
|
IHTMLFormElement_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static dispex_static_data_t HTMLFormElement_dispex = {
|
|
|
|
NULL,
|
|
|
|
DispHTMLFormElement_tid,
|
2016-07-07 12:50:18 +02:00
|
|
|
HTMLFormElement_iface_tids,
|
|
|
|
HTMLElement_init_dispex_info
|
2009-11-30 18:40:06 +01:00
|
|
|
};
|
|
|
|
|
2018-02-12 01:29:41 +01:00
|
|
|
HRESULT HTMLFormElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
|
2009-11-30 18:40:06 +01:00
|
|
|
{
|
2010-12-01 22:43:14 +01:00
|
|
|
HTMLFormElement *ret;
|
2009-11-30 18:40:06 +01:00
|
|
|
nsresult nsres;
|
|
|
|
|
2010-12-01 22:43:14 +01:00
|
|
|
ret = heap_alloc_zero(sizeof(HTMLFormElement));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-01-04 01:44:12 +01:00
|
|
|
ret->IHTMLFormElement_iface.lpVtbl = &HTMLFormElementVtbl;
|
2009-11-30 18:40:06 +01:00
|
|
|
ret->element.node.vtbl = &HTMLFormElementImplVtbl;
|
|
|
|
|
2012-06-27 10:56:00 +02:00
|
|
|
HTMLElement_Init(&ret->element, doc, nselem, &HTMLFormElement_dispex);
|
|
|
|
|
2018-02-12 01:29:41 +01:00
|
|
|
nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLFormElement, (void**)&ret->nsform);
|
2014-09-24 16:05:12 +02:00
|
|
|
assert(nsres == NS_OK);
|
2010-12-01 22:43:14 +01:00
|
|
|
|
|
|
|
*elem = &ret->element;
|
|
|
|
return S_OK;
|
2009-11-30 18:40:06 +01:00
|
|
|
}
|