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 HTMLImg
*impl_from_IHTMLImgElement(IHTMLImgElement
*iface
)
45 return CONTAINING_RECORD(iface
, HTMLImg
, IHTMLImgElement_iface
);
48 static HRESULT WINAPI
HTMLImgElement_QueryInterface(IHTMLImgElement
*iface
, REFIID riid
, void **ppv
)
50 HTMLImg
*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 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
59 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
62 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
64 HTMLImg
*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 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
72 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
75 static HRESULT WINAPI
HTMLImgElement_GetTypeInfo(IHTMLImgElement
*iface
, UINT iTInfo
,
76 LCID lcid
, ITypeInfo
**ppTInfo
)
78 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
79 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.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 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
88 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.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 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
97 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.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 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
106 TRACE("(%p)->(%x)\n", This
, v
);
108 nsres
= nsIDOMHTMLImageElement_SetIsMap(This
->nsimg
, v
!= VARIANT_FALSE
);
109 if (NS_FAILED(nsres
)) {
110 ERR("Set IsMap failed: %08lx\n", nsres
);
117 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
119 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
123 TRACE("(%p)->(%p)\n", This
, p
);
128 nsres
= nsIDOMHTMLImageElement_GetIsMap(This
->nsimg
, &b
);
129 if (NS_FAILED(nsres
)) {
130 ERR("Get IsMap failed: %08lx\n", nsres
);
134 *p
= variant_bool(b
);
138 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
140 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
141 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
145 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
147 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
148 FIXME("(%p)->(%p)\n", This
, p
);
152 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
154 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
155 FIXME("(%p)->(%p)\n", This
, p
);
159 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
161 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
162 FIXME("(%p)->(%p)\n", This
, p
);
166 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
168 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
169 FIXME("(%p)->(%p)\n", This
, p
);
173 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
175 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
176 FIXME("(%p)->(%p)\n", This
, p
);
180 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
182 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
183 FIXME("(%p)->(%p)\n", This
, p
);
187 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
189 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
190 FIXME("(%p)->(%p)\n", This
, p
);
194 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
196 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
197 FIXME("(%p)->(%p)\n", This
, p
);
201 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
203 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
204 FIXME("(%p)->(%p)\n", This
, p
);
208 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
210 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
211 FIXME("(%p)->()\n", This
);
215 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
217 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
218 FIXME("(%p)->(%p)\n", This
, p
);
222 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
224 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
225 FIXME("(%p)->(%ld)\n", This
, v
);
229 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
231 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
232 FIXME("(%p)->(%p)\n", This
, p
);
236 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
238 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
239 FIXME("(%p)->(%ld)\n", This
, v
);
243 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
245 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
246 FIXME("(%p)->(%p)\n", This
, p
);
250 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
252 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
256 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
258 nsAString_InitDepend(&alt_str
, v
);
259 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
260 nsAString_Finish(&alt_str
);
262 ERR("SetAlt failed: %08lx\n", nsres
);
267 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
269 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
273 TRACE("(%p)->(%p)\n", This
, p
);
275 nsAString_Init(&alt_str
, NULL
);
276 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
277 return return_nsstr(nsres
, &alt_str
, p
);
280 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
282 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
286 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
288 nsAString_InitDepend(&src_str
, v
);
289 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
290 nsAString_Finish(&src_str
);
292 ERR("SetSrc failed: %08lx\n", nsres
);
297 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
299 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
300 const PRUnichar
*src
;
305 TRACE("(%p)->(%p)\n", This
, p
);
307 nsAString_Init(&src_str
, NULL
);
308 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
309 if(NS_SUCCEEDED(nsres
)) {
310 nsAString_GetData(&src_str
, &src
);
312 if(!wcsnicmp(src
, L
"BLOCKED::", ARRAY_SIZE(L
"BLOCKED::")-1)) {
313 TRACE("returning BLOCKED::\n");
314 *p
= SysAllocString(L
"BLOCKED::");
316 hres
= E_OUTOFMEMORY
;
318 hres
= nsuri_to_url(src
, TRUE
, p
);
321 ERR("GetSrc failed: %08lx\n", nsres
);
325 nsAString_Finish(&src_str
);
329 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
331 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
332 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
336 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
338 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
339 FIXME("(%p)->(%p)\n", This
, p
);
343 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
345 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
346 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
350 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
352 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
353 FIXME("(%p)->(%p)\n", This
, p
);
357 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
359 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
360 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
364 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
366 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
367 FIXME("(%p)->(%p)\n", This
, p
);
371 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
373 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
374 FIXME("(%p)->(%p)\n", This
, p
);
378 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
380 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
384 TRACE("(%p)->(%p)\n", This
, p
);
386 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
387 if(NS_FAILED(nsres
)) {
388 ERR("GetComplete failed: %08lx\n", nsres
);
392 *p
= variant_bool(complete
);
396 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
398 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
399 FIXME("(%p)->()\n", This
);
403 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
405 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
406 FIXME("(%p)->(%p)\n", This
, p
);
410 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
412 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
416 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
418 nsAString_InitDepend(&str
, v
);
420 nsres
= nsIDOMHTMLImageElement_SetAlign(This
->nsimg
, &str
);
421 nsAString_Finish(&str
);
422 if (NS_FAILED(nsres
)){
423 ERR("Set Align(%s) failed: %08lx\n", debugstr_w(v
), nsres
);
430 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
432 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
436 TRACE("(%p)->(%p)\n", This
, p
);
438 nsAString_Init(&str
, NULL
);
439 nsres
= nsIDOMHTMLImageElement_GetAlign(This
->nsimg
, &str
);
441 return return_nsstr(nsres
, &str
, p
);
444 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
446 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
448 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
450 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
453 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
455 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
457 TRACE("(%p)->(%p)\n", This
, p
);
459 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
462 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
464 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
466 TRACE("(%p)->()\n", This
);
468 return set_node_event(&This
->element
.node
, EVENTID_ERROR
, &v
);
471 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
473 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
475 TRACE("(%p)->(%p)\n", This
, p
);
477 return get_node_event(&This
->element
.node
, EVENTID_ERROR
, p
);
480 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
482 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
484 TRACE("(%p)->()\n", This
);
486 return set_node_event(&This
->element
.node
, EVENTID_ABORT
, &v
);
489 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
491 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
493 TRACE("(%p)->(%p)\n", This
, p
);
495 return get_node_event(&This
->element
.node
, EVENTID_ABORT
, p
);
498 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
500 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
501 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
505 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
507 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
511 TRACE("(%p)->(%p)\n", This
, p
);
513 nsAString_Init(&name
, NULL
);
514 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &name
);
515 return return_nsstr(nsres
, &name
, p
);
518 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
520 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
523 TRACE("(%p)->(%ld)\n", This
, v
);
525 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
526 if(NS_FAILED(nsres
)) {
527 ERR("SetWidth failed: %08lx\n", nsres
);
534 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
536 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
540 TRACE("(%p)->(%p)\n", This
, p
);
542 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
543 if(NS_FAILED(nsres
)) {
544 ERR("GetWidth failed: %08lx\n", nsres
);
552 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
554 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
557 TRACE("(%p)->(%ld)\n", This
, v
);
559 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
560 if(NS_FAILED(nsres
)) {
561 ERR("SetHeight failed: %08lx\n", nsres
);
568 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
570 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
574 TRACE("(%p)->(%p)\n", This
, p
);
576 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
577 if(NS_FAILED(nsres
)) {
578 ERR("GetHeight failed: %08lx\n", nsres
);
586 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
588 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
589 FIXME("(%p)->()\n", This
);
593 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
595 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
596 FIXME("(%p)->(%p)\n", This
, p
);
600 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
601 HTMLImgElement_QueryInterface
,
602 HTMLImgElement_AddRef
,
603 HTMLImgElement_Release
,
604 HTMLImgElement_GetTypeInfoCount
,
605 HTMLImgElement_GetTypeInfo
,
606 HTMLImgElement_GetIDsOfNames
,
607 HTMLImgElement_Invoke
,
608 HTMLImgElement_put_isMap
,
609 HTMLImgElement_get_isMap
,
610 HTMLImgElement_put_useMap
,
611 HTMLImgElement_get_useMap
,
612 HTMLImgElement_get_mimeType
,
613 HTMLImgElement_get_fileSize
,
614 HTMLImgElement_get_fileCreatedDate
,
615 HTMLImgElement_get_fileModifiedDate
,
616 HTMLImgElement_get_fileUpdatedDate
,
617 HTMLImgElement_get_protocol
,
618 HTMLImgElement_get_href
,
619 HTMLImgElement_get_nameProp
,
620 HTMLImgElement_put_border
,
621 HTMLImgElement_get_border
,
622 HTMLImgElement_put_vspace
,
623 HTMLImgElement_get_vspace
,
624 HTMLImgElement_put_hspace
,
625 HTMLImgElement_get_hspace
,
626 HTMLImgElement_put_alt
,
627 HTMLImgElement_get_alt
,
628 HTMLImgElement_put_src
,
629 HTMLImgElement_get_src
,
630 HTMLImgElement_put_lowsrc
,
631 HTMLImgElement_get_lowsrc
,
632 HTMLImgElement_put_vrml
,
633 HTMLImgElement_get_vrml
,
634 HTMLImgElement_put_dynsrc
,
635 HTMLImgElement_get_dynsrc
,
636 HTMLImgElement_get_readyState
,
637 HTMLImgElement_get_complete
,
638 HTMLImgElement_put_loop
,
639 HTMLImgElement_get_loop
,
640 HTMLImgElement_put_align
,
641 HTMLImgElement_get_align
,
642 HTMLImgElement_put_onload
,
643 HTMLImgElement_get_onload
,
644 HTMLImgElement_put_onerror
,
645 HTMLImgElement_get_onerror
,
646 HTMLImgElement_put_onabort
,
647 HTMLImgElement_get_onabort
,
648 HTMLImgElement_put_name
,
649 HTMLImgElement_get_name
,
650 HTMLImgElement_put_width
,
651 HTMLImgElement_get_width
,
652 HTMLImgElement_put_height
,
653 HTMLImgElement_get_height
,
654 HTMLImgElement_put_start
,
655 HTMLImgElement_get_start
658 static inline HTMLImg
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
660 return CONTAINING_RECORD(iface
, HTMLImg
, element
.node
);
663 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
665 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
669 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
670 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
671 *ppv
= &This
->IHTMLImgElement_iface
;
673 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
676 IUnknown_AddRef((IUnknown
*)*ppv
);
680 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
682 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
684 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
687 static void HTMLImgElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
689 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
692 note_cc_edge((nsISupports
*)This
->nsimg
, "This->nsimg", cb
);
695 static void HTMLImgElement_unlink(HTMLDOMNode
*iface
)
697 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
700 nsIDOMHTMLImageElement
*nsimg
= This
->nsimg
;
703 nsIDOMHTMLImageElement_Release(nsimg
);
707 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
710 HTMLElement_destructor
,
713 HTMLElement_handle_event
,
714 HTMLElement_get_attr_col
,
719 HTMLImgElement_get_readystate
,
723 HTMLImgElement_traverse
,
724 HTMLImgElement_unlink
727 static const tid_t HTMLImgElement_iface_tids
[] = {
732 static dispex_static_data_t HTMLImgElement_dispex
= {
736 HTMLImgElement_iface_tids
,
737 HTMLElement_init_dispex_info
740 HRESULT
HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
745 ret
= heap_alloc_zero(sizeof(HTMLImg
));
747 return E_OUTOFMEMORY
;
749 ret
->IHTMLImgElement_iface
.lpVtbl
= &HTMLImgElementVtbl
;
750 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
752 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
754 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
755 assert(nsres
== NS_OK
);
757 *elem
= &ret
->element
;
761 static inline HTMLImageElementFactory
*impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory
*iface
)
763 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, IHTMLImageElementFactory_iface
);
766 static HRESULT WINAPI
HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory
*iface
,
767 REFIID riid
, void **ppv
)
769 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
771 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
773 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
774 *ppv
= &This
->IHTMLImageElementFactory_iface
;
775 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
)) {
776 *ppv
= &This
->IHTMLImageElementFactory_iface
;
777 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
778 return *ppv
? S_OK
: E_NOINTERFACE
;
781 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
782 return E_NOINTERFACE
;
785 IUnknown_AddRef((IUnknown
*)*ppv
);
789 static ULONG WINAPI
HTMLImageElementFactory_AddRef(IHTMLImageElementFactory
*iface
)
791 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
792 LONG ref
= InterlockedIncrement(&This
->ref
);
794 TRACE("(%p) ref=%ld\n", This
, ref
);
799 static ULONG WINAPI
HTMLImageElementFactory_Release(IHTMLImageElementFactory
*iface
)
801 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
802 LONG ref
= InterlockedDecrement(&This
->ref
);
804 TRACE("(%p) ref=%ld\n", This
, ref
);
812 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory
*iface
,
815 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
816 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
819 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory
*iface
,
820 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
822 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
823 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
826 static HRESULT WINAPI
HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory
*iface
,
827 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
,
830 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
831 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
834 static HRESULT WINAPI
HTMLImageElementFactory_Invoke(IHTMLImageElementFactory
*iface
,
835 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
,
836 DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
839 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
840 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
841 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
844 static LONG
var_to_size(const VARIANT
*v
)
855 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
857 FIXME("VarI4FromStr failed: %08lx\n", hres
);
863 FIXME("unsupported size %s\n", debugstr_variant(v
));
868 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
869 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
871 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
872 HTMLDocumentNode
*doc
;
873 IHTMLImgElement
*img
;
875 nsIDOMElement
*nselem
;
879 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
880 debugstr_variant(&height
), img_elem
);
882 if(!This
->window
|| !This
->window
->doc
) {
887 doc
= This
->window
->doc
;
891 hres
= create_nselem(doc
, L
"IMG", &nselem
);
895 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, FALSE
, &elem
);
896 nsIDOMElement_Release(nselem
);
898 ERR("HTMLElement_Create failed\n");
902 hres
= IHTMLElement_QueryInterface(&elem
->IHTMLElement_iface
, &IID_IHTMLImgElement
,
904 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
906 ERR("IHTMLElement_QueryInterface failed: 0x%08lx\n", hres
);
910 l
= var_to_size(&width
);
912 IHTMLImgElement_put_width(img
, l
);
913 l
= var_to_size(&height
);
915 IHTMLImgElement_put_height(img
, l
);
921 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
922 HTMLImageElementFactory_QueryInterface
,
923 HTMLImageElementFactory_AddRef
,
924 HTMLImageElementFactory_Release
,
925 HTMLImageElementFactory_GetTypeInfoCount
,
926 HTMLImageElementFactory_GetTypeInfo
,
927 HTMLImageElementFactory_GetIDsOfNames
,
928 HTMLImageElementFactory_Invoke
,
929 HTMLImageElementFactory_create
932 static inline HTMLImageElementFactory
*impl_from_DispatchEx(DispatchEx
*iface
)
934 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, dispex
);
937 static HRESULT
HTMLImageElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
938 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
939 IServiceProvider
*caller
)
941 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
942 IHTMLImgElement
*img
;
943 VARIANT empty
, *width
, *height
;
945 int argc
= params
->cArgs
- params
->cNamedArgs
;
949 V_VT(&empty
) = VT_EMPTY
;
951 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
952 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
954 hres
= IHTMLImageElementFactory_create(&This
->IHTMLImageElementFactory_iface
, *width
, *height
,
959 V_VT(res
) = VT_DISPATCH
;
960 V_DISPATCH(res
) = (IDispatch
*)img
;
965 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
966 IHTMLImageElementFactory_tid
,
970 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
971 HTMLImageElementFactory_value
,
977 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
979 &HTMLImageElementFactory_dispex_vtbl
,
980 IHTMLImageElementFactory_tid
,
981 HTMLImageElementFactory_iface_tids
984 HRESULT
HTMLImageElementFactory_Create(HTMLInnerWindow
*window
, HTMLImageElementFactory
**ret_val
)
986 HTMLImageElementFactory
*ret
;
988 ret
= heap_alloc(sizeof(HTMLImageElementFactory
));
990 return E_OUTOFMEMORY
;
992 ret
->IHTMLImageElementFactory_iface
.lpVtbl
= &HTMLImageElementFactoryVtbl
;
994 ret
->window
= window
;
996 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLImageElementFactory_iface
,
997 &HTMLImageElementFactory_dispex
, dispex_compat_mode(&window
->event_target
.dispex
));