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
;
45 static inline HTMLImg
*impl_from_IHTMLImgElement(IHTMLImgElement
*iface
)
47 return CONTAINING_RECORD(iface
, HTMLImg
, IHTMLImgElement_iface
);
50 static HRESULT WINAPI
HTMLImgElement_QueryInterface(IHTMLImgElement
*iface
, REFIID riid
, void **ppv
)
52 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
54 return IHTMLDOMNode_QueryInterface(&This
->element
.node
.IHTMLDOMNode_iface
, riid
, ppv
);
57 static ULONG WINAPI
HTMLImgElement_AddRef(IHTMLImgElement
*iface
)
59 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
61 return IHTMLDOMNode_AddRef(&This
->element
.node
.IHTMLDOMNode_iface
);
64 static ULONG WINAPI
HTMLImgElement_Release(IHTMLImgElement
*iface
)
66 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
68 return IHTMLDOMNode_Release(&This
->element
.node
.IHTMLDOMNode_iface
);
71 static HRESULT WINAPI
HTMLImgElement_GetTypeInfoCount(IHTMLImgElement
*iface
, UINT
*pctinfo
)
73 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
74 return IDispatchEx_GetTypeInfoCount(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
77 static HRESULT WINAPI
HTMLImgElement_GetTypeInfo(IHTMLImgElement
*iface
, UINT iTInfo
,
78 LCID lcid
, ITypeInfo
**ppTInfo
)
80 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
81 return IDispatchEx_GetTypeInfo(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
,
85 static HRESULT WINAPI
HTMLImgElement_GetIDsOfNames(IHTMLImgElement
*iface
, REFIID riid
,
86 LPOLESTR
*rgszNames
, UINT cNames
,
87 LCID lcid
, DISPID
*rgDispId
)
89 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
90 return IDispatchEx_GetIDsOfNames(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, riid
, rgszNames
,
91 cNames
, lcid
, rgDispId
);
94 static HRESULT WINAPI
HTMLImgElement_Invoke(IHTMLImgElement
*iface
, DISPID dispIdMember
,
95 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
96 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
98 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
99 return IDispatchEx_Invoke(&This
->element
.node
.event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
,
100 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
103 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
105 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
108 TRACE("(%p)->(%x)\n", This
, v
);
110 nsres
= nsIDOMHTMLImageElement_SetIsMap(This
->nsimg
, v
!= VARIANT_FALSE
);
111 if (NS_FAILED(nsres
)) {
112 ERR("Set IsMap failed: %08lx\n", nsres
);
119 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
121 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
125 TRACE("(%p)->(%p)\n", This
, p
);
130 nsres
= nsIDOMHTMLImageElement_GetIsMap(This
->nsimg
, &b
);
131 if (NS_FAILED(nsres
)) {
132 ERR("Get IsMap failed: %08lx\n", nsres
);
136 *p
= variant_bool(b
);
140 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
142 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
143 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
147 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
149 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
150 FIXME("(%p)->(%p)\n", This
, p
);
154 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
156 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
157 FIXME("(%p)->(%p)\n", This
, p
);
161 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
163 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
164 FIXME("(%p)->(%p)\n", This
, p
);
168 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
170 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
171 FIXME("(%p)->(%p)\n", This
, p
);
175 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
177 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
178 FIXME("(%p)->(%p)\n", This
, p
);
182 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
184 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
185 FIXME("(%p)->(%p)\n", This
, p
);
189 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
191 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
192 FIXME("(%p)->(%p)\n", This
, p
);
196 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
198 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
199 FIXME("(%p)->(%p)\n", This
, p
);
203 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
205 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
206 FIXME("(%p)->(%p)\n", This
, p
);
210 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
212 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
213 FIXME("(%p)->()\n", This
);
217 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
219 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
220 FIXME("(%p)->(%p)\n", This
, p
);
224 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
226 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
227 FIXME("(%p)->(%ld)\n", This
, v
);
231 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
233 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
234 FIXME("(%p)->(%p)\n", This
, p
);
238 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
240 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
241 FIXME("(%p)->(%ld)\n", This
, v
);
245 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
247 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
248 FIXME("(%p)->(%p)\n", This
, p
);
252 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
254 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
258 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
260 nsAString_InitDepend(&alt_str
, v
);
261 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
262 nsAString_Finish(&alt_str
);
264 ERR("SetAlt failed: %08lx\n", nsres
);
269 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
271 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
275 TRACE("(%p)->(%p)\n", This
, p
);
277 nsAString_Init(&alt_str
, NULL
);
278 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
279 return return_nsstr(nsres
, &alt_str
, p
);
282 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
284 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
289 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
291 nsAString_InitDepend(&src_str
, v
);
292 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
293 nsAString_Finish(&src_str
);
295 ERR("SetSrc failed: %08lx\n", nsres
);
297 if(dispex_compat_mode(&This
->element
.node
.event_target
.dispex
) < COMPAT_MODE_IE9
) {
303 /* Synchronously send load event if the image was completed immediately (such as from cache) */
304 This
->skip_event
= EVENTID_INVALID
;
306 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
307 if(NS_SUCCEEDED(nsres
) && complete
) {
308 nsIDOMHTMLImageElement_GetNaturalHeight(This
->nsimg
, &height
);
309 eventid
= height
? EVENTID_LOAD
: EVENTID_ERROR
;
311 hres
= create_document_event(This
->element
.node
.doc
, eventid
, &event
);
312 if(SUCCEEDED(hres
)) {
313 This
->skip_event
= eventid
;
314 dispatch_event(&This
->element
.node
.event_target
, event
);
315 IDOMEvent_Release(&event
->IDOMEvent_iface
);
322 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
324 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
325 const PRUnichar
*src
;
330 TRACE("(%p)->(%p)\n", This
, p
);
332 nsAString_Init(&src_str
, NULL
);
333 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
334 if(NS_SUCCEEDED(nsres
)) {
335 nsAString_GetData(&src_str
, &src
);
337 if(!wcsnicmp(src
, L
"BLOCKED::", ARRAY_SIZE(L
"BLOCKED::")-1)) {
338 TRACE("returning BLOCKED::\n");
339 *p
= SysAllocString(L
"BLOCKED::");
341 hres
= E_OUTOFMEMORY
;
343 hres
= nsuri_to_url(src
, TRUE
, p
);
346 ERR("GetSrc failed: %08lx\n", nsres
);
350 nsAString_Finish(&src_str
);
354 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
356 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
357 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
361 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
363 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
364 FIXME("(%p)->(%p)\n", This
, p
);
368 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
370 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
371 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
375 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
377 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
378 FIXME("(%p)->(%p)\n", This
, p
);
382 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
384 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
385 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
389 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
391 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
392 FIXME("(%p)->(%p)\n", This
, p
);
396 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
398 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
399 FIXME("(%p)->(%p)\n", This
, p
);
403 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
405 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
409 TRACE("(%p)->(%p)\n", This
, p
);
411 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
412 if(NS_FAILED(nsres
)) {
413 ERR("GetComplete failed: %08lx\n", nsres
);
417 *p
= variant_bool(complete
);
421 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
423 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
424 FIXME("(%p)->()\n", This
);
428 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
430 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
431 FIXME("(%p)->(%p)\n", This
, p
);
435 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
437 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
441 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
443 nsAString_InitDepend(&str
, v
);
445 nsres
= nsIDOMHTMLImageElement_SetAlign(This
->nsimg
, &str
);
446 nsAString_Finish(&str
);
447 if (NS_FAILED(nsres
)){
448 ERR("Set Align(%s) failed: %08lx\n", debugstr_w(v
), nsres
);
455 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
457 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
461 TRACE("(%p)->(%p)\n", This
, p
);
463 nsAString_Init(&str
, NULL
);
464 nsres
= nsIDOMHTMLImageElement_GetAlign(This
->nsimg
, &str
);
466 return return_nsstr(nsres
, &str
, p
);
469 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
471 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
473 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
475 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
478 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
480 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
482 TRACE("(%p)->(%p)\n", This
, p
);
484 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
487 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
489 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
491 TRACE("(%p)->()\n", This
);
493 return set_node_event(&This
->element
.node
, EVENTID_ERROR
, &v
);
496 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
498 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
500 TRACE("(%p)->(%p)\n", This
, p
);
502 return get_node_event(&This
->element
.node
, EVENTID_ERROR
, p
);
505 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
507 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
509 TRACE("(%p)->()\n", This
);
511 return set_node_event(&This
->element
.node
, EVENTID_ABORT
, &v
);
514 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
516 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
518 TRACE("(%p)->(%p)\n", This
, p
);
520 return get_node_event(&This
->element
.node
, EVENTID_ABORT
, p
);
523 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
525 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
526 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
530 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
532 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
536 TRACE("(%p)->(%p)\n", This
, p
);
538 nsAString_Init(&name
, NULL
);
539 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &name
);
540 return return_nsstr(nsres
, &name
, p
);
543 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
545 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
548 TRACE("(%p)->(%ld)\n", This
, v
);
550 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
551 if(NS_FAILED(nsres
)) {
552 ERR("SetWidth failed: %08lx\n", nsres
);
559 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
561 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
565 TRACE("(%p)->(%p)\n", This
, p
);
567 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
568 if(NS_FAILED(nsres
)) {
569 ERR("GetWidth failed: %08lx\n", nsres
);
577 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
579 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
582 TRACE("(%p)->(%ld)\n", This
, v
);
584 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
585 if(NS_FAILED(nsres
)) {
586 ERR("SetHeight failed: %08lx\n", nsres
);
593 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
595 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
599 TRACE("(%p)->(%p)\n", This
, p
);
601 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
602 if(NS_FAILED(nsres
)) {
603 ERR("GetHeight failed: %08lx\n", nsres
);
611 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
613 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
614 FIXME("(%p)->()\n", This
);
618 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
620 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
621 FIXME("(%p)->(%p)\n", This
, p
);
625 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
626 HTMLImgElement_QueryInterface
,
627 HTMLImgElement_AddRef
,
628 HTMLImgElement_Release
,
629 HTMLImgElement_GetTypeInfoCount
,
630 HTMLImgElement_GetTypeInfo
,
631 HTMLImgElement_GetIDsOfNames
,
632 HTMLImgElement_Invoke
,
633 HTMLImgElement_put_isMap
,
634 HTMLImgElement_get_isMap
,
635 HTMLImgElement_put_useMap
,
636 HTMLImgElement_get_useMap
,
637 HTMLImgElement_get_mimeType
,
638 HTMLImgElement_get_fileSize
,
639 HTMLImgElement_get_fileCreatedDate
,
640 HTMLImgElement_get_fileModifiedDate
,
641 HTMLImgElement_get_fileUpdatedDate
,
642 HTMLImgElement_get_protocol
,
643 HTMLImgElement_get_href
,
644 HTMLImgElement_get_nameProp
,
645 HTMLImgElement_put_border
,
646 HTMLImgElement_get_border
,
647 HTMLImgElement_put_vspace
,
648 HTMLImgElement_get_vspace
,
649 HTMLImgElement_put_hspace
,
650 HTMLImgElement_get_hspace
,
651 HTMLImgElement_put_alt
,
652 HTMLImgElement_get_alt
,
653 HTMLImgElement_put_src
,
654 HTMLImgElement_get_src
,
655 HTMLImgElement_put_lowsrc
,
656 HTMLImgElement_get_lowsrc
,
657 HTMLImgElement_put_vrml
,
658 HTMLImgElement_get_vrml
,
659 HTMLImgElement_put_dynsrc
,
660 HTMLImgElement_get_dynsrc
,
661 HTMLImgElement_get_readyState
,
662 HTMLImgElement_get_complete
,
663 HTMLImgElement_put_loop
,
664 HTMLImgElement_get_loop
,
665 HTMLImgElement_put_align
,
666 HTMLImgElement_get_align
,
667 HTMLImgElement_put_onload
,
668 HTMLImgElement_get_onload
,
669 HTMLImgElement_put_onerror
,
670 HTMLImgElement_get_onerror
,
671 HTMLImgElement_put_onabort
,
672 HTMLImgElement_get_onabort
,
673 HTMLImgElement_put_name
,
674 HTMLImgElement_get_name
,
675 HTMLImgElement_put_width
,
676 HTMLImgElement_get_width
,
677 HTMLImgElement_put_height
,
678 HTMLImgElement_get_height
,
679 HTMLImgElement_put_start
,
680 HTMLImgElement_get_start
683 static inline HTMLImg
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
685 return CONTAINING_RECORD(iface
, HTMLImg
, element
.node
);
688 static HRESULT
HTMLImgElement_QI(HTMLDOMNode
*iface
, REFIID riid
, void **ppv
)
690 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
694 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
)) {
695 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This
, ppv
);
696 *ppv
= &This
->IHTMLImgElement_iface
;
698 return HTMLElement_QI(&This
->element
.node
, riid
, ppv
);
701 IUnknown_AddRef((IUnknown
*)*ppv
);
705 static HRESULT
HTMLImgElement_dispatch_nsevent_hook(HTMLDOMNode
*iface
, DOMEvent
*event
)
707 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
709 if(event
->event_id
== This
->skip_event
) {
710 This
->skip_event
= EVENTID_INVALID
;
717 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
719 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
721 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
724 static void HTMLImgElement_traverse(HTMLDOMNode
*iface
, nsCycleCollectionTraversalCallback
*cb
)
726 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
729 note_cc_edge((nsISupports
*)This
->nsimg
, "This->nsimg", cb
);
732 static void HTMLImgElement_unlink(HTMLDOMNode
*iface
)
734 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
737 nsIDOMHTMLImageElement
*nsimg
= This
->nsimg
;
740 nsIDOMHTMLImageElement_Release(nsimg
);
744 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
747 HTMLElement_destructor
,
750 HTMLImgElement_dispatch_nsevent_hook
,
751 HTMLElement_handle_event
,
752 HTMLElement_get_attr_col
,
757 HTMLImgElement_get_readystate
,
762 HTMLImgElement_traverse
,
763 HTMLImgElement_unlink
766 static const tid_t HTMLImgElement_iface_tids
[] = {
771 static void HTMLImgElement_init_dispex_info(dispex_data_t
*info
, compat_mode_t mode
)
773 static const dispex_hook_t img_ie11_hooks
[] = {
774 {DISPID_IHTMLIMGELEMENT_FILESIZE
, NULL
},
778 HTMLElement_init_dispex_info(info
, mode
);
780 dispex_info_add_interface(info
, IHTMLImgElement_tid
, mode
>= COMPAT_MODE_IE11
? img_ie11_hooks
: NULL
);
783 static dispex_static_data_t HTMLImgElement_dispex
= {
787 HTMLImgElement_iface_tids
,
788 HTMLImgElement_init_dispex_info
791 HRESULT
HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
796 ret
= calloc(1, sizeof(HTMLImg
));
798 return E_OUTOFMEMORY
;
800 ret
->IHTMLImgElement_iface
.lpVtbl
= &HTMLImgElementVtbl
;
801 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
802 ret
->skip_event
= EVENTID_INVALID
;
804 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
806 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
807 assert(nsres
== NS_OK
);
809 *elem
= &ret
->element
;
813 static inline HTMLImageElementFactory
*impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory
*iface
)
815 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, IHTMLImageElementFactory_iface
);
818 static HRESULT WINAPI
HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory
*iface
,
819 REFIID riid
, void **ppv
)
821 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
823 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
825 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
826 *ppv
= &This
->IHTMLImageElementFactory_iface
;
827 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
)) {
828 *ppv
= &This
->IHTMLImageElementFactory_iface
;
829 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
830 return *ppv
? S_OK
: E_NOINTERFACE
;
833 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
834 return E_NOINTERFACE
;
837 IUnknown_AddRef((IUnknown
*)*ppv
);
841 static ULONG WINAPI
HTMLImageElementFactory_AddRef(IHTMLImageElementFactory
*iface
)
843 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
844 LONG ref
= InterlockedIncrement(&This
->ref
);
846 TRACE("(%p) ref=%ld\n", This
, ref
);
851 static ULONG WINAPI
HTMLImageElementFactory_Release(IHTMLImageElementFactory
*iface
)
853 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
854 LONG ref
= InterlockedDecrement(&This
->ref
);
856 TRACE("(%p) ref=%ld\n", This
, ref
);
864 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory
*iface
,
867 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
868 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
871 static HRESULT WINAPI
HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory
*iface
,
872 UINT iTInfo
, LCID lcid
, ITypeInfo
**ppTInfo
)
874 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
875 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
878 static HRESULT WINAPI
HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory
*iface
,
879 REFIID riid
, LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
,
882 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
883 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
, rgDispId
);
886 static HRESULT WINAPI
HTMLImageElementFactory_Invoke(IHTMLImageElementFactory
*iface
,
887 DISPID dispIdMember
, REFIID riid
, LCID lcid
, WORD wFlags
,
888 DISPPARAMS
*pDispParams
, VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
,
891 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
892 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
893 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
896 static LONG
var_to_size(const VARIANT
*v
)
907 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
909 FIXME("VarI4FromStr failed: %08lx\n", hres
);
915 FIXME("unsupported size %s\n", debugstr_variant(v
));
920 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
921 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
923 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
924 HTMLDocumentNode
*doc
;
925 IHTMLImgElement
*img
;
927 nsIDOMElement
*nselem
;
931 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
932 debugstr_variant(&height
), img_elem
);
934 if(!This
->window
|| !This
->window
->doc
) {
939 doc
= This
->window
->doc
;
943 hres
= create_nselem(doc
, L
"IMG", &nselem
);
947 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, FALSE
, &elem
);
948 nsIDOMElement_Release(nselem
);
950 ERR("HTMLElement_Create failed\n");
954 hres
= IHTMLElement_QueryInterface(&elem
->IHTMLElement_iface
, &IID_IHTMLImgElement
,
956 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
958 ERR("IHTMLElement_QueryInterface failed: 0x%08lx\n", hres
);
962 l
= var_to_size(&width
);
964 IHTMLImgElement_put_width(img
, l
);
965 l
= var_to_size(&height
);
967 IHTMLImgElement_put_height(img
, l
);
973 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
974 HTMLImageElementFactory_QueryInterface
,
975 HTMLImageElementFactory_AddRef
,
976 HTMLImageElementFactory_Release
,
977 HTMLImageElementFactory_GetTypeInfoCount
,
978 HTMLImageElementFactory_GetTypeInfo
,
979 HTMLImageElementFactory_GetIDsOfNames
,
980 HTMLImageElementFactory_Invoke
,
981 HTMLImageElementFactory_create
984 static inline HTMLImageElementFactory
*impl_from_DispatchEx(DispatchEx
*iface
)
986 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, dispex
);
989 static HRESULT
HTMLImageElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
990 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
991 IServiceProvider
*caller
)
993 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
994 IHTMLImgElement
*img
;
995 VARIANT empty
, *width
, *height
;
997 int argc
= params
->cArgs
- params
->cNamedArgs
;
1001 V_VT(&empty
) = VT_EMPTY
;
1003 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
1004 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
1006 hres
= IHTMLImageElementFactory_create(&This
->IHTMLImageElementFactory_iface
, *width
, *height
,
1011 V_VT(res
) = VT_DISPATCH
;
1012 V_DISPATCH(res
) = (IDispatch
*)img
;
1017 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
1018 IHTMLImageElementFactory_tid
,
1022 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
1023 HTMLImageElementFactory_value
,
1029 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
1031 &HTMLImageElementFactory_dispex_vtbl
,
1032 IHTMLImageElementFactory_tid
,
1033 HTMLImageElementFactory_iface_tids
1036 HRESULT
HTMLImageElementFactory_Create(HTMLInnerWindow
*window
, HTMLImageElementFactory
**ret_val
)
1038 HTMLImageElementFactory
*ret
;
1040 ret
= malloc(sizeof(HTMLImageElementFactory
));
1042 return E_OUTOFMEMORY
;
1044 ret
->IHTMLImageElementFactory_iface
.lpVtbl
= &HTMLImageElementFactoryVtbl
;
1046 ret
->window
= window
;
1048 init_dispatch(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLImageElementFactory_iface
,
1049 &HTMLImageElementFactory_dispex
, dispex_compat_mode(&window
->event_target
.dispex
));