dsdmo: Add Flanger effect stub.
[wine.git] / dlls / mshtml / htmlstyleelem.c
blobabd720cc18f5091bbe850399b11c14afab795c96
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>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "mshtmdid.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 struct HTMLStyleElement {
37 HTMLElement element;
39 IHTMLStyleElement IHTMLStyleElement_iface;
40 IHTMLStyleElement2 IHTMLStyleElement2_iface;
42 nsIDOMHTMLStyleElement *nsstyle;
43 IHTMLStyleSheet *style_sheet;
46 static inline HTMLStyleElement *impl_from_IHTMLStyleElement(IHTMLStyleElement *iface)
48 return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement_iface);
51 static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
52 REFIID riid, void **ppv)
54 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
56 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
59 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
61 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
63 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
66 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
68 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
70 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
73 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
75 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
76 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
79 static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
80 LCID lcid, ITypeInfo **ppTInfo)
82 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
83 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
84 ppTInfo);
87 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
88 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
90 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
91 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
92 cNames, lcid, rgDispId);
95 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
96 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
97 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
99 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
100 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
101 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
104 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
106 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
107 nsAString type_str;
108 nsresult nsres;
110 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
112 nsAString_InitDepend(&type_str, v);
113 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
114 nsAString_Finish(&type_str);
115 if(NS_FAILED(nsres)) {
116 ERR("SetType failed: %08lx\n", nsres);
117 return E_FAIL;
120 return S_OK;
123 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
125 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
126 nsAString nsstr;
127 nsresult nsres;
129 TRACE("(%p)->(%p)\n", This, p);
131 nsAString_Init(&nsstr, NULL);
132 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
133 return return_nsstr(nsres, &nsstr, p);
136 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
138 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
139 FIXME("(%p)->(%p)\n", This, p);
140 return E_NOTIMPL;
143 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
145 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
146 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
147 return E_NOTIMPL;
150 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
152 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
153 FIXME("(%p)->(%p)\n", This, p);
154 return E_NOTIMPL;
157 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
159 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
160 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
161 return IHTMLElement6_put_onload(&This->element.IHTMLElement6_iface, v);
164 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
166 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
167 TRACE("(%p)->(%p)\n", This, p);
168 return IHTMLElement6_get_onload(&This->element.IHTMLElement6_iface, p);
171 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
173 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
174 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
175 return IHTMLElement6_put_onerror(&This->element.IHTMLElement6_iface, v);
178 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
180 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
181 TRACE("(%p)->(%p)\n", This, p);
182 return IHTMLElement6_get_onerror(&This->element.IHTMLElement6_iface, p);
185 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
187 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
189 TRACE("(%p)->(%p)\n", This, p);
191 if(!This->nsstyle)
192 return E_FAIL;
194 if(!This->style_sheet) {
195 nsIDOMStyleSheet *ss;
196 nsresult nsres;
198 nsres = nsIDOMHTMLStyleElement_GetDOMStyleSheet(This->nsstyle, &ss);
199 assert(nsres == NS_OK);
201 if(ss) {
202 HRESULT hres = create_style_sheet(ss, dispex_compat_mode(&This->element.node.event_target.dispex),
203 &This->style_sheet);
204 nsIDOMStyleSheet_Release(ss);
205 if(FAILED(hres))
206 return hres;
210 if(This->style_sheet)
211 IHTMLStyleSheet_AddRef(This->style_sheet);
212 *p = This->style_sheet;
213 return S_OK;
216 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
218 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
219 FIXME("(%p)->(%x)\n", This, v);
220 return E_NOTIMPL;
223 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
225 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
226 FIXME("(%p)->(%p)\n", This, p);
227 return E_NOTIMPL;
230 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
232 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
233 nsAString media_str;
234 nsresult nsres;
236 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
238 nsAString_InitDepend(&media_str, v);
239 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
240 nsAString_Finish(&media_str);
241 if(NS_FAILED(nsres)) {
242 ERR("SetMedia failed: %08lx\n", nsres);
243 return E_FAIL;
246 return S_OK;
249 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
251 HTMLStyleElement *This = impl_from_IHTMLStyleElement(iface);
252 nsAString nsstr;
253 nsresult nsres;
255 TRACE("(%p)->(%p)\n", This, p);
257 nsAString_Init(&nsstr, NULL);
258 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
259 return return_nsstr(nsres, &nsstr, p);
262 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
263 HTMLStyleElement_QueryInterface,
264 HTMLStyleElement_AddRef,
265 HTMLStyleElement_Release,
266 HTMLStyleElement_GetTypeInfoCount,
267 HTMLStyleElement_GetTypeInfo,
268 HTMLStyleElement_GetIDsOfNames,
269 HTMLStyleElement_Invoke,
270 HTMLStyleElement_put_type,
271 HTMLStyleElement_get_type,
272 HTMLStyleElement_get_readyState,
273 HTMLStyleElement_put_onreadystatechange,
274 HTMLStyleElement_get_onreadystatechange,
275 HTMLStyleElement_put_onload,
276 HTMLStyleElement_get_onload,
277 HTMLStyleElement_put_onerror,
278 HTMLStyleElement_get_onerror,
279 HTMLStyleElement_get_styleSheet,
280 HTMLStyleElement_put_disabled,
281 HTMLStyleElement_get_disabled,
282 HTMLStyleElement_put_media,
283 HTMLStyleElement_get_media
286 static inline HTMLStyleElement *impl_from_IHTMLStyleElement2(IHTMLStyleElement2 *iface)
288 return CONTAINING_RECORD(iface, HTMLStyleElement, IHTMLStyleElement2_iface);
291 static HRESULT WINAPI HTMLStyleElement2_QueryInterface(IHTMLStyleElement2 *iface,
292 REFIID riid, void **ppv)
294 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
296 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
299 static ULONG WINAPI HTMLStyleElement2_AddRef(IHTMLStyleElement2 *iface)
301 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
303 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
306 static ULONG WINAPI HTMLStyleElement2_Release(IHTMLStyleElement2 *iface)
308 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
310 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
313 static HRESULT WINAPI HTMLStyleElement2_GetTypeInfoCount(IHTMLStyleElement2 *iface, UINT *pctinfo)
315 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
316 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
319 static HRESULT WINAPI HTMLStyleElement2_GetTypeInfo(IHTMLStyleElement2 *iface, UINT iTInfo,
320 LCID lcid, ITypeInfo **ppTInfo)
322 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
323 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
324 ppTInfo);
327 static HRESULT WINAPI HTMLStyleElement2_GetIDsOfNames(IHTMLStyleElement2 *iface, REFIID riid,
328 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
330 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
331 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
332 cNames, lcid, rgDispId);
335 static HRESULT WINAPI HTMLStyleElement2_Invoke(IHTMLStyleElement2 *iface, DISPID dispIdMember,
336 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
337 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
339 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
340 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
341 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
344 static HRESULT WINAPI HTMLStyleElement2_get_sheet(IHTMLStyleElement2 *iface, IHTMLStyleSheet **p)
346 HTMLStyleElement *This = impl_from_IHTMLStyleElement2(iface);
347 TRACE("(%p)->(%p)\n", This, p);
348 return IHTMLStyleElement_get_styleSheet(&This->IHTMLStyleElement_iface, p);
351 static const IHTMLStyleElement2Vtbl HTMLStyleElement2Vtbl = {
352 HTMLStyleElement2_QueryInterface,
353 HTMLStyleElement2_AddRef,
354 HTMLStyleElement2_Release,
355 HTMLStyleElement2_GetTypeInfoCount,
356 HTMLStyleElement2_GetTypeInfo,
357 HTMLStyleElement2_GetIDsOfNames,
358 HTMLStyleElement2_Invoke,
359 HTMLStyleElement2_get_sheet
362 static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
364 return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
367 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
369 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
371 if(IsEqualGUID(&IID_IUnknown, riid)) {
372 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
373 *ppv = &This->IHTMLStyleElement_iface;
374 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
375 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
376 *ppv = &This->IHTMLStyleElement_iface;
377 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
378 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
379 *ppv = &This->IHTMLStyleElement_iface;
380 }else if(IsEqualGUID(&IID_IHTMLStyleElement2, riid)) {
381 TRACE("(%p)->(IID_IHTMLStyleElement2 %p)\n", This, ppv);
382 *ppv = &This->IHTMLStyleElement2_iface;
383 }else {
384 return HTMLElement_QI(&This->element.node, riid, ppv);
387 IUnknown_AddRef((IUnknown*)*ppv);
388 return S_OK;
391 static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
393 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
395 if(This->style_sheet) {
396 IHTMLStyleSheet_Release(This->style_sheet);
397 This->style_sheet = NULL;
400 HTMLElement_destructor(iface);
403 static void HTMLStyleElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
405 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
407 if(This->nsstyle)
408 note_cc_edge((nsISupports*)This->nsstyle, "This->nsstyle", cb);
411 static void HTMLStyleElement_unlink(HTMLDOMNode *iface)
413 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
415 if(This->nsstyle) {
416 nsIDOMHTMLStyleElement *nsstyle = This->nsstyle;
418 This->nsstyle = NULL;
419 nsIDOMHTMLStyleElement_Release(nsstyle);
423 static void HTMLStyleElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
425 static const dispex_hook_t ie11_hooks[] = {
426 {DISPID_IHTMLSTYLEELEMENT_READYSTATE, NULL},
427 {DISPID_IHTMLSTYLEELEMENT_STYLESHEET, NULL},
428 {DISPID_UNKNOWN}
431 HTMLElement_init_dispex_info(info, mode);
433 dispex_info_add_interface(info, IHTMLStyleElement_tid,
434 mode >= COMPAT_MODE_IE11 ? ie11_hooks : NULL);
436 if(mode >= COMPAT_MODE_IE9)
437 dispex_info_add_interface(info, IHTMLStyleElement2_tid, NULL);
440 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
441 &CLSID_HTMLStyleElement,
442 HTMLStyleElement_QI,
443 HTMLStyleElement_destructor,
444 HTMLElement_cpc,
445 HTMLElement_clone,
446 HTMLElement_handle_event,
447 HTMLElement_get_attr_col,
448 NULL,
449 NULL,
450 NULL,
451 NULL,
452 NULL,
453 NULL,
454 NULL,
455 NULL,
456 NULL,
457 HTMLStyleElement_traverse,
458 HTMLStyleElement_unlink
461 static const tid_t HTMLStyleElement_iface_tids[] = {
462 HTMLELEMENT_TIDS,
465 static dispex_static_data_t HTMLStyleElement_dispex = {
466 L"HTMLStyleElement",
467 NULL,
468 DispHTMLStyleElement_tid,
469 HTMLStyleElement_iface_tids,
470 HTMLStyleElement_init_dispex_info
473 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
475 HTMLStyleElement *ret;
476 nsresult nsres;
478 ret = calloc(1, sizeof(*ret));
479 if(!ret)
480 return E_OUTOFMEMORY;
482 ret->IHTMLStyleElement_iface.lpVtbl = &HTMLStyleElementVtbl;
483 ret->IHTMLStyleElement2_iface.lpVtbl = &HTMLStyleElement2Vtbl;
484 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
486 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
488 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
489 assert(nsres == NS_OK);
491 *elem = &ret->element;
492 return S_OK;