From 31ae80233ded69ad7ddee37b9070acbaad67776f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 30 Sep 2008 17:40:19 +0200 Subject: [PATCH] mshtml: Added IHTMLTableRow stub implementation. --- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmlelem.c | 3 + dlls/mshtml/htmltablerow.c | 294 +++++++++++++++++++++++++++++++++++ dlls/mshtml/main.c | 22 +++ dlls/mshtml/mshtml_private.h | 3 + dlls/mshtml/tests/dom.c | 20 ++- 6 files changed, 340 insertions(+), 3 deletions(-) create mode 100644 dlls/mshtml/htmltablerow.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 2a7b1fabcd..0a02b2209a 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -32,6 +32,7 @@ C_SRCS = \ htmlstyle.c \ htmlstylesheet.c \ htmltable.c \ + htmltablerow.c \ htmltextarea.c \ htmltextcont.c \ htmltextnode.c \ diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 78e9c9be5a..bd6092fcd6 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1496,6 +1496,7 @@ HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode, BOOL use_ 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 wszTR[] = {'T','R',0}; static const WCHAR wszTEXTAREA[] = {'T','E','X','T','A','R','E','A',0}; nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMHTMLElement, (void**)&nselem); @@ -1523,6 +1524,8 @@ HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode, BOOL use_ ret = HTMLSelectElement_Create(nselem); else if(!strcmpW(class_name, wszTABLE)) ret = HTMLTable_Create(nselem); + else if(!strcmpW(class_name, wszTR)) + ret = HTMLTableRow_Create(nselem); else if(!strcmpW(class_name, wszTEXTAREA)) ret = HTMLTextAreaElement_Create(nselem); else if(use_generic) diff --git a/dlls/mshtml/htmltablerow.c b/dlls/mshtml/htmltablerow.c new file mode 100644 index 0000000000..007d6bd2b4 --- /dev/null +++ b/dlls/mshtml/htmltablerow.c @@ -0,0 +1,294 @@ +/* + * 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 + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLElement element; + + const IHTMLTableRowVtbl *lpHTMLTableRowVtbl; +} HTMLTableRow; + +#define HTMLTABLEROW(x) ((IHTMLTableRow*) &(x)->lpHTMLTableRowVtbl) + +#define HTMLTABLEROW_THIS(iface) DEFINE_THIS(HTMLTableRow, HTMLTableRow, iface) + +static HRESULT WINAPI HTMLTableRow_QueryInterface(IHTMLTableRow *iface, + REFIID riid, void **ppv) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + + return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv); +} + +static ULONG WINAPI HTMLTableRow_AddRef(IHTMLTableRow *iface) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + + return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->element.node)); +} + +static ULONG WINAPI HTMLTableRow_Release(IHTMLTableRow *iface) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + + return IHTMLDOMNode_Release(HTMLDOMNODE(&This->element.node)); +} + +static HRESULT WINAPI HTMLTableRow_GetTypeInfoCount(IHTMLTableRow *iface, UINT *pctinfo) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->element.node.dispex), pctinfo); +} + +static HRESULT WINAPI HTMLTableRow_GetTypeInfo(IHTMLTableRow *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->element.node.dispex), iTInfo, lcid, ppTInfo); +} + +static HRESULT WINAPI HTMLTableRow_GetIDsOfNames(IHTMLTableRow *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->element.node.dispex), riid, rgszNames, cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLTableRow_Invoke(IHTMLTableRow *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + return IDispatchEx_Invoke(DISPATCHEX(&This->element.node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLTableRow_put_align(IHTMLTableRow *iface, BSTR v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_align(IHTMLTableRow *iface, BSTR *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_put_vAlign(IHTMLTableRow *iface, BSTR v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_vAlign(IHTMLTableRow *iface, BSTR *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_put_bgColor(IHTMLTableRow *iface, VARIANT v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_bgColor(IHTMLTableRow *iface, VARIANT *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_put_borderColor(IHTMLTableRow *iface, VARIANT v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_borderColor(IHTMLTableRow *iface, VARIANT *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_put_borderColorLight(IHTMLTableRow *iface, VARIANT v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_borderColorLight(IHTMLTableRow *iface, VARIANT *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_put_borderColorDark(IHTMLTableRow *iface, VARIANT v) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_borderColorDark(IHTMLTableRow *iface, VARIANT *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_rowIndex(IHTMLTableRow *iface, long *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_selectionRowIndex(IHTMLTableRow *iface, long *p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementCollection **p) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_insertCell(IHTMLTableRow *iface, long index, IDispatch **row) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%ld %p)\n", This, index, row); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLTableRow_deleteCell(IHTMLTableRow *iface, long index) +{ + HTMLTableRow *This = HTMLTABLEROW_THIS(iface); + FIXME("(%p)->(%ld)\n", This, index); + return E_NOTIMPL; +} + +#undef HTMLTABLEROW_THIS + +static const IHTMLTableRowVtbl HTMLTableRowVtbl = { + HTMLTableRow_QueryInterface, + HTMLTableRow_AddRef, + HTMLTableRow_Release, + HTMLTableRow_GetTypeInfoCount, + HTMLTableRow_GetTypeInfo, + HTMLTableRow_GetIDsOfNames, + HTMLTableRow_Invoke, + HTMLTableRow_put_align, + HTMLTableRow_get_align, + HTMLTableRow_put_vAlign, + HTMLTableRow_get_vAlign, + HTMLTableRow_put_bgColor, + HTMLTableRow_get_bgColor, + HTMLTableRow_put_borderColor, + HTMLTableRow_get_borderColor, + HTMLTableRow_put_borderColorLight, + HTMLTableRow_get_borderColorLight, + HTMLTableRow_put_borderColorDark, + HTMLTableRow_get_borderColorDark, + HTMLTableRow_get_rowIndex, + HTMLTableRow_get_selectionRowIndex, + HTMLTableRow_get_cells, + HTMLTableRow_insertCell, + HTMLTableRow_deleteCell +}; + +#define HTMLTABLEROW_NODE_THIS(iface) DEFINE_THIS2(HTMLTableRow, element.node, iface) + +static HRESULT HTMLTableRow_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLTableRow *This = HTMLTABLEROW_NODE_THIS(iface); + + *ppv = NULL; + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = HTMLTABLEROW(This); + }else if(IsEqualGUID(&IID_IDispatch, riid)) { + TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv); + *ppv = HTMLTABLEROW(This); + }else if(IsEqualGUID(&IID_IHTMLTableRow, riid)) { + TRACE("(%p)->(IID_IHTMLTableRow %p)\n", This, ppv); + *ppv = HTMLTABLEROW(This); + } + + if(*ppv) { + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; + } + + return HTMLElement_QI(&This->element.node, riid, ppv); +} + +static void HTMLTableRow_destructor(HTMLDOMNode *iface) +{ + HTMLTableRow *This = HTMLTABLEROW_NODE_THIS(iface); + HTMLElement_destructor(&This->element.node); +} + +#undef HTMLTABLEROW_NODE_THIS + +static const NodeImplVtbl HTMLTableRowImplVtbl = { + HTMLTableRow_QI, + HTMLTableRow_destructor +}; + +HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement *nselem) +{ + HTMLTableRow *ret = heap_alloc_zero(sizeof(HTMLTableRow)); + + HTMLElement_Init(&ret->element); + + ret->lpHTMLTableRowVtbl = &HTMLTableRowVtbl; + ret->element.node.vtbl = &HTMLTableRowImplVtbl; + + return &ret->element; +} diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c index 1c52c5a07b..1315e8a469 100644 --- a/dlls/mshtml/main.c +++ b/dlls/mshtml/main.c @@ -423,3 +423,25 @@ HRESULT WINAPI DllUnregisterServer(void) { return register_server(FALSE); } + +const char *debugstr_variant(const VARIANT *v) +{ + switch(V_VT(v)) { + case VT_EMPTY: + return wine_dbg_sprintf("{VT_EMPTY}"); + case VT_NULL: + return wine_dbg_sprintf("{VT_NULL}"); + case VT_I4: + return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v)); + case VT_R8: + return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v)); + case VT_BSTR: + return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v))); + case VT_DISPATCH: + return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v)); + case VT_BOOL: + return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v)); + default: + return wine_dbg_sprintf("{vt %d}", V_VT(v)); + } +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index 5211d2fb03..646adfd32e 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -557,6 +557,7 @@ HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*); +HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*); HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*); @@ -647,6 +648,8 @@ HRESULT get_typeinfo(tid_t,ITypeInfo**); void release_typelib(void); void call_disp_func(HTMLDocument*,IDispatch*); +const char *debugstr_variant(const VARIANT*); + DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 7d3b3e3815..a03d11c32a 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -45,7 +45,7 @@ static const char elem_test_str[] = "" "" "" - "
" + "
" "" "" "" @@ -84,7 +84,8 @@ typedef enum { ET_TEST, ET_TESTG, ET_COMMENT, - ET_IMG + ET_IMG, + ET_TR } elem_type_t; static const IID * const none_iids[] = { @@ -235,6 +236,17 @@ static const IID * const img_iids[] = { NULL }; +static const IID * const tr_iids[] = { + &IID_IHTMLDOMNode, + &IID_IHTMLDOMNode2, + &IID_IHTMLElement, + &IID_IHTMLElement2, + &IID_IDispatchEx, + &IID_IHTMLTableRow, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const generic_iids[] = { &IID_IHTMLDOMNode, &IID_IHTMLDOMNode2, @@ -273,7 +285,8 @@ static const elem_type_info_t elem_type_infos[] = { {"TEST", elem_iids, &DIID_DispHTMLUnknownElement}, {"TEST", generic_iids, &DIID_DispHTMLGenericElement}, {"!", comment_iids, &DIID_DispHTMLCommentElement}, - {"IMG", img_iids, &DIID_DispHTMLImg} + {"IMG", img_iids, &DIID_DispHTMLImg}, + {"TR", tr_iids, NULL} }; static const char *dbgstr_w(LPCWSTR str) @@ -2362,6 +2375,7 @@ static void test_elems(IHTMLDocument2 *doc) ET_TEXTAREA, ET_TABLE, ET_TBODY, + ET_TR, ET_SCRIPT, ET_TEST, ET_IMG