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
,
196 HTMLStyleSheetRulesCollection_iface_tids
199 static IHTMLStyleSheetRulesCollection
*HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList
*nslist
)
201 HTMLStyleSheetRulesCollection
*ret
;
203 ret
= heap_alloc(sizeof(*ret
));
204 ret
->IHTMLStyleSheetRulesCollection_iface
.lpVtbl
= &HTMLStyleSheetRulesCollectionVtbl
;
206 ret
->nslist
= nslist
;
208 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetRulesCollection_iface
, &HTMLStyleSheetRulesCollection_dispex
);
211 nsIDOMCSSRuleList_AddRef(nslist
);
213 return &ret
->IHTMLStyleSheetRulesCollection_iface
;
216 static inline HTMLStyleSheetsCollection
*impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection
*iface
)
218 return CONTAINING_RECORD(iface
, HTMLStyleSheetsCollection
, IHTMLStyleSheetsCollection_iface
);
221 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
222 REFIID riid
, void **ppv
)
224 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
226 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
228 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
229 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
230 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
231 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
232 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
233 *ppv
= &This
->IHTMLStyleSheetsCollection_iface
;
234 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
235 return *ppv
? S_OK
: E_NOINTERFACE
;
238 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
239 return E_NOINTERFACE
;
242 IUnknown_AddRef((IUnknown
*)*ppv
);
246 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
248 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
249 LONG ref
= InterlockedIncrement(&This
->ref
);
251 TRACE("(%p) ref=%d\n", This
, ref
);
256 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
258 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
259 LONG ref
= InterlockedDecrement(&This
->ref
);
261 TRACE("(%p) ref=%d\n", This
, ref
);
264 release_dispex(&This
->dispex
);
266 nsIDOMStyleSheetList_Release(This
->nslist
);
273 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
276 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
277 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
280 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
281 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
283 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
284 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
287 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
288 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
290 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
291 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
295 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
296 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
297 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
299 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
300 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
301 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
304 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
307 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
310 TRACE("(%p)->(%p)\n", This
, p
);
313 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
319 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
322 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
323 FIXME("(%p)->(%p)\n", This
, p
);
327 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
328 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
330 HTMLStyleSheetsCollection
*This
= impl_from_IHTMLStyleSheetsCollection(iface
);
332 TRACE("(%p)->(%s %p)\n", This
, debugstr_variant(pvarIndex
), pvarResult
);
334 switch(V_VT(pvarIndex
)) {
336 nsIDOMStyleSheet
*nsstylesheet
;
339 TRACE("index=%d\n", V_I4(pvarIndex
));
341 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
342 if(NS_FAILED(nsres
) || !nsstylesheet
) {
343 WARN("Item failed: %08x\n", nsres
);
344 V_VT(pvarResult
) = VT_EMPTY
;
348 V_VT(pvarResult
) = VT_DISPATCH
;
349 V_DISPATCH(pvarResult
) = (IDispatch
*)HTMLStyleSheet_Create(nsstylesheet
);
355 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
359 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
365 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
366 HTMLStyleSheetsCollection_QueryInterface
,
367 HTMLStyleSheetsCollection_AddRef
,
368 HTMLStyleSheetsCollection_Release
,
369 HTMLStyleSheetsCollection_GetTypeInfoCount
,
370 HTMLStyleSheetsCollection_GetTypeInfo
,
371 HTMLStyleSheetsCollection_GetIDsOfNames
,
372 HTMLStyleSheetsCollection_Invoke
,
373 HTMLStyleSheetsCollection_get_length
,
374 HTMLStyleSheetsCollection_get__newEnum
,
375 HTMLStyleSheetsCollection_item
378 static const tid_t HTMLStyleSheetsCollection_iface_tids
[] = {
379 IHTMLStyleSheetsCollection_tid
,
382 static dispex_static_data_t HTMLStyleSheetsCollection_dispex
= {
384 DispHTMLStyleSheetsCollection_tid
,
386 HTMLStyleSheetsCollection_iface_tids
389 IHTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList
*nslist
)
391 HTMLStyleSheetsCollection
*ret
= heap_alloc(sizeof(HTMLStyleSheetsCollection
));
393 ret
->IHTMLStyleSheetsCollection_iface
.lpVtbl
= &HTMLStyleSheetsCollectionVtbl
;
397 nsIDOMStyleSheetList_AddRef(nslist
);
398 ret
->nslist
= nslist
;
400 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheetsCollection_iface
,
401 &HTMLStyleSheetsCollection_dispex
);
403 return &ret
->IHTMLStyleSheetsCollection_iface
;
406 static inline HTMLStyleSheet
*impl_from_IHTMLStyleSheet(IHTMLStyleSheet
*iface
)
408 return CONTAINING_RECORD(iface
, HTMLStyleSheet
, IHTMLStyleSheet_iface
);
411 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
413 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
415 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
417 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
418 *ppv
= &This
->IHTMLStyleSheet_iface
;
419 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
420 *ppv
= &This
->IHTMLStyleSheet_iface
;
421 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
422 *ppv
= &This
->IHTMLStyleSheet_iface
;
423 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
424 return *ppv
? S_OK
: E_NOINTERFACE
;
427 WARN("unsupported %s\n", debugstr_mshtml_guid(riid
));
428 return E_NOINTERFACE
;
431 IUnknown_AddRef((IUnknown
*)*ppv
);
435 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
437 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
438 LONG ref
= InterlockedIncrement(&This
->ref
);
440 TRACE("(%p) ref=%d\n", This
, ref
);
445 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
447 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
448 LONG ref
= InterlockedDecrement(&This
->ref
);
450 TRACE("(%p) ref=%d\n", This
, ref
);
453 release_dispex(&This
->dispex
);
454 if(This
->nsstylesheet
)
455 nsIDOMCSSStyleSheet_Release(This
->nsstylesheet
);
462 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
464 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
465 TRACE("(%p)->(%p)\n", This
, pctinfo
);
466 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
469 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
470 LCID lcid
, ITypeInfo
**ppTInfo
)
472 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
473 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
476 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
477 LPOLESTR
*rgszNames
, UINT cNames
,
478 LCID lcid
, DISPID
*rgDispId
)
480 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
481 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
484 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
485 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
486 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
488 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
489 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
490 pVarResult
, pExcepInfo
, puArgErr
);
493 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
495 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
496 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
500 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
502 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
503 FIXME("(%p)->(%p)\n", This
, p
);
507 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
510 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
511 FIXME("(%p)->(%p)\n", This
, p
);
515 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
517 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
518 FIXME("(%p)->(%p)\n", This
, p
);
522 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
524 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
525 FIXME("(%p)->(%x)\n", This
, v
);
529 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
531 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
532 FIXME("(%p)->(%p)\n", This
, p
);
536 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
538 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
539 FIXME("(%p)->(%p)\n", This
, p
);
543 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
544 IHTMLStyleSheetsCollection
**p
)
546 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
547 FIXME("(%p)->(%p)\n", This
, p
);
551 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
553 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
554 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
558 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
560 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
564 TRACE("(%p)->(%p)\n", This
, p
);
566 nsAString_Init(&href_str
, NULL
);
567 nsres
= nsIDOMCSSStyleSheet_GetHref(This
->nsstylesheet
, &href_str
);
568 return return_nsstr(nsres
, &href_str
, p
);
571 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
573 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
574 FIXME("(%p)->(%p)\n", This
, p
);
578 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
580 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
581 FIXME("(%p)->(%p)\n", This
, p
);
585 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
586 LONG lIndex
, LONG
*plIndex
)
588 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
589 FIXME("(%p)->(%s %d %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
593 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
594 BSTR bstrStyle
, LONG lIndex
, LONG
*plIndex
)
596 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
597 FIXME("(%p)->(%s %s %d %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
602 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, LONG lIndex
)
604 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
605 FIXME("(%p)->(%d)\n", This
, lIndex
);
609 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, LONG lIndex
)
611 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
612 FIXME("(%p)->(%d)\n", This
, lIndex
);
616 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
618 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
619 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
623 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
625 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
626 FIXME("(%p)->(%p)\n", This
, p
);
630 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
632 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
635 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
638 nsres
= nsIDOMCSSStyleSheet_DeleteRule(This
->nsstylesheet
, 0);
639 }while(NS_SUCCEEDED(nsres
));
645 /* FIXME: This won't work for multiple rules in the string. */
646 nsAString_InitDepend(&nsstr
, v
);
647 nsres
= nsIDOMCSSStyleSheet_InsertRule(This
->nsstylesheet
, &nsstr
, 0, &idx
);
648 nsAString_Finish(&nsstr
);
649 if(NS_FAILED(nsres
)) {
650 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v
));
658 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
660 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
661 nsIDOMCSSRuleList
*nslist
= NULL
;
662 nsIDOMCSSRule
*nsrule
;
667 TRACE("(%p)->(%p)\n", This
, p
);
669 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
670 if(NS_FAILED(nsres
)) {
671 ERR("GetCssRules failed: %08x\n", nsres
);
675 nsres
= nsIDOMCSSRuleList_GetLength(nslist
, &len
);
676 assert(nsres
== NS_OK
);
679 nsres
= nsIDOMCSSRuleList_Item(nslist
, 0, &nsrule
);
681 ERR("Item failed: %08x\n", nsres
);
684 nsIDOMCSSRuleList_Release(nslist
);
693 nsAString_Init(&nsstr
, NULL
);
694 nsres
= nsIDOMCSSRule_GetCssText(nsrule
, &nsstr
);
695 nsIDOMCSSRule_Release(nsrule
);
696 return return_nsstr(nsres
, &nsstr
, p
);
699 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
700 IHTMLStyleSheetRulesCollection
**p
)
702 HTMLStyleSheet
*This
= impl_from_IHTMLStyleSheet(iface
);
703 nsIDOMCSSRuleList
*nslist
= NULL
;
706 TRACE("(%p)->(%p)\n", This
, p
);
708 nsres
= nsIDOMCSSStyleSheet_GetCssRules(This
->nsstylesheet
, &nslist
);
709 if(NS_FAILED(nsres
)) {
710 ERR("GetCssRules failed: %08x\n", nsres
);
714 *p
= HTMLStyleSheetRulesCollection_Create(nslist
);
718 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
719 HTMLStyleSheet_QueryInterface
,
720 HTMLStyleSheet_AddRef
,
721 HTMLStyleSheet_Release
,
722 HTMLStyleSheet_GetTypeInfoCount
,
723 HTMLStyleSheet_GetTypeInfo
,
724 HTMLStyleSheet_GetIDsOfNames
,
725 HTMLStyleSheet_Invoke
,
726 HTMLStyleSheet_put_title
,
727 HTMLStyleSheet_get_title
,
728 HTMLStyleSheet_get_parentStyleSheet
,
729 HTMLStyleSheet_get_owningElement
,
730 HTMLStyleSheet_put_disabled
,
731 HTMLStyleSheet_get_disabled
,
732 HTMLStyleSheet_get_readOnly
,
733 HTMLStyleSheet_get_imports
,
734 HTMLStyleSheet_put_href
,
735 HTMLStyleSheet_get_href
,
736 HTMLStyleSheet_get_type
,
737 HTMLStyleSheet_get_id
,
738 HTMLStyleSheet_addImport
,
739 HTMLStyleSheet_addRule
,
740 HTMLStyleSheet_removeImport
,
741 HTMLStyleSheet_removeRule
,
742 HTMLStyleSheet_put_media
,
743 HTMLStyleSheet_get_media
,
744 HTMLStyleSheet_put_cssText
,
745 HTMLStyleSheet_get_cssText
,
746 HTMLStyleSheet_get_rules
749 static const tid_t HTMLStyleSheet_iface_tids
[] = {
753 static dispex_static_data_t HTMLStyleSheet_dispex
= {
755 DispHTMLStyleSheet_tid
,
757 HTMLStyleSheet_iface_tids
760 IHTMLStyleSheet
*HTMLStyleSheet_Create(nsIDOMStyleSheet
*nsstylesheet
)
762 HTMLStyleSheet
*ret
= heap_alloc(sizeof(HTMLStyleSheet
));
765 ret
->IHTMLStyleSheet_iface
.lpVtbl
= &HTMLStyleSheetVtbl
;
767 ret
->nsstylesheet
= NULL
;
769 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLStyleSheet_iface
, &HTMLStyleSheet_dispex
);
772 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
773 (void**)&ret
->nsstylesheet
);
775 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres
);
778 return &ret
->IHTMLStyleSheet_iface
;