From 78b579dff22701febf5dd8948eb3dfc9bcdb810b Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 14 Mar 2013 17:52:34 +0100 Subject: [PATCH] mshtml: Added IHTMLButtonElement stub implementation. --- dlls/mshtml/htmlelem.c | 2 + dlls/mshtml/htmlinput.c | 229 +++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 3 + dlls/mshtml/tests/dom.c | 15 ++- 4 files changed, 247 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index f0789f866b7..cb25a18d3cb 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -38,6 +38,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); static const WCHAR aW[] = {'A',0}; static const WCHAR bodyW[] = {'B','O','D','Y',0}; +static const WCHAR buttonW[] = {'B','U','T','T','O','N',0}; static const WCHAR embedW[] = {'E','M','B','E','D',0}; static const WCHAR formW[] = {'F','O','R','M',0}; static const WCHAR frameW[] = {'F','R','A','M','E',0}; @@ -67,6 +68,7 @@ typedef struct { static const tag_desc_t tag_descs[] = { {aW, HTMLAnchorElement_Create}, {bodyW, HTMLBodyElement_Create}, + {buttonW, HTMLButtonElement_Create}, {embedW, HTMLEmbedElement_Create}, {formW, HTMLFormElement_Create}, {frameW, HTMLFrameElement_Create}, diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c index c660ca85f17..8c7769a66e5 100644 --- a/dlls/mshtml/htmlinput.c +++ b/dlls/mshtml/htmlinput.c @@ -1410,3 +1410,232 @@ HRESULT HTMLLabelElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem *elem = &ret->element; return S_OK; } + +typedef struct { + HTMLElement element; + + IHTMLButtonElement IHTMLButtonElement_iface; +} HTMLButtonElement; + +static inline HTMLButtonElement *impl_from_IHTMLButtonElement(IHTMLButtonElement *iface) +{ + return CONTAINING_RECORD(iface, HTMLButtonElement, IHTMLButtonElement_iface); +} + +static HRESULT WINAPI HTMLButtonElement_QueryInterface(IHTMLButtonElement *iface, + REFIID riid, void **ppv) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv); +} + +static ULONG WINAPI HTMLButtonElement_AddRef(IHTMLButtonElement *iface) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface); +} + +static ULONG WINAPI HTMLButtonElement_Release(IHTMLButtonElement *iface) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface); +} + +static HRESULT WINAPI HTMLButtonElement_GetTypeInfoCount(IHTMLButtonElement *iface, UINT *pctinfo) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo); +} + +static HRESULT WINAPI HTMLButtonElement_GetTypeInfo(IHTMLButtonElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLButtonElement_GetIDsOfNames(IHTMLButtonElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames, + cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLButtonElement_Invoke(IHTMLButtonElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + + return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLButtonElement_get_type(IHTMLButtonElement *iface, BSTR *p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_put_value(IHTMLButtonElement *iface, BSTR v) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_get_value(IHTMLButtonElement *iface, BSTR *p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_put_name(IHTMLButtonElement *iface, BSTR v) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_get_name(IHTMLButtonElement *iface, BSTR *p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_put_status(IHTMLButtonElement *iface, VARIANT v) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_get_status(IHTMLButtonElement *iface, VARIANT *p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_put_disabled(IHTMLButtonElement *iface, VARIANT_BOOL v) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%x)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_get_disabled(IHTMLButtonElement *iface, VARIANT_BOOL *p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_get_form(IHTMLButtonElement *iface, IHTMLFormElement **p) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLButtonElement_createTextRange(IHTMLButtonElement *iface, IHTMLTxtRange **range) +{ + HTMLButtonElement *This = impl_from_IHTMLButtonElement(iface); + FIXME("(%p)->(%p)\n", This, range); + return E_NOTIMPL; +} + +static const IHTMLButtonElementVtbl HTMLButtonElementVtbl = { + HTMLButtonElement_QueryInterface, + HTMLButtonElement_AddRef, + HTMLButtonElement_Release, + HTMLButtonElement_GetTypeInfoCount, + HTMLButtonElement_GetTypeInfo, + HTMLButtonElement_GetIDsOfNames, + HTMLButtonElement_Invoke, + HTMLButtonElement_get_type, + HTMLButtonElement_put_value, + HTMLButtonElement_get_value, + HTMLButtonElement_put_name, + HTMLButtonElement_get_name, + HTMLButtonElement_put_status, + HTMLButtonElement_get_status, + HTMLButtonElement_put_disabled, + HTMLButtonElement_get_disabled, + HTMLButtonElement_get_form, + HTMLButtonElement_createTextRange +}; + +static inline HTMLButtonElement *button_from_HTMLDOMNode(HTMLDOMNode *iface) +{ + return CONTAINING_RECORD(iface, HTMLButtonElement, element.node); +} + +static HRESULT HTMLButtonElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLButtonElement *This = button_from_HTMLDOMNode(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = &This->IHTMLButtonElement_iface; + }else if(IsEqualGUID(&IID_IHTMLButtonElement, riid)) { + TRACE("(%p)->(IID_IHTMLButtonElement %p)\n", This, ppv); + *ppv = &This->IHTMLButtonElement_iface; + }else { + return HTMLElement_QI(&This->element.node, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static const NodeImplVtbl HTMLButtonElementImplVtbl = { + HTMLButtonElement_QI, + HTMLElement_destructor, + HTMLElement_clone, + HTMLElement_handle_event, + HTMLElement_get_attr_col, +}; + +static const tid_t HTMLButtonElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLButtonElement_tid, + 0 +}; + +static dispex_static_data_t HTMLButtonElement_dispex = { + NULL, + DispHTMLButtonElement_tid, + NULL, + HTMLButtonElement_iface_tids +}; + +HRESULT HTMLButtonElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem) +{ + HTMLButtonElement *ret; + + ERR("!!!\n"); + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; + + ret->IHTMLButtonElement_iface.lpVtbl = &HTMLButtonElementVtbl; + ret->element.node.vtbl = &HTMLButtonElementImplVtbl; + + HTMLElement_Init(&ret->element, doc, nselem, &HTMLButtonElement_dispex); + *elem = &ret->element; + return S_OK; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index c515e6c3e6b..9983edecb6d 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -77,6 +77,7 @@ typedef struct event_target_t event_target_t; XDIID(DispHTMLAnchorElement) \ XDIID(DispHTMLAttributeCollection) \ XDIID(DispHTMLBody) \ + XDIID(DispHTMLButtonElement) \ XDIID(DispHTMLCommentElement) \ XDIID(DispHTMLCurrentStyle) \ XDIID(DispHTMLDocument) \ @@ -119,6 +120,7 @@ typedef struct event_target_t event_target_t; XIID(IHTMLAttributeCollection3) \ XIID(IHTMLBodyElement) \ XIID(IHTMLBodyElement2) \ + XIID(IHTMLButtonElement) \ XIID(IHTMLCommentElement) \ XIID(IHTMLCurrentStyle) \ XIID(IHTMLCurrentStyle2) \ @@ -869,6 +871,7 @@ HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**) DEC HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; +HRESULT HTMLButtonElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 2fde048f3f4..d2be89f351d 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -53,6 +53,7 @@ static const char elem_test_str[] = "link" "" "" + "" "" "" "
td1 texttd2 text
" @@ -128,7 +129,8 @@ typedef enum { ET_META, ET_NOSCRIPT, ET_LINK, - ET_LABEL + ET_LABEL, + ET_BUTTON } elem_type_t; static const IID * const none_iids[] = { @@ -207,6 +209,13 @@ static const IID * const input_iids[] = { NULL }; +static const IID *const button_iids[] = { + ELEM_IFACES, + &IID_IHTMLButtonElement, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const label_iids[] = { ELEM_IFACES, &IID_IHTMLLabelElement, @@ -457,7 +466,8 @@ static const elem_type_info_t elem_type_infos[] = { {"META", meta_iids, &DIID_DispHTMLMetaElement}, {"NOSCRIPT", elem_iids, NULL /*&DIID_DispHTMLNoShowElement*/}, {"LINK", link_iids, &DIID_DispHTMLLinkElement}, - {"LABEL", label_iids, &DIID_DispHTMLLabelElement} + {"LABEL", label_iids, &DIID_DispHTMLLabelElement}, + {"BUTTON", button_iids, &DIID_DispHTMLButtonElement} }; static const char *dbgstr_guid(REFIID riid) @@ -5768,6 +5778,7 @@ static void test_elems(IHTMLDocument2 *doc) ET_A, ET_LABEL, ET_INPUT, + ET_BUTTON, ET_SELECT, ET_OPTION, ET_OPTION, -- 2.11.4.GIT