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