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