diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 07a32ed5d5e..45094e62f6a 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -22,6 +22,7 @@ C_SRCS = \ htmlinput.c \ htmlnode.c \ htmloption.c \ + htmlscript.c \ htmlselect.c \ htmlstyle.c \ htmlstylesheet.c \ diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 42906ef19b3..145a6255986 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1307,6 +1307,7 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) static const WCHAR wszBODY[] = {'B','O','D','Y',0}; static const WCHAR wszINPUT[] = {'I','N','P','U','T',0}; static const WCHAR wszOPTION[] = {'O','P','T','I','O','N',0}; + static const WCHAR wszSCRIPT[] = {'S','C','R','I','P','T',0}; static const WCHAR wszSELECT[] = {'S','E','L','E','C','T',0}; static const WCHAR wszTABLE[] = {'T','A','B','L','E',0}; static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0}; @@ -1328,6 +1329,8 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) ret = HTMLInputElement_Create(nselem); else if(!strcmpW(class_name, wszOPTION)) ret = HTMLOptionElement_Create(nselem); + else if(!strcmpW(class_name, wszSCRIPT)) + ret = HTMLScriptElement_Create(nselem); else if(!strcmpW(class_name, wszSELECT)) ret = HTMLSelectElement_Create(nselem); else if(!strcmpW(class_name, wszTABLE)) diff --git a/dlls/mshtml/htmlscript.c b/dlls/mshtml/htmlscript.c new file mode 100644 index 00000000000..fa7867d699b --- /dev/null +++ b/dlls/mshtml/htmlscript.c @@ -0,0 +1,287 @@ +/* + * Copyright 2008 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "winnls.h" +#include "ole2.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLElement element; + + const IHTMLScriptElementVtbl *lpHTMLScriptElementVtbl; +} HTMLScriptElement; + +#define HTMLSCRIPT(x) ((IHTMLScriptElement*) &(x)->lpHTMLScriptElementVtbl) + +#define HTMLSCRIPT_THIS(iface) DEFINE_THIS(HTMLScriptElement, HTMLScriptElement, iface) + +static HRESULT WINAPI HTMLScriptElement_QueryInterface(IHTMLScriptElement *iface, + REFIID riid, void **ppv) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv); +} + +static ULONG WINAPI HTMLScriptElement_AddRef(IHTMLScriptElement *iface) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node)); +} + +static ULONG WINAPI HTMLScriptElement_Release(IHTMLScriptElement *iface) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node)); +} + +static HRESULT WINAPI HTMLScriptElement_GetTypeInfoCount(IHTMLScriptElement *iface, UINT *pctinfo) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, pctinfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_GetTypeInfo(IHTMLScriptElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_GetIDsOfNames(IHTMLScriptElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, + lcid, rgDispId); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_Invoke(IHTMLScriptElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid), + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_src(IHTMLScriptElement *iface, BSTR v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_src(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_htmlFor(IHTMLScriptElement *iface, BSTR v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_htmlFor(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_event(IHTMLScriptElement *iface, BSTR v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_event(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_text(IHTMLScriptElement *iface, BSTR v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_text(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_defer(IHTMLScriptElement *iface, VARIANT_BOOL v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%x)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_defer(IHTMLScriptElement *iface, VARIANT_BOOL *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_readyState(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_onerror(IHTMLScriptElement *iface, VARIANT v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(v(%d))\n", This, V_VT(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_onerror(IHTMLScriptElement *iface, VARIANT *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_put_type(IHTMLScriptElement *iface, BSTR v) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLScriptElement_get_type(IHTMLScriptElement *iface, BSTR *p) +{ + HTMLScriptElement *This = HTMLSCRIPT_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static const IHTMLScriptElementVtbl HTMLScriptElementVtbl = { + HTMLScriptElement_QueryInterface, + HTMLScriptElement_AddRef, + HTMLScriptElement_Release, + HTMLScriptElement_GetTypeInfoCount, + HTMLScriptElement_GetTypeInfo, + HTMLScriptElement_GetIDsOfNames, + HTMLScriptElement_Invoke, + HTMLScriptElement_put_src, + HTMLScriptElement_get_src, + HTMLScriptElement_put_htmlFor, + HTMLScriptElement_get_htmlFor, + HTMLScriptElement_put_event, + HTMLScriptElement_get_event, + HTMLScriptElement_put_text, + HTMLScriptElement_get_text, + HTMLScriptElement_put_defer, + HTMLScriptElement_get_defer, + HTMLScriptElement_get_readyState, + HTMLScriptElement_put_onerror, + HTMLScriptElement_get_onerror, + HTMLScriptElement_put_type, + HTMLScriptElement_get_type +}; + +#undef HTMLSCRIPT_THIS + +#define HTMLSCRIPT_NODE_THIS(iface) DEFINE_THIS2(HTMLScriptElement, element.node, iface) + +static HRESULT HTMLScriptElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLSCRIPT(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLSCRIPT(This); + }else if(IsEqualGUID(&IID_IHTMLScriptElement, riid)) { + TRACE("(%p)->(IID_IHTMLScriptElement %p)\n", This, ppv); + *ppv = HTMLSCRIPT(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + return HTMLElement_QI(&This->element.node, riid, ppv); +} + +static void HTMLScriptElement_destructor(HTMLDOMNode *iface) +{ + HTMLScriptElement *This = HTMLSCRIPT_NODE_THIS(iface); + HTMLElement_destructor(&This->element.node); +} + +#undef HTMLSCRIPT_NODE_THIS + +static const NodeImplVtbl HTMLScriptElementImplVtbl = { + HTMLScriptElement_QI, + HTMLScriptElement_destructor +}; + +HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem) +{ + HTMLScriptElement *ret = heap_alloc(sizeof(HTMLScriptElement)); + + HTMLElement_Init(&ret->element); + + ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl; + ret->element.node.vtbl = &HTMLScriptElementImplVtbl; + + return &ret->element; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 6eb7f30a425..b97910db8b8 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -192,6 +192,7 @@ struct NSContainer { nsEventListener focus_listener; nsEventListener keypress_listener; nsEventListener load_listener; + nsEventListener node_insert_listener; nsIWebBrowser *webbrowser; nsIWebNavigation *navigation; @@ -446,6 +447,7 @@ HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*); +HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*); HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index e966f45a22e..60ddb6fec59 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -43,6 +43,7 @@ static const char elem_test_str[] = "" "" "
" + "" ""; static const char indent_test_str[] = "testabc
123"; @@ -69,7 +70,8 @@ typedef enum { ET_P, ET_BR, ET_TABLE, - ET_TBODY + ET_TBODY, + ET_SCRIPT } elem_type_t; static REFIID const none_iids[] = { @@ -150,6 +152,15 @@ static REFIID const table_iids[] = { NULL }; +static REFIID const script_iids[] = { + &IID_IHTMLDOMNode, + &IID_IHTMLElement, + &IID_IHTMLElement2, + &IID_IHTMLScriptElement, + &IID_IConnectionPointContainer, + NULL +}; + typedef struct { const char *tag; REFIID *iids; @@ -171,7 +182,8 @@ static const elem_type_info_t elem_type_infos[] = { {"P", elem_iids}, {"BR", elem_iids}, {"TABLE", table_iids}, - {"TBODY", elem_iids} + {"TBODY", elem_iids}, + {"SCRIPT", script_iids} }; static const char *dbgstr_w(LPCWSTR str) @@ -1196,7 +1208,8 @@ static void test_elems(IHTMLDocument2 *doc) ET_OPTION, ET_TEXTAREA, ET_TABLE, - ET_TBODY + ET_TBODY, + ET_SCRIPT }; static const elem_type_t item_types[] = {