mshtml: Use an iface instead of a vtbl pointer in HTMLEventObj.
[wine] / dlls / mshtml / htmlstyleelem.c
1 /*
2  * Copyright 2010 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 <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28
29 #include "wine/debug.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 typedef struct {
36     HTMLElement element;
37
38     const IHTMLStyleElementVtbl *lpIHTMLStyleElementVtbl;
39 } HTMLStyleElement;
40
41 #define HTMLSTYLE(x)  (&(x)->lpIHTMLStyleElementVtbl)
42
43 #define HTMLSTYLE_THIS(iface) DEFINE_THIS(HTMLStyleElement, IHTMLStyleElement, iface)
44
45 static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
46         REFIID riid, void **ppv)
47 {
48     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
49
50     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
51 }
52
53 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
54 {
55     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
56
57     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
58 }
59
60 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
61 {
62     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
63
64     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
65 }
66
67 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
68 {
69     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
70     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
71 }
72
73 static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
74         LCID lcid, ITypeInfo **ppTInfo)
75 {
76     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
77     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
78 }
79
80 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
81         LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
82 {
83     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
84     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
85 }
86
87 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
88         REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
89         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
90 {
91     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
92     return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
93             pVarResult, pExcepInfo, puArgErr);
94 }
95
96 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
97 {
98     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
99     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
100     return E_NOTIMPL;
101 }
102
103 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
104 {
105     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
106     FIXME("(%p)->(%p)\n", This, p);
107     return E_NOTIMPL;
108 }
109
110 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
111 {
112     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
113     FIXME("(%p)->(%p)\n", This, p);
114     return E_NOTIMPL;
115 }
116
117 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
118 {
119     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
120     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
121     return E_NOTIMPL;
122 }
123
124 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
125 {
126     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
127     FIXME("(%p)->(%p)\n", This, p);
128     return E_NOTIMPL;
129 }
130
131 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
132 {
133     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
134     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
135     return E_NOTIMPL;
136 }
137
138 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
139 {
140     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
141     FIXME("(%p)->(%p)\n", This, p);
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
146 {
147     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
148     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
153 {
154     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
155     FIXME("(%p)->(%p)\n", This, p);
156     return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
160 {
161     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
162     FIXME("(%p)->(%p)\n", This, p);
163     return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
167 {
168     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
169     FIXME("(%p)->(%x)\n", This, v);
170     return E_NOTIMPL;
171 }
172
173 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
174 {
175     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
176     FIXME("(%p)->(%p)\n", This, p);
177     return E_NOTIMPL;
178 }
179
180 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
181 {
182     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
183     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
184     return E_NOTIMPL;
185 }
186
187 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
188 {
189     HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
190     FIXME("(%p)->(%p)\n", This, p);
191     return E_NOTIMPL;
192 }
193
194 #undef HTMLSTYLE_THIS
195
196 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
197     HTMLStyleElement_QueryInterface,
198     HTMLStyleElement_AddRef,
199     HTMLStyleElement_Release,
200     HTMLStyleElement_GetTypeInfoCount,
201     HTMLStyleElement_GetTypeInfo,
202     HTMLStyleElement_GetIDsOfNames,
203     HTMLStyleElement_Invoke,
204     HTMLStyleElement_put_type,
205     HTMLStyleElement_get_type,
206     HTMLStyleElement_get_readyState,
207     HTMLStyleElement_put_onreadystatechange,
208     HTMLStyleElement_get_onreadystatechange,
209     HTMLStyleElement_put_onload,
210     HTMLStyleElement_get_onload,
211     HTMLStyleElement_put_onerror,
212     HTMLStyleElement_get_onerror,
213     HTMLStyleElement_get_styleSheet,
214     HTMLStyleElement_put_disabled,
215     HTMLStyleElement_get_disabled,
216     HTMLStyleElement_put_media,
217     HTMLStyleElement_get_media
218 };
219
220 #define HTMLSTYLE_NODE_THIS(iface) DEFINE_THIS2(HTMLStyleElement, element.node, iface)
221
222 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
223 {
224     HTMLStyleElement *This = HTMLSTYLE_NODE_THIS(iface);
225
226     if(IsEqualGUID(&IID_IUnknown, riid)) {
227         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
228         *ppv = HTMLSTYLE(This);
229     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
230         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
231         *ppv = HTMLSTYLE(This);
232     }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
233         TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
234         *ppv = HTMLSTYLE(This);
235     }else {
236         return HTMLElement_QI(&This->element.node, riid, ppv);
237     }
238
239     IUnknown_AddRef((IUnknown*)*ppv);
240     return S_OK;
241 }
242
243 static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
244 {
245     HTMLStyleElement *This = HTMLSTYLE_NODE_THIS(iface);
246
247     HTMLElement_destructor(&This->element.node);
248 }
249
250 #undef HTMLSTYLE_NODE_THIS
251
252 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
253     HTMLStyleElement_QI,
254     HTMLStyleElement_destructor,
255     HTMLElement_clone
256 };
257
258 static const tid_t HTMLStyleElement_iface_tids[] = {
259     HTMLELEMENT_TIDS,
260     IHTMLStyleElement_tid,
261     0
262 };
263 static dispex_static_data_t HTMLStyleElement_dispex = {
264     NULL,
265     DispHTMLStyleElement_tid,
266     NULL,
267     HTMLStyleElement_iface_tids
268 };
269
270 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
271 {
272     HTMLStyleElement *ret;
273
274     ret = heap_alloc_zero(sizeof(*ret));
275     if(!ret)
276         return E_OUTOFMEMORY;
277
278     ret->lpIHTMLStyleElementVtbl = &HTMLStyleElementVtbl;
279     ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
280
281     HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
282     *elem = &ret->element;
283     return S_OK;
284 }