wined3d: Store the current GLSL program in the backend's private data.
[wine/hacks.git] / dlls / mshtml / htmlscript.c
blob36512adc98c42789707fc4777f4126fb49360cf9
1 /*
2 * Copyright 2008 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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct {
35 HTMLElement element;
37 const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl;
39 nsIDOMHTMLScriptElement *nsscript;
40 } HTMLScriptElement;
42 #define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl)
44 #define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface)
46 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
47 REFIID riid, void **ppv)
49 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
54 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
56 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
61 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
63 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
68 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
70 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
71 FIXME("(%p)->(%p)\n", This, pctinfo);
72 return E_NOTIMPL;
75 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
79 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
80 return E_NOTIMPL;
83 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
88 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
89 lcid, rgDispId);
90 return E_NOTIMPL;
93 static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
98 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
100 return E_NOTIMPL;
103 static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
105 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
106 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
112 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
113 FIXME("(%p)->(%p)\n", This, p);
114 return E_NOTIMPL;
117 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
119 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
120 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
121 return E_NOTIMPL;
124 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
126 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
127 FIXME("(%p)->(%p)\n", This, p);
128 return E_NOTIMPL;
131 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
133 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
134 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
135 return E_NOTIMPL;
138 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
140 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
141 FIXME("(%p)->(%p)\n", This, p);
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
147 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
148 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
149 return E_NOTIMPL;
152 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
154 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
155 FIXME("(%p)->(%p)\n", This, p);
156 return E_NOTIMPL;
159 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
161 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
162 FIXME("(%p)->(%x)\n", This, v);
163 return E_NOTIMPL;
166 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
168 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
169 FIXME("(%p)->(%p)\n", This, p);
170 return E_NOTIMPL;
173 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
175 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
176 FIXME("(%p)->(%p)\n", This, p);
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
182 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
183 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
189 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
190 FIXME("(%p)->(%p)\n", This, p);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
196 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
197 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
198 return E_NOTIMPL;
201 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
203 HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
204 const PRUnichar *nstype;
205 nsAString nstype_str;
206 nsresult nsres;
208 TRACE("(%p)->(%p)\n", This, p);
210 nsAString_Init(&nstype_str, NULL);
211 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
212 if(NS_FAILED(nsres))
213 ERR("GetType failed: %08x\n", nsres);
215 nsAString_GetData(&nstype_str, &nstype);
216 *p = *nstype ? SysAllocString(nstype) : NULL;
217 nsAString_Finish(&nstype_str);
219 return S_OK;
222 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
223 HTMLScriptElement_QueryInterface,
224 HTMLScriptElement_AddRef,
225 HTMLScriptElement_Release,
226 HTMLScriptElement_GetTypeInfoCount,
227 HTMLScriptElement_GetTypeInfo,
228 HTMLScriptElement_GetIDsOfNames,
229 HTMLScriptElement_Invoke,
230 HTMLScriptElement_put_src,
231 HTMLScriptElement_get_src,
232 HTMLScriptElement_put_htmlFor,
233 HTMLScriptElement_get_htmlFor,
234 HTMLScriptElement_put_event,
235 HTMLScriptElement_get_event,
236 HTMLScriptElement_put_text,
237 HTMLScriptElement_get_text,
238 HTMLScriptElement_put_defer,
239 HTMLScriptElement_get_defer,
240 HTMLScriptElement_get_readyState,
241 HTMLScriptElement_put_onerror,
242 HTMLScriptElement_get_onerror,
243 HTMLScriptElement_put_type,
244 HTMLScriptElement_get_type
247 #undef HTMLSCRIPT_THIS
249 #define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface)
251 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
253 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
255 *ppv = NULL;
257 if(IsEqualGUID(&IID_IUnknown, riid)) {
258 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
259 *ppv = HTMLSCRIPT(This);
260 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
261 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
262 *ppv = HTMLSCRIPT(This);
263 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
264 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
265 *ppv = HTMLSCRIPT(This);
268 if(*ppv) {
269 IUnknown_AddRef((IUnknown*)*ppv);
270 return S_OK;
273 return HTMLElement_QI(&This->element.node, riid, ppv);
276 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
278 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
279 HTMLElement_destructor(&This->element.node);
282 #undef HTMLSCRIPT_NODE_THIS
284 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
285 HTMLScriptElement_QI,
286 HTMLScriptElement_destructor
289 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem)
291 HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement));
292 nsresult nsres;
294 HTMLElement_Init(&ret->element);
296 ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
297 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
299 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
300 if(NS_FAILED(nsres))
301 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
303 return &ret->element;