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 "mshtml_private.h"
24 IHTMLImgElement IHTMLImgElement_iface
;
26 nsIDOMHTMLImageElement
*nsimg
;
29 static inline HTMLImgElement
*impl_from_IHTMLImgElement(IHTMLImgElement
*iface
)
31 return CONTAINING_RECORD(iface
, HTMLImgElement
, IHTMLImgElement_iface
);
34 static HRESULT WINAPI
HTMLImgElement_QueryInterface(IHTMLImgElement
*iface
, REFIID riid
, void **ppv
)
36 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
38 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
41 static ULONG WINAPI
HTMLImgElement_AddRef(IHTMLImgElement
*iface
)
43 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
45 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
48 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
50 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
52 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
55 static HRESULT WINAPI
HTMLImgElement_GetTypeInfoCount(IHTMLImgElement
*iface
, UINT
*pctinfo
)
57 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
58 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.dispex
.IDispatchEx_iface
, pctinfo
);
61 static HRESULT WINAPI
HTMLImgElement_GetTypeInfo(IHTMLImgElement
*iface
, UINT iTInfo
,
62 LCID lcid
, ITypeInfo
**ppTInfo
)
64 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
65 return IDispatchEx_GetTypeInfo(&This
->element
.node
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
69 static HRESULT WINAPI
HTMLImgElement_GetIDsOfNames(IHTMLImgElement
*iface
, REFIID riid
,
70 LPOLESTR
*rgszNames
, UINT cNames
,
71 LCID lcid
, DISPID
*rgDispId
)
73 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
74 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
75 cNames
, lcid
, rgDispId
);
78 static HRESULT WINAPI
HTMLImgElement_Invoke(IHTMLImgElement
*iface
, DISPID dispIdMember
,
79 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
80 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
82 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
83 return IDispatchEx_Invoke(&This
->element
.node
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
84 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
87 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
89 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
92 TRACE("(%p)->(%x)\n", This
, v
);
94 nsres
= nsIDOMHTMLImageElement_SetIsMap(This
->nsimg
, v
!= VARIANT_FALSE
);
95 if (NS_FAILED(nsres
)) {
96 ERR("Set IsMap failed: %08x\n", nsres
);
103 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
105 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
109 TRACE("(%p)->(%p)\n", This
, p
);
114 nsres
= nsIDOMHTMLImageElement_GetIsMap(This
->nsimg
, &b
);
115 if (NS_FAILED(nsres
)) {
116 ERR("Get IsMap failed: %08x\n", nsres
);
119 *p
= b
? VARIANT_TRUE
: VARIANT_FALSE
;
123 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
125 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
126 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
130 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
132 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
133 FIXME("(%p)->(%p)\n", This
, p
);
137 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
139 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
140 FIXME("(%p)->(%p)\n", This
, p
);
144 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
146 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
147 FIXME("(%p)->(%p)\n", This
, p
);
151 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
153 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
154 FIXME("(%p)->(%p)\n", This
, p
);
158 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
160 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
161 FIXME("(%p)->(%p)\n", This
, p
);
165 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
167 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
168 FIXME("(%p)->(%p)\n", This
, p
);
172 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
174 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
175 FIXME("(%p)->(%p)\n", This
, p
);
179 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
181 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
182 FIXME("(%p)->(%p)\n", This
, p
);
186 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
188 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
189 FIXME("(%p)->(%p)\n", This
, p
);
193 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
195 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
196 FIXME("(%p)->()\n", This
);
200 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
202 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
203 FIXME("(%p)->(%p)\n", This
, p
);
207 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
209 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
210 FIXME("(%p)->(%d)\n", This
, v
);
214 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
216 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
217 FIXME("(%p)->(%p)\n", This
, p
);
221 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
223 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
224 FIXME("(%p)->(%d)\n", This
, v
);
228 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
230 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
231 FIXME("(%p)->(%p)\n", This
, p
);
235 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
237 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
241 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
243 nsAString_InitDepend(&alt_str
, v
);
244 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
245 nsAString_Finish(&alt_str
);
247 ERR("SetAlt failed: %08x\n", nsres
);
252 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
254 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
258 TRACE("(%p)->(%p)\n", This
, p
);
260 nsAString_Init(&alt_str
, NULL
);
261 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
262 return return_nsstr(nsres
, &alt_str
, p
);
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 static const WCHAR blockedW
[] = {'B','L','O','C','K','E','D',':',':',0};
292 TRACE("(%p)->(%p)\n", This
, p
);
294 nsAString_Init(&src_str
, NULL
);
295 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
296 if(NS_SUCCEEDED(nsres
)) {
297 nsAString_GetData(&src_str
, &src
);
299 if(!strncmpiW(src
, blockedW
, sizeof(blockedW
)/sizeof(WCHAR
)-1)) {
300 TRACE("returning BLOCKED::\n");
301 *p
= SysAllocString(blockedW
);
303 hres
= E_OUTOFMEMORY
;
305 hres
= nsuri_to_url(src
, TRUE
, p
);
308 ERR("GetSrc failed: %08x\n", nsres
);
312 nsAString_Finish(&src_str
);
316 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
318 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
319 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
323 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
325 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
326 FIXME("(%p)->(%p)\n", This
, p
);
330 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
332 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
333 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
337 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
339 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
340 FIXME("(%p)->(%p)\n", This
, p
);
344 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
346 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
347 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
351 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
353 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
354 FIXME("(%p)->(%p)\n", This
, p
);
358 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
360 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
361 FIXME("(%p)->(%p)\n", This
, p
);
365 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
367 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
371 TRACE("(%p)->(%p)\n", This
, p
);
373 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
374 if(NS_FAILED(nsres
)) {
375 ERR("GetComplete failed: %08x\n", nsres
);
379 *p
= complete
? VARIANT_TRUE
: VARIANT_FALSE
;
383 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
385 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
386 FIXME("(%p)->()\n", This
);
390 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
392 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
393 FIXME("(%p)->(%p)\n", This
, p
);
397 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
399 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
403 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
405 nsAString_InitDepend(&str
, v
);
407 nsres
= nsIDOMHTMLImageElement_SetAlign(This
->nsimg
, &str
);
408 nsAString_Finish(&str
);
409 if (NS_FAILED(nsres
)){
410 ERR("Set Align(%s) failed: %08x\n", debugstr_w(v
), nsres
);
417 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
419 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
423 TRACE("(%p)->(%p)\n", This
, p
);
425 nsAString_Init(&str
, NULL
);
426 nsres
= nsIDOMHTMLImageElement_GetAlign(This
->nsimg
, &str
);
428 return return_nsstr(nsres
, &str
, p
);
431 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
433 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
435 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
437 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
440 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
442 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
444 TRACE("(%p)->(%p)\n", This
, p
);
446 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
449 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
451 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
453 TRACE("(%p)->()\n", This
);
455 return set_node_event(&This
->element
.node
, EVENTID_ERROR
, &v
);
458 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
460 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
462 TRACE("(%p)->(%p)\n", This
, p
);
464 return get_node_event(&This
->element
.node
, EVENTID_ERROR
, p
);
467 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
469 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
471 TRACE("(%p)->()\n", This
);
473 return set_node_event(&This
->element
.node
, EVENTID_ABORT
, &v
);
476 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
478 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
480 TRACE("(%p)->(%p)\n", This
, p
);
482 return get_node_event(&This
->element
.node
, EVENTID_ABORT
, p
);
485 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
487 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
488 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
492 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
494 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
498 TRACE("(%p)->(%p)\n", This
, p
);
500 nsAString_Init(&name
, NULL
);
501 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &name
);
502 return return_nsstr(nsres
, &name
, p
);
505 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
507 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
510 TRACE("(%p)->(%d)\n", This
, v
);
512 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
513 if(NS_FAILED(nsres
)) {
514 ERR("SetWidth failed: %08x\n", nsres
);
521 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
523 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
527 TRACE("(%p)->(%p)\n", This
, p
);
529 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
530 if(NS_FAILED(nsres
)) {
531 ERR("GetWidth failed: %08x\n", nsres
);
539 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
541 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
544 TRACE("(%p)->(%d)\n", This
, v
);
546 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
547 if(NS_FAILED(nsres
)) {
548 ERR("SetHeight failed: %08x\n", nsres
);
555 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
557 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
561 TRACE("(%p)->(%p)\n", This
, p
);
563 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
564 if(NS_FAILED(nsres
)) {
565 ERR("GetHeight failed: %08x\n", nsres
);
573 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
575 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
576 FIXME("(%p)->()\n", This
);
580 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
582 HTMLImgElement
*This
= impl_from_IHTMLImgElement(iface
);
583 FIXME("(%p)->(%p)\n", This
, p
);
587 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
588 HTMLImgElement_QueryInterface
,
589 HTMLImgElement_AddRef
,
590 HTMLImgElement_Release
,
591 HTMLImgElement_GetTypeInfoCount
,
592 HTMLImgElement_GetTypeInfo
,
593 HTMLImgElement_GetIDsOfNames
,
594 HTMLImgElement_Invoke
,
595 HTMLImgElement_put_isMap
,
596 HTMLImgElement_get_isMap
,
597 HTMLImgElement_put_useMap
,
598 HTMLImgElement_get_useMap
,
599 HTMLImgElement_get_mimeType
,
600 HTMLImgElement_get_fileSize
,
601 HTMLImgElement_get_fileCreatedDate
,
602 HTMLImgElement_get_fileModifiedDate
,
603 HTMLImgElement_get_fileUpdatedDate
,
604 HTMLImgElement_get_protocol
,
605 HTMLImgElement_get_href
,
606 HTMLImgElement_get_nameProp
,
607 HTMLImgElement_put_border
,
608 HTMLImgElement_get_border
,
609 HTMLImgElement_put_vspace
,
610 HTMLImgElement_get_vspace
,
611 HTMLImgElement_put_hspace
,
612 HTMLImgElement_get_hspace
,
613 HTMLImgElement_put_alt
,
614 HTMLImgElement_get_alt
,
615 HTMLImgElement_put_src
,
616 HTMLImgElement_get_src
,
617 HTMLImgElement_put_lowsrc
,
618 HTMLImgElement_get_lowsrc
,
619 HTMLImgElement_put_vrml
,
620 HTMLImgElement_get_vrml
,
621 HTMLImgElement_put_dynsrc
,
622 HTMLImgElement_get_dynsrc
,
623 HTMLImgElement_get_readyState
,
624 HTMLImgElement_get_complete
,
625 HTMLImgElement_put_loop
,
626 HTMLImgElement_get_loop
,
627 HTMLImgElement_put_align
,
628 HTMLImgElement_get_align
,
629 HTMLImgElement_put_onload
,
630 HTMLImgElement_get_onload
,
631 HTMLImgElement_put_onerror
,
632 HTMLImgElement_get_onerror
,
633 HTMLImgElement_put_onabort
,
634 HTMLImgElement_get_onabort
,
635 HTMLImgElement_put_name
,
636 HTMLImgElement_get_name
,
637 HTMLImgElement_put_width
,
638 HTMLImgElement_get_width
,
639 HTMLImgElement_put_height
,
640 HTMLImgElement_get_height
,
641 HTMLImgElement_put_start
,
642 HTMLImgElement_get_start
645 static inline HTMLImgElement
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
647 return CONTAINING_RECORD(iface
, HTMLImgElement
, element
.node
);
650 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
652 HTMLImgElement
*This
= impl_from_HTMLDOMNode(iface
);
656 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
657 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
658 *ppv
= &This
->IHTMLImgElement_iface
;
660 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
663 IUnknown_AddRef((IUnknown
*)*ppv
);
667 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
669 HTMLImgElement
*This
= impl_from_HTMLDOMNode(iface
);
671 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
674 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
676 HTMLElement_destructor
,
679 HTMLElement_handle_event
,
680 HTMLElement_get_attr_col
,
686 HTMLImgElement_get_readystate
689 static const tid_t HTMLImgElement_iface_tids
[] = {
694 static dispex_static_data_t HTMLImgElement_dispex
= {
698 HTMLImgElement_iface_tids
701 HRESULT
HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMHTMLElement
*nselem
, HTMLElement
**elem
)
706 ret
= heap_alloc_zero(sizeof(HTMLImgElement
));
708 return E_OUTOFMEMORY
;
710 ret
->IHTMLImgElement_iface
.lpVtbl
= &HTMLImgElementVtbl
;
711 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
713 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
715 nsres
= nsIDOMHTMLElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
717 /* Share nsimg reference with nsnode */
718 assert(nsres
== NS_OK
&& (nsIDOMNode
*)ret
->nsimg
== ret
->element
.node
.nsnode
);
719 nsIDOMNode_Release(ret
->element
.node
.nsnode
);
721 *elem
= &ret
->element
;
725 static inline HTMLImageElementFactory
*impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory
*iface
)
727 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, IHTMLImageElementFactory_iface
);
730 static HRESULT WINAPI
HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory
*iface
,
731 REFIID riid
, void **ppv
)
733 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
735 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
737 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
738 *ppv
= &This
->IHTMLImageElementFactory_iface
;
739 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
)) {
740 *ppv
= &This
->IHTMLImageElementFactory_iface
;
741 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
742 return *ppv
? S_OK
: E_NOINTERFACE
;
745 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
746 return E_NOINTERFACE
;
749 IUnknown_AddRef((IUnknown
*)*ppv
);
753 static ULONG WINAPI
HTMLImageElementFactory_AddRef(IHTMLImageElementFactory
*iface
)
755 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
756 LONG ref
= InterlockedIncrement(&This
->ref
);
758 TRACE("(%p) ref=%d\n", This
, ref
);
763 static ULONG WINAPI
HTMLImageElementFactory_Release(IHTMLImageElementFactory
*iface
)
765 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
766 LONG ref
= InterlockedDecrement(&This
->ref
);
768 TRACE("(%p) ref=%d\n", This
, ref
);
776 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory
*iface
,
779 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
780 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
783 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory
*iface
,
784 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
786 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
787 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
790 static HRESULT WINAPI
HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory
*iface
,
791 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
,
794 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
795 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
798 static HRESULT WINAPI
HTMLImageElementFactory_Invoke(IHTMLImageElementFactory
*iface
,
799 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
,
800 DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
803 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
804 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
805 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
808 static LONG
var_to_size(const VARIANT
*v
)
819 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
821 FIXME("VarI4FromStr failed: %08x\n", hres
);
827 FIXME("unsupported size %s\n", debugstr_variant(v
));
832 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
833 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
835 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
836 HTMLDocumentNode
*doc
;
837 IHTMLImgElement
*img
;
839 nsIDOMHTMLElement
*nselem
;
843 static const PRUnichar imgW
[] = {'I','M','G',0};
845 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
846 debugstr_variant(&height
), img_elem
);
848 if(!This
->window
|| !This
->window
->doc
) {
853 doc
= This
->window
->doc
;
857 hres
= create_nselem(doc
, imgW
, &nselem
);
861 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, FALSE
, &elem
);
862 nsIDOMHTMLElement_Release(nselem
);
864 ERR("HTMLElement_Create failed\n");
868 hres
= IHTMLElement_QueryInterface(&elem
->IHTMLElement_iface
, &IID_IHTMLImgElement
,
870 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
872 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres
);
876 l
= var_to_size(&width
);
878 IHTMLImgElement_put_width(img
, l
);
879 l
= var_to_size(&height
);
881 IHTMLImgElement_put_height(img
, l
);
887 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
888 HTMLImageElementFactory_QueryInterface
,
889 HTMLImageElementFactory_AddRef
,
890 HTMLImageElementFactory_Release
,
891 HTMLImageElementFactory_GetTypeInfoCount
,
892 HTMLImageElementFactory_GetTypeInfo
,
893 HTMLImageElementFactory_GetIDsOfNames
,
894 HTMLImageElementFactory_Invoke
,
895 HTMLImageElementFactory_create
898 static inline HTMLImageElementFactory
*impl_from_DispatchEx(DispatchEx
*iface
)
900 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, dispex
);
903 static HRESULT
HTMLImageElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
904 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
905 IServiceProvider
*caller
)
907 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
908 IHTMLImgElement
*img
;
909 VARIANT empty
, *width
, *height
;
911 int argc
= params
->cArgs
- params
->cNamedArgs
;
915 V_VT(&empty
) = VT_EMPTY
;
917 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
918 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
920 hres
= IHTMLImageElementFactory_create(&This
->IHTMLImageElementFactory_iface
, *width
, *height
,
925 V_VT(res
) = VT_DISPATCH
;
926 V_DISPATCH(res
) = (IDispatch
*)img
;
931 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
932 IHTMLImageElementFactory_tid
,
936 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
937 HTMLImageElementFactory_value
,
943 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
944 &HTMLImageElementFactory_dispex_vtbl
,
945 IHTMLImageElementFactory_tid
,
947 HTMLImageElementFactory_iface_tids
950 HRESULT
HTMLImageElementFactory_Create(HTMLInnerWindow
*window
, HTMLImageElementFactory
**ret_val
)
952 HTMLImageElementFactory
*ret
;
954 ret
= heap_alloc(sizeof(HTMLImageElementFactory
));
956 return E_OUTOFMEMORY
;
958 ret
->IHTMLImageElementFactory_iface
.lpVtbl
= &HTMLImageElementFactoryVtbl
;
960 ret
->window
= window
;
962 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLImageElementFactory_iface
,
963 &HTMLImageElementFactory_dispex
);