gphoto2.ds: Set supported groups.
[wine.git] / dlls / mshtml / htmlstylesheet.c
blobb0e024cfed5d5cb1c00b07855a34c8a22d363e1f
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 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;
204 ret->ref = 1;
205 ret->nslist = nslist;
207 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetRulesCollection_iface, &HTMLStyleSheetRulesCollection_dispex);
209 if(nslist)
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;
235 }else {
236 *ppv = NULL;
237 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
238 return E_NOINTERFACE;
241 IUnknown_AddRef((IUnknown*)*ppv);
242 return S_OK;
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);
252 return 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);
262 if(!ref) {
263 release_dispex(&This->dispex);
264 if(This->nslist)
265 nsIDOMStyleSheetList_Release(This->nslist);
266 heap_free(This);
269 return ref;
272 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
273 UINT *pctinfo)
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,
291 lcid, rgDispId);
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,
304 LONG *p)
306 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
307 UINT32 len = 0;
309 TRACE("(%p)->(%p)\n", This, p);
311 if(This->nslist)
312 nsIDOMStyleSheetList_GetLength(This->nslist, &len);
314 *p = len;
315 return S_OK;
318 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
319 IUnknown **p)
321 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
322 FIXME("(%p)->(%p)\n", This, p);
323 return E_NOTIMPL;
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)) {
334 case VT_I4: {
335 nsIDOMStyleSheet *nsstylesheet;
336 nsresult nsres;
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;
344 return E_INVALIDARG;
347 V_VT(pvarResult) = VT_DISPATCH;
348 V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
350 return S_OK;
353 case VT_BSTR:
354 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
355 return E_NOTIMPL;
357 default:
358 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
361 return E_INVALIDARG;
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 = {
382 NULL,
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;
392 ret->ref = 1;
394 if(nslist)
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;
423 }else {
424 *ppv = NULL;
425 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
426 return E_NOINTERFACE;
429 IUnknown_AddRef((IUnknown*)*ppv);
430 return S_OK;
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);
440 return 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);
450 if(!ref) {
451 release_dispex(&This->dispex);
452 if(This->nsstylesheet)
453 nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
454 heap_free(This);
457 return ref;
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));
495 return E_NOTIMPL;
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);
502 return E_NOTIMPL;
505 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
506 IHTMLStyleSheet **p)
508 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
509 FIXME("(%p)->(%p)\n", This, p);
510 return E_NOTIMPL;
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);
517 return E_NOTIMPL;
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);
524 return E_NOTIMPL;
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);
531 return E_NOTIMPL;
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);
538 return E_NOTIMPL;
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);
546 return E_NOTIMPL;
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));
553 return E_NOTIMPL;
556 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
558 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
559 nsAString href_str;
560 nsresult nsres;
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);
573 return E_NOTIMPL;
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);
580 return E_NOTIMPL;
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);
588 return E_NOTIMPL;
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),
596 lIndex, plIndex);
597 return E_NOTIMPL;
600 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
602 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
603 FIXME("(%p)->(%d)\n", This, lIndex);
604 return E_NOTIMPL;
607 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
609 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
610 FIXME("(%p)->(%d)\n", This, lIndex);
611 return E_NOTIMPL;
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));
618 return E_NOTIMPL;
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);
625 return E_NOTIMPL;
628 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
630 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
631 nsresult nsres;
633 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
635 do {
636 nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
637 }while(NS_SUCCEEDED(nsres));
639 if(v && *v) {
640 nsAString nsstr;
641 UINT32 idx;
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));
649 return E_FAIL;
653 return S_OK;
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;
661 nsAString nsstr;
662 UINT32 len;
663 nsresult nsres;
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);
670 return E_FAIL;
673 nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
674 assert(nsres == NS_OK);
676 if(len) {
677 nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
678 if(NS_FAILED(nsres))
679 ERR("Item failed: %08x\n", nsres);
682 nsIDOMCSSRuleList_Release(nslist);
683 if(NS_FAILED(nsres))
684 return E_FAIL;
686 if(!len) {
687 *p = NULL;
688 return S_OK;
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;
702 nsresult nsres;
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);
709 return E_FAIL;
712 *p = HTMLStyleSheetRulesCollection_Create(nslist);
713 return S_OK;
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[] = {
748 IHTMLStyleSheet_tid,
751 static dispex_static_data_t HTMLStyleSheet_dispex = {
752 NULL,
753 DispHTMLStyleSheet_tid,
754 HTMLStyleSheet_iface_tids
757 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
759 HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet));
760 nsresult nsres;
762 ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
763 ret->ref = 1;
764 ret->nsstylesheet = NULL;
766 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex);
768 if(nsstylesheet) {
769 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
770 (void**)&ret->nsstylesheet);
771 if(NS_FAILED(nsres))
772 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
775 return &ret->IHTMLStyleSheet_iface;