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
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
40 const IHTMLStyleSheetVtbl
*lpHTMLStyleSheetVtbl
;
44 nsIDOMCSSStyleSheet
*nsstylesheet
;
48 const IHTMLStyleSheetsCollectionVtbl
*lpHTMLStyleSheetsCollectionVtbl
;
52 nsIDOMStyleSheetList
*nslist
;
53 } HTMLStyleSheetsCollection
;
55 #define HTMLSTYLESHEET(x) ((IHTMLStyleSheet*) &(x)->lpHTMLStyleSheetVtbl);
56 #define HTMLSTYLESHEETSCOL(x) ((IHTMLStyleSheetsCollection*) &(x)->lpHTMLStyleSheetsCollectionVtbl);
58 #define HTMLSTYLESHEETSCOL_THIS(iface) \
59 DEFINE_THIS(HTMLStyleSheetsCollection, HTMLStyleSheetsCollection, iface)
61 static HRESULT WINAPI
HTMLStyleSheetsCollection_QueryInterface(IHTMLStyleSheetsCollection
*iface
,
62 REFIID riid
, void **ppv
)
64 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
68 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
69 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
70 *ppv
= HTMLSTYLESHEETSCOL(This
);
71 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
72 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
73 *ppv
= HTMLSTYLESHEETSCOL(This
);
74 }else if(IsEqualGUID(&IID_IHTMLStyleSheetsCollection
, riid
)) {
75 TRACE("(%p)->(IID_IHTMLStyleSheetsCollection %p)\n", This
, ppv
);
76 *ppv
= HTMLSTYLESHEETSCOL(This
);
80 IUnknown_AddRef((IUnknown
*)*ppv
);
84 WARN("unsupported %s\n", debugstr_guid(riid
));
88 static ULONG WINAPI
HTMLStyleSheetsCollection_AddRef(IHTMLStyleSheetsCollection
*iface
)
90 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
91 LONG ref
= InterlockedIncrement(&This
->ref
);
93 TRACE("(%p) ref=%d\n", This
, ref
);
98 static ULONG WINAPI
HTMLStyleSheetsCollection_Release(IHTMLStyleSheetsCollection
*iface
)
100 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
101 LONG ref
= InterlockedDecrement(&This
->ref
);
103 TRACE("(%p) ref=%d\n", This
, ref
);
111 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfoCount(IHTMLStyleSheetsCollection
*iface
,
114 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
115 FIXME("(%p)->(%p)\n", This
, pctinfo
);
119 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetTypeInfo(IHTMLStyleSheetsCollection
*iface
,
120 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
122 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
123 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
127 static HRESULT WINAPI
HTMLStyleSheetsCollection_GetIDsOfNames(IHTMLStyleSheetsCollection
*iface
,
128 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
130 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
131 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
136 static HRESULT WINAPI
HTMLStyleSheetsCollection_Invoke(IHTMLStyleSheetsCollection
*iface
,
137 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
138 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
140 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
141 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
142 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
146 static HRESULT WINAPI
HTMLStyleSheetsCollection_get_length(IHTMLStyleSheetsCollection
*iface
,
149 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
152 TRACE("(%p)->(%p)\n", This
, p
);
155 nsIDOMStyleSheetList_GetLength(This
->nslist
, &len
);
161 static HRESULT WINAPI
HTMLStyleSheetsCollection_get__newEnum(IHTMLStyleSheetsCollection
*iface
,
164 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
165 FIXME("(%p)->(%p)\n", This
, p
);
169 static HRESULT WINAPI
HTMLStyleSheetsCollection_item(IHTMLStyleSheetsCollection
*iface
,
170 VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
172 HTMLStyleSheetsCollection
*This
= HTMLSTYLESHEETSCOL_THIS(iface
);
174 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
176 switch(V_VT(pvarIndex
)) {
178 nsIDOMStyleSheet
*nsstylesheet
;
181 TRACE("index=%d\n", V_I4(pvarIndex
));
183 nsres
= nsIDOMStyleSheetList_Item(This
->nslist
, V_I4(pvarIndex
), &nsstylesheet
);
184 if(NS_FAILED(nsres
) || !nsstylesheet
) {
185 WARN("Item failed: %08x\n", nsres
);
186 V_VT(pvarResult
) = VT_EMPTY
;
190 V_VT(pvarResult
) = VT_DISPATCH
;
191 V_DISPATCH(pvarResult
) = (IDispatch
*)HTMLStyleSheet_Create(nsstylesheet
);
197 FIXME("id=%s not implemented\n", debugstr_w(V_BSTR(pvarResult
)));
201 WARN("Invalid vt=%d\n", V_VT(pvarIndex
));
207 #undef HTMLSTYLESHEETSCOL_THIS
209 static const IHTMLStyleSheetsCollectionVtbl HTMLStyleSheetsCollectionVtbl
= {
210 HTMLStyleSheetsCollection_QueryInterface
,
211 HTMLStyleSheetsCollection_AddRef
,
212 HTMLStyleSheetsCollection_Release
,
213 HTMLStyleSheetsCollection_GetTypeInfoCount
,
214 HTMLStyleSheetsCollection_GetTypeInfo
,
215 HTMLStyleSheetsCollection_GetIDsOfNames
,
216 HTMLStyleSheetsCollection_Invoke
,
217 HTMLStyleSheetsCollection_get_length
,
218 HTMLStyleSheetsCollection_get__newEnum
,
219 HTMLStyleSheetsCollection_item
222 IHTMLStyleSheetsCollection
*HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList
*nslist
)
224 HTMLStyleSheetsCollection
*ret
= mshtml_alloc(sizeof(HTMLStyleSheetsCollection
));
226 ret
->lpHTMLStyleSheetsCollectionVtbl
= &HTMLStyleSheetsCollectionVtbl
;
230 nsIDOMStyleSheetList_AddRef(nslist
);
231 ret
->nslist
= nslist
;
233 return HTMLSTYLESHEETSCOL(ret
);
236 #define HTMLSTYLESHEET_THIS(iface) DEFINE_THIS(HTMLStyleSheet, HTMLStyleSheet, iface)
238 static HRESULT WINAPI
HTMLStyleSheet_QueryInterface(IHTMLStyleSheet
*iface
, REFIID riid
, void **ppv
)
240 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
244 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
245 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
246 *ppv
= HTMLSTYLESHEET(This
);
247 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
248 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
249 *ppv
= HTMLSTYLESHEET(This
);
250 }else if(IsEqualGUID(&IID_IHTMLStyleSheet
, riid
)) {
251 TRACE("(%p)->(IID_IHTMLStyleSheet %p)\n", This
, ppv
);
252 *ppv
= HTMLSTYLESHEET(This
);
256 IUnknown_AddRef((IUnknown
*)*ppv
);
260 WARN("unsupported %s\n", debugstr_guid(riid
));
261 return E_NOINTERFACE
;
264 static ULONG WINAPI
HTMLStyleSheet_AddRef(IHTMLStyleSheet
*iface
)
266 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
267 LONG ref
= InterlockedIncrement(&This
->ref
);
269 TRACE("(%p) ref=%d\n", This
, ref
);
274 static ULONG WINAPI
HTMLStyleSheet_Release(IHTMLStyleSheet
*iface
)
276 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
277 LONG ref
= InterlockedDecrement(&This
->ref
);
279 TRACE("(%p) ref=%d\n", This
, ref
);
287 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfoCount(IHTMLStyleSheet
*iface
, UINT
*pctinfo
)
289 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
290 FIXME("(%p)->(%p)\n", This
, pctinfo
);
294 static HRESULT WINAPI
HTMLStyleSheet_GetTypeInfo(IHTMLStyleSheet
*iface
, UINT iTInfo
,
295 LCID lcid
, ITypeInfo
**ppTInfo
)
297 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
298 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
302 static HRESULT WINAPI
HTMLStyleSheet_GetIDsOfNames(IHTMLStyleSheet
*iface
, REFIID riid
,
303 LPOLESTR
*rgszNames
, UINT cNames
,
304 LCID lcid
, DISPID
*rgDispId
)
306 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
307 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
312 static HRESULT WINAPI
HTMLStyleSheet_Invoke(IHTMLStyleSheet
*iface
, DISPID dispIdMember
,
313 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
314 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
316 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
317 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
318 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
322 static HRESULT WINAPI
HTMLStyleSheet_put_title(IHTMLStyleSheet
*iface
, BSTR v
)
324 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
325 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
329 static HRESULT WINAPI
HTMLStyleSheet_get_title(IHTMLStyleSheet
*iface
, BSTR
*p
)
331 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
332 FIXME("(%p)->(%p)\n", This
, p
);
336 static HRESULT WINAPI
HTMLStyleSheet_get_parentStyleSheet(IHTMLStyleSheet
*iface
,
339 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
340 FIXME("(%p)->(%p)\n", This
, p
);
344 static HRESULT WINAPI
HTMLStyleSheet_get_owningElement(IHTMLStyleSheet
*iface
, IHTMLElement
**p
)
346 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
347 FIXME("(%p)->(%p)\n", This
, p
);
351 static HRESULT WINAPI
HTMLStyleSheet_put_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL v
)
353 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
354 FIXME("(%p)->(%x)\n", This
, v
);
358 static HRESULT WINAPI
HTMLStyleSheet_get_disabled(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
360 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
361 FIXME("(%p)->(%p)\n", This
, p
);
365 static HRESULT WINAPI
HTMLStyleSheet_get_readOnly(IHTMLStyleSheet
*iface
, VARIANT_BOOL
*p
)
367 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
368 FIXME("(%p)->(%p)\n", This
, p
);
372 static HRESULT WINAPI
HTMLStyleSheet_get_imports(IHTMLStyleSheet
*iface
,
373 IHTMLStyleSheetsCollection
**p
)
375 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
376 FIXME("(%p)->(%p)\n", This
, p
);
380 static HRESULT WINAPI
HTMLStyleSheet_put_href(IHTMLStyleSheet
*iface
, BSTR v
)
382 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
383 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
387 static HRESULT WINAPI
HTMLStyleSheet_get_href(IHTMLStyleSheet
*iface
, BSTR
*p
)
389 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
390 FIXME("(%p)->(%p)\n", This
, p
);
394 static HRESULT WINAPI
HTMLStyleSheet_get_type(IHTMLStyleSheet
*iface
, BSTR
*p
)
396 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
397 FIXME("(%p)->(%p)\n", This
, p
);
401 static HRESULT WINAPI
HTMLStyleSheet_get_id(IHTMLStyleSheet
*iface
, BSTR
*p
)
403 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
404 FIXME("(%p)->(%p)\n", This
, p
);
408 static HRESULT WINAPI
HTMLStyleSheet_addImport(IHTMLStyleSheet
*iface
, BSTR bstrURL
,
409 long lIndex
, long *plIndex
)
411 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
412 FIXME("(%p)->(%s %ld %p)\n", This
, debugstr_w(bstrURL
), lIndex
, plIndex
);
416 static HRESULT WINAPI
HTMLStyleSheet_addRule(IHTMLStyleSheet
*iface
, BSTR bstrSelector
,
417 BSTR bstrStyle
, long lIndex
, long *plIndex
)
419 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
420 FIXME("(%p)->(%s %s %ld %p)\n", This
, debugstr_w(bstrSelector
), debugstr_w(bstrStyle
),
425 static HRESULT WINAPI
HTMLStyleSheet_removeImport(IHTMLStyleSheet
*iface
, long lIndex
)
427 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
428 FIXME("(%p)->(%ld)\n", This
, lIndex
);
432 static HRESULT WINAPI
HTMLStyleSheet_removeRule(IHTMLStyleSheet
*iface
, long lIndex
)
434 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
435 FIXME("(%p)->(%ld)\n", This
, lIndex
);
439 static HRESULT WINAPI
HTMLStyleSheet_put_media(IHTMLStyleSheet
*iface
, BSTR v
)
441 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
442 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
446 static HRESULT WINAPI
HTMLStyleSheet_get_media(IHTMLStyleSheet
*iface
, BSTR
*p
)
448 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
449 FIXME("(%p)->(%p)\n", This
, p
);
453 static HRESULT WINAPI
HTMLStyleSheet_put_cssText(IHTMLStyleSheet
*iface
, BSTR v
)
455 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
456 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
460 static HRESULT WINAPI
HTMLStyleSheet_get_cssText(IHTMLStyleSheet
*iface
, BSTR
*p
)
462 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
463 FIXME("(%p)->(%p)\n", This
, p
);
467 static HRESULT WINAPI
HTMLStyleSheet_get_rules(IHTMLStyleSheet
*iface
,
468 IHTMLStyleSheetRulesCollection
**p
)
470 HTMLStyleSheet
*This
= HTMLSTYLESHEET_THIS(iface
);
471 FIXME("(%p)->(%p)\n", This
, p
);
475 static const IHTMLStyleSheetVtbl HTMLStyleSheetVtbl
= {
476 HTMLStyleSheet_QueryInterface
,
477 HTMLStyleSheet_AddRef
,
478 HTMLStyleSheet_Release
,
479 HTMLStyleSheet_GetTypeInfoCount
,
480 HTMLStyleSheet_GetTypeInfo
,
481 HTMLStyleSheet_GetIDsOfNames
,
482 HTMLStyleSheet_Invoke
,
483 HTMLStyleSheet_put_title
,
484 HTMLStyleSheet_get_title
,
485 HTMLStyleSheet_get_parentStyleSheet
,
486 HTMLStyleSheet_get_owningElement
,
487 HTMLStyleSheet_put_disabled
,
488 HTMLStyleSheet_get_disabled
,
489 HTMLStyleSheet_get_readOnly
,
490 HTMLStyleSheet_get_imports
,
491 HTMLStyleSheet_put_href
,
492 HTMLStyleSheet_get_href
,
493 HTMLStyleSheet_get_type
,
494 HTMLStyleSheet_get_id
,
495 HTMLStyleSheet_addImport
,
496 HTMLStyleSheet_addRule
,
497 HTMLStyleSheet_removeImport
,
498 HTMLStyleSheet_removeRule
,
499 HTMLStyleSheet_put_media
,
500 HTMLStyleSheet_get_media
,
501 HTMLStyleSheet_put_cssText
,
502 HTMLStyleSheet_get_cssText
,
503 HTMLStyleSheet_get_rules
506 IHTMLStyleSheet
*HTMLStyleSheet_Create(nsIDOMStyleSheet
*nsstylesheet
)
508 HTMLStyleSheet
*ret
= mshtml_alloc(sizeof(HTMLStyleSheet
));
511 ret
->lpHTMLStyleSheetVtbl
= &HTMLStyleSheetVtbl
;
513 ret
->nsstylesheet
= NULL
;
516 nsres
= nsIDOMStyleSheet_QueryInterface(nsstylesheet
, &IID_nsIDOMCSSStyleSheet
,
517 (void**)&ret
->nsstylesheet
);
519 ERR("Could not get nsICSSStyleSheet interface: %08x\n", nsres
);
522 return HTMLSTYLESHEET(ret
);