2 * Copyright 2006 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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
35 struct HTMLStyleSheet
{
37 IHTMLStyleSheet IHTMLStyleSheet_iface
;
41 nsIDOMCSSStyleSheet
*nsstylesheet
;
44 struct HTMLStyleSheetsCollection
{
46 IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface
;
50 nsIDOMStyleSheetList
*nslist
;
53 struct HTMLStyleSheetRulesCollection
{
55 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface
;
59 nsIDOMCSSRuleList
*nslist
;
62 struct HTMLStyleSheetRule
{
64 IHTMLStyleSheetRule IHTMLStyleSheetRule_iface
;
68 nsIDOMCSSRule
*nsstylesheetrule
;
71 static inline HTMLStyleSheetRule
*impl_from_IHTMLStyleSheetRule(IHTMLStyleSheetRule
*iface
)
73 return CONTAINING_RECORD(iface
, HTMLStyleSheetRule
, IHTMLStyleSheetRule_iface
);
76 static HRESULT WINAPI
HTMLStyleSheetRule_QueryInterface(IHTMLStyleSheetRule
*iface
,
77 REFIID riid
, void **ppv
)
79 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
81 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
83 if (IsEqualGUID(&IID_IUnknown
, riid
))
84 *ppv
= &This
->IHTMLStyleSheetRule_iface
;
85 else if (IsEqualGUID(&IID_IHTMLStyleSheetRule
, riid
))
86 *ppv
= &This
->IHTMLStyleSheetRule_iface
;
87 else if (dispex_query_interface(&This
->dispex
, riid
, ppv
))
88 return *ppv
? S_OK
: E_NOINTERFACE
;
92 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
96 IUnknown_AddRef((IUnknown
*)*ppv
);
100 static ULONG WINAPI
HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule
*iface
)
102 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
103 LONG ref
= InterlockedIncrement(&This
->ref
);
105 TRACE("(%p) ref=%d\n", This
, ref
);
110 static ULONG WINAPI
HTMLStyleSheetRule_Release(IHTMLStyleSheetRule
*iface
)
112 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
113 LONG ref
= InterlockedDecrement(&This
->ref
);
115 TRACE("(%p) ref=%d\n", This
, ref
);
118 release_dispex(&This
->dispex
);
119 if(This
->nsstylesheetrule
)
120 nsIDOMCSSRule_Release(This
->nsstylesheetrule
);
127 static HRESULT WINAPI
HTMLStyleSheetRule_GetTypeInfoCount(
128 IHTMLStyleSheetRule
*iface
, UINT
*pctinfo
)
130 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
131 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
134 static HRESULT WINAPI
HTMLStyleSheetRule_GetTypeInfo(IHTMLStyleSheetRule
*iface
,
135 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
137 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
138 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
141 static HRESULT WINAPI
HTMLStyleSheetRule_GetIDsOfNames(IHTMLStyleSheetRule
*iface
,
142 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
144 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
145 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
149 static HRESULT WINAPI
HTMLStyleSheetRule_Invoke(IHTMLStyleSheetRule
*iface
,
150 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
151 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
153 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
154 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
155 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
158 static HRESULT WINAPI
HTMLStyleSheetRule_put_selectorText(IHTMLStyleSheetRule
*iface
, BSTR v
)
160 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
161 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
165 static HRESULT WINAPI
HTMLStyleSheetRule_get_selectorText(IHTMLStyleSheetRule
*iface
, BSTR
*p
)
167 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
168 FIXME("(%p)->(%p)\n", This
, p
);
172 static HRESULT WINAPI
HTMLStyleSheetRule_get_style(IHTMLStyleSheetRule
*iface
, IHTMLRuleStyle
**p
)
174 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
175 FIXME("(%p)->(%p)\n", This
, p
);
179 static HRESULT WINAPI
HTMLStyleSheetRule_get_readOnly(IHTMLStyleSheetRule
*iface
, VARIANT_BOOL
*p
)
181 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
182 FIXME("(%p)->(%p)\n", This
, p
);
186 static const IHTMLStyleSheetRuleVtbl HTMLStyleSheetRuleVtbl
= {
187 HTMLStyleSheetRule_QueryInterface
,
188 HTMLStyleSheetRule_AddRef
,
189 HTMLStyleSheetRule_Release
,
190 HTMLStyleSheetRule_GetTypeInfoCount
,
191 HTMLStyleSheetRule_GetTypeInfo
,
192 HTMLStyleSheetRule_GetIDsOfNames
,
193 HTMLStyleSheetRule_Invoke
,
194 HTMLStyleSheetRule_put_selectorText
,
195 HTMLStyleSheetRule_get_selectorText
,
196 HTMLStyleSheetRule_get_style
,
197 HTMLStyleSheetRule_get_readOnly
200 static const tid_t HTMLStyleSheetRule_iface_tids
[] = {
201 IHTMLStyleSheetRule_tid
,
204 static dispex_static_data_t HTMLStyleSheetRule_dispex
= {
206 DispHTMLStyleSheetRule_tid
,
207 HTMLStyleSheetRule_iface_tids
210 static IHTMLStyleSheetRule
*HTMLStyleSheetRule_Create(nsIDOMCSSRule
*nsstylesheetrule
)
212 HTMLStyleSheetRule
*ret
;
215 if(!(ret
= heap_alloc(sizeof(*ret
))))
218 ret
->IHTMLStyleSheetRule_iface
.lpVtbl
= &HTMLStyleSheetRuleVtbl
;
220 ret
->nsstylesheetrule
= NULL
;
222 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetRule_iface
, &HTMLStyleSheetRule_dispex
);
224 if (nsstylesheetrule
)
226 nsres
= nsIDOMCSSRule_QueryInterface(nsstylesheetrule
, &IID_nsIDOMCSSRule
,
227 (void **)&ret
->nsstylesheetrule
);
228 if (NS_FAILED(nsres
))
229 ERR("Could not get nsIDOMCSSRule interface: %08x\n", nsres
);
232 return &ret
->IHTMLStyleSheetRule_iface
;
235 static inline HTMLStyleSheetRulesCollection
*impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection
*iface
)
237 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, IHTMLStyleSheetRulesCollection_iface
);
240 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection
*iface
,
241 REFIID riid
, void **ppv
)
243 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
245 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
247 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
248 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
249 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection
, riid
)) {
250 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
251 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
252 return *ppv
? S_OK
: E_NOINTERFACE
;
255 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
256 return E_NOINTERFACE
;
259 IUnknown_AddRef((IUnknown
*)*ppv
);
263 static ULONG WINAPI
HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection
*iface
)
265 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
266 LONG ref
= InterlockedIncrement(&This
->ref
);
268 TRACE("(%p) ref=%d\n", This
, ref
);
273 static ULONG WINAPI
HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection
*iface
)
275 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
276 LONG ref
= InterlockedDecrement(&This
->ref
);
278 TRACE("(%p) ref=%d\n", This
, ref
);
281 release_dispex(&This
->dispex
);
283 nsIDOMCSSRuleList_Release(This
->nslist
);
290 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfoCount(
291 IHTMLStyleSheetRulesCollection
*iface
, UINT
*pctinfo
)
293 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
294 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
297 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection
*iface
,
298 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
300 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
301 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
304 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection
*iface
,
305 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
307 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
308 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
312 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection
*iface
,
313 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
314 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
316 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
317 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
318 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
321 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection
*iface
,
324 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
327 TRACE("(%p)->(%p)\n", This
, p
);
332 nsres
= nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
334 ERR("GetLength failed: %08x\n", nsres
);
341 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection
*iface
,
342 LONG index
, IHTMLStyleSheetRule
**ppHTMLStyleSheetRule
)
344 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
345 nsIDOMCSSRule
*nsstylesheetrule
;
348 TRACE("(%p)->(%d %p)\n", This
, index
, ppHTMLStyleSheetRule
);
350 nsres
= nsIDOMCSSRuleList_Item(This
->nslist
, index
, &nsstylesheetrule
);
352 return map_nsresult(nsres
);
353 if(!nsstylesheetrule
)
356 *ppHTMLStyleSheetRule
= HTMLStyleSheetRule_Create(nsstylesheetrule
);
357 return *ppHTMLStyleSheetRule
? S_OK
: E_OUTOFMEMORY
;
360 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl
= {
361 HTMLStyleSheetRulesCollection_QueryInterface
,
362 HTMLStyleSheetRulesCollection_AddRef
,
363 HTMLStyleSheetRulesCollection_Release
,
364 HTMLStyleSheetRulesCollection_GetTypeInfoCount
,
365 HTMLStyleSheetRulesCollection_GetTypeInfo
,
366 HTMLStyleSheetRulesCollection_GetIDsOfNames
,
367 HTMLStyleSheetRulesCollection_Invoke
,
368 HTMLStyleSheetRulesCollection_get_length
,
369 HTMLStyleSheetRulesCollection_item
372 static const tid_t HTMLStyleSheetRulesCollection_iface_tids
[] = {
373 IHTMLStyleSheetRulesCollection_tid
,
376 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex
= {
378 DispHTMLStyleSheetRulesCollection_tid
,
379 HTMLStyleSheetRulesCollection_iface_tids
382 static IHTMLStyleSheetRulesCollection
*HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList
*nslist
)
384 HTMLStyleSheetRulesCollection
*ret
;
386 ret
= heap_alloc(sizeof(*ret
));
387 ret
->IHTMLStyleSheetRulesCollection_iface
.lpVtbl
= &HTMLStyleSheetRulesCollectionVtbl
;
389 ret
->nslist
= nslist
;
391 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetRulesCollection_iface
, &HTMLStyleSheetRulesCollection_dispex
);
394 nsIDOMCSSRuleList_AddRef(nslist
);
396 return &ret
->IHTMLStyleSheetRulesCollection_iface
;
399 static inline HTMLStyleSheetsCollection
*impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection
*iface
)
401 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, IHTMLStyleSheetsCollection_iface
);
404 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
405 REFIID riid
, void **ppv
)
407 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
409 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
411 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
412 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
413 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
414 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
415 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
416 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
417 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
418 return *ppv
? S_OK
: E_NOINTERFACE
;
421 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
422 return E_NOINTERFACE
;
425 IUnknown_AddRef((IUnknown
*)*ppv
);
429 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
431 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
432 LONG ref
= InterlockedIncrement(&This
->ref
);
434 TRACE("(%p) ref=%d\n", This
, ref
);
439 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
441 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
442 LONG ref
= InterlockedDecrement(&This
->ref
);
444 TRACE("(%p) ref=%d\n", This
, ref
);
447 release_dispex(&This
->dispex
);
449 nsIDOMStyleSheetList_Release(This
->nslist
);
456 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
459 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
460 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
463 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
464 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
466 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
467 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
470 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
471 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
473 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
474 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
478 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
479 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
480 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
482 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
483 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
484 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
487 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
490 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
493 TRACE("(%p)->(%p)\n", This
, p
);
496 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
502 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
505 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
506 FIXME("(%p)->(%p)\n", This
, p
);
510 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
511 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
513 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
515 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(pvarIndex
), pvarResult
);
517 switch(V_VT(pvarIndex
)) {
519 nsIDOMStyleSheet
*nsstylesheet
;
522 TRACE("index=%d\n", V_I4(pvarIndex
));
524 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
525 if(NS_FAILED(nsres
) || !nsstylesheet
) {
526 WARN("Item failed: %08x\n", nsres
);
527 V_VT(pvarResult
) = VT_EMPTY
;
531 V_VT(pvarResult
) = VT_DISPATCH
;
532 V_DISPATCH(pvarResult
) = (IDispatch
*)HTMLStyleSheet_Create(nsstylesheet
);
538 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
542 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
548 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
549 HTMLStyleSheetsCollection_QueryInterface
,
550 HTMLStyleSheetsCollection_AddRef
,
551 HTMLStyleSheetsCollection_Release
,
552 HTMLStyleSheetsCollection_GetTypeInfoCount
,
553 HTMLStyleSheetsCollection_GetTypeInfo
,
554 HTMLStyleSheetsCollection_GetIDsOfNames
,
555 HTMLStyleSheetsCollection_Invoke
,
556 HTMLStyleSheetsCollection_get_length
,
557 HTMLStyleSheetsCollection_get__newEnum
,
558 HTMLStyleSheetsCollection_item
561 static const tid_t HTMLStyleSheetsCollection_iface_tids
[] = {
562 IHTMLStyleSheetsCollection_tid
,
565 static dispex_static_data_t HTMLStyleSheetsCollection_dispex
= {
567 DispHTMLStyleSheetsCollection_tid
,
568 HTMLStyleSheetsCollection_iface_tids
571 IHTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList
*nslist
)
573 HTMLStyleSheetsCollection
*ret
= heap_alloc(sizeof(HTMLStyleSheetsCollection
));
575 ret
->IHTMLStyleSheetsCollection_iface
.lpVtbl
= &HTMLStyleSheetsCollectionVtbl
;
579 nsIDOMStyleSheetList_AddRef(nslist
);
580 ret
->nslist
= nslist
;
582 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetsCollection_iface
,
583 &HTMLStyleSheetsCollection_dispex
);
585 return &ret
->IHTMLStyleSheetsCollection_iface
;
588 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet(IHTMLStyleSheet
*iface
)
590 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet_iface
);
593 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
595 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
597 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
599 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
600 *ppv
= &This
->IHTMLStyleSheet_iface
;
601 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
602 *ppv
= &This
->IHTMLStyleSheet_iface
;
603 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
604 *ppv
= &This
->IHTMLStyleSheet_iface
;
605 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
606 return *ppv
? S_OK
: E_NOINTERFACE
;
609 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
610 return E_NOINTERFACE
;
613 IUnknown_AddRef((IUnknown
*)*ppv
);
617 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
619 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
620 LONG ref
= InterlockedIncrement(&This
->ref
);
622 TRACE("(%p) ref=%d\n", This
, ref
);
627 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
629 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
630 LONG ref
= InterlockedDecrement(&This
->ref
);
632 TRACE("(%p) ref=%d\n", This
, ref
);
635 release_dispex(&This
->dispex
);
636 if(This
->nsstylesheet
)
637 nsIDOMCSSStyleSheet_Release(This
->nsstylesheet
);
644 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
646 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
647 TRACE("(%p)->(%p)\n", This
, pctinfo
);
648 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
651 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
652 LCID lcid
, ITypeInfo
**ppTInfo
)
654 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
655 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
658 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
659 LPOLESTR
*rgszNames
, UINT cNames
,
660 LCID lcid
, DISPID
*rgDispId
)
662 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
663 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
666 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
667 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
668 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
670 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
671 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
672 pVarResult
, pExcepInfo
, puArgErr
);
675 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
677 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
678 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
682 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
684 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
685 FIXME("(%p)->(%p)\n", This
, p
);
689 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
692 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
693 FIXME("(%p)->(%p)\n", This
, p
);
697 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
699 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
700 FIXME("(%p)->(%p)\n", This
, p
);
704 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
706 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
707 FIXME("(%p)->(%x)\n", This
, v
);
711 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
713 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
714 FIXME("(%p)->(%p)\n", This
, p
);
718 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
720 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
721 FIXME("(%p)->(%p)\n", This
, p
);
725 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
726 IHTMLStyleSheetsCollection
**p
)
728 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
729 FIXME("(%p)->(%p)\n", This
, p
);
733 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
735 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
736 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
740 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
742 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
746 TRACE("(%p)->(%p)\n", This
, p
);
748 nsAString_Init(&href_str
, NULL
);
749 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
750 return return_nsstr(nsres
, &href_str
, p
);
753 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
755 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
756 FIXME("(%p)->(%p)\n", This
, p
);
760 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
762 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
763 FIXME("(%p)->(%p)\n", This
, p
);
767 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
768 LONG lIndex
, LONG
*plIndex
)
770 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
771 FIXME("(%p)->(%s %d %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
775 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
776 BSTR bstrStyle
, LONG lIndex
, LONG
*plIndex
)
778 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
779 FIXME("(%p)->(%s %s %d %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
784 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, LONG lIndex
)
786 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
787 FIXME("(%p)->(%d)\n", This
, lIndex
);
791 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, LONG lIndex
)
793 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
794 FIXME("(%p)->(%d)\n", This
, lIndex
);
798 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
800 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
801 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
805 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
807 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
808 FIXME("(%p)->(%p)\n", This
, p
);
812 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
814 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
817 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
820 nsres
= nsIDOMCSSStyleSheet_DeleteRule(This
->nsstylesheet
, 0);
821 }while(NS_SUCCEEDED(nsres
));
827 /* FIXME: This won't work for multiple rules in the string. */
828 nsAString_InitDepend(&nsstr
, v
);
829 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, 0, &idx
);
830 nsAString_Finish(&nsstr
);
831 if(NS_FAILED(nsres
)) {
832 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v
));
840 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
842 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
843 nsIDOMCSSRuleList
*nslist
= NULL
;
844 nsIDOMCSSRule
*nsrule
;
849 TRACE("(%p)->(%p)\n", This
, p
);
851 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
852 if(NS_FAILED(nsres
)) {
853 ERR("GetCssRules failed: %08x\n", nsres
);
857 nsres
= nsIDOMCSSRuleList_GetLength(nslist
, &len
);
858 assert(nsres
== NS_OK
);
861 nsres
= nsIDOMCSSRuleList_Item(nslist
, 0, &nsrule
);
863 ERR("Item failed: %08x\n", nsres
);
866 nsIDOMCSSRuleList_Release(nslist
);
875 nsAString_Init(&nsstr
, NULL
);
876 nsres
= nsIDOMCSSRule_GetCssText(nsrule
, &nsstr
);
877 nsIDOMCSSRule_Release(nsrule
);
878 return return_nsstr(nsres
, &nsstr
, p
);
881 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
882 IHTMLStyleSheetRulesCollection
**p
)
884 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
885 nsIDOMCSSRuleList
*nslist
= NULL
;
888 TRACE("(%p)->(%p)\n", This
, p
);
890 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
891 if(NS_FAILED(nsres
)) {
892 ERR("GetCssRules failed: %08x\n", nsres
);
896 *p
= HTMLStyleSheetRulesCollection_Create(nslist
);
900 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
901 HTMLStyleSheet_QueryInterface
,
902 HTMLStyleSheet_AddRef
,
903 HTMLStyleSheet_Release
,
904 HTMLStyleSheet_GetTypeInfoCount
,
905 HTMLStyleSheet_GetTypeInfo
,
906 HTMLStyleSheet_GetIDsOfNames
,
907 HTMLStyleSheet_Invoke
,
908 HTMLStyleSheet_put_title
,
909 HTMLStyleSheet_get_title
,
910 HTMLStyleSheet_get_parentStyleSheet
,
911 HTMLStyleSheet_get_owningElement
,
912 HTMLStyleSheet_put_disabled
,
913 HTMLStyleSheet_get_disabled
,
914 HTMLStyleSheet_get_readOnly
,
915 HTMLStyleSheet_get_imports
,
916 HTMLStyleSheet_put_href
,
917 HTMLStyleSheet_get_href
,
918 HTMLStyleSheet_get_type
,
919 HTMLStyleSheet_get_id
,
920 HTMLStyleSheet_addImport
,
921 HTMLStyleSheet_addRule
,
922 HTMLStyleSheet_removeImport
,
923 HTMLStyleSheet_removeRule
,
924 HTMLStyleSheet_put_media
,
925 HTMLStyleSheet_get_media
,
926 HTMLStyleSheet_put_cssText
,
927 HTMLStyleSheet_get_cssText
,
928 HTMLStyleSheet_get_rules
931 static const tid_t HTMLStyleSheet_iface_tids
[] = {
935 static dispex_static_data_t HTMLStyleSheet_dispex
= {
937 DispHTMLStyleSheet_tid
,
938 HTMLStyleSheet_iface_tids
941 IHTMLStyleSheet
*HTMLStyleSheet_Create(nsIDOMStyleSheet
*nsstylesheet
)
943 HTMLStyleSheet
*ret
= heap_alloc(sizeof(HTMLStyleSheet
));
946 ret
->IHTMLStyleSheet_iface
.lpVtbl
= &HTMLStyleSheetVtbl
;
948 ret
->nsstylesheet
= NULL
;
950 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheet_iface
, &HTMLStyleSheet_dispex
);
953 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
954 (void**)&ret
->nsstylesheet
);
956 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres
);
959 return &ret
->IHTMLStyleSheet_iface
;