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 const IHTMLStyleElementVtbl *lpIHTMLStyleElementVtbl;
40 nsIDOMHTMLStyleElement *nsstyle;
43 #define HTMLSTYLE(x) (&(x)->lpIHTMLStyleElementVtbl)
45 #define HTMLSTYLE_THIS(iface) DEFINE_THIS(HTMLStyleElement, IHTMLStyleElement, iface)
47 static HRESULT WINAPI HTMLStyleElement_QueryInterface(IHTMLStyleElement *iface,
48 REFIID riid, void **ppv)
50 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
52 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
55 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
57 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
59 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
62 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
64 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
66 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
69 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
71 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
75 static HRESULT WINAPI HTMLStyleElement_GetTypeInfo(IHTMLStyleElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
79 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
83 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
86 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
87 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
88 cNames, lcid, rgDispId);
91 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
92 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
93 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
95 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
96 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
97 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
102 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
106 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
108 nsAString_InitDepend(&type_str, v);
109 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
110 nsAString_Finish(&type_str);
111 if(NS_FAILED(nsres)) {
112 ERR("SetType failed: %08x\n", nsres);
119 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
121 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
125 TRACE("(%p)->(%p)\n", This, p);
127 nsAString_Init(&nsstr, NULL);
128 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
129 return return_nsstr(nsres, &nsstr, p);
132 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
134 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
135 FIXME("(%p)->(%p)\n", This, p);
139 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
141 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
142 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
146 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
148 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
149 FIXME("(%p)->(%p)\n", This, p);
153 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
155 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
156 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
160 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
162 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
163 FIXME("(%p)->(%p)\n", This, p);
167 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
169 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
170 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
174 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
176 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
181 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
183 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
184 FIXME("(%p)->(%p)\n", This, p);
188 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
190 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
191 FIXME("(%p)->(%x)\n", This, v);
195 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
197 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
198 FIXME("(%p)->(%p)\n", This, p);
202 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
204 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
208 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
210 nsAString_InitDepend(&media_str, v);
211 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
212 nsAString_Finish(&media_str);
213 if(NS_FAILED(nsres)) {
214 ERR("SetMedia failed: %08x\n", nsres);
221 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
223 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
227 TRACE("(%p)->(%p)\n", This, p);
229 nsAString_Init(&nsstr, NULL);
230 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
231 return return_nsstr(nsres, &nsstr, p);
234 #undef HTMLSTYLE_THIS
236 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
237 HTMLStyleElement_QueryInterface,
238 HTMLStyleElement_AddRef,
239 HTMLStyleElement_Release,
240 HTMLStyleElement_GetTypeInfoCount,
241 HTMLStyleElement_GetTypeInfo,
242 HTMLStyleElement_GetIDsOfNames,
243 HTMLStyleElement_Invoke,
244 HTMLStyleElement_put_type,
245 HTMLStyleElement_get_type,
246 HTMLStyleElement_get_readyState,
247 HTMLStyleElement_put_onreadystatechange,
248 HTMLStyleElement_get_onreadystatechange,
249 HTMLStyleElement_put_onload,
250 HTMLStyleElement_get_onload,
251 HTMLStyleElement_put_onerror,
252 HTMLStyleElement_get_onerror,
253 HTMLStyleElement_get_styleSheet,
254 HTMLStyleElement_put_disabled,
255 HTMLStyleElement_get_disabled,
256 HTMLStyleElement_put_media,
257 HTMLStyleElement_get_media
260 static inline HTMLStyleElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
262 return CONTAINING_RECORD(iface, HTMLStyleElement, element.node);
265 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
267 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
269 if(IsEqualGUID(&IID_IUnknown, riid)) {
270 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
271 *ppv = HTMLSTYLE(This);
272 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
273 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
274 *ppv = HTMLSTYLE(This);
275 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
276 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
277 *ppv = HTMLSTYLE(This);
279 return HTMLElement_QI(&This->element.node, riid, ppv);
282 IUnknown_AddRef((IUnknown*)*ppv);
286 static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
288 HTMLStyleElement *This = impl_from_HTMLDOMNode(iface);
291 nsIDOMHTMLStyleElement_Release(This->nsstyle);
293 HTMLElement_destructor(&This->element.node);
296 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
298 HTMLStyleElement_destructor,
302 static const tid_t HTMLStyleElement_iface_tids[] = {
304 IHTMLStyleElement_tid,
307 static dispex_static_data_t HTMLStyleElement_dispex = {
309 DispHTMLStyleElement_tid,
311 HTMLStyleElement_iface_tids
314 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
316 HTMLStyleElement *ret;
319 ret = heap_alloc_zero(sizeof(*ret));
321 return E_OUTOFMEMORY;
323 ret->lpIHTMLStyleElementVtbl = &HTMLStyleElementVtbl;
324 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
326 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
327 if(NS_FAILED(nsres)) {
328 ERR("Could not get nsIDOMHTMLStyleElement iface: %08x\n", nsres);
333 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
334 *elem = &ret->element;