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
;
54 IEnumVARIANT IEnumVARIANT_iface
;
59 HTMLStyleSheetsCollection
*col
;
60 } HTMLStyleSheetsCollectionEnum
;
62 struct HTMLStyleSheetRulesCollection
{
64 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface
;
68 nsIDOMCSSRuleList
*nslist
;
71 struct HTMLStyleSheetRule
{
73 IHTMLStyleSheetRule IHTMLStyleSheetRule_iface
;
77 nsIDOMCSSRule
*nsstylesheetrule
;
80 static inline HTMLStyleSheetRule
*impl_from_IHTMLStyleSheetRule(IHTMLStyleSheetRule
*iface
)
82 return CONTAINING_RECORD(iface
, HTMLStyleSheetRule
, IHTMLStyleSheetRule_iface
);
85 static HRESULT WINAPI
HTMLStyleSheetRule_QueryInterface(IHTMLStyleSheetRule
*iface
,
86 REFIID riid
, void **ppv
)
88 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
90 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
92 if (IsEqualGUID(&IID_IUnknown
, riid
))
93 *ppv
= &This
->IHTMLStyleSheetRule_iface
;
94 else if (IsEqualGUID(&IID_IHTMLStyleSheetRule
, riid
))
95 *ppv
= &This
->IHTMLStyleSheetRule_iface
;
96 else if (dispex_query_interface(&This
->dispex
, riid
, ppv
))
97 return *ppv
? S_OK
: E_NOINTERFACE
;
101 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
102 return E_NOINTERFACE
;
105 IUnknown_AddRef((IUnknown
*)*ppv
);
109 static ULONG WINAPI
HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule
*iface
)
111 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
112 LONG ref
= InterlockedIncrement(&This
->ref
);
114 TRACE("(%p) ref=%ld\n", This
, ref
);
119 static ULONG WINAPI
HTMLStyleSheetRule_Release(IHTMLStyleSheetRule
*iface
)
121 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
122 LONG ref
= InterlockedDecrement(&This
->ref
);
124 TRACE("(%p) ref=%ld\n", This
, ref
);
127 release_dispex(&This
->dispex
);
128 if(This
->nsstylesheetrule
)
129 nsIDOMCSSRule_Release(This
->nsstylesheetrule
);
136 static HRESULT WINAPI
HTMLStyleSheetRule_GetTypeInfoCount(
137 IHTMLStyleSheetRule
*iface
, UINT
*pctinfo
)
139 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
140 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
143 static HRESULT WINAPI
HTMLStyleSheetRule_GetTypeInfo(IHTMLStyleSheetRule
*iface
,
144 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
146 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
147 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
150 static HRESULT WINAPI
HTMLStyleSheetRule_GetIDsOfNames(IHTMLStyleSheetRule
*iface
,
151 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
153 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
154 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
158 static HRESULT WINAPI
HTMLStyleSheetRule_Invoke(IHTMLStyleSheetRule
*iface
,
159 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
160 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
162 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
163 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
164 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
167 static HRESULT WINAPI
HTMLStyleSheetRule_put_selectorText(IHTMLStyleSheetRule
*iface
, BSTR v
)
169 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
170 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
174 static HRESULT WINAPI
HTMLStyleSheetRule_get_selectorText(IHTMLStyleSheetRule
*iface
, BSTR
*p
)
176 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
177 FIXME("(%p)->(%p)\n", This
, p
);
181 static HRESULT WINAPI
HTMLStyleSheetRule_get_style(IHTMLStyleSheetRule
*iface
, IHTMLRuleStyle
**p
)
183 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
184 FIXME("(%p)->(%p)\n", This
, p
);
188 static HRESULT WINAPI
HTMLStyleSheetRule_get_readOnly(IHTMLStyleSheetRule
*iface
, VARIANT_BOOL
*p
)
190 HTMLStyleSheetRule
*This
= impl_from_IHTMLStyleSheetRule(iface
);
191 FIXME("(%p)->(%p)\n", This
, p
);
195 static const IHTMLStyleSheetRuleVtbl HTMLStyleSheetRuleVtbl
= {
196 HTMLStyleSheetRule_QueryInterface
,
197 HTMLStyleSheetRule_AddRef
,
198 HTMLStyleSheetRule_Release
,
199 HTMLStyleSheetRule_GetTypeInfoCount
,
200 HTMLStyleSheetRule_GetTypeInfo
,
201 HTMLStyleSheetRule_GetIDsOfNames
,
202 HTMLStyleSheetRule_Invoke
,
203 HTMLStyleSheetRule_put_selectorText
,
204 HTMLStyleSheetRule_get_selectorText
,
205 HTMLStyleSheetRule_get_style
,
206 HTMLStyleSheetRule_get_readOnly
209 static const tid_t HTMLStyleSheetRule_iface_tids
[] = {
210 IHTMLStyleSheetRule_tid
,
213 static dispex_static_data_t HTMLStyleSheetRule_dispex
= {
216 DispHTMLStyleSheetRule_tid
,
217 HTMLStyleSheetRule_iface_tids
220 static HRESULT
create_style_sheet_rule(nsIDOMCSSRule
*nsstylesheetrule
, compat_mode_t compat_mode
,
221 IHTMLStyleSheetRule
**ret
)
223 HTMLStyleSheetRule
*rule
;
226 if(!(rule
= malloc(sizeof(*rule
))))
227 return E_OUTOFMEMORY
;
229 rule
->IHTMLStyleSheetRule_iface
.lpVtbl
= &HTMLStyleSheetRuleVtbl
;
231 rule
->nsstylesheetrule
= NULL
;
233 init_dispatch(&rule
->dispex
, (IUnknown
*)&rule
->IHTMLStyleSheetRule_iface
, &HTMLStyleSheetRule_dispex
,
236 if (nsstylesheetrule
)
238 nsres
= nsIDOMCSSRule_QueryInterface(nsstylesheetrule
, &IID_nsIDOMCSSRule
,
239 (void **)&rule
->nsstylesheetrule
);
240 if (NS_FAILED(nsres
))
241 ERR("Could not get nsIDOMCSSRule interface: %08lx\n", nsres
);
244 *ret
= &rule
->IHTMLStyleSheetRule_iface
;
248 static inline HTMLStyleSheetRulesCollection
*impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection
*iface
)
250 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, IHTMLStyleSheetRulesCollection_iface
);
253 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection
*iface
,
254 REFIID riid
, void **ppv
)
256 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
258 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
260 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
261 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
262 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection
, riid
)) {
263 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
264 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
265 return *ppv
? S_OK
: E_NOINTERFACE
;
268 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
269 return E_NOINTERFACE
;
272 IUnknown_AddRef((IUnknown
*)*ppv
);
276 static ULONG WINAPI
HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection
*iface
)
278 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
279 LONG ref
= InterlockedIncrement(&This
->ref
);
281 TRACE("(%p) ref=%ld\n", This
, ref
);
286 static ULONG WINAPI
HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection
*iface
)
288 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
289 LONG ref
= InterlockedDecrement(&This
->ref
);
291 TRACE("(%p) ref=%ld\n", This
, ref
);
294 release_dispex(&This
->dispex
);
296 nsIDOMCSSRuleList_Release(This
->nslist
);
303 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfoCount(
304 IHTMLStyleSheetRulesCollection
*iface
, UINT
*pctinfo
)
306 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
307 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
310 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection
*iface
,
311 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
313 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
314 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
317 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection
*iface
,
318 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
320 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
321 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
325 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection
*iface
,
326 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
327 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
329 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
330 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
331 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
334 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection
*iface
,
337 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
340 TRACE("(%p)->(%p)\n", This
, p
);
345 nsres
= nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
347 ERR("GetLength failed: %08lx\n", nsres
);
354 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection
*iface
,
355 LONG index
, IHTMLStyleSheetRule
**p
)
357 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
358 nsIDOMCSSRule
*nsstylesheetrule
;
362 TRACE("(%p)->(%ld %p)\n", This
, index
, p
);
364 nsres
= nsIDOMCSSRuleList_Item(This
->nslist
, index
, &nsstylesheetrule
);
366 return map_nsresult(nsres
);
367 if(!nsstylesheetrule
)
370 hres
= create_style_sheet_rule(nsstylesheetrule
, dispex_compat_mode(&This
->dispex
), p
);
371 nsIDOMCSSRule_Release(nsstylesheetrule
);
375 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl
= {
376 HTMLStyleSheetRulesCollection_QueryInterface
,
377 HTMLStyleSheetRulesCollection_AddRef
,
378 HTMLStyleSheetRulesCollection_Release
,
379 HTMLStyleSheetRulesCollection_GetTypeInfoCount
,
380 HTMLStyleSheetRulesCollection_GetTypeInfo
,
381 HTMLStyleSheetRulesCollection_GetIDsOfNames
,
382 HTMLStyleSheetRulesCollection_Invoke
,
383 HTMLStyleSheetRulesCollection_get_length
,
384 HTMLStyleSheetRulesCollection_item
387 static inline HTMLStyleSheetRulesCollection
*HTMLStyleSheetRulesCollection_from_DispatchEx(DispatchEx
*iface
)
389 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, dispex
);
392 static HRESULT
HTMLStyleSheetRulesCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
394 HTMLStyleSheetRulesCollection
*This
= HTMLStyleSheetRulesCollection_from_DispatchEx(dispex
);
399 for(ptr
= name
; *ptr
&& is_digit(*ptr
); ptr
++)
400 idx
= idx
*10 + (*ptr
-'0');
402 return DISP_E_UNKNOWNNAME
;
404 nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
406 return DISP_E_UNKNOWNNAME
;
408 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
409 TRACE("ret %lx\n", *dispid
);
413 static HRESULT
HTMLStyleSheetRulesCollection_get_name(DispatchEx
*dispex
, DISPID id
, BSTR
*name
)
415 HTMLStyleSheetRulesCollection
*This
= HTMLStyleSheetRulesCollection_from_DispatchEx(dispex
);
416 DWORD idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
420 nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
422 return DISP_E_MEMBERNOTFOUND
;
424 len
= swprintf(buf
, ARRAY_SIZE(buf
), L
"%u", idx
);
425 return (*name
= SysAllocStringLen(buf
, len
)) ? S_OK
: E_OUTOFMEMORY
;
428 static HRESULT
HTMLStyleSheetRulesCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
429 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
431 HTMLStyleSheetRulesCollection
*This
= HTMLStyleSheetRulesCollection_from_DispatchEx(dispex
);
433 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
436 case DISPATCH_PROPERTYGET
: {
437 IHTMLStyleSheetRule
*stylesheetrule
;
438 nsIDOMCSSRule
*nsstylesheetrule
;
442 nsres
= nsIDOMCSSRuleList_Item(This
->nslist
, id
- MSHTML_DISPID_CUSTOM_MIN
, &nsstylesheetrule
);
444 return DISP_E_MEMBERNOTFOUND
;
445 if(!nsstylesheetrule
) {
446 V_VT(res
) = VT_EMPTY
;
450 hres
= create_style_sheet_rule(nsstylesheetrule
, dispex_compat_mode(&This
->dispex
), &stylesheetrule
);
451 nsIDOMCSSRule_Release(nsstylesheetrule
);
455 V_VT(res
) = VT_DISPATCH
;
456 V_DISPATCH(res
) = (IDispatch
*)stylesheetrule
;
461 FIXME("unimplemented flags %x\n", flags
);
468 static const dispex_static_data_vtbl_t HTMLStyleSheetRulesCollection_dispex_vtbl
= {
470 HTMLStyleSheetRulesCollection_get_dispid
,
471 HTMLStyleSheetRulesCollection_get_name
,
472 HTMLStyleSheetRulesCollection_invoke
474 static const tid_t HTMLStyleSheetRulesCollection_iface_tids
[] = {
475 IHTMLStyleSheetRulesCollection_tid
,
478 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex
= {
480 &HTMLStyleSheetRulesCollection_dispex_vtbl
,
481 DispHTMLStyleSheetRulesCollection_tid
,
482 HTMLStyleSheetRulesCollection_iface_tids
485 static HRESULT
create_style_sheet_rules_collection(nsIDOMCSSRuleList
*nslist
, compat_mode_t compat_mode
,
486 IHTMLStyleSheetRulesCollection
**ret
)
488 HTMLStyleSheetRulesCollection
*collection
;
490 if(!(collection
= malloc(sizeof(*collection
))))
491 return E_OUTOFMEMORY
;
493 collection
->IHTMLStyleSheetRulesCollection_iface
.lpVtbl
= &HTMLStyleSheetRulesCollectionVtbl
;
495 collection
->nslist
= nslist
;
497 init_dispatch(&collection
->dispex
, (IUnknown
*)&collection
->IHTMLStyleSheetRulesCollection_iface
,
498 &HTMLStyleSheetRulesCollection_dispex
, compat_mode
);
501 nsIDOMCSSRuleList_AddRef(nslist
);
503 *ret
= &collection
->IHTMLStyleSheetRulesCollection_iface
;
507 static inline HTMLStyleSheetsCollectionEnum
*HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(IEnumVARIANT
*iface
)
509 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollectionEnum
, IEnumVARIANT_iface
);
512 static HRESULT WINAPI
HTMLStyleSheetsCollectionEnum_QueryInterface(IEnumVARIANT
*iface
, REFIID riid
, void **ppv
)
514 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
516 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
518 if(IsEqualGUID(riid
, &IID_IUnknown
)) {
519 *ppv
= &This
->IEnumVARIANT_iface
;
520 }else if(IsEqualGUID(riid
, &IID_IEnumVARIANT
)) {
521 *ppv
= &This
->IEnumVARIANT_iface
;
523 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
525 return E_NOINTERFACE
;
528 IUnknown_AddRef((IUnknown
*)*ppv
);
532 static ULONG WINAPI
HTMLStyleSheetsCollectionEnum_AddRef(IEnumVARIANT
*iface
)
534 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
535 LONG ref
= InterlockedIncrement(&This
->ref
);
537 TRACE("(%p) ref=%ld\n", This
, ref
);
542 static ULONG WINAPI
HTMLStyleSheetsCollectionEnum_Release(IEnumVARIANT
*iface
)
544 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
545 LONG ref
= InterlockedDecrement(&This
->ref
);
547 TRACE("(%p) ref=%ld\n", This
, ref
);
550 IHTMLStyleSheetsCollection_Release(&This
->col
->IHTMLStyleSheetsCollection_iface
);
557 static HRESULT WINAPI
HTMLStyleSheetsCollectionEnum_Next(IEnumVARIANT
*iface
, ULONG celt
, VARIANT
*rgVar
, ULONG
*pCeltFetched
)
559 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
565 TRACE("(%p)->(%lu %p %p)\n", This
, celt
, rgVar
, pCeltFetched
);
567 nsIDOMStyleSheetList_GetLength(This
->col
->nslist
, &len
);
568 num
= min(len
- This
->iter
, celt
);
569 V_VT(&index
) = VT_I4
;
571 for(i
= 0; i
< num
; i
++) {
572 V_I4(&index
) = This
->iter
+ i
;
573 hres
= IHTMLStyleSheetsCollection_item(&This
->col
->IHTMLStyleSheetsCollection_iface
, &index
, &rgVar
[i
]);
576 VariantClear(&rgVar
[i
]);
584 return num
== celt
? S_OK
: S_FALSE
;
587 static HRESULT WINAPI
HTMLStyleSheetsCollectionEnum_Skip(IEnumVARIANT
*iface
, ULONG celt
)
589 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
592 TRACE("(%p)->(%lu)\n", This
, celt
);
594 nsIDOMStyleSheetList_GetLength(This
->col
->nslist
, &len
);
595 if(This
->iter
+ celt
> len
) {
604 static HRESULT WINAPI
HTMLStyleSheetsCollectionEnum_Reset(IEnumVARIANT
*iface
)
606 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
608 TRACE("(%p)->()\n", This
);
614 static HRESULT WINAPI
HTMLStyleSheetsCollectionEnum_Clone(IEnumVARIANT
*iface
, IEnumVARIANT
**ppEnum
)
616 HTMLStyleSheetsCollectionEnum
*This
= HTMLStyleSheetsCollectionEnum_from_IEnumVARIANT(iface
);
617 FIXME("(%p)->(%p)\n", This
, ppEnum
);
621 static const IEnumVARIANTVtbl HTMLStyleSheetsCollectionEnumVtbl
= {
622 HTMLStyleSheetsCollectionEnum_QueryInterface
,
623 HTMLStyleSheetsCollectionEnum_AddRef
,
624 HTMLStyleSheetsCollectionEnum_Release
,
625 HTMLStyleSheetsCollectionEnum_Next
,
626 HTMLStyleSheetsCollectionEnum_Skip
,
627 HTMLStyleSheetsCollectionEnum_Reset
,
628 HTMLStyleSheetsCollectionEnum_Clone
631 static inline HTMLStyleSheetsCollection
*impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection
*iface
)
633 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, IHTMLStyleSheetsCollection_iface
);
636 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
637 REFIID riid
, void **ppv
)
639 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
641 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
643 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
644 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
645 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
646 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
647 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
648 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
649 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
650 return *ppv
? S_OK
: E_NOINTERFACE
;
653 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
654 return E_NOINTERFACE
;
657 IUnknown_AddRef((IUnknown
*)*ppv
);
661 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
663 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
664 LONG ref
= InterlockedIncrement(&This
->ref
);
666 TRACE("(%p) ref=%ld\n", This
, ref
);
671 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
673 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
674 LONG ref
= InterlockedDecrement(&This
->ref
);
676 TRACE("(%p) ref=%ld\n", This
, ref
);
679 release_dispex(&This
->dispex
);
681 nsIDOMStyleSheetList_Release(This
->nslist
);
688 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
691 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
692 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
695 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
696 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
698 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
699 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
702 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
703 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
705 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
706 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
710 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
711 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
712 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
714 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
715 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
716 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
719 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
722 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
725 TRACE("(%p)->(%p)\n", This
, p
);
728 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
734 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
737 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
738 HTMLStyleSheetsCollectionEnum
*ret
;
740 TRACE("(%p)->(%p)\n", This
, p
);
742 ret
= malloc(sizeof(*ret
));
744 return E_OUTOFMEMORY
;
746 ret
->IEnumVARIANT_iface
.lpVtbl
= &HTMLStyleSheetsCollectionEnumVtbl
;
750 HTMLStyleSheetsCollection_AddRef(&This
->IHTMLStyleSheetsCollection_iface
);
753 *p
= (IUnknown
*)&ret
->IEnumVARIANT_iface
;
757 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
758 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
760 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
762 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(pvarIndex
), pvarResult
);
764 switch(V_VT(pvarIndex
)) {
766 nsIDOMStyleSheet
*nsstylesheet
;
767 IHTMLStyleSheet
*stylesheet
;
771 TRACE("index=%ld\n", V_I4(pvarIndex
));
773 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
774 if(NS_FAILED(nsres
) || !nsstylesheet
) {
775 WARN("Item failed: %08lx\n", nsres
);
776 V_VT(pvarResult
) = VT_EMPTY
;
780 hres
= create_style_sheet(nsstylesheet
, dispex_compat_mode(&This
->dispex
), &stylesheet
);
781 nsIDOMStyleSheet_Release(nsstylesheet
);
785 V_VT(pvarResult
) = VT_DISPATCH
;
786 V_DISPATCH(pvarResult
) = (IDispatch
*)stylesheet
;
791 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
795 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
801 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
802 HTMLStyleSheetsCollection_QueryInterface
,
803 HTMLStyleSheetsCollection_AddRef
,
804 HTMLStyleSheetsCollection_Release
,
805 HTMLStyleSheetsCollection_GetTypeInfoCount
,
806 HTMLStyleSheetsCollection_GetTypeInfo
,
807 HTMLStyleSheetsCollection_GetIDsOfNames
,
808 HTMLStyleSheetsCollection_Invoke
,
809 HTMLStyleSheetsCollection_get_length
,
810 HTMLStyleSheetsCollection_get__newEnum
,
811 HTMLStyleSheetsCollection_item
814 static inline HTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_from_DispatchEx(DispatchEx
*iface
)
816 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, dispex
);
819 static HRESULT
HTMLStyleSheetsCollection_get_dispid(DispatchEx
*dispex
, BSTR name
, DWORD flags
, DISPID
*dispid
)
821 HTMLStyleSheetsCollection
*This
= HTMLStyleSheetsCollection_from_DispatchEx(dispex
);
826 for(ptr
= name
; *ptr
&& is_digit(*ptr
); ptr
++)
827 idx
= idx
*10 + (*ptr
-'0');
829 return DISP_E_UNKNOWNNAME
;
831 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
833 return DISP_E_UNKNOWNNAME
;
835 *dispid
= MSHTML_DISPID_CUSTOM_MIN
+ idx
;
836 TRACE("ret %lx\n", *dispid
);
840 static HRESULT
HTMLStyleSheetsCollection_get_name(DispatchEx
*dispex
, DISPID id
, BSTR
*name
)
842 HTMLStyleSheetsCollection
*This
= HTMLStyleSheetsCollection_from_DispatchEx(dispex
);
843 DWORD idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
847 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
849 return DISP_E_MEMBERNOTFOUND
;
851 len
= swprintf(buf
, ARRAY_SIZE(buf
), L
"%u", idx
);
852 return (*name
= SysAllocStringLen(buf
, len
)) ? S_OK
: E_OUTOFMEMORY
;
855 static HRESULT
HTMLStyleSheetsCollection_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
856 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
858 HTMLStyleSheetsCollection
*This
= HTMLStyleSheetsCollection_from_DispatchEx(dispex
);
860 TRACE("(%p)->(%lx %lx %x %p %p %p %p)\n", This
, id
, lcid
, flags
, params
, res
, ei
, caller
);
863 case DISPATCH_PROPERTYGET
: {
864 nsIDOMStyleSheet
*nsstylesheet
;
865 IHTMLStyleSheet
*stylesheet
;
869 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, id
- MSHTML_DISPID_CUSTOM_MIN
, &nsstylesheet
);
871 return DISP_E_MEMBERNOTFOUND
;
873 V_VT(res
) = VT_EMPTY
;
877 hres
= create_style_sheet(nsstylesheet
, dispex_compat_mode(&This
->dispex
), &stylesheet
);
878 nsIDOMStyleSheet_Release(nsstylesheet
);
882 V_VT(res
) = VT_DISPATCH
;
883 V_DISPATCH(res
) = (IDispatch
*)stylesheet
;
888 FIXME("unimplemented flags %x\n", flags
);
895 static const dispex_static_data_vtbl_t HTMLStyleSheetsCollection_dispex_vtbl
= {
897 HTMLStyleSheetsCollection_get_dispid
,
898 HTMLStyleSheetsCollection_get_name
,
899 HTMLStyleSheetsCollection_invoke
901 static const tid_t HTMLStyleSheetsCollection_iface_tids
[] = {
902 IHTMLStyleSheetsCollection_tid
,
905 static dispex_static_data_t HTMLStyleSheetsCollection_dispex
= {
907 &HTMLStyleSheetsCollection_dispex_vtbl
,
908 DispHTMLStyleSheetsCollection_tid
,
909 HTMLStyleSheetsCollection_iface_tids
912 HRESULT
create_style_sheet_collection(nsIDOMStyleSheetList
*nslist
, compat_mode_t compat_mode
,
913 IHTMLStyleSheetsCollection
**ret
)
915 HTMLStyleSheetsCollection
*collection
;
917 if(!(collection
= malloc(sizeof(HTMLStyleSheetsCollection
))))
918 return E_OUTOFMEMORY
;
920 collection
->IHTMLStyleSheetsCollection_iface
.lpVtbl
= &HTMLStyleSheetsCollectionVtbl
;
924 nsIDOMStyleSheetList_AddRef(nslist
);
925 collection
->nslist
= nslist
;
927 init_dispatch(&collection
->dispex
, (IUnknown
*)&collection
->IHTMLStyleSheetsCollection_iface
,
928 &HTMLStyleSheetsCollection_dispex
, compat_mode
);
930 *ret
= &collection
->IHTMLStyleSheetsCollection_iface
;
934 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet(IHTMLStyleSheet
*iface
)
936 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet_iface
);
939 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
941 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
943 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
945 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
946 *ppv
= &This
->IHTMLStyleSheet_iface
;
947 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
948 *ppv
= &This
->IHTMLStyleSheet_iface
;
949 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
950 *ppv
= &This
->IHTMLStyleSheet_iface
;
951 }else if(IsEqualGUID(&IID_IHTMLStyleSheet4
, riid
)) {
952 *ppv
= &This
->IHTMLStyleSheet4_iface
;
953 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
954 return *ppv
? S_OK
: E_NOINTERFACE
;
957 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
958 return E_NOINTERFACE
;
961 IUnknown_AddRef((IUnknown
*)*ppv
);
965 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
967 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
968 LONG ref
= InterlockedIncrement(&This
->ref
);
970 TRACE("(%p) ref=%ld\n", This
, ref
);
975 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
977 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
978 LONG ref
= InterlockedDecrement(&This
->ref
);
980 TRACE("(%p) ref=%ld\n", This
, ref
);
983 release_dispex(&This
->dispex
);
984 if(This
->nsstylesheet
)
985 nsIDOMCSSStyleSheet_Release(This
->nsstylesheet
);
992 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
994 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
995 TRACE("(%p)->(%p)\n", This
, pctinfo
);
996 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
999 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
1000 LCID lcid
, ITypeInfo
**ppTInfo
)
1002 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1003 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1006 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
1007 LPOLESTR
*rgszNames
, UINT cNames
,
1008 LCID lcid
, DISPID
*rgDispId
)
1010 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1011 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1014 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
1015 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1016 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1018 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1019 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1020 pVarResult
, pExcepInfo
, puArgErr
);
1023 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
1025 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1026 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1030 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
1032 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1033 FIXME("(%p)->(%p)\n", This
, p
);
1037 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
1038 IHTMLStyleSheet
**p
)
1040 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1041 FIXME("(%p)->(%p)\n", This
, p
);
1045 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
1047 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1048 FIXME("(%p)->(%p)\n", This
, p
);
1052 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
1054 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1055 FIXME("(%p)->(%x)\n", This
, v
);
1059 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
1061 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1062 FIXME("(%p)->(%p)\n", This
, p
);
1066 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
1068 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1069 FIXME("(%p)->(%p)\n", This
, p
);
1073 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
1074 IHTMLStyleSheetsCollection
**p
)
1076 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1077 FIXME("(%p)->(%p)\n", This
, p
);
1081 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
1083 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1084 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1088 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
1090 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1094 TRACE("(%p)->(%p)\n", This
, p
);
1096 nsAString_Init(&href_str
, NULL
);
1097 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
1098 return return_nsstr(nsres
, &href_str
, p
);
1101 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
1103 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1104 FIXME("(%p)->(%p)\n", This
, p
);
1108 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
1110 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1111 FIXME("(%p)->(%p)\n", This
, p
);
1115 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
1116 LONG lIndex
, LONG
*plIndex
)
1118 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1119 FIXME("(%p)->(%s %ld %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
1123 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
1124 BSTR bstrStyle
, LONG lIndex
, LONG
*plIndex
)
1126 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1127 const WCHAR format
[] = L
"%s {%s}";
1128 nsIDOMCSSRuleList
*nslist
= NULL
;
1129 UINT32 length
, new_index
;
1135 TRACE("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
1138 if(!bstrSelector
|| !bstrStyle
|| !bstrSelector
[0] || !bstrStyle
[0])
1139 return E_INVALIDARG
;
1141 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
1142 if(NS_FAILED(nsres
))
1144 nsIDOMCSSRuleList_GetLength(nslist
, &length
);
1149 len
= ARRAY_SIZE(format
) - 4 /* %s twice */ + wcslen(bstrSelector
) + wcslen(bstrStyle
);
1150 if(!(rule
= malloc(len
* sizeof(WCHAR
))))
1151 return E_OUTOFMEMORY
;
1152 swprintf(rule
, len
, format
, bstrSelector
, bstrStyle
);
1154 nsAString_InitDepend(&nsstr
, rule
);
1155 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, lIndex
, &new_index
);
1156 if(NS_FAILED(nsres
)) WARN("failed: %08lx\n", nsres
);
1157 nsAString_Finish(&nsstr
);
1160 *plIndex
= new_index
;
1161 return map_nsresult(nsres
);
1164 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, LONG lIndex
)
1166 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1167 FIXME("(%p)->(%ld)\n", This
, lIndex
);
1171 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, LONG lIndex
)
1173 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1174 FIXME("(%p)->(%ld)\n", This
, lIndex
);
1178 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
1180 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1181 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
1185 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
1187 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1188 FIXME("(%p)->(%p)\n", This
, p
);
1192 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
1194 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1197 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
1200 nsres
= nsIDOMCSSStyleSheet_DeleteRule(This
->nsstylesheet
, 0);
1201 }while(NS_SUCCEEDED(nsres
));
1207 /* FIXME: This won't work for multiple rules in the string. */
1208 nsAString_InitDepend(&nsstr
, v
);
1209 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, 0, &idx
);
1210 nsAString_Finish(&nsstr
);
1211 if(NS_FAILED(nsres
)) {
1212 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v
));
1220 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
1222 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1223 nsIDOMCSSRuleList
*nslist
= NULL
;
1224 nsIDOMCSSRule
*nsrule
;
1229 TRACE("(%p)->(%p)\n", This
, p
);
1231 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
1232 if(NS_FAILED(nsres
)) {
1233 ERR("GetCssRules failed: %08lx\n", nsres
);
1237 nsres
= nsIDOMCSSRuleList_GetLength(nslist
, &len
);
1238 assert(nsres
== NS_OK
);
1241 nsres
= nsIDOMCSSRuleList_Item(nslist
, 0, &nsrule
);
1242 if(NS_FAILED(nsres
))
1243 ERR("Item failed: %08lx\n", nsres
);
1246 nsIDOMCSSRuleList_Release(nslist
);
1247 if(NS_FAILED(nsres
))
1255 nsAString_Init(&nsstr
, NULL
);
1256 nsres
= nsIDOMCSSRule_GetCssText(nsrule
, &nsstr
);
1257 nsIDOMCSSRule_Release(nsrule
);
1258 return return_nsstr(nsres
, &nsstr
, p
);
1261 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
1262 IHTMLStyleSheetRulesCollection
**p
)
1264 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
1265 nsIDOMCSSRuleList
*nslist
= NULL
;
1269 TRACE("(%p)->(%p)\n", This
, p
);
1271 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
1272 if(NS_FAILED(nsres
)) {
1273 ERR("GetCssRules failed: %08lx\n", nsres
);
1277 hres
= create_style_sheet_rules_collection(nslist
, dispex_compat_mode(&This
->dispex
), p
);
1278 nsIDOMCSSRuleList_Release(nslist
);
1282 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
1283 HTMLStyleSheet_QueryInterface
,
1284 HTMLStyleSheet_AddRef
,
1285 HTMLStyleSheet_Release
,
1286 HTMLStyleSheet_GetTypeInfoCount
,
1287 HTMLStyleSheet_GetTypeInfo
,
1288 HTMLStyleSheet_GetIDsOfNames
,
1289 HTMLStyleSheet_Invoke
,
1290 HTMLStyleSheet_put_title
,
1291 HTMLStyleSheet_get_title
,
1292 HTMLStyleSheet_get_parentStyleSheet
,
1293 HTMLStyleSheet_get_owningElement
,
1294 HTMLStyleSheet_put_disabled
,
1295 HTMLStyleSheet_get_disabled
,
1296 HTMLStyleSheet_get_readOnly
,
1297 HTMLStyleSheet_get_imports
,
1298 HTMLStyleSheet_put_href
,
1299 HTMLStyleSheet_get_href
,
1300 HTMLStyleSheet_get_type
,
1301 HTMLStyleSheet_get_id
,
1302 HTMLStyleSheet_addImport
,
1303 HTMLStyleSheet_addRule
,
1304 HTMLStyleSheet_removeImport
,
1305 HTMLStyleSheet_removeRule
,
1306 HTMLStyleSheet_put_media
,
1307 HTMLStyleSheet_get_media
,
1308 HTMLStyleSheet_put_cssText
,
1309 HTMLStyleSheet_get_cssText
,
1310 HTMLStyleSheet_get_rules
1313 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet4(IHTMLStyleSheet4
*iface
)
1315 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet4_iface
);
1318 static HRESULT WINAPI
HTMLStyleSheet4_QueryInterface(IHTMLStyleSheet4
*iface
, REFIID riid
, void **ppv
)
1320 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1321 return IHTMLStyleSheet_QueryInterface(&This
->IHTMLStyleSheet_iface
, riid
, ppv
);
1324 static ULONG WINAPI
HTMLStyleSheet4_AddRef(IHTMLStyleSheet4
*iface
)
1326 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1327 return IHTMLStyleSheet_AddRef(&This
->IHTMLStyleSheet_iface
);
1330 static ULONG WINAPI
HTMLStyleSheet4_Release(IHTMLStyleSheet4
*iface
)
1332 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1333 return IHTMLStyleSheet_Release(&This
->IHTMLStyleSheet_iface
);
1336 static HRESULT WINAPI
HTMLStyleSheet4_GetTypeInfoCount(IHTMLStyleSheet4
*iface
, UINT
*pctinfo
)
1338 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1339 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1340 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1343 static HRESULT WINAPI
HTMLStyleSheet4_GetTypeInfo(IHTMLStyleSheet4
*iface
, UINT iTInfo
,
1344 LCID lcid
, ITypeInfo
**ppTInfo
)
1346 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1347 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1350 static HRESULT WINAPI
HTMLStyleSheet4_GetIDsOfNames(IHTMLStyleSheet4
*iface
, REFIID riid
,
1351 LPOLESTR
*rgszNames
, UINT cNames
,
1352 LCID lcid
, DISPID
*rgDispId
)
1354 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1355 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1358 static HRESULT WINAPI
HTMLStyleSheet4_Invoke(IHTMLStyleSheet4
*iface
, DISPID dispIdMember
,
1359 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1360 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1362 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1363 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1364 pVarResult
, pExcepInfo
, puArgErr
);
1367 static HRESULT WINAPI
HTMLStyleSheet4_get_type(IHTMLStyleSheet4
*iface
, BSTR
*p
)
1369 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1370 TRACE("(%p)->(%p)\n", This
, p
);
1371 return IHTMLStyleSheet_get_type(&This
->IHTMLStyleSheet_iface
, p
);
1374 static HRESULT WINAPI
HTMLStyleSheet4_get_href(IHTMLStyleSheet4
*iface
, VARIANT
*p
)
1376 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1380 TRACE("(%p)->(%p)\n", This
, p
);
1382 nsAString_Init(&href_str
, NULL
);
1383 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
1384 return return_nsstr_variant(nsres
, &href_str
, 0, p
);
1387 static HRESULT WINAPI
HTMLStyleSheet4_get_title(IHTMLStyleSheet4
*iface
, BSTR
*p
)
1389 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1390 FIXME("(%p)->(%p)\n", This
, p
);
1394 static HRESULT WINAPI
HTMLStyleSheet4_get_ownerNode(IHTMLStyleSheet4
*iface
, IHTMLElement
**p
)
1396 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1397 FIXME("(%p)->(%p)\n", This
, p
);
1401 static HRESULT WINAPI
HTMLStyleSheet4_get_ownerRule(IHTMLStyleSheet4
*iface
, IHTMLCSSRule
**p
)
1403 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1404 FIXME("(%p)->(%p)\n", This
, p
);
1408 static HRESULT WINAPI
HTMLStyleSheet4_get_cssRules(IHTMLStyleSheet4
*iface
, IHTMLStyleSheetRulesCollection
**p
)
1410 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1411 TRACE("(%p)->(%p)\n", This
, p
);
1412 return IHTMLStyleSheet_get_rules(&This
->IHTMLStyleSheet_iface
, p
);
1415 static HRESULT WINAPI
HTMLStyleSheet4_get_media(IHTMLStyleSheet4
*iface
, VARIANT
*p
)
1417 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1418 FIXME("(%p)->(%p)\n", This
, p
);
1422 static HRESULT WINAPI
HTMLStyleSheet4_insertRule(IHTMLStyleSheet4
*iface
, BSTR rule
, LONG index
, LONG
*p
)
1424 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1425 UINT32 new_index
= 0;
1429 TRACE("(%p)->(%s %ld %p)\n", This
, debugstr_w(rule
), index
, p
);
1431 nsAString_InitDepend(&nsstr
, rule
);
1432 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, index
, &new_index
);
1433 if(NS_FAILED(nsres
)) WARN("failed: %08lx\n", nsres
);
1434 nsAString_Finish(&nsstr
);
1436 return map_nsresult(nsres
);
1439 static HRESULT WINAPI
HTMLStyleSheet4_deleteRule(IHTMLStyleSheet4
*iface
, LONG index
)
1441 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet4(iface
);
1442 FIXME("(%p)->(%ld)\n", This
, index
);
1446 static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl
= {
1447 HTMLStyleSheet4_QueryInterface
,
1448 HTMLStyleSheet4_AddRef
,
1449 HTMLStyleSheet4_Release
,
1450 HTMLStyleSheet4_GetTypeInfoCount
,
1451 HTMLStyleSheet4_GetTypeInfo
,
1452 HTMLStyleSheet4_GetIDsOfNames
,
1453 HTMLStyleSheet4_Invoke
,
1454 HTMLStyleSheet4_get_type
,
1455 HTMLStyleSheet4_get_href
,
1456 HTMLStyleSheet4_get_title
,
1457 HTMLStyleSheet4_get_ownerNode
,
1458 HTMLStyleSheet4_get_ownerRule
,
1459 HTMLStyleSheet4_get_cssRules
,
1460 HTMLStyleSheet4_get_media
,
1461 HTMLStyleSheet4_insertRule
,
1462 HTMLStyleSheet4_deleteRule
,
1465 static void HTMLStyleSheet_init_dispex_info(dispex_data_t
*info
, compat_mode_t mode
)
1467 if(mode
>= COMPAT_MODE_IE9
)
1468 dispex_info_add_interface(info
, IHTMLStyleSheet4_tid
, NULL
);
1471 static const tid_t HTMLStyleSheet_iface_tids
[] = {
1472 IHTMLStyleSheet_tid
,
1475 static dispex_static_data_t HTMLStyleSheet_dispex
= {
1478 DispHTMLStyleSheet_tid
,
1479 HTMLStyleSheet_iface_tids
,
1480 HTMLStyleSheet_init_dispex_info
1483 HRESULT
create_style_sheet(nsIDOMStyleSheet
*nsstylesheet
, compat_mode_t compat_mode
, IHTMLStyleSheet
**ret
)
1485 HTMLStyleSheet
*style_sheet
;
1488 if(!(style_sheet
= malloc(sizeof(HTMLStyleSheet
))))
1489 return E_OUTOFMEMORY
;
1491 style_sheet
->IHTMLStyleSheet_iface
.lpVtbl
= &HTMLStyleSheetVtbl
;
1492 style_sheet
->IHTMLStyleSheet4_iface
.lpVtbl
= &HTMLStyleSheet4Vtbl
;
1493 style_sheet
->ref
= 1;
1494 style_sheet
->nsstylesheet
= NULL
;
1496 init_dispatch(&style_sheet
->dispex
, (IUnknown
*)&style_sheet
->IHTMLStyleSheet_iface
,
1497 &HTMLStyleSheet_dispex
, compat_mode
);
1500 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
1501 (void**)&style_sheet
->nsstylesheet
);
1502 if(NS_FAILED(nsres
))
1503 ERR("Could not get nsICSSStyleSheet interface: %08lx\n", nsres
);
1506 *ret
= &style_sheet
->IHTMLStyleSheet_iface
;