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

htmlscript.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 
00032 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
00033 
00034 typedef struct {
00035     HTMLElement element;
00036 
00037     const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl;
00038 
00039     nsIDOMHTMLScriptElement *nsscript;
00040 } HTMLScriptElement;
00041 
00042 #define HTMLSCRIPT(x)  ((IHTMLScriptElement*)  &(x)->lpHTMLScriptElementVtbl)
00043 
00044 #define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface)
00045 
00046 static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface,
00047         REFIID riid, void **ppv)
00048 {
00049     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00050 
00051     return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
00052 }
00053 
00054 static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface)
00055 {
00056     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00057 
00058     return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node));
00059 }
00060 
00061 static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface)
00062 {
00063     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00064 
00065     return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node));
00066 }
00067 
00068 static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo)
00069 {
00070     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00071     return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo);
00072 }
00073 
00074 static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo,
00075                                               LCID lcid, ITypeInfo **ppTInfo)
00076 {
00077     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00078     return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo);
00079 }
00080 
00081 static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid,
00082                                                 LPOLESTR *rgszNames, UINT cNames,
00083                                                 LCID lcid, DISPID *rgDispId)
00084 {
00085     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00086     return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
00087 }
00088 
00089 static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember,
00090                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
00091                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
00092 {
00093     HTMLScriptElement *This = HTMLSCRIPT_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 HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v)
00099 {
00100     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00101     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00102     return E_NOTIMPL;
00103 }
00104 
00105 static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p)
00106 {
00107     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00108     FIXME("(%p)->(%p)\n", This, p);
00109     return E_NOTIMPL;
00110 }
00111 
00112 static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v)
00113 {
00114     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00115     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00116     return E_NOTIMPL;
00117 }
00118 
00119 static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p)
00120 {
00121     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00122     FIXME("(%p)->(%p)\n", This, p);
00123     return E_NOTIMPL;
00124 }
00125 
00126 static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v)
00127 {
00128     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00129     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00130     return E_NOTIMPL;
00131 }
00132 
00133 static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p)
00134 {
00135     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00136     FIXME("(%p)->(%p)\n", This, p);
00137     return E_NOTIMPL;
00138 }
00139 
00140 static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v)
00141 {
00142     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00143     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
00144     return E_NOTIMPL;
00145 }
00146 
00147 static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p)
00148 {
00149     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00150     FIXME("(%p)->(%p)\n", This, p);
00151     return E_NOTIMPL;
00152 }
00153 
00154 static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v)
00155 {
00156     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00157     HRESULT hr = S_OK;
00158     nsresult nsres;
00159 
00160     TRACE("(%p)->(%x)\n", This, v);
00161 
00162     nsres = nsIDOMHTMLScriptElement_SetDefer(This->nsscript, v != VARIANT_FALSE);
00163     if(NS_FAILED(nsres))
00164     {
00165         hr = E_FAIL;
00166     }
00167 
00168     return hr;
00169 }
00170 
00171 static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p)
00172 {
00173     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00174     PRBool defer = FALSE;
00175     nsresult nsres;
00176 
00177     TRACE("(%p)->(%p)\n", This, p);
00178 
00179     if(!p)
00180         return E_INVALIDARG;
00181 
00182     nsres = nsIDOMHTMLScriptElement_GetDefer(This->nsscript, &defer);
00183     if(NS_FAILED(nsres)) {
00184         ERR("GetSrc failed: %08x\n", nsres);
00185     }
00186 
00187     *p = defer ? VARIANT_TRUE : VARIANT_FALSE;
00188 
00189     TRACE("*p = %d\n", *p);
00190     return S_OK;
00191 }
00192 
00193 static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p)
00194 {
00195     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00196     FIXME("(%p)->(%p)\n", This, p);
00197     return E_NOTIMPL;
00198 }
00199 
00200 static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v)
00201 {
00202     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00203     FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
00204     return E_NOTIMPL;
00205 }
00206 
00207 static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p)
00208 {
00209     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00210     FIXME("(%p)->(%p)\n", This, p);
00211     return E_NOTIMPL;
00212 }
00213 
00214 static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v)
00215 {
00216     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00217     nsAString nstype_str;
00218     nsresult nsres;
00219 
00220     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
00221 
00222     nsAString_Init(&nstype_str, v);
00223     nsres = nsIDOMHTMLScriptElement_SetType(This->nsscript, &nstype_str);
00224     if (NS_FAILED(nsres))
00225         ERR("SetType failed: %08x\n", nsres);
00226     nsAString_Finish (&nstype_str);
00227 
00228     return S_OK;
00229 }
00230 
00231 static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p)
00232 {
00233     HTMLScriptElement *This = HTMLSCRIPT_THIS(iface);
00234     const PRUnichar *nstype;
00235     nsAString nstype_str;
00236     nsresult nsres;
00237 
00238     TRACE("(%p)->(%p)\n", This, p);
00239 
00240     nsAString_Init(&nstype_str, NULL);
00241     nsres = nsIDOMHTMLScriptElement_GetType(This->nsscript, &nstype_str);
00242     if(NS_FAILED(nsres))
00243         ERR("GetType failed: %08x\n", nsres);
00244 
00245     nsAString_GetData(&nstype_str, &nstype);
00246     *p = *nstype ? SysAllocString(nstype) : NULL;
00247     nsAString_Finish(&nstype_str);
00248 
00249     return S_OK;
00250 }
00251 
00252 static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = {
00253     HTMLScriptElement_QueryInterface,
00254     HTMLScriptElement_AddRef,
00255     HTMLScriptElement_Release,
00256     HTMLScriptElement_GetTypeInfoCount,
00257     HTMLScriptElement_GetTypeInfo,
00258     HTMLScriptElement_GetIDsOfNames,
00259     HTMLScriptElement_Invoke,
00260     HTMLScriptElement_put_src,
00261     HTMLScriptElement_get_src,
00262     HTMLScriptElement_put_htmlFor,
00263     HTMLScriptElement_get_htmlFor,
00264     HTMLScriptElement_put_event,
00265     HTMLScriptElement_get_event,
00266     HTMLScriptElement_put_text,
00267     HTMLScriptElement_get_text,
00268     HTMLScriptElement_put_defer,
00269     HTMLScriptElement_get_defer,
00270     HTMLScriptElement_get_readyState,
00271     HTMLScriptElement_put_onerror,
00272     HTMLScriptElement_get_onerror,
00273     HTMLScriptElement_put_type,
00274     HTMLScriptElement_get_type
00275 };
00276 
00277 #undef HTMLSCRIPT_THIS
00278 
00279 #define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface)
00280 
00281 static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
00282 {
00283     HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
00284 
00285     *ppv = NULL;
00286 
00287     if(IsEqualGUID(&IID_IUnknown, riid)) {
00288         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
00289         *ppv = HTMLSCRIPT(This);
00290     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
00291         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
00292         *ppv = HTMLSCRIPT(This);
00293     }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) {
00294         TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv);
00295         *ppv = HTMLSCRIPT(This);
00296     }
00297 
00298     if(*ppv) {
00299         IUnknown_AddRef((IUnknown*)*ppv);
00300         return S_OK;
00301     }
00302 
00303     return HTMLElement_QI(&This->element.node, riid, ppv);
00304 }
00305 
00306 static void HTMLScriptElement_destructor(HTMLDOMNode *iface)
00307 {
00308     HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
00309     HTMLElement_destructor(&This->element.node);
00310 }
00311 
00312 static HRESULT HTMLScriptElement_get_readystate(HTMLDOMNode *iface, BSTR *p)
00313 {
00314     HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface);
00315 
00316     return IHTMLScriptElement_get_readyState(HTMLSCRIPT(This), p);
00317 }
00318 
00319 #undef HTMLSCRIPT_NODE_THIS
00320 
00321 static const NodeImplVtbl HTMLScriptElementImplVtbl = {
00322     HTMLScriptElement_QI,
00323     HTMLScriptElement_destructor,
00324     NULL,
00325     NULL,
00326     NULL,
00327     NULL,
00328     NULL,
00329     HTMLScriptElement_get_readystate
00330 };
00331 
00332 static const tid_t HTMLScriptElement_iface_tids[] = {
00333     HTMLELEMENT_TIDS,
00334     IHTMLScriptElement_tid,
00335     0
00336 };
00337 
00338 static dispex_static_data_t HTMLScriptElement_dispex = {
00339     NULL,
00340     DispHTMLScriptElement_tid,
00341     NULL,
00342     HTMLScriptElement_iface_tids
00343 };
00344 
00345 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
00346 {
00347     HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement));
00348     nsresult nsres;
00349 
00350     ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
00351     ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
00352 
00353     HTMLElement_Init(&ret->element, doc, nselem, &HTMLScriptElement_dispex);
00354 
00355     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
00356     if(NS_FAILED(nsres))
00357         ERR("Could not get nsIDOMHTMLScriptElement: %08x\n", nsres);
00358 
00359     return &ret->element;
00360 }

Generated on Sat May 26 2012 04:23:33 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.