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(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
55 static ULONG WINAPI
HTMLScriptElement_AddRef(IHTMLScriptElement
*iface
)
57 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
59 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
62 static ULONG WINAPI
HTMLScriptElement_Release(IHTMLScriptElement
*iface
)
64 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
66 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
69 static HRESULT WINAPI
HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement
*iface
, UINT
*pctinfo
)
71 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, 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(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
83 static HRESULT WINAPI
HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement
*iface
, REFIID riid
,
84 LPOLESTR
*rgszNames
, UINT cNames
,
85 LCID lcid
, DISPID
*rgDispId
)
87 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
88 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
89 cNames
, lcid
, rgDispId
);
92 static HRESULT WINAPI
HTMLScriptElement_Invoke(IHTMLScriptElement
*iface
, DISPID dispIdMember
,
93 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
94 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
96 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
97 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
98 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
101 static HRESULT WINAPI
HTMLScriptElement_put_src(IHTMLScriptElement
*iface
, BSTR v
)
103 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
104 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
108 static HRESULT WINAPI
HTMLScriptElement_get_src(IHTMLScriptElement
*iface
, BSTR
*p
)
110 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
114 TRACE("(%p)->(%p)\n", This
, p
);
116 nsAString_Init(&src_str
, NULL
);
117 nsres
= nsIDOMHTMLScriptElement_GetSrc(This
->nsscript
, &src_str
);
118 return return_nsstr(nsres
, &src_str
, p
);
121 static HRESULT WINAPI
HTMLScriptElement_put_htmlFor(IHTMLScriptElement
*iface
, BSTR v
)
123 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
124 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
128 static HRESULT WINAPI
HTMLScriptElement_get_htmlFor(IHTMLScriptElement
*iface
, BSTR
*p
)
130 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
131 FIXME("(%p)->(%p)\n", This
, p
);
135 static HRESULT WINAPI
HTMLScriptElement_put_event(IHTMLScriptElement
*iface
, BSTR v
)
137 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
138 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
142 static HRESULT WINAPI
HTMLScriptElement_get_event(IHTMLScriptElement
*iface
, BSTR
*p
)
144 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
145 FIXME("(%p)->(%p)\n", This
, p
);
149 static HRESULT WINAPI
HTMLScriptElement_put_text(IHTMLScriptElement
*iface
, BSTR v
)
151 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
152 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
156 static HRESULT WINAPI
HTMLScriptElement_get_text(IHTMLScriptElement
*iface
, BSTR
*p
)
158 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
159 FIXME("(%p)->(%p)\n", This
, p
);
163 static HRESULT WINAPI
HTMLScriptElement_put_defer(IHTMLScriptElement
*iface
, VARIANT_BOOL v
)
165 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
169 TRACE("(%p)->(%x)\n", This
, v
);
171 nsres
= nsIDOMHTMLScriptElement_SetDefer(This
->nsscript
, v
!= VARIANT_FALSE
);
180 static HRESULT WINAPI
HTMLScriptElement_get_defer(IHTMLScriptElement
*iface
, VARIANT_BOOL
*p
)
182 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
183 PRBool defer
= FALSE
;
186 TRACE("(%p)->(%p)\n", This
, p
);
191 nsres
= nsIDOMHTMLScriptElement_GetDefer(This
->nsscript
, &defer
);
192 if(NS_FAILED(nsres
)) {
193 ERR("GetSrc failed: %08x\n", nsres
);
196 *p
= defer
? VARIANT_TRUE
: VARIANT_FALSE
;
198 TRACE("*p = %d\n", *p
);
202 static HRESULT WINAPI
HTMLScriptElement_get_readyState(IHTMLScriptElement
*iface
, BSTR
*p
)
204 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
205 FIXME("(%p)->(%p)\n", This
, p
);
209 static HRESULT WINAPI
HTMLScriptElement_put_onerror(IHTMLScriptElement
*iface
, VARIANT v
)
211 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
212 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
216 static HRESULT WINAPI
HTMLScriptElement_get_onerror(IHTMLScriptElement
*iface
, VARIANT
*p
)
218 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
219 FIXME("(%p)->(%p)\n", This
, p
);
223 static HRESULT WINAPI
HTMLScriptElement_put_type(IHTMLScriptElement
*iface
, BSTR v
)
225 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
226 nsAString nstype_str
;
229 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
231 nsAString_Init(&nstype_str
, v
);
232 nsres
= nsIDOMHTMLScriptElement_SetType(This
->nsscript
, &nstype_str
);
233 if (NS_FAILED(nsres
))
234 ERR("SetType failed: %08x\n", nsres
);
235 nsAString_Finish (&nstype_str
);
240 static HRESULT WINAPI
HTMLScriptElement_get_type(IHTMLScriptElement
*iface
, BSTR
*p
)
242 HTMLScriptElement
*This
= impl_from_IHTMLScriptElement(iface
);
243 const PRUnichar
*nstype
;
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
);
252 ERR("GetType failed: %08x\n", nsres
);
254 nsAString_GetData(&nstype_str
, &nstype
);
255 *p
= *nstype
? SysAllocString(nstype
) : NULL
;
256 nsAString_Finish(&nstype_str
);
261 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl
= {
262 HTMLScriptElement_QueryInterface
,
263 HTMLScriptElement_AddRef
,
264 HTMLScriptElement_Release
,
265 HTMLScriptElement_GetTypeInfoCount
,
266 HTMLScriptElement_GetTypeInfo
,
267 HTMLScriptElement_GetIDsOfNames
,
268 HTMLScriptElement_Invoke
,
269 HTMLScriptElement_put_src
,
270 HTMLScriptElement_get_src
,
271 HTMLScriptElement_put_htmlFor
,
272 HTMLScriptElement_get_htmlFor
,
273 HTMLScriptElement_put_event
,
274 HTMLScriptElement_get_event
,
275 HTMLScriptElement_put_text
,
276 HTMLScriptElement_get_text
,
277 HTMLScriptElement_put_defer
,
278 HTMLScriptElement_get_defer
,
279 HTMLScriptElement_get_readyState
,
280 HTMLScriptElement_put_onerror
,
281 HTMLScriptElement_get_onerror
,
282 HTMLScriptElement_put_type
,
283 HTMLScriptElement_get_type
286 static inline HTMLScriptElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
288 return CONTAINING_RECORD(iface
, HTMLScriptElement
, element
.node
);
291 static HRESULT
HTMLScriptElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
293 HTMLScriptElement
*This
= impl_from_HTMLDOMNode(iface
);
297 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
298 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
299 *ppv
= &This
->IHTMLScriptElement_iface
;
300 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
301 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
302 *ppv
= &This
->IHTMLScriptElement_iface
;
303 }else if(IsEqualGUID(&IID_IHTMLScriptElement
, riid
)) {
304 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This
, ppv
);
305 *ppv
= &This
->IHTMLScriptElement_iface
;
309 IUnknown_AddRef((IUnknown
*)*ppv
);
313 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
316 static void HTMLScriptElement_destructor(HTMLDOMNode
*iface
)
318 HTMLScriptElement
*This
= impl_from_HTMLDOMNode(iface
);
319 HTMLElement_destructor(&This
->element
.node
);
322 static HRESULT
HTMLScriptElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
324 HTMLScriptElement
*This
= impl_from_HTMLDOMNode(iface
);
326 return IHTMLScriptElement_get_readyState(&This
->IHTMLScriptElement_iface
, p
);
329 static const NodeImplVtbl HTMLScriptElementImplVtbl
= {
330 HTMLScriptElement_QI
,
331 HTMLScriptElement_destructor
,
338 HTMLScriptElement_get_readystate
341 static const tid_t HTMLScriptElement_iface_tids
[] = {
343 IHTMLScriptElement_tid
,
347 static dispex_static_data_t HTMLScriptElement_dispex
= {
349 DispHTMLScriptElement_tid
,
351 HTMLScriptElement_iface_tids
354 HRESULT
HTMLScriptElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
356 HTMLScriptElement
*ret
;
359 ret
= heap_alloc_zero(sizeof(HTMLScriptElement
));
361 return E_OUTOFMEMORY
;
363 ret
->IHTMLScriptElement_iface
.lpVtbl
= &HTMLScriptElementVtbl
;
364 ret
->element
.node
.vtbl
= &HTMLScriptElementImplVtbl
;
366 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLScriptElement
, (void**)&ret
->nsscript
);
367 if(NS_FAILED(nsres
)) {
368 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres
);
373 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLScriptElement_dispex
);
375 *elem
= &ret
->element
;