From 1563c137fa8a5f0ad08e73f2a7d37371490f726e Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Mon, 30 Nov 2009 11:40:06 -0600 Subject: [PATCH] mshtml: Add stub implementation of IHTMLFormElement. --- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/dispex.c | 2 + dlls/mshtml/htmlelem.c | 3 + dlls/mshtml/htmlform.c | 380 +++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 3 + dlls/mshtml/nsiface.idl | 27 ++- dlls/mshtml/tests/dom.c | 22 ++- 7 files changed, 434 insertions(+), 4 deletions(-) create mode 100644 dlls/mshtml/htmlform.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 53c995e6366..e7ca4180fbd 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -25,6 +25,7 @@ C_SRCS = \ htmlelem3.c \ htmlelemcol.c \ htmlevent.c \ + htmlform.c \ htmlframebase.c \ htmlgeneric.c \ htmliframe.c \ diff --git a/dlls/mshtml/dispex.c b/dlls/mshtml/dispex.c index f26f897583c..8216c8b2975 100644 --- a/dlls/mshtml/dispex.c +++ b/dlls/mshtml/dispex.c @@ -90,6 +90,7 @@ static REFIID tid_ids[] = { &DIID_DispHTMLDocument, &DIID_DispHTMLDOMTextNode, &DIID_DispHTMLElementCollection, + &DIID_DispHTMLFormElement, &DIID_DispHTMLGenericElement, &DIID_DispHTMLIFrame, &DIID_DispHTMLImg, @@ -127,6 +128,7 @@ static REFIID tid_ids[] = { &IID_IHTMLElement4, &IID_IHTMLElementCollection, &IID_IHTMLEventObj, + &IID_IHTMLFormElement, &IID_IHTMLFrameBase, &IID_IHTMLFrameBase2, &IID_IHTMLGenericElement, diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 45338fef0c1..4e154cd4d3b 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1568,6 +1568,7 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL static const WCHAR wszA[] = {'A',0}; static const WCHAR wszBODY[] = {'B','O','D','Y',0}; + static const WCHAR wszFORM[] = {'F','O','R','M',0}; static const WCHAR wszIFRAME[] = {'I','F','R','A','M','E',0}; static const WCHAR wszIMG[] = {'I','M','G',0}; static const WCHAR wszINPUT[] = {'I','N','P','U','T',0}; @@ -1591,6 +1592,8 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL ret = HTMLAnchorElement_Create(doc, nselem); else if(!strcmpW(class_name, wszBODY)) ret = HTMLBodyElement_Create(doc, nselem); + else if(!strcmpW(class_name, wszFORM)) + ret = HTMLFormElement_Create(doc, nselem); else if(!strcmpW(class_name, wszIFRAME)) ret = HTMLIFrame_Create(doc, nselem, NULL); else if(!strcmpW(class_name, wszIMG)) diff --git a/dlls/mshtml/htmlform.c b/dlls/mshtml/htmlform.c new file mode 100644 index 00000000000..153d8aa5b8e --- /dev/null +++ b/dlls/mshtml/htmlform.c @@ -0,0 +1,380 @@ +/* + * 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 + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +struct HTMLFormElement { + HTMLElement element; + + const IHTMLFormElementVtbl *lpHTMLFormElementVtbl; + + nsIDOMHTMLFormElement *nsform; +}; + +#define HTMLFORM(x) (&(x)->lpHTMLFormElementVtbl) + +#define HTMLFORM_THIS(iface) DEFINE_THIS(HTMLFormElement, HTMLFormElement, iface) + +static HRESULT WINAPI HTMLFormElement_QueryInterface(IHTMLFormElement *iface, + REFIID riid, void **ppv) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv); +} + +static ULONG WINAPI HTMLFormElement_AddRef(IHTMLFormElement *iface) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node)); +} + +static ULONG WINAPI HTMLFormElement_Release(IHTMLFormElement *iface) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node)); +} + +static HRESULT WINAPI HTMLFormElement_GetTypeInfoCount(IHTMLFormElement *iface, UINT *pctinfo) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLFormElement_GetTypeInfo(IHTMLFormElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLFormElement_GetIDsOfNames(IHTMLFormElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLFormElement_Invoke(IHTMLFormElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLFormElement_put_action(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_action(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_dir(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_dir(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_encoding(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_encoding(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_method(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_method(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_elements(IHTMLFormElement *iface, IDispatch **p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_target(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_target(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_name(IHTMLFormElement *iface, BSTR v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%s)\n", This, wine_dbgstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_name(IHTMLFormElement *iface, BSTR *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_onsubmit(IHTMLFormElement *iface, VARIANT v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_onsubmit(IHTMLFormElement *iface, VARIANT *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_onreset(IHTMLFormElement *iface, VARIANT v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(v)\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_onreset(IHTMLFormElement *iface, VARIANT *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_submit(IHTMLFormElement *iface) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->()\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_reset(IHTMLFormElement *iface) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->()\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_put_length(IHTMLFormElement *iface, LONG v) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%d)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_get_length(IHTMLFormElement *iface, LONG *p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement__newEnum(IHTMLFormElement *iface, IUnknown **p) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_item(IHTMLFormElement *iface, VARIANT name, + VARIANT index, IDispatch **pdisp) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(v v %p)\n", This, pdisp); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLFormElement_tags(IHTMLFormElement *iface, VARIANT tagName, + IDispatch **pdisp) +{ + HTMLFormElement *This = HTMLFORM_THIS(iface); + FIXME("(%p)->(v %p)\n", This, pdisp); + return E_NOTIMPL; +} + +#undef HTMLFORM_THIS + +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 +}; + +#define HTMLFORM_NODE_THIS(iface) DEFINE_THIS2(HTMLFormElement, element.node, iface) + +static HRESULT HTMLFormElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLFormElement *This = HTMLFORM_NODE_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLFORM(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLFORM(This); + }else if(IsEqualGUID(&IID_IHTMLFormElement, riid)) { + TRACE("(%p)->(IID_IHTMLFormElement %p)\n", This, ppv); + *ppv = HTMLFORM(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + return HTMLElement_QI(&This->element.node, riid, ppv); +} + +static void HTMLFormElement_destructor(HTMLDOMNode *iface) +{ + HTMLFormElement *This = HTMLFORM_NODE_THIS(iface); + + if(This->nsform) + nsIDOMHTMLFormElement_Release(This->nsform); + + HTMLElement_destructor(&This->element.node); +} + +#undef HTMLFORM_NODE_THIS + +static const NodeImplVtbl HTMLFormElementImplVtbl = { + HTMLFormElement_QI, + HTMLFormElement_destructor +}; + +static const tid_t HTMLFormElement_iface_tids[] = { + IHTMLDOMNode_tid, + IHTMLDOMNode2_tid, + IHTMLElement_tid, + IHTMLElement2_tid, + IHTMLElement3_tid, + IHTMLFormElement_tid, + 0 +}; + +static dispex_static_data_t HTMLFormElement_dispex = { + NULL, + DispHTMLFormElement_tid, + NULL, + HTMLFormElement_iface_tids +}; + +HTMLElement *HTMLFormElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem) +{ + HTMLFormElement *ret = heap_alloc_zero(sizeof(HTMLFormElement)); + nsresult nsres; + + ret->lpHTMLFormElementVtbl = &HTMLFormElementVtbl; + ret->element.node.vtbl = &HTMLFormElementImplVtbl; + + HTMLElement_Init(&ret->element, doc, nselem, &HTMLFormElement_dispex); + + nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLFormElement, (void**)&ret->nsform); + if(NS_FAILED(nsres)) + ERR("Could not get nsIDOMHTMLFormElement interface: %08x\n", nsres); + + return &ret->element; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 2cb22da12c1..e0e842cc40d 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -67,6 +67,7 @@ typedef enum { DispHTMLDocument_tid, DispHTMLDOMTextNode_tid, DispHTMLElementCollection_tid, + DispHTMLFormElement_tid, DispHTMLGenericElement_tid, DispHTMLIFrame_tid, DispHTMLImg_tid, @@ -104,6 +105,7 @@ typedef enum { IHTMLElement4_tid, IHTMLElementCollection_tid, IHTMLEventObj_tid, + IHTMLFormElement_tid, IHTMLFrameBase_tid, IHTMLFrameBase2_tid, IHTMLGenericElement_tid, @@ -728,6 +730,7 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL); HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*); HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); +HTMLElement *HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*); HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*); HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 3612613652c..68d37fef6f6 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -119,7 +119,6 @@ typedef nsISupports nsIDOMDOMImplementation; typedef nsISupports nsIDOMCDATASection; typedef nsISupports nsIDOMProcessingInstruction; typedef nsISupports nsIDOMEntityReference; -typedef nsISupports nsIDOMHTMLFormElement; typedef nsISupports nsIDOMHTMLOptionsCollection; typedef nsISupports nsIWebProgressListener; typedef nsISupports nsIDOMCSSValue; @@ -1222,6 +1221,32 @@ interface nsIDOMHTMLBodyElement : nsIDOMHTMLElement [ object, + uuid(a6cf908f-15b3-11d2-932e-00805f8add32), + local + /* FROZEN */ +] +interface nsIDOMHTMLFormElement : nsIDOMHTMLElement +{ + nsresult GetElements(nsIDOMHTMLCollection **aElements); + nsresult GetLength(PRInt32 *aLength); + nsresult GetName(nsAString *aName); + nsresult SetName(const nsAString *aName); + nsresult GetAcceptCharset(nsAString *aAcceptCharset); + nsresult SetAcceptCharset(const nsAString *aAcceptCharset); + nsresult GetAction(nsAString *aAction); + nsresult SetAction(const nsAString *aAction); + nsresult GetEnctype(nsAString *aEnctype); + nsresult SetEnctype(const nsAString *aEnctype); + nsresult GetMethod(nsAString *aMethod); + nsresult SetMethod(const nsAString *aMethod); + nsresult GetTarget(nsAString *aTarget); + nsresult SetTarget(const nsAString *aTarget); + nsresult Submit(); + nsresult Reset(); +} + +[ + object, uuid(a6cf9093-15b3-11d2-932e-00805f8add32), local /* FROZEN */ diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index f370fe5ae93..e0e1413b097 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -51,6 +51,7 @@ static const char elem_test_str[] = "" "" "" + "
" ""; static const char elem_test2_str[] = "test" @@ -96,7 +97,8 @@ typedef enum { ET_IMG, ET_TR, ET_TD, - ET_IFRAME + ET_IFRAME, + ET_FORM } elem_type_t; static const IID * const none_iids[] = { @@ -320,6 +322,18 @@ static const IID * const iframe_iids[] = { NULL }; +static const IID * const form_iids[] = { + &IID_IHTMLDOMNode, + &IID_IHTMLDOMNode2, + &IID_IHTMLElement, + &IID_IHTMLElement2, + &IID_IHTMLElement3, + &IID_IHTMLFormElement, + &IID_IDispatchEx, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const generic_iids[] = { &IID_IHTMLDOMNode, &IID_IHTMLDOMNode2, @@ -389,7 +403,8 @@ static const elem_type_info_t elem_type_infos[] = { {"IMG", img_iids, &DIID_DispHTMLImg}, {"TR", tr_iids, &DIID_DispHTMLTableRow}, {"TD", td_iids, NULL}, - {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame} + {"IFRAME", iframe_iids, &DIID_DispHTMLIFrame}, + {"FORM", form_iids, &DIID_DispHTMLFormElement} }; static const char *dbgstr_guid(REFIID riid) @@ -5113,7 +5128,8 @@ static void test_elems(IHTMLDocument2 *doc) ET_SCRIPT, ET_TEST, ET_IMG, - ET_IFRAME + ET_IFRAME, + ET_FORM }; static const elem_type_t item_types[] = { -- 2.11.4.GIT