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 21 typedef struct { 22 HTMLElement element; 23 24 IHTMLImgElement IHTMLImgElement_iface; 25 26 nsIDOMHTMLImageElement *nsimg; 27 } HTMLImgElement; 28 29 static inline HTMLImgElement *impl_from_IHTMLImgElement(IHTMLImgElement *iface) 30 { 31 return CONTAINING_RECORD(iface, HTMLImgElement, IHTMLImgElement_iface); 32 } 33 34 static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv) 35 { 36 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 37 38 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv); 39 } 40 41 static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface) 42 { 43 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 44 45 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface); 46 } 47 48 static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface) 49 { 50 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 51 52 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface); 53 } 54 55 static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo) 56 { 57 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 58 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo); 59 } 60 61 static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo, 62 LCID lcid, ITypeInfo **ppTInfo) 63 { 64 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 65 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, 66 ppTInfo); 67 } 68 69 static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid, 70 LPOLESTR *rgszNames, UINT cNames, 71 LCID lcid, DISPID *rgDispId) 72 { 73 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 74 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, 75 cNames, lcid, rgDispId); 76 } 77 78 static 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 { 82 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 83 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, 84 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); 85 } 86 87 static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v) 88 { 89 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 103 static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p) 104 { 105 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 123 static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v) 124 { 125 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 126 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 127 return E_NOTIMPL; 128 } 129 130 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p) 131 { 132 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 133 FIXME("(%p)->(%p)\n", This, p); 134 return E_NOTIMPL; 135 } 136 137 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p) 138 { 139 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 140 FIXME("(%p)->(%p)\n", This, p); 141 return E_NOTIMPL; 142 } 143 144 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p) 145 { 146 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 147 FIXME("(%p)->(%p)\n", This, p); 148 return E_NOTIMPL; 149 } 150 151 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p) 152 { 153 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 154 FIXME("(%p)->(%p)\n", This, p); 155 return E_NOTIMPL; 156 } 157 158 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p) 159 { 160 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 161 FIXME("(%p)->(%p)\n", This, p); 162 return E_NOTIMPL; 163 } 164 165 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p) 166 { 167 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 168 FIXME("(%p)->(%p)\n", This, p); 169 return E_NOTIMPL; 170 } 171 172 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p) 173 { 174 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 175 FIXME("(%p)->(%p)\n", This, p); 176 return E_NOTIMPL; 177 } 178 179 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p) 180 { 181 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 182 FIXME("(%p)->(%p)\n", This, p); 183 return E_NOTIMPL; 184 } 185 186 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p) 187 { 188 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 189 FIXME("(%p)->(%p)\n", This, p); 190 return E_NOTIMPL; 191 } 192 193 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v) 194 { 195 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 196 FIXME("(%p)->()\n", This); 197 return E_NOTIMPL; 198 } 199 200 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p) 201 { 202 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 203 FIXME("(%p)->(%p)\n", This, p); 204 return E_NOTIMPL; 205 } 206 207 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v) 208 { 209 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 210 FIXME("(%p)->(%d)\n", This, v); 211 return E_NOTIMPL; 212 } 213 214 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p) 215 { 216 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 217 FIXME("(%p)->(%p)\n", This, p); 218 return E_NOTIMPL; 219 } 220 221 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v) 222 { 223 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 224 FIXME("(%p)->(%d)\n", This, v); 225 return E_NOTIMPL; 226 } 227 228 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p) 229 { 230 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 231 FIXME("(%p)->(%p)\n", This, p); 232 return E_NOTIMPL; 233 } 234 235 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v) 236 { 237 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 252 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p) 253 { 254 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 265 static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v) 266 { 267 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 282 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p) 283 { 284 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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) 303 hres = E_OUTOFMEMORY; 304 }else { 305 hres = nsuri_to_url(src, TRUE, p); 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 316 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v) 317 { 318 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 319 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 320 return E_NOTIMPL; 321 } 322 323 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p) 324 { 325 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 326 FIXME("(%p)->(%p)\n", This, p); 327 return E_NOTIMPL; 328 } 329 330 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v) 331 { 332 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 333 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 334 return E_NOTIMPL; 335 } 336 337 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p) 338 { 339 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 340 FIXME("(%p)->(%p)\n", This, p); 341 return E_NOTIMPL; 342 } 343 344 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v) 345 { 346 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 347 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 348 return E_NOTIMPL; 349 } 350 351 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p) 352 { 353 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 354 FIXME("(%p)->(%p)\n", This, p); 355 return E_NOTIMPL; 356 } 357 358 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p) 359 { 360 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 361 FIXME("(%p)->(%p)\n", This, p); 362 return E_NOTIMPL; 363 } 364 365 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p) 366 { 367 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 368 cpp_bool complete; 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 383 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v) 384 { 385 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 386 FIXME("(%p)->()\n", This); 387 return E_NOTIMPL; 388 } 389 390 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p) 391 { 392 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 393 FIXME("(%p)->(%p)\n", This, p); 394 return E_NOTIMPL; 395 } 396 397 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v) 398 { 399 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 400 nsAString str; 401 nsresult nsres; 402 403 TRACE("(%p)->(%s)\n", This, debugstr_w(v)); 404 405 nsAString_InitDepend(&str, v); 406 407 nsres = nsIDOMHTMLImageElement_SetAlign(This->nsimg, &str); 408 nsAString_Finish(&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 417 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p) 418 { 419 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 420 nsAString str; 421 nsresult nsres; 422 423 TRACE("(%p)->(%p)\n", This, p); 424 425 nsAString_Init(&str, NULL); 426 nsres = nsIDOMHTMLImageElement_GetAlign(This->nsimg, &str); 427 428 return return_nsstr(nsres, &str, p); 429 } 430 431 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v) 432 { 433 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 434 435 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v)); 436 437 return set_node_event(&This->element.node, EVENTID_LOAD, &v); 438 } 439 440 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p) 441 { 442 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 443 444 TRACE("(%p)->(%p)\n", This, p); 445 446 return get_node_event(&This->element.node, EVENTID_LOAD, p); 447 } 448 449 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v) 450 { 451 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 452 453 TRACE("(%p)->()\n", This); 454 455 return set_node_event(&This->element.node, EVENTID_ERROR, &v); 456 } 457 458 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p) 459 { 460 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 461 462 TRACE("(%p)->(%p)\n", This, p); 463 464 return get_node_event(&This->element.node, EVENTID_ERROR, p); 465 } 466 467 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v) 468 { 469 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 470 471 TRACE("(%p)->()\n", This); 472 473 return set_node_event(&This->element.node, EVENTID_ABORT, &v); 474 } 475 476 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p) 477 { 478 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 479 480 TRACE("(%p)->(%p)\n", This, p); 481 482 return get_node_event(&This->element.node, EVENTID_ABORT, p); 483 } 484 485 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v) 486 { 487 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 488 FIXME("(%p)->(%s)\n", This, debugstr_w(v)); 489 return E_NOTIMPL; 490 } 491 492 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p) 493 { 494 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 495 nsAString name; 496 nsresult nsres; 497 498 TRACE("(%p)->(%p)\n", This, p); 499 500 nsAString_Init(&name, NULL); 501 nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &name); 502 return return_nsstr(nsres, &name, p); 503 } 504 505 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v) 506 { 507 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 521 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p) 522 { 523 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 524 UINT32 width; 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 539 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v) 540 { 541 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 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 555 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p) 556 { 557 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 558 UINT32 height; 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 573 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v) 574 { 575 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 576 FIXME("(%p)->()\n", This); 577 return E_NOTIMPL; 578 } 579 580 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p) 581 { 582 HTMLImgElement *This = impl_from_IHTMLImgElement(iface); 583 FIXME("(%p)->(%p)\n", This, p); 584 return E_NOTIMPL; 585 } 586 587 static const IHTMLImgElementVtbl HTMLImgElementVtbl = { 588 HTMLImgElement_QueryInterface, 589 HTMLImgElement_AddRef, 590 HTMLImgElement_Release, 591 HTMLImgElement_GetTypeInfoCount, 592 HTMLImgElement_GetTypeInfo, 593 HTMLImgElement_GetIDsOfNames, 594 HTMLImgElement_Invoke, 595 HTMLImgElement_put_isMap, 596 HTMLImgElement_get_isMap, 597 HTMLImgElement_put_useMap, 598 HTMLImgElement_get_useMap, 599 HTMLImgElement_get_mimeType, 600 HTMLImgElement_get_fileSize, 601 HTMLImgElement_get_fileCreatedDate, 602 HTMLImgElement_get_fileModifiedDate, 603 HTMLImgElement_get_fileUpdatedDate, 604 HTMLImgElement_get_protocol, 605 HTMLImgElement_get_href, 606 HTMLImgElement_get_nameProp, 607 HTMLImgElement_put_border, 608 HTMLImgElement_get_border, 609 HTMLImgElement_put_vspace, 610 HTMLImgElement_get_vspace, 611 HTMLImgElement_put_hspace, 612 HTMLImgElement_get_hspace, 613 HTMLImgElement_put_alt, 614 HTMLImgElement_get_alt, 615 HTMLImgElement_put_src, 616 HTMLImgElement_get_src, 617 HTMLImgElement_put_lowsrc, 618 HTMLImgElement_get_lowsrc, 619 HTMLImgElement_put_vrml, 620 HTMLImgElement_get_vrml, 621 HTMLImgElement_put_dynsrc, 622 HTMLImgElement_get_dynsrc, 623 HTMLImgElement_get_readyState, 624 HTMLImgElement_get_complete, 625 HTMLImgElement_put_loop, 626 HTMLImgElement_get_loop, 627 HTMLImgElement_put_align, 628 HTMLImgElement_get_align, 629 HTMLImgElement_put_onload, 630 HTMLImgElement_get_onload, 631 HTMLImgElement_put_onerror, 632 HTMLImgElement_get_onerror, 633 HTMLImgElement_put_onabort, 634 HTMLImgElement_get_onabort, 635 HTMLImgElement_put_name, 636 HTMLImgElement_get_name, 637 HTMLImgElement_put_width, 638 HTMLImgElement_get_width, 639 HTMLImgElement_put_height, 640 HTMLImgElement_get_height, 641 HTMLImgElement_put_start, 642 HTMLImgElement_get_start 643 }; 644 645 static inline HTMLImgElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface) 646 { 647 return CONTAINING_RECORD(iface, HTMLImgElement, element.node); 648 } 649 650 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) 651 { 652 HTMLImgElement *This = impl_from_HTMLDOMNode(iface); 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 667 static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p) 668 { 669 HTMLImgElement *This = impl_from_HTMLDOMNode(iface); 670 671 return IHTMLImgElement_get_readyState(&This->IHTMLImgElement_iface, p); 672 } 673 674 static void HTMLImgElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb) 675 { 676 HTMLImgElement *This = impl_from_HTMLDOMNode(iface); 677 678 if(This->nsimg) 679 note_cc_edge((nsISupports*)This->nsimg, "This->nsimg", cb); 680 } 681 682 static void HTMLImgElement_unlink(HTMLDOMNode *iface) 683 { 684 HTMLImgElement *This = impl_from_HTMLDOMNode(iface); 685 686 if(This->nsimg) { 687 nsIDOMHTMLImageElement *nsimg = This->nsimg; 688 689 This->nsimg = NULL; 690 nsIDOMHTMLImageElement_Release(nsimg); 691 } 692 } 693 694 static const NodeImplVtbl HTMLImgElementImplVtbl = { 695 HTMLImgElement_QI, 696 HTMLElement_destructor, 697 HTMLElement_cpc, 698 HTMLElement_clone, 699 HTMLElement_handle_event, 700 HTMLElement_get_attr_col, 701 NULL, 702 NULL, 703 NULL, 704 NULL, 705 NULL, 706 HTMLImgElement_get_readystate, 707 NULL, 708 NULL, 709 NULL, 710 HTMLImgElement_traverse, 711 HTMLImgElement_unlink 712 }; 713 714 static const tid_t HTMLImgElement_iface_tids[] = { 715 HTMLELEMENT_TIDS, 716 IHTMLImgElement_tid, 717 0 718 }; 719 static dispex_static_data_t HTMLImgElement_dispex = { 720 NULL, 721 DispHTMLImg_tid, 722 NULL, 723 HTMLImgElement_iface_tids 724 }; 725 726 HRESULT HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem) 727 { 728 HTMLImgElement *ret; 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 747 static inline HTMLImageElementFactory *impl_from_IHTMLImageElementFactory(IHTMLImageElementFactory *iface) 748 { 749 return CONTAINING_RECORD(iface, HTMLImageElementFactory, IHTMLImageElementFactory_iface); 750 } 751 752 static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface, 753 REFIID riid, void **ppv) 754 { 755 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 756 757 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv); 758 759 if(IsEqualGUID(&IID_IUnknown, riid)) { 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 775 static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface) 776 { 777 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 778 LONG ref = InterlockedIncrement(&This->ref); 779 780 TRACE("(%p) ref=%d\n", This, ref); 781 782 return ref; 783 } 784 785 static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface) 786 { 787 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 788 LONG ref = InterlockedDecrement(&This->ref); 789 790 TRACE("(%p) ref=%d\n", This, ref); 791 792 if(!ref) 793 heap_free(This); 794 795 return ref; 796 } 797 798 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface, 799 UINT *pctinfo) 800 { 801 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 802 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo); 803 } 804 805 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface, 806 UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) 807 { 808 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 809 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo); 810 } 811 812 static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface, 813 REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, 814 DISPID *rgDispId) 815 { 816 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 817 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames, lcid, rgDispId); 818 } 819 820 static 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 { 825 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 826 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags, 827 pDispParams, pVarResult, pExcepInfo, puArgErr); 828 } 829 830 static 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; 839 HRESULT hres; 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 854 static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface, 855 VARIANT width, VARIANT height, IHTMLImgElement **img_elem) 856 { 857 HTMLImageElementFactory *This = impl_from_IHTMLImageElementFactory(iface); 858 HTMLDocumentNode *doc; 859 IHTMLImgElement *img; 860 HTMLElement *elem; 861 nsIDOMHTMLElement *nselem; 862 LONG l; 863 HRESULT hres; 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 909 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = { 910 HTMLImageElementFactory_QueryInterface, 911 HTMLImageElementFactory_AddRef, 912 HTMLImageElementFactory_Release, 913 HTMLImageElementFactory_GetTypeInfoCount, 914 HTMLImageElementFactory_GetTypeInfo, 915 HTMLImageElementFactory_GetIDsOfNames, 916 HTMLImageElementFactory_Invoke, 917 HTMLImageElementFactory_create 918 }; 919 920 static inline HTMLImageElementFactory *impl_from_DispatchEx(DispatchEx *iface) 921 { 922 return CONTAINING_RECORD(iface, HTMLImageElementFactory, dispex); 923 } 924 925 static HRESULT HTMLImageElementFactory_value(DispatchEx *dispex, LCID lcid, 926 WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei, 927 IServiceProvider *caller) 928 { 929 HTMLImageElementFactory *This = impl_from_DispatchEx(dispex); 930 IHTMLImgElement *img; 931 VARIANT empty, *width, *height; 932 HRESULT hres; 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 947 V_VT(res) = VT_DISPATCH; 948 V_DISPATCH(res) = (IDispatch*)img; 949 950 return S_OK; 951 } 952 953 static const tid_t HTMLImageElementFactory_iface_tids[] = { 954 IHTMLImageElementFactory_tid, 955 0 956 }; 957 958 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = { 959 HTMLImageElementFactory_value, 960 NULL, 961 NULL, 962 NULL 963 }; 964 965 static dispex_static_data_t HTMLImageElementFactory_dispex = { 966 &HTMLImageElementFactory_dispex_vtbl, 967 IHTMLImageElementFactory_tid, 968 NULL, 969 HTMLImageElementFactory_iface_tids 970 }; 971 972 HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow *window, HTMLImageElementFactory **ret_val) 973 { 974 HTMLImageElementFactory *ret; 975 976 ret = heap_alloc(sizeof(HTMLImageElementFactory)); 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, 985 &HTMLImageElementFactory_dispex); 986 987 *ret_val = ret; 988 return S_OK; 989 } 990