qcap: Implement a stubbed SmartTee filter.
[wine/multimedia.git] / dlls / mshtml / htmlstylesheet.c
blobd2960d2ef73edf4614d2ead70f29d4e5f8e6c020
1 /*
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
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct HTMLStyleSheet {
36 DispatchEx dispex;
37 IHTMLStyleSheet IHTMLStyleSheet_iface;
39 LONG ref;
41 nsIDOMCSSStyleSheet *nsstylesheet;
44 struct HTMLStyleSheetsCollection {
45 DispatchEx dispex;
46 IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
48 LONG ref;
50 nsIDOMStyleSheetList *nslist;
53 struct HTMLStyleSheetRulesCollection {
54 DispatchEx dispex;
55 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
57 LONG ref;
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;
80 }else {
81 *ppv = NULL;
82 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
83 return E_NOINTERFACE;
86 IUnknown_AddRef((IUnknown*)*ppv);
87 return S_OK;
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);
97 return 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);
107 if(!ref) {
108 release_dispex(&This->dispex);
109 if(This->nslist)
110 nsIDOMCSSRuleList_Release(This->nslist);
111 heap_free(This);
114 return ref;
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,
136 lcid, rgDispId);
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,
149 LONG *p)
151 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
152 UINT32 len = 0;
154 TRACE("(%p)->(%p)\n", This, p);
156 if(This->nslist) {
157 nsresult nsres;
159 nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
160 if(NS_FAILED(nsres))
161 ERR("GetLength failed: %08x\n", nsres);
164 *p = len;
165 return S_OK;
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);
173 return E_NOTIMPL;
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 = {
193 NULL,
194 DispHTMLStyleSheetRulesCollection_tid,
195 NULL,
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;
205 ret->ref = 1;
206 ret->nslist = nslist;
208 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetRulesCollection_iface, &HTMLStyleSheetRulesCollection_dispex);
210 if(nslist)
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;
236 }else {
237 *ppv = NULL;
238 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
239 return E_NOINTERFACE;
242 IUnknown_AddRef((IUnknown*)*ppv);
243 return S_OK;
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);
253 return 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);
263 if(!ref) {
264 release_dispex(&This->dispex);
265 if(This->nslist)
266 nsIDOMStyleSheetList_Release(This->nslist);
267 heap_free(This);
270 return ref;
273 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
274 UINT *pctinfo)
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,
292 lcid, rgDispId);
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,
305 LONG *p)
307 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
308 UINT32 len = 0;
310 TRACE("(%p)->(%p)\n", This, p);
312 if(This->nslist)
313 nsIDOMStyleSheetList_GetLength(This->nslist, &len);
315 *p = len;
316 return S_OK;
319 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
320 IUnknown **p)
322 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
323 FIXME("(%p)->(%p)\n", This, p);
324 return E_NOTIMPL;
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)) {
335 case VT_I4: {
336 nsIDOMStyleSheet *nsstylesheet;
337 nsresult nsres;
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;
345 return E_INVALIDARG;
348 V_VT(pvarResult) = VT_DISPATCH;
349 V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
351 return S_OK;
354 case VT_BSTR:
355 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
356 return E_NOTIMPL;
358 default:
359 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
362 return E_INVALIDARG;
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 = {
383 NULL,
384 DispHTMLStyleSheetsCollection_tid,
385 NULL,
386 HTMLStyleSheetsCollection_iface_tids
389 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
391 HTMLStyleSheetsCollection *ret = heap_alloc(sizeof(HTMLStyleSheetsCollection));
393 ret->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
394 ret->ref = 1;
396 if(nslist)
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;
425 }else {
426 *ppv = NULL;
427 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
428 return E_NOINTERFACE;
431 IUnknown_AddRef((IUnknown*)*ppv);
432 return S_OK;
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);
442 return 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);
452 if(!ref) {
453 release_dispex(&This->dispex);
454 if(This->nsstylesheet)
455 nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
456 heap_free(This);
459 return ref;
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));
497 return E_NOTIMPL;
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);
504 return E_NOTIMPL;
507 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
508 IHTMLStyleSheet **p)
510 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
511 FIXME("(%p)->(%p)\n", This, p);
512 return E_NOTIMPL;
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);
519 return E_NOTIMPL;
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);
526 return E_NOTIMPL;
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);
533 return E_NOTIMPL;
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);
540 return E_NOTIMPL;
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);
548 return E_NOTIMPL;
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));
555 return E_NOTIMPL;
558 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
560 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
561 nsAString href_str;
562 nsresult nsres;
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);
575 return E_NOTIMPL;
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);
582 return E_NOTIMPL;
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);
590 return E_NOTIMPL;
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),
598 lIndex, plIndex);
599 return E_NOTIMPL;
602 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
604 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
605 FIXME("(%p)->(%d)\n", This, lIndex);
606 return E_NOTIMPL;
609 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
611 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
612 FIXME("(%p)->(%d)\n", This, lIndex);
613 return E_NOTIMPL;
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));
620 return E_NOTIMPL;
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);
627 return E_NOTIMPL;
630 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
632 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
633 nsresult nsres;
635 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
637 do {
638 nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
639 }while(NS_SUCCEEDED(nsres));
641 if(v && *v) {
642 nsAString nsstr;
643 UINT32 idx;
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));
651 return E_FAIL;
655 return S_OK;
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;
663 nsAString nsstr;
664 UINT32 len;
665 nsresult nsres;
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);
672 return E_FAIL;
675 nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
676 assert(nsres == NS_OK);
678 if(len) {
679 nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
680 if(NS_FAILED(nsres))
681 ERR("Item failed: %08x\n", nsres);
684 nsIDOMCSSRuleList_Release(nslist);
685 if(NS_FAILED(nsres))
686 return E_FAIL;
688 if(!len) {
689 *p = NULL;
690 return S_OK;
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;
704 nsresult nsres;
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);
711 return E_FAIL;
714 *p = HTMLStyleSheetRulesCollection_Create(nslist);
715 return S_OK;
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[] = {
750 IHTMLStyleSheet_tid,
753 static dispex_static_data_t HTMLStyleSheet_dispex = {
754 NULL,
755 DispHTMLStyleSheet_tid,
756 NULL,
757 HTMLStyleSheet_iface_tids
760 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
762 HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet));
763 nsresult nsres;
765 ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
766 ret->ref = 1;
767 ret->nsstylesheet = NULL;
769 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex);
771 if(nsstylesheet) {
772 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
773 (void**)&ret->nsstylesheet);
774 if(NS_FAILED(nsres))
775 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
778 return &ret->IHTMLStyleSheet_iface;