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 DISPEX_IDISPATCH_IMPL(HTMLImgElement
, IHTMLImgElement
,
50 impl_from_IHTMLImgElement(iface
)->element
.node
.event_target
.dispex
)
52 static HRESULT WINAPI
HTMLImgElement_put_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL v
)
54 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
57 TRACE("(%p)->(%x)\n", This
, v
);
59 nsres
= nsIDOMHTMLImageElement_SetIsMap(This
->nsimg
, v
!= VARIANT_FALSE
);
60 if (NS_FAILED(nsres
)) {
61 ERR("Set IsMap failed: %08lx\n", nsres
);
68 static HRESULT WINAPI
HTMLImgElement_get_isMap(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
70 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
74 TRACE("(%p)->(%p)\n", This
, p
);
79 nsres
= nsIDOMHTMLImageElement_GetIsMap(This
->nsimg
, &b
);
80 if (NS_FAILED(nsres
)) {
81 ERR("Get IsMap failed: %08lx\n", nsres
);
89 static HRESULT WINAPI
HTMLImgElement_put_useMap(IHTMLImgElement
*iface
, BSTR v
)
91 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
92 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
96 static HRESULT WINAPI
HTMLImgElement_get_useMap(IHTMLImgElement
*iface
, BSTR
*p
)
98 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
99 FIXME("(%p)->(%p)\n", This
, p
);
103 static HRESULT WINAPI
HTMLImgElement_get_mimeType(IHTMLImgElement
*iface
, BSTR
*p
)
105 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
106 FIXME("(%p)->(%p)\n", This
, p
);
110 static HRESULT WINAPI
HTMLImgElement_get_fileSize(IHTMLImgElement
*iface
, BSTR
*p
)
112 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
113 FIXME("(%p)->(%p)\n", This
, p
);
117 static HRESULT WINAPI
HTMLImgElement_get_fileCreatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
119 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
120 FIXME("(%p)->(%p)\n", This
, p
);
124 static HRESULT WINAPI
HTMLImgElement_get_fileModifiedDate(IHTMLImgElement
*iface
, BSTR
*p
)
126 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
127 FIXME("(%p)->(%p)\n", This
, p
);
131 static HRESULT WINAPI
HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement
*iface
, BSTR
*p
)
133 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
134 FIXME("(%p)->(%p)\n", This
, p
);
138 static HRESULT WINAPI
HTMLImgElement_get_protocol(IHTMLImgElement
*iface
, BSTR
*p
)
140 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
141 FIXME("(%p)->(%p)\n", This
, p
);
145 static HRESULT WINAPI
HTMLImgElement_get_href(IHTMLImgElement
*iface
, BSTR
*p
)
147 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
148 FIXME("(%p)->(%p)\n", This
, p
);
152 static HRESULT WINAPI
HTMLImgElement_get_nameProp(IHTMLImgElement
*iface
, BSTR
*p
)
154 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
155 FIXME("(%p)->(%p)\n", This
, p
);
159 static HRESULT WINAPI
HTMLImgElement_put_border(IHTMLImgElement
*iface
, VARIANT v
)
161 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
162 FIXME("(%p)->()\n", This
);
166 static HRESULT WINAPI
HTMLImgElement_get_border(IHTMLImgElement
*iface
, VARIANT
*p
)
168 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
169 FIXME("(%p)->(%p)\n", This
, p
);
173 static HRESULT WINAPI
HTMLImgElement_put_vspace(IHTMLImgElement
*iface
, LONG v
)
175 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
176 FIXME("(%p)->(%ld)\n", This
, v
);
180 static HRESULT WINAPI
HTMLImgElement_get_vspace(IHTMLImgElement
*iface
, LONG
*p
)
182 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
183 FIXME("(%p)->(%p)\n", This
, p
);
187 static HRESULT WINAPI
HTMLImgElement_put_hspace(IHTMLImgElement
*iface
, LONG v
)
189 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
190 FIXME("(%p)->(%ld)\n", This
, v
);
194 static HRESULT WINAPI
HTMLImgElement_get_hspace(IHTMLImgElement
*iface
, LONG
*p
)
196 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
197 FIXME("(%p)->(%p)\n", This
, p
);
201 static HRESULT WINAPI
HTMLImgElement_put_alt(IHTMLImgElement
*iface
, BSTR v
)
203 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
207 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
209 nsAString_InitDepend(&alt_str
, v
);
210 nsres
= nsIDOMHTMLImageElement_SetAlt(This
->nsimg
, &alt_str
);
211 nsAString_Finish(&alt_str
);
213 ERR("SetAlt failed: %08lx\n", nsres
);
218 static HRESULT WINAPI
HTMLImgElement_get_alt(IHTMLImgElement
*iface
, BSTR
*p
)
220 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
224 TRACE("(%p)->(%p)\n", This
, p
);
226 nsAString_Init(&alt_str
, NULL
);
227 nsres
= nsIDOMHTMLImageElement_GetAlt(This
->nsimg
, &alt_str
);
228 return return_nsstr(nsres
, &alt_str
, p
);
231 static HRESULT WINAPI
HTMLImgElement_put_src(IHTMLImgElement
*iface
, BSTR v
)
233 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
237 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
239 nsAString_InitDepend(&src_str
, v
);
240 nsres
= nsIDOMHTMLImageElement_SetSrc(This
->nsimg
, &src_str
);
241 nsAString_Finish(&src_str
);
242 return map_nsresult(nsres
);
245 static HRESULT WINAPI
HTMLImgElement_get_src(IHTMLImgElement
*iface
, BSTR
*p
)
247 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
248 const PRUnichar
*src
;
253 TRACE("(%p)->(%p)\n", This
, p
);
255 nsAString_Init(&src_str
, NULL
);
256 nsres
= nsIDOMHTMLImageElement_GetSrc(This
->nsimg
, &src_str
);
257 if(NS_SUCCEEDED(nsres
)) {
258 nsAString_GetData(&src_str
, &src
);
260 if(!wcsnicmp(src
, L
"BLOCKED::", ARRAY_SIZE(L
"BLOCKED::")-1)) {
261 TRACE("returning BLOCKED::\n");
262 *p
= SysAllocString(L
"BLOCKED::");
264 hres
= E_OUTOFMEMORY
;
266 hres
= nsuri_to_url(src
, TRUE
, p
);
269 ERR("GetSrc failed: %08lx\n", nsres
);
273 nsAString_Finish(&src_str
);
277 static HRESULT WINAPI
HTMLImgElement_put_lowsrc(IHTMLImgElement
*iface
, BSTR v
)
279 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
280 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
284 static HRESULT WINAPI
HTMLImgElement_get_lowsrc(IHTMLImgElement
*iface
, BSTR
*p
)
286 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
287 FIXME("(%p)->(%p)\n", This
, p
);
291 static HRESULT WINAPI
HTMLImgElement_put_vrml(IHTMLImgElement
*iface
, BSTR v
)
293 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
294 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
298 static HRESULT WINAPI
HTMLImgElement_get_vrml(IHTMLImgElement
*iface
, BSTR
*p
)
300 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
301 FIXME("(%p)->(%p)\n", This
, p
);
305 static HRESULT WINAPI
HTMLImgElement_put_dynsrc(IHTMLImgElement
*iface
, BSTR v
)
307 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
308 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
312 static HRESULT WINAPI
HTMLImgElement_get_dynsrc(IHTMLImgElement
*iface
, BSTR
*p
)
314 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
315 FIXME("(%p)->(%p)\n", This
, p
);
319 static HRESULT WINAPI
HTMLImgElement_get_readyState(IHTMLImgElement
*iface
, BSTR
*p
)
321 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
322 FIXME("(%p)->(%p)\n", This
, p
);
326 static HRESULT WINAPI
HTMLImgElement_get_complete(IHTMLImgElement
*iface
, VARIANT_BOOL
*p
)
328 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
332 TRACE("(%p)->(%p)\n", This
, p
);
334 nsres
= nsIDOMHTMLImageElement_GetComplete(This
->nsimg
, &complete
);
335 if(NS_FAILED(nsres
)) {
336 ERR("GetComplete failed: %08lx\n", nsres
);
340 *p
= variant_bool(complete
);
344 static HRESULT WINAPI
HTMLImgElement_put_loop(IHTMLImgElement
*iface
, VARIANT v
)
346 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
347 FIXME("(%p)->()\n", This
);
351 static HRESULT WINAPI
HTMLImgElement_get_loop(IHTMLImgElement
*iface
, VARIANT
*p
)
353 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
354 FIXME("(%p)->(%p)\n", This
, p
);
358 static HRESULT WINAPI
HTMLImgElement_put_align(IHTMLImgElement
*iface
, BSTR v
)
360 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
364 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
366 nsAString_InitDepend(&str
, v
);
368 nsres
= nsIDOMHTMLImageElement_SetAlign(This
->nsimg
, &str
);
369 nsAString_Finish(&str
);
370 if (NS_FAILED(nsres
)){
371 ERR("Set Align(%s) failed: %08lx\n", debugstr_w(v
), nsres
);
378 static HRESULT WINAPI
HTMLImgElement_get_align(IHTMLImgElement
*iface
, BSTR
*p
)
380 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
384 TRACE("(%p)->(%p)\n", This
, p
);
386 nsAString_Init(&str
, NULL
);
387 nsres
= nsIDOMHTMLImageElement_GetAlign(This
->nsimg
, &str
);
389 return return_nsstr(nsres
, &str
, p
);
392 static HRESULT WINAPI
HTMLImgElement_put_onload(IHTMLImgElement
*iface
, VARIANT v
)
394 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
396 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
398 return set_node_event(&This
->element
.node
, EVENTID_LOAD
, &v
);
401 static HRESULT WINAPI
HTMLImgElement_get_onload(IHTMLImgElement
*iface
, VARIANT
*p
)
403 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
405 TRACE("(%p)->(%p)\n", This
, p
);
407 return get_node_event(&This
->element
.node
, EVENTID_LOAD
, p
);
410 static HRESULT WINAPI
HTMLImgElement_put_onerror(IHTMLImgElement
*iface
, VARIANT v
)
412 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
414 TRACE("(%p)->()\n", This
);
416 return set_node_event(&This
->element
.node
, EVENTID_ERROR
, &v
);
419 static HRESULT WINAPI
HTMLImgElement_get_onerror(IHTMLImgElement
*iface
, VARIANT
*p
)
421 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
423 TRACE("(%p)->(%p)\n", This
, p
);
425 return get_node_event(&This
->element
.node
, EVENTID_ERROR
, p
);
428 static HRESULT WINAPI
HTMLImgElement_put_onabort(IHTMLImgElement
*iface
, VARIANT v
)
430 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
432 TRACE("(%p)->()\n", This
);
434 return set_node_event(&This
->element
.node
, EVENTID_ABORT
, &v
);
437 static HRESULT WINAPI
HTMLImgElement_get_onabort(IHTMLImgElement
*iface
, VARIANT
*p
)
439 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
441 TRACE("(%p)->(%p)\n", This
, p
);
443 return get_node_event(&This
->element
.node
, EVENTID_ABORT
, p
);
446 static HRESULT WINAPI
HTMLImgElement_put_name(IHTMLImgElement
*iface
, BSTR v
)
448 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
449 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
453 static HRESULT WINAPI
HTMLImgElement_get_name(IHTMLImgElement
*iface
, BSTR
*p
)
455 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
459 TRACE("(%p)->(%p)\n", This
, p
);
461 nsAString_Init(&name
, NULL
);
462 nsres
= nsIDOMHTMLImageElement_GetName(This
->nsimg
, &name
);
463 return return_nsstr(nsres
, &name
, p
);
466 static HRESULT WINAPI
HTMLImgElement_put_width(IHTMLImgElement
*iface
, LONG v
)
468 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
471 TRACE("(%p)->(%ld)\n", This
, v
);
473 nsres
= nsIDOMHTMLImageElement_SetWidth(This
->nsimg
, v
);
474 if(NS_FAILED(nsres
)) {
475 ERR("SetWidth failed: %08lx\n", nsres
);
482 static HRESULT WINAPI
HTMLImgElement_get_width(IHTMLImgElement
*iface
, LONG
*p
)
484 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
488 TRACE("(%p)->(%p)\n", This
, p
);
490 nsres
= nsIDOMHTMLImageElement_GetWidth(This
->nsimg
, &width
);
491 if(NS_FAILED(nsres
)) {
492 ERR("GetWidth failed: %08lx\n", nsres
);
500 static HRESULT WINAPI
HTMLImgElement_put_height(IHTMLImgElement
*iface
, LONG v
)
502 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
505 TRACE("(%p)->(%ld)\n", This
, v
);
507 nsres
= nsIDOMHTMLImageElement_SetHeight(This
->nsimg
, v
);
508 if(NS_FAILED(nsres
)) {
509 ERR("SetHeight failed: %08lx\n", nsres
);
516 static HRESULT WINAPI
HTMLImgElement_get_height(IHTMLImgElement
*iface
, LONG
*p
)
518 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
522 TRACE("(%p)->(%p)\n", This
, p
);
524 nsres
= nsIDOMHTMLImageElement_GetHeight(This
->nsimg
, &height
);
525 if(NS_FAILED(nsres
)) {
526 ERR("GetHeight failed: %08lx\n", nsres
);
534 static HRESULT WINAPI
HTMLImgElement_put_start(IHTMLImgElement
*iface
, BSTR v
)
536 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
537 FIXME("(%p)->()\n", This
);
541 static HRESULT WINAPI
HTMLImgElement_get_start(IHTMLImgElement
*iface
, BSTR
*p
)
543 HTMLImg
*This
= impl_from_IHTMLImgElement(iface
);
544 FIXME("(%p)->(%p)\n", This
, p
);
548 static const IHTMLImgElementVtbl HTMLImgElementVtbl
= {
549 HTMLImgElement_QueryInterface
,
550 HTMLImgElement_AddRef
,
551 HTMLImgElement_Release
,
552 HTMLImgElement_GetTypeInfoCount
,
553 HTMLImgElement_GetTypeInfo
,
554 HTMLImgElement_GetIDsOfNames
,
555 HTMLImgElement_Invoke
,
556 HTMLImgElement_put_isMap
,
557 HTMLImgElement_get_isMap
,
558 HTMLImgElement_put_useMap
,
559 HTMLImgElement_get_useMap
,
560 HTMLImgElement_get_mimeType
,
561 HTMLImgElement_get_fileSize
,
562 HTMLImgElement_get_fileCreatedDate
,
563 HTMLImgElement_get_fileModifiedDate
,
564 HTMLImgElement_get_fileUpdatedDate
,
565 HTMLImgElement_get_protocol
,
566 HTMLImgElement_get_href
,
567 HTMLImgElement_get_nameProp
,
568 HTMLImgElement_put_border
,
569 HTMLImgElement_get_border
,
570 HTMLImgElement_put_vspace
,
571 HTMLImgElement_get_vspace
,
572 HTMLImgElement_put_hspace
,
573 HTMLImgElement_get_hspace
,
574 HTMLImgElement_put_alt
,
575 HTMLImgElement_get_alt
,
576 HTMLImgElement_put_src
,
577 HTMLImgElement_get_src
,
578 HTMLImgElement_put_lowsrc
,
579 HTMLImgElement_get_lowsrc
,
580 HTMLImgElement_put_vrml
,
581 HTMLImgElement_get_vrml
,
582 HTMLImgElement_put_dynsrc
,
583 HTMLImgElement_get_dynsrc
,
584 HTMLImgElement_get_readyState
,
585 HTMLImgElement_get_complete
,
586 HTMLImgElement_put_loop
,
587 HTMLImgElement_get_loop
,
588 HTMLImgElement_put_align
,
589 HTMLImgElement_get_align
,
590 HTMLImgElement_put_onload
,
591 HTMLImgElement_get_onload
,
592 HTMLImgElement_put_onerror
,
593 HTMLImgElement_get_onerror
,
594 HTMLImgElement_put_onabort
,
595 HTMLImgElement_get_onabort
,
596 HTMLImgElement_put_name
,
597 HTMLImgElement_get_name
,
598 HTMLImgElement_put_width
,
599 HTMLImgElement_get_width
,
600 HTMLImgElement_put_height
,
601 HTMLImgElement_get_height
,
602 HTMLImgElement_put_start
,
603 HTMLImgElement_get_start
606 static inline HTMLImg
*impl_from_HTMLDOMNode(HTMLDOMNode
*iface
)
608 return CONTAINING_RECORD(iface
, HTMLImg
, element
.node
);
611 static HRESULT
HTMLImgElement_get_readystate(HTMLDOMNode
*iface
, BSTR
*p
)
613 HTMLImg
*This
= impl_from_HTMLDOMNode(iface
);
615 return IHTMLImgElement_get_readyState(&This
->IHTMLImgElement_iface
, p
);
618 static inline HTMLImg
*HTMLImg_from_DispatchEx(DispatchEx
*iface
)
620 return CONTAINING_RECORD(iface
, HTMLImg
, element
.node
.event_target
.dispex
);
623 static void *HTMLImgElement_query_interface(DispatchEx
*dispex
, REFIID riid
)
625 HTMLImg
*This
= HTMLImg_from_DispatchEx(dispex
);
627 if(IsEqualGUID(&IID_IHTMLImgElement
, riid
))
628 return &This
->IHTMLImgElement_iface
;
630 return HTMLElement_query_interface(&This
->element
.node
.event_target
.dispex
, riid
);
633 static void HTMLImgElement_traverse(DispatchEx
*dispex
, nsCycleCollectionTraversalCallback
*cb
)
635 HTMLImg
*This
= HTMLImg_from_DispatchEx(dispex
);
636 HTMLElement_traverse(dispex
, cb
);
639 note_cc_edge((nsISupports
*)This
->nsimg
, "nsimg", cb
);
642 static void HTMLImgElement_unlink(DispatchEx
*dispex
)
644 HTMLImg
*This
= HTMLImg_from_DispatchEx(dispex
);
645 HTMLElement_unlink(dispex
);
646 unlink_ref(&This
->nsimg
);
649 static const NodeImplVtbl HTMLImgElementImplVtbl
= {
650 .clsid
= &CLSID_HTMLImg
,
651 .cpc_entries
= HTMLElement_cpc
,
652 .clone
= HTMLElement_clone
,
653 .get_attr_col
= HTMLElement_get_attr_col
,
654 .get_readystate
= HTMLImgElement_get_readystate
,
657 static const event_target_vtbl_t HTMLImgElement_event_target_vtbl
= {
659 HTMLELEMENT_DISPEX_VTBL_ENTRIES
,
660 .query_interface
= HTMLImgElement_query_interface
,
661 .destructor
= HTMLElement_destructor
,
662 .traverse
= HTMLImgElement_traverse
,
663 .unlink
= HTMLImgElement_unlink
665 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES
,
666 .handle_event
= HTMLElement_handle_event
669 static const tid_t HTMLImgElement_iface_tids
[] = {
674 static void HTMLImgElement_init_dispex_info(dispex_data_t
*info
, compat_mode_t mode
)
676 static const dispex_hook_t img_ie11_hooks
[] = {
677 {DISPID_IHTMLIMGELEMENT_FILESIZE
, NULL
},
681 HTMLElement_init_dispex_info(info
, mode
);
683 dispex_info_add_interface(info
, IHTMLImgElement_tid
, mode
>= COMPAT_MODE_IE11
? img_ie11_hooks
: NULL
);
686 static dispex_static_data_t HTMLImgElement_dispex
= {
688 &HTMLImgElement_event_target_vtbl
.dispex_vtbl
,
690 HTMLImgElement_iface_tids
,
691 HTMLImgElement_init_dispex_info
694 HRESULT
HTMLImgElement_Create(HTMLDocumentNode
*doc
, nsIDOMElement
*nselem
, HTMLElement
**elem
)
699 ret
= calloc(1, sizeof(HTMLImg
));
701 return E_OUTOFMEMORY
;
703 ret
->IHTMLImgElement_iface
.lpVtbl
= &HTMLImgElementVtbl
;
704 ret
->element
.node
.vtbl
= &HTMLImgElementImplVtbl
;
706 HTMLElement_Init(&ret
->element
, doc
, nselem
, &HTMLImgElement_dispex
);
708 nsres
= nsIDOMElement_QueryInterface(nselem
, &IID_nsIDOMHTMLImageElement
, (void**)&ret
->nsimg
);
709 assert(nsres
== NS_OK
);
711 *elem
= &ret
->element
;
715 static inline HTMLImageElementFactory
*impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory
*iface
)
717 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, IHTMLImageElementFactory_iface
);
720 DISPEX_IDISPATCH_IMPL(HTMLImageElementFactory
, IHTMLImageElementFactory
,
721 impl_from_IHTMLImageElementFactory(iface
)->dispex
)
723 static LONG
var_to_size(const VARIANT
*v
)
734 hres
= VarI4FromStr(V_BSTR(v
), 0, 0, &ret
);
736 FIXME("VarI4FromStr failed: %08lx\n", hres
);
742 FIXME("unsupported size %s\n", debugstr_variant(v
));
747 static HRESULT WINAPI
HTMLImageElementFactory_create(IHTMLImageElementFactory
*iface
,
748 VARIANT width
, VARIANT height
, IHTMLImgElement
**img_elem
)
750 HTMLImageElementFactory
*This
= impl_from_IHTMLImageElementFactory(iface
);
751 HTMLDocumentNode
*doc
= This
->window
->doc
;
752 IHTMLImgElement
*img
;
754 nsIDOMElement
*nselem
;
758 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_variant(&width
),
759 debugstr_variant(&height
), img_elem
);
763 hres
= create_nselem(doc
, L
"IMG", &nselem
);
767 hres
= HTMLElement_Create(doc
, (nsIDOMNode
*)nselem
, FALSE
, &elem
);
768 nsIDOMElement_Release(nselem
);
770 ERR("HTMLElement_Create failed\n");
774 hres
= IHTMLElement_QueryInterface(&elem
->IHTMLElement_iface
, &IID_IHTMLImgElement
,
776 IHTMLElement_Release(&elem
->IHTMLElement_iface
);
778 ERR("IHTMLElement_QueryInterface failed: 0x%08lx\n", hres
);
782 l
= var_to_size(&width
);
784 IHTMLImgElement_put_width(img
, l
);
785 l
= var_to_size(&height
);
787 IHTMLImgElement_put_height(img
, l
);
793 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
= {
794 HTMLImageElementFactory_QueryInterface
,
795 HTMLImageElementFactory_AddRef
,
796 HTMLImageElementFactory_Release
,
797 HTMLImageElementFactory_GetTypeInfoCount
,
798 HTMLImageElementFactory_GetTypeInfo
,
799 HTMLImageElementFactory_GetIDsOfNames
,
800 HTMLImageElementFactory_Invoke
,
801 HTMLImageElementFactory_create
804 static inline HTMLImageElementFactory
*impl_from_DispatchEx(DispatchEx
*iface
)
806 return CONTAINING_RECORD(iface
, HTMLImageElementFactory
, dispex
);
809 static void *HTMLImageElementFactory_query_interface(DispatchEx
*dispex
, REFIID riid
)
811 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
813 if(IsEqualGUID(&IID_IHTMLImageElementFactory
, riid
))
814 return &This
->IHTMLImageElementFactory_iface
;
819 static void HTMLImageElementFactory_traverse(DispatchEx
*dispex
, nsCycleCollectionTraversalCallback
*cb
)
821 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
824 note_cc_edge((nsISupports
*)&This
->window
->base
.IHTMLWindow2_iface
, "window", cb
);
827 static void HTMLImageElementFactory_unlink(DispatchEx
*dispex
)
829 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
832 HTMLInnerWindow
*window
= This
->window
;
834 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
838 static void HTMLImageElementFactory_destructor(DispatchEx
*dispex
)
840 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
844 static HRESULT
HTMLImageElementFactory_value(DispatchEx
*dispex
, LCID lcid
,
845 WORD flags
, DISPPARAMS
*params
, VARIANT
*res
, EXCEPINFO
*ei
,
846 IServiceProvider
*caller
)
848 HTMLImageElementFactory
*This
= impl_from_DispatchEx(dispex
);
849 IHTMLImgElement
*img
;
850 VARIANT empty
, *width
, *height
;
852 int argc
= params
->cArgs
- params
->cNamedArgs
;
856 V_VT(&empty
) = VT_EMPTY
;
858 width
= argc
>= 1 ? params
->rgvarg
+ (params
->cArgs
- 1) : &empty
;
859 height
= argc
>= 2 ? params
->rgvarg
+ (params
->cArgs
- 2) : &empty
;
861 hres
= IHTMLImageElementFactory_create(&This
->IHTMLImageElementFactory_iface
, *width
, *height
,
866 V_VT(res
) = VT_DISPATCH
;
867 V_DISPATCH(res
) = (IDispatch
*)img
;
872 static const tid_t HTMLImageElementFactory_iface_tids
[] = {
873 IHTMLImageElementFactory_tid
,
877 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
= {
878 .query_interface
= HTMLImageElementFactory_query_interface
,
879 .destructor
= HTMLImageElementFactory_destructor
,
880 .traverse
= HTMLImageElementFactory_traverse
,
881 .unlink
= HTMLImageElementFactory_unlink
,
882 .value
= HTMLImageElementFactory_value
,
885 static dispex_static_data_t HTMLImageElementFactory_dispex
= {
887 &HTMLImageElementFactory_dispex_vtbl
,
888 IHTMLImageElementFactory_tid
,
889 HTMLImageElementFactory_iface_tids
892 HRESULT
HTMLImageElementFactory_Create(HTMLInnerWindow
*window
, HTMLImageElementFactory
**ret_val
)
894 HTMLImageElementFactory
*ret
;
896 ret
= malloc(sizeof(HTMLImageElementFactory
));
898 return E_OUTOFMEMORY
;
900 ret
->IHTMLImageElementFactory_iface
.lpVtbl
= &HTMLImageElementFactoryVtbl
;
901 ret
->window
= window
;
902 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
904 init_dispatch(&ret
->dispex
, &HTMLImageElementFactory_dispex
, NULL
,
905 dispex_compat_mode(&window
->event_target
.dispex
));