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(HTMLDOMNODE(&This->element.node), riid, ppv);
55 static ULONG WINAPI HTMLStyleElement_AddRef(IHTMLStyleElement *iface)
57 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
59 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
62 static ULONG WINAPI HTMLStyleElement_Release(IHTMLStyleElement *iface)
64 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
66 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
69 static HRESULT WINAPI HTMLStyleElement_GetTypeInfoCount(IHTMLStyleElement *iface, UINT *pctinfo)
71 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), 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(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
82 static HRESULT WINAPI HTMLStyleElement_GetIDsOfNames(IHTMLStyleElement *iface, REFIID riid,
83 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
85 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
86 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
89 static HRESULT WINAPI HTMLStyleElement_Invoke(IHTMLStyleElement *iface, DISPID dispIdMember,
90 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
91 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
93 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
94 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
95 pVarResult, pExcepInfo, puArgErr);
98 static HRESULT WINAPI HTMLStyleElement_put_type(IHTMLStyleElement *iface, BSTR v)
100 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
104 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
106 nsAString_InitDepend(&type_str, v);
107 nsres = nsIDOMHTMLStyleElement_SetType(This->nsstyle, &type_str);
108 nsAString_Finish(&type_str);
109 if(NS_FAILED(nsres)) {
110 ERR("SetType failed: %08x\n", nsres);
117 static HRESULT WINAPI HTMLStyleElement_get_type(IHTMLStyleElement *iface, BSTR *p)
119 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
123 TRACE("(%p)->(%p)\n", This, p);
125 nsAString_Init(&nsstr, NULL);
126 nsres = nsIDOMHTMLStyleElement_GetType(This->nsstyle, &nsstr);
127 return return_nsstr(nsres, &nsstr, p);
130 static HRESULT WINAPI HTMLStyleElement_get_readyState(IHTMLStyleElement *iface, BSTR *p)
132 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
133 FIXME("(%p)->(%p)\n", This, p);
137 static HRESULT WINAPI HTMLStyleElement_put_onreadystatechange(IHTMLStyleElement *iface, VARIANT v)
139 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
140 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
144 static HRESULT WINAPI HTMLStyleElement_get_onreadystatechange(IHTMLStyleElement *iface, VARIANT *p)
146 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
147 FIXME("(%p)->(%p)\n", This, p);
151 static HRESULT WINAPI HTMLStyleElement_put_onload(IHTMLStyleElement *iface, VARIANT v)
153 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
154 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
158 static HRESULT WINAPI HTMLStyleElement_get_onload(IHTMLStyleElement *iface, VARIANT *p)
160 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
161 FIXME("(%p)->(%p)\n", This, p);
165 static HRESULT WINAPI HTMLStyleElement_put_onerror(IHTMLStyleElement *iface, VARIANT v)
167 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
168 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
172 static HRESULT WINAPI HTMLStyleElement_get_onerror(IHTMLStyleElement *iface, VARIANT *p)
174 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
175 FIXME("(%p)->(%p)\n", This, p);
179 static HRESULT WINAPI HTMLStyleElement_get_styleSheet(IHTMLStyleElement *iface, IHTMLStyleSheet **p)
181 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
182 FIXME("(%p)->(%p)\n", This, p);
186 static HRESULT WINAPI HTMLStyleElement_put_disabled(IHTMLStyleElement *iface, VARIANT_BOOL v)
188 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
189 FIXME("(%p)->(%x)\n", This, v);
193 static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VARIANT_BOOL *p)
195 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
196 FIXME("(%p)->(%p)\n", This, p);
200 static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
202 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
206 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
208 nsAString_InitDepend(&media_str, v);
209 nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
210 nsAString_Finish(&media_str);
211 if(NS_FAILED(nsres)) {
212 ERR("SetMedia failed: %08x\n", nsres);
219 static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
221 HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
225 TRACE("(%p)->(%p)\n", This, p);
227 nsAString_Init(&nsstr, NULL);
228 nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
229 return return_nsstr(nsres, &nsstr, p);
232 #undef HTMLSTYLE_THIS
234 static const IHTMLStyleElementVtbl HTMLStyleElementVtbl = {
235 HTMLStyleElement_QueryInterface,
236 HTMLStyleElement_AddRef,
237 HTMLStyleElement_Release,
238 HTMLStyleElement_GetTypeInfoCount,
239 HTMLStyleElement_GetTypeInfo,
240 HTMLStyleElement_GetIDsOfNames,
241 HTMLStyleElement_Invoke,
242 HTMLStyleElement_put_type,
243 HTMLStyleElement_get_type,
244 HTMLStyleElement_get_readyState,
245 HTMLStyleElement_put_onreadystatechange,
246 HTMLStyleElement_get_onreadystatechange,
247 HTMLStyleElement_put_onload,
248 HTMLStyleElement_get_onload,
249 HTMLStyleElement_put_onerror,
250 HTMLStyleElement_get_onerror,
251 HTMLStyleElement_get_styleSheet,
252 HTMLStyleElement_put_disabled,
253 HTMLStyleElement_get_disabled,
254 HTMLStyleElement_put_media,
255 HTMLStyleElement_get_media
258 #define HTMLSTYLE_NODE_THIS(iface) DEFINE_THIS2(HTMLStyleElement, element.node, iface)
260 static HRESULT HTMLStyleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
262 HTMLStyleElement *This = HTMLSTYLE_NODE_THIS(iface);
264 if(IsEqualGUID(&IID_IUnknown, riid)) {
265 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
266 *ppv = HTMLSTYLE(This);
267 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
268 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
269 *ppv = HTMLSTYLE(This);
270 }else if(IsEqualGUID(&IID_IHTMLStyleElement, riid)) {
271 TRACE("(%p)->(IID_IHTMLStyleElement %p)\n", This, ppv);
272 *ppv = HTMLSTYLE(This);
274 return HTMLElement_QI(&This->element.node, riid, ppv);
277 IUnknown_AddRef((IUnknown*)*ppv);
281 static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
283 HTMLStyleElement *This = HTMLSTYLE_NODE_THIS(iface);
286 nsIDOMHTMLStyleElement_Release(This->nsstyle);
288 HTMLElement_destructor(&This->element.node);
291 #undef HTMLSTYLE_NODE_THIS
293 static const NodeImplVtbl HTMLStyleElementImplVtbl = {
295 HTMLStyleElement_destructor,
299 static const tid_t HTMLStyleElement_iface_tids[] = {
301 IHTMLStyleElement_tid,
304 static dispex_static_data_t HTMLStyleElement_dispex = {
306 DispHTMLStyleElement_tid,
308 HTMLStyleElement_iface_tids
311 HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
313 HTMLStyleElement *ret;
316 ret = heap_alloc_zero(sizeof(*ret));
318 return E_OUTOFMEMORY;
320 ret->lpIHTMLStyleElementVtbl = &HTMLStyleElementVtbl;
321 ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
323 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
324 if(NS_FAILED(nsres)) {
325 ERR("Could not get nsIDOMHTMLStyleElement iface: %08x\n", nsres);
330 HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
331 *elem = &ret->element;