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 const IHTMLImgElementVtbl
*lpHTMLImgElementVtbl
;
40 nsIDOMHTMLImageElement
*nsimg
;
43 #define HTMLIMG(x) ((IHTMLImgElement*) &(x)->lpHTMLImgElementVtbl)
45 #define HTMLIMG_THIS(iface) DEFINE_THIS(HTMLImgElement, HTMLImgElement, iface)
47 static HRESULT WINAPI
HTMLImgElement_QueryInterface(IHTMLImgElement
*iface
, REFIID riid
, void **ppv
)
49 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
51 return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
54 static ULONG WINAPI
HTMLImgElement_AddRef(IHTMLImgElement
*iface
)
56 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
58 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
61 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
63 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
65 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
68 static HRESULT WINAPI
HTMLImgElement_GetTypeInfoCount(IHTMLImgElement
*iface
, UINT
*pctinfo
)
70 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
71 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->element
.node
.dispex
), pctinfo
);
74 static HRESULT WINAPI
HTMLImgElement_GetTypeInfo(IHTMLImgElement
*iface
, UINT iTInfo
,
75 LCID lcid
, ITypeInfo
**ppTInfo
)
77 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
78 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->element
.node
.dispex
), iTInfo
, lcid
, ppTInfo
);
81 static HRESULT WINAPI
HTMLImgElement_GetIDsOfNames(IHTMLImgElement
*iface
, REFIID riid
,
82 LPOLESTR
*rgszNames
, UINT cNames
,
83 LCID lcid
, DISPID
*rgDispId
)
85 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
86 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->element
.node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
89 static HRESULT WINAPI
HTMLImgElement_Invoke(IHTMLImgElement
*iface
, DISPID dispIdMember
,
90 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
91 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
93 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
94 return IDispatchEx_Invoke(DISPATCHEX(&This
->element
.node
.dispex
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
95 pVarResult
, pExcepInfo
, puArgErr
);
98 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
100 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
101 FIXME("(%p)->(%x)\n", This
, v
);
105 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
107 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
108 FIXME("(%p)->(%p)\n", This
, p
);
112 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
114 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
115 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
119 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
121 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
122 FIXME("(%p)->(%p)\n", This
, p
);
126 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
128 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
129 FIXME("(%p)->(%p)\n", This
, p
);
133 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
135 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
136 FIXME("(%p)->(%p)\n", This
, p
);
140 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
142 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
143 FIXME("(%p)->(%p)\n", This
, p
);
147 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
149 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
150 FIXME("(%p)->(%p)\n", This
, p
);
154 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
156 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
157 FIXME("(%p)->(%p)\n", This
, p
);
161 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
163 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
164 FIXME("(%p)->(%p)\n", This
, p
);
168 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
170 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
171 FIXME("(%p)->(%p)\n", This
, p
);
175 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
177 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
178 FIXME("(%p)->(%p)\n", This
, p
);
182 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
184 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
185 FIXME("(%p)->()\n", This
);
189 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
191 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
192 FIXME("(%p)->(%p)\n", This
, p
);
196 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
198 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
199 FIXME("(%p)->(%d)\n", This
, v
);
203 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
205 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
206 FIXME("(%p)->(%p)\n", This
, p
);
210 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
212 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
213 FIXME("(%p)->(%d)\n", This
, v
);
217 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
219 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
220 FIXME("(%p)->(%p)\n", This
, p
);
224 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
226 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
230 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
232 nsAString_InitDepend(&alt_str
, v
);
233 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
234 nsAString_Finish(&alt_str
);
236 ERR("SetAlt failed: %08x\n", nsres
);
241 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
243 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
247 TRACE("(%p)->(%p)\n", This
, p
);
249 nsAString_Init(&alt_str
, NULL
);
250 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
251 if(NS_SUCCEEDED(nsres
)) {
252 const PRUnichar
*alt
;
254 nsAString_GetData(&alt_str
, &alt
);
255 *p
= *alt
? SysAllocString(alt
) : NULL
;
257 ERR("GetAlt failed: %08x\n", nsres
);
259 nsAString_Finish(&alt_str
);
261 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
264 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
266 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
270 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
272 nsAString_InitDepend(&src_str
, v
);
273 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
274 nsAString_Finish(&src_str
);
276 ERR("SetSrc failed: %08x\n", nsres
);
281 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
283 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
284 const PRUnichar
*src
;
289 TRACE("(%p)->(%p)\n", This
, p
);
291 nsAString_Init(&src_str
, NULL
);
292 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
293 if(NS_FAILED(nsres
)) {
294 ERR("GetSrc failed: %08x\n", nsres
);
298 nsAString_GetData(&src_str
, &src
);
299 hres
= nsuri_to_url(src
, TRUE
, p
);
300 nsAString_Finish(&src_str
);
305 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
307 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
308 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
312 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
314 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
315 FIXME("(%p)->(%p)\n", This
, p
);
319 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
321 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
322 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
326 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
328 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
329 FIXME("(%p)->(%p)\n", This
, p
);
333 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
335 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
336 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
340 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
342 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
343 FIXME("(%p)->(%p)\n", This
, p
);
347 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
349 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
350 FIXME("(%p)->(%p)\n", This
, p
);
354 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
356 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
357 FIXME("(%p)->(%p)\n", This
, p
);
361 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
363 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
364 FIXME("(%p)->()\n", This
);
368 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
370 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
371 FIXME("(%p)->(%p)\n", This
, p
);
375 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
377 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
378 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
382 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
384 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
385 FIXME("(%p)->(%p)\n", This
, p
);
389 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
391 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
393 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
395 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
398 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
400 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
402 TRACE("(%p)->(%p)\n", This
, p
);
404 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
407 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
409 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
410 FIXME("(%p)->()\n", This
);
414 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
416 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
417 FIXME("(%p)->(%p)\n", This
, p
);
421 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
423 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
424 FIXME("(%p)->()\n", This
);
428 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
430 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
431 FIXME("(%p)->(%p)\n", This
, p
);
435 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
437 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
438 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
442 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
444 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
448 TRACE("(%p)->(%p)\n", This
, p
);
450 nsAString_Init(&strName
, NULL
);
451 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &strName
);
452 if(NS_SUCCEEDED(nsres
)) {
453 const PRUnichar
*str
;
455 nsAString_GetData(&strName
, &str
);
456 *p
= *str
? SysAllocString(str
) : NULL
;
458 ERR("GetName failed: %08x\n", nsres
);
460 nsAString_Finish(&strName
);
462 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
465 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
467 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
470 TRACE("(%p)->(%d)\n", This
, v
);
472 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
473 if(NS_FAILED(nsres
)) {
474 ERR("SetWidth failed: %08x\n", nsres
);
481 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
483 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
487 TRACE("(%p)->(%p)\n", This
, p
);
489 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
490 if(NS_FAILED(nsres
)) {
491 ERR("GetWidth failed: %08x\n", nsres
);
499 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
501 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
504 TRACE("(%p)->(%d)\n", This
, v
);
506 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
507 if(NS_FAILED(nsres
)) {
508 ERR("SetHeight failed: %08x\n", nsres
);
515 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
517 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
521 TRACE("(%p)->(%p)\n", This
, p
);
523 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
524 if(NS_FAILED(nsres
)) {
525 ERR("GetHeight failed: %08x\n", nsres
);
533 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
535 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
536 FIXME("(%p)->()\n", This
);
540 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
542 HTMLImgElement
*This
= HTMLIMG_THIS(iface
);
543 FIXME("(%p)->(%p)\n", This
, p
);
549 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
550 HTMLImgElement_QueryInterface
,
551 HTMLImgElement_AddRef
,
552 HTMLImgElement_Release
,
553 HTMLImgElement_GetTypeInfoCount
,
554 HTMLImgElement_GetTypeInfo
,
555 HTMLImgElement_GetIDsOfNames
,
556 HTMLImgElement_Invoke
,
557 HTMLImgElement_put_isMap
,
558 HTMLImgElement_get_isMap
,
559 HTMLImgElement_put_useMap
,
560 HTMLImgElement_get_useMap
,
561 HTMLImgElement_get_mimeType
,
562 HTMLImgElement_get_fileSize
,
563 HTMLImgElement_get_fileCreatedDate
,
564 HTMLImgElement_get_fileModifiedDate
,
565 HTMLImgElement_get_fileUpdatedDate
,
566 HTMLImgElement_get_protocol
,
567 HTMLImgElement_get_href
,
568 HTMLImgElement_get_nameProp
,
569 HTMLImgElement_put_border
,
570 HTMLImgElement_get_border
,
571 HTMLImgElement_put_vspace
,
572 HTMLImgElement_get_vspace
,
573 HTMLImgElement_put_hspace
,
574 HTMLImgElement_get_hspace
,
575 HTMLImgElement_put_alt
,
576 HTMLImgElement_get_alt
,
577 HTMLImgElement_put_src
,
578 HTMLImgElement_get_src
,
579 HTMLImgElement_put_lowsrc
,
580 HTMLImgElement_get_lowsrc
,
581 HTMLImgElement_put_vrml
,
582 HTMLImgElement_get_vrml
,
583 HTMLImgElement_put_dynsrc
,
584 HTMLImgElement_get_dynsrc
,
585 HTMLImgElement_get_readyState
,
586 HTMLImgElement_get_complete
,
587 HTMLImgElement_put_loop
,
588 HTMLImgElement_get_loop
,
589 HTMLImgElement_put_align
,
590 HTMLImgElement_get_align
,
591 HTMLImgElement_put_onload
,
592 HTMLImgElement_get_onload
,
593 HTMLImgElement_put_onerror
,
594 HTMLImgElement_get_onerror
,
595 HTMLImgElement_put_onabort
,
596 HTMLImgElement_get_onabort
,
597 HTMLImgElement_put_name
,
598 HTMLImgElement_get_name
,
599 HTMLImgElement_put_width
,
600 HTMLImgElement_get_width
,
601 HTMLImgElement_put_height
,
602 HTMLImgElement_get_height
,
603 HTMLImgElement_put_start
,
604 HTMLImgElement_get_start
607 #define HTMLIMG_NODE_THIS(iface) DEFINE_THIS2(HTMLImgElement, element.node, iface)
609 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
611 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
615 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
616 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
617 *ppv
= HTMLIMG(This
);
619 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
622 IUnknown_AddRef((IUnknown
*)*ppv
);
626 static void HTMLImgElement_destructor(HTMLDOMNode
*iface
)
628 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
631 nsIDOMHTMLImageElement_Release(This
->nsimg
);
633 HTMLElement_destructor(&This
->element
.node
);
636 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
638 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
640 return IHTMLImgElement_get_readyState(HTMLIMG(This
), p
);
643 #undef HTMLIMG_NODE_THIS
645 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
647 HTMLImgElement_destructor
,
653 HTMLImgElement_get_readystate
656 static const tid_t HTMLImgElement_iface_tids
[] = {
661 static dispex_static_data_t HTMLImgElement_dispex
= {
665 HTMLImgElement_iface_tids
668 HTMLElement
*HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
)
670 HTMLImgElement
*ret
= heap_alloc_zero(sizeof(HTMLImgElement
));
673 ret
->lpHTMLImgElementVtbl
= &HTMLImgElementVtbl
;
674 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
676 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
678 ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres
);
680 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
682 return &ret
->element
;
685 #define HTMLIMGFACTORY_THIS(iface) DEFINE_THIS(HTMLImageElementFactory, HTMLImageElementFactory, iface)
687 static HRESULT WINAPI
HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory
*iface
,
688 REFIID riid
, void **ppv
)
690 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
694 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
695 TRACE("(%p)->(IID_Unknown %p)\n", This
, ppv
);
696 *ppv
= HTMLIMGFACTORY(This
);
697 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
)) {
698 TRACE("(%p)->(IID_IHTMLImageElementFactory %p)\n", This
, ppv
);
699 *ppv
= HTMLIMGFACTORY(This
);
700 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
))
701 return *ppv
? S_OK
: E_NOINTERFACE
;
704 IUnknown_AddRef((IUnknown
*)*ppv
);
708 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
709 return E_NOINTERFACE
;
712 static ULONG WINAPI
HTMLImageElementFactory_AddRef(IHTMLImageElementFactory
*iface
)
714 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
715 LONG ref
= InterlockedIncrement(&This
->ref
);
717 TRACE("(%p) ref=%d\n", This
, ref
);
722 static ULONG WINAPI
HTMLImageElementFactory_Release(IHTMLImageElementFactory
*iface
)
724 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
725 LONG ref
= InterlockedDecrement(&This
->ref
);
727 TRACE("(%p) ref=%d\n", This
, ref
);
735 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory
*iface
,
738 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
739 FIXME("(%p)->(%p)\n", This
, pctinfo
);
743 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory
*iface
,
744 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
746 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
747 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
751 static HRESULT WINAPI
HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory
*iface
,
752 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
,
755 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
756 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
,
757 cNames
, lcid
, rgDispId
);
761 static HRESULT WINAPI
HTMLImageElementFactory_Invoke(IHTMLImageElementFactory
*iface
,
762 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
,
763 DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
766 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
767 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
768 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
772 static LONG
var_to_size(const VARIANT
*v
)
783 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
785 FIXME("VarI4FromStr failed: %08x\n", hres
);
791 FIXME("unsupported size %s\n", debugstr_variant(v
));
796 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
797 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
799 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
800 IHTMLImgElement
*img
;
802 nsIDOMHTMLElement
*nselem
;
806 static const PRUnichar imgW
[] = {'I','M','G',0};
808 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
809 debugstr_variant(&height
), img_elem
);
811 if(!This
->window
|| !This
->window
->doc
) {
818 hres
= create_nselem(This
->window
->doc
, imgW
, &nselem
);
822 elem
= HTMLElement_Create(This
->window
->doc
, (nsIDOMNode
*)nselem
, FALSE
);
824 ERR("HTMLElement_Create failed\n");
828 hres
= IHTMLElement_QueryInterface(HTMLELEM(elem
), &IID_IHTMLImgElement
, (void**)&img
);
830 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres
);
834 nsIDOMHTMLElement_Release(nselem
);
836 l
= var_to_size(&width
);
838 IHTMLImgElement_put_width(img
, l
);
839 l
= var_to_size(&height
);
841 IHTMLImgElement_put_height(img
, l
);
847 static HRESULT
HTMLImageElementFactory_value(IUnknown
*iface
, LCID lcid
,
848 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
849 IServiceProvider
*caller
)
851 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
852 IHTMLImgElement
*img
;
853 VARIANT empty
, *width
, *height
;
855 int argc
= params
->cArgs
- params
->cNamedArgs
;
859 V_VT(&empty
) = VT_EMPTY
;
861 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
862 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
864 hres
= IHTMLImageElementFactory_create(HTMLIMGFACTORY(This
), *width
, *height
, &img
);
868 V_VT(res
) = VT_DISPATCH
;
869 V_DISPATCH(res
) = (IDispatch
*)img
;
874 #undef HTMLIMGFACTORY_THIS
876 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
877 HTMLImageElementFactory_QueryInterface
,
878 HTMLImageElementFactory_AddRef
,
879 HTMLImageElementFactory_Release
,
880 HTMLImageElementFactory_GetTypeInfoCount
,
881 HTMLImageElementFactory_GetTypeInfo
,
882 HTMLImageElementFactory_GetIDsOfNames
,
883 HTMLImageElementFactory_Invoke
,
884 HTMLImageElementFactory_create
887 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
888 IHTMLImageElementFactory_tid
,
892 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
893 HTMLImageElementFactory_value
,
898 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
899 &HTMLImageElementFactory_dispex_vtbl
,
900 IHTMLImageElementFactory_tid
,
902 HTMLImageElementFactory_iface_tids
905 HTMLImageElementFactory
*HTMLImageElementFactory_Create(HTMLWindow
*window
)
907 HTMLImageElementFactory
*ret
;
909 ret
= heap_alloc(sizeof(HTMLImageElementFactory
));
911 ret
->lpHTMLImageElementFactoryVtbl
= &HTMLImageElementFactoryVtbl
;
913 ret
->window
= window
;
915 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLIMGFACTORY(ret
), &HTMLImageElementFactory_dispex
);