mshtml: Use correct iexplore.exe path in mshtml.inf.
[wine] / dlls / mshtml / htmlstylesheet.c
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
30
31 #include "mshtml_private.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34
35 struct HTMLStyleSheet {
36     const IHTMLStyleSheetVtbl *lpHTMLStyleSheetVtbl;
37
38     LONG ref;
39
40     nsIDOMCSSStyleSheet *nsstylesheet;
41 };
42
43 struct HTMLStyleSheetsCollection {
44     const IHTMLStyleSheetsCollectionVtbl *lpHTMLStyleSheetsCollectionVtbl;
45
46     LONG ref;
47
48     nsIDOMStyleSheetList *nslist;
49 };
50
51 struct HTMLStyleSheetRulesCollection {
52     const IHTMLStyleSheetRulesCollectionVtbl *lpHTMLStyleSheetRulesCollectionVtbl;
53
54     LONG ref;
55
56     nsIDOMCSSRuleList *nslist;
57 };
58
59 #define HTMLSTYLESHEET(x)     ((IHTMLStyleSheet*)                &(x)->lpHTMLStyleSheetVtbl)
60 #define HTMLSTYLESHEETSCOL(x) ((IHTMLStyleSheetsCollection*)     &(x)->lpHTMLStyleSheetsCollectionVtbl)
61 #define HTMLSTYLERULESCOL(x)  ((IHTMLStyleSheetRulesCollection*) &(x)->lpHTMLStyleSheetRulesCollectionVtbl)
62
63 #define HTMLSTYLERULESCOL_THIS(iface) \
64     DEFINE_THIS(HTMLStyleSheetRulesCollection, HTMLStyleSheetRulesCollection, iface)
65
66 static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
67         REFIID riid, void **ppv)
68 {
69     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
70
71     if(IsEqualGUID(&IID_IUnknown, riid)) {
72         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
73         *ppv = HTMLSTYLERULESCOL(This);
74     }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
75         TRACE("(%p)->(IID_IHTMLStyleSheetRulesCollection %p)\n", This, ppv);
76         *ppv = HTMLSTYLERULESCOL(This);
77     }
78
79     if(*ppv) {
80         IUnknown_AddRef((IUnknown*)*ppv);
81         return S_OK;
82     }
83
84     FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
85     return E_NOINTERFACE;
86 }
87
88 static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
89 {
90     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
91     LONG ref = InterlockedIncrement(&This->ref);
92
93     TRACE("(%p) ref=%d\n", This, ref);
94
95     return ref;
96 }
97
98 static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
99 {
100     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
101     LONG ref = InterlockedDecrement(&This->ref);
102
103     TRACE("(%p) ref=%d\n", This, ref);
104
105     if(!ref) {
106         if(This->nslist)
107             nsIDOMCSSRuleList_Release(This->nslist);
108         heap_free(This);
109     }
110
111     return ref;
112 }
113
114 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(
115         IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
116 {
117     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
118     FIXME("(%p)->(%p)\n", This, pctinfo);
119     return E_NOTIMPL;
120 }
121
122 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
123         UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
124 {
125     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
126     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
127     return E_NOTIMPL;
128 }
129
130 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
131         REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
132 {
133     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
134     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
135           lcid, rgDispId);
136     return E_NOTIMPL;
137 }
138
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)
142 {
143     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
144     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
145           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
146     return E_NOTIMPL;
147 }
148
149 static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
150         LONG *p)
151 {
152     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
153     PRUint32 len = 0;
154
155     TRACE("(%p)->(%p)\n", This, p);
156
157     if(This->nslist) {
158         nsresult nsres;
159
160         nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
161         if(NS_FAILED(nsres))
162             ERR("GetLength failed: %08x\n", nsres);
163     }
164
165     *p = len;
166     return S_OK;
167 }
168
169 static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
170         LONG index, IHTMLStyleSheetRule **ppHTMLStyleSheetRule)
171 {
172     HTMLStyleSheetRulesCollection *This = HTMLSTYLERULESCOL_THIS(iface);
173     FIXME("(%p)->(%d %p)\n", This, index, ppHTMLStyleSheetRule);
174     return E_NOTIMPL;
175 }
176
177 #undef HTMLSTYLERULECOL_THIS
178
179 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
180     HTMLStyleSheetRulesCollection_QueryInterface,
181     HTMLStyleSheetRulesCollection_AddRef,
182     HTMLStyleSheetRulesCollection_Release,
183     HTMLStyleSheetRulesCollection_GetTypeInfoCount,
184     HTMLStyleSheetRulesCollection_GetTypeInfo,
185     HTMLStyleSheetRulesCollection_GetIDsOfNames,
186     HTMLStyleSheetRulesCollection_Invoke,
187     HTMLStyleSheetRulesCollection_get_length,
188     HTMLStyleSheetRulesCollection_item
189 };
190
191 static IHTMLStyleSheetRulesCollection *HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList *nslist)
192 {
193     HTMLStyleSheetRulesCollection *ret;
194
195     ret = heap_alloc(sizeof(*ret));
196     ret->lpHTMLStyleSheetRulesCollectionVtbl = &HTMLStyleSheetRulesCollectionVtbl;
197     ret->ref = 1;
198     ret->nslist = nslist;
199
200     if(nslist)
201         nsIDOMCSSRuleList_AddRef(nslist);
202
203     return HTMLSTYLERULESCOL(ret);
204 }
205
206 #define HTMLSTYLESHEETSCOL_THIS(iface) \
207     DEFINE_THIS(HTMLStyleSheetsCollection, HTMLStyleSheetsCollection, iface)
208
209 static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
210          REFIID riid, void **ppv)
211 {
212     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
213
214     *ppv = NULL;
215
216     if(IsEqualGUID(&IID_IUnknown, riid)) {
217         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
218         *ppv = HTMLSTYLESHEETSCOL(This);
219     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
220         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
221         *ppv = HTMLSTYLESHEETSCOL(This);
222     }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
223         TRACE("(%p)->(IID_IHTMLStyleSheetsCollection %p)\n", This, ppv);
224         *ppv = HTMLSTYLESHEETSCOL(This);
225     }
226
227     if(*ppv) {
228         IUnknown_AddRef((IUnknown*)*ppv);
229         return S_OK;
230     }
231
232     WARN("unsupported %s\n", debugstr_guid(riid));
233     return E_NOINTERFACE;
234 }
235
236 static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
237 {
238     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
239     LONG ref = InterlockedIncrement(&This->ref);
240
241     TRACE("(%p) ref=%d\n", This, ref);
242
243     return ref;
244 }
245
246 static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
247 {
248     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
249     LONG ref = InterlockedDecrement(&This->ref);
250
251     TRACE("(%p) ref=%d\n", This, ref);
252
253     if(!ref) {
254         if(This->nslist)
255             nsIDOMStyleSheetList_Release(This->nslist);
256         heap_free(This);
257     }
258
259     return ref;
260 }
261
262 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
263         UINT *pctinfo)
264 {
265     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
266     FIXME("(%p)->(%p)\n", This, pctinfo);
267     return E_NOTIMPL;
268 }
269
270 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
271         UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
272 {
273     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
274     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
275     return E_NOTIMPL;
276 }
277
278 static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
279         REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
280 {
281     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
282     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
283           lcid, rgDispId);
284     return E_NOTIMPL;
285 }
286
287 static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
288         DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
289         VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
290 {
291     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
292     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
293           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
294     return E_NOTIMPL;
295 }
296
297 static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
298         LONG *p)
299 {
300     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
301     PRUint32 len = 0;
302
303     TRACE("(%p)->(%p)\n", This, p);
304
305     if(This->nslist)
306         nsIDOMStyleSheetList_GetLength(This->nslist, &len);
307
308     *p = len;
309     return S_OK;
310 }
311
312 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
313         IUnknown **p)
314 {
315     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
316     FIXME("(%p)->(%p)\n", This, p);
317     return E_NOTIMPL;
318 }
319
320 static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
321         VARIANT *pvarIndex, VARIANT *pvarResult)
322 {
323     HTMLStyleSheetsCollection *This = HTMLSTYLESHEETSCOL_THIS(iface);
324
325     TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
326
327     switch(V_VT(pvarIndex)) {
328     case VT_I4: {
329         nsIDOMStyleSheet *nsstylesheet;
330         nsresult nsres;
331
332         TRACE("index=%d\n", V_I4(pvarIndex));
333
334         nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
335         if(NS_FAILED(nsres) || !nsstylesheet) {
336             WARN("Item failed: %08x\n", nsres);
337             V_VT(pvarResult) = VT_EMPTY;
338             return E_INVALIDARG;
339         }
340
341         V_VT(pvarResult) = VT_DISPATCH;
342         V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
343
344         return S_OK;
345     }
346
347     case VT_BSTR:
348         FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
349         return E_NOTIMPL;
350
351     default:
352         WARN("Invalid vt=%d\n", V_VT(pvarIndex));
353     }
354
355     return E_INVALIDARG;
356 }
357
358 #undef HTMLSTYLESHEETSCOL_THIS
359
360 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
361     HTMLStyleSheetsCollection_QueryInterface,
362     HTMLStyleSheetsCollection_AddRef,
363     HTMLStyleSheetsCollection_Release,
364     HTMLStyleSheetsCollection_GetTypeInfoCount,
365     HTMLStyleSheetsCollection_GetTypeInfo,
366     HTMLStyleSheetsCollection_GetIDsOfNames,
367     HTMLStyleSheetsCollection_Invoke,
368     HTMLStyleSheetsCollection_get_length,
369     HTMLStyleSheetsCollection_get__newEnum,
370     HTMLStyleSheetsCollection_item
371 };
372
373 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
374 {
375     HTMLStyleSheetsCollection *ret = heap_alloc(sizeof(HTMLStyleSheetsCollection));
376
377     ret->lpHTMLStyleSheetsCollectionVtbl = &HTMLStyleSheetsCollectionVtbl;
378     ret->ref = 1;
379
380     if(nslist)
381         nsIDOMStyleSheetList_AddRef(nslist);
382     ret->nslist = nslist;
383
384     return HTMLSTYLESHEETSCOL(ret);
385 }
386
387 #define HTMLSTYLESHEET_THIS(iface) DEFINE_THIS(HTMLStyleSheet, HTMLStyleSheet, iface)
388
389 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
390 {
391     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
392
393     *ppv = NULL;
394
395     if(IsEqualGUID(&IID_IUnknown, riid)) {
396         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
397         *ppv = HTMLSTYLESHEET(This);
398     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
399         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
400         *ppv = HTMLSTYLESHEET(This);
401     }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
402         TRACE("(%p)->(IID_IHTMLStyleSheet %p)\n", This, ppv);
403         *ppv = HTMLSTYLESHEET(This);
404     }
405
406     if(*ppv) {
407         IUnknown_AddRef((IUnknown*)*ppv);
408         return S_OK;
409     }
410
411     WARN("unsupported %s\n", debugstr_guid(riid));
412     return E_NOINTERFACE;
413 }
414
415 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
416 {
417     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
418     LONG ref = InterlockedIncrement(&This->ref);
419
420     TRACE("(%p) ref=%d\n", This, ref);
421
422     return ref;
423 }
424
425 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
426 {
427     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
428     LONG ref = InterlockedDecrement(&This->ref);
429
430     TRACE("(%p) ref=%d\n", This, ref);
431
432     if(!ref)
433         heap_free(This);
434
435     return ref;
436 }
437
438 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
439 {
440     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
441     FIXME("(%p)->(%p)\n", This, pctinfo);
442     return E_NOTIMPL;
443 }
444
445 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
446                                               LCID lcid, ITypeInfo **ppTInfo)
447 {
448     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
449     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
450     return E_NOTIMPL;
451 }
452
453 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
454                                                 LPOLESTR *rgszNames, UINT cNames,
455                                                 LCID lcid, DISPID *rgDispId)
456 {
457     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
458     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
459           lcid, rgDispId);
460     return E_NOTIMPL;
461 }
462
463 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
464                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
465                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
466 {
467     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
468     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
469           lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
470     return E_NOTIMPL;
471 }
472
473 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
474 {
475     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
476     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
477     return E_NOTIMPL;
478 }
479
480 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
481 {
482     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
483     FIXME("(%p)->(%p)\n", This, p);
484     return E_NOTIMPL;
485 }
486
487 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
488                                                           IHTMLStyleSheet **p)
489 {
490     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
491     FIXME("(%p)->(%p)\n", This, p);
492     return E_NOTIMPL;
493 }
494
495 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
496 {
497     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
498     FIXME("(%p)->(%p)\n", This, p);
499     return E_NOTIMPL;
500 }
501
502 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
503 {
504     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
505     FIXME("(%p)->(%x)\n", This, v);
506     return E_NOTIMPL;
507 }
508
509 static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
510 {
511     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
512     FIXME("(%p)->(%p)\n", This, p);
513     return E_NOTIMPL;
514 }
515
516 static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
517 {
518     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
519     FIXME("(%p)->(%p)\n", This, p);
520     return E_NOTIMPL;
521 }
522
523 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
524                                                  IHTMLStyleSheetsCollection **p)
525 {
526     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
527     FIXME("(%p)->(%p)\n", This, p);
528     return E_NOTIMPL;
529 }
530
531 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
532 {
533     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
534     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
535     return E_NOTIMPL;
536 }
537
538 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
539 {
540     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
541     FIXME("(%p)->(%p)\n", This, p);
542     return E_NOTIMPL;
543 }
544
545 static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
546 {
547     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
548     FIXME("(%p)->(%p)\n", This, p);
549     return E_NOTIMPL;
550 }
551
552 static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
553 {
554     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
555     FIXME("(%p)->(%p)\n", This, p);
556     return E_NOTIMPL;
557 }
558
559 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
560                                                LONG lIndex, LONG *plIndex)
561 {
562     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
563     FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
564     return E_NOTIMPL;
565 }
566
567 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
568                                              BSTR bstrStyle, LONG lIndex, LONG *plIndex)
569 {
570     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
571     FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
572           lIndex, plIndex);
573     return E_NOTIMPL;
574 }
575
576 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
577 {
578     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
579     FIXME("(%p)->(%d)\n", This, lIndex);
580     return E_NOTIMPL;
581 }
582
583 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
584 {
585     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
586     FIXME("(%p)->(%d)\n", This, lIndex);
587     return E_NOTIMPL;
588 }
589
590 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
591 {
592     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
593     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
594     return E_NOTIMPL;
595 }
596
597 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
598 {
599     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
600     FIXME("(%p)->(%p)\n", This, p);
601     return E_NOTIMPL;
602 }
603
604 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
605 {
606     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
607     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
608     return E_NOTIMPL;
609 }
610
611 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
612 {
613     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
614     FIXME("(%p)->(%p)\n", This, p);
615     return E_NOTIMPL;
616 }
617
618 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
619                                                IHTMLStyleSheetRulesCollection **p)
620 {
621     HTMLStyleSheet *This = HTMLSTYLESHEET_THIS(iface);
622     nsIDOMCSSRuleList *nslist = NULL;
623     nsresult nsres;
624
625     TRACE("(%p)->(%p)\n", This, p);
626
627     /* Gecko has buggy security checks and GetCssRules will fail. We have a correct
628      * implementation and it will work when the bug will be fixed in Gecko. */
629     nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
630     if(NS_FAILED(nsres))
631         WARN("GetCssRules failed: %08x\n", nsres);
632
633     *p = HTMLStyleSheetRulesCollection_Create(nslist);
634     return S_OK;
635 }
636
637 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
638     HTMLStyleSheet_QueryInterface,
639     HTMLStyleSheet_AddRef,
640     HTMLStyleSheet_Release,
641     HTMLStyleSheet_GetTypeInfoCount,
642     HTMLStyleSheet_GetTypeInfo,
643     HTMLStyleSheet_GetIDsOfNames,
644     HTMLStyleSheet_Invoke,
645     HTMLStyleSheet_put_title,
646     HTMLStyleSheet_get_title,
647     HTMLStyleSheet_get_parentStyleSheet,
648     HTMLStyleSheet_get_owningElement,
649     HTMLStyleSheet_put_disabled,
650     HTMLStyleSheet_get_disabled,
651     HTMLStyleSheet_get_readOnly,
652     HTMLStyleSheet_get_imports,
653     HTMLStyleSheet_put_href,
654     HTMLStyleSheet_get_href,
655     HTMLStyleSheet_get_type,
656     HTMLStyleSheet_get_id,
657     HTMLStyleSheet_addImport,
658     HTMLStyleSheet_addRule,
659     HTMLStyleSheet_removeImport,
660     HTMLStyleSheet_removeRule,
661     HTMLStyleSheet_put_media,
662     HTMLStyleSheet_get_media,
663     HTMLStyleSheet_put_cssText,
664     HTMLStyleSheet_get_cssText,
665     HTMLStyleSheet_get_rules
666 };
667
668 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
669 {
670     HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet));
671     nsresult nsres;
672
673     ret->lpHTMLStyleSheetVtbl = &HTMLStyleSheetVtbl;
674     ret->ref = 1;
675     ret->nsstylesheet = NULL;
676
677     if(nsstylesheet) {
678         nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
679                 (void**)&ret->nsstylesheet);
680         if(NS_FAILED(nsres))
681             ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
682     }
683
684     return HTMLSTYLESHEET(ret);
685 }