Commit e80c55c3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLTableRow::get_cells implementation.

parent ac4117fd
......@@ -35,6 +35,8 @@ typedef struct {
HTMLElement element;
const IHTMLTableRowVtbl *lpHTMLTableRowVtbl;
nsIDOMHTMLTableRowElement *nsrow;
} HTMLTableRow;
#define HTMLTABLEROW(x) ((IHTMLTableRow*) &(x)->lpHTMLTableRowVtbl)
......@@ -194,8 +196,21 @@ static HRESULT WINAPI HTMLTableRow_get_selectionRowIndex(IHTMLTableRow *iface, l
static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementCollection **p)
{
HTMLTableRow *This = HTMLTABLEROW_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsIDOMHTMLCollection *nscol;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMHTMLTableRowElement_GetCells(This->nsrow, &nscol);
if(NS_FAILED(nsres)) {
ERR("GetCells failed: %08x\n", nsres);
return E_FAIL;
}
*p = create_collection_from_htmlcol(This->element.node.doc, (IUnknown*)HTMLTABLEROW(This), nscol);
nsIDOMHTMLCollection_Release(nscol);
return S_OK;
}
static HRESULT WINAPI HTMLTableRow_insertCell(IHTMLTableRow *iface, long index, IDispatch **row)
......@@ -271,6 +286,10 @@ static HRESULT HTMLTableRow_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
static void HTMLTableRow_destructor(HTMLDOMNode *iface)
{
HTMLTableRow *This = HTMLTABLEROW_NODE_THIS(iface);
if(This->nsrow)
nsIDOMHTMLTableRowElement_Release(This->nsrow);
HTMLElement_destructor(&This->element.node);
}
......@@ -300,6 +319,7 @@ static dispex_static_data_t HTMLTableRow_dispex = {
HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement *nselem)
{
HTMLTableRow *ret = heap_alloc_zero(sizeof(HTMLTableRow));
nsresult nsres;
ret->lpHTMLTableRowVtbl = &HTMLTableRowVtbl;
ret->element.node.vtbl = &HTMLTableRowImplVtbl;
......@@ -307,5 +327,9 @@ HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement *nselem)
init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLTABLEROW(ret), &HTMLTableRow_dispex);
HTMLElement_Init(&ret->element);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableRowElement, (void**)&ret->nsrow);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLTableRowElement iface: %08x\n", nsres);
return &ret->element;
}
......@@ -1389,6 +1389,31 @@ interface nsIDOMHTMLTableElement : nsIDOMHTMLElement
[
object,
uuid(a6cf90b6-15b3-11d2-932e-00805f8add32),
local
/* FROZEN */
]
interface nsIDOMHTMLTableRowElement : nsIDOMHTMLElement
{
nsresult GetRowIndex(PRInt32 *aRowIndex);
nsresult GetSectionRowIndex(PRInt32 *aSectionRowIndex);
nsresult GetCells(nsIDOMHTMLCollection **aCells);
nsresult GetAlign(nsAString *aAlign);
nsresult SetAlign(const nsAString *aAlign);
nsresult GetBgColor(nsAString *aBgColor);
nsresult SetBgColor(const nsAString *aBgColor);
nsresult GetCh(nsAString *aCh);
nsresult SetCh(const nsAString *aCh);
nsresult GetChOff(nsAString *aChOff);
nsresult SetChOff(const nsAString *aChOff);
nsresult GetVAlign(nsAString *aVAlign);
nsresult SetVAlign(const nsAString *aVAlign);
nsresult InsertCell(PRInt32 index, nsIDOMHTMLElement **_retval);
nsresult DeleteCell(PRInt32 index);
}
[
object,
uuid(94928ab3-8b63-11d3-989d-001083010e9b),
local
/* FROZEN */
......
......@@ -45,7 +45,7 @@ static const char elem_test_str[] =
"<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
"<select id=\"s\"><option id=\"x\" value=\"val1\">opt1</option><option id=\"y\">opt2</option></select>"
"<textarea id=\"X\">text text</textarea>"
"<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"></tr></tbody></table>"
"<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"><td>td1 text</td><td>td2 text</td></tr></tbody></table>"
"<script id=\"sc\" type=\"text/javascript\"></script>"
"<test />"
"<img id=\"imgid\"/>"
......@@ -85,7 +85,8 @@ typedef enum {
ET_TESTG,
ET_COMMENT,
ET_IMG,
ET_TR
ET_TR,
ET_TD
} elem_type_t;
static const IID * const none_iids[] = {
......@@ -247,6 +248,16 @@ static const IID * const tr_iids[] = {
NULL
};
static const IID * const td_iids[] = {
&IID_IHTMLDOMNode,
&IID_IHTMLDOMNode2,
&IID_IHTMLElement,
&IID_IHTMLElement2,
&IID_IDispatchEx,
&IID_IConnectionPointContainer,
NULL
};
static const IID * const generic_iids[] = {
&IID_IHTMLDOMNode,
&IID_IHTMLDOMNode2,
......@@ -286,7 +297,8 @@ static const elem_type_info_t elem_type_infos[] = {
{"TEST", generic_iids, &DIID_DispHTMLGenericElement},
{"!", comment_iids, &DIID_DispHTMLCommentElement},
{"IMG", img_iids, &DIID_DispHTMLImg},
{"TR", tr_iids, &DIID_DispHTMLTableRow}
{"TR", tr_iids, &DIID_DispHTMLTableRow},
{"TD", td_iids, NULL}
};
static const char *dbgstr_w(LPCWSTR str)
......@@ -2243,6 +2255,30 @@ static void test_defaults(IHTMLDocument2 *doc)
test_doc_title(doc, "");
}
static void test_tr_elem(IHTMLElement *elem)
{
IHTMLElementCollection *col;
IHTMLTableRow *row;
HRESULT hres;
static const elem_type_t cell_types[] = {ET_TD,ET_TD};
hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTableRow, (void**)&row);
ok(hres == S_OK, "Could not get IHTMLTableRow iface: %08x\n", hres);
if(FAILED(hres))
return;
col = NULL;
hres = IHTMLTableRow_get_cells(row, &col);
ok(hres == S_OK, "get_cells failed: %08x\n", hres);
ok(col != NULL, "get_cells returned NULL\n");
test_elem_collection((IUnknown*)col, cell_types, sizeof(cell_types)/sizeof(*cell_types));
IHTMLElementCollection_Release(col);
IHTMLTable_Release(row);
}
static void test_table_elem(IHTMLElement *elem)
{
IHTMLElementCollection *col;
......@@ -2384,6 +2420,7 @@ static void test_elems(IHTMLDocument2 *doc)
static const WCHAR scW[] = {'s','c',0};
static const WCHAR xxxW[] = {'x','x','x',0};
static const WCHAR tblW[] = {'t','b','l',0};
static const WCHAR row2W[] = {'r','o','w','2',0};
static const elem_type_t all_types[] = {
ET_HTML,
......@@ -2402,6 +2439,8 @@ static void test_elems(IHTMLDocument2 *doc)
ET_TBODY,
ET_TR,
ET_TR,
ET_TD,
ET_TD,
ET_SCRIPT,
ET_TEST,
ET_IMG
......@@ -2570,6 +2609,13 @@ static void test_elems(IHTMLDocument2 *doc)
IHTMLElement_Release(elem);
}
elem = get_doc_elem_by_id(doc, row2W);
ok(elem != NULL, "elem == NULL\n");
if(elem) {
test_tr_elem(elem);
IHTMLElement_Release(elem);
}
hres = IHTMLDocument2_get_body(doc, &elem);
ok(hres == S_OK, "get_body failed: %08x\n", hres);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment