dsound: Get rid of the DSOUND_QueryInterface() helper.
[wine/multimedia.git] / dlls / mshtml / htmlstyleelem.c
blobd0eb9c02b903732c6b651563bf96a6ee7b10926c
1 /*
2 * Copyright 2010 Jacek Caban for CodeWeavers
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.
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.
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
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "winreg.h"
28 #include "ole2.h"
30 #include "wine/debug.h"
32 #include "mshtml_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 typedef struct {
37 HTMLElement element;
39 IHTMLStyleElement IHTMLStyleElement_iface;
41 nsIDOMHTMLStyleElement *nsstyle;
42 } HTMLStyleElement;
44 static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
46 return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
49 static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
50 REFIID riid, void **ppv)
52 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
54 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
57 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
59 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
61 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
64 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
66 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
68 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
71 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
73 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
74 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
77 static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
78 LCID lcid, ITypeInfo **ppTInfo)
80 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
81 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
82 ppTInfo);
85 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
86 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
88 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
98 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
104 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
105 nsAString type_str;
106 nsresult nsres;
108 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
110 nsAString_InitDepend(&type_str, v);
111 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
112 nsAString_Finish(&type_str);
113 if(NS_FAILED(nsres)) {
114 ERR("SetType failed: %08x\n", nsres);
115 return E_FAIL;
118 return S_OK;
121 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
123 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
124 nsAString nsstr;
125 nsresult nsres;
127 TRACE("(%p)->(%p)\n", This, p);
129 nsAString_Init(&nsstr, NULL);
130 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
131 return return_nsstr(nsres, &nsstr, p);
134 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
136 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
137 FIXME("(%p)->(%p)\n", This, p);
138 return E_NOTIMPL;
141 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
143 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
144 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
145 return E_NOTIMPL;
148 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
150 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
151 FIXME("(%p)->(%p)\n", This, p);
152 return E_NOTIMPL;
155 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
157 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
158 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
159 return E_NOTIMPL;
162 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
164 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
165 FIXME("(%p)->(%p)\n", This, p);
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
171 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
172 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
173 return E_NOTIMPL;
176 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
178 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
179 FIXME("(%p)->(%p)\n", This, p);
180 return E_NOTIMPL;
183 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
185 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
186 FIXME("(%p)->(%p)\n", This, p);
187 return E_NOTIMPL;
190 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
192 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
193 FIXME("(%p)->(%x)\n", This, v);
194 return E_NOTIMPL;
197 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
199 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
200 FIXME("(%p)->(%p)\n", This, p);
201 return E_NOTIMPL;
204 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
206 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
207 nsAString media_str;
208 nsresult nsres;
210 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
212 nsAString_InitDepend(&media_str, v);
213 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
214 nsAString_Finish(&media_str);
215 if(NS_FAILED(nsres)) {
216 ERR("SetMedia failed: %08x\n", nsres);
217 return E_FAIL;
220 return S_OK;
223 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
225 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
226 nsAString nsstr;
227 nsresult nsres;
229 TRACE("(%p)->(%p)\n", This, p);
231 nsAString_Init(&nsstr, NULL);
232 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
233 return return_nsstr(nsres, &nsstr, p);
236 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
237 HTMLStyleElement_QueryInterface,
238 HTMLStyleElement_AddRef,
239 HTMLStyleElement_Release,
240 HTMLStyleElement_GetTypeInfoCount,
241 HTMLStyleElement_GetTypeInfo,
242 HTMLStyleElement_GetIDsOfNames,
243 HTMLStyleElement_Invoke,
244 HTMLStyleElement_put_type,
245 HTMLStyleElement_get_type,
246 HTMLStyleElement_get_readyState,
247 HTMLStyleElement_put_onreadystatechange,
248 HTMLStyleElement_get_onreadystatechange,
249 HTMLStyleElement_put_onload,
250 HTMLStyleElement_get_onload,
251 HTMLStyleElement_put_onerror,
252 HTMLStyleElement_get_onerror,
253 HTMLStyleElement_get_styleSheet,
254 HTMLStyleElement_put_disabled,
255 HTMLStyleElement_get_disabled,
256 HTMLStyleElement_put_media,
257 HTMLStyleElement_get_media
260 static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
262 return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
265 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
267 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
269 if(IsEqualGUID(&IID_IUnknown, riid)) {
270 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
271 *ppv = &This->IHTMLStyleElement_iface;
272 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
273 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
274 *ppv = &This->IHTMLStyleElement_iface;
275 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
276 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
277 *ppv = &This->IHTMLStyleElement_iface;
278 }else {
279 return HTMLElement_QI(&This->element.node, riid, ppv);
282 IUnknown_AddRef((IUnknown*)*ppv);
283 return S_OK;
286 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
287 HTMLStyleElement_QI,
288 HTMLElement_destructor,
289 HTMLElement_clone,
290 HTMLElement_get_attr_col
293 static const tid_t HTMLStyleElement_iface_tids[] = {
294 HTMLELEMENT_TIDS,
295 IHTMLStyleElement_tid,
298 static dispex_static_data_t HTMLStyleElement_dispex = {
299 NULL,
300 DispHTMLStyleElement_tid,
301 NULL,
302 HTMLStyleElement_iface_tids
305 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
307 HTMLStyleElement *ret;
308 nsresult nsres;
310 ret = heap_alloc_zero(sizeof(*ret));
311 if(!ret)
312 return E_OUTOFMEMORY;
314 ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
315 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
317 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
319 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
321 /* Share nsstyle reference with nsnode */
322 assert(nsres == NS_OK && (nsIDOMNode*)ret->nsstyle == ret->element.node.nsnode);
323 nsIDOMNode_Release(ret->element.node.nsnode);
325 *elem = &ret->element;
326 return S_OK;