dbghelp/dwarf: Don't unmap the fmap of a DWZ module twice.
[wine.git] / dlls / mshtml / htmlstylesheet.c
blobc31c7809f631e5a871ec777acb8669140393f557
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 L"CSSStyleRule",
206 NULL,
207 DispHTMLStyleSheetRule_tid,
208 HTMLStyleSheetRule_iface_tids
211 static HRESULT create_style_sheet_rule(nsIDOMCSSRule *nsstylesheetrule, compat_mode_t compat_mode,
212 IHTMLStyleSheetRule **ret)
214 HTMLStyleSheetRule *rule;
215 nsresult nsres;
217 if(!(rule = heap_alloc(sizeof(*rule))))
218 return E_OUTOFMEMORY;
220 rule->IHTMLStyleSheetRule_iface.lpVtbl = &HTMLStyleSheetRuleVtbl;
221 rule->ref = 1;
222 rule->nsstylesheetrule = NULL;
224 init_dispatch(&rule->dispex, (IUnknown *)&rule->IHTMLStyleSheetRule_iface, &HTMLStyleSheetRule_dispex,
225 compat_mode);
227 if (nsstylesheetrule)
229 nsres = nsIDOMCSSRule_QueryInterface(nsstylesheetrule, &IID_nsIDOMCSSRule,
230 (void **)&rule->nsstylesheetrule);
231 if (NS_FAILED(nsres))
232 ERR("Could not get nsIDOMCSSRule interface: %08x\n", nsres);
235 *ret = &rule->IHTMLStyleSheetRule_iface;
236 return S_OK;
239 static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
241 return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface);
244 static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
245 REFIID riid, void **ppv)
247 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
249 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
251 if(IsEqualGUID(&IID_IUnknown, riid)) {
252 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
253 }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
254 *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
255 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
256 return *ppv ? S_OK : E_NOINTERFACE;
257 }else {
258 *ppv = NULL;
259 FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
260 return E_NOINTERFACE;
263 IUnknown_AddRef((IUnknown*)*ppv);
264 return S_OK;
267 static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
269 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
270 LONG ref = InterlockedIncrement(&This->ref);
272 TRACE("(%p) ref=%d\n", This, ref);
274 return ref;
277 static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
279 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
280 LONG ref = InterlockedDecrement(&This->ref);
282 TRACE("(%p) ref=%d\n", This, ref);
284 if(!ref) {
285 release_dispex(&This->dispex);
286 if(This->nslist)
287 nsIDOMCSSRuleList_Release(This->nslist);
288 heap_free(This);
291 return ref;
294 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(
295 IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
297 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
298 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
301 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
302 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
304 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
305 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
308 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
309 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
311 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
312 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
313 lcid, rgDispId);
316 static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface,
317 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
318 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
320 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
321 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
322 pDispParams, pVarResult, pExcepInfo, puArgErr);
325 static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
326 LONG *p)
328 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
329 UINT32 len = 0;
331 TRACE("(%p)->(%p)\n", This, p);
333 if(This->nslist) {
334 nsresult nsres;
336 nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
337 if(NS_FAILED(nsres))
338 ERR("GetLength failed: %08x\n", nsres);
341 *p = len;
342 return S_OK;
345 static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
346 LONG index, IHTMLStyleSheetRule **p)
348 HTMLStyleSheetRulesCollection *This = impl_from_IHTMLStyleSheetRulesCollection(iface);
349 nsIDOMCSSRule *nsstylesheetrule;
350 nsresult nsres;
351 HRESULT hres;
353 TRACE("(%p)->(%d %p)\n", This, index, p);
355 nsres = nsIDOMCSSRuleList_Item(This->nslist, index, &nsstylesheetrule);
356 if(NS_FAILED(nsres))
357 return map_nsresult(nsres);
358 if(!nsstylesheetrule)
359 return E_INVALIDARG;
361 hres = create_style_sheet_rule(nsstylesheetrule, dispex_compat_mode(&This->dispex), p);
362 nsIDOMCSSRule_Release(nsstylesheetrule);
363 return hres;
366 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
367 HTMLStyleSheetRulesCollection_QueryInterface,
368 HTMLStyleSheetRulesCollection_AddRef,
369 HTMLStyleSheetRulesCollection_Release,
370 HTMLStyleSheetRulesCollection_GetTypeInfoCount,
371 HTMLStyleSheetRulesCollection_GetTypeInfo,
372 HTMLStyleSheetRulesCollection_GetIDsOfNames,
373 HTMLStyleSheetRulesCollection_Invoke,
374 HTMLStyleSheetRulesCollection_get_length,
375 HTMLStyleSheetRulesCollection_item
378 static const tid_t HTMLStyleSheetRulesCollection_iface_tids[] = {
379 IHTMLStyleSheetRulesCollection_tid,
382 static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex = {
383 L"MSCSSRuleList",
384 NULL,
385 DispHTMLStyleSheetRulesCollection_tid,
386 HTMLStyleSheetRulesCollection_iface_tids
389 static HRESULT create_style_sheet_rules_collection(nsIDOMCSSRuleList *nslist, compat_mode_t compat_mode,
390 IHTMLStyleSheetRulesCollection **ret)
392 HTMLStyleSheetRulesCollection *collection;
394 if(!(collection = heap_alloc(sizeof(*collection))))
395 return E_OUTOFMEMORY;
397 collection->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl;
398 collection->ref = 1;
399 collection->nslist = nslist;
401 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetRulesCollection_iface,
402 &HTMLStyleSheetRulesCollection_dispex, compat_mode);
404 if(nslist)
405 nsIDOMCSSRuleList_AddRef(nslist);
407 *ret = &collection->IHTMLStyleSheetRulesCollection_iface;
408 return S_OK;
411 static inline HTMLStyleSheetsCollection *impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface)
413 return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, IHTMLStyleSheetsCollection_iface);
416 static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
417 REFIID riid, void **ppv)
419 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
421 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
423 if(IsEqualGUID(&IID_IUnknown, riid)) {
424 *ppv = &This->IHTMLStyleSheetsCollection_iface;
425 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
426 *ppv = &This->IHTMLStyleSheetsCollection_iface;
427 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
428 *ppv = &This->IHTMLStyleSheetsCollection_iface;
429 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
430 return *ppv ? S_OK : E_NOINTERFACE;
431 }else {
432 *ppv = NULL;
433 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
434 return E_NOINTERFACE;
437 IUnknown_AddRef((IUnknown*)*ppv);
438 return S_OK;
441 static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
443 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
444 LONG ref = InterlockedIncrement(&This->ref);
446 TRACE("(%p) ref=%d\n", This, ref);
448 return ref;
451 static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
453 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
454 LONG ref = InterlockedDecrement(&This->ref);
456 TRACE("(%p) ref=%d\n", This, ref);
458 if(!ref) {
459 release_dispex(&This->dispex);
460 if(This->nslist)
461 nsIDOMStyleSheetList_Release(This->nslist);
462 heap_free(This);
465 return ref;
468 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
469 UINT *pctinfo)
471 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
472 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
475 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
476 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
478 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
479 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
482 static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
483 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
485 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
486 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
487 lcid, rgDispId);
490 static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
491 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
492 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
494 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
495 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
496 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
499 static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
500 LONG *p)
502 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
503 UINT32 len = 0;
505 TRACE("(%p)->(%p)\n", This, p);
507 if(This->nslist)
508 nsIDOMStyleSheetList_GetLength(This->nslist, &len);
510 *p = len;
511 return S_OK;
514 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
515 IUnknown **p)
517 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
518 FIXME("(%p)->(%p)\n", This, p);
519 return E_NOTIMPL;
522 static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
523 VARIANT *pvarIndex, VARIANT *pvarResult)
525 HTMLStyleSheetsCollection *This = impl_from_IHTMLStyleSheetsCollection(iface);
527 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarIndex), pvarResult);
529 switch(V_VT(pvarIndex)) {
530 case VT_I4: {
531 nsIDOMStyleSheet *nsstylesheet;
532 IHTMLStyleSheet *stylesheet;
533 nsresult nsres;
534 HRESULT hres;
536 TRACE("index=%d\n", V_I4(pvarIndex));
538 nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
539 if(NS_FAILED(nsres) || !nsstylesheet) {
540 WARN("Item failed: %08x\n", nsres);
541 V_VT(pvarResult) = VT_EMPTY;
542 return E_INVALIDARG;
545 hres = create_style_sheet(nsstylesheet, dispex_compat_mode(&This->dispex), &stylesheet);
546 nsIDOMStyleSheet_Release(nsstylesheet);
547 if(FAILED(hres))
548 return hres;
550 V_VT(pvarResult) = VT_DISPATCH;
551 V_DISPATCH(pvarResult) = (IDispatch*)stylesheet;
552 return S_OK;
555 case VT_BSTR:
556 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
557 return E_NOTIMPL;
559 default:
560 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
563 return E_INVALIDARG;
566 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
567 HTMLStyleSheetsCollection_QueryInterface,
568 HTMLStyleSheetsCollection_AddRef,
569 HTMLStyleSheetsCollection_Release,
570 HTMLStyleSheetsCollection_GetTypeInfoCount,
571 HTMLStyleSheetsCollection_GetTypeInfo,
572 HTMLStyleSheetsCollection_GetIDsOfNames,
573 HTMLStyleSheetsCollection_Invoke,
574 HTMLStyleSheetsCollection_get_length,
575 HTMLStyleSheetsCollection_get__newEnum,
576 HTMLStyleSheetsCollection_item
579 static const tid_t HTMLStyleSheetsCollection_iface_tids[] = {
580 IHTMLStyleSheetsCollection_tid,
583 static dispex_static_data_t HTMLStyleSheetsCollection_dispex = {
584 L"StyleSheetList",
585 NULL,
586 DispHTMLStyleSheetsCollection_tid,
587 HTMLStyleSheetsCollection_iface_tids
590 HRESULT create_style_sheet_collection(nsIDOMStyleSheetList *nslist, compat_mode_t compat_mode,
591 IHTMLStyleSheetsCollection **ret)
593 HTMLStyleSheetsCollection *collection;
595 if(!(collection = heap_alloc(sizeof(HTMLStyleSheetsCollection))))
596 return E_OUTOFMEMORY;
598 collection->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
599 collection->ref = 1;
601 if(nslist)
602 nsIDOMStyleSheetList_AddRef(nslist);
603 collection->nslist = nslist;
605 init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLStyleSheetsCollection_iface,
606 &HTMLStyleSheetsCollection_dispex, compat_mode);
608 *ret = &collection->IHTMLStyleSheetsCollection_iface;
609 return S_OK;
612 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
614 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface);
617 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
619 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
621 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
623 if(IsEqualGUID(&IID_IUnknown, riid)) {
624 *ppv = &This->IHTMLStyleSheet_iface;
625 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
626 *ppv = &This->IHTMLStyleSheet_iface;
627 }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
628 *ppv = &This->IHTMLStyleSheet_iface;
629 }else if(IsEqualGUID(&IID_IHTMLStyleSheet4, riid)) {
630 *ppv = &This->IHTMLStyleSheet4_iface;
631 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
632 return *ppv ? S_OK : E_NOINTERFACE;
633 }else {
634 *ppv = NULL;
635 WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
636 return E_NOINTERFACE;
639 IUnknown_AddRef((IUnknown*)*ppv);
640 return S_OK;
643 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
645 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
646 LONG ref = InterlockedIncrement(&This->ref);
648 TRACE("(%p) ref=%d\n", This, ref);
650 return ref;
653 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
655 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
656 LONG ref = InterlockedDecrement(&This->ref);
658 TRACE("(%p) ref=%d\n", This, ref);
660 if(!ref) {
661 release_dispex(&This->dispex);
662 if(This->nsstylesheet)
663 nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
664 heap_free(This);
667 return ref;
670 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
672 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
673 TRACE("(%p)->(%p)\n", This, pctinfo);
674 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
677 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
678 LCID lcid, ITypeInfo **ppTInfo)
680 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
681 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
684 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
685 LPOLESTR *rgszNames, UINT cNames,
686 LCID lcid, DISPID *rgDispId)
688 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
689 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
692 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
693 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
694 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
696 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
697 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
698 pVarResult, pExcepInfo, puArgErr);
701 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
703 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
704 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
705 return E_NOTIMPL;
708 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
710 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
711 FIXME("(%p)->(%p)\n", This, p);
712 return E_NOTIMPL;
715 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
716 IHTMLStyleSheet **p)
718 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
725 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
726 FIXME("(%p)->(%p)\n", This, p);
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
732 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
733 FIXME("(%p)->(%x)\n", This, v);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLStyleSheet_get_disabled(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_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
746 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
747 FIXME("(%p)->(%p)\n", This, p);
748 return E_NOTIMPL;
751 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
752 IHTMLStyleSheetsCollection **p)
754 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
755 FIXME("(%p)->(%p)\n", This, p);
756 return E_NOTIMPL;
759 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
761 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
762 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
763 return E_NOTIMPL;
766 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
768 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
769 nsAString href_str;
770 nsresult nsres;
772 TRACE("(%p)->(%p)\n", This, p);
774 nsAString_Init(&href_str, NULL);
775 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
776 return return_nsstr(nsres, &href_str, p);
779 static HRESULT WINAPI HTMLStyleSheet_get_type(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_get_id(IHTMLStyleSheet *iface, BSTR *p)
788 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
789 FIXME("(%p)->(%p)\n", This, p);
790 return E_NOTIMPL;
793 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
794 LONG lIndex, LONG *plIndex)
796 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
797 FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
798 return E_NOTIMPL;
801 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
802 BSTR bstrStyle, LONG lIndex, LONG *plIndex)
804 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
805 const WCHAR format[] = L"%s {%s}";
806 nsIDOMCSSRuleList *nslist = NULL;
807 UINT32 length, new_index;
808 nsAString nsstr;
809 nsresult nsres;
810 WCHAR *rule;
811 size_t len;
813 TRACE("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
814 lIndex, plIndex);
816 if(!bstrSelector || !bstrStyle || !bstrSelector[0] || !bstrStyle[0])
817 return E_INVALIDARG;
819 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
820 if(NS_FAILED(nsres))
821 return E_FAIL;
822 nsIDOMCSSRuleList_GetLength(nslist, &length);
824 if(lIndex > length)
825 lIndex = length;
827 len = ARRAY_SIZE(format) - 4 /* %s twice */ + wcslen(bstrSelector) + wcslen(bstrStyle);
828 if(!(rule = heap_alloc(len * sizeof(WCHAR))))
829 return E_OUTOFMEMORY;
830 swprintf(rule, len, format, bstrSelector, bstrStyle);
832 nsAString_InitDepend(&nsstr, rule);
833 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, lIndex, &new_index);
834 if(NS_FAILED(nsres)) WARN("failed: %08x\n", nsres);
835 nsAString_Finish(&nsstr);
836 heap_free(rule);
838 *plIndex = new_index;
839 return map_nsresult(nsres);
842 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
844 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
845 FIXME("(%p)->(%d)\n", This, lIndex);
846 return E_NOTIMPL;
849 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
851 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
852 FIXME("(%p)->(%d)\n", This, lIndex);
853 return E_NOTIMPL;
856 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
858 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
859 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
860 return E_NOTIMPL;
863 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
865 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
866 FIXME("(%p)->(%p)\n", This, p);
867 return E_NOTIMPL;
870 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
872 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
873 nsresult nsres;
875 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
877 do {
878 nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
879 }while(NS_SUCCEEDED(nsres));
881 if(v && *v) {
882 nsAString nsstr;
883 UINT32 idx;
885 /* FIXME: This won't work for multiple rules in the string. */
886 nsAString_InitDepend(&nsstr, v);
887 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx);
888 nsAString_Finish(&nsstr);
889 if(NS_FAILED(nsres)) {
890 FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v));
891 return E_FAIL;
895 return S_OK;
898 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
900 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
901 nsIDOMCSSRuleList *nslist = NULL;
902 nsIDOMCSSRule *nsrule;
903 nsAString nsstr;
904 UINT32 len;
905 nsresult nsres;
907 TRACE("(%p)->(%p)\n", This, p);
909 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
910 if(NS_FAILED(nsres)) {
911 ERR("GetCssRules failed: %08x\n", nsres);
912 return E_FAIL;
915 nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
916 assert(nsres == NS_OK);
918 if(len) {
919 nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
920 if(NS_FAILED(nsres))
921 ERR("Item failed: %08x\n", nsres);
924 nsIDOMCSSRuleList_Release(nslist);
925 if(NS_FAILED(nsres))
926 return E_FAIL;
928 if(!len) {
929 *p = NULL;
930 return S_OK;
933 nsAString_Init(&nsstr, NULL);
934 nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr);
935 nsIDOMCSSRule_Release(nsrule);
936 return return_nsstr(nsres, &nsstr, p);
939 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
940 IHTMLStyleSheetRulesCollection **p)
942 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
943 nsIDOMCSSRuleList *nslist = NULL;
944 nsresult nsres;
945 HRESULT hres;
947 TRACE("(%p)->(%p)\n", This, p);
949 nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
950 if(NS_FAILED(nsres)) {
951 ERR("GetCssRules failed: %08x\n", nsres);
952 return E_FAIL;
955 hres = create_style_sheet_rules_collection(nslist, dispex_compat_mode(&This->dispex), p);
956 nsIDOMCSSRuleList_Release(nslist);
957 return hres;
960 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
961 HTMLStyleSheet_QueryInterface,
962 HTMLStyleSheet_AddRef,
963 HTMLStyleSheet_Release,
964 HTMLStyleSheet_GetTypeInfoCount,
965 HTMLStyleSheet_GetTypeInfo,
966 HTMLStyleSheet_GetIDsOfNames,
967 HTMLStyleSheet_Invoke,
968 HTMLStyleSheet_put_title,
969 HTMLStyleSheet_get_title,
970 HTMLStyleSheet_get_parentStyleSheet,
971 HTMLStyleSheet_get_owningElement,
972 HTMLStyleSheet_put_disabled,
973 HTMLStyleSheet_get_disabled,
974 HTMLStyleSheet_get_readOnly,
975 HTMLStyleSheet_get_imports,
976 HTMLStyleSheet_put_href,
977 HTMLStyleSheet_get_href,
978 HTMLStyleSheet_get_type,
979 HTMLStyleSheet_get_id,
980 HTMLStyleSheet_addImport,
981 HTMLStyleSheet_addRule,
982 HTMLStyleSheet_removeImport,
983 HTMLStyleSheet_removeRule,
984 HTMLStyleSheet_put_media,
985 HTMLStyleSheet_get_media,
986 HTMLStyleSheet_put_cssText,
987 HTMLStyleSheet_get_cssText,
988 HTMLStyleSheet_get_rules
991 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet4(IHTMLStyleSheet4 *iface)
993 return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet4_iface);
996 static HRESULT WINAPI HTMLStyleSheet4_QueryInterface(IHTMLStyleSheet4 *iface, REFIID riid, void **ppv)
998 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
999 return IHTMLStyleSheet_QueryInterface(&This->IHTMLStyleSheet_iface, riid, ppv);
1002 static ULONG WINAPI HTMLStyleSheet4_AddRef(IHTMLStyleSheet4 *iface)
1004 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1005 return IHTMLStyleSheet_AddRef(&This->IHTMLStyleSheet_iface);
1008 static ULONG WINAPI HTMLStyleSheet4_Release(IHTMLStyleSheet4 *iface)
1010 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1011 return IHTMLStyleSheet_Release(&This->IHTMLStyleSheet_iface);
1014 static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfoCount(IHTMLStyleSheet4 *iface, UINT *pctinfo)
1016 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1017 TRACE("(%p)->(%p)\n", This, pctinfo);
1018 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1021 static HRESULT WINAPI HTMLStyleSheet4_GetTypeInfo(IHTMLStyleSheet4 *iface, UINT iTInfo,
1022 LCID lcid, ITypeInfo **ppTInfo)
1024 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1025 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1028 static HRESULT WINAPI HTMLStyleSheet4_GetIDsOfNames(IHTMLStyleSheet4 *iface, REFIID riid,
1029 LPOLESTR *rgszNames, UINT cNames,
1030 LCID lcid, DISPID *rgDispId)
1032 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1033 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
1036 static HRESULT WINAPI HTMLStyleSheet4_Invoke(IHTMLStyleSheet4 *iface, DISPID dispIdMember,
1037 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1038 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1040 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1041 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
1042 pVarResult, pExcepInfo, puArgErr);
1045 static HRESULT WINAPI HTMLStyleSheet4_get_type(IHTMLStyleSheet4 *iface, BSTR *p)
1047 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1048 TRACE("(%p)->(%p)\n", This, p);
1049 return IHTMLStyleSheet_get_type(&This->IHTMLStyleSheet_iface, p);
1052 static HRESULT WINAPI HTMLStyleSheet4_get_href(IHTMLStyleSheet4 *iface, VARIANT *p)
1054 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1055 nsAString href_str;
1056 nsresult nsres;
1058 TRACE("(%p)->(%p)\n", This, p);
1060 nsAString_Init(&href_str, NULL);
1061 nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
1062 return return_nsstr_variant(nsres, &href_str, 0, p);
1065 static HRESULT WINAPI HTMLStyleSheet4_get_title(IHTMLStyleSheet4 *iface, BSTR *p)
1067 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1068 FIXME("(%p)->(%p)\n", This, p);
1069 return E_NOTIMPL;
1072 static HRESULT WINAPI HTMLStyleSheet4_get_ownerNode(IHTMLStyleSheet4 *iface, IHTMLElement **p)
1074 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1075 FIXME("(%p)->(%p)\n", This, p);
1076 return E_NOTIMPL;
1079 static HRESULT WINAPI HTMLStyleSheet4_get_ownerRule(IHTMLStyleSheet4 *iface, IHTMLCSSRule **p)
1081 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1082 FIXME("(%p)->(%p)\n", This, p);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLStyleSheet4_get_cssRules(IHTMLStyleSheet4 *iface, IHTMLStyleSheetRulesCollection **p)
1088 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1089 TRACE("(%p)->(%p)\n", This, p);
1090 return IHTMLStyleSheet_get_rules(&This->IHTMLStyleSheet_iface, p);
1093 static HRESULT WINAPI HTMLStyleSheet4_get_media(IHTMLStyleSheet4 *iface, VARIANT *p)
1095 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1096 FIXME("(%p)->(%p)\n", This, p);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLStyleSheet4_insertRule(IHTMLStyleSheet4 *iface, BSTR rule, LONG index, LONG *p)
1102 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1103 UINT32 new_index = 0;
1104 nsAString nsstr;
1105 nsresult nsres;
1107 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(rule), index, p);
1109 nsAString_InitDepend(&nsstr, rule);
1110 nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, index, &new_index);
1111 if(NS_FAILED(nsres)) WARN("failed: %08x\n", nsres);
1112 nsAString_Finish(&nsstr);
1113 *p = new_index;
1114 return map_nsresult(nsres);
1117 static HRESULT WINAPI HTMLStyleSheet4_deleteRule(IHTMLStyleSheet4 *iface, LONG index)
1119 HTMLStyleSheet *This = impl_from_IHTMLStyleSheet4(iface);
1120 FIXME("(%p)->(%d)\n", This, index);
1121 return E_NOTIMPL;
1124 static const IHTMLStyleSheet4Vtbl HTMLStyleSheet4Vtbl = {
1125 HTMLStyleSheet4_QueryInterface,
1126 HTMLStyleSheet4_AddRef,
1127 HTMLStyleSheet4_Release,
1128 HTMLStyleSheet4_GetTypeInfoCount,
1129 HTMLStyleSheet4_GetTypeInfo,
1130 HTMLStyleSheet4_GetIDsOfNames,
1131 HTMLStyleSheet4_Invoke,
1132 HTMLStyleSheet4_get_type,
1133 HTMLStyleSheet4_get_href,
1134 HTMLStyleSheet4_get_title,
1135 HTMLStyleSheet4_get_ownerNode,
1136 HTMLStyleSheet4_get_ownerRule,
1137 HTMLStyleSheet4_get_cssRules,
1138 HTMLStyleSheet4_get_media,
1139 HTMLStyleSheet4_insertRule,
1140 HTMLStyleSheet4_deleteRule,
1143 static void HTMLStyleSheet_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
1145 if(mode >= COMPAT_MODE_IE9)
1146 dispex_info_add_interface(info, IHTMLStyleSheet4_tid, NULL);
1149 static const tid_t HTMLStyleSheet_iface_tids[] = {
1150 IHTMLStyleSheet_tid,
1153 static dispex_static_data_t HTMLStyleSheet_dispex = {
1154 L"CSSStyleSheet",
1155 NULL,
1156 DispHTMLStyleSheet_tid,
1157 HTMLStyleSheet_iface_tids,
1158 HTMLStyleSheet_init_dispex_info
1161 HRESULT create_style_sheet(nsIDOMStyleSheet *nsstylesheet, compat_mode_t compat_mode, IHTMLStyleSheet **ret)
1163 HTMLStyleSheet *style_sheet;
1164 nsresult nsres;
1166 if(!(style_sheet = heap_alloc(sizeof(HTMLStyleSheet))))
1167 return E_OUTOFMEMORY;
1169 style_sheet->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
1170 style_sheet->IHTMLStyleSheet4_iface.lpVtbl = &HTMLStyleSheet4Vtbl;
1171 style_sheet->ref = 1;
1172 style_sheet->nsstylesheet = NULL;
1174 init_dispatch(&style_sheet->dispex, (IUnknown*)&style_sheet->IHTMLStyleSheet_iface,
1175 &HTMLStyleSheet_dispex, compat_mode);
1177 if(nsstylesheet) {
1178 nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
1179 (void**)&style_sheet->nsstylesheet);
1180 if(NS_FAILED(nsres))
1181 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
1184 *ret = &style_sheet->IHTMLStyleSheet_iface;
1185 return S_OK;