2 * Copyright 2010 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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 IHTMLStyleElement IHTMLStyleElement_iface
;
40 nsIDOMHTMLStyleElement
*nsstyle
;
43 static inline HTMLStyleElement
*impl_from_IHTMLStyleElement(IHTMLStyleElement
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLStyleElement
, IHTMLStyleElement_iface
);
48 static HRESULT WINAPI
HTMLStyleElement_QueryInterface(IHTMLStyleElement
*iface
,
49 REFIID riid
, void **ppv
)
51 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLStyleElement_AddRef(IHTMLStyleElement
*iface
)
58 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLStyleElement_Release(IHTMLStyleElement
*iface
)
65 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement
*iface
, UINT
*pctinfo
)
72 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLStyleElement_GetTypeInfo(IHTMLStyleElement
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
87 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
88 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
89 cNames
, lcid
, rgDispId
);
92 static HRESULT WINAPI
HTMLStyleElement_Invoke(IHTMLStyleElement
*iface
, DISPID dispIdMember
,
93 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
94 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
96 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
97 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
98 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
101 static HRESULT WINAPI
HTMLStyleElement_put_type(IHTMLStyleElement
*iface
, BSTR v
)
103 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
107 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
109 nsAString_InitDepend(&type_str
, v
);
110 nsres
= nsIDOMHTMLStyleElement_SetType(This
->nsstyle
, &type_str
);
111 nsAString_Finish(&type_str
);
112 if(NS_FAILED(nsres
)) {
113 ERR("SetType failed: %08x\n", nsres
);
120 static HRESULT WINAPI
HTMLStyleElement_get_type(IHTMLStyleElement
*iface
, BSTR
*p
)
122 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
126 TRACE("(%p)->(%p)\n", This
, p
);
128 nsAString_Init(&nsstr
, NULL
);
129 nsres
= nsIDOMHTMLStyleElement_GetType(This
->nsstyle
, &nsstr
);
130 return return_nsstr(nsres
, &nsstr
, p
);
133 static HRESULT WINAPI
HTMLStyleElement_get_readyState(IHTMLStyleElement
*iface
, BSTR
*p
)
135 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
136 FIXME("(%p)->(%p)\n", This
, p
);
140 static HRESULT WINAPI
HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement
*iface
, VARIANT v
)
142 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
143 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
147 static HRESULT WINAPI
HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement
*iface
, VARIANT
*p
)
149 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
150 FIXME("(%p)->(%p)\n", This
, p
);
154 static HRESULT WINAPI
HTMLStyleElement_put_onload(IHTMLStyleElement
*iface
, VARIANT v
)
156 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
157 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
161 static HRESULT WINAPI
HTMLStyleElement_get_onload(IHTMLStyleElement
*iface
, VARIANT
*p
)
163 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
164 FIXME("(%p)->(%p)\n", This
, p
);
168 static HRESULT WINAPI
HTMLStyleElement_put_onerror(IHTMLStyleElement
*iface
, VARIANT v
)
170 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
171 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
175 static HRESULT WINAPI
HTMLStyleElement_get_onerror(IHTMLStyleElement
*iface
, VARIANT
*p
)
177 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
178 FIXME("(%p)->(%p)\n", This
, p
);
182 static HRESULT WINAPI
HTMLStyleElement_get_styleSheet(IHTMLStyleElement
*iface
, IHTMLStyleSheet
**p
)
184 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
185 FIXME("(%p)->(%p)\n", This
, p
);
189 static HRESULT WINAPI
HTMLStyleElement_put_disabled(IHTMLStyleElement
*iface
, VARIANT_BOOL v
)
191 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
192 FIXME("(%p)->(%x)\n", This
, v
);
196 static HRESULT WINAPI
HTMLStyleElement_get_disabled(IHTMLStyleElement
*iface
, VARIANT_BOOL
*p
)
198 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLStyleElement_put_media(IHTMLStyleElement
*iface
, BSTR v
)
205 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
209 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
211 nsAString_InitDepend(&media_str
, v
);
212 nsres
= nsIDOMHTMLStyleElement_SetMedia(This
->nsstyle
, &media_str
);
213 nsAString_Finish(&media_str
);
214 if(NS_FAILED(nsres
)) {
215 ERR("SetMedia failed: %08x\n", nsres
);
222 static HRESULT WINAPI
HTMLStyleElement_get_media(IHTMLStyleElement
*iface
, BSTR
*p
)
224 HTMLStyleElement
*This
= impl_from_IHTMLStyleElement(iface
);
228 TRACE("(%p)->(%p)\n", This
, p
);
230 nsAString_Init(&nsstr
, NULL
);
231 nsres
= nsIDOMHTMLStyleElement_GetMedia(This
->nsstyle
, &nsstr
);
232 return return_nsstr(nsres
, &nsstr
, p
);
235 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl
= {
236 HTMLStyleElement_QueryInterface
,
237 HTMLStyleElement_AddRef
,
238 HTMLStyleElement_Release
,
239 HTMLStyleElement_GetTypeInfoCount
,
240 HTMLStyleElement_GetTypeInfo
,
241 HTMLStyleElement_GetIDsOfNames
,
242 HTMLStyleElement_Invoke
,
243 HTMLStyleElement_put_type
,
244 HTMLStyleElement_get_type
,
245 HTMLStyleElement_get_readyState
,
246 HTMLStyleElement_put_onreadystatechange
,
247 HTMLStyleElement_get_onreadystatechange
,
248 HTMLStyleElement_put_onload
,
249 HTMLStyleElement_get_onload
,
250 HTMLStyleElement_put_onerror
,
251 HTMLStyleElement_get_onerror
,
252 HTMLStyleElement_get_styleSheet
,
253 HTMLStyleElement_put_disabled
,
254 HTMLStyleElement_get_disabled
,
255 HTMLStyleElement_put_media
,
256 HTMLStyleElement_get_media
259 static inline HTMLStyleElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
261 return CONTAINING_RECORD(iface
, HTMLStyleElement
, element
.node
);
264 static HRESULT
HTMLStyleElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
266 HTMLStyleElement
*This
= impl_from_HTMLDOMNode(iface
);
268 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
269 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
270 *ppv
= &This
->IHTMLStyleElement_iface
;
271 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
272 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
273 *ppv
= &This
->IHTMLStyleElement_iface
;
274 }else if(IsEqualGUID(&IID_IHTMLStyleElement
, riid
)) {
275 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This
, ppv
);
276 *ppv
= &This
->IHTMLStyleElement_iface
;
278 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
281 IUnknown_AddRef((IUnknown
*)*ppv
);
285 static void HTMLStyleElement_destructor(HTMLDOMNode
*iface
)
287 HTMLStyleElement
*This
= impl_from_HTMLDOMNode(iface
);
290 nsIDOMHTMLStyleElement_Release(This
->nsstyle
);
292 HTMLElement_destructor(&This
->element
.node
);
295 static const NodeImplVtbl HTMLStyleElementImplVtbl
= {
297 HTMLStyleElement_destructor
,
301 static const tid_t HTMLStyleElement_iface_tids
[] = {
303 IHTMLStyleElement_tid
,
306 static dispex_static_data_t HTMLStyleElement_dispex
= {
308 DispHTMLStyleElement_tid
,
310 HTMLStyleElement_iface_tids
313 HRESULT
HTMLStyleElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
315 HTMLStyleElement
*ret
;
318 ret
= heap_alloc_zero(sizeof(*ret
));
320 return E_OUTOFMEMORY
;
322 ret
->IHTMLStyleElement_iface
.lpVtbl
= &HTMLStyleElementVtbl
;
323 ret
->element
.node
.vtbl
= &HTMLStyleElementImplVtbl
;
325 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLStyleElement
, (void**)&ret
->nsstyle
);
326 if(NS_FAILED(nsres
)) {
327 ERR("Could not get nsIDOMHTMLStyleElement iface: %08x\n", nsres
);
332 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLStyleElement_dispex
);
333 *elem
= &ret
->element
;