xref: /reactos/dll/win32/mshtml/htmlgeneric.c (revision c2c66aff)
1 /*
2  * Copyright 2008 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "mshtml_private.h"
20 
21 typedef struct {
22     HTMLElement element;
23 
24     IHTMLGenericElement IHTMLGenericElement_iface;
25 } HTMLGenericElement;
26 
impl_from_IHTMLGenericElement(IHTMLGenericElement * iface)27 static inline HTMLGenericElement *impl_from_IHTMLGenericElement(IHTMLGenericElement *iface)
28 {
29     return CONTAINING_RECORD(iface, HTMLGenericElement, IHTMLGenericElement_iface);
30 }
31 
HTMLGenericElement_QueryInterface(IHTMLGenericElement * iface,REFIID riid,void ** ppv)32 static HRESULT WINAPI HTMLGenericElement_QueryInterface(IHTMLGenericElement *iface, REFIID riid, void **ppv)
33 {
34     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
35 
36     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
37 }
38 
HTMLGenericElement_AddRef(IHTMLGenericElement * iface)39 static ULONG WINAPI HTMLGenericElement_AddRef(IHTMLGenericElement *iface)
40 {
41     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
42 
43     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
44 }
45 
HTMLGenericElement_Release(IHTMLGenericElement * iface)46 static ULONG WINAPI HTMLGenericElement_Release(IHTMLGenericElement *iface)
47 {
48     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
49 
50     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
51 }
52 
HTMLGenericElement_GetTypeInfoCount(IHTMLGenericElement * iface,UINT * pctinfo)53 static HRESULT WINAPI HTMLGenericElement_GetTypeInfoCount(IHTMLGenericElement *iface, UINT *pctinfo)
54 {
55     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
56     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
57 }
58 
HTMLGenericElement_GetTypeInfo(IHTMLGenericElement * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)59 static HRESULT WINAPI HTMLGenericElement_GetTypeInfo(IHTMLGenericElement *iface, UINT iTInfo,
60                                               LCID lcid, ITypeInfo **ppTInfo)
61 {
62     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
63     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
64             ppTInfo);
65 }
66 
HTMLGenericElement_GetIDsOfNames(IHTMLGenericElement * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)67 static HRESULT WINAPI HTMLGenericElement_GetIDsOfNames(IHTMLGenericElement *iface, REFIID riid,
68         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
69 {
70     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
71     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
72             cNames, lcid, rgDispId);
73 }
74 
HTMLGenericElement_Invoke(IHTMLGenericElement * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)75 static HRESULT WINAPI HTMLGenericElement_Invoke(IHTMLGenericElement *iface, DISPID dispIdMember,
76         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
77         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
78 {
79     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
80     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
81             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
82 }
83 
HTMLGenericElement_get_recordset(IHTMLGenericElement * iface,IDispatch ** p)84 static HRESULT WINAPI HTMLGenericElement_get_recordset(IHTMLGenericElement *iface, IDispatch **p)
85 {
86     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
87     FIXME("(%p)->(%p)\n", This, p);
88     return E_NOTIMPL;
89 }
90 
HTMLGenericElement_namedRecordset(IHTMLGenericElement * iface,BSTR dataMember,VARIANT * hierarchy,IDispatch ** ppRecordset)91 static HRESULT WINAPI HTMLGenericElement_namedRecordset(IHTMLGenericElement *iface,
92         BSTR dataMember, VARIANT *hierarchy, IDispatch **ppRecordset)
93 {
94     HTMLGenericElement *This = impl_from_IHTMLGenericElement(iface);
95     FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(dataMember), hierarchy, ppRecordset);
96     return E_NOTIMPL;
97 }
98 
99 static const IHTMLGenericElementVtbl HTMLGenericElementVtbl = {
100     HTMLGenericElement_QueryInterface,
101     HTMLGenericElement_AddRef,
102     HTMLGenericElement_Release,
103     HTMLGenericElement_GetTypeInfoCount,
104     HTMLGenericElement_GetTypeInfo,
105     HTMLGenericElement_GetIDsOfNames,
106     HTMLGenericElement_Invoke,
107     HTMLGenericElement_get_recordset,
108     HTMLGenericElement_namedRecordset
109 };
110 
impl_from_HTMLDOMNode(HTMLDOMNode * iface)111 static inline HTMLGenericElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
112 {
113     return CONTAINING_RECORD(iface, HTMLGenericElement, element.node);
114 }
115 
HTMLGenericElement_QI(HTMLDOMNode * iface,REFIID riid,void ** ppv)116 static HRESULT HTMLGenericElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
117 {
118     HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
119 
120     *ppv = NULL;
121 
122     if(IsEqualGUID(&IID_IHTMLGenericElement, riid)) {
123         TRACE("(%p)->(IID_IHTMLGenericElement %p)\n", This, ppv);
124         *ppv = &This->IHTMLGenericElement_iface;
125     }else {
126         return HTMLElement_QI(&This->element.node, riid, ppv);
127     }
128 
129     IUnknown_AddRef((IUnknown*)*ppv);
130     return S_OK;
131 }
132 
HTMLGenericElement_destructor(HTMLDOMNode * iface)133 static void HTMLGenericElement_destructor(HTMLDOMNode *iface)
134 {
135     HTMLGenericElement *This = impl_from_HTMLDOMNode(iface);
136 
137     HTMLElement_destructor(&This->element.node);
138 }
139 
140 static const NodeImplVtbl HTMLGenericElementImplVtbl = {
141     HTMLGenericElement_QI,
142     HTMLGenericElement_destructor,
143     HTMLElement_cpc,
144     HTMLElement_clone,
145     HTMLElement_handle_event,
146     HTMLElement_get_attr_col
147 };
148 
149 static const tid_t HTMLGenericElement_iface_tids[] = {
150     HTMLELEMENT_TIDS,
151     IHTMLGenericElement_tid,
152     0
153 };
154 
155 static dispex_static_data_t HTMLGenericElement_dispex = {
156     NULL,
157     DispHTMLGenericElement_tid,
158     NULL,
159     HTMLGenericElement_iface_tids
160 };
161 
HTMLGenericElement_Create(HTMLDocumentNode * doc,nsIDOMHTMLElement * nselem,HTMLElement ** elem)162 HRESULT HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
163 {
164     HTMLGenericElement *ret;
165 
166     ret = heap_alloc_zero(sizeof(HTMLGenericElement));
167     if(!ret)
168         return E_OUTOFMEMORY;
169 
170     ret->IHTMLGenericElement_iface.lpVtbl = &HTMLGenericElementVtbl;
171     ret->element.node.vtbl = &HTMLGenericElementImplVtbl;
172 
173     HTMLElement_Init(&ret->element, doc, nselem, &HTMLGenericElement_dispex);
174 
175     *elem = &ret->element;
176     return S_OK;
177 }
178