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 const IHTMLImgElementVtbl *lpHTMLImgElementVtbl;
39 nsIDOMHTMLImageElement *nsimg;
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);
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);
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));
118 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
120 HTMLImgElement *This = HTMLIMG_THIS(iface);
121 FIXME("(%p)->(%p)\n", This, p);
125 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
127 HTMLImgElement *This = HTMLIMG_THIS(iface);
128 FIXME("(%p)->(%p)\n", This, p);
132 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
134 HTMLImgElement *This = HTMLIMG_THIS(iface);
135 FIXME("(%p)->(%p)\n", This, p);
139 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
141 HTMLImgElement *This = HTMLIMG_THIS(iface);
142 FIXME("(%p)->(%p)\n", This, p);
146 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
148 HTMLImgElement *This = HTMLIMG_THIS(iface);
149 FIXME("(%p)->(%p)\n", This, p);
153 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
155 HTMLImgElement *This = HTMLIMG_THIS(iface);
156 FIXME("(%p)->(%p)\n", This, p);
160 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
162 HTMLImgElement *This = HTMLIMG_THIS(iface);
163 FIXME("(%p)->(%p)\n", This, p);
167 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
169 HTMLImgElement *This = HTMLIMG_THIS(iface);
170 FIXME("(%p)->(%p)\n", This, p);
174 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
176 HTMLImgElement *This = HTMLIMG_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
181 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
183 HTMLImgElement *This = HTMLIMG_THIS(iface);
184 FIXME("(%p)->()\n", This);
188 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
190 HTMLImgElement *This = HTMLIMG_THIS(iface);
191 FIXME("(%p)->(%p)\n", This, p);
195 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, long v)
197 HTMLImgElement *This = HTMLIMG_THIS(iface);
198 FIXME("(%p)->(%ld)\n", This, v);
202 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, long *p)
204 HTMLImgElement *This = HTMLIMG_THIS(iface);
205 FIXME("(%p)->(%p)\n", This, p);
209 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, long v)
211 HTMLImgElement *This = HTMLIMG_THIS(iface);
212 FIXME("(%p)->(%ld)\n", This, v);
216 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, long *p)
218 HTMLImgElement *This = HTMLIMG_THIS(iface);
219 FIXME("(%p)->(%p)\n", This, p);
223 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
225 HTMLImgElement *This = HTMLIMG_THIS(iface);
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);
235 ERR("SetAlt failed: %08x\n", nsres);
240 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
242 HTMLImgElement *This = HTMLIMG_THIS(iface);
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;
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);
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);
275 ERR("SetSrc failed: %08x\n", nsres);
280 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
282 HTMLImgElement *This = HTMLIMG_THIS(iface);
283 FIXME("(%p)->(%p)\n", This, p);
287 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
289 HTMLImgElement *This = HTMLIMG_THIS(iface);
290 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
294 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
296 HTMLImgElement *This = HTMLIMG_THIS(iface);
297 FIXME("(%p)->(%p)\n", This, p);
301 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
303 HTMLImgElement *This = HTMLIMG_THIS(iface);
304 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
308 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
310 HTMLImgElement *This = HTMLIMG_THIS(iface);
311 FIXME("(%p)->(%p)\n", This, p);
315 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
317 HTMLImgElement *This = HTMLIMG_THIS(iface);
318 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
322 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
324 HTMLImgElement *This = HTMLIMG_THIS(iface);
325 FIXME("(%p)->(%p)\n", This, p);
329 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
331 HTMLImgElement *This = HTMLIMG_THIS(iface);
332 FIXME("(%p)->(%p)\n", This, p);
336 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
338 HTMLImgElement *This = HTMLIMG_THIS(iface);
339 FIXME("(%p)->(%p)\n", This, p);
343 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
345 HTMLImgElement *This = HTMLIMG_THIS(iface);
346 FIXME("(%p)->()\n", This);
350 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
352 HTMLImgElement *This = HTMLIMG_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
357 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
359 HTMLImgElement *This = HTMLIMG_THIS(iface);
360 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
364 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
366 HTMLImgElement *This = HTMLIMG_THIS(iface);
367 FIXME("(%p)->(%p)\n", This, p);
371 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
373 HTMLImgElement *This = HTMLIMG_THIS(iface);
374 FIXME("(%p)->()\n", This);
378 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
380 HTMLImgElement *This = HTMLIMG_THIS(iface);
381 FIXME("(%p)->(%p)\n", This, p);
385 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
387 HTMLImgElement *This = HTMLIMG_THIS(iface);
388 FIXME("(%p)->()\n", This);
392 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
394 HTMLImgElement *This = HTMLIMG_THIS(iface);
395 FIXME("(%p)->(%p)\n", This, p);
399 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
401 HTMLImgElement *This = HTMLIMG_THIS(iface);
402 FIXME("(%p)->()\n", This);
406 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
408 HTMLImgElement *This = HTMLIMG_THIS(iface);
409 FIXME("(%p)->(%p)\n", This, p);
413 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
415 HTMLImgElement *This = HTMLIMG_THIS(iface);
416 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
420 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
422 HTMLImgElement *This = HTMLIMG_THIS(iface);
423 FIXME("(%p)->(%p)\n", This, p);
427 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, long v)
429 HTMLImgElement *This = HTMLIMG_THIS(iface);
430 FIXME("(%p)->(%ld)\n", This, v);
434 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, long *p)
436 HTMLImgElement *This = HTMLIMG_THIS(iface);
437 FIXME("(%p)->(%p)\n", This, p);
441 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, long v)
443 HTMLImgElement *This = HTMLIMG_THIS(iface);
444 FIXME("(%p)->(%ld)\n", This, v);
448 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, long *p)
450 HTMLImgElement *This = HTMLIMG_THIS(iface);
451 FIXME("(%p)->(%p)\n", This, p);
455 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
457 HTMLImgElement *This = HTMLIMG_THIS(iface);
458 FIXME("(%p)->()\n", This);
462 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
464 HTMLImgElement *This = HTMLIMG_THIS(iface);
465 FIXME("(%p)->(%p)\n", This, p);
471 static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
472 HTMLImgElement_QueryInterface,
473 HTMLImgElement_AddRef,
474 HTMLImgElement_Release,
475 HTMLImgElement_GetTypeInfoCount,
476 HTMLImgElement_GetTypeInfo,
477 HTMLImgElement_GetIDsOfNames,
478 HTMLImgElement_Invoke,
479 HTMLImgElement_put_isMap,
480 HTMLImgElement_get_isMap,
481 HTMLImgElement_put_useMap,
482 HTMLImgElement_get_useMap,
483 HTMLImgElement_get_mimeType,
484 HTMLImgElement_get_fileSize,
485 HTMLImgElement_get_fileCreatedDate,
486 HTMLImgElement_get_fileModifiedDate,
487 HTMLImgElement_get_fileUpdatedDate,
488 HTMLImgElement_get_protocol,
489 HTMLImgElement_get_href,
490 HTMLImgElement_get_nameProp,
491 HTMLImgElement_put_border,
492 HTMLImgElement_get_border,
493 HTMLImgElement_put_vspace,
494 HTMLImgElement_get_vspace,
495 HTMLImgElement_put_hspace,
496 HTMLImgElement_get_hspace,
497 HTMLImgElement_put_alt,
498 HTMLImgElement_get_alt,
499 HTMLImgElement_put_src,
500 HTMLImgElement_get_src,
501 HTMLImgElement_put_lowsrc,
502 HTMLImgElement_get_lowsrc,
503 HTMLImgElement_put_vrml,
504 HTMLImgElement_get_vrml,
505 HTMLImgElement_put_dynsrc,
506 HTMLImgElement_get_dynsrc,
507 HTMLImgElement_get_readyState,
508 HTMLImgElement_get_complete,
509 HTMLImgElement_put_loop,
510 HTMLImgElement_get_loop,
511 HTMLImgElement_put_align,
512 HTMLImgElement_get_align,
513 HTMLImgElement_put_onload,
514 HTMLImgElement_get_onload,
515 HTMLImgElement_put_onerror,
516 HTMLImgElement_get_onerror,
517 HTMLImgElement_put_onabort,
518 HTMLImgElement_get_onabort,
519 HTMLImgElement_put_name,
520 HTMLImgElement_get_name,
521 HTMLImgElement_put_width,
522 HTMLImgElement_get_width,
523 HTMLImgElement_put_height,
524 HTMLImgElement_get_height,
525 HTMLImgElement_put_start,
526 HTMLImgElement_get_start
529 #define HTMLIMG_NODE_THIS(iface) DEFINE_THIS2(HTMLImgElement, element.node, iface)
531 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
533 HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
537 if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
538 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
539 *ppv = HTMLIMG(This);
541 return HTMLElement_QI(&This->element.node, riid, ppv);
544 IUnknown_AddRef((IUnknown*)*ppv);
548 static void HTMLImgElement_destructor(HTMLDOMNode *iface)
550 HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
553 nsIDOMHTMLImageElement_Release(This->nsimg);
555 HTMLElement_destructor(&This->element.node);
558 #undef HTMLIMG_NODE_THIS
560 static const NodeImplVtbl HTMLImgElementImplVtbl = {
562 HTMLImgElement_destructor
565 static const tid_t HTMLImgElement_iface_tids[] = {
573 static dispex_static_data_t HTMLImgElement_dispex = {
577 HTMLImgElement_iface_tids
580 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement *nselem)
582 HTMLImgElement *ret = heap_alloc_zero(sizeof(HTMLImgElement));
585 ret->lpHTMLImgElementVtbl = &HTMLImgElementVtbl;
586 ret->element.node.vtbl = &HTMLImgElementImplVtbl;
588 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
590 ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres);
592 init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLIMG(ret), &HTMLImgElement_dispex);
593 HTMLElement_Init(&ret->element);
595 return &ret->element;