d3d11: Add ID3D11Buffer interface stub.
[wine.git] / dlls / mshtml / htmlimg.c
bloba29dbe3d300aedaad20d0d0aab50af3f840b4b62
1 /*
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
19 #include <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 typedef struct {
37 HTMLElement element;
39 IHTMLImgElement IHTMLImgElement_iface;
41 nsIDOMHTMLImageElement *nsimg;
42 } HTMLImgElement;
44 static inline HTMLImgElement *impl_from_IHTMLImgElement(IHTMLImgElement *iface)
46 return CONTAINING_RECORD(iface, HTMLImgElement, IHTMLImgElement_iface);
49 static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
51 HTMLImgElement *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 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
65 HTMLImgElement *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 HTMLImgElement *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 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames,
86 LCID lcid, DISPID *rgDispId)
88 HTMLImgElement *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 HTMLImgElement *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 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
105 nsresult nsres;
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);
112 return E_FAIL;
115 return S_OK;
118 static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
120 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
121 cpp_bool b;
122 nsresult nsres;
124 TRACE("(%p)->(%p)\n", This, p);
126 if (p == NULL)
127 return E_INVALIDARG;
129 nsres = nsIDOMHTMLImageElement_GetIsMap(This->nsimg, &b);
130 if (NS_FAILED(nsres)) {
131 ERR("Get IsMap failed: %08x\n", nsres);
132 return E_FAIL;
134 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
135 return S_OK;
138 static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
140 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
141 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
142 return E_NOTIMPL;
145 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
147 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
148 FIXME("(%p)->(%p)\n", This, p);
149 return E_NOTIMPL;
152 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
154 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
155 FIXME("(%p)->(%p)\n", This, p);
156 return E_NOTIMPL;
159 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
161 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
162 FIXME("(%p)->(%p)\n", This, p);
163 return E_NOTIMPL;
166 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
168 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
169 FIXME("(%p)->(%p)\n", This, p);
170 return E_NOTIMPL;
173 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
175 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
176 FIXME("(%p)->(%p)\n", This, p);
177 return E_NOTIMPL;
180 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
182 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
183 FIXME("(%p)->(%p)\n", This, p);
184 return E_NOTIMPL;
187 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
189 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
190 FIXME("(%p)->(%p)\n", This, p);
191 return E_NOTIMPL;
194 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
196 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
197 FIXME("(%p)->(%p)\n", This, p);
198 return E_NOTIMPL;
201 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
203 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
204 FIXME("(%p)->(%p)\n", This, p);
205 return E_NOTIMPL;
208 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
210 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
211 FIXME("(%p)->()\n", This);
212 return E_NOTIMPL;
215 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
217 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
218 FIXME("(%p)->(%p)\n", This, p);
219 return E_NOTIMPL;
222 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v)
224 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
225 FIXME("(%p)->(%d)\n", This, v);
226 return E_NOTIMPL;
229 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p)
231 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
232 FIXME("(%p)->(%p)\n", This, p);
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v)
238 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
239 FIXME("(%p)->(%d)\n", This, v);
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p)
245 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
246 FIXME("(%p)->(%p)\n", This, p);
247 return E_NOTIMPL;
250 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
252 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
253 nsAString alt_str;
254 nsresult nsres;
256 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
258 nsAString_InitDepend(&alt_str, v);
259 nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
260 nsAString_Finish(&alt_str);
261 if(NS_FAILED(nsres))
262 ERR("SetAlt failed: %08x\n", nsres);
264 return S_OK;
267 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
269 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
270 nsAString alt_str;
271 nsresult nsres;
273 TRACE("(%p)->(%p)\n", This, p);
275 nsAString_Init(&alt_str, NULL);
276 nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
277 return return_nsstr(nsres, &alt_str, p);
280 static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
282 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
283 nsAString src_str;
284 nsresult nsres;
286 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
288 nsAString_InitDepend(&src_str, v);
289 nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
290 nsAString_Finish(&src_str);
291 if(NS_FAILED(nsres))
292 ERR("SetSrc failed: %08x\n", nsres);
294 return NS_OK;
297 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
299 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
300 const PRUnichar *src;
301 nsAString src_str;
302 nsresult nsres;
303 HRESULT hres = S_OK;
305 static const WCHAR blockedW[] = {'B','L','O','C','K','E','D',':',':',0};
307 TRACE("(%p)->(%p)\n", This, p);
309 nsAString_Init(&src_str, NULL);
310 nsres = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &src_str);
311 if(NS_SUCCEEDED(nsres)) {
312 nsAString_GetData(&src_str, &src);
314 if(!strncmpiW(src, blockedW, sizeof(blockedW)/sizeof(WCHAR)-1)) {
315 TRACE("returning BLOCKED::\n");
316 *p = SysAllocString(blockedW);
317 if(!*p)
318 hres = E_OUTOFMEMORY;
319 }else {
320 hres = nsuri_to_url(src, TRUE, p);
322 }else {
323 ERR("GetSrc failed: %08x\n", nsres);
324 hres = E_FAIL;
327 nsAString_Finish(&src_str);
328 return hres;
331 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
333 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
334 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
335 return E_NOTIMPL;
338 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
340 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
341 FIXME("(%p)->(%p)\n", This, p);
342 return E_NOTIMPL;
345 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
347 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
348 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
349 return E_NOTIMPL;
352 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
354 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
355 FIXME("(%p)->(%p)\n", This, p);
356 return E_NOTIMPL;
359 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
361 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
362 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
363 return E_NOTIMPL;
366 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
368 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
369 FIXME("(%p)->(%p)\n", This, p);
370 return E_NOTIMPL;
373 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
375 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
376 FIXME("(%p)->(%p)\n", This, p);
377 return E_NOTIMPL;
380 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
382 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
383 cpp_bool complete;
384 nsresult nsres;
386 TRACE("(%p)->(%p)\n", This, p);
388 nsres = nsIDOMHTMLImageElement_GetComplete(This->nsimg, &complete);
389 if(NS_FAILED(nsres)) {
390 ERR("GetComplete failed: %08x\n", nsres);
391 return E_FAIL;
394 *p = complete ? VARIANT_TRUE : VARIANT_FALSE;
395 return S_OK;
398 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
400 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
401 FIXME("(%p)->()\n", This);
402 return E_NOTIMPL;
405 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
407 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
408 FIXME("(%p)->(%p)\n", This, p);
409 return E_NOTIMPL;
412 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
414 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
415 nsAString str;
416 nsresult nsres;
418 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
420 nsAString_InitDepend(&str, v);
422 nsres = nsIDOMHTMLImageElement_SetAlign(This->nsimg, &str);
423 nsAString_Finish(&str);
424 if (NS_FAILED(nsres)){
425 ERR("Set Align(%s) failed: %08x\n", debugstr_w(v), nsres);
426 return E_FAIL;
429 return S_OK;
432 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
434 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
435 nsAString str;
436 nsresult nsres;
438 TRACE("(%p)->(%p)\n", This, p);
440 nsAString_Init(&str, NULL);
441 nsres = nsIDOMHTMLImageElement_GetAlign(This->nsimg, &str);
443 return return_nsstr(nsres, &str, p);
446 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
448 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
450 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
452 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
455 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
457 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
459 TRACE("(%p)->(%p)\n", This, p);
461 return get_node_event(&This->element.node, EVENTID_LOAD, p);
464 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
466 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
468 TRACE("(%p)->()\n", This);
470 return set_node_event(&This->element.node, EVENTID_ERROR, &v);
473 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
475 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
477 TRACE("(%p)->(%p)\n", This, p);
479 return get_node_event(&This->element.node, EVENTID_ERROR, p);
482 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
484 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
486 TRACE("(%p)->()\n", This);
488 return set_node_event(&This->element.node, EVENTID_ABORT, &v);
491 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
493 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
495 TRACE("(%p)->(%p)\n", This, p);
497 return get_node_event(&This->element.node, EVENTID_ABORT, p);
500 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
502 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
503 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
504 return E_NOTIMPL;
507 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
509 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
510 nsAString name;
511 nsresult nsres;
513 TRACE("(%p)->(%p)\n", This, p);
515 nsAString_Init(&name, NULL);
516 nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &name);
517 return return_nsstr(nsres, &name, p);
520 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
522 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
523 nsresult nsres;
525 TRACE("(%p)->(%d)\n", This, v);
527 nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v);
528 if(NS_FAILED(nsres)) {
529 ERR("SetWidth failed: %08x\n", nsres);
530 return E_FAIL;
533 return S_OK;
536 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p)
538 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
539 UINT32 width;
540 nsresult nsres;
542 TRACE("(%p)->(%p)\n", This, p);
544 nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width);
545 if(NS_FAILED(nsres)) {
546 ERR("GetWidth failed: %08x\n", nsres);
547 return E_FAIL;
550 *p = width;
551 return S_OK;
554 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v)
556 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
557 nsresult nsres;
559 TRACE("(%p)->(%d)\n", This, v);
561 nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v);
562 if(NS_FAILED(nsres)) {
563 ERR("SetHeight failed: %08x\n", nsres);
564 return E_FAIL;
567 return S_OK;
570 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p)
572 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
573 UINT32 height;
574 nsresult nsres;
576 TRACE("(%p)->(%p)\n", This, p);
578 nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height);
579 if(NS_FAILED(nsres)) {
580 ERR("GetHeight failed: %08x\n", nsres);
581 return E_FAIL;
584 *p = height;
585 return S_OK;
588 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
590 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
591 FIXME("(%p)->()\n", This);
592 return E_NOTIMPL;
595 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
597 HTMLImgElement *This = impl_from_IHTMLImgElement(iface);
598 FIXME("(%p)->(%p)\n", This, p);
599 return E_NOTIMPL;
602 static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
603 HTMLImgElement_QueryInterface,
604 HTMLImgElement_AddRef,
605 HTMLImgElement_Release,
606 HTMLImgElement_GetTypeInfoCount,
607 HTMLImgElement_GetTypeInfo,
608 HTMLImgElement_GetIDsOfNames,
609 HTMLImgElement_Invoke,
610 HTMLImgElement_put_isMap,
611 HTMLImgElement_get_isMap,
612 HTMLImgElement_put_useMap,
613 HTMLImgElement_get_useMap,
614 HTMLImgElement_get_mimeType,
615 HTMLImgElement_get_fileSize,
616 HTMLImgElement_get_fileCreatedDate,
617 HTMLImgElement_get_fileModifiedDate,
618 HTMLImgElement_get_fileUpdatedDate,
619 HTMLImgElement_get_protocol,
620 HTMLImgElement_get_href,
621 HTMLImgElement_get_nameProp,
622 HTMLImgElement_put_border,
623 HTMLImgElement_get_border,
624 HTMLImgElement_put_vspace,
625 HTMLImgElement_get_vspace,
626 HTMLImgElement_put_hspace,
627 HTMLImgElement_get_hspace,
628 HTMLImgElement_put_alt,
629 HTMLImgElement_get_alt,
630 HTMLImgElement_put_src,
631 HTMLImgElement_get_src,
632 HTMLImgElement_put_lowsrc,
633 HTMLImgElement_get_lowsrc,
634 HTMLImgElement_put_vrml,
635 HTMLImgElement_get_vrml,
636 HTMLImgElement_put_dynsrc,
637 HTMLImgElement_get_dynsrc,
638 HTMLImgElement_get_readyState,
639 HTMLImgElement_get_complete,
640 HTMLImgElement_put_loop,
641 HTMLImgElement_get_loop,
642 HTMLImgElement_put_align,
643 HTMLImgElement_get_align,
644 HTMLImgElement_put_onload,
645 HTMLImgElement_get_onload,
646 HTMLImgElement_put_onerror,
647 HTMLImgElement_get_onerror,
648 HTMLImgElement_put_onabort,
649 HTMLImgElement_get_onabort,
650 HTMLImgElement_put_name,
651 HTMLImgElement_get_name,
652 HTMLImgElement_put_width,
653 HTMLImgElement_get_width,
654 HTMLImgElement_put_height,
655 HTMLImgElement_get_height,
656 HTMLImgElement_put_start,
657 HTMLImgElement_get_start
660 static inline HTMLImgElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
662 return CONTAINING_RECORD(iface, HTMLImgElement, element.node);
665 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
667 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
669 *ppv = NULL;
671 if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
672 TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
673 *ppv = &This->IHTMLImgElement_iface;
674 }else {
675 return HTMLElement_QI(&This->element.node, riid, ppv);
678 IUnknown_AddRef((IUnknown*)*ppv);
679 return S_OK;
682 static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
684 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
686 return IHTMLImgElement_get_readyState(&This->IHTMLImgElement_iface, p);
689 static void HTMLImgElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
691 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
693 if(This->nsimg)
694 note_cc_edge((nsISupports*)This->nsimg, "This->nsimg", cb);
697 static void HTMLImgElement_unlink(HTMLDOMNode *iface)
699 HTMLImgElement *This = impl_from_HTMLDOMNode(iface);
701 if(This->nsimg) {
702 nsIDOMHTMLImageElement *nsimg = This->nsimg;
704 This->nsimg = NULL;
705 nsIDOMHTMLImageElement_Release(nsimg);
709 static const NodeImplVtbl HTMLImgElementImplVtbl = {
710 HTMLImgElement_QI,
711 HTMLElement_destructor,
712 HTMLElement_cpc,
713 HTMLElement_clone,
714 HTMLElement_handle_event,
715 HTMLElement_get_attr_col,
716 NULL,
717 NULL,
718 NULL,
719 NULL,
720 NULL,
721 HTMLImgElement_get_readystate,
722 NULL,
723 NULL,
724 NULL,
725 HTMLImgElement_traverse,
726 HTMLImgElement_unlink
729 static const tid_t HTMLImgElement_iface_tids[] = {
730 HTMLELEMENT_TIDS,
731 IHTMLImgElement_tid,
734 static dispex_static_data_t HTMLImgElement_dispex = {
735 NULL,
736 DispHTMLImg_tid,
737 NULL,
738 HTMLImgElement_iface_tids
741 HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
743 HTMLImgElement *ret;
744 nsresult nsres;
746 ret = heap_alloc_zero(sizeof(HTMLImgElement));
747 if(!ret)
748 return E_OUTOFMEMORY;
750 ret->IHTMLImgElement_iface.lpVtbl = &HTMLImgElementVtbl;
751 ret->element.node.vtbl = &HTMLImgElementImplVtbl;
753 HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
755 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
756 assert(nsres == NS_OK);
758 *elem = &ret->element;
759 return S_OK;
762 static inline HTMLImageElementFactory *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface)
764 return CONTAINING_RECORD(iface, HTMLImageElementFactory, IHTMLImageElementFactory_iface);
767 static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface,
768 REFIID riid, void **ppv)
770 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
772 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
774 if(IsEqualGUID(&IID_IUnknown, riid)) {
775 *ppv = &This->IHTMLImageElementFactory_iface;
776 }else if(IsEqualGUID(&IID_IHTMLImageElementFactory, riid)) {
777 *ppv = &This->IHTMLImageElementFactory_iface;
778 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
779 return *ppv ? S_OK : E_NOINTERFACE;
780 }else {
781 *ppv = NULL;
782 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
783 return E_NOINTERFACE;
786 IUnknown_AddRef((IUnknown*)*ppv);
787 return S_OK;
790 static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface)
792 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
793 LONG ref = InterlockedIncrement(&This->ref);
795 TRACE("(%p) ref=%d\n", This, ref);
797 return ref;
800 static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface)
802 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
803 LONG ref = InterlockedDecrement(&This->ref);
805 TRACE("(%p) ref=%d\n", This, ref);
807 if(!ref)
808 heap_free(This);
810 return ref;
813 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface,
814 UINT *pctinfo)
816 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
817 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
820 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface,
821 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
823 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
824 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
827 static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface,
828 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
829 DISPID *rgDispId)
831 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
832 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId);
835 static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *iface,
836 DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
837 DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
838 UINT *puArgErr)
840 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
841 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
842 pDispParams, pVarResult, pExcepInfo, puArgErr);
845 static LONG var_to_size(const VARIANT *v)
847 switch(V_VT(v)) {
848 case VT_EMPTY:
849 return 0;
850 case VT_I4:
851 return V_I4(v);
852 case VT_BSTR: {
853 LONG ret;
854 HRESULT hres;
856 hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret);
857 if(FAILED(hres)) {
858 FIXME("VarI4FromStr failed: %08x\n", hres);
859 return 0;
861 return ret;
863 default:
864 FIXME("unsupported size %s\n", debugstr_variant(v));
866 return 0;
869 static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface,
870 VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
872 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface);
873 HTMLDocumentNode *doc;
874 IHTMLImgElement *img;
875 HTMLElement *elem;
876 nsIDOMHTMLElement *nselem;
877 LONG l;
878 HRESULT hres;
880 static const PRUnichar imgW[] = {'I','M','G',0};
882 TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
883 debugstr_variant(&height), img_elem);
885 if(!This->window || !This->window->doc) {
886 WARN("NULL doc\n");
887 return E_UNEXPECTED;
890 doc = This->window->doc;
892 *img_elem = NULL;
894 hres = create_nselem(doc, imgW, &nselem);
895 if(FAILED(hres))
896 return hres;
898 hres = HTMLElement_Create(doc, (nsIDOMNode*)nselem, FALSE, &elem);
899 nsIDOMHTMLElement_Release(nselem);
900 if(FAILED(hres)) {
901 ERR("HTMLElement_Create failed\n");
902 return hres;
905 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLImgElement,
906 (void**)&img);
907 IHTMLElement_Release(&elem->IHTMLElement_iface);
908 if(FAILED(hres)) {
909 ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
910 return hres;
913 l = var_to_size(&width);
914 if(l)
915 IHTMLImgElement_put_width(img, l);
916 l = var_to_size(&height);
917 if(l)
918 IHTMLImgElement_put_height(img, l);
920 *img_elem = img;
921 return S_OK;
924 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = {
925 HTMLImageElementFactory_QueryInterface,
926 HTMLImageElementFactory_AddRef,
927 HTMLImageElementFactory_Release,
928 HTMLImageElementFactory_GetTypeInfoCount,
929 HTMLImageElementFactory_GetTypeInfo,
930 HTMLImageElementFactory_GetIDsOfNames,
931 HTMLImageElementFactory_Invoke,
932 HTMLImageElementFactory_create
935 static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface)
937 return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex);
940 static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid,
941 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
942 IServiceProvider *caller)
944 HTMLImageElementFactory *This = impl_from_DispatchEx(dispex);
945 IHTMLImgElement *img;
946 VARIANT empty, *width, *height;
947 HRESULT hres;
948 int argc = params->cArgs - params->cNamedArgs;
950 V_VT(res) = VT_NULL;
952 V_VT(&empty) = VT_EMPTY;
954 width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : &empty;
955 height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : &empty;
957 hres = IHTMLImageElementFactory_create(&This->IHTMLImageElementFactory_iface, *width, *height,
958 &img);
959 if(FAILED(hres))
960 return hres;
962 V_VT(res) = VT_DISPATCH;
963 V_DISPATCH(res) = (IDispatch*)img;
965 return S_OK;
968 static const tid_t HTMLImageElementFactory_iface_tids[] = {
969 IHTMLImageElementFactory_tid,
973 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = {
974 HTMLImageElementFactory_value,
975 NULL,
976 NULL,
977 NULL
980 static dispex_static_data_t HTMLImageElementFactory_dispex = {
981 &HTMLImageElementFactory_dispex_vtbl,
982 IHTMLImageElementFactory_tid,
983 NULL,
984 HTMLImageElementFactory_iface_tids
987 HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElementFactory **ret_val)
989 HTMLImageElementFactory *ret;
991 ret = heap_alloc(sizeof(HTMLImageElementFactory));
992 if(!ret)
993 return E_OUTOFMEMORY;
995 ret->IHTMLImageElementFactory_iface.lpVtbl = &HTMLImageElementFactoryVtbl;
996 ret->ref = 1;
997 ret->window = window;
999 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLImageElementFactory_iface,
1000 &HTMLImageElementFactory_dispex);
1002 *ret_val = ret;
1003 return S_OK;