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 static inline HTMLStyleSheetRulesCollection
*impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection
*iface
)
64 return CONTAINING_RECORD(iface
, HTMLStyleSheetRulesCollection
, IHTMLStyleSheetRulesCollection_iface
);
67 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection
*iface
,
68 REFIID riid
, void **ppv
)
70 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
72 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
74 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
75 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
76 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection
, riid
)) {
77 *ppv
= &This
->IHTMLStyleSheetRulesCollection_iface
;
78 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
79 return *ppv
? S_OK
: E_NOINTERFACE
;
82 FIXME("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
86 IUnknown_AddRef((IUnknown
*)*ppv
);
90 static ULONG WINAPI
HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection
*iface
)
92 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
93 LONG ref
= InterlockedIncrement(&This
->ref
);
95 TRACE("(%p) ref=%d\n", This
, ref
);
100 static ULONG WINAPI
HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection
*iface
)
102 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
103 LONG ref
= InterlockedDecrement(&This
->ref
);
105 TRACE("(%p) ref=%d\n", This
, ref
);
108 release_dispex(&This
->dispex
);
110 nsIDOMCSSRuleList_Release(This
->nslist
);
117 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfoCount(
118 IHTMLStyleSheetRulesCollection
*iface
, UINT
*pctinfo
)
120 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
121 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
124 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection
*iface
,
125 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
127 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
128 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
131 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection
*iface
,
132 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
134 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
135 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
139 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection
*iface
,
140 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
141 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
143 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
144 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
145 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
148 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection
*iface
,
151 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
154 TRACE("(%p)->(%p)\n", This
, p
);
159 nsres
= nsIDOMCSSRuleList_GetLength(This
->nslist
, &len
);
161 ERR("GetLength failed: %08x\n", nsres
);
168 static HRESULT WINAPI
HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection
*iface
,
169 LONG index
, IHTMLStyleSheetRule
**ppHTMLStyleSheetRule
)
171 HTMLStyleSheetRulesCollection
*This
= impl_from_IHTMLStyleSheetRulesCollection(iface
);
172 FIXME("(%p)->(%d %p)\n", This
, index
, ppHTMLStyleSheetRule
);
176 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl
= {
177 HTMLStyleSheetRulesCollection_QueryInterface
,
178 HTMLStyleSheetRulesCollection_AddRef
,
179 HTMLStyleSheetRulesCollection_Release
,
180 HTMLStyleSheetRulesCollection_GetTypeInfoCount
,
181 HTMLStyleSheetRulesCollection_GetTypeInfo
,
182 HTMLStyleSheetRulesCollection_GetIDsOfNames
,
183 HTMLStyleSheetRulesCollection_Invoke
,
184 HTMLStyleSheetRulesCollection_get_length
,
185 HTMLStyleSheetRulesCollection_item
188 static const tid_t HTMLStyleSheetRulesCollection_iface_tids
[] = {
189 IHTMLStyleSheetRulesCollection_tid
,
192 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex
= {
194 DispHTMLStyleSheetRulesCollection_tid
,
195 HTMLStyleSheetRulesCollection_iface_tids
198 static IHTMLStyleSheetRulesCollection
*HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList
*nslist
)
200 HTMLStyleSheetRulesCollection
*ret
;
202 ret
= heap_alloc(sizeof(*ret
));
203 ret
->IHTMLStyleSheetRulesCollection_iface
.lpVtbl
= &HTMLStyleSheetRulesCollectionVtbl
;
205 ret
->nslist
= nslist
;
207 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetRulesCollection_iface
, &HTMLStyleSheetRulesCollection_dispex
);
210 nsIDOMCSSRuleList_AddRef(nslist
);
212 return &ret
->IHTMLStyleSheetRulesCollection_iface
;
215 static inline HTMLStyleSheetsCollection
*impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection
*iface
)
217 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, IHTMLStyleSheetsCollection_iface
);
220 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
221 REFIID riid
, void **ppv
)
223 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
225 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
227 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
228 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
229 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
230 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
231 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
232 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
233 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
234 return *ppv
? S_OK
: E_NOINTERFACE
;
237 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
238 return E_NOINTERFACE
;
241 IUnknown_AddRef((IUnknown
*)*ppv
);
245 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
247 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
248 LONG ref
= InterlockedIncrement(&This
->ref
);
250 TRACE("(%p) ref=%d\n", This
, ref
);
255 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
257 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
258 LONG ref
= InterlockedDecrement(&This
->ref
);
260 TRACE("(%p) ref=%d\n", This
, ref
);
263 release_dispex(&This
->dispex
);
265 nsIDOMStyleSheetList_Release(This
->nslist
);
272 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
275 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
276 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
279 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
280 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
282 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
283 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
286 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
287 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
289 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
290 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
294 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
295 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
296 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
298 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
299 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
300 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
303 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
306 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
309 TRACE("(%p)->(%p)\n", This
, p
);
312 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
318 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
321 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
322 FIXME("(%p)->(%p)\n", This
, p
);
326 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
327 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
329 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
331 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(pvarIndex
), pvarResult
);
333 switch(V_VT(pvarIndex
)) {
335 nsIDOMStyleSheet
*nsstylesheet
;
338 TRACE("index=%d\n", V_I4(pvarIndex
));
340 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
341 if(NS_FAILED(nsres
) || !nsstylesheet
) {
342 WARN("Item failed: %08x\n", nsres
);
343 V_VT(pvarResult
) = VT_EMPTY
;
347 V_VT(pvarResult
) = VT_DISPATCH
;
348 V_DISPATCH(pvarResult
) = (IDispatch
*)HTMLStyleSheet_Create(nsstylesheet
);
354 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
358 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
364 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
365 HTMLStyleSheetsCollection_QueryInterface
,
366 HTMLStyleSheetsCollection_AddRef
,
367 HTMLStyleSheetsCollection_Release
,
368 HTMLStyleSheetsCollection_GetTypeInfoCount
,
369 HTMLStyleSheetsCollection_GetTypeInfo
,
370 HTMLStyleSheetsCollection_GetIDsOfNames
,
371 HTMLStyleSheetsCollection_Invoke
,
372 HTMLStyleSheetsCollection_get_length
,
373 HTMLStyleSheetsCollection_get__newEnum
,
374 HTMLStyleSheetsCollection_item
377 static const tid_t HTMLStyleSheetsCollection_iface_tids
[] = {
378 IHTMLStyleSheetsCollection_tid
,
381 static dispex_static_data_t HTMLStyleSheetsCollection_dispex
= {
383 DispHTMLStyleSheetsCollection_tid
,
384 HTMLStyleSheetsCollection_iface_tids
387 IHTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList
*nslist
)
389 HTMLStyleSheetsCollection
*ret
= heap_alloc(sizeof(HTMLStyleSheetsCollection
));
391 ret
->IHTMLStyleSheetsCollection_iface
.lpVtbl
= &HTMLStyleSheetsCollectionVtbl
;
395 nsIDOMStyleSheetList_AddRef(nslist
);
396 ret
->nslist
= nslist
;
398 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetsCollection_iface
,
399 &HTMLStyleSheetsCollection_dispex
);
401 return &ret
->IHTMLStyleSheetsCollection_iface
;
404 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet(IHTMLStyleSheet
*iface
)
406 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet_iface
);
409 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
411 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
413 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
415 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
416 *ppv
= &This
->IHTMLStyleSheet_iface
;
417 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
418 *ppv
= &This
->IHTMLStyleSheet_iface
;
419 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
420 *ppv
= &This
->IHTMLStyleSheet_iface
;
421 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
422 return *ppv
? S_OK
: E_NOINTERFACE
;
425 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
426 return E_NOINTERFACE
;
429 IUnknown_AddRef((IUnknown
*)*ppv
);
433 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
435 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
436 LONG ref
= InterlockedIncrement(&This
->ref
);
438 TRACE("(%p) ref=%d\n", This
, ref
);
443 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
445 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
446 LONG ref
= InterlockedDecrement(&This
->ref
);
448 TRACE("(%p) ref=%d\n", This
, ref
);
451 release_dispex(&This
->dispex
);
452 if(This
->nsstylesheet
)
453 nsIDOMCSSStyleSheet_Release(This
->nsstylesheet
);
460 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
462 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
463 TRACE("(%p)->(%p)\n", This
, pctinfo
);
464 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
467 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
468 LCID lcid
, ITypeInfo
**ppTInfo
)
470 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
471 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
474 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
475 LPOLESTR
*rgszNames
, UINT cNames
,
476 LCID lcid
, DISPID
*rgDispId
)
478 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
479 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
482 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
483 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
484 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
486 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
487 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
488 pVarResult
, pExcepInfo
, puArgErr
);
491 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
493 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
494 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
498 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
500 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
501 FIXME("(%p)->(%p)\n", This
, p
);
505 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
508 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
509 FIXME("(%p)->(%p)\n", This
, p
);
513 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
515 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
516 FIXME("(%p)->(%p)\n", This
, p
);
520 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
522 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
523 FIXME("(%p)->(%x)\n", This
, v
);
527 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
529 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
530 FIXME("(%p)->(%p)\n", This
, p
);
534 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
536 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
537 FIXME("(%p)->(%p)\n", This
, p
);
541 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
542 IHTMLStyleSheetsCollection
**p
)
544 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
545 FIXME("(%p)->(%p)\n", This
, p
);
549 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
551 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
552 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
556 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
558 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
562 TRACE("(%p)->(%p)\n", This
, p
);
564 nsAString_Init(&href_str
, NULL
);
565 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
566 return return_nsstr(nsres
, &href_str
, p
);
569 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
571 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
572 FIXME("(%p)->(%p)\n", This
, p
);
576 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
578 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
579 FIXME("(%p)->(%p)\n", This
, p
);
583 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
584 LONG lIndex
, LONG
*plIndex
)
586 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
587 FIXME("(%p)->(%s %d %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
591 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
592 BSTR bstrStyle
, LONG lIndex
, LONG
*plIndex
)
594 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
595 FIXME("(%p)->(%s %s %d %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
600 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, LONG lIndex
)
602 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
603 FIXME("(%p)->(%d)\n", This
, lIndex
);
607 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, LONG lIndex
)
609 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
610 FIXME("(%p)->(%d)\n", This
, lIndex
);
614 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
616 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
617 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
621 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
623 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
624 FIXME("(%p)->(%p)\n", This
, p
);
628 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
630 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
633 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
636 nsres
= nsIDOMCSSStyleSheet_DeleteRule(This
->nsstylesheet
, 0);
637 }while(NS_SUCCEEDED(nsres
));
643 /* FIXME: This won't work for multiple rules in the string. */
644 nsAString_InitDepend(&nsstr
, v
);
645 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, 0, &idx
);
646 nsAString_Finish(&nsstr
);
647 if(NS_FAILED(nsres
)) {
648 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v
));
656 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
658 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
659 nsIDOMCSSRuleList
*nslist
= NULL
;
660 nsIDOMCSSRule
*nsrule
;
665 TRACE("(%p)->(%p)\n", This
, p
);
667 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
668 if(NS_FAILED(nsres
)) {
669 ERR("GetCssRules failed: %08x\n", nsres
);
673 nsres
= nsIDOMCSSRuleList_GetLength(nslist
, &len
);
674 assert(nsres
== NS_OK
);
677 nsres
= nsIDOMCSSRuleList_Item(nslist
, 0, &nsrule
);
679 ERR("Item failed: %08x\n", nsres
);
682 nsIDOMCSSRuleList_Release(nslist
);
691 nsAString_Init(&nsstr
, NULL
);
692 nsres
= nsIDOMCSSRule_GetCssText(nsrule
, &nsstr
);
693 nsIDOMCSSRule_Release(nsrule
);
694 return return_nsstr(nsres
, &nsstr
, p
);
697 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
698 IHTMLStyleSheetRulesCollection
**p
)
700 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
701 nsIDOMCSSRuleList
*nslist
= NULL
;
704 TRACE("(%p)->(%p)\n", This
, p
);
706 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
707 if(NS_FAILED(nsres
)) {
708 ERR("GetCssRules failed: %08x\n", nsres
);
712 *p
= HTMLStyleSheetRulesCollection_Create(nslist
);
716 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
717 HTMLStyleSheet_QueryInterface
,
718 HTMLStyleSheet_AddRef
,
719 HTMLStyleSheet_Release
,
720 HTMLStyleSheet_GetTypeInfoCount
,
721 HTMLStyleSheet_GetTypeInfo
,
722 HTMLStyleSheet_GetIDsOfNames
,
723 HTMLStyleSheet_Invoke
,
724 HTMLStyleSheet_put_title
,
725 HTMLStyleSheet_get_title
,
726 HTMLStyleSheet_get_parentStyleSheet
,
727 HTMLStyleSheet_get_owningElement
,
728 HTMLStyleSheet_put_disabled
,
729 HTMLStyleSheet_get_disabled
,
730 HTMLStyleSheet_get_readOnly
,
731 HTMLStyleSheet_get_imports
,
732 HTMLStyleSheet_put_href
,
733 HTMLStyleSheet_get_href
,
734 HTMLStyleSheet_get_type
,
735 HTMLStyleSheet_get_id
,
736 HTMLStyleSheet_addImport
,
737 HTMLStyleSheet_addRule
,
738 HTMLStyleSheet_removeImport
,
739 HTMLStyleSheet_removeRule
,
740 HTMLStyleSheet_put_media
,
741 HTMLStyleSheet_get_media
,
742 HTMLStyleSheet_put_cssText
,
743 HTMLStyleSheet_get_cssText
,
744 HTMLStyleSheet_get_rules
747 static const tid_t HTMLStyleSheet_iface_tids
[] = {
751 static dispex_static_data_t HTMLStyleSheet_dispex
= {
753 DispHTMLStyleSheet_tid
,
754 HTMLStyleSheet_iface_tids
757 IHTMLStyleSheet
*HTMLStyleSheet_Create(nsIDOMStyleSheet
*nsstylesheet
)
759 HTMLStyleSheet
*ret
= heap_alloc(sizeof(HTMLStyleSheet
));
762 ret
->IHTMLStyleSheet_iface
.lpVtbl
= &HTMLStyleSheetVtbl
;
764 ret
->nsstylesheet
= NULL
;
766 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheet_iface
, &HTMLStyleSheet_dispex
);
769 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
770 (void**)&ret
->nsstylesheet
);
772 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres
);
775 return &ret
->IHTMLStyleSheet_iface
;