mlang/tests: Fix a pointer casting warning on 64-bit.
[wine/testsucceed.git] / dlls / mshtml / htmlimg.c
blobe5c03722068427f0d9e9433de03245f377b779ba
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 IHTMLImgElementVtbl *lpHTMLImgElementVtbl;
39 nsIDOMHTMLImageElement *nsimg;
40 } HTMLImgElement;
42 #define HTMLIMG(x) ((IHTMLImgElement*) &(x)->lpHTMLImgElementVtbl)
44 #define HTMLIMG_THIS(iface) DEFINE_THIS(HTMLImgElement, HTMLImgElement, iface)
46 static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
48 HTMLImgElement *This = HTMLIMG_THIS(iface);
50 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
53 static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface)
55 HTMLImgElement *This = HTMLIMG_THIS(iface);
57 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
60 static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
62 HTMLImgElement *This = HTMLIMG_THIS(iface);
64 return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
67 static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo)
69 HTMLImgElement *This = HTMLIMG_THIS(iface);
70 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
73 static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo,
74 LCID lcid, ITypeInfo **ppTInfo)
76 HTMLImgElement *This = HTMLIMG_THIS(iface);
77 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
80 static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid,
81 LPOLESTR *rgszNames, UINT cNames,
82 LCID lcid, DISPID *rgDispId)
84 HTMLImgElement *This = HTMLIMG_THIS(iface);
85 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
88 static HRESULT WINAPI HTMLImgElement_Invoke(IHTMLImgElement *iface, DISPID dispIdMember,
89 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
90 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
92 HTMLImgElement *This = HTMLIMG_THIS(iface);
93 return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
94 pVarResult, pExcepInfo, puArgErr);
97 static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v)
99 HTMLImgElement *This = HTMLIMG_THIS(iface);
100 FIXME("(%p)->(%x)\n", This, v);
101 return E_NOTIMPL;
104 static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
106 HTMLImgElement *This = HTMLIMG_THIS(iface);
107 FIXME("(%p)->(%p)\n", This, p);
108 return E_NOTIMPL;
111 static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
113 HTMLImgElement *This = HTMLIMG_THIS(iface);
114 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
115 return E_NOTIMPL;
118 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
120 HTMLImgElement *This = HTMLIMG_THIS(iface);
121 FIXME("(%p)->(%p)\n", This, p);
122 return E_NOTIMPL;
125 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
127 HTMLImgElement *This = HTMLIMG_THIS(iface);
128 FIXME("(%p)->(%p)\n", This, p);
129 return E_NOTIMPL;
132 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
134 HTMLImgElement *This = HTMLIMG_THIS(iface);
135 FIXME("(%p)->(%p)\n", This, p);
136 return E_NOTIMPL;
139 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
141 HTMLImgElement *This = HTMLIMG_THIS(iface);
142 FIXME("(%p)->(%p)\n", This, p);
143 return E_NOTIMPL;
146 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
148 HTMLImgElement *This = HTMLIMG_THIS(iface);
149 FIXME("(%p)->(%p)\n", This, p);
150 return E_NOTIMPL;
153 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
155 HTMLImgElement *This = HTMLIMG_THIS(iface);
156 FIXME("(%p)->(%p)\n", This, p);
157 return E_NOTIMPL;
160 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
162 HTMLImgElement *This = HTMLIMG_THIS(iface);
163 FIXME("(%p)->(%p)\n", This, p);
164 return E_NOTIMPL;
167 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
169 HTMLImgElement *This = HTMLIMG_THIS(iface);
170 FIXME("(%p)->(%p)\n", This, p);
171 return E_NOTIMPL;
174 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
176 HTMLImgElement *This = HTMLIMG_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
178 return E_NOTIMPL;
181 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
183 HTMLImgElement *This = HTMLIMG_THIS(iface);
184 FIXME("(%p)->()\n", This);
185 return E_NOTIMPL;
188 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
190 HTMLImgElement *This = HTMLIMG_THIS(iface);
191 FIXME("(%p)->(%p)\n", This, p);
192 return E_NOTIMPL;
195 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, long v)
197 HTMLImgElement *This = HTMLIMG_THIS(iface);
198 FIXME("(%p)->(%ld)\n", This, v);
199 return E_NOTIMPL;
202 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, long *p)
204 HTMLImgElement *This = HTMLIMG_THIS(iface);
205 FIXME("(%p)->(%p)\n", This, p);
206 return E_NOTIMPL;
209 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, long v)
211 HTMLImgElement *This = HTMLIMG_THIS(iface);
212 FIXME("(%p)->(%ld)\n", This, v);
213 return E_NOTIMPL;
216 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, long *p)
218 HTMLImgElement *This = HTMLIMG_THIS(iface);
219 FIXME("(%p)->(%p)\n", This, p);
220 return E_NOTIMPL;
223 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
225 HTMLImgElement *This = HTMLIMG_THIS(iface);
226 nsAString alt_str;
227 nsresult nsres;
229 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
231 nsAString_Init(&alt_str, v);
232 nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
233 nsAString_Finish(&alt_str);
234 if(NS_FAILED(nsres))
235 ERR("SetAlt failed: %08x\n", nsres);
237 return S_OK;
240 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
242 HTMLImgElement *This = HTMLIMG_THIS(iface);
243 nsAString alt_str;
244 nsresult nsres;
246 TRACE("(%p)->(%p)\n", This, p);
248 nsAString_Init(&alt_str, NULL);
249 nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
250 if(NS_SUCCEEDED(nsres)) {
251 const PRUnichar *alt;
253 nsAString_GetData(&alt_str, &alt);
254 *p = *alt ? SysAllocString(alt) : NULL;
255 }else {
256 ERR("GetAlt failed: %08x\n", nsres);
258 nsAString_Finish(&alt_str);
260 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
263 static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
265 HTMLImgElement *This = HTMLIMG_THIS(iface);
266 nsAString src_str;
267 nsresult nsres;
269 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
271 nsAString_Init(&src_str, v);
272 nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
273 nsAString_Finish(&src_str);
274 if(NS_FAILED(nsres))
275 ERR("SetSrc failed: %08x\n", nsres);
277 return NS_OK;
280 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
282 HTMLImgElement *This = HTMLIMG_THIS(iface);
283 const PRUnichar *src;
284 nsAString src_str;
285 nsresult nsres;
286 HRESULT hres;
288 TRACE("(%p)->(%p)\n", This, p);
290 nsAString_Init(&src_str, NULL);
291 nsres = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &src_str);
292 if(NS_FAILED(nsres)) {
293 ERR("GetSrc failed: %08x\n", nsres);
294 return E_FAIL;
297 nsAString_GetData(&src_str, &src);
298 hres = nsuri_to_url(src, p);
299 nsAString_Finish(&src_str);
301 return hres;
304 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
306 HTMLImgElement *This = HTMLIMG_THIS(iface);
307 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
308 return E_NOTIMPL;
311 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
313 HTMLImgElement *This = HTMLIMG_THIS(iface);
314 FIXME("(%p)->(%p)\n", This, p);
315 return E_NOTIMPL;
318 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
320 HTMLImgElement *This = HTMLIMG_THIS(iface);
321 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
322 return E_NOTIMPL;
325 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
327 HTMLImgElement *This = HTMLIMG_THIS(iface);
328 FIXME("(%p)->(%p)\n", This, p);
329 return E_NOTIMPL;
332 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
334 HTMLImgElement *This = HTMLIMG_THIS(iface);
335 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
336 return E_NOTIMPL;
339 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
341 HTMLImgElement *This = HTMLIMG_THIS(iface);
342 FIXME("(%p)->(%p)\n", This, p);
343 return E_NOTIMPL;
346 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
348 HTMLImgElement *This = HTMLIMG_THIS(iface);
349 FIXME("(%p)->(%p)\n", This, p);
350 return E_NOTIMPL;
353 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
355 HTMLImgElement *This = HTMLIMG_THIS(iface);
356 FIXME("(%p)->(%p)\n", This, p);
357 return E_NOTIMPL;
360 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
362 HTMLImgElement *This = HTMLIMG_THIS(iface);
363 FIXME("(%p)->()\n", This);
364 return E_NOTIMPL;
367 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
369 HTMLImgElement *This = HTMLIMG_THIS(iface);
370 FIXME("(%p)->(%p)\n", This, p);
371 return E_NOTIMPL;
374 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
376 HTMLImgElement *This = HTMLIMG_THIS(iface);
377 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
378 return E_NOTIMPL;
381 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
383 HTMLImgElement *This = HTMLIMG_THIS(iface);
384 FIXME("(%p)->(%p)\n", This, p);
385 return E_NOTIMPL;
388 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
390 HTMLImgElement *This = HTMLIMG_THIS(iface);
391 FIXME("(%p)->()\n", This);
392 return E_NOTIMPL;
395 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
397 HTMLImgElement *This = HTMLIMG_THIS(iface);
398 FIXME("(%p)->(%p)\n", This, p);
399 return E_NOTIMPL;
402 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
404 HTMLImgElement *This = HTMLIMG_THIS(iface);
405 FIXME("(%p)->()\n", This);
406 return E_NOTIMPL;
409 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
411 HTMLImgElement *This = HTMLIMG_THIS(iface);
412 FIXME("(%p)->(%p)\n", This, p);
413 return E_NOTIMPL;
416 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
418 HTMLImgElement *This = HTMLIMG_THIS(iface);
419 FIXME("(%p)->()\n", This);
420 return E_NOTIMPL;
423 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
425 HTMLImgElement *This = HTMLIMG_THIS(iface);
426 FIXME("(%p)->(%p)\n", This, p);
427 return E_NOTIMPL;
430 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
432 HTMLImgElement *This = HTMLIMG_THIS(iface);
433 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
434 return E_NOTIMPL;
437 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
439 HTMLImgElement *This = HTMLIMG_THIS(iface);
440 FIXME("(%p)->(%p)\n", This, p);
441 return E_NOTIMPL;
444 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, long v)
446 HTMLImgElement *This = HTMLIMG_THIS(iface);
447 FIXME("(%p)->(%ld)\n", This, v);
448 return E_NOTIMPL;
451 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, long *p)
453 HTMLImgElement *This = HTMLIMG_THIS(iface);
454 FIXME("(%p)->(%p)\n", This, p);
455 return E_NOTIMPL;
458 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, long v)
460 HTMLImgElement *This = HTMLIMG_THIS(iface);
461 FIXME("(%p)->(%ld)\n", This, v);
462 return E_NOTIMPL;
465 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, long *p)
467 HTMLImgElement *This = HTMLIMG_THIS(iface);
468 FIXME("(%p)->(%p)\n", This, p);
469 return E_NOTIMPL;
472 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
474 HTMLImgElement *This = HTMLIMG_THIS(iface);
475 FIXME("(%p)->()\n", This);
476 return E_NOTIMPL;
479 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
481 HTMLImgElement *This = HTMLIMG_THIS(iface);
482 FIXME("(%p)->(%p)\n", This, p);
483 return E_NOTIMPL;
486 #undef HTMLIMG_THIS
488 static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
489 HTMLImgElement_QueryInterface,
490 HTMLImgElement_AddRef,
491 HTMLImgElement_Release,
492 HTMLImgElement_GetTypeInfoCount,
493 HTMLImgElement_GetTypeInfo,
494 HTMLImgElement_GetIDsOfNames,
495 HTMLImgElement_Invoke,
496 HTMLImgElement_put_isMap,
497 HTMLImgElement_get_isMap,
498 HTMLImgElement_put_useMap,
499 HTMLImgElement_get_useMap,
500 HTMLImgElement_get_mimeType,
501 HTMLImgElement_get_fileSize,
502 HTMLImgElement_get_fileCreatedDate,
503 HTMLImgElement_get_fileModifiedDate,
504 HTMLImgElement_get_fileUpdatedDate,
505 HTMLImgElement_get_protocol,
506 HTMLImgElement_get_href,
507 HTMLImgElement_get_nameProp,
508 HTMLImgElement_put_border,
509 HTMLImgElement_get_border,
510 HTMLImgElement_put_vspace,
511 HTMLImgElement_get_vspace,
512 HTMLImgElement_put_hspace,
513 HTMLImgElement_get_hspace,
514 HTMLImgElement_put_alt,
515 HTMLImgElement_get_alt,
516 HTMLImgElement_put_src,
517 HTMLImgElement_get_src,
518 HTMLImgElement_put_lowsrc,
519 HTMLImgElement_get_lowsrc,
520 HTMLImgElement_put_vrml,
521 HTMLImgElement_get_vrml,
522 HTMLImgElement_put_dynsrc,
523 HTMLImgElement_get_dynsrc,
524 HTMLImgElement_get_readyState,
525 HTMLImgElement_get_complete,
526 HTMLImgElement_put_loop,
527 HTMLImgElement_get_loop,
528 HTMLImgElement_put_align,
529 HTMLImgElement_get_align,
530 HTMLImgElement_put_onload,
531 HTMLImgElement_get_onload,
532 HTMLImgElement_put_onerror,
533 HTMLImgElement_get_onerror,
534 HTMLImgElement_put_onabort,
535 HTMLImgElement_get_onabort,
536 HTMLImgElement_put_name,
537 HTMLImgElement_get_name,
538 HTMLImgElement_put_width,
539 HTMLImgElement_get_width,
540 HTMLImgElement_put_height,
541 HTMLImgElement_get_height,
542 HTMLImgElement_put_start,
543 HTMLImgElement_get_start
546 #define HTMLIMG_NODE_THIS(iface) DEFINE_THIS2(HTMLImgElement, element.node, iface)
548 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
550 HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
552 *ppv = NULL;
554 if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
555 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
556 *ppv = HTMLIMG(This);
557 }else {
558 return HTMLElement_QI(&This->element.node, riid, ppv);
561 IUnknown_AddRef((IUnknown*)*ppv);
562 return S_OK;
565 static void HTMLImgElement_destructor(HTMLDOMNode *iface)
567 HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
569 if(This->nsimg)
570 nsIDOMHTMLImageElement_Release(This->nsimg);
572 HTMLElement_destructor(&This->element.node);
575 #undef HTMLIMG_NODE_THIS
577 static const NodeImplVtbl HTMLImgElementImplVtbl = {
578 HTMLImgElement_QI,
579 HTMLImgElement_destructor
582 static const tid_t HTMLImgElement_iface_tids[] = {
583 IHTMLDOMNode_tid,
584 IHTMLDOMNode2_tid,
585 IHTMLElement_tid,
586 IHTMLElement2_tid,
587 IHTMLElement3_tid,
588 IHTMLImgElement_tid,
591 static dispex_static_data_t HTMLImgElement_dispex = {
592 NULL,
593 DispHTMLImg_tid,
594 NULL,
595 HTMLImgElement_iface_tids
598 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement *nselem)
600 HTMLImgElement *ret = heap_alloc_zero(sizeof(HTMLImgElement));
601 nsresult nsres;
603 ret->lpHTMLImgElementVtbl = &HTMLImgElementVtbl;
604 ret->element.node.vtbl = &HTMLImgElementImplVtbl;
606 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
607 if(NS_FAILED(nsres))
608 ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres);
610 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLIMG(ret), &HTMLImgElement_dispex);
611 HTMLElement_Init(&ret->element);
613 return &ret->element;