xinput1_3/tests: Add some HID report tests.
[wine.git] / dlls / mshtml / htmlstylesheet.c
blob4519b06155e866aa2d469a1139a984c76c6236b7
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;
37 IHTMLStyleSheet4 IHTMLStyleSheet4_iface;
39 LONG ref;
41 nsIDOMCSSStyleSheet *nsstylesheet;
44 struct HTMLStyleSheetsCollection {
45 DispatchEx dispex;
46 IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
48 LONG ref;
50 nsIDOMStyleSheetList *nslist;
53 struct HTMLStyleSheetRulesCollection {
54 DispatchEx dispex;
55 IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
57 LONG ref;
59 nsIDOMCSSRuleList *nslist;
62 struct HTMLStyleSheetRule {
63 DispatchEx dispex;
64 IHTMLStyleSheetRule IHTMLStyleSheetRule_iface;
66 LONG ref;
68 nsIDOMCSSRule *nsstylesheetrule;
71 static inline HTMLStyleSheetRule *impl_from_IHTMLStyleSheetRule(IHTMLStyleSheetRule *iface)
73 return CONTAINING_RECORD(iface, HTMLStyleSheetRule, IHTMLStyleSheetRule_iface);
76 static HRESULT WINAPI HTMLStyleSheetRule_QueryInterface(IHTMLStyleSheetRule *iface,
77 REFIID riid, void **ppv)
79 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
81 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
83 if (IsEqualGUID(&IID_IUnknown, riid))
84 *ppv = &This->IHTMLStyleSheetRule_iface;
85 else if (IsEqualGUID(&IID_IHTMLStyleSheetRule, riid))
86 *ppv = &This->IHTMLStyleSheetRule_iface;
87 else if (dispex_query_interface(&This->dispex, riid, ppv))
88 return *ppv ? S_OK : E_NOINTERFACE;
89 else
91 *ppv = NULL;
92 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
93 return E_NOINTERFACE;
96 IUnknown_AddRef((IUnknown *)*ppv);
97 return S_OK;
100 static ULONG WINAPI HTMLStyleSheetRule_AddRef(IHTMLStyleSheetRule *iface)
102 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
103 LONG ref = InterlockedIncrement(&This->ref);
105 TRACE("(%p) ref=%d\n", This, ref);
107 return ref;
110 static ULONG WINAPI HTMLStyleSheetRule_Release(IHTMLStyleSheetRule *iface)
112 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
113 LONG ref = InterlockedDecrement(&This->ref);
115 TRACE("(%p) ref=%d\n", This, ref);
117 if(!ref) {
118 release_dispex(&This->dispex);
119 if(This->nsstylesheetrule)
120 nsIDOMCSSRule_Release(This->nsstylesheetrule);
121 heap_free(This);
124 return ref;
127 static HRESULT WINAPI HTMLStyleSheetRule_GetTypeInfoCount(
128 IHTMLStyleSheetRule *iface, UINT *pctinfo)
130 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
131 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
134 static HRESULT WINAPI HTMLStyleSheetRule_GetTypeInfo(IHTMLStyleSheetRule *iface,
135 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
137 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
138 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
141 static HRESULT WINAPI HTMLStyleSheetRule_GetIDsOfNames(IHTMLStyleSheetRule *iface,
142 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
144 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
145 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
146 lcid, rgDispId);
149 static HRESULT WINAPI HTMLStyleSheetRule_Invoke(IHTMLStyleSheetRule *iface,
150 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
151 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
153 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
154 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
155 pDispParams, pVarResult, pExcepInfo, puArgErr);
158 static HRESULT WINAPI HTMLStyleSheetRule_put_selectorText(IHTMLStyleSheetRule *iface, BSTR v)
160 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
161 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
162 return E_NOTIMPL;
165 static HRESULT WINAPI HTMLStyleSheetRule_get_selectorText(IHTMLStyleSheetRule *iface, BSTR *p)
167 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
168 FIXME("(%p)->(%p)\n", This, p);
169 return E_NOTIMPL;
172 static HRESULT WINAPI HTMLStyleSheetRule_get_style(IHTMLStyleSheetRule *iface, IHTMLRuleStyle **p)
174 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
175 FIXME("(%p)->(%p)\n", This, p);
176 return E_NOTIMPL;
179 static HRESULT WINAPI HTMLStyleSheetRule_get_readOnly(IHTMLStyleSheetRule *iface, VARIANT_BOOL *p)
181 HTMLStyleSheetRule *This = impl_from_IHTMLStyleSheetRule(iface);
182 FIXME("(%p)->(%p)\n", This, p);
183 return E_NOTIMPL;
186 static const IHTMLStyleSheetRuleVtbl HTMLStyleSheetRuleVtbl = {
187 HTMLStyleSheetRule_QueryInterface,
188 HTMLStyleSheetRule_AddRef,
189 HTMLStyleSheetRule_Release,
190 HTMLStyleSheetRule_GetTypeInfoCount,
191 HTMLStyleSheetRule_GetTypeInfo,
192 HTMLStyleSheetRule_GetIDsOfNames,
193 HTMLStyleSheetRule_Invoke,
194 HTMLStyleSheetRule_put_selectorText,
195 HTMLStyleSheetRule_get_selectorText,
196 HTMLStyleSheetRule_get_style,
197 HTMLStyleSheetRule_get_readOnly
200 static const tid_t HTMLStyleSheetRule_iface_tids[] = {
201 IHTMLStyleSheetRule_tid,
204 static dispex_static_data_t HTMLStyleSheetRule_dispex = {
205 NULL,
206 DispHTMLStyleSheetRule_tid,
207 HTMLStyleSheetRule_iface_tids
210 static HRESULT create_style_sheet_rule(nsIDOMCSSRule *nsstylesheetrule, compat_mode_t compat_mode,
211 IHTMLStyleSheetRule **ret)
213 HTMLStyleSheetRule *rule;
214 nsresult nsres;
216 if(!(rule = heap_alloc(sizeof(*rule))))
217 return E_OUTOFMEMORY;
219 rule->IHTMLStyleSheetRule_iface.lpVtbl = &HTMLStyleSheetRuleVtbl;
220 rule->ref = 1;
221 rule->nsstylesheetrule = NULL;
223 init_dispatch(&rule->dispex, (IUnknown *)&rule->IHTMLStyleSheetRule_iface, &HTMLStyleSheetRule_dispex,
224 compat_mode);
226 if (nsstylesheetrule)
228 nsres = nsIDOMCSSRule_QueryInterface(nsstylesheetrule, &IID_nsIDOMCSSRule,
229 (void **)&rule->nsstylesheetrule);
230 if (NS_FAILED(nsres))
231 ERR("Could not get nsIDOMCSSRule interface: %08x\n", nsres);
234 *ret = &rule->IHTMLStyleSheetRule_iface;
235 return S_OK;
238 static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
240 return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface);
243 static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
244 REFIID riid, void **ppv)
246 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
248 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
250 if(IsEqualGUID(&IID_IUnknown, riid)) {
251 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
252 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
253 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
254 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
255 return *ppv ? S_OK : E_NOINTERFACE;
256 }else {
257 *ppv = NULL;
258 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
259 return E_NOINTERFACE;
262 IUnknown_AddRef((IUnknown*)*ppv);
263 return S_OK;
266 static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
268 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
269 LONG ref = InterlockedIncrement(&This->ref);
271 TRACE("(%p) ref=%d\n", This, ref);
273 return ref;
276 static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
278 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
279 LONG ref = InterlockedDecrement(&This->ref);
281 TRACE("(%p) ref=%d\n", This, ref);
283 if(!ref) {
284 release_dispex(&This->dispex);
285 if(This->nslist)
286 nsIDOMCSSRuleList_Release(This->nslist);
287 heap_free(This);
290 return ref;
293 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(
294 IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
296 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
297 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
300 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
301 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
303 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
304 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
307 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
308 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
310 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
311 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
312 lcid, rgDispId);
315 static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface,
316 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
317 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
319 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
320 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
321 pDispParams, pVarResult, pExcepInfo, puArgErr);
324 static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
325 LONG *p)
327 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
328 UINT32 len = 0;
330 TRACE("(%p)->(%p)\n", This, p);
332 if(This->nslist) {
333 nsresult nsres;
335 nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
336 if(NS_FAILED(nsres))
337 ERR("GetLength failed: %08x\n", nsres);
340 *p = len;
341 return S_OK;
344 static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
345 LONG index, IHTMLStyleSheetRule **p)
347 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
348 nsIDOMCSSRule *nsstylesheetrule;
349 nsresult nsres;
351 TRACE("(%p)->(%d %p)\n", This, index, p);
353 nsres = nsIDOMCSSRuleList_Item(This->nslist, index, &nsstylesheetrule);
354 if(NS_FAILED(nsres))
355 return map_nsresult(nsres);
356 if(!nsstylesheetrule)
357 return E_INVALIDARG;
359 return create_style_sheet_rule(nsstylesheetrule, dispex_compat_mode(&This->dispex), p);
362 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
363 HTMLStyleSheetRulesCollection_QueryInterface,
364 HTMLStyleSheetRulesCollection_AddRef,
365 HTMLStyleSheetRulesCollection_Release,
366 HTMLStyleSheetRulesCollection_GetTypeInfoCount,
367 HTMLStyleSheetRulesCollection_GetTypeInfo,
368 HTMLStyleSheetRulesCollection_GetIDsOfNames,
369 HTMLStyleSheetRulesCollection_Invoke,
370 HTMLStyleSheetRulesCollection_get_length,
371 HTMLStyleSheetRulesCollection_item
374 static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = {
375 IHTMLStyleSheetRulesCollection_tid,
378 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = {
379 NULL,
380 DispHTMLStyleSheetRulesCollection_tid,
381 HTMLStyleSheetRulesCollection_iface_tids
384 static HRESULT create_style_sheet_rules_collection(nsIDOMCSSRuleList *nslist, compat_mode_t compat_mode,
385 IHTMLStyleSheetRulesCollection **ret)
387 HTMLStyleSheetRulesCollection *collection;
389 if(!(collection = heap_alloc(sizeof(*collection))))
390 return E_OUTOFMEMORY;
392 collection->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl;
393 collection->ref = 1;
394 collection->nslist = nslist;
396 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetRulesCollection_iface,
397 &HTMLStyleSheetRulesCollection_dispex, compat_mode);
399 if(nslist)
400 nsIDOMCSSRuleList_AddRef(nslist);
402 *ret = &collection->IHTMLStyleSheetRulesCollection_iface;
403 return S_OK;
406 static inline HTMLStyleSheetsCollection *impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface)
408 return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, IHTMLStyleSheetsCollection_iface);
411 static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
412 REFIID riid, void **ppv)
414 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
416 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
418 if(IsEqualGUID(&IID_IUnknown, riid)) {
419 *ppv = &This->IHTMLStyleSheetsCollection_iface;
420 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
421 *ppv = &This->IHTMLStyleSheetsCollection_iface;
422 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
423 *ppv = &This->IHTMLStyleSheetsCollection_iface;
424 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
425 return *ppv ? S_OK : E_NOINTERFACE;
426 }else {
427 *ppv = NULL;
428 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
429 return E_NOINTERFACE;
432 IUnknown_AddRef((IUnknown*)*ppv);
433 return S_OK;
436 static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
438 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
439 LONG ref = InterlockedIncrement(&This->ref);
441 TRACE("(%p) ref=%d\n", This, ref);
443 return ref;
446 static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
448 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
449 LONG ref = InterlockedDecrement(&This->ref);
451 TRACE("(%p) ref=%d\n", This, ref);
453 if(!ref) {
454 release_dispex(&This->dispex);
455 if(This->nslist)
456 nsIDOMStyleSheetList_Release(This->nslist);
457 heap_free(This);
460 return ref;
463 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
464 UINT *pctinfo)
466 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
467 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
470 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
471 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
473 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
474 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
477 static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
478 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
480 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
481 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
482 lcid, rgDispId);
485 static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
486 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
487 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
489 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
490 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
491 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
494 static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
495 LONG *p)
497 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
498 UINT32 len = 0;
500 TRACE("(%p)->(%p)\n", This, p);
502 if(This->nslist)
503 nsIDOMStyleSheetList_GetLength(This->nslist, &len);
505 *p = len;
506 return S_OK;
509 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
510 IUnknown **p)
512 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
513 FIXME("(%p)->(%p)\n", This, p);
514 return E_NOTIMPL;
517 static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
518 VARIANT *pvarIndex, VARIANT *pvarResult)
520 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
522 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarIndex), pvarResult);
524 switch(V_VT(pvarIndex)) {
525 case VT_I4: {
526 nsIDOMStyleSheet *nsstylesheet;
527 IHTMLStyleSheet *stylesheet;
528 nsresult nsres;
529 HRESULT hres;
531 TRACE("index=%d\n", V_I4(pvarIndex));
533 nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
534 if(NS_FAILED(nsres) || !nsstylesheet) {
535 WARN("Item failed: %08x\n", nsres);
536 V_VT(pvarResult) = VT_EMPTY;
537 return E_INVALIDARG;
540 hres = create_style_sheet(nsstylesheet, dispex_compat_mode(&This->dispex), &stylesheet);
541 if(FAILED(hres))
542 return hres;
544 V_VT(pvarResult) = VT_DISPATCH;
545 V_DISPATCH(pvarResult) = (IDispatch*)stylesheet;
546 return S_OK;
549 case VT_BSTR:
550 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
551 return E_NOTIMPL;
553 default:
554 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
557 return E_INVALIDARG;
560 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
561 HTMLStyleSheetsCollection_QueryInterface,
562 HTMLStyleSheetsCollection_AddRef,
563 HTMLStyleSheetsCollection_Release,
564 HTMLStyleSheetsCollection_GetTypeInfoCount,
565 HTMLStyleSheetsCollection_GetTypeInfo,
566 HTMLStyleSheetsCollection_GetIDsOfNames,
567 HTMLStyleSheetsCollection_Invoke,
568 HTMLStyleSheetsCollection_get_length,
569 HTMLStyleSheetsCollection_get__newEnum,
570 HTMLStyleSheetsCollection_item
573 static const tid_t HTMLStyleSheetsCollection_iface_tids[] = {
574 IHTMLStyleSheetsCollection_tid,
577 static dispex_static_data_t HTMLStyleSheetsCollection_dispex = {
578 NULL,
579 DispHTMLStyleSheetsCollection_tid,
580 HTMLStyleSheetsCollection_iface_tids
583 HRESULT create_style_sheet_collection(nsIDOMStyleSheetList *nslist, compat_mode_t compat_mode,
584 IHTMLStyleSheetsCollection **ret)
586 HTMLStyleSheetsCollection *collection;
588 if(!(collection = heap_alloc(sizeof(HTMLStyleSheetsCollection))))
589 return E_OUTOFMEMORY;
591 collection->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
592 collection->ref = 1;
594 if(nslist)
595 nsIDOMStyleSheetList_AddRef(nslist);
596 collection->nslist = nslist;
598 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetsCollection_iface,
599 &HTMLStyleSheetsCollection_dispex, compat_mode);
601 *ret = &collection->IHTMLStyleSheetsCollection_iface;
602 return S_OK;
605 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
607 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface);
610 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
612 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
614 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
616 if(IsEqualGUID(&IID_IUnknown, riid)) {
617 *ppv = &This->IHTMLStyleSheet_iface;
618 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
619 *ppv = &This->IHTMLStyleSheet_iface;
620 }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
621 *ppv = &This->IHTMLStyleSheet_iface;
622 }else if(IsEqualGUID(&IID_IHTMLStyleSheet4, riid)) {
623 *ppv = &This->IHTMLStyleSheet4_iface;
624 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
625 return *ppv ? S_OK : E_NOINTERFACE;
626 }else {
627 *ppv = NULL;
628 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
629 return E_NOINTERFACE;
632 IUnknown_AddRef((IUnknown*)*ppv);
633 return S_OK;
636 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
638 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
639 LONG ref = InterlockedIncrement(&This->ref);
641 TRACE("(%p) ref=%d\n", This, ref);
643 return ref;
646 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
648 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
649 LONG ref = InterlockedDecrement(&This->ref);
651 TRACE("(%p) ref=%d\n", This, ref);
653 if(!ref) {
654 release_dispex(&This->dispex);
655 if(This->nsstylesheet)
656 nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
657 heap_free(This);
660 return ref;
663 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
665 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
666 TRACE("(%p)->(%p)\n", This, pctinfo);
667 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
670 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
671 LCID lcid, ITypeInfo **ppTInfo)
673 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
674 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
677 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
678 LPOLESTR *rgszNames, UINT cNames,
679 LCID lcid, DISPID *rgDispId)
681 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
682 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
685 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
686 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
687 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
689 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
690 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
691 pVarResult, pExcepInfo, puArgErr);
694 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
696 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
697 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
698 return E_NOTIMPL;
701 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
703 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
704 FIXME("(%p)->(%p)\n", This, p);
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
709 IHTMLStyleSheet **p)
711 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
712 FIXME("(%p)->(%p)\n", This, p);
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
718 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
725 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
726 FIXME("(%p)->(%x)\n", This, v);
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
732 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
733 FIXME("(%p)->(%p)\n", This, p);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
739 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
740 FIXME("(%p)->(%p)\n", This, p);
741 return E_NOTIMPL;
744 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
745 IHTMLStyleSheetsCollection **p)
747 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
748 FIXME("(%p)->(%p)\n", This, p);
749 return E_NOTIMPL;
752 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
754 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
755 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
756 return E_NOTIMPL;
759 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
761 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
762 nsAString href_str;
763 nsresult nsres;
765 TRACE("(%p)->(%p)\n", This, p);
767 nsAString_Init(&href_str, NULL);
768 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
769 return return_nsstr(nsres, &href_str, p);
772 static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
774 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
775 FIXME("(%p)->(%p)\n", This, p);
776 return E_NOTIMPL;
779 static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
781 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
782 FIXME("(%p)->(%p)\n", This, p);
783 return E_NOTIMPL;
786 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
787 LONG lIndex, LONG *plIndex)
789 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
790 FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
791 return E_NOTIMPL;
794 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
795 BSTR bstrStyle, LONG lIndex, LONG *plIndex)
797 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
798 FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
799 lIndex, plIndex);
800 return E_NOTIMPL;
803 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
805 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
806 FIXME("(%p)->(%d)\n", This, lIndex);
807 return E_NOTIMPL;
810 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
812 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
813 FIXME("(%p)->(%d)\n", This, lIndex);
814 return E_NOTIMPL;
817 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
819 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
820 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
821 return E_NOTIMPL;
824 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
826 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
827 FIXME("(%p)->(%p)\n", This, p);
828 return E_NOTIMPL;
831 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
833 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
834 nsresult nsres;
836 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
838 do {
839 nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
840 }while(NS_SUCCEEDED(nsres));
842 if(v && *v) {
843 nsAString nsstr;
844 UINT32 idx;
846 /* FIXME: This won't work for multiple rules in the string. */
847 nsAString_InitDepend(&nsstr, v);
848 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx);
849 nsAString_Finish(&nsstr);
850 if(NS_FAILED(nsres)) {
851 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v));
852 return E_FAIL;
856 return S_OK;
859 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
861 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
862 nsIDOMCSSRuleList *nslist = NULL;
863 nsIDOMCSSRule *nsrule;
864 nsAString nsstr;
865 UINT32 len;
866 nsresult nsres;
868 TRACE("(%p)->(%p)\n", This, p);
870 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
871 if(NS_FAILED(nsres)) {
872 ERR("GetCssRules failed: %08x\n", nsres);
873 return E_FAIL;
876 nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
877 assert(nsres == NS_OK);
879 if(len) {
880 nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
881 if(NS_FAILED(nsres))
882 ERR("Item failed: %08x\n", nsres);
885 nsIDOMCSSRuleList_Release(nslist);
886 if(NS_FAILED(nsres))
887 return E_FAIL;
889 if(!len) {
890 *p = NULL;
891 return S_OK;
894 nsAString_Init(&nsstr, NULL);
895 nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr);
896 nsIDOMCSSRule_Release(nsrule);
897 return return_nsstr(nsres, &nsstr, p);
900 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
901 IHTMLStyleSheetRulesCollection **p)
903 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
904 nsIDOMCSSRuleList *nslist = NULL;
905 nsresult nsres;
906 HRESULT hres;
908 TRACE("(%p)->(%p)\n", This, p);
910 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
911 if(NS_FAILED(nsres)) {
912 ERR("GetCssRules failed: %08x\n", nsres);
913 return E_FAIL;
916 hres = create_style_sheet_rules_collection(nslist, dispex_compat_mode(&This->dispex), p);
917 nsIDOMCSSRuleList_Release(nslist);
918 return hres;
921 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
922 HTMLStyleSheet_QueryInterface,
923 HTMLStyleSheet_AddRef,
924 HTMLStyleSheet_Release,
925 HTMLStyleSheet_GetTypeInfoCount,
926 HTMLStyleSheet_GetTypeInfo,
927 HTMLStyleSheet_GetIDsOfNames,
928 HTMLStyleSheet_Invoke,
929 HTMLStyleSheet_put_title,
930 HTMLStyleSheet_get_title,
931 HTMLStyleSheet_get_parentStyleSheet,
932 HTMLStyleSheet_get_owningElement,
933 HTMLStyleSheet_put_disabled,
934 HTMLStyleSheet_get_disabled,
935 HTMLStyleSheet_get_readOnly,
936 HTMLStyleSheet_get_imports,
937 HTMLStyleSheet_put_href,
938 HTMLStyleSheet_get_href,
939 HTMLStyleSheet_get_type,
940 HTMLStyleSheet_get_id,
941 HTMLStyleSheet_addImport,
942 HTMLStyleSheet_addRule,
943 HTMLStyleSheet_removeImport,
944 HTMLStyleSheet_removeRule,
945 HTMLStyleSheet_put_media,
946 HTMLStyleSheet_get_media,
947 HTMLStyleSheet_put_cssText,
948 HTMLStyleSheet_get_cssText,
949 HTMLStyleSheet_get_rules
952 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet4(IHTMLStyleSheet4 *iface)
954 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet4_iface);
957 static HRESULT WINAPI HTMLStyleSheet4_QueryInterface(IHTMLStyleSheet4 *iface, REFIID riid, void **ppv)
959 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
960 return IHTMLStyleSheet_QueryInterface(&This->IHTMLStyleSheet_iface, riid, ppv);
963 static ULONG WINAPI HTMLStyleSheet4_AddRef(IHTMLStyleSheet4 *iface)
965 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
966 return IHTMLStyleSheet_AddRef(&This->IHTMLStyleSheet_iface);
969 static ULONG WINAPI HTMLStyleSheet4_Release(IHTMLStyleSheet4 *iface)
971 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
972 return IHTMLStyleSheet_Release(&This->IHTMLStyleSheet_iface);
975 static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfoCount(IHTMLStyleSheet4 *iface, UINT *pctinfo)
977 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
978 TRACE("(%p)->(%p)\n", This, pctinfo);
979 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
982 static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfo(IHTMLStyleSheet4 *iface, UINT iTInfo,
983 LCID lcid, ITypeInfo **ppTInfo)
985 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
986 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
989 static HRESULT WINAPI HTMLStyleSheet4_GetIDsOfNames(IHTMLStyleSheet4 *iface, REFIID riid,
990 LPOLESTR *rgszNames, UINT cNames,
991 LCID lcid, DISPID *rgDispId)
993 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
994 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
997 static HRESULT WINAPI HTMLStyleSheet4_Invoke(IHTMLStyleSheet4 *iface, DISPID dispIdMember,
998 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
999 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1001 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1002 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
1003 pVarResult, pExcepInfo, puArgErr);
1006 static HRESULT WINAPI HTMLStyleSheet4_get_type(IHTMLStyleSheet4 *iface, BSTR *p)
1008 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1009 TRACE("(%p)->(%p)\n", This, p);
1010 return IHTMLStyleSheet_get_type(&This->IHTMLStyleSheet_iface, p);
1013 static HRESULT WINAPI HTMLStyleSheet4_get_href(IHTMLStyleSheet4 *iface, VARIANT *p)
1015 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1016 nsAString href_str;
1017 nsresult nsres;
1019 TRACE("(%p)->(%p)\n", This, p);
1021 nsAString_Init(&href_str, NULL);
1022 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
1023 return return_nsstr_variant(nsres, &href_str, 0, p);
1026 static HRESULT WINAPI HTMLStyleSheet4_get_title(IHTMLStyleSheet4 *iface, BSTR *p)
1028 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1029 FIXME("(%p)->(%p)\n", This, p);
1030 return E_NOTIMPL;
1033 static HRESULT WINAPI HTMLStyleSheet4_get_ownerNode(IHTMLStyleSheet4 *iface, IHTMLElement **p)
1035 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1036 FIXME("(%p)->(%p)\n", This, p);
1037 return E_NOTIMPL;
1040 static HRESULT WINAPI HTMLStyleSheet4_get_ownerRule(IHTMLStyleSheet4 *iface, IHTMLCSSRule **p)
1042 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1043 FIXME("(%p)->(%p)\n", This, p);
1044 return E_NOTIMPL;
1047 static HRESULT WINAPI HTMLStyleSheet4_get_cssRules(IHTMLStyleSheet4 *iface, IHTMLStyleSheetRulesCollection **p)
1049 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1050 TRACE("(%p)->(%p)\n", This, p);
1051 return IHTMLStyleSheet_get_rules(&This->IHTMLStyleSheet_iface, p);
1054 static HRESULT WINAPI HTMLStyleSheet4_get_media(IHTMLStyleSheet4 *iface, VARIANT *p)
1056 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1057 FIXME("(%p)->(%p)\n", This, p);
1058 return E_NOTIMPL;
1061 static HRESULT WINAPI HTMLStyleSheet4_insertRule(IHTMLStyleSheet4 *iface, BSTR rule, LONG index, LONG *p)
1063 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1064 UINT32 new_index = 0;
1065 nsAString nsstr;
1066 nsresult nsres;
1068 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(rule), index, p);
1070 nsAString_InitDepend(&nsstr, rule);
1071 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, index, &new_index);
1072 if(NS_FAILED(nsres)) WARN("failed: %08x\n", nsres);
1073 nsAString_Finish(&nsstr);
1074 *p = new_index;
1075 return map_nsresult(nsres);
1078 static HRESULT WINAPI HTMLStyleSheet4_deleteRule(IHTMLStyleSheet4 *iface, LONG index)
1080 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1081 FIXME("(%p)->(%d)\n", This, index);
1082 return E_NOTIMPL;
1085 static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl = {
1086 HTMLStyleSheet4_QueryInterface,
1087 HTMLStyleSheet4_AddRef,
1088 HTMLStyleSheet4_Release,
1089 HTMLStyleSheet4_GetTypeInfoCount,
1090 HTMLStyleSheet4_GetTypeInfo,
1091 HTMLStyleSheet4_GetIDsOfNames,
1092 HTMLStyleSheet4_Invoke,
1093 HTMLStyleSheet4_get_type,
1094 HTMLStyleSheet4_get_href,
1095 HTMLStyleSheet4_get_title,
1096 HTMLStyleSheet4_get_ownerNode,
1097 HTMLStyleSheet4_get_ownerRule,
1098 HTMLStyleSheet4_get_cssRules,
1099 HTMLStyleSheet4_get_media,
1100 HTMLStyleSheet4_insertRule,
1101 HTMLStyleSheet4_deleteRule,
1104 static void HTMLStyleSheet_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
1106 if(mode >= COMPAT_MODE_IE9)
1107 dispex_info_add_interface(info, IHTMLStyleSheet4_tid, NULL);
1110 static const tid_t HTMLStyleSheet_iface_tids[] = {
1111 IHTMLStyleSheet_tid,
1114 static dispex_static_data_t HTMLStyleSheet_dispex = {
1115 NULL,
1116 DispHTMLStyleSheet_tid,
1117 HTMLStyleSheet_iface_tids,
1118 HTMLStyleSheet_init_dispex_info
1121 HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_mode, IHTMLStyleSheet **ret)
1123 HTMLStyleSheet *style_sheet;
1124 nsresult nsres;
1126 if(!(style_sheet = heap_alloc(sizeof(HTMLStyleSheet))))
1127 return E_OUTOFMEMORY;
1129 style_sheet->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
1130 style_sheet->IHTMLStyleSheet4_iface.lpVtbl = &HTMLStyleSheet4Vtbl;
1131 style_sheet->ref = 1;
1132 style_sheet->nsstylesheet = NULL;
1134 init_dispatch(&style_sheet->dispex, (IUnknown*)&style_sheet->IHTMLStyleSheet_iface,
1135 &HTMLStyleSheet_dispex, compat_mode);
1137 if(nsstylesheet) {
1138 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
1139 (void**)&style_sheet->nsstylesheet);
1140 if(NS_FAILED(nsres))
1141 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
1144 *ret = &style_sheet->IHTMLStyleSheet_iface;
1145 return S_OK;