ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

htmlimg.c
Go to the documentation of this file.
00001 /*
00002  * Copyright 2008 Jacek Caban for CodeWeavers
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public
00015  * License along with this library; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00017  */
00018 
00019 #include <stdarg.h>
00020 
00021 #define COBJMACROS
00022 
00023 #include "windef.h"
00024 #include "winbase.h"
00025 #include "winuser.h"
00026 #include "ole2.h"
00027 
00028 #include "wine/debug.h"
00029 
00030 #include "mshtml_private.h"
00031 #include "htmlevent.h"
00032 
00033 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
00034 
00035 typedef struct {
00036     HTMLElement element;
00037 
00038     const IHTMLImgElementVtbl *lpHTMLImgElementVtbl;
00039 
00040     nsIDOMHTMLImageElement *nsimg;
00041 } HTMLImgElement;
00042 
00043 #define HTMLIMG(x)  ((IHTMLImgElement*)  &(x)->lpHTMLImgElementVtbl)
00044 
00045 #define HTMLIMG_THIS(iface) DEFINE_THIS(HTMLImgElement, HTMLImgElement, iface)
00046 
00047 static HRESULT WINAPI HTMLImgElement_QueryInterface(IHTMLImgElement *iface, REFIID riid, void **ppv)
00048 {
00049     HTMLImgElement *This = HTMLIMG_THIS(iface);
00050 
00051     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
00052 }
00053 
00054 static ULONG WINAPI HTMLImgElement_AddRef(IHTMLImgElement *iface)
00055 {
00056     HTMLImgElement *This = HTMLIMG_THIS(iface);
00057 
00058     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
00059 }
00060 
00061 static ULONG WINAPI HTMLImgElement_Release(IHTMLImgElement *iface)
00062 {
00063     HTMLImgElement *This = HTMLIMG_THIS(iface);
00064 
00065     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
00066 }
00067 
00068 static HRESULT WINAPI HTMLImgElement_GetTypeInfoCount(IHTMLImgElement *iface, UINT *pctinfo)
00069 {
00070     HTMLImgElement *This = HTMLIMG_THIS(iface);
00071     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
00072 }
00073 
00074 static HRESULT WINAPI HTMLImgElement_GetTypeInfo(IHTMLImgElement *iface, UINT iTInfo,
00075                                               LCID lcid, ITypeInfo **ppTInfo)
00076 {
00077     HTMLImgElement *This = HTMLIMG_THIS(iface);
00078     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
00079 }
00080 
00081 static HRESULT WINAPI HTMLImgElement_GetIDsOfNames(IHTMLImgElement *iface, REFIID riid,
00082                                                 LPOLESTR *rgszNames, UINT cNames,
00083                                                 LCID lcid, DISPID *rgDispId)
00084 {
00085     HTMLImgElement *This = HTMLIMG_THIS(iface);
00086     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
00087 }
00088 
00089 static HRESULT WINAPI HTMLImgElement_Invoke(IHTMLImgElement *iface, DISPID dispIdMember,
00090                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
00091                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
00092 {
00093     HTMLImgElement *This = HTMLIMG_THIS(iface);
00094     return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
00095             pVarResult, pExcepInfo, puArgErr);
00096 }
00097 
00098 static HRESULT WINAPI HTMLImgElement_put_isMap(IHTMLImgElement *iface, VARIANT_BOOL v)
00099 {
00100     HTMLImgElement *This = HTMLIMG_THIS(iface);
00101     FIXME("(%p)->(%x)\n", This, v);
00102     return E_NOTIMPL;
00103 }
00104 
00105 static HRESULT WINAPI HTMLImgElement_get_isMap(IHTMLImgElement *iface, VARIANT_BOOL *p)
00106 {
00107     HTMLImgElement *This = HTMLIMG_THIS(iface);
00108     FIXME("(%p)->(%p)\n", This, p);
00109     return E_NOTIMPL;
00110 }
00111 
00112 static HRESULT WINAPI HTMLImgElement_put_useMap(IHTMLImgElement *iface, BSTR v)
00113 {
00114     HTMLImgElement *This = HTMLIMG_THIS(iface);
00115     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00116     return E_NOTIMPL;
00117 }
00118 
00119 static HRESULT WINAPI HTMLImgElement_get_useMap(IHTMLImgElement *iface, BSTR *p)
00120 {
00121     HTMLImgElement *This = HTMLIMG_THIS(iface);
00122     FIXME("(%p)->(%p)\n", This, p);
00123     return E_NOTIMPL;
00124 }
00125 
00126 static HRESULT WINAPI HTMLImgElement_get_mimeType(IHTMLImgElement *iface, BSTR *p)
00127 {
00128     HTMLImgElement *This = HTMLIMG_THIS(iface);
00129     FIXME("(%p)->(%p)\n", This, p);
00130     return E_NOTIMPL;
00131 }
00132 
00133 static HRESULT WINAPI HTMLImgElement_get_fileSize(IHTMLImgElement *iface, BSTR *p)
00134 {
00135     HTMLImgElement *This = HTMLIMG_THIS(iface);
00136     FIXME("(%p)->(%p)\n", This, p);
00137     return E_NOTIMPL;
00138 }
00139 
00140 static HRESULT WINAPI HTMLImgElement_get_fileCreatedDate(IHTMLImgElement *iface, BSTR *p)
00141 {
00142     HTMLImgElement *This = HTMLIMG_THIS(iface);
00143     FIXME("(%p)->(%p)\n", This, p);
00144     return E_NOTIMPL;
00145 }
00146 
00147 static HRESULT WINAPI HTMLImgElement_get_fileModifiedDate(IHTMLImgElement *iface, BSTR *p)
00148 {
00149     HTMLImgElement *This = HTMLIMG_THIS(iface);
00150     FIXME("(%p)->(%p)\n", This, p);
00151     return E_NOTIMPL;
00152 }
00153 
00154 static HRESULT WINAPI HTMLImgElement_get_fileUpdatedDate(IHTMLImgElement *iface, BSTR *p)
00155 {
00156     HTMLImgElement *This = HTMLIMG_THIS(iface);
00157     FIXME("(%p)->(%p)\n", This, p);
00158     return E_NOTIMPL;
00159 }
00160 
00161 static HRESULT WINAPI HTMLImgElement_get_protocol(IHTMLImgElement *iface, BSTR *p)
00162 {
00163     HTMLImgElement *This = HTMLIMG_THIS(iface);
00164     FIXME("(%p)->(%p)\n", This, p);
00165     return E_NOTIMPL;
00166 }
00167 
00168 static HRESULT WINAPI HTMLImgElement_get_href(IHTMLImgElement *iface, BSTR *p)
00169 {
00170     HTMLImgElement *This = HTMLIMG_THIS(iface);
00171     FIXME("(%p)->(%p)\n", This, p);
00172     return E_NOTIMPL;
00173 }
00174 
00175 static HRESULT WINAPI HTMLImgElement_get_nameProp(IHTMLImgElement *iface, BSTR *p)
00176 {
00177     HTMLImgElement *This = HTMLIMG_THIS(iface);
00178     FIXME("(%p)->(%p)\n", This, p);
00179     return E_NOTIMPL;
00180 }
00181 
00182 static HRESULT WINAPI HTMLImgElement_put_border(IHTMLImgElement *iface, VARIANT v)
00183 {
00184     HTMLImgElement *This = HTMLIMG_THIS(iface);
00185     FIXME("(%p)->()\n", This);
00186     return E_NOTIMPL;
00187 }
00188 
00189 static HRESULT WINAPI HTMLImgElement_get_border(IHTMLImgElement *iface, VARIANT *p)
00190 {
00191     HTMLImgElement *This = HTMLIMG_THIS(iface);
00192     FIXME("(%p)->(%p)\n", This, p);
00193     return E_NOTIMPL;
00194 }
00195 
00196 static HRESULT WINAPI HTMLImgElement_put_vspace(IHTMLImgElement *iface, LONG v)
00197 {
00198     HTMLImgElement *This = HTMLIMG_THIS(iface);
00199     FIXME("(%p)->(%d)\n", This, v);
00200     return E_NOTIMPL;
00201 }
00202 
00203 static HRESULT WINAPI HTMLImgElement_get_vspace(IHTMLImgElement *iface, LONG *p)
00204 {
00205     HTMLImgElement *This = HTMLIMG_THIS(iface);
00206     FIXME("(%p)->(%p)\n", This, p);
00207     return E_NOTIMPL;
00208 }
00209 
00210 static HRESULT WINAPI HTMLImgElement_put_hspace(IHTMLImgElement *iface, LONG v)
00211 {
00212     HTMLImgElement *This = HTMLIMG_THIS(iface);
00213     FIXME("(%p)->(%d)\n", This, v);
00214     return E_NOTIMPL;
00215 }
00216 
00217 static HRESULT WINAPI HTMLImgElement_get_hspace(IHTMLImgElement *iface, LONG *p)
00218 {
00219     HTMLImgElement *This = HTMLIMG_THIS(iface);
00220     FIXME("(%p)->(%p)\n", This, p);
00221     return E_NOTIMPL;
00222 }
00223 
00224 static HRESULT WINAPI HTMLImgElement_put_alt(IHTMLImgElement *iface, BSTR v)
00225 {
00226     HTMLImgElement *This = HTMLIMG_THIS(iface);
00227     nsAString alt_str;
00228     nsresult nsres;
00229 
00230     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
00231 
00232     nsAString_InitDepend(&alt_str, v);
00233     nsres = nsIDOMHTMLImageElement_SetAlt(This->nsimg, &alt_str);
00234     nsAString_Finish(&alt_str);
00235     if(NS_FAILED(nsres))
00236         ERR("SetAlt failed: %08x\n", nsres);
00237 
00238     return S_OK;
00239 }
00240 
00241 static HRESULT WINAPI HTMLImgElement_get_alt(IHTMLImgElement *iface, BSTR *p)
00242 {
00243     HTMLImgElement *This = HTMLIMG_THIS(iface);
00244     nsAString alt_str;
00245     nsresult nsres;
00246 
00247     TRACE("(%p)->(%p)\n", This, p);
00248 
00249     nsAString_Init(&alt_str, NULL);
00250     nsres = nsIDOMHTMLImageElement_GetAlt(This->nsimg, &alt_str);
00251     if(NS_SUCCEEDED(nsres)) {
00252         const PRUnichar *alt;
00253 
00254         nsAString_GetData(&alt_str, &alt);
00255         *p = *alt ? SysAllocString(alt) : NULL;
00256     }else {
00257         ERR("GetAlt failed: %08x\n", nsres);
00258     }
00259     nsAString_Finish(&alt_str);
00260 
00261     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
00262 }
00263 
00264 static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
00265 {
00266     HTMLImgElement *This = HTMLIMG_THIS(iface);
00267     nsAString src_str;
00268     nsresult nsres;
00269 
00270     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
00271 
00272     nsAString_InitDepend(&src_str, v);
00273     nsres = nsIDOMHTMLImageElement_SetSrc(This->nsimg, &src_str);
00274     nsAString_Finish(&src_str);
00275     if(NS_FAILED(nsres))
00276         ERR("SetSrc failed: %08x\n", nsres);
00277 
00278     return NS_OK;
00279 }
00280 
00281 static HRESULT WINAPI HTMLImgElement_get_src(IHTMLImgElement *iface, BSTR *p)
00282 {
00283     HTMLImgElement *This = HTMLIMG_THIS(iface);
00284     const PRUnichar *src;
00285     nsAString src_str;
00286     nsresult nsres;
00287     HRESULT hres;
00288 
00289     TRACE("(%p)->(%p)\n", This, p);
00290 
00291     nsAString_Init(&src_str, NULL);
00292     nsres = nsIDOMHTMLImageElement_GetSrc(This->nsimg, &src_str);
00293     if(NS_FAILED(nsres)) {
00294         ERR("GetSrc failed: %08x\n", nsres);
00295         return E_FAIL;
00296     }
00297 
00298     nsAString_GetData(&src_str, &src);
00299     hres = nsuri_to_url(src, TRUE, p);
00300     nsAString_Finish(&src_str);
00301 
00302     return hres;
00303 }
00304 
00305 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
00306 {
00307     HTMLImgElement *This = HTMLIMG_THIS(iface);
00308     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00309     return E_NOTIMPL;
00310 }
00311 
00312 static HRESULT WINAPI HTMLImgElement_get_lowsrc(IHTMLImgElement *iface, BSTR *p)
00313 {
00314     HTMLImgElement *This = HTMLIMG_THIS(iface);
00315     FIXME("(%p)->(%p)\n", This, p);
00316     return E_NOTIMPL;
00317 }
00318 
00319 static HRESULT WINAPI HTMLImgElement_put_vrml(IHTMLImgElement *iface, BSTR v)
00320 {
00321     HTMLImgElement *This = HTMLIMG_THIS(iface);
00322     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00323     return E_NOTIMPL;
00324 }
00325 
00326 static HRESULT WINAPI HTMLImgElement_get_vrml(IHTMLImgElement *iface, BSTR *p)
00327 {
00328     HTMLImgElement *This = HTMLIMG_THIS(iface);
00329     FIXME("(%p)->(%p)\n", This, p);
00330     return E_NOTIMPL;
00331 }
00332 
00333 static HRESULT WINAPI HTMLImgElement_put_dynsrc(IHTMLImgElement *iface, BSTR v)
00334 {
00335     HTMLImgElement *This = HTMLIMG_THIS(iface);
00336     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00337     return E_NOTIMPL;
00338 }
00339 
00340 static HRESULT WINAPI HTMLImgElement_get_dynsrc(IHTMLImgElement *iface, BSTR *p)
00341 {
00342     HTMLImgElement *This = HTMLIMG_THIS(iface);
00343     FIXME("(%p)->(%p)\n", This, p);
00344     return E_NOTIMPL;
00345 }
00346 
00347 static HRESULT WINAPI HTMLImgElement_get_readyState(IHTMLImgElement *iface, BSTR *p)
00348 {
00349     HTMLImgElement *This = HTMLIMG_THIS(iface);
00350     FIXME("(%p)->(%p)\n", This, p);
00351     return E_NOTIMPL;
00352 }
00353 
00354 static HRESULT WINAPI HTMLImgElement_get_complete(IHTMLImgElement *iface, VARIANT_BOOL *p)
00355 {
00356     HTMLImgElement *This = HTMLIMG_THIS(iface);
00357     FIXME("(%p)->(%p)\n", This, p);
00358     return E_NOTIMPL;
00359 }
00360 
00361 static HRESULT WINAPI HTMLImgElement_put_loop(IHTMLImgElement *iface, VARIANT v)
00362 {
00363     HTMLImgElement *This = HTMLIMG_THIS(iface);
00364     FIXME("(%p)->()\n", This);
00365     return E_NOTIMPL;
00366 }
00367 
00368 static HRESULT WINAPI HTMLImgElement_get_loop(IHTMLImgElement *iface, VARIANT *p)
00369 {
00370     HTMLImgElement *This = HTMLIMG_THIS(iface);
00371     FIXME("(%p)->(%p)\n", This, p);
00372     return E_NOTIMPL;
00373 }
00374 
00375 static HRESULT WINAPI HTMLImgElement_put_align(IHTMLImgElement *iface, BSTR v)
00376 {
00377     HTMLImgElement *This = HTMLIMG_THIS(iface);
00378     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00379     return E_NOTIMPL;
00380 }
00381 
00382 static HRESULT WINAPI HTMLImgElement_get_align(IHTMLImgElement *iface, BSTR *p)
00383 {
00384     HTMLImgElement *This = HTMLIMG_THIS(iface);
00385     FIXME("(%p)->(%p)\n", This, p);
00386     return E_NOTIMPL;
00387 }
00388 
00389 static HRESULT WINAPI HTMLImgElement_put_onload(IHTMLImgElement *iface, VARIANT v)
00390 {
00391     HTMLImgElement *This = HTMLIMG_THIS(iface);
00392 
00393     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
00394 
00395     return set_node_event(&This->element.node, EVENTID_LOAD, &v);
00396 }
00397 
00398 static HRESULT WINAPI HTMLImgElement_get_onload(IHTMLImgElement *iface, VARIANT *p)
00399 {
00400     HTMLImgElement *This = HTMLIMG_THIS(iface);
00401 
00402     TRACE("(%p)->(%p)\n", This, p);
00403 
00404     return get_node_event(&This->element.node, EVENTID_LOAD, p);
00405 }
00406 
00407 static HRESULT WINAPI HTMLImgElement_put_onerror(IHTMLImgElement *iface, VARIANT v)
00408 {
00409     HTMLImgElement *This = HTMLIMG_THIS(iface);
00410     FIXME("(%p)->()\n", This);
00411     return E_NOTIMPL;
00412 }
00413 
00414 static HRESULT WINAPI HTMLImgElement_get_onerror(IHTMLImgElement *iface, VARIANT *p)
00415 {
00416     HTMLImgElement *This = HTMLIMG_THIS(iface);
00417     FIXME("(%p)->(%p)\n", This, p);
00418     return E_NOTIMPL;
00419 }
00420 
00421 static HRESULT WINAPI HTMLImgElement_put_onabort(IHTMLImgElement *iface, VARIANT v)
00422 {
00423     HTMLImgElement *This = HTMLIMG_THIS(iface);
00424     FIXME("(%p)->()\n", This);
00425     return E_NOTIMPL;
00426 }
00427 
00428 static HRESULT WINAPI HTMLImgElement_get_onabort(IHTMLImgElement *iface, VARIANT *p)
00429 {
00430     HTMLImgElement *This = HTMLIMG_THIS(iface);
00431     FIXME("(%p)->(%p)\n", This, p);
00432     return E_NOTIMPL;
00433 }
00434 
00435 static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
00436 {
00437     HTMLImgElement *This = HTMLIMG_THIS(iface);
00438     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00439     return E_NOTIMPL;
00440 }
00441 
00442 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
00443 {
00444     HTMLImgElement *This = HTMLIMG_THIS(iface);
00445     nsAString strName;
00446     nsresult nsres;
00447 
00448     TRACE("(%p)->(%p)\n", This, p);
00449 
00450     nsAString_Init(&strName, NULL);
00451     nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &strName);
00452     if(NS_SUCCEEDED(nsres)) {
00453         const PRUnichar *str;
00454 
00455         nsAString_GetData(&strName, &str);
00456         *p = *str ? SysAllocString(str) : NULL;
00457     }else {
00458         ERR("GetName failed: %08x\n", nsres);
00459     }
00460     nsAString_Finish(&strName);
00461 
00462     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
00463 }
00464 
00465 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
00466 {
00467     HTMLImgElement *This = HTMLIMG_THIS(iface);
00468     nsresult nsres;
00469 
00470     TRACE("(%p)->(%d)\n", This, v);
00471 
00472     nsres = nsIDOMHTMLImageElement_SetWidth(This->nsimg, v);
00473     if(NS_FAILED(nsres)) {
00474         ERR("SetWidth failed: %08x\n", nsres);
00475         return E_FAIL;
00476     }
00477 
00478     return S_OK;
00479 }
00480 
00481 static HRESULT WINAPI HTMLImgElement_get_width(IHTMLImgElement *iface, LONG *p)
00482 {
00483     HTMLImgElement *This = HTMLIMG_THIS(iface);
00484     PRInt32 width;
00485     nsresult nsres;
00486 
00487     TRACE("(%p)->(%p)\n", This, p);
00488 
00489     nsres = nsIDOMHTMLImageElement_GetWidth(This->nsimg, &width);
00490     if(NS_FAILED(nsres)) {
00491         ERR("GetWidth failed: %08x\n", nsres);
00492         return E_FAIL;
00493     }
00494 
00495     *p = width;
00496     return S_OK;
00497 }
00498 
00499 static HRESULT WINAPI HTMLImgElement_put_height(IHTMLImgElement *iface, LONG v)
00500 {
00501     HTMLImgElement *This = HTMLIMG_THIS(iface);
00502     nsresult nsres;
00503 
00504     TRACE("(%p)->(%d)\n", This, v);
00505 
00506     nsres = nsIDOMHTMLImageElement_SetHeight(This->nsimg, v);
00507     if(NS_FAILED(nsres)) {
00508         ERR("SetHeight failed: %08x\n", nsres);
00509         return E_FAIL;
00510     }
00511 
00512     return S_OK;
00513 }
00514 
00515 static HRESULT WINAPI HTMLImgElement_get_height(IHTMLImgElement *iface, LONG *p)
00516 {
00517     HTMLImgElement *This = HTMLIMG_THIS(iface);
00518     PRInt32 height;
00519     nsresult nsres;
00520 
00521     TRACE("(%p)->(%p)\n", This, p);
00522 
00523     nsres = nsIDOMHTMLImageElement_GetHeight(This->nsimg, &height);
00524     if(NS_FAILED(nsres)) {
00525         ERR("GetHeight failed: %08x\n", nsres);
00526         return E_FAIL;
00527     }
00528 
00529     *p = height;
00530     return S_OK;
00531 }
00532 
00533 static HRESULT WINAPI HTMLImgElement_put_start(IHTMLImgElement *iface, BSTR v)
00534 {
00535     HTMLImgElement *This = HTMLIMG_THIS(iface);
00536     FIXME("(%p)->()\n", This);
00537     return E_NOTIMPL;
00538 }
00539 
00540 static HRESULT WINAPI HTMLImgElement_get_start(IHTMLImgElement *iface, BSTR *p)
00541 {
00542     HTMLImgElement *This = HTMLIMG_THIS(iface);
00543     FIXME("(%p)->(%p)\n", This, p);
00544     return E_NOTIMPL;
00545 }
00546 
00547 #undef HTMLIMG_THIS
00548 
00549 static const IHTMLImgElementVtbl HTMLImgElementVtbl = {
00550     HTMLImgElement_QueryInterface,
00551     HTMLImgElement_AddRef,
00552     HTMLImgElement_Release,
00553     HTMLImgElement_GetTypeInfoCount,
00554     HTMLImgElement_GetTypeInfo,
00555     HTMLImgElement_GetIDsOfNames,
00556     HTMLImgElement_Invoke,
00557     HTMLImgElement_put_isMap,
00558     HTMLImgElement_get_isMap,
00559     HTMLImgElement_put_useMap,
00560     HTMLImgElement_get_useMap,
00561     HTMLImgElement_get_mimeType,
00562     HTMLImgElement_get_fileSize,
00563     HTMLImgElement_get_fileCreatedDate,
00564     HTMLImgElement_get_fileModifiedDate,
00565     HTMLImgElement_get_fileUpdatedDate,
00566     HTMLImgElement_get_protocol,
00567     HTMLImgElement_get_href,
00568     HTMLImgElement_get_nameProp,
00569     HTMLImgElement_put_border,
00570     HTMLImgElement_get_border,
00571     HTMLImgElement_put_vspace,
00572     HTMLImgElement_get_vspace,
00573     HTMLImgElement_put_hspace,
00574     HTMLImgElement_get_hspace,
00575     HTMLImgElement_put_alt,
00576     HTMLImgElement_get_alt,
00577     HTMLImgElement_put_src,
00578     HTMLImgElement_get_src,
00579     HTMLImgElement_put_lowsrc,
00580     HTMLImgElement_get_lowsrc,
00581     HTMLImgElement_put_vrml,
00582     HTMLImgElement_get_vrml,
00583     HTMLImgElement_put_dynsrc,
00584     HTMLImgElement_get_dynsrc,
00585     HTMLImgElement_get_readyState,
00586     HTMLImgElement_get_complete,
00587     HTMLImgElement_put_loop,
00588     HTMLImgElement_get_loop,
00589     HTMLImgElement_put_align,
00590     HTMLImgElement_get_align,
00591     HTMLImgElement_put_onload,
00592     HTMLImgElement_get_onload,
00593     HTMLImgElement_put_onerror,
00594     HTMLImgElement_get_onerror,
00595     HTMLImgElement_put_onabort,
00596     HTMLImgElement_get_onabort,
00597     HTMLImgElement_put_name,
00598     HTMLImgElement_get_name,
00599     HTMLImgElement_put_width,
00600     HTMLImgElement_get_width,
00601     HTMLImgElement_put_height,
00602     HTMLImgElement_get_height,
00603     HTMLImgElement_put_start,
00604     HTMLImgElement_get_start
00605 };
00606 
00607 #define HTMLIMG_NODE_THIS(iface) DEFINE_THIS2(HTMLImgElement, element.node, iface)
00608 
00609 static HRESULT HTMLImgElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
00610 {
00611     HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
00612 
00613     *ppv = NULL;
00614 
00615     if(IsEqualGUID(&IID_IHTMLImgElement, riid)) {
00616         TRACE("(%p)->(IID_IHTMLImgElement %p)\n", This, ppv);
00617         *ppv = HTMLIMG(This);
00618     }else {
00619         return HTMLElement_QI(&This->element.node, riid, ppv);
00620     }
00621 
00622     IUnknown_AddRef((IUnknown*)*ppv);
00623     return S_OK;
00624 }
00625 
00626 static void HTMLImgElement_destructor(HTMLDOMNode *iface)
00627 {
00628     HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
00629 
00630     if(This->nsimg)
00631         nsIDOMHTMLImageElement_Release(This->nsimg);
00632 
00633     HTMLElement_destructor(&This->element.node);
00634 }
00635 
00636 static HRESULT HTMLImgElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
00637 {
00638     HTMLImgElement *This = HTMLIMG_NODE_THIS(iface);
00639 
00640     return IHTMLImgElement_get_readyState(HTMLIMG(This), p);
00641 }
00642 
00643 #undef HTMLIMG_NODE_THIS
00644 
00645 static const NodeImplVtbl HTMLImgElementImplVtbl = {
00646     HTMLImgElement_QI,
00647     HTMLImgElement_destructor,
00648     NULL,
00649     NULL,
00650     NULL,
00651     NULL,
00652     NULL,
00653     HTMLImgElement_get_readystate
00654 };
00655 
00656 static const tid_t HTMLImgElement_iface_tids[] = {
00657     HTMLELEMENT_TIDS,
00658     IHTMLImgElement_tid,
00659     0
00660 };
00661 static dispex_static_data_t HTMLImgElement_dispex = {
00662     NULL,
00663     DispHTMLImg_tid,
00664     NULL,
00665     HTMLImgElement_iface_tids
00666 };
00667 
00668 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
00669 {
00670     HTMLImgElement *ret = heap_alloc_zero(sizeof(HTMLImgElement));
00671     nsresult nsres;
00672 
00673     ret->lpHTMLImgElementVtbl = &HTMLImgElementVtbl;
00674     ret->element.node.vtbl = &HTMLImgElementImplVtbl;
00675 
00676     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLImageElement, (void**)&ret->nsimg);
00677     if(NS_FAILED(nsres))
00678         ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres);
00679 
00680     HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
00681 
00682     return &ret->element;
00683 }
00684 
00685 #define HTMLIMGFACTORY_THIS(iface) DEFINE_THIS(HTMLImageElementFactory, HTMLImageElementFactory, iface)
00686 
00687 static HRESULT WINAPI HTMLImageElementFactory_QueryInterface(IHTMLImageElementFactory *iface,
00688         REFIID riid, void **ppv)
00689 {
00690     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00691 
00692     *ppv = NULL;
00693 
00694     if(IsEqualGUID(&IID_IUnknown, riid)) {
00695         TRACE("(%p)->(IID_Unknown %p)\n", This, ppv);
00696         *ppv = HTMLIMGFACTORY(This);
00697     }else if(IsEqualGUID(&IID_IHTMLImageElementFactory, riid)) {
00698         TRACE("(%p)->(IID_IHTMLImageElementFactory %p)\n", This, ppv);
00699         *ppv = HTMLIMGFACTORY(This);
00700     }else if(dispex_query_interface(&This->dispex, riid, ppv))
00701         return *ppv ? S_OK : E_NOINTERFACE;
00702 
00703     if(*ppv) {
00704         IUnknown_AddRef((IUnknown*)*ppv);
00705         return S_OK;
00706     }
00707 
00708     WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
00709     return E_NOINTERFACE;
00710 }
00711 
00712 static ULONG WINAPI HTMLImageElementFactory_AddRef(IHTMLImageElementFactory *iface)
00713 {
00714     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00715     LONG ref = InterlockedIncrement(&This->ref);
00716 
00717     TRACE("(%p) ref=%d\n", This, ref);
00718 
00719     return ref;
00720 }
00721 
00722 static ULONG WINAPI HTMLImageElementFactory_Release(IHTMLImageElementFactory *iface)
00723 {
00724     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00725     LONG ref = InterlockedDecrement(&This->ref);
00726 
00727     TRACE("(%p) ref=%d\n", This, ref);
00728 
00729     if(!ref)
00730         heap_free(This);
00731 
00732     return ref;
00733 }
00734 
00735 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfoCount(IHTMLImageElementFactory *iface,
00736         UINT *pctinfo)
00737 {
00738     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00739     FIXME("(%p)->(%p)\n", This, pctinfo);
00740     return E_NOTIMPL;
00741 }
00742 
00743 static HRESULT WINAPI HTMLImageElementFactory_GetTypeInfo(IHTMLImageElementFactory *iface,
00744         UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
00745 {
00746     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00747     FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
00748     return E_NOTIMPL;
00749 }
00750 
00751 static HRESULT WINAPI HTMLImageElementFactory_GetIDsOfNames(IHTMLImageElementFactory *iface,
00752         REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
00753         DISPID *rgDispId)
00754 {
00755     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00756     FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames,
00757             cNames, lcid, rgDispId);
00758     return E_NOTIMPL;
00759 }
00760 
00761 static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *iface,
00762         DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
00763         DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
00764         UINT *puArgErr)
00765 {
00766     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00767     FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
00768             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
00769     return E_NOTIMPL;
00770 }
00771 
00772 static LONG var_to_size(const VARIANT *v)
00773 {
00774     switch(V_VT(v)) {
00775     case VT_EMPTY:
00776         return 0;
00777     case VT_I4:
00778         return V_I4(v);
00779     case VT_BSTR: {
00780         LONG ret;
00781         HRESULT hres;
00782 
00783         hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret);
00784         if(FAILED(hres)) {
00785             FIXME("VarI4FromStr failed: %08x\n", hres);
00786             return 0;
00787         }
00788         return ret;
00789     }
00790     default:
00791         FIXME("unsupported size %s\n", debugstr_variant(v));
00792     }
00793     return 0;
00794 }
00795 
00796 static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface,
00797         VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
00798 {
00799     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00800     IHTMLImgElement *img;
00801     HTMLElement *elem;
00802     nsIDOMHTMLElement *nselem;
00803     LONG l;
00804     HRESULT hres;
00805 
00806     static const PRUnichar imgW[] = {'I','M','G',0};
00807 
00808     TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(&width),
00809             debugstr_variant(&height), img_elem);
00810 
00811     if(!This->window || !This->window->doc) {
00812         WARN("NULL doc\n");
00813         return E_UNEXPECTED;
00814     }
00815 
00816     *img_elem = NULL;
00817 
00818     hres = create_nselem(This->window->doc, imgW, &nselem);
00819     if(FAILED(hres))
00820         return hres;
00821 
00822     elem = HTMLElement_Create(This->window->doc, (nsIDOMNode*)nselem, FALSE);
00823     if(!elem) {
00824         ERR("HTMLElement_Create failed\n");
00825         return E_FAIL;
00826     }
00827 
00828     hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)&img);
00829     if(FAILED(hres)) {
00830         ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
00831         return hres;
00832     }
00833 
00834     nsIDOMHTMLElement_Release(nselem);
00835 
00836     l = var_to_size(&width);
00837     if(l)
00838         IHTMLImgElement_put_width(img, l);
00839     l = var_to_size(&height);
00840     if(l)
00841         IHTMLImgElement_put_height(img, l);
00842 
00843     *img_elem = img;
00844     return S_OK;
00845 }
00846 
00847 static HRESULT HTMLImageElementFactory_value(IUnknown *iface, LCID lcid,
00848         WORD flags, DISPPARAMS *params, VARIANT *res, EXCEPINFO *ei,
00849         IServiceProvider *caller)
00850 {
00851     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
00852     IHTMLImgElement *img;
00853     VARIANT empty, *width, *height;
00854     HRESULT hres;
00855     int argc = params->cArgs - params->cNamedArgs;
00856 
00857     V_VT(res) = VT_NULL;
00858 
00859     V_VT(&empty) = VT_EMPTY;
00860 
00861     width = argc >= 1 ? params->rgvarg + (params->cArgs - 1) : &empty;
00862     height = argc >= 2 ? params->rgvarg + (params->cArgs - 2) : &empty;
00863 
00864     hres = IHTMLImageElementFactory_create(HTMLIMGFACTORY(This), *width, *height, &img);
00865     if(FAILED(hres))
00866         return hres;
00867 
00868     V_VT(res) = VT_DISPATCH;
00869     V_DISPATCH(res) = (IDispatch*)img;
00870 
00871     return S_OK;
00872 }
00873 
00874 #undef HTMLIMGFACTORY_THIS
00875 
00876 static const IHTMLImageElementFactoryVtbl HTMLImageElementFactoryVtbl = {
00877     HTMLImageElementFactory_QueryInterface,
00878     HTMLImageElementFactory_AddRef,
00879     HTMLImageElementFactory_Release,
00880     HTMLImageElementFactory_GetTypeInfoCount,
00881     HTMLImageElementFactory_GetTypeInfo,
00882     HTMLImageElementFactory_GetIDsOfNames,
00883     HTMLImageElementFactory_Invoke,
00884     HTMLImageElementFactory_create
00885 };
00886 
00887 static const tid_t HTMLImageElementFactory_iface_tids[] = {
00888     IHTMLImageElementFactory_tid,
00889     0
00890 };
00891 
00892 static const dispex_static_data_vtbl_t HTMLImageElementFactory_dispex_vtbl = {
00893     HTMLImageElementFactory_value,
00894     NULL,
00895     NULL
00896 };
00897 
00898 static dispex_static_data_t HTMLImageElementFactory_dispex = {
00899     &HTMLImageElementFactory_dispex_vtbl,
00900     IHTMLImageElementFactory_tid,
00901     NULL,
00902     HTMLImageElementFactory_iface_tids
00903 };
00904 
00905 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow *window)
00906 {
00907     HTMLImageElementFactory *ret;
00908 
00909     ret = heap_alloc(sizeof(HTMLImageElementFactory));
00910 
00911     ret->lpHTMLImageElementFactoryVtbl = &HTMLImageElementFactoryVtbl;
00912     ret->ref = 1;
00913     ret->window = window;
00914 
00915     init_dispex(&ret->dispex, (IUnknown*)HTMLIMGFACTORY(ret), &HTMLImageElementFactory_dispex);
00916 
00917     return ret;
00918 }

Generated on Thu May 24 2012 04:25:25 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.