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(HTMLDOMNODE(&This
->element
.node
), riid
, ppv
);
55 static ULONG WINAPI
HTMLImgElement_AddRef(IHTMLImgElement
*iface
)
57 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
59 return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This
->element
.node
));
62 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
64 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
66 return IHTMLDOMNode_Release(HTMLDOMNODE(&This
->element
.node
));
69 static HRESULT WINAPI
HTMLImgElement_GetTypeInfoCount(IHTMLImgElement
*iface
, UINT
*pctinfo
)
71 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->element
.node
.dispex
), 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(DISPATCHEX(&This
->element
.node
.dispex
), iTInfo
, lcid
, ppTInfo
);
82 static HRESULT WINAPI
HTMLImgElement_GetIDsOfNames(IHTMLImgElement
*iface
, REFIID riid
,
83 LPOLESTR
*rgszNames
, UINT cNames
,
84 LCID lcid
, DISPID
*rgDispId
)
86 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
87 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->element
.node
.dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
90 static HRESULT WINAPI
HTMLImgElement_Invoke(IHTMLImgElement
*iface
, DISPID dispIdMember
,
91 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
92 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
94 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
95 return IDispatchEx_Invoke(DISPATCHEX(&This
->element
.node
.dispex
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
96 pVarResult
, pExcepInfo
, puArgErr
);
99 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
101 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
102 FIXME("(%p)->(%x)\n", This
, v
);
106 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
108 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
109 FIXME("(%p)->(%p)\n", This
, p
);
113 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
115 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
116 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
120 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
122 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
123 FIXME("(%p)->(%p)\n", This
, p
);
127 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
129 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
130 FIXME("(%p)->(%p)\n", This
, p
);
134 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
136 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
137 FIXME("(%p)->(%p)\n", This
, p
);
141 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
143 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
144 FIXME("(%p)->(%p)\n", This
, p
);
148 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
150 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
151 FIXME("(%p)->(%p)\n", This
, p
);
155 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
157 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
158 FIXME("(%p)->(%p)\n", This
, p
);
162 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
164 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
165 FIXME("(%p)->(%p)\n", This
, p
);
169 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
171 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
172 FIXME("(%p)->(%p)\n", This
, p
);
176 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
178 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
179 FIXME("(%p)->(%p)\n", This
, p
);
183 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
185 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
186 FIXME("(%p)->()\n", This
);
190 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
192 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
193 FIXME("(%p)->(%p)\n", This
, p
);
197 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
199 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
200 FIXME("(%p)->(%d)\n", This
, v
);
204 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
206 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
207 FIXME("(%p)->(%p)\n", This
, p
);
211 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
213 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
214 FIXME("(%p)->(%d)\n", This
, v
);
218 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
220 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
221 FIXME("(%p)->(%p)\n", This
, p
);
225 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
227 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
231 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
233 nsAString_InitDepend(&alt_str
, v
);
234 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
235 nsAString_Finish(&alt_str
);
237 ERR("SetAlt failed: %08x\n", nsres
);
242 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
244 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
248 TRACE("(%p)->(%p)\n", This
, p
);
250 nsAString_Init(&alt_str
, NULL
);
251 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
252 if(NS_SUCCEEDED(nsres
)) {
253 const PRUnichar
*alt
;
255 nsAString_GetData(&alt_str
, &alt
);
256 *p
= *alt
? SysAllocString(alt
) : NULL
;
258 ERR("GetAlt failed: %08x\n", nsres
);
260 nsAString_Finish(&alt_str
);
262 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
265 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
267 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
271 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
273 nsAString_InitDepend(&src_str
, v
);
274 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
275 nsAString_Finish(&src_str
);
277 ERR("SetSrc failed: %08x\n", nsres
);
282 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
284 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
285 const PRUnichar
*src
;
290 TRACE("(%p)->(%p)\n", This
, p
);
292 nsAString_Init(&src_str
, NULL
);
293 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
294 if(NS_FAILED(nsres
)) {
295 ERR("GetSrc failed: %08x\n", nsres
);
299 nsAString_GetData(&src_str
, &src
);
300 hres
= nsuri_to_url(src
, TRUE
, p
);
301 nsAString_Finish(&src_str
);
306 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
308 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
309 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
313 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
315 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
316 FIXME("(%p)->(%p)\n", This
, p
);
320 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
322 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
323 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
327 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
329 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
330 FIXME("(%p)->(%p)\n", This
, p
);
334 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
336 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
337 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
341 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
343 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
344 FIXME("(%p)->(%p)\n", This
, p
);
348 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
350 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
351 FIXME("(%p)->(%p)\n", This
, p
);
355 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
357 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
358 FIXME("(%p)->(%p)\n", This
, p
);
362 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
364 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
365 FIXME("(%p)->()\n", This
);
369 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
371 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
372 FIXME("(%p)->(%p)\n", This
, p
);
376 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
378 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
379 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
383 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
385 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
386 FIXME("(%p)->(%p)\n", This
, p
);
390 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
392 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
394 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
396 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
399 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
401 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
403 TRACE("(%p)->(%p)\n", This
, p
);
405 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
408 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
410 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
411 FIXME("(%p)->()\n", This
);
415 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
417 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
418 FIXME("(%p)->(%p)\n", This
, p
);
422 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
424 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
425 FIXME("(%p)->()\n", This
);
429 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
431 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
432 FIXME("(%p)->(%p)\n", This
, p
);
436 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
438 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
439 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
443 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
445 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
449 TRACE("(%p)->(%p)\n", This
, p
);
451 nsAString_Init(&strName
, NULL
);
452 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &strName
);
453 if(NS_SUCCEEDED(nsres
)) {
454 const PRUnichar
*str
;
456 nsAString_GetData(&strName
, &str
);
457 *p
= *str
? SysAllocString(str
) : NULL
;
459 ERR("GetName failed: %08x\n", nsres
);
461 nsAString_Finish(&strName
);
463 return NS_SUCCEEDED(nsres
) ? S_OK
: E_FAIL
;
466 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
468 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
471 TRACE("(%p)->(%d)\n", This
, v
);
473 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
474 if(NS_FAILED(nsres
)) {
475 ERR("SetWidth failed: %08x\n", nsres
);
482 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
484 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
488 TRACE("(%p)->(%p)\n", This
, p
);
490 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
491 if(NS_FAILED(nsres
)) {
492 ERR("GetWidth failed: %08x\n", nsres
);
500 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
502 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
505 TRACE("(%p)->(%d)\n", This
, v
);
507 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
508 if(NS_FAILED(nsres
)) {
509 ERR("SetHeight failed: %08x\n", nsres
);
516 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
518 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
522 TRACE("(%p)->(%p)\n", This
, p
);
524 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
525 if(NS_FAILED(nsres
)) {
526 ERR("GetHeight failed: %08x\n", nsres
);
534 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
536 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
537 FIXME("(%p)->()\n", This
);
541 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
543 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
544 FIXME("(%p)->(%p)\n", This
, p
);
548 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
549 HTMLImgElement_QueryInterface
,
550 HTMLImgElement_AddRef
,
551 HTMLImgElement_Release
,
552 HTMLImgElement_GetTypeInfoCount
,
553 HTMLImgElement_GetTypeInfo
,
554 HTMLImgElement_GetIDsOfNames
,
555 HTMLImgElement_Invoke
,
556 HTMLImgElement_put_isMap
,
557 HTMLImgElement_get_isMap
,
558 HTMLImgElement_put_useMap
,
559 HTMLImgElement_get_useMap
,
560 HTMLImgElement_get_mimeType
,
561 HTMLImgElement_get_fileSize
,
562 HTMLImgElement_get_fileCreatedDate
,
563 HTMLImgElement_get_fileModifiedDate
,
564 HTMLImgElement_get_fileUpdatedDate
,
565 HTMLImgElement_get_protocol
,
566 HTMLImgElement_get_href
,
567 HTMLImgElement_get_nameProp
,
568 HTMLImgElement_put_border
,
569 HTMLImgElement_get_border
,
570 HTMLImgElement_put_vspace
,
571 HTMLImgElement_get_vspace
,
572 HTMLImgElement_put_hspace
,
573 HTMLImgElement_get_hspace
,
574 HTMLImgElement_put_alt
,
575 HTMLImgElement_get_alt
,
576 HTMLImgElement_put_src
,
577 HTMLImgElement_get_src
,
578 HTMLImgElement_put_lowsrc
,
579 HTMLImgElement_get_lowsrc
,
580 HTMLImgElement_put_vrml
,
581 HTMLImgElement_get_vrml
,
582 HTMLImgElement_put_dynsrc
,
583 HTMLImgElement_get_dynsrc
,
584 HTMLImgElement_get_readyState
,
585 HTMLImgElement_get_complete
,
586 HTMLImgElement_put_loop
,
587 HTMLImgElement_get_loop
,
588 HTMLImgElement_put_align
,
589 HTMLImgElement_get_align
,
590 HTMLImgElement_put_onload
,
591 HTMLImgElement_get_onload
,
592 HTMLImgElement_put_onerror
,
593 HTMLImgElement_get_onerror
,
594 HTMLImgElement_put_onabort
,
595 HTMLImgElement_get_onabort
,
596 HTMLImgElement_put_name
,
597 HTMLImgElement_get_name
,
598 HTMLImgElement_put_width
,
599 HTMLImgElement_get_width
,
600 HTMLImgElement_put_height
,
601 HTMLImgElement_get_height
,
602 HTMLImgElement_put_start
,
603 HTMLImgElement_get_start
606 #define HTMLIMG_NODE_THIS(iface) DEFINE_THIS2(HTMLImgElement, element.node, iface)
608 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
610 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
614 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
615 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
616 *ppv
= &This
->IHTMLImgElement_iface
;
618 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
621 IUnknown_AddRef((IUnknown
*)*ppv
);
625 static void HTMLImgElement_destructor(HTMLDOMNode
*iface
)
627 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
630 nsIDOMHTMLImageElement_Release(This
->nsimg
);
632 HTMLElement_destructor(&This
->element
.node
);
635 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
637 HTMLImgElement
*This
= HTMLIMG_NODE_THIS(iface
);
639 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
642 #undef HTMLIMG_NODE_THIS
644 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
646 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 HRESULT
HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
673 ret
= heap_alloc_zero(sizeof(HTMLImgElement
));
675 return E_OUTOFMEMORY
;
677 ret
->IHTMLImgElement_iface
.lpVtbl
= &HTMLImgElementVtbl
;
678 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
680 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
681 if(NS_FAILED(nsres
)) {
682 ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres
);
687 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
689 *elem
= &ret
->element
;
693 #define HTMLIMGFACTORY_THIS(iface) DEFINE_THIS(HTMLImageElementFactory, HTMLImageElementFactory, iface)
695 static HRESULT WINAPI
HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory
*iface
,
696 REFIID riid
, void **ppv
)
698 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
702 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
703 TRACE("(%p)->(IID_Unknown %p)\n", This
, ppv
);
704 *ppv
= HTMLIMGFACTORY(This
);
705 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
)) {
706 TRACE("(%p)->(IID_IHTMLImageElementFactory %p)\n", This
, ppv
);
707 *ppv
= HTMLIMGFACTORY(This
);
708 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
))
709 return *ppv
? S_OK
: E_NOINTERFACE
;
712 IUnknown_AddRef((IUnknown
*)*ppv
);
716 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
717 return E_NOINTERFACE
;
720 static ULONG WINAPI
HTMLImageElementFactory_AddRef(IHTMLImageElementFactory
*iface
)
722 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
723 LONG ref
= InterlockedIncrement(&This
->ref
);
725 TRACE("(%p) ref=%d\n", This
, ref
);
730 static ULONG WINAPI
HTMLImageElementFactory_Release(IHTMLImageElementFactory
*iface
)
732 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
733 LONG ref
= InterlockedDecrement(&This
->ref
);
735 TRACE("(%p) ref=%d\n", This
, ref
);
743 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory
*iface
,
746 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
747 FIXME("(%p)->(%p)\n", This
, pctinfo
);
751 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory
*iface
,
752 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
754 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
755 FIXME("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
759 static HRESULT WINAPI
HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory
*iface
,
760 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
,
763 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
764 FIXME("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
,
765 cNames
, lcid
, rgDispId
);
769 static HRESULT WINAPI
HTMLImageElementFactory_Invoke(IHTMLImageElementFactory
*iface
,
770 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
,
771 DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
774 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
775 FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
776 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
780 static LONG
var_to_size(const VARIANT
*v
)
791 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
793 FIXME("VarI4FromStr failed: %08x\n", hres
);
799 FIXME("unsupported size %s\n", debugstr_variant(v
));
804 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
805 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
807 HTMLImageElementFactory
*This
= HTMLIMGFACTORY_THIS(iface
);
808 IHTMLImgElement
*img
;
810 nsIDOMHTMLElement
*nselem
;
814 static const PRUnichar imgW
[] = {'I','M','G',0};
816 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
817 debugstr_variant(&height
), img_elem
);
819 if(!This
->window
|| !This
->window
->doc
) {
826 hres
= create_nselem(This
->window
->doc
, imgW
, &nselem
);
830 hres
= HTMLElement_Create(This
->window
->doc
, (nsIDOMNode
*)nselem
, FALSE
, &elem
);
831 nsIDOMHTMLElement_Release(nselem
);
833 ERR("HTMLElement_Create failed\n");
837 hres
= IHTMLElement_QueryInterface(HTMLELEM(elem
), &IID_IHTMLImgElement
, (void**)&img
);
839 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres
);
843 l
= var_to_size(&width
);
845 IHTMLImgElement_put_width(img
, l
);
846 l
= var_to_size(&height
);
848 IHTMLImgElement_put_height(img
, l
);
854 #undef HTMLIMGFACTORY_THIS
856 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
857 HTMLImageElementFactory_QueryInterface
,
858 HTMLImageElementFactory_AddRef
,
859 HTMLImageElementFactory_Release
,
860 HTMLImageElementFactory_GetTypeInfoCount
,
861 HTMLImageElementFactory_GetTypeInfo
,
862 HTMLImageElementFactory_GetIDsOfNames
,
863 HTMLImageElementFactory_Invoke
,
864 HTMLImageElementFactory_create
867 static inline HTMLImageElementFactory
*impl_from_DispatchEx(DispatchEx
*iface
)
869 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, dispex
);
872 static HRESULT
HTMLImageElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
873 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
874 IServiceProvider
*caller
)
876 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
877 IHTMLImgElement
*img
;
878 VARIANT empty
, *width
, *height
;
880 int argc
= params
->cArgs
- params
->cNamedArgs
;
884 V_VT(&empty
) = VT_EMPTY
;
886 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
887 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
889 hres
= IHTMLImageElementFactory_create(HTMLIMGFACTORY(This
), *width
, *height
, &img
);
893 V_VT(res
) = VT_DISPATCH
;
894 V_DISPATCH(res
) = (IDispatch
*)img
;
899 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
900 IHTMLImageElementFactory_tid
,
904 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
905 HTMLImageElementFactory_value
,
910 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
911 &HTMLImageElementFactory_dispex_vtbl
,
912 IHTMLImageElementFactory_tid
,
914 HTMLImageElementFactory_iface_tids
917 HTMLImageElementFactory
*HTMLImageElementFactory_Create(HTMLWindow
*window
)
919 HTMLImageElementFactory
*ret
;
921 ret
= heap_alloc(sizeof(HTMLImageElementFactory
));
923 ret
->lpHTMLImageElementFactoryVtbl
= &HTMLImageElementFactoryVtbl
;
925 ret
->window
= window
;
927 init_dispex(&ret
->dispex
, (IUnknown
*)HTMLIMGFACTORY(ret
), &HTMLImageElementFactory_dispex
);