ReactOS  0.4.15-dev-506-ga3ec01c
htmlstylesheet.c
Go to the documentation of this file.
1 /*
2  * Copyright 2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #include "mshtml_private.h"
20 
23  IHTMLStyleSheet IHTMLStyleSheet_iface;
24 
26 
28 };
29 
32  IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface;
33 
35 
37 };
38 
41  IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface;
42 
44 
46 };
47 
48 static inline HTMLStyleSheetRulesCollection *impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
49 {
50  return CONTAINING_RECORD(iface, HTMLStyleSheetRulesCollection, IHTMLStyleSheetRulesCollection_iface);
51 }
52 
53 static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface,
54  REFIID riid, void **ppv)
55 {
57 
58  TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
59 
61  *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
62  }else if(IsEqualGUID(&IID_IHTMLStyleSheetRulesCollection, riid)) {
63  *ppv = &This->IHTMLStyleSheetRulesCollection_iface;
64  }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
65  return *ppv ? S_OK : E_NOINTERFACE;
66  }else {
67  *ppv = NULL;
68  FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
69  return E_NOINTERFACE;
70  }
71 
72  IUnknown_AddRef((IUnknown*)*ppv);
73  return S_OK;
74 }
75 
76 static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
77 {
80 
81  TRACE("(%p) ref=%d\n", This, ref);
82 
83  return ref;
84 }
85 
86 static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
87 {
90 
91  TRACE("(%p) ref=%d\n", This, ref);
92 
93  if(!ref) {
94  release_dispex(&This->dispex);
95  if(This->nslist)
96  nsIDOMCSSRuleList_Release(This->nslist);
97  heap_free(This);
98  }
99 
100  return ref;
101 }
102 
104  IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
105 {
107  return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
108 }
109 
110 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface,
111  UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
112 {
114  return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
115 }
116 
117 static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface,
118  REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
119 {
121  return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
122  lcid, rgDispId);
123 }
124 
125 static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface,
126  DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
127  VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
128 {
130  return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
131  pDispParams, pVarResult, pExcepInfo, puArgErr);
132 }
133 
134 static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface,
135  LONG *p)
136 {
138  UINT32 len = 0;
139 
140  TRACE("(%p)->(%p)\n", This, p);
141 
142  if(This->nslist) {
143  nsresult nsres;
144 
145  nsres = nsIDOMCSSRuleList_GetLength(This->nslist, &len);
146  if(NS_FAILED(nsres))
147  ERR("GetLength failed: %08x\n", nsres);
148  }
149 
150  *p = len;
151  return S_OK;
152 }
153 
154 static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface,
155  LONG index, IHTMLStyleSheetRule **ppHTMLStyleSheetRule)
156 {
158  FIXME("(%p)->(%d %p)\n", This, index, ppHTMLStyleSheetRule);
159  return E_NOTIMPL;
160 }
161 
162 static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl = {
172 };
173 
175  IHTMLStyleSheetRulesCollection_tid,
176  0
177 };
179  NULL,
180  DispHTMLStyleSheetRulesCollection_tid,
181  NULL,
183 };
184 
185 static IHTMLStyleSheetRulesCollection *HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList *nslist)
186 {
188 
189  ret = heap_alloc(sizeof(*ret));
190  ret->IHTMLStyleSheetRulesCollection_iface.lpVtbl = &HTMLStyleSheetRulesCollectionVtbl;
191  ret->ref = 1;
192  ret->nslist = nslist;
193 
194  init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetRulesCollection_iface, &HTMLStyleSheetRulesCollection_dispex);
195 
196  if(nslist)
197  nsIDOMCSSRuleList_AddRef(nslist);
198 
199  return &ret->IHTMLStyleSheetRulesCollection_iface;
200 }
201 
202 static inline HTMLStyleSheetsCollection *impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface)
203 {
204  return CONTAINING_RECORD(iface, HTMLStyleSheetsCollection, IHTMLStyleSheetsCollection_iface);
205 }
206 
207 static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface,
208  REFIID riid, void **ppv)
209 {
211 
212  TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
213 
214  if(IsEqualGUID(&IID_IUnknown, riid)) {
215  *ppv = &This->IHTMLStyleSheetsCollection_iface;
216  }else if(IsEqualGUID(&IID_IDispatch, riid)) {
217  *ppv = &This->IHTMLStyleSheetsCollection_iface;
218  }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection, riid)) {
219  *ppv = &This->IHTMLStyleSheetsCollection_iface;
220  }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
221  return *ppv ? S_OK : E_NOINTERFACE;
222  }else {
223  *ppv = NULL;
224  WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
225  return E_NOINTERFACE;
226  }
227 
228  IUnknown_AddRef((IUnknown*)*ppv);
229  return S_OK;
230 }
231 
232 static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
233 {
236 
237  TRACE("(%p) ref=%d\n", This, ref);
238 
239  return ref;
240 }
241 
242 static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
243 {
246 
247  TRACE("(%p) ref=%d\n", This, ref);
248 
249  if(!ref) {
250  release_dispex(&This->dispex);
251  if(This->nslist)
252  nsIDOMStyleSheetList_Release(This->nslist);
253  heap_free(This);
254  }
255 
256  return ref;
257 }
258 
259 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface,
260  UINT *pctinfo)
261 {
263  return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
264 }
265 
266 static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface,
267  UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
268 {
270  return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
271 }
272 
273 static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface,
274  REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
275 {
277  return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
278  lcid, rgDispId);
279 }
280 
281 static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface,
282  DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
283  VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
284 {
286  return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
287  wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
288 }
289 
290 static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface,
291  LONG *p)
292 {
294  UINT32 len = 0;
295 
296  TRACE("(%p)->(%p)\n", This, p);
297 
298  if(This->nslist)
299  nsIDOMStyleSheetList_GetLength(This->nslist, &len);
300 
301  *p = len;
302  return S_OK;
303 }
304 
305 static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface,
306  IUnknown **p)
307 {
309  FIXME("(%p)->(%p)\n", This, p);
310  return E_NOTIMPL;
311 }
312 
313 static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface,
314  VARIANT *pvarIndex, VARIANT *pvarResult)
315 {
317 
318  TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarIndex), pvarResult);
319 
320  switch(V_VT(pvarIndex)) {
321  case VT_I4: {
322  nsIDOMStyleSheet *nsstylesheet;
323  nsresult nsres;
324 
325  TRACE("index=%d\n", V_I4(pvarIndex));
326 
327  nsres = nsIDOMStyleSheetList_Item(This->nslist, V_I4(pvarIndex), &nsstylesheet);
328  if(NS_FAILED(nsres) || !nsstylesheet) {
329  WARN("Item failed: %08x\n", nsres);
330  V_VT(pvarResult) = VT_EMPTY;
331  return E_INVALIDARG;
332  }
333 
334  V_VT(pvarResult) = VT_DISPATCH;
335  V_DISPATCH(pvarResult) = (IDispatch*)HTMLStyleSheet_Create(nsstylesheet);
336 
337  return S_OK;
338  }
339 
340  case VT_BSTR:
341  FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult)));
342  return E_NOTIMPL;
343 
344  default:
345  WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
346  }
347 
348  return E_INVALIDARG;
349 }
350 
351 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl = {
362 };
363 
365  IHTMLStyleSheetsCollection_tid,
366  0
367 };
369  NULL,
370  DispHTMLStyleSheetsCollection_tid,
371  NULL,
373 };
374 
375 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
376 {
378 
379  ret->IHTMLStyleSheetsCollection_iface.lpVtbl = &HTMLStyleSheetsCollectionVtbl;
380  ret->ref = 1;
381 
382  if(nslist)
383  nsIDOMStyleSheetList_AddRef(nslist);
384  ret->nslist = nslist;
385 
386  init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheetsCollection_iface,
388 
389  return &ret->IHTMLStyleSheetsCollection_iface;
390 }
391 
392 static inline HTMLStyleSheet *impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
393 {
394  return CONTAINING_RECORD(iface, HTMLStyleSheet, IHTMLStyleSheet_iface);
395 }
396 
397 static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
398 {
400 
401  TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
402 
403  if(IsEqualGUID(&IID_IUnknown, riid)) {
404  *ppv = &This->IHTMLStyleSheet_iface;
405  }else if(IsEqualGUID(&IID_IDispatch, riid)) {
406  *ppv = &This->IHTMLStyleSheet_iface;
407  }else if(IsEqualGUID(&IID_IHTMLStyleSheet, riid)) {
408  *ppv = &This->IHTMLStyleSheet_iface;
409  }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
410  return *ppv ? S_OK : E_NOINTERFACE;
411  }else {
412  *ppv = NULL;
413  WARN("unsupported %s\n", debugstr_mshtml_guid(riid));
414  return E_NOINTERFACE;
415  }
416 
417  IUnknown_AddRef((IUnknown*)*ppv);
418  return S_OK;
419 }
420 
421 static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
422 {
425 
426  TRACE("(%p) ref=%d\n", This, ref);
427 
428  return ref;
429 }
430 
431 static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
432 {
435 
436  TRACE("(%p) ref=%d\n", This, ref);
437 
438  if(!ref) {
439  release_dispex(&This->dispex);
440  if(This->nsstylesheet)
441  nsIDOMCSSStyleSheet_Release(This->nsstylesheet);
442  heap_free(This);
443  }
444 
445  return ref;
446 }
447 
448 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
449 {
451  TRACE("(%p)->(%p)\n", This, pctinfo);
452  return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
453 }
454 
455 static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo,
456  LCID lcid, ITypeInfo **ppTInfo)
457 {
459  return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
460 }
461 
462 static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid,
463  LPOLESTR *rgszNames, UINT cNames,
464  LCID lcid, DISPID *rgDispId)
465 {
467  return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
468 }
469 
470 static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember,
471  REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
472  VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
473 {
475  return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, pDispParams,
476  pVarResult, pExcepInfo, puArgErr);
477 }
478 
479 static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
480 {
482  FIXME("(%p)->(%s)\n", This, debugstr_w(v));
483  return E_NOTIMPL;
484 }
485 
486 static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
487 {
489  FIXME("(%p)->(%p)\n", This, p);
490  return E_NOTIMPL;
491 }
492 
493 static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface,
494  IHTMLStyleSheet **p)
495 {
497  FIXME("(%p)->(%p)\n", This, p);
498  return E_NOTIMPL;
499 }
500 
501 static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
502 {
504  FIXME("(%p)->(%p)\n", This, p);
505  return E_NOTIMPL;
506 }
507 
508 static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
509 {
511  FIXME("(%p)->(%x)\n", This, v);
512  return E_NOTIMPL;
513 }
514 
515 static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
516 {
518  FIXME("(%p)->(%p)\n", This, p);
519  return E_NOTIMPL;
520 }
521 
522 static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
523 {
525  FIXME("(%p)->(%p)\n", This, p);
526  return E_NOTIMPL;
527 }
528 
529 static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface,
530  IHTMLStyleSheetsCollection **p)
531 {
533  FIXME("(%p)->(%p)\n", This, p);
534  return E_NOTIMPL;
535 }
536 
537 static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
538 {
540  FIXME("(%p)->(%s)\n", This, debugstr_w(v));
541  return E_NOTIMPL;
542 }
543 
544 static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
545 {
547  nsAString href_str;
548  nsresult nsres;
549 
550  TRACE("(%p)->(%p)\n", This, p);
551 
552  nsAString_Init(&href_str, NULL);
553  nsres = nsIDOMCSSStyleSheet_GetHref(This->nsstylesheet, &href_str);
554  return return_nsstr(nsres, &href_str, p);
555 }
556 
557 static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
558 {
560  FIXME("(%p)->(%p)\n", This, p);
561  return E_NOTIMPL;
562 }
563 
564 static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
565 {
567  FIXME("(%p)->(%p)\n", This, p);
568  return E_NOTIMPL;
569 }
570 
571 static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL,
572  LONG lIndex, LONG *plIndex)
573 {
575  FIXME("(%p)->(%s %d %p)\n", This, debugstr_w(bstrURL), lIndex, plIndex);
576  return E_NOTIMPL;
577 }
578 
579 static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector,
580  BSTR bstrStyle, LONG lIndex, LONG *plIndex)
581 {
583  FIXME("(%p)->(%s %s %d %p)\n", This, debugstr_w(bstrSelector), debugstr_w(bstrStyle),
584  lIndex, plIndex);
585  return E_NOTIMPL;
586 }
587 
588 static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
589 {
591  FIXME("(%p)->(%d)\n", This, lIndex);
592  return E_NOTIMPL;
593 }
594 
595 static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
596 {
598  FIXME("(%p)->(%d)\n", This, lIndex);
599  return E_NOTIMPL;
600 }
601 
602 static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
603 {
605  FIXME("(%p)->(%s)\n", This, debugstr_w(v));
606  return E_NOTIMPL;
607 }
608 
609 static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
610 {
612  FIXME("(%p)->(%p)\n", This, p);
613  return E_NOTIMPL;
614 }
615 
616 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
617 {
619  nsresult nsres;
620 
621  TRACE("(%p)->(%s)\n", This, debugstr_w(v));
622 
623  do {
624  nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
625  }while(NS_SUCCEEDED(nsres));
626 
627  if(v && *v) {
628  nsAString nsstr;
629  UINT32 idx;
630 
631  /* FIXME: This won't work for multiple rules in the string. */
632  nsAString_InitDepend(&nsstr, v);
633  nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx);
634  nsAString_Finish(&nsstr);
635  if(NS_FAILED(nsres)) {
636  FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v));
637  return E_FAIL;
638  }
639  }
640 
641  return S_OK;
642 }
643 
644 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
645 {
647  nsIDOMCSSRuleList *nslist = NULL;
648  nsIDOMCSSRule *nsrule;
649  nsAString nsstr;
650  UINT32 len;
651  nsresult nsres;
652 
653  TRACE("(%p)->(%p)\n", This, p);
654 
655  nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
656  if(NS_FAILED(nsres)) {
657  ERR("GetCssRules failed: %08x\n", nsres);
658  return E_FAIL;
659  }
660 
661  nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
662  assert(nsres == NS_OK);
663 
664  if(len) {
665  nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
666  if(NS_FAILED(nsres))
667  ERR("Item failed: %08x\n", nsres);
668  }
669 
670  nsIDOMCSSRuleList_Release(nslist);
671  if(NS_FAILED(nsres))
672  return E_FAIL;
673 
674  if(!len) {
675  *p = NULL;
676  return S_OK;
677  }
678 
679  nsAString_Init(&nsstr, NULL);
680  nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr);
681  nsIDOMCSSRule_Release(nsrule);
682  return return_nsstr(nsres, &nsstr, p);
683 }
684 
685 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,
686  IHTMLStyleSheetRulesCollection **p)
687 {
689  nsIDOMCSSRuleList *nslist = NULL;
690  nsresult nsres;
691 
692  TRACE("(%p)->(%p)\n", This, p);
693 
694  nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
695  if(NS_FAILED(nsres)) {
696  ERR("GetCssRules failed: %08x\n", nsres);
697  return E_FAIL;
698  }
699 
701  return S_OK;
702 }
703 
704 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl = {
733 };
734 
736  IHTMLStyleSheet_tid,
737  0
738 };
740  NULL,
741  DispHTMLStyleSheet_tid,
742  NULL,
744 };
745 
746 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
747 {
749  nsresult nsres;
750 
751  ret->IHTMLStyleSheet_iface.lpVtbl = &HTMLStyleSheetVtbl;
752  ret->ref = 1;
753  ret->nsstylesheet = NULL;
754 
755  init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLStyleSheet_iface, &HTMLStyleSheet_dispex);
756 
757  if(nsstylesheet) {
758  nsres = nsIDOMStyleSheet_QueryInterface(nsstylesheet, &IID_nsIDOMCSSStyleSheet,
759  (void**)&ret->nsstylesheet);
760  if(NS_FAILED(nsres))
761  ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres);
762  }
763 
764  return &ret->IHTMLStyleSheet_iface;
765 }
IHTMLStyleSheet IHTMLStyleSheet_iface
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static HRESULT WINAPI HTMLStyleSheetRulesCollection_Invoke(IHTMLStyleSheetRulesCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
IHTMLStyleSheetRulesCollection IHTMLStyleSheetRulesCollection_iface
Definition: compat.h:1948
static HRESULT WINAPI HTMLStyleSheet_put_media(IHTMLStyleSheet *iface, BSTR v)
static ULONG WINAPI HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection *iface)
static HRESULT WINAPI HTMLStyleSheet_QueryInterface(IHTMLStyleSheet *iface, REFIID riid, void **ppv)
static HRESULT WINAPI HTMLStyleSheet_get_readOnly(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
nsIDOMCSSRuleList * nslist
REFIID riid
Definition: precomp.h:44
IHTMLStyleSheetsCollection IHTMLStyleSheetsCollection_iface
tid_t
Definition: ieframe.h:311
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfoCount(IHTMLStyleSheetRulesCollection *iface, UINT *pctinfo)
#define WARN(fmt,...)
Definition: debug.h:112
REFIID LPVOID * ppv
Definition: atlbase.h:39
static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
#define assert(x)
Definition: debug.h:53
nsIDOMCSSStyleSheet * nsstylesheet
DWORD LCID
Definition: nls.h:13
OLECHAR * BSTR
Definition: compat.h:1943
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetIDsOfNames(IHTMLStyleSheetRulesCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
static LPOLESTR
Definition: stg_prop.c:27
nsIDOMStyleSheetList * nslist
#define E_FAIL
Definition: ddrawi.h:102
static HRESULT WINAPI HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
short VARIANT_BOOL
Definition: compat.h:1940
Definition: send.c:48
static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface, IHTMLStyleSheetRulesCollection **p)
static void * heap_alloc(size_t len)
Definition: appwiz.h:65
#define V_I4(A)
Definition: oleauto.h:247
static HRESULT WINAPI HTMLStyleSheetRulesCollection_item(IHTMLStyleSheetRulesCollection *iface, LONG index, IHTMLStyleSheetRule **ppHTMLStyleSheetRule)
#define V_DISPATCH(A)
Definition: oleauto.h:239
static HRESULT WINAPI HTMLStyleSheet_put_href(IHTMLStyleSheet *iface, BSTR v)
const char * debugstr_mshtml_guid(const GUID *iid)
Definition: main.c:535
#define NS_OK
static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
static HTMLStyleSheetsCollection * impl_from_IHTMLStyleSheetsCollection(IHTMLStyleSheetsCollection *iface)
unsigned int UINT32
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:111
static HRESULT WINAPI HTMLStyleSheet_get_id(IHTMLStyleSheet *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleSheet_addRule(IHTMLStyleSheet *iface, BSTR bstrSelector, BSTR bstrStyle, LONG lIndex, LONG *plIndex)
unsigned int idx
Definition: utils.c:41
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
static HRESULT WINAPI HTMLStyleSheet_get_type(IHTMLStyleSheet *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleSheet_get_imports(IHTMLStyleSheet *iface, IHTMLStyleSheetsCollection **p)
GLuint index
Definition: glext.h:6031
static HRESULT WINAPI HTMLStyleSheetRulesCollection_get_length(IHTMLStyleSheetRulesCollection *iface, LONG *p)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define NS_FAILED(res)
static HRESULT WINAPI HTMLStyleSheet_removeImport(IHTMLStyleSheet *iface, LONG lIndex)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
DispatchEx dispex
static dispex_static_data_t HTMLStyleSheetsCollection_dispex
static HRESULT WINAPI HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection *iface, IUnknown **p)
static HRESULT WINAPI HTMLStyleSheetRulesCollection_QueryInterface(IHTMLStyleSheetRulesCollection *iface, REFIID riid, void **ppv)
static HRESULT WINAPI HTMLStyleSheet_Invoke(IHTMLStyleSheet *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
static HRESULT WINAPI HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
static HRESULT WINAPI HTMLStyleSheet_removeRule(IHTMLStyleSheet *iface, LONG lIndex)
LONG HRESULT
Definition: typedefs.h:78
IHTMLStyleSheet * HTMLStyleSheet_Create(nsIDOMStyleSheet *nsstylesheet)
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
unsigned short WORD
Definition: ntddk_ex.h:93
static ULONG WINAPI HTMLStyleSheetRulesCollection_Release(IHTMLStyleSheetRulesCollection *iface)
static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection *iface, UINT *pctinfo)
#define NS_SUCCEEDED(res)
static HRESULT WINAPI HTMLStyleSheetRulesCollection_GetTypeInfo(IHTMLStyleSheetRulesCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
static HRESULT WINAPI HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection *iface, LONG *p)
const GUID IID_IDispatch
static HRESULT WINAPI HTMLStyleSheet_put_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL v)
int ret
static const tid_t HTMLStyleSheet_iface_tids[]
static HTMLStyleSheet * impl_from_IHTMLStyleSheet(IHTMLStyleSheet *iface)
#define InterlockedDecrement
Definition: armddk.h:52
#define V_VT(A)
Definition: oleauto.h:211
static ULONG WINAPI HTMLStyleSheetRulesCollection_AddRef(IHTMLStyleSheetRulesCollection *iface)
GLenum GLsizei len
Definition: glext.h:6722
static HTMLStyleSheetRulesCollection * impl_from_IHTMLStyleSheetRulesCollection(IHTMLStyleSheetRulesCollection *iface)
static HRESULT WINAPI HTMLStyleSheet_get_disabled(IHTMLStyleSheet *iface, VARIANT_BOOL *p)
#define V_BSTR(A)
Definition: oleauto.h:226
IHTMLStyleSheetsCollection * HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList *nslist)
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:534
#define ERR(fmt,...)
Definition: debug.h:110
static dispex_static_data_t HTMLStyleSheet_dispex
struct stdole::EXCEPINFO EXCEPINFO
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static VARIANTARG static DISPID
Definition: ordinal.c:49
#define S_OK
Definition: intsafe.h:59
static HRESULT WINAPI HTMLStyleSheet_get_owningElement(IHTMLStyleSheet *iface, IHTMLElement **p)
#define InterlockedIncrement
Definition: armddk.h:53
const GLdouble * v
Definition: gl.h:2040
static HRESULT WINAPI HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
Definition: dispex.c:1656
static const tid_t HTMLStyleSheetsCollection_iface_tids[]
static ULONG WINAPI HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection *iface)
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT WINAPI HTMLStyleSheet_put_title(IHTMLStyleSheet *iface, BSTR v)
static HRESULT WINAPI HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
static HRESULT WINAPI HTMLStyleSheet_get_title(IHTMLStyleSheet *iface, BSTR *p)
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
static dispex_static_data_t HTMLStyleSheetRulesCollection_dispex
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
static HRESULT WINAPI HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet *iface, UINT *pctinfo)
struct stdole::DISPPARAMS DISPPARAMS
static HRESULT WINAPI HTMLStyleSheet_get_href(IHTMLStyleSheet *iface, BSTR *p)
HRESULT nsresult
Definition: nsiface.idl:39
static ULONG WINAPI HTMLStyleSheet_Release(IHTMLStyleSheet *iface)
unsigned int ULONG
Definition: retypes.h:1
static HRESULT WINAPI HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet *iface, IHTMLStyleSheet **p)
GLfloat GLfloat p
Definition: glext.h:8902
static IHTMLStyleSheetRulesCollection * HTMLStyleSheetRulesCollection_Create(nsIDOMCSSRuleList *nslist)
static HRESULT WINAPI HTMLStyleSheet_addImport(IHTMLStyleSheet *iface, BSTR bstrURL, LONG lIndex, LONG *plIndex)
static HRESULT WINAPI HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection *iface, REFIID riid, void **ppv)
void release_dispex(DispatchEx *This)
Definition: dispex.c:1706
static ULONG WINAPI HTMLStyleSheet_AddRef(IHTMLStyleSheet *iface)
static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
static HRESULT WINAPI HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
static const tid_t HTMLStyleSheetRulesCollection_iface_tids[]
static const IHTMLStyleSheetRulesCollectionVtbl HTMLStyleSheetRulesCollectionVtbl
static BOOL heap_free(void *mem)
Definition: appwiz.h:75