ReactOS 0.4.15-dev-7842-g558ab78
htmlimg.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include "mshtml_private.h"
20
21typedef struct {
23
24 IHTMLImgElement IHTMLImgElement_iface;
25
28
29static inline HTMLImgElement *impl_from_IHTMLImgElement(IHTMLImgElement *iface)
30{
31 return CONTAINING_RECORD(iface, HTMLImgElement, IHTMLImgElement_iface);
32}
33
34static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
35{
37
38 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
39}
40
41static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface)
42{
44
45 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
46}
47
48static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
49{
51
52 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
53}
54
55static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo)
56{
58 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
59}
60
61static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo,
62 LCID lcid, ITypeInfo **ppTInfo)
63{
65 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
66 ppTInfo);
67}
68
69static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid,
70 LPOLESTR *rgszNames, UINT cNames,
71 LCID lcid, DISPID *rgDispId)
72{
74 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
75 cNames, lcid, rgDispId);
76}
77
78static HRESULT WINAPI HTMLImgElement_Invoke(IHTMLImgElement *iface, DISPID dispIdMember,
79 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
80 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
81{
83 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
84 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
85}
86
87static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v)
88{
90 nsresult nsres;
91
92 TRACE("(%p)->(%x)\n", This, v);
93
94 nsres = nsIDOMHTMLImageElement_SetIsMap(This->nsimg, v != VARIANT_FALSE);
95 if (NS_FAILED(nsres)) {
96 ERR("Set IsMap failed: %08x\n", nsres);
97 return E_FAIL;
98 }
99
100 return S_OK;
101}
102
103static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
104{
106 cpp_bool b;
107 nsresult nsres;
108
109 TRACE("(%p)->(%p)\n", This, p);
110
111 if (p == NULL)
112 return E_INVALIDARG;
113
114 nsres = nsIDOMHTMLImageElement_GetIsMap(This->nsimg, &b);
115 if (NS_FAILED(nsres)) {
116 ERR("Get IsMap failed: %08x\n", nsres);
117 return E_FAIL;
118 }
119 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
120 return S_OK;
121}
122
123static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
124{
126 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
127 return E_NOTIMPL;
128}
129
130static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
131{
133 FIXME("(%p)->(%p)\n", This, p);
134 return E_NOTIMPL;
135}
136
137static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
138{
140 FIXME("(%p)->(%p)\n", This, p);
141 return E_NOTIMPL;
142}
143
144static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
145{
147 FIXME("(%p)->(%p)\n", This, p);
148 return E_NOTIMPL;
149}
150
152{
154 FIXME("(%p)->(%p)\n", This, p);
155 return E_NOTIMPL;
156}
157
159{
161 FIXME("(%p)->(%p)\n", This, p);
162 return E_NOTIMPL;
163}
164
166{
168 FIXME("(%p)->(%p)\n", This, p);
169 return E_NOTIMPL;
170}
171
172static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
173{
175 FIXME("(%p)->(%p)\n", This, p);
176 return E_NOTIMPL;
177}
178
179static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
180{
182 FIXME("(%p)->(%p)\n", This, p);
183 return E_NOTIMPL;
184}
185
186static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
187{
189 FIXME("(%p)->(%p)\n", This, p);
190 return E_NOTIMPL;
191}
192
193static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
194{
196 FIXME("(%p)->()\n", This);
197 return E_NOTIMPL;
198}
199
200static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
201{
203 FIXME("(%p)->(%p)\n", This, p);
204 return E_NOTIMPL;
205}
206
207static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v)
208{
210 FIXME("(%p)->(%d)\n", This, v);
211 return E_NOTIMPL;
212}
213
214static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p)
215{
217 FIXME("(%p)->(%p)\n", This, p);
218 return E_NOTIMPL;
219}
220
221static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v)
222{
224 FIXME("(%p)->(%d)\n", This, v);
225 return E_NOTIMPL;
226}
227
228static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p)
229{
231 FIXME("(%p)->(%p)\n", This, p);
232 return E_NOTIMPL;
233}
234
235static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
236{
238 nsAString alt_str;
239 nsresult nsres;
240
241 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
242
243 nsAString_InitDepend(&alt_str, v);
244 nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
245 nsAString_Finish(&alt_str);
246 if(NS_FAILED(nsres))
247 ERR("SetAlt failed: %08x\n", nsres);
248
249 return S_OK;
250}
251
252static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
253{
255 nsAString alt_str;
256 nsresult nsres;
257
258 TRACE("(%p)->(%p)\n", This, p);
259
260 nsAString_Init(&alt_str, NULL);
261 nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
262 return return_nsstr(nsres, &alt_str, p);
263}
264
265static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
266{
268 nsAString src_str;
269 nsresult nsres;
270
271 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
272
273 nsAString_InitDepend(&src_str, v);
274 nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
275 nsAString_Finish(&src_str);
276 if(NS_FAILED(nsres))
277 ERR("SetSrc failed: %08x\n", nsres);
278
279 return NS_OK;
280}
281
282static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
283{
285 const PRUnichar *src;
286 nsAString src_str;
287 nsresult nsres;
288 HRESULT hres = S_OK;
289
290 static const WCHAR blockedW[] = {'B','L','O','C','K','E','D',':',':',0};
291
292 TRACE("(%p)->(%p)\n", This, p);
293
294 nsAString_Init(&src_str, NULL);
295 nsres = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &src_str);
296 if(NS_SUCCEEDED(nsres)) {
297 nsAString_GetData(&src_str, &src);
298
299 if(!strncmpiW(src, blockedW, sizeof(blockedW)/sizeof(WCHAR)-1)) {
300 TRACE("returning BLOCKED::\n");
301 *p = SysAllocString(blockedW);
302 if(!*p)
304 }else {
306 }
307 }else {
308 ERR("GetSrc failed: %08x\n", nsres);
309 hres = E_FAIL;
310 }
311
312 nsAString_Finish(&src_str);
313 return hres;
314}
315
316static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
317{
319 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
320 return E_NOTIMPL;
321}
322
323static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
324{
326 FIXME("(%p)->(%p)\n", This, p);
327 return E_NOTIMPL;
328}
329
330static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
331{
333 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
334 return E_NOTIMPL;
335}
336
337static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
338{
340 FIXME("(%p)->(%p)\n", This, p);
341 return E_NOTIMPL;
342}
343
344static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
345{
347 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
348 return E_NOTIMPL;
349}
350
351static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
352{
354 FIXME("(%p)->(%p)\n", This, p);
355 return E_NOTIMPL;
356}
357
358static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
359{
361 FIXME("(%p)->(%p)\n", This, p);
362 return E_NOTIMPL;
363}
364
366{
369 nsresult nsres;
370
371 TRACE("(%p)->(%p)\n", This, p);
372
373 nsres = nsIDOMHTMLImageElement_GetComplete(This->nsimg, &complete);
374 if(NS_FAILED(nsres)) {
375 ERR("GetComplete failed: %08x\n", nsres);
376 return E_FAIL;
377 }
378
379 *p = complete ? VARIANT_TRUE : VARIANT_FALSE;
380 return S_OK;
381}
382
383static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
384{
386 FIXME("(%p)->()\n", This);
387 return E_NOTIMPL;
388}
389
390static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
391{
393 FIXME("(%p)->(%p)\n", This, p);
394 return E_NOTIMPL;
395}
396
397static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
398{
401 nsresult nsres;
402
403 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
404
406
407 nsres = nsIDOMHTMLImageElement_SetAlign(This->nsimg, &str);
409 if (NS_FAILED(nsres)){
410 ERR("Set Align(%s) failed: %08x\n", debugstr_w(v), nsres);
411 return E_FAIL;
412 }
413
414 return S_OK;
415}
416
417static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
418{
421 nsresult nsres;
422
423 TRACE("(%p)->(%p)\n", This, p);
424
426 nsres = nsIDOMHTMLImageElement_GetAlign(This->nsimg, &str);
427
428 return return_nsstr(nsres, &str, p);
429}
430
431static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
432{
434
435 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
436
437 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
438}
439
440static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
441{
443
444 TRACE("(%p)->(%p)\n", This, p);
445
446 return get_node_event(&This->element.node, EVENTID_LOAD, p);
447}
448
449static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
450{
452
453 TRACE("(%p)->()\n", This);
454
455 return set_node_event(&This->element.node, EVENTID_ERROR, &v);
456}
457
458static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
459{
461
462 TRACE("(%p)->(%p)\n", This, p);
463
464 return get_node_event(&This->element.node, EVENTID_ERROR, p);
465}
466
467static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
468{
470
471 TRACE("(%p)->()\n", This);
472
473 return set_node_event(&This->element.node, EVENTID_ABORT, &v);
474}
475
476static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
477{
479
480 TRACE("(%p)->(%p)\n", This, p);
481
482 return get_node_event(&This->element.node, EVENTID_ABORT, p);
483}
484
485static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
486{
488 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
489 return E_NOTIMPL;
490}
491
492static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
493{
496 nsresult nsres;
497
498 TRACE("(%p)->(%p)\n", This, p);
499
501 nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &name);
502 return return_nsstr(nsres, &name, p);
503}
504
505static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
506{
508 nsresult nsres;
509
510 TRACE("(%p)->(%d)\n", This, v);
511
512 nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v);
513 if(NS_FAILED(nsres)) {
514 ERR("SetWidth failed: %08x\n", nsres);
515 return E_FAIL;
516 }
517
518 return S_OK;
519}
520
521static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p)
522{
525 nsresult nsres;
526
527 TRACE("(%p)->(%p)\n", This, p);
528
529 nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width);
530 if(NS_FAILED(nsres)) {
531 ERR("GetWidth failed: %08x\n", nsres);
532 return E_FAIL;
533 }
534
535 *p = width;
536 return S_OK;
537}
538
539static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v)
540{
542 nsresult nsres;
543
544 TRACE("(%p)->(%d)\n", This, v);
545
546 nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v);
547 if(NS_FAILED(nsres)) {
548 ERR("SetHeight failed: %08x\n", nsres);
549 return E_FAIL;
550 }
551
552 return S_OK;
553}
554
555static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p)
556{
559 nsresult nsres;
560
561 TRACE("(%p)->(%p)\n", This, p);
562
563 nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height);
564 if(NS_FAILED(nsres)) {
565 ERR("GetHeight failed: %08x\n", nsres);
566 return E_FAIL;
567 }
568
569 *p = height;
570 return S_OK;
571}
572
573static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
574{
576 FIXME("(%p)->()\n", This);
577 return E_NOTIMPL;
578}
579
580static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
581{
583 FIXME("(%p)->(%p)\n", This, p);
584 return E_NOTIMPL;
585}
586
587static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
643};
644
646{
647 return CONTAINING_RECORD(iface, HTMLImgElement, element.node);
648}
649
651{
653
654 *ppv = NULL;
655
656 if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
657 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
658 *ppv = &This->IHTMLImgElement_iface;
659 }else {
660 return HTMLElement_QI(&This->element.node, riid, ppv);
661 }
662
663 IUnknown_AddRef((IUnknown*)*ppv);
664 return S_OK;
665}
666
668{
670
671 return IHTMLImgElement_get_readyState(&This->IHTMLImgElement_iface, p);
672}
673
675{
677
678 if(This->nsimg)
679 note_cc_edge((nsISupports*)This->nsimg, "This->nsimg", cb);
680}
681
683{
685
686 if(This->nsimg) {
687 nsIDOMHTMLImageElement *nsimg = This->nsimg;
688
689 This->nsimg = NULL;
690 nsIDOMHTMLImageElement_Release(nsimg);
691 }
692}
693
701 NULL,
702 NULL,
703 NULL,
704 NULL,
705 NULL,
707 NULL,
708 NULL,
709 NULL,
712};
713
716 IHTMLImgElement_tid,
717 0
718};
720 NULL,
721 DispHTMLImg_tid,
722 NULL,
724};
725
727{
729 nsresult nsres;
730
731 ret = heap_alloc_zero(sizeof(HTMLImgElement));
732 if(!ret)
733 return E_OUTOFMEMORY;
734
735 ret->IHTMLImgElement_iface.lpVtbl = &HTMLImgElementVtbl;
736 ret->element.node.vtbl = &HTMLImgElementImplVtbl;
737
738 HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
739
740 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
741 assert(nsres == NS_OK);
742
743 *elem = &ret->element;
744 return S_OK;
745}
746
747static inline HTMLImageElementFactory *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface)
748{
749 return CONTAINING_RECORD(iface, HTMLImageElementFactory, IHTMLImageElementFactory_iface);
750}
751
752static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface,
753 REFIID riid, void **ppv)
754{
756
757 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
758
760 *ppv = &This->IHTMLImageElementFactory_iface;
761 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory, riid)) {
762 *ppv = &This->IHTMLImageElementFactory_iface;
763 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
764 return *ppv ? S_OK : E_NOINTERFACE;
765 }else {
766 *ppv = NULL;
767 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
768 return E_NOINTERFACE;
769 }
770
771 IUnknown_AddRef((IUnknown*)*ppv);
772 return S_OK;
773}
774
775static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface)
776{
779
780 TRACE("(%p) ref=%d\n", This, ref);
781
782 return ref;
783}
784
785static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface)
786{
789
790 TRACE("(%p) ref=%d\n", This, ref);
791
792 if(!ref)
794
795 return ref;
796}
797
798static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface,
799 UINT *pctinfo)
800{
802 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
803}
804
805static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface,
806 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
807{
809 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
810}
811
812static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface,
813 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
814 DISPID *rgDispId)
815{
817 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
818}
819
820static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *iface,
821 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
822 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
823 UINT *puArgErr)
824{
826 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
827 pDispParams, pVarResult, pExcepInfo, puArgErr);
828}
829
830static LONG var_to_size(const VARIANT *v)
831{
832 switch(V_VT(v)) {
833 case VT_EMPTY:
834 return 0;
835 case VT_I4:
836 return V_I4(v);
837 case VT_BSTR: {
838 LONG ret;
840
841 hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret);
842 if(FAILED(hres)) {
843 FIXME("VarI4FromStr failed: %08x\n", hres);
844 return 0;
845 }
846 return ret;
847 }
848 default:
849 FIXME("unsupported size %s\n", debugstr_variant(v));
850 }
851 return 0;
852}
853
854static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface,
855 VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
856{
858 HTMLDocumentNode *doc;
859 IHTMLImgElement *img;
861 nsIDOMHTMLElement *nselem;
862 LONG l;
864
865 static const PRUnichar imgW[] = {'I','M','G',0};
866
867 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
868 debugstr_variant(&height), img_elem);
869
870 if(!This->window || !This->window->doc) {
871 WARN("NULL doc\n");
872 return E_UNEXPECTED;
873 }
874
875 doc = This->window->doc;
876
877 *img_elem = NULL;
878
879 hres = create_nselem(doc, imgW, &nselem);
880 if(FAILED(hres))
881 return hres;
882
883 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, FALSE, &elem);
884 nsIDOMHTMLElement_Release(nselem);
885 if(FAILED(hres)) {
886 ERR("HTMLElement_Create failed\n");
887 return hres;
888 }
889
890 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLImgElement,
891 (void**)&img);
892 IHTMLElement_Release(&elem->IHTMLElement_iface);
893 if(FAILED(hres)) {
894 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
895 return hres;
896 }
897
898 l = var_to_size(&width);
899 if(l)
900 IHTMLImgElement_put_width(img, l);
901 l = var_to_size(&height);
902 if(l)
903 IHTMLImgElement_put_height(img, l);
904
905 *img_elem = img;
906 return S_OK;
907}
908
909static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = {
918};
919
921{
922 return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex);
923}
924
926 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
927 IServiceProvider *caller)
928{
930 IHTMLImgElement *img;
933 int argc = params->cArgs - params->cNamedArgs;
934
935 V_VT(res) = VT_NULL;
936
937 V_VT(&empty) = VT_EMPTY;
938
939 width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : ∅
940 height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : ∅
941
942 hres = IHTMLImageElementFactory_create(&This->IHTMLImageElementFactory_iface, *width, *height,
943 &img);
944 if(FAILED(hres))
945 return hres;
946
949
950 return S_OK;
951}
952
954 IHTMLImageElementFactory_tid,
955 0
956};
957
960 NULL,
961 NULL,
962 NULL
963};
964
967 IHTMLImageElementFactory_tid,
968 NULL,
970};
971
973{
975
977 if(!ret)
978 return E_OUTOFMEMORY;
979
980 ret->IHTMLImageElementFactory_iface.lpVtbl = &HTMLImageElementFactoryVtbl;
981 ret->ref = 1;
982 ret->window = window;
983
984 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLImageElementFactory_iface,
986
987 *ret_val = ret;
988 return S_OK;
989}
unsigned int UINT32
static int argc
Definition: ServiceArgs.c:12
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
#define ERR(fmt,...)
Definition: debug.h:110
r l[0]
Definition: byte_order.h:168
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned char cpp_bool
Definition: atl.c:38
static const WCHAR empty[]
Definition: main.c:47
OLECHAR * BSTR
Definition: compat.h:2293
short VARIANT_BOOL
Definition: compat.h:2290
@ VT_BSTR
Definition: compat.h:2303
@ VT_NULL
Definition: compat.h:2296
@ VT_I4
Definition: compat.h:2298
@ VT_EMPTY
Definition: compat.h:2295
@ VT_DISPATCH
Definition: compat.h:2304
const char * debugstr_mshtml_guid(const GUID *iid)
Definition: main.c:542
HRESULT WINAPI VarI4FromStr(OLECHAR *strIn, LCID lcid, ULONG dwFlags, LONG *piOut)
Definition: vartype.c:1611
#define assert(x)
Definition: debug.h:53
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLvoid * img
Definition: gl.h:1956
const GLdouble * v
Definition: gl.h:2040
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum const GLfloat * params
Definition: glext.h:5645
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
Definition: htmlelem.c:3793
HRESULT HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic, HTMLElement **ret)
Definition: htmlelem.c:4032
void HTMLElement_destructor(HTMLDOMNode *iface)
Definition: htmlelem.c:3764
HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
Definition: htmlelem.c:3815
const cpc_entry_t HTMLElement_cpc[]
Definition: htmlelem.c:3847
void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
Definition: htmlelem.c:4008
static const WCHAR imgW[]
Definition: htmlelem.c:30
HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
Definition: htmlelem.c:4827
HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmlelem.c:3738
HRESULT create_nselem(HTMLDocumentNode *doc, const WCHAR *tag, nsIDOMHTMLElement **ret)
Definition: htmlelem.c:246
@ EVENTID_ABORT
Definition: htmlevent.h:22
@ EVENTID_ERROR
Definition: htmlevent.h:32
@ EVENTID_LOAD
Definition: htmlevent.h:39
static HRESULT get_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
Definition: htmlevent.h:85
static HRESULT set_node_event(HTMLDOMNode *node, eventid_t eid, VARIANT *var)
Definition: htmlevent.h:80
static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:144
static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface)
Definition: htmlimg.c:775
static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:337
static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p)
Definition: htmlimg.c:521
static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:179
static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:344
static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:573
static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v)
Definition: htmlimg.c:539
static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v)
Definition: htmlimg.c:207
static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:397
static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmlimg.c:61
static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:330
static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmlimg.c:69
static HRESULT WINAPI HTMLImgElement_Invoke(IHTMLImgElement *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: htmlimg.c:78
static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:417
static HTMLImgElement * impl_from_IHTMLImgElement(IHTMLImgElement *iface)
Definition: htmlimg.c:29
static void HTMLImgElement_unlink(HTMLDOMNode *iface)
Definition: htmlimg.c:682
static void HTMLImgElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
Definition: htmlimg.c:674
static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface)
Definition: htmlimg.c:41
static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:316
static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo)
Definition: htmlimg.c:55
static const IHTMLImgElementVtbl HTMLImgElementVtbl
Definition: htmlimg.c:587
static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:351
static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:130
static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
Definition: htmlimg.c:440
static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:165
static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:323
static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p)
Definition: htmlimg.c:228
static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:137
static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:358
static dispex_static_data_t HTMLImageElementFactory_dispex
Definition: htmlimg.c:965
static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
Definition: htmlimg.c:505
static dispex_static_data_t HTMLImgElement_dispex
Definition: htmlimg.c:719
static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
Definition: htmlimg.c:449
static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
Definition: htmlimg.c:34
static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
Definition: htmlimg.c:476
static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:151
static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmlimg.c:805
static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:172
HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
Definition: htmlimg.c:726
static const NodeImplVtbl HTMLImgElementImplVtbl
Definition: htmlimg.c:694
static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:580
HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElementFactory **ret_val)
Definition: htmlimg.c:972
static HTMLImageElementFactory * impl_from_DispatchEx(DispatchEx *iface)
Definition: htmlimg.c:920
static const tid_t HTMLImgElement_iface_tids[]
Definition: htmlimg.c:714
static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
Definition: htmlimg.c:193
static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
Definition: htmlimg.c:383
static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface)
Definition: htmlimg.c:785
static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:265
static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmlimg.c:650
static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v)
Definition: htmlimg.c:221
static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p)
Definition: htmlimg.c:555
static LONG var_to_size(const VARIANT *v)
Definition: htmlimg.c:830
static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:235
static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl
Definition: htmlimg.c:958
static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: htmlimg.c:820
static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:158
static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:252
static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
Definition: htmlimg.c:458
static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
Definition: htmlimg.c:667
static HTMLImgElement * impl_from_HTMLDOMNode(HTMLDOMNode *iface)
Definition: htmlimg.c:645
static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
Definition: htmlimg.c:431
static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
Definition: htmlimg.c:103
static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
Definition: htmlimg.c:467
static const tid_t HTMLImageElementFactory_iface_tids[]
Definition: htmlimg.c:953
static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:485
static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
Definition: htmlimg.c:123
static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
Definition: htmlimg.c:390
static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface, VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
Definition: htmlimg.c:854
static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
Definition: htmlimg.c:925
static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl
Definition: htmlimg.c:909
static HTMLImageElementFactory * impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface)
Definition: htmlimg.c:747
static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
Definition: htmlimg.c:365
static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface, REFIID riid, void **ppv)
Definition: htmlimg.c:752
static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmlimg.c:812
static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v)
Definition: htmlimg.c:87
static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:186
static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
Definition: htmlimg.c:200
static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
Definition: htmlimg.c:48
static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p)
Definition: htmlimg.c:214
static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:492
static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
Definition: htmlimg.c:282
static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface, UINT *pctinfo)
Definition: htmlimg.c:798
tid_t
Definition: ieframe.h:311
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
#define b
Definition: ke_i.h:79
#define debugstr_w
Definition: kernel32.h:32
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
HRESULT hres
Definition: protocol.c:465
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static IHTMLWindow2 * window
Definition: events.c:77
static BOOL complete
Definition: htmldoc.c:198
static size_t elem
Definition: string.c:68
static LPOLESTR
Definition: stg_prop.c:27
static VARIANTARG static DISPID
Definition: ordinal.c:52
BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
Definition: dispex.c:1656
#define NS_OK
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
UINT32 nsAString_GetData(const nsAString *, const PRUnichar **) DECLSPEC_HIDDEN
Definition: nsembed.c:831
#define HTMLELEMENT_TIDS
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
HRESULT nsuri_to_url(LPCWSTR, BOOL, BSTR *) DECLSPEC_HIDDEN
Definition: nsio.c:175
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback
#define NS_SUCCEEDED(res)
#define NS_FAILED(res)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
unsigned int UINT
Definition: ndis.h:50
WCHAR PRUnichar
Definition: nsiface.idl:48
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
#define V_VT(A)
Definition: oleauto.h:211
#define V_BSTR(A)
Definition: oleauto.h:226
#define V_I4(A)
Definition: oleauto.h:247
#define V_DISPATCH(A)
Definition: oleauto.h:239
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
const WCHAR * str
DWORD LCID
Definition: nls.h:13
#define TRACE(s)
Definition: solgame.cpp:4
HTMLElement element
Definition: htmlimg.c:22
IHTMLImgElement IHTMLImgElement_iface
Definition: htmlimg.c:24
nsIDOMHTMLImageElement * nsimg
Definition: htmlimg.c:26
Definition: name.c:39
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_UNEXPECTED
Definition: winerror.h:2456
__wchar_t WCHAR
Definition: xmlstorage.h:180