dpnet/tests: Add a trailing '\n' to some ok() calls.
[wine.git] / dlls / mshtml / htmlstylesheet.c
blob8f48a07357d6494de64b0d8693105bfbad453164
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>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 struct HTMLStyleSheet {
35 DispatchEx dispex;
36 IHTMLStyleSheet IHTMLStyleSheet_iface;
38 LONG ref;
40 nsIDOMCSSStyleSheet *nsstylesheet;
43 struct HTMLStyleSheetsCollection {
44 DispatchEx dispex;
45 IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
47 LONG ref;
49 nsIDOMStyleSheetList *nslist;
52 struct HTMLStyleSheetRulesCollection {
53 DispatchEx dispex;
54 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
56 LONG ref;
58 nsIDOMCSSRuleList *nslist;
61 static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
63 return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface);
66 static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
67 REFIID riid, void **ppv)
69 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
71 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
73 if(IsEqualGUID(&IID_IUnknown, riid)) {
74 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
75 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
76 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
77 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
78 return *ppv ? S_OK : E_NOINTERFACE;
79 }else {
80 *ppv = NULL;
81 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
82 return E_NOINTERFACE;
85 IUnknown_AddRef((IUnknown*)*ppv);
86 return S_OK;
89 static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
91 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
92 LONG ref = InterlockedIncrement(&This->ref);
94 TRACE("(%p) ref=%d\n", This, ref);
96 return ref;
99 static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
101 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
102 LONG ref = InterlockedDecrement(&This->ref);
104 TRACE("(%p) ref=%d\n", This, ref);
106 if(!ref) {
107 release_dispex(&This->dispex);
108 if(This->nslist)
109 nsIDOMCSSRuleList_Release(This->nslist);
110 heap_free(This);
113 return ref;
116 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(
117 IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
119 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
120 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
123 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
124 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
126 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
127 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
130 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
131 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
133 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
134 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
135 lcid, rgDispId);
138 static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface,
139 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
140 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
142 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
143 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
144 pDispParams, pVarResult, pExcepInfo, puArgErr);
147 static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
148 LONG *p)
150 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
151 UINT32 len = 0;
153 TRACE("(%p)->(%p)\n", This, p);
155 if(This->nslist) {
156 nsresult nsres;
158 nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
159 if(NS_FAILED(nsres))
160 ERR("GetLength failed: %08x\n", nsres);
163 *p = len;
164 return S_OK;
167 static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
168 LONG index, IHTMLStyleSheetRule **ppHTMLStyleSheetRule)
170 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
171 FIXME("(%p)->(%d %p)\n", This, index, ppHTMLStyleSheetRule);
172 return E_NOTIMPL;
175 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
176 HTMLStyleSheetRulesCollection_QueryInterface,
177 HTMLStyleSheetRulesCollection_AddRef,
178 HTMLStyleSheetRulesCollection_Release,
179 HTMLStyleSheetRulesCollection_GetTypeInfoCount,
180 HTMLStyleSheetRulesCollection_GetTypeInfo,
181 HTMLStyleSheetRulesCollection_GetIDsOfNames,
182 HTMLStyleSheetRulesCollection_Invoke,
183 HTMLStyleSheetRulesCollection_get_length,
184 HTMLStyleSheetRulesCollection_item
187 static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = {
188 IHTMLStyleSheetRulesCollection_tid,
191 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = {
192 NULL,
193 DispHTMLStyleSheetRulesCollection_tid,
194 NULL,
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 NULL,
385 HTMLStyleSheetsCollection_iface_tids
388 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
390 HTMLStyleSheetsCollection *ret = heap_alloc(sizeof(HTMLStyleSheetsCollection));
392 ret->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
393 ret->ref = 1;
395 if(nslist)
396 nsIDOMStyleSheetList_AddRef(nslist);
397 ret->nslist = nslist;
399 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetsCollection_iface,
400 &HTMLStyleSheetsCollection_dispex);
402 return &ret->IHTMLStyleSheetsCollection_iface;
405 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
407 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface);
410 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
412 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
414 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
416 if(IsEqualGUID(&IID_IUnknown, riid)) {
417 *ppv = &This->IHTMLStyleSheet_iface;
418 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
419 *ppv = &This->IHTMLStyleSheet_iface;
420 }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
421 *ppv = &This->IHTMLStyleSheet_iface;
422 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
423 return *ppv ? S_OK : E_NOINTERFACE;
424 }else {
425 *ppv = NULL;
426 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
427 return E_NOINTERFACE;
430 IUnknown_AddRef((IUnknown*)*ppv);
431 return S_OK;
434 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
436 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
437 LONG ref = InterlockedIncrement(&This->ref);
439 TRACE("(%p) ref=%d\n", This, ref);
441 return ref;
444 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
446 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
447 LONG ref = InterlockedDecrement(&This->ref);
449 TRACE("(%p) ref=%d\n", This, ref);
451 if(!ref) {
452 release_dispex(&This->dispex);
453 if(This->nsstylesheet)
454 nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
455 heap_free(This);
458 return ref;
461 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
463 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
464 TRACE("(%p)->(%p)\n", This, pctinfo);
465 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
468 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
469 LCID lcid, ITypeInfo **ppTInfo)
471 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
472 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
475 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
476 LPOLESTR *rgszNames, UINT cNames,
477 LCID lcid, DISPID *rgDispId)
479 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
480 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
483 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
484 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
485 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
487 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
488 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
489 pVarResult, pExcepInfo, puArgErr);
492 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
494 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
495 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
496 return E_NOTIMPL;
499 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
501 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
502 FIXME("(%p)->(%p)\n", This, p);
503 return E_NOTIMPL;
506 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
507 IHTMLStyleSheet **p)
509 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
510 FIXME("(%p)->(%p)\n", This, p);
511 return E_NOTIMPL;
514 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
516 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
517 FIXME("(%p)->(%p)\n", This, p);
518 return E_NOTIMPL;
521 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
523 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
524 FIXME("(%p)->(%x)\n", This, v);
525 return E_NOTIMPL;
528 static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
530 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
531 FIXME("(%p)->(%p)\n", This, p);
532 return E_NOTIMPL;
535 static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
537 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
538 FIXME("(%p)->(%p)\n", This, p);
539 return E_NOTIMPL;
542 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
543 IHTMLStyleSheetsCollection **p)
545 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
546 FIXME("(%p)->(%p)\n", This, p);
547 return E_NOTIMPL;
550 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
552 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
553 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
554 return E_NOTIMPL;
557 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
559 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
560 nsAString href_str;
561 nsresult nsres;
563 TRACE("(%p)->(%p)\n", This, p);
565 nsAString_Init(&href_str, NULL);
566 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
567 return return_nsstr(nsres, &href_str, p);
570 static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
572 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
573 FIXME("(%p)->(%p)\n", This, p);
574 return E_NOTIMPL;
577 static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
579 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
580 FIXME("(%p)->(%p)\n", This, p);
581 return E_NOTIMPL;
584 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
585 LONG lIndex, LONG *plIndex)
587 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
588 FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
589 return E_NOTIMPL;
592 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
593 BSTR bstrStyle, LONG lIndex, LONG *plIndex)
595 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
596 FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
597 lIndex, plIndex);
598 return E_NOTIMPL;
601 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
603 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
604 FIXME("(%p)->(%d)\n", This, lIndex);
605 return E_NOTIMPL;
608 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
610 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
611 FIXME("(%p)->(%d)\n", This, lIndex);
612 return E_NOTIMPL;
615 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
617 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
618 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
619 return E_NOTIMPL;
622 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
624 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
625 FIXME("(%p)->(%p)\n", This, p);
626 return E_NOTIMPL;
629 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
631 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
632 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
633 return E_NOTIMPL;
636 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
638 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
639 FIXME("(%p)->(%p)\n", This, p);
640 return E_NOTIMPL;
643 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
644 IHTMLStyleSheetRulesCollection **p)
646 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
647 nsIDOMCSSRuleList *nslist = NULL;
648 nsresult nsres;
650 TRACE("(%p)->(%p)\n", This, p);
652 /* Gecko has buggy security checks and GetCssRules will fail. We have a correct
653 * implementation and it will work when the bug will be fixed in Gecko. */
654 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
655 if(NS_FAILED(nsres))
656 WARN("GetCssRules failed: %08x\n", nsres);
658 *p = HTMLStyleSheetRulesCollection_Create(nslist);
659 return S_OK;
662 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
663 HTMLStyleSheet_QueryInterface,
664 HTMLStyleSheet_AddRef,
665 HTMLStyleSheet_Release,
666 HTMLStyleSheet_GetTypeInfoCount,
667 HTMLStyleSheet_GetTypeInfo,
668 HTMLStyleSheet_GetIDsOfNames,
669 HTMLStyleSheet_Invoke,
670 HTMLStyleSheet_put_title,
671 HTMLStyleSheet_get_title,
672 HTMLStyleSheet_get_parentStyleSheet,
673 HTMLStyleSheet_get_owningElement,
674 HTMLStyleSheet_put_disabled,
675 HTMLStyleSheet_get_disabled,
676 HTMLStyleSheet_get_readOnly,
677 HTMLStyleSheet_get_imports,
678 HTMLStyleSheet_put_href,
679 HTMLStyleSheet_get_href,
680 HTMLStyleSheet_get_type,
681 HTMLStyleSheet_get_id,
682 HTMLStyleSheet_addImport,
683 HTMLStyleSheet_addRule,
684 HTMLStyleSheet_removeImport,
685 HTMLStyleSheet_removeRule,
686 HTMLStyleSheet_put_media,
687 HTMLStyleSheet_get_media,
688 HTMLStyleSheet_put_cssText,
689 HTMLStyleSheet_get_cssText,
690 HTMLStyleSheet_get_rules
693 static const tid_t HTMLStyleSheet_iface_tids[] = {
694 IHTMLStyleSheet_tid,
697 static dispex_static_data_t HTMLStyleSheet_dispex = {
698 NULL,
699 DispHTMLStyleSheet_tid,
700 NULL,
701 HTMLStyleSheet_iface_tids
704 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
706 HTMLStyleSheet *ret = heap_alloc(sizeof(HTMLStyleSheet));
707 nsresult nsres;
709 ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
710 ret->ref = 1;
711 ret->nsstylesheet = NULL;
713 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex);
715 if(nsstylesheet) {
716 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
717 (void**)&ret->nsstylesheet);
718 if(NS_FAILED(nsres))
719 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
722 return &ret->IHTMLStyleSheet_iface;