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
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 IHTMLImgElement IHTMLImgElement_iface
;
41 nsIDOMHTMLImageElement
*nsimg
;
44 static inline HTMLImg
*impl_from_IHTMLImgElement(IHTMLImgElement
*iface
)
46 return CONTAINING_RECORD(iface
, HTMLImg
, IHTMLImgElement_iface
);
49 static HRESULT WINAPI
HTMLImgElement_QueryInterface(IHTMLImgElement
*iface
, REFIID riid
, void **ppv
)
51 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
53 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
56 static ULONG WINAPI
HTMLImgElement_AddRef(IHTMLImgElement
*iface
)
58 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
60 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
63 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
65 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
67 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
70 static HRESULT WINAPI
HTMLImgElement_GetTypeInfoCount(IHTMLImgElement
*iface
, UINT
*pctinfo
)
72 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
73 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
76 static HRESULT WINAPI
HTMLImgElement_GetTypeInfo(IHTMLImgElement
*iface
, UINT iTInfo
,
77 LCID lcid
, ITypeInfo
**ppTInfo
)
79 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
80 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
84 static HRESULT WINAPI
HTMLImgElement_GetIDsOfNames(IHTMLImgElement
*iface
, REFIID riid
,
85 LPOLESTR
*rgszNames
, UINT cNames
,
86 LCID lcid
, DISPID
*rgDispId
)
88 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
89 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
90 cNames
, lcid
, rgDispId
);
93 static HRESULT WINAPI
HTMLImgElement_Invoke(IHTMLImgElement
*iface
, DISPID dispIdMember
,
94 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
95 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
97 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
98 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
99 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
102 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
104 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
107 TRACE("(%p)->(%x)\n", This
, v
);
109 nsres
= nsIDOMHTMLImageElement_SetIsMap(This
->nsimg
, v
!= VARIANT_FALSE
);
110 if (NS_FAILED(nsres
)) {
111 ERR("Set IsMap failed: %08x\n", nsres
);
118 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
120 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
124 TRACE("(%p)->(%p)\n", This
, p
);
129 nsres
= nsIDOMHTMLImageElement_GetIsMap(This
->nsimg
, &b
);
130 if (NS_FAILED(nsres
)) {
131 ERR("Get IsMap failed: %08x\n", nsres
);
135 *p
= variant_bool(b
);
139 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
141 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
142 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
146 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
148 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
149 FIXME("(%p)->(%p)\n", This
, p
);
153 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
155 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
156 FIXME("(%p)->(%p)\n", This
, p
);
160 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
162 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
163 FIXME("(%p)->(%p)\n", This
, p
);
167 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
169 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
170 FIXME("(%p)->(%p)\n", This
, p
);
174 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
176 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
177 FIXME("(%p)->(%p)\n", This
, p
);
181 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
183 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
184 FIXME("(%p)->(%p)\n", This
, p
);
188 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
190 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
191 FIXME("(%p)->(%p)\n", This
, p
);
195 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
197 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
198 FIXME("(%p)->(%p)\n", This
, p
);
202 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
204 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
205 FIXME("(%p)->(%p)\n", This
, p
);
209 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
211 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
212 FIXME("(%p)->()\n", This
);
216 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
218 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
219 FIXME("(%p)->(%p)\n", This
, p
);
223 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
225 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
226 FIXME("(%p)->(%d)\n", This
, v
);
230 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
232 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
233 FIXME("(%p)->(%p)\n", This
, p
);
237 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
239 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
240 FIXME("(%p)->(%d)\n", This
, v
);
244 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
246 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
247 FIXME("(%p)->(%p)\n", This
, p
);
251 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
253 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
257 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
259 nsAString_InitDepend(&alt_str
, v
);
260 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
261 nsAString_Finish(&alt_str
);
263 ERR("SetAlt failed: %08x\n", nsres
);
268 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
270 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
274 TRACE("(%p)->(%p)\n", This
, p
);
276 nsAString_Init(&alt_str
, NULL
);
277 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
278 return return_nsstr(nsres
, &alt_str
, p
);
281 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
283 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
287 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
289 nsAString_InitDepend(&src_str
, v
);
290 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
291 nsAString_Finish(&src_str
);
293 ERR("SetSrc failed: %08x\n", nsres
);
298 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
300 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
301 const PRUnichar
*src
;
306 TRACE("(%p)->(%p)\n", This
, p
);
308 nsAString_Init(&src_str
, NULL
);
309 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
310 if(NS_SUCCEEDED(nsres
)) {
311 nsAString_GetData(&src_str
, &src
);
313 if(!wcsnicmp(src
, L
"BLOCKED::", ARRAY_SIZE(L
"BLOCKED::")-1)) {
314 TRACE("returning BLOCKED::\n");
315 *p
= SysAllocString(L
"BLOCKED::");
317 hres
= E_OUTOFMEMORY
;
319 hres
= nsuri_to_url(src
, TRUE
, p
);
322 ERR("GetSrc failed: %08x\n", nsres
);
326 nsAString_Finish(&src_str
);
330 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
332 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
333 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
337 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
339 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
340 FIXME("(%p)->(%p)\n", This
, p
);
344 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
346 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
347 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
351 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
353 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
354 FIXME("(%p)->(%p)\n", This
, p
);
358 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
360 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
361 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
365 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
367 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
368 FIXME("(%p)->(%p)\n", This
, p
);
372 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
374 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
375 FIXME("(%p)->(%p)\n", This
, p
);
379 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
381 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
385 TRACE("(%p)->(%p)\n", This
, p
);
387 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
388 if(NS_FAILED(nsres
)) {
389 ERR("GetComplete failed: %08x\n", nsres
);
393 *p
= variant_bool(complete
);
397 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
399 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
400 FIXME("(%p)->()\n", This
);
404 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
406 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
407 FIXME("(%p)->(%p)\n", This
, p
);
411 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
413 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
417 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
419 nsAString_InitDepend(&str
, v
);
421 nsres
= nsIDOMHTMLImageElement_SetAlign(This
->nsimg
, &str
);
422 nsAString_Finish(&str
);
423 if (NS_FAILED(nsres
)){
424 ERR("Set Align(%s) failed: %08x\n", debugstr_w(v
), nsres
);
431 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
433 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
437 TRACE("(%p)->(%p)\n", This
, p
);
439 nsAString_Init(&str
, NULL
);
440 nsres
= nsIDOMHTMLImageElement_GetAlign(This
->nsimg
, &str
);
442 return return_nsstr(nsres
, &str
, p
);
445 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
447 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
449 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
451 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
454 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
456 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
458 TRACE("(%p)->(%p)\n", This
, p
);
460 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
463 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
465 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
467 TRACE("(%p)->()\n", This
);
469 return set_node_event(&This
->element
.node
, EVENTID_ERROR
, &v
);
472 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
474 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
476 TRACE("(%p)->(%p)\n", This
, p
);
478 return get_node_event(&This
->element
.node
, EVENTID_ERROR
, p
);
481 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
483 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
485 TRACE("(%p)->()\n", This
);
487 return set_node_event(&This
->element
.node
, EVENTID_ABORT
, &v
);
490 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
492 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
494 TRACE("(%p)->(%p)\n", This
, p
);
496 return get_node_event(&This
->element
.node
, EVENTID_ABORT
, p
);
499 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
501 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
502 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
506 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
508 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
512 TRACE("(%p)->(%p)\n", This
, p
);
514 nsAString_Init(&name
, NULL
);
515 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &name
);
516 return return_nsstr(nsres
, &name
, p
);
519 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
521 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
524 TRACE("(%p)->(%d)\n", This
, v
);
526 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
527 if(NS_FAILED(nsres
)) {
528 ERR("SetWidth failed: %08x\n", nsres
);
535 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
537 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
541 TRACE("(%p)->(%p)\n", This
, p
);
543 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
544 if(NS_FAILED(nsres
)) {
545 ERR("GetWidth failed: %08x\n", nsres
);
553 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
555 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
558 TRACE("(%p)->(%d)\n", This
, v
);
560 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
561 if(NS_FAILED(nsres
)) {
562 ERR("SetHeight failed: %08x\n", nsres
);
569 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
571 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
575 TRACE("(%p)->(%p)\n", This
, p
);
577 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
578 if(NS_FAILED(nsres
)) {
579 ERR("GetHeight failed: %08x\n", nsres
);
587 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
589 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
590 FIXME("(%p)->()\n", This
);
594 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
596 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
597 FIXME("(%p)->(%p)\n", This
, p
);
601 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
602 HTMLImgElement_QueryInterface
,
603 HTMLImgElement_AddRef
,
604 HTMLImgElement_Release
,
605 HTMLImgElement_GetTypeInfoCount
,
606 HTMLImgElement_GetTypeInfo
,
607 HTMLImgElement_GetIDsOfNames
,
608 HTMLImgElement_Invoke
,
609 HTMLImgElement_put_isMap
,
610 HTMLImgElement_get_isMap
,
611 HTMLImgElement_put_useMap
,
612 HTMLImgElement_get_useMap
,
613 HTMLImgElement_get_mimeType
,
614 HTMLImgElement_get_fileSize
,
615 HTMLImgElement_get_fileCreatedDate
,
616 HTMLImgElement_get_fileModifiedDate
,
617 HTMLImgElement_get_fileUpdatedDate
,
618 HTMLImgElement_get_protocol
,
619 HTMLImgElement_get_href
,
620 HTMLImgElement_get_nameProp
,
621 HTMLImgElement_put_border
,
622 HTMLImgElement_get_border
,
623 HTMLImgElement_put_vspace
,
624 HTMLImgElement_get_vspace
,
625 HTMLImgElement_put_hspace
,
626 HTMLImgElement_get_hspace
,
627 HTMLImgElement_put_alt
,
628 HTMLImgElement_get_alt
,
629 HTMLImgElement_put_src
,
630 HTMLImgElement_get_src
,
631 HTMLImgElement_put_lowsrc
,
632 HTMLImgElement_get_lowsrc
,
633 HTMLImgElement_put_vrml
,
634 HTMLImgElement_get_vrml
,
635 HTMLImgElement_put_dynsrc
,
636 HTMLImgElement_get_dynsrc
,
637 HTMLImgElement_get_readyState
,
638 HTMLImgElement_get_complete
,
639 HTMLImgElement_put_loop
,
640 HTMLImgElement_get_loop
,
641 HTMLImgElement_put_align
,
642 HTMLImgElement_get_align
,
643 HTMLImgElement_put_onload
,
644 HTMLImgElement_get_onload
,
645 HTMLImgElement_put_onerror
,
646 HTMLImgElement_get_onerror
,
647 HTMLImgElement_put_onabort
,
648 HTMLImgElement_get_onabort
,
649 HTMLImgElement_put_name
,
650 HTMLImgElement_get_name
,
651 HTMLImgElement_put_width
,
652 HTMLImgElement_get_width
,
653 HTMLImgElement_put_height
,
654 HTMLImgElement_get_height
,
655 HTMLImgElement_put_start
,
656 HTMLImgElement_get_start
659 static inline HTMLImg
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
661 return CONTAINING_RECORD(iface
, HTMLImg
, element
.node
);
664 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
666 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
670 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
671 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
672 *ppv
= &This
->IHTMLImgElement_iface
;
674 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
677 IUnknown_AddRef((IUnknown
*)*ppv
);
681 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
683 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
685 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
688 static void HTMLImgElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
690 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
693 note_cc_edge((nsISupports
*)This
->nsimg
, "This->nsimg", cb
);
696 static void HTMLImgElement_unlink(HTMLDOMNode
*iface
)
698 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
701 nsIDOMHTMLImageElement
*nsimg
= This
->nsimg
;
704 nsIDOMHTMLImageElement_Release(nsimg
);
708 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
711 HTMLElement_destructor
,
714 HTMLElement_handle_event
,
715 HTMLElement_get_attr_col
,
720 HTMLImgElement_get_readystate
,
724 HTMLImgElement_traverse
,
725 HTMLImgElement_unlink
728 static const tid_t HTMLImgElement_iface_tids
[] = {
733 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=%d\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=%d\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: %08x\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%08x\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
= {
978 &HTMLImageElementFactory_dispex_vtbl
,
979 IHTMLImageElementFactory_tid
,
980 HTMLImageElementFactory_iface_tids
983 HRESULT
HTMLImageElementFactory_Create(HTMLInnerWindow
*window
, HTMLImageElementFactory
**ret_val
)
985 HTMLImageElementFactory
*ret
;
987 ret
= heap_alloc(sizeof(HTMLImageElementFactory
));
989 return E_OUTOFMEMORY
;
991 ret
->IHTMLImageElementFactory_iface
.lpVtbl
= &HTMLImageElementFactoryVtbl
;
993 ret
->window
= window
;
995 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLImageElementFactory_iface
,
996 &HTMLImageElementFactory_dispex
, dispex_compat_mode(&window
->event_target
.dispex
));