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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
34 struct HTMLStyleSheet
{
36 IHTMLStyleSheet IHTMLStyleSheet_iface
;
37 IHTMLStyleSheet4 IHTMLStyleSheet4_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=%ld\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=%ld\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
= {
207 DispHTMLStyleSheetRule_tid
,
208 HTMLStyleSheetRule_iface_tids
211 static HRESULT
create_style_sheet_rule(nsIDOMCSSRule
*nsstylesheetrule
, compat_mode_t compat_mode
,
212 IHTMLStyleSheetRule
**ret
)
214 HTMLStyleSheetRule
*rule
;
217 if(!(rule
= heap_alloc(sizeof(*rule
))))
218 return E_OUTOFMEMORY
;
220 rule
->IHTMLStyleSheetRule_iface
.lpVtbl
= &HTMLStyleSheetRuleVtbl
;
222 rule
->nsstylesheetrule
= NULL
;
224 init_dispatch(&rule
->dispex
, (IUnknown
*)&rule
->IHTMLStyleSheetRule_iface
, &HTMLStyleSheetRule_dispex
,
227 if (nsstylesheetrule
)
229 nsres
= nsIDOMCSSRule_QueryInterface(nsstylesheetrule
, &IID_nsIDOMCSSRule
,
230 (void **)&rule
->nsstylesheetrule
);
231 if (NS_FAILED(nsres
))
232 ERR("Could not get nsIDOMCSSRule interface: %08lx\n", nsres
);
235 *ret
= &rule
->IHTMLStyleSheetRule_iface
;
239 static inline HTMLStyleSheetRulesCollection
*impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection
*iface
)
241 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, IHTMLStyleSheetRulesCollection_iface
);
244 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection
*iface
,
245 REFIID riid
, void **ppv
)
247 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
249 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
251 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
252 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
253 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection
, riid
)) {
254 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
255 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
256 return *ppv
? S_OK
: E_NOINTERFACE
;
259 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
260 return E_NOINTERFACE
;
263 IUnknown_AddRef((IUnknown
*)*ppv
);
267 static ULONG WINAPI
HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection
*iface
)
269 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
270 LONG ref
= InterlockedIncrement(&This
->ref
);
272 TRACE("(%p) ref=%ld\n", This
, ref
);
277 static ULONG WINAPI
HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection
*iface
)
279 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
280 LONG ref
= InterlockedDecrement(&This
->ref
);
282 TRACE("(%p) ref=%ld\n", This
, ref
);
285 release_dispex(&This
->dispex
);
287 nsIDOMCSSRuleList_Release(This
->nslist
);
294 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfoCount(
295 IHTMLStyleSheetRulesCollection
*iface
, UINT
*pctinfo
)
297 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
298 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
301 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection
*iface
,
302 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
304 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
305 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
308 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection
*iface
,
309 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
311 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
312 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
316 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection
*iface
,
317 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
318 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
320 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
321 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
322 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
325 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection
*iface
,
328 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
331 TRACE("(%p)->(%p)\n", This
, p
);
336 nsres
= nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
338 ERR("GetLength failed: %08lx\n", nsres
);
345 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection
*iface
,
346 LONG index
, IHTMLStyleSheetRule
**p
)
348 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
349 nsIDOMCSSRule
*nsstylesheetrule
;
353 TRACE("(%p)->(%ld %p)\n", This
, index
, p
);
355 nsres
= nsIDOMCSSRuleList_Item(This
->nslist
, index
, &nsstylesheetrule
);
357 return map_nsresult(nsres
);
358 if(!nsstylesheetrule
)
361 hres
= create_style_sheet_rule(nsstylesheetrule
, dispex_compat_mode(&This
->dispex
), p
);
362 nsIDOMCSSRule_Release(nsstylesheetrule
);
366 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl
= {
367 HTMLStyleSheetRulesCollection_QueryInterface
,
368 HTMLStyleSheetRulesCollection_AddRef
,
369 HTMLStyleSheetRulesCollection_Release
,
370 HTMLStyleSheetRulesCollection_GetTypeInfoCount
,
371 HTMLStyleSheetRulesCollection_GetTypeInfo
,
372 HTMLStyleSheetRulesCollection_GetIDsOfNames
,
373 HTMLStyleSheetRulesCollection_Invoke
,
374 HTMLStyleSheetRulesCollection_get_length
,
375 HTMLStyleSheetRulesCollection_item
378 static inline HTMLStyleSheetRulesCollection
*HTMLStyleSheetRulesCollection_from_DispatchEx(DispatchEx
*iface
)
380 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, dispex
);
383 static HRESULT
HTMLStyleSheetRulesCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
385 HTMLStyleSheetRulesCollection
*This
= HTMLStyleSheetRulesCollection_from_DispatchEx(dispex
);
390 for(ptr
= name
; *ptr
&& is_digit(*ptr
); ptr
++)
391 idx
= idx
*10 + (*ptr
-'0');
393 return DISP_E_UNKNOWNNAME
;
395 nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
397 return DISP_E_UNKNOWNNAME
;
399 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
400 TRACE("ret %lx\n", *dispid
);
404 static HRESULT
HTMLStyleSheetRulesCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
405 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
407 HTMLStyleSheetRulesCollection
*This
= HTMLStyleSheetRulesCollection_from_DispatchEx(dispex
);
409 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
412 case DISPATCH_PROPERTYGET
: {
413 IHTMLStyleSheetRule
*stylesheetrule
;
414 nsIDOMCSSRule
*nsstylesheetrule
;
418 nsres
= nsIDOMCSSRuleList_Item(This
->nslist
, id
- MSHTML_DISPID_CUSTOM_MIN
, &nsstylesheetrule
);
420 return DISP_E_MEMBERNOTFOUND
;
421 if(!nsstylesheetrule
) {
422 V_VT(res
) = VT_EMPTY
;
426 hres
= create_style_sheet_rule(nsstylesheetrule
, dispex_compat_mode(&This
->dispex
), &stylesheetrule
);
427 nsIDOMCSSRule_Release(nsstylesheetrule
);
431 V_VT(res
) = VT_DISPATCH
;
432 V_DISPATCH(res
) = (IDispatch
*)stylesheetrule
;
437 FIXME("unimplemented flags %x\n", flags
);
444 static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl
= {
446 HTMLStyleSheetRulesCollection_get_dispid
,
447 HTMLStyleSheetRulesCollection_invoke
449 static const tid_t HTMLStyleSheetRulesCollection_iface_tids
[] = {
450 IHTMLStyleSheetRulesCollection_tid
,
453 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex
= {
455 &HTMLStyleSheetRulesCollection_dispex_vtbl
,
456 DispHTMLStyleSheetRulesCollection_tid
,
457 HTMLStyleSheetRulesCollection_iface_tids
460 static HRESULT
create_style_sheet_rules_collection(nsIDOMCSSRuleList
*nslist
, compat_mode_t compat_mode
,
461 IHTMLStyleSheetRulesCollection
**ret
)
463 HTMLStyleSheetRulesCollection
*collection
;
465 if(!(collection
= heap_alloc(sizeof(*collection
))))
466 return E_OUTOFMEMORY
;
468 collection
->IHTMLStyleSheetRulesCollection_iface
.lpVtbl
= &HTMLStyleSheetRulesCollectionVtbl
;
470 collection
->nslist
= nslist
;
472 init_dispatch(&collection
->dispex
, (IUnknown
*)&collection
->IHTMLStyleSheetRulesCollection_iface
,
473 &HTMLStyleSheetRulesCollection_dispex
, compat_mode
);
476 nsIDOMCSSRuleList_AddRef(nslist
);
478 *ret
= &collection
->IHTMLStyleSheetRulesCollection_iface
;
482 static inline HTMLStyleSheetsCollection
*impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection
*iface
)
484 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, IHTMLStyleSheetsCollection_iface
);
487 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
488 REFIID riid
, void **ppv
)
490 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
492 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
494 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
495 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
496 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
497 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
498 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
499 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
500 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
501 return *ppv
? S_OK
: E_NOINTERFACE
;
504 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
505 return E_NOINTERFACE
;
508 IUnknown_AddRef((IUnknown
*)*ppv
);
512 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
514 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
515 LONG ref
= InterlockedIncrement(&This
->ref
);
517 TRACE("(%p) ref=%ld\n", This
, ref
);
522 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
524 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
525 LONG ref
= InterlockedDecrement(&This
->ref
);
527 TRACE("(%p) ref=%ld\n", This
, ref
);
530 release_dispex(&This
->dispex
);
532 nsIDOMStyleSheetList_Release(This
->nslist
);
539 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
542 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
543 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
546 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
547 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
549 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
550 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
553 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
554 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
556 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
557 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
561 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
562 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
563 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
565 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
566 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
567 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
570 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
573 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
576 TRACE("(%p)->(%p)\n", This
, p
);
579 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
585 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
588 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
589 FIXME("(%p)->(%p)\n", This
, p
);
593 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
594 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
596 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
598 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(pvarIndex
), pvarResult
);
600 switch(V_VT(pvarIndex
)) {
602 nsIDOMStyleSheet
*nsstylesheet
;
603 IHTMLStyleSheet
*stylesheet
;
607 TRACE("index=%ld\n", V_I4(pvarIndex
));
609 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
610 if(NS_FAILED(nsres
) || !nsstylesheet
) {
611 WARN("Item failed: %08lx\n", nsres
);
612 V_VT(pvarResult
) = VT_EMPTY
;
616 hres
= create_style_sheet(nsstylesheet
, dispex_compat_mode(&This
->dispex
), &stylesheet
);
617 nsIDOMStyleSheet_Release(nsstylesheet
);
621 V_VT(pvarResult
) = VT_DISPATCH
;
622 V_DISPATCH(pvarResult
) = (IDispatch
*)stylesheet
;
627 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
631 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
637 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
638 HTMLStyleSheetsCollection_QueryInterface
,
639 HTMLStyleSheetsCollection_AddRef
,
640 HTMLStyleSheetsCollection_Release
,
641 HTMLStyleSheetsCollection_GetTypeInfoCount
,
642 HTMLStyleSheetsCollection_GetTypeInfo
,
643 HTMLStyleSheetsCollection_GetIDsOfNames
,
644 HTMLStyleSheetsCollection_Invoke
,
645 HTMLStyleSheetsCollection_get_length
,
646 HTMLStyleSheetsCollection_get__newEnum
,
647 HTMLStyleSheetsCollection_item
650 static inline HTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_from_DispatchEx(DispatchEx
*iface
)
652 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, dispex
);
655 static HRESULT
HTMLStyleSheetsCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
657 HTMLStyleSheetsCollection
*This
= HTMLStyleSheetsCollection_from_DispatchEx(dispex
);
662 for(ptr
= name
; *ptr
&& is_digit(*ptr
); ptr
++)
663 idx
= idx
*10 + (*ptr
-'0');
665 return DISP_E_UNKNOWNNAME
;
667 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
669 return DISP_E_UNKNOWNNAME
;
671 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
672 TRACE("ret %lx\n", *dispid
);
676 static HRESULT
HTMLStyleSheetsCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
677 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
679 HTMLStyleSheetsCollection
*This
= HTMLStyleSheetsCollection_from_DispatchEx(dispex
);
681 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
684 case DISPATCH_PROPERTYGET
: {
685 nsIDOMStyleSheet
*nsstylesheet
;
686 IHTMLStyleSheet
*stylesheet
;
690 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, id
- MSHTML_DISPID_CUSTOM_MIN
, &nsstylesheet
);
692 return DISP_E_MEMBERNOTFOUND
;
694 V_VT(res
) = VT_EMPTY
;
698 hres
= create_style_sheet(nsstylesheet
, dispex_compat_mode(&This
->dispex
), &stylesheet
);
699 nsIDOMStyleSheet_Release(nsstylesheet
);
703 V_VT(res
) = VT_DISPATCH
;
704 V_DISPATCH(res
) = (IDispatch
*)stylesheet
;
709 FIXME("unimplemented flags %x\n", flags
);
716 static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl
= {
718 HTMLStyleSheetsCollection_get_dispid
,
719 HTMLStyleSheetsCollection_invoke
721 static const tid_t HTMLStyleSheetsCollection_iface_tids
[] = {
722 IHTMLStyleSheetsCollection_tid
,
725 static dispex_static_data_t HTMLStyleSheetsCollection_dispex
= {
727 &HTMLStyleSheetsCollection_dispex_vtbl
,
728 DispHTMLStyleSheetsCollection_tid
,
729 HTMLStyleSheetsCollection_iface_tids
732 HRESULT
create_style_sheet_collection(nsIDOMStyleSheetList
*nslist
, compat_mode_t compat_mode
,
733 IHTMLStyleSheetsCollection
**ret
)
735 HTMLStyleSheetsCollection
*collection
;
737 if(!(collection
= heap_alloc(sizeof(HTMLStyleSheetsCollection
))))
738 return E_OUTOFMEMORY
;
740 collection
->IHTMLStyleSheetsCollection_iface
.lpVtbl
= &HTMLStyleSheetsCollectionVtbl
;
744 nsIDOMStyleSheetList_AddRef(nslist
);
745 collection
->nslist
= nslist
;
747 init_dispatch(&collection
->dispex
, (IUnknown
*)&collection
->IHTMLStyleSheetsCollection_iface
,
748 &HTMLStyleSheetsCollection_dispex
, compat_mode
);
750 *ret
= &collection
->IHTMLStyleSheetsCollection_iface
;
754 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet(IHTMLStyleSheet
*iface
)
756 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet_iface
);
759 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
761 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
763 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
765 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
766 *ppv
= &This
->IHTMLStyleSheet_iface
;
767 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
768 *ppv
= &This
->IHTMLStyleSheet_iface
;
769 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
770 *ppv
= &This
->IHTMLStyleSheet_iface
;
771 }else if(IsEqualGUID(&IID_IHTMLStyleSheet4
, riid
)) {
772 *ppv
= &This
->IHTMLStyleSheet4_iface
;
773 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
774 return *ppv
? S_OK
: E_NOINTERFACE
;
777 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
778 return E_NOINTERFACE
;
781 IUnknown_AddRef((IUnknown
*)*ppv
);
785 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
787 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
788 LONG ref
= InterlockedIncrement(&This
->ref
);
790 TRACE("(%p) ref=%ld\n", This
, ref
);
795 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
797 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
798 LONG ref
= InterlockedDecrement(&This
->ref
);
800 TRACE("(%p) ref=%ld\n", This
, ref
);
803 release_dispex(&This
->dispex
);
804 if(This
->nsstylesheet
)
805 nsIDOMCSSStyleSheet_Release(This
->nsstylesheet
);
812 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
814 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
815 TRACE("(%p)->(%p)\n", This
, pctinfo
);
816 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
819 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
820 LCID lcid
, ITypeInfo
**ppTInfo
)
822 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
823 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
826 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
827 LPOLESTR
*rgszNames
, UINT cNames
,
828 LCID lcid
, DISPID
*rgDispId
)
830 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
831 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
834 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
835 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
836 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
838 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
839 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
840 pVarResult
, pExcepInfo
, puArgErr
);
843 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
845 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
846 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
850 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
852 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
853 FIXME("(%p)->(%p)\n", This
, p
);
857 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
860 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
861 FIXME("(%p)->(%p)\n", This
, p
);
865 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
867 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
868 FIXME("(%p)->(%p)\n", This
, p
);
872 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
874 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
875 FIXME("(%p)->(%x)\n", This
, v
);
879 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
881 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
882 FIXME("(%p)->(%p)\n", This
, p
);
886 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
888 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
889 FIXME("(%p)->(%p)\n", This
, p
);
893 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
894 IHTMLStyleSheetsCollection
**p
)
896 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
897 FIXME("(%p)->(%p)\n", This
, p
);
901 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
903 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
904 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
908 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
910 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
914 TRACE("(%p)->(%p)\n", This
, p
);
916 nsAString_Init(&href_str
, NULL
);
917 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
918 return return_nsstr(nsres
, &href_str
, p
);
921 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
923 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
924 FIXME("(%p)->(%p)\n", This
, p
);
928 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
930 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
931 FIXME("(%p)->(%p)\n", This
, p
);
935 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
936 LONG lIndex
, LONG
*plIndex
)
938 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
939 FIXME("(%p)->(%s %ld %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
943 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
944 BSTR bstrStyle
, LONG lIndex
, LONG
*plIndex
)
946 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
947 const WCHAR format
[] = L
"%s {%s}";
948 nsIDOMCSSRuleList
*nslist
= NULL
;
949 UINT32 length
, new_index
;
955 TRACE("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
958 if(!bstrSelector
|| !bstrStyle
|| !bstrSelector
[0] || !bstrStyle
[0])
961 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
964 nsIDOMCSSRuleList_GetLength(nslist
, &length
);
969 len
= ARRAY_SIZE(format
) - 4 /* %s twice */ + wcslen(bstrSelector
) + wcslen(bstrStyle
);
970 if(!(rule
= heap_alloc(len
* sizeof(WCHAR
))))
971 return E_OUTOFMEMORY
;
972 swprintf(rule
, len
, format
, bstrSelector
, bstrStyle
);
974 nsAString_InitDepend(&nsstr
, rule
);
975 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, lIndex
, &new_index
);
976 if(NS_FAILED(nsres
)) WARN("failed: %08lx\n", nsres
);
977 nsAString_Finish(&nsstr
);
980 *plIndex
= new_index
;
981 return map_nsresult(nsres
);
984 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, LONG lIndex
)
986 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
987 FIXME("(%p)->(%ld)\n", This
, lIndex
);
991 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, LONG lIndex
)
993 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
994 FIXME("(%p)->(%ld)\n", This
, lIndex
);
998 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
1000 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1001 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1005 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
1007 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1008 FIXME("(%p)->(%p)\n", This
, p
);
1012 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
1014 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1017 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1020 nsres
= nsIDOMCSSStyleSheet_DeleteRule(This
->nsstylesheet
, 0);
1021 }while(NS_SUCCEEDED(nsres
));
1027 /* FIXME: This won't work for multiple rules in the string. */
1028 nsAString_InitDepend(&nsstr
, v
);
1029 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, 0, &idx
);
1030 nsAString_Finish(&nsstr
);
1031 if(NS_FAILED(nsres
)) {
1032 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v
));
1040 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
1042 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1043 nsIDOMCSSRuleList
*nslist
= NULL
;
1044 nsIDOMCSSRule
*nsrule
;
1049 TRACE("(%p)->(%p)\n", This
, p
);
1051 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
1052 if(NS_FAILED(nsres
)) {
1053 ERR("GetCssRules failed: %08lx\n", nsres
);
1057 nsres
= nsIDOMCSSRuleList_GetLength(nslist
, &len
);
1058 assert(nsres
== NS_OK
);
1061 nsres
= nsIDOMCSSRuleList_Item(nslist
, 0, &nsrule
);
1062 if(NS_FAILED(nsres
))
1063 ERR("Item failed: %08lx\n", nsres
);
1066 nsIDOMCSSRuleList_Release(nslist
);
1067 if(NS_FAILED(nsres
))
1075 nsAString_Init(&nsstr
, NULL
);
1076 nsres
= nsIDOMCSSRule_GetCssText(nsrule
, &nsstr
);
1077 nsIDOMCSSRule_Release(nsrule
);
1078 return return_nsstr(nsres
, &nsstr
, p
);
1081 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
1082 IHTMLStyleSheetRulesCollection
**p
)
1084 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1085 nsIDOMCSSRuleList
*nslist
= NULL
;
1089 TRACE("(%p)->(%p)\n", This
, p
);
1091 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
1092 if(NS_FAILED(nsres
)) {
1093 ERR("GetCssRules failed: %08lx\n", nsres
);
1097 hres
= create_style_sheet_rules_collection(nslist
, dispex_compat_mode(&This
->dispex
), p
);
1098 nsIDOMCSSRuleList_Release(nslist
);
1102 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
1103 HTMLStyleSheet_QueryInterface
,
1104 HTMLStyleSheet_AddRef
,
1105 HTMLStyleSheet_Release
,
1106 HTMLStyleSheet_GetTypeInfoCount
,
1107 HTMLStyleSheet_GetTypeInfo
,
1108 HTMLStyleSheet_GetIDsOfNames
,
1109 HTMLStyleSheet_Invoke
,
1110 HTMLStyleSheet_put_title
,
1111 HTMLStyleSheet_get_title
,
1112 HTMLStyleSheet_get_parentStyleSheet
,
1113 HTMLStyleSheet_get_owningElement
,
1114 HTMLStyleSheet_put_disabled
,
1115 HTMLStyleSheet_get_disabled
,
1116 HTMLStyleSheet_get_readOnly
,
1117 HTMLStyleSheet_get_imports
,
1118 HTMLStyleSheet_put_href
,
1119 HTMLStyleSheet_get_href
,
1120 HTMLStyleSheet_get_type
,
1121 HTMLStyleSheet_get_id
,
1122 HTMLStyleSheet_addImport
,
1123 HTMLStyleSheet_addRule
,
1124 HTMLStyleSheet_removeImport
,
1125 HTMLStyleSheet_removeRule
,
1126 HTMLStyleSheet_put_media
,
1127 HTMLStyleSheet_get_media
,
1128 HTMLStyleSheet_put_cssText
,
1129 HTMLStyleSheet_get_cssText
,
1130 HTMLStyleSheet_get_rules
1133 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet4(IHTMLStyleSheet4
*iface
)
1135 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet4_iface
);
1138 static HRESULT WINAPI
HTMLStyleSheet4_QueryInterface(IHTMLStyleSheet4
*iface
, REFIID riid
, void **ppv
)
1140 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1141 return IHTMLStyleSheet_QueryInterface(&This
->IHTMLStyleSheet_iface
, riid
, ppv
);
1144 static ULONG WINAPI
HTMLStyleSheet4_AddRef(IHTMLStyleSheet4
*iface
)
1146 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1147 return IHTMLStyleSheet_AddRef(&This
->IHTMLStyleSheet_iface
);
1150 static ULONG WINAPI
HTMLStyleSheet4_Release(IHTMLStyleSheet4
*iface
)
1152 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1153 return IHTMLStyleSheet_Release(&This
->IHTMLStyleSheet_iface
);
1156 static HRESULT WINAPI
HTMLStyleSheet4_GetTypeInfoCount(IHTMLStyleSheet4
*iface
, UINT
*pctinfo
)
1158 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1159 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1160 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1163 static HRESULT WINAPI
HTMLStyleSheet4_GetTypeInfo(IHTMLStyleSheet4
*iface
, UINT iTInfo
,
1164 LCID lcid
, ITypeInfo
**ppTInfo
)
1166 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1167 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1170 static HRESULT WINAPI
HTMLStyleSheet4_GetIDsOfNames(IHTMLStyleSheet4
*iface
, REFIID riid
,
1171 LPOLESTR
*rgszNames
, UINT cNames
,
1172 LCID lcid
, DISPID
*rgDispId
)
1174 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1175 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1178 static HRESULT WINAPI
HTMLStyleSheet4_Invoke(IHTMLStyleSheet4
*iface
, DISPID dispIdMember
,
1179 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1180 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1182 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1183 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1184 pVarResult
, pExcepInfo
, puArgErr
);
1187 static HRESULT WINAPI
HTMLStyleSheet4_get_type(IHTMLStyleSheet4
*iface
, BSTR
*p
)
1189 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1190 TRACE("(%p)->(%p)\n", This
, p
);
1191 return IHTMLStyleSheet_get_type(&This
->IHTMLStyleSheet_iface
, p
);
1194 static HRESULT WINAPI
HTMLStyleSheet4_get_href(IHTMLStyleSheet4
*iface
, VARIANT
*p
)
1196 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1200 TRACE("(%p)->(%p)\n", This
, p
);
1202 nsAString_Init(&href_str
, NULL
);
1203 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
1204 return return_nsstr_variant(nsres
, &href_str
, 0, p
);
1207 static HRESULT WINAPI
HTMLStyleSheet4_get_title(IHTMLStyleSheet4
*iface
, BSTR
*p
)
1209 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1210 FIXME("(%p)->(%p)\n", This
, p
);
1214 static HRESULT WINAPI
HTMLStyleSheet4_get_ownerNode(IHTMLStyleSheet4
*iface
, IHTMLElement
**p
)
1216 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1217 FIXME("(%p)->(%p)\n", This
, p
);
1221 static HRESULT WINAPI
HTMLStyleSheet4_get_ownerRule(IHTMLStyleSheet4
*iface
, IHTMLCSSRule
**p
)
1223 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1224 FIXME("(%p)->(%p)\n", This
, p
);
1228 static HRESULT WINAPI
HTMLStyleSheet4_get_cssRules(IHTMLStyleSheet4
*iface
, IHTMLStyleSheetRulesCollection
**p
)
1230 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1231 TRACE("(%p)->(%p)\n", This
, p
);
1232 return IHTMLStyleSheet_get_rules(&This
->IHTMLStyleSheet_iface
, p
);
1235 static HRESULT WINAPI
HTMLStyleSheet4_get_media(IHTMLStyleSheet4
*iface
, VARIANT
*p
)
1237 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1238 FIXME("(%p)->(%p)\n", This
, p
);
1242 static HRESULT WINAPI
HTMLStyleSheet4_insertRule(IHTMLStyleSheet4
*iface
, BSTR rule
, LONG index
, LONG
*p
)
1244 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1245 UINT32 new_index
= 0;
1249 TRACE("(%p)->(%s %ld %p)\n", This
, debugstr_w(rule
), index
, p
);
1251 nsAString_InitDepend(&nsstr
, rule
);
1252 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, index
, &new_index
);
1253 if(NS_FAILED(nsres
)) WARN("failed: %08lx\n", nsres
);
1254 nsAString_Finish(&nsstr
);
1256 return map_nsresult(nsres
);
1259 static HRESULT WINAPI
HTMLStyleSheet4_deleteRule(IHTMLStyleSheet4
*iface
, LONG index
)
1261 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1262 FIXME("(%p)->(%ld)\n", This
, index
);
1266 static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl
= {
1267 HTMLStyleSheet4_QueryInterface
,
1268 HTMLStyleSheet4_AddRef
,
1269 HTMLStyleSheet4_Release
,
1270 HTMLStyleSheet4_GetTypeInfoCount
,
1271 HTMLStyleSheet4_GetTypeInfo
,
1272 HTMLStyleSheet4_GetIDsOfNames
,
1273 HTMLStyleSheet4_Invoke
,
1274 HTMLStyleSheet4_get_type
,
1275 HTMLStyleSheet4_get_href
,
1276 HTMLStyleSheet4_get_title
,
1277 HTMLStyleSheet4_get_ownerNode
,
1278 HTMLStyleSheet4_get_ownerRule
,
1279 HTMLStyleSheet4_get_cssRules
,
1280 HTMLStyleSheet4_get_media
,
1281 HTMLStyleSheet4_insertRule
,
1282 HTMLStyleSheet4_deleteRule
,
1285 static void HTMLStyleSheet_init_dispex_info(dispex_data_t
*info
, compat_mode_t mode
)
1287 if(mode
>= COMPAT_MODE_IE9
)
1288 dispex_info_add_interface(info
, IHTMLStyleSheet4_tid
, NULL
);
1291 static const tid_t HTMLStyleSheet_iface_tids
[] = {
1292 IHTMLStyleSheet_tid
,
1295 static dispex_static_data_t HTMLStyleSheet_dispex
= {
1298 DispHTMLStyleSheet_tid
,
1299 HTMLStyleSheet_iface_tids
,
1300 HTMLStyleSheet_init_dispex_info
1303 HRESULT
create_style_sheet(nsIDOMStyleSheet
*nsstylesheet
, compat_mode_t compat_mode
, IHTMLStyleSheet
**ret
)
1305 HTMLStyleSheet
*style_sheet
;
1308 if(!(style_sheet
= heap_alloc(sizeof(HTMLStyleSheet
))))
1309 return E_OUTOFMEMORY
;
1311 style_sheet
->IHTMLStyleSheet_iface
.lpVtbl
= &HTMLStyleSheetVtbl
;
1312 style_sheet
->IHTMLStyleSheet4_iface
.lpVtbl
= &HTMLStyleSheet4Vtbl
;
1313 style_sheet
->ref
= 1;
1314 style_sheet
->nsstylesheet
= NULL
;
1316 init_dispatch(&style_sheet
->dispex
, (IUnknown
*)&style_sheet
->IHTMLStyleSheet_iface
,
1317 &HTMLStyleSheet_dispex
, compat_mode
);
1320 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
1321 (void**)&style_sheet
->nsstylesheet
);
1322 if(NS_FAILED(nsres
))
1323 ERR("Could not get nsICSSStyleSheet interface: %08lx\n", nsres
);
1326 *ret
= &style_sheet
->IHTMLStyleSheet_iface
;