winex11: Store the DC bounds rectangle as a pointer.
[wine/multimedia.git] / dlls / mshtml / htmlscript.c
blob376db7b39b25de5d7c2080b38531eb3c76533f78
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 IHTMLScriptElement IHTMLScriptElement_iface;
39 nsIDOMHTMLScriptElement *nsscript;
40 } HTMLScriptElement;
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,
80 ppTInfo);
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));
105 return E_NOTIMPL;
108 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
110 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
111 nsAString src_str;
112 nsresult nsres;
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));
125 return E_NOTIMPL;
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);
132 return E_NOTIMPL;
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));
139 return E_NOTIMPL;
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);
146 return E_NOTIMPL;
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));
153 return E_NOTIMPL;
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);
160 return E_NOTIMPL;
163 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
165 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
166 HRESULT hr = S_OK;
167 nsresult nsres;
169 TRACE("(%p)->(%x)\n", This, v);
171 nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
172 if(NS_FAILED(nsres))
174 hr = E_FAIL;
177 return hr;
180 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
182 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
183 cpp_bool defer = FALSE;
184 nsresult nsres;
186 TRACE("(%p)->(%p)\n", This, p);
188 if(!p)
189 return E_INVALIDARG;
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);
199 return S_OK;
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);
206 return E_NOTIMPL;
209 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
211 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
212 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
213 return E_NOTIMPL;
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);
220 return E_NOTIMPL;
223 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
225 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
226 nsAString nstype_str;
227 nsresult nsres;
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);
237 return S_OK;
240 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
242 HTMLScriptElement *This = impl_from_IHTMLScriptElement(iface);
243 nsAString nstype_str;
244 nsresult nsres;
246 TRACE("(%p)->(%p)\n", This, p);
248 nsAString_Init(&nstype_str, NULL);
249 nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
250 return return_nsstr(nsres, &nstype_str, p);
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 static inline HTMLScriptElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
280 return CONTAINING_RECORD(iface, HTMLScriptElement, element.node);
283 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
285 HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
287 *ppv = NULL;
289 if(IsEqualGUID(&IID_IUnknown, riid)) {
290 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
291 *ppv = &This->IHTMLScriptElement_iface;
292 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
293 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
294 *ppv = &This->IHTMLScriptElement_iface;
295 }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
296 TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
297 *ppv = &This->IHTMLScriptElement_iface;
300 if(*ppv) {
301 IUnknown_AddRef((IUnknown*)*ppv);
302 return S_OK;
305 return HTMLElement_QI(&This->element.node, riid, ppv);
308 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
310 HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
311 HTMLElement_destructor(&This->element.node);
314 static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
316 HTMLScriptElement *This = impl_from_HTMLDOMNode(iface);
318 return IHTMLScriptElement_get_readyState(&This->IHTMLScriptElement_iface, p);
321 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
322 HTMLScriptElement_QI,
323 HTMLScriptElement_destructor,
324 HTMLElement_clone,
325 HTMLElement_get_attr_col,
326 NULL,
327 NULL,
328 NULL,
329 NULL,
330 NULL,
331 NULL,
332 HTMLScriptElement_get_readystate
335 static const tid_t HTMLScriptElement_iface_tids[] = {
336 HTMLELEMENT_TIDS,
337 IHTMLScriptElement_tid,
341 static dispex_static_data_t HTMLScriptElement_dispex = {
342 NULL,
343 DispHTMLScriptElement_tid,
344 NULL,
345 HTMLScriptElement_iface_tids
348 HRESULT HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
350 HTMLScriptElement *ret;
351 nsresult nsres;
353 ret = heap_alloc_zero(sizeof(HTMLScriptElement));
354 if(!ret)
355 return E_OUTOFMEMORY;
357 ret->IHTMLScriptElement_iface.lpVtbl = &HTMLScriptElementVtbl;
358 ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
360 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
361 if(NS_FAILED(nsres)) {
362 ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
363 heap_free(ret);
364 return E_FAIL;
367 HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
369 *elem = &ret->element;
370 return S_OK;