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
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 IHTMLScriptElement IHTMLScriptElement_iface;
39 nsIDOMHTMLScriptElement *nsscript;
42 static inline HTMLScriptElement *impl_from_IHTMLScriptElement(IHTMLScriptElement *iface)
44 return CONTAINING_RECORD(iface, HTMLScriptElement, IHTMLScriptElement_iface);
47 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
48 REFIID riid, void **ppv)
50 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
52 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
55 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
57 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
59 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
62 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
64 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
66 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
69 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
71 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
75 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
79 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
82 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
83 LPOLESTR *rgszNames, UINT cNames,
84 LCID lcid, DISPID *rgDispId)
86 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
87 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
90 static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
91 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
92 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
94 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
95 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
96 pVarResult, pExcepInfo, puArgErr);
99 static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
101 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
102 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
106 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
108 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
109 FIXME("(%p)->(%p)\n", This, p);
113 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
115 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
116 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
120 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
122 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
123 FIXME("(%p)->(%p)\n", This, p);
127 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
129 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
130 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
134 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
136 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
137 FIXME("(%p)->(%p)\n", This, p);
141 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
143 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
144 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
148 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
150 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
151 FIXME("(%p)->(%p)\n", This, p);
155 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
157 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
161 TRACE("(%p)->(%x)\n", This, v);
163 nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
172 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
174 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
175 PRBool defer = FALSE;
178 TRACE("(%p)->(%p)\n", This, p);
183 nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
184 if(NS_FAILED(nsres)) {
185 ERR("GetSrc failed: %08x\n", nsres);
188 *p = defer ? VARIANT_TRUE : VARIANT_FALSE;
190 TRACE("*p = %d\n", *p);
194 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
196 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
197 FIXME("(%p)->(%p)\n", This, p);
201 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
203 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
204 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
208 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
210 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
211 FIXME("(%p)->(%p)\n", This, p);
215 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
217 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
218 nsAString nstype_str;
221 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
223 nsAString_Init(&nstype_str, v);
224 nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str);
225 if (NS_FAILED(nsres))
226 ERR("SetType failed: %08x\n", nsres);
227 nsAString_Finish (&nstype_str);
232 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
234 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
235 const PRUnichar *nstype;
236 nsAString nstype_str;
239 TRACE("(%p)->(%p)\n", This, p);
241 nsAString_Init(&nstype_str, NULL);
242 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
244 ERR("GetType failed: %08x\n", nsres);
246 nsAString_GetData(&nstype_str, &nstype);
247 *p = *nstype ? SysAllocString(nstype) : NULL;
248 nsAString_Finish(&nstype_str);
253 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
254 HTMLScriptElement_QueryInterface,
255 HTMLScriptElement_AddRef,
256 HTMLScriptElement_Release,
257 HTMLScriptElement_GetTypeInfoCount,
258 HTMLScriptElement_GetTypeInfo,
259 HTMLScriptElement_GetIDsOfNames,
260 HTMLScriptElement_Invoke,
261 HTMLScriptElement_put_src,
262 HTMLScriptElement_get_src,
263 HTMLScriptElement_put_htmlFor,
264 HTMLScriptElement_get_htmlFor,
265 HTMLScriptElement_put_event,
266 HTMLScriptElement_get_event,
267 HTMLScriptElement_put_text,
268 HTMLScriptElement_get_text,
269 HTMLScriptElement_put_defer,
270 HTMLScriptElement_get_defer,
271 HTMLScriptElement_get_readyState,
272 HTMLScriptElement_put_onerror,
273 HTMLScriptElement_get_onerror,
274 HTMLScriptElement_put_type,
275 HTMLScriptElement_get_type
278 #define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface)
280 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
282 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
286 if(IsEqualGUID(&IID_IUnknown, riid)) {
287 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
288 *ppv = &This->IHTMLScriptElement_iface;
289 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
290 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
291 *ppv = &This->IHTMLScriptElement_iface;
292 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
293 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
294 *ppv = &This->IHTMLScriptElement_iface;
298 IUnknown_AddRef((IUnknown*)*ppv);
302 return HTMLElement_QI(&This->element.node, riid, ppv);
305 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
307 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
308 HTMLElement_destructor(&This->element.node);
311 static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
313 HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
315 return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, p);
318 #undef HTMLSCRIPT_NODE_THIS
320 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
321 HTMLScriptElement_QI,
322 HTMLScriptElement_destructor,
329 HTMLScriptElement_get_readystate
332 static const tid_t HTMLScriptElement_iface_tids[] = {
334 IHTMLScriptElement_tid,
338 static dispex_static_data_t HTMLScriptElement_dispex = {
340 DispHTMLScriptElement_tid,
342 HTMLScriptElement_iface_tids
345 HRESULT HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
347 HTMLScriptElement *ret;
350 ret = heap_alloc_zero(sizeof(HTMLScriptElement));
352 return E_OUTOFMEMORY;
354 ret->IHTMLScriptElement_iface.lpVtbl = &HTMLScriptElementVtbl;
355 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
357 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
358 if(NS_FAILED(nsres)) {
359 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
364 HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
366 *elem = &ret->element;