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"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 IHTMLImgElement IHTMLImgElement_iface;
40 nsIDOMHTMLImageElement *nsimg;
43 static inline HTMLImgElement *impl_from_IHTMLImgElement(IHTMLImgElement *iface)
45 return CONTAINING_RECORD(iface, HTMLImgElement, IHTMLImgElement_iface);
48 static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
50 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
52 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
55 static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface)
57 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
59 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
62 static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
64 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
66 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
69 static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo)
71 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo);
75 static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
79 return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid,
83 static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
88 return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames,
89 cNames, lcid, rgDispId);
92 static HRESULT WINAPI HTMLImgElement_Invoke(IHTMLImgElement *iface, DISPID dispIdMember,
93 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
96 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
97 return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid,
98 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
101 static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v)
103 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
104 FIXME("(%p)->(%x)\n", This, v);
108 static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
110 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
111 FIXME("(%p)->(%p)\n", This, p);
115 static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
117 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
118 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
122 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
124 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
125 FIXME("(%p)->(%p)\n", This, p);
129 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
131 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
132 FIXME("(%p)->(%p)\n", This, p);
136 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
138 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
139 FIXME("(%p)->(%p)\n", This, p);
143 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
145 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
146 FIXME("(%p)->(%p)\n", This, p);
150 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
152 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
153 FIXME("(%p)->(%p)\n", This, p);
157 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
159 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
160 FIXME("(%p)->(%p)\n", This, p);
164 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
166 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
167 FIXME("(%p)->(%p)\n", This, p);
171 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
173 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
174 FIXME("(%p)->(%p)\n", This, p);
178 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
180 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
181 FIXME("(%p)->(%p)\n", This, p);
185 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
187 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
188 FIXME("(%p)->()\n", This);
192 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
194 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
195 FIXME("(%p)->(%p)\n", This, p);
199 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v)
201 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
202 FIXME("(%p)->(%d)\n", This, v);
206 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p)
208 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
209 FIXME("(%p)->(%p)\n", This, p);
213 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v)
215 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
216 FIXME("(%p)->(%d)\n", This, v);
220 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p)
222 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
223 FIXME("(%p)->(%p)\n", This, p);
227 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
229 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
233 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
235 nsAString_InitDepend(&alt_str, v);
236 nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
237 nsAString_Finish(&alt_str);
239 ERR("SetAlt failed: %08x\n", nsres);
244 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
246 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
250 TRACE("(%p)->(%p)\n", This, p);
252 nsAString_Init(&alt_str, NULL);
253 nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
254 if(NS_SUCCEEDED(nsres)) {
255 const PRUnichar *alt;
257 nsAString_GetData(&alt_str, &alt);
258 *p = *alt ? SysAllocString(alt) : NULL;
260 ERR("GetAlt failed: %08x\n", nsres);
262 nsAString_Finish(&alt_str);
264 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
267 static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
269 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
273 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
275 nsAString_InitDepend(&src_str, v);
276 nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
277 nsAString_Finish(&src_str);
279 ERR("SetSrc failed: %08x\n", nsres);
284 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
286 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
287 const PRUnichar *src;
292 static const WCHAR blockedW[] = {'B','L','O','C','K','E','D',':',':',0};
294 TRACE("(%p)->(%p)\n", This, p);
296 nsAString_Init(&src_str, NULL);
297 nsres = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &src_str);
298 if(NS_SUCCEEDED(nsres)) {
299 nsAString_GetData(&src_str, &src);
301 if(!strncmpiW(src, blockedW, sizeof(blockedW)/sizeof(WCHAR)-1)) {
302 TRACE("returning BLOCKED::\n");
303 *p = SysAllocString(blockedW);
305 hres = E_OUTOFMEMORY;
307 hres = nsuri_to_url(src, TRUE, p);
310 ERR("GetSrc failed: %08x\n", nsres);
314 nsAString_Finish(&src_str);
318 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
320 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
321 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
325 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
327 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
328 FIXME("(%p)->(%p)\n", This, p);
332 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
334 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
335 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
339 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
341 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
342 FIXME("(%p)->(%p)\n", This, p);
346 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
348 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
349 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
353 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
355 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
356 FIXME("(%p)->(%p)\n", This, p);
360 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
362 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
363 FIXME("(%p)->(%p)\n", This, p);
367 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
369 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
370 FIXME("(%p)->(%p)\n", This, p);
374 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
376 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
377 FIXME("(%p)->()\n", This);
381 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
383 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
384 FIXME("(%p)->(%p)\n", This, p);
388 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
390 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
391 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
395 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
397 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
398 FIXME("(%p)->(%p)\n", This, p);
402 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
404 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
406 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
408 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
411 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
413 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
415 TRACE("(%p)->(%p)\n", This, p);
417 return get_node_event(&This->element.node, EVENTID_LOAD, p);
420 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
422 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
424 TRACE("(%p)->()\n", This);
426 return set_node_event(&This->element.node, EVENTID_ERROR, &v);
429 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
431 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
433 TRACE("(%p)->(%p)\n", This, p);
435 return get_node_event(&This->element.node, EVENTID_ERROR, p);
438 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
440 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
441 FIXME("(%p)->()\n", This);
445 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
447 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
448 FIXME("(%p)->(%p)\n", This, p);
452 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
454 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
455 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
459 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
461 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
465 TRACE("(%p)->(%p)\n", This, p);
467 nsAString_Init(&strName, NULL);
468 nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName);
469 if(NS_SUCCEEDED(nsres)) {
470 const PRUnichar *str;
472 nsAString_GetData(&strName, &str);
473 *p = *str ? SysAllocString(str) : NULL;
475 ERR("GetName failed: %08x\n", nsres);
477 nsAString_Finish(&strName);
479 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
482 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
484 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
487 TRACE("(%p)->(%d)\n", This, v);
489 nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v);
490 if(NS_FAILED(nsres)) {
491 ERR("SetWidth failed: %08x\n", nsres);
498 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p)
500 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
504 TRACE("(%p)->(%p)\n", This, p);
506 nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width);
507 if(NS_FAILED(nsres)) {
508 ERR("GetWidth failed: %08x\n", nsres);
516 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v)
518 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
521 TRACE("(%p)->(%d)\n", This, v);
523 nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v);
524 if(NS_FAILED(nsres)) {
525 ERR("SetHeight failed: %08x\n", nsres);
532 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p)
534 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
538 TRACE("(%p)->(%p)\n", This, p);
540 nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height);
541 if(NS_FAILED(nsres)) {
542 ERR("GetHeight failed: %08x\n", nsres);
550 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
552 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
553 FIXME("(%p)->()\n", This);
557 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
559 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
560 FIXME("(%p)->(%p)\n", This, p);
564 static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
565 HTMLImgElement_QueryInterface,
566 HTMLImgElement_AddRef,
567 HTMLImgElement_Release,
568 HTMLImgElement_GetTypeInfoCount,
569 HTMLImgElement_GetTypeInfo,
570 HTMLImgElement_GetIDsOfNames,
571 HTMLImgElement_Invoke,
572 HTMLImgElement_put_isMap,
573 HTMLImgElement_get_isMap,
574 HTMLImgElement_put_useMap,
575 HTMLImgElement_get_useMap,
576 HTMLImgElement_get_mimeType,
577 HTMLImgElement_get_fileSize,
578 HTMLImgElement_get_fileCreatedDate,
579 HTMLImgElement_get_fileModifiedDate,
580 HTMLImgElement_get_fileUpdatedDate,
581 HTMLImgElement_get_protocol,
582 HTMLImgElement_get_href,
583 HTMLImgElement_get_nameProp,
584 HTMLImgElement_put_border,
585 HTMLImgElement_get_border,
586 HTMLImgElement_put_vspace,
587 HTMLImgElement_get_vspace,
588 HTMLImgElement_put_hspace,
589 HTMLImgElement_get_hspace,
590 HTMLImgElement_put_alt,
591 HTMLImgElement_get_alt,
592 HTMLImgElement_put_src,
593 HTMLImgElement_get_src,
594 HTMLImgElement_put_lowsrc,
595 HTMLImgElement_get_lowsrc,
596 HTMLImgElement_put_vrml,
597 HTMLImgElement_get_vrml,
598 HTMLImgElement_put_dynsrc,
599 HTMLImgElement_get_dynsrc,
600 HTMLImgElement_get_readyState,
601 HTMLImgElement_get_complete,
602 HTMLImgElement_put_loop,
603 HTMLImgElement_get_loop,
604 HTMLImgElement_put_align,
605 HTMLImgElement_get_align,
606 HTMLImgElement_put_onload,
607 HTMLImgElement_get_onload,
608 HTMLImgElement_put_onerror,
609 HTMLImgElement_get_onerror,
610 HTMLImgElement_put_onabort,
611 HTMLImgElement_get_onabort,
612 HTMLImgElement_put_name,
613 HTMLImgElement_get_name,
614 HTMLImgElement_put_width,
615 HTMLImgElement_get_width,
616 HTMLImgElement_put_height,
617 HTMLImgElement_get_height,
618 HTMLImgElement_put_start,
619 HTMLImgElement_get_start
622 static inline HTMLImgElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
624 return CONTAINING_RECORD(iface, HTMLImgElement, element.node);
627 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
629 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
633 if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
634 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
635 *ppv = &This->IHTMLImgElement_iface;
637 return HTMLElement_QI(&This->element.node, riid, ppv);
640 IUnknown_AddRef((IUnknown*)*ppv);
644 static void HTMLImgElement_destructor(HTMLDOMNode *iface)
646 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
649 nsIDOMHTMLImageElement_Release(This->nsimg);
651 HTMLElement_destructor(&This->element.node);
654 static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
656 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
658 return IHTMLImgElement_get_readyState(&This->IHTMLImgElement_iface, p);
661 static const NodeImplVtbl HTMLImgElementImplVtbl = {
663 HTMLImgElement_destructor,
665 HTMLElement_get_attr_col,
672 HTMLImgElement_get_readystate
675 static const tid_t HTMLImgElement_iface_tids[] = {
680 static dispex_static_data_t HTMLImgElement_dispex = {
684 HTMLImgElement_iface_tids
687 HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
692 ret = heap_alloc_zero(sizeof(HTMLImgElement));
694 return E_OUTOFMEMORY;
696 ret->IHTMLImgElement_iface.lpVtbl = &HTMLImgElementVtbl;
697 ret->element.node.vtbl = &HTMLImgElementImplVtbl;
699 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
700 if(NS_FAILED(nsres)) {
701 ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres);
706 HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
708 *elem = &ret->element;
712 static inline HTMLImageElementFactory *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface)
714 return CONTAINING_RECORD(iface, HTMLImageElementFactory, IHTMLImageElementFactory_iface);
717 static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface,
718 REFIID riid, void **ppv)
720 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
724 if(IsEqualGUID(&IID_IUnknown, riid)) {
725 TRACE("(%p)->(IID_Unknown %p)\n", This, ppv);
726 *ppv = &This->IHTMLImageElementFactory_iface;
727 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory, riid)) {
728 TRACE("(%p)->(IID_IHTMLImageElementFactory %p)\n", This, ppv);
729 *ppv = &This->IHTMLImageElementFactory_iface;
730 }else if(dispex_query_interface(&This->dispex, riid, ppv))
731 return *ppv ? S_OK : E_NOINTERFACE;
734 IUnknown_AddRef((IUnknown*)*ppv);
738 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
739 return E_NOINTERFACE;
742 static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface)
744 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
745 LONG ref = InterlockedIncrement(&This->ref);
747 TRACE("(%p) ref=%d\n", This, ref);
752 static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface)
754 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
755 LONG ref = InterlockedDecrement(&This->ref);
757 TRACE("(%p) ref=%d\n", This, ref);
765 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface,
768 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
769 FIXME("(%p)->(%p)\n", This, pctinfo);
773 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface,
774 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
776 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
777 FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
781 static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface,
782 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
785 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
786 FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames,
787 cNames, lcid, rgDispId);
791 static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *iface,
792 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
793 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
796 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
797 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
798 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
802 static LONG var_to_size(const VARIANT *v)
813 hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret);
815 FIXME("VarI4FromStr failed: %08x\n", hres);
821 FIXME("unsupported size %s\n", debugstr_variant(v));
826 static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface,
827 VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
829 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
830 IHTMLImgElement *img;
832 nsIDOMHTMLElement *nselem;
836 static const PRUnichar imgW[] = {'I','M','G',0};
838 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
839 debugstr_variant(&height), img_elem);
841 if(!This->window || !This->window->doc) {
848 hres = create_nselem(This->window->doc, imgW, &nselem);
852 hres = HTMLElement_Create(This->window->doc, (nsIDOMNode*)nselem, FALSE, &elem);
853 nsIDOMHTMLElement_Release(nselem);
855 ERR("HTMLElement_Create failed\n");
859 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLImgElement,
862 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
866 l = var_to_size(&width);
868 IHTMLImgElement_put_width(img, l);
869 l = var_to_size(&height);
871 IHTMLImgElement_put_height(img, l);
877 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = {
878 HTMLImageElementFactory_QueryInterface,
879 HTMLImageElementFactory_AddRef,
880 HTMLImageElementFactory_Release,
881 HTMLImageElementFactory_GetTypeInfoCount,
882 HTMLImageElementFactory_GetTypeInfo,
883 HTMLImageElementFactory_GetIDsOfNames,
884 HTMLImageElementFactory_Invoke,
885 HTMLImageElementFactory_create
888 static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface)
890 return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex);
893 static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid,
894 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
895 IServiceProvider *caller)
897 HTMLImageElementFactory *This = impl_from_DispatchEx(dispex);
898 IHTMLImgElement *img;
899 VARIANT empty, *width, *height;
901 int argc = params->cArgs - params->cNamedArgs;
905 V_VT(&empty) = VT_EMPTY;
907 width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : ∅
908 height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : ∅
910 hres = IHTMLImageElementFactory_create(&This->IHTMLImageElementFactory_iface, *width, *height,
915 V_VT(res) = VT_DISPATCH;
916 V_DISPATCH(res) = (IDispatch*)img;
921 static const tid_t HTMLImageElementFactory_iface_tids[] = {
922 IHTMLImageElementFactory_tid,
926 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = {
927 HTMLImageElementFactory_value,
933 static dispex_static_data_t HTMLImageElementFactory_dispex = {
934 &HTMLImageElementFactory_dispex_vtbl,
935 IHTMLImageElementFactory_tid,
937 HTMLImageElementFactory_iface_tids
940 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow *window)
942 HTMLImageElementFactory *ret;
944 ret = heap_alloc(sizeof(HTMLImageElementFactory));
946 ret->IHTMLImageElementFactory_iface.lpVtbl = &HTMLImageElementFactoryVtbl;
948 ret->window = window;
950 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLImageElementFactory_iface,
951 &HTMLImageElementFactory_dispex);