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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 IHTMLScriptElement IHTMLScriptElement_iface;
40 nsIDOMHTMLScriptElement *nsscript;
43 static inline HTMLScriptElement *impl_from_IHTMLScriptElement(IHTMLScriptElement *iface)
45 return CONTAINING_RECORD(iface, HTMLScriptElement, IHTMLScriptElement_iface);
48 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
49 REFIID riid, void **ppv)
51 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
58 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
65 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
72 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
84 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
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 = impl_from_IHTMLScriptElement(iface);
98 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
99 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
102 static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
104 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
105 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
109 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
111 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
115 TRACE("(%p)->(%p)\n", This, p);
117 nsAString_Init(&src_str, NULL);
118 nsres = nsIDOMHTMLScriptElement_GetSrc(This->nsscript, &src_str);
119 return return_nsstr(nsres, &src_str, p);
122 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
124 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
125 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
129 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
131 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
132 FIXME("(%p)->(%p)\n", This, p);
136 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
138 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
139 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
143 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
145 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
146 FIXME("(%p)->(%p)\n", This, p);
150 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
152 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
153 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
157 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
159 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
160 FIXME("(%p)->(%p)\n", This, p);
164 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
166 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
170 TRACE("(%p)->(%x)\n", This, v);
172 nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
181 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
183 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
184 cpp_bool defer = FALSE;
187 TRACE("(%p)->(%p)\n", This, p);
192 nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
193 if(NS_FAILED(nsres)) {
194 ERR("GetSrc failed: %08x\n", nsres);
197 *p = defer ? VARIANT_TRUE : VARIANT_FALSE;
199 TRACE("*p = %d\n", *p);
203 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
205 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
206 FIXME("(%p)->(%p)\n", This, p);
210 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
212 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
213 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
217 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
219 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
220 FIXME("(%p)->(%p)\n", This, p);
224 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
226 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
227 nsAString nstype_str;
230 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
232 nsAString_Init(&nstype_str, v);
233 nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str);
234 if (NS_FAILED(nsres))
235 ERR("SetType failed: %08x\n", nsres);
236 nsAString_Finish (&nstype_str);
241 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
243 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
244 nsAString nstype_str;
247 TRACE("(%p)->(%p)\n", This, p);
249 nsAString_Init(&nstype_str, NULL);
250 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
251 return return_nsstr(nsres, &nstype_str, p);
254 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
255 HTMLScriptElement_QueryInterface,
256 HTMLScriptElement_AddRef,
257 HTMLScriptElement_Release,
258 HTMLScriptElement_GetTypeInfoCount,
259 HTMLScriptElement_GetTypeInfo,
260 HTMLScriptElement_GetIDsOfNames,
261 HTMLScriptElement_Invoke,
262 HTMLScriptElement_put_src,
263 HTMLScriptElement_get_src,
264 HTMLScriptElement_put_htmlFor,
265 HTMLScriptElement_get_htmlFor,
266 HTMLScriptElement_put_event,
267 HTMLScriptElement_get_event,
268 HTMLScriptElement_put_text,
269 HTMLScriptElement_get_text,
270 HTMLScriptElement_put_defer,
271 HTMLScriptElement_get_defer,
272 HTMLScriptElement_get_readyState,
273 HTMLScriptElement_put_onerror,
274 HTMLScriptElement_get_onerror,
275 HTMLScriptElement_put_type,
276 HTMLScriptElement_get_type
279 static inline HTMLScriptElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
281 return CONTAINING_RECORD(iface, HTMLScriptElement, element.node);
284 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
286 HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
290 if(IsEqualGUID(&IID_IUnknown, riid)) {
291 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
292 *ppv = &This->IHTMLScriptElement_iface;
293 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
294 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
295 *ppv = &This->IHTMLScriptElement_iface;
296 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
297 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
298 *ppv = &This->IHTMLScriptElement_iface;
302 IUnknown_AddRef((IUnknown*)*ppv);
306 return HTMLElement_QI(&This->element.node, riid, ppv);
309 static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
311 HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
313 return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, p);
316 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
317 HTMLScriptElement_QI,
318 HTMLElement_destructor,
320 HTMLElement_get_attr_col,
327 HTMLScriptElement_get_readystate
330 static const tid_t HTMLScriptElement_iface_tids[] = {
332 IHTMLScriptElement_tid,
336 static dispex_static_data_t HTMLScriptElement_dispex = {
338 DispHTMLScriptElement_tid,
340 HTMLScriptElement_iface_tids
343 HRESULT HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
345 HTMLScriptElement *ret;
348 ret = heap_alloc_zero(sizeof(HTMLScriptElement));
350 return E_OUTOFMEMORY;
352 ret->IHTMLScriptElement_iface.lpVtbl = &HTMLScriptElementVtbl;
353 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
355 HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
357 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
359 /* Share nsscript reference with nsnode */
360 assert(nsres == NS_OK && (nsIDOMNode*)ret->nsscript == ret->element.node.nsnode);
361 nsIDOMNode_Release(ret->element.node.nsnode);
363 *elem = &ret->element;