Commit bc582f09 authored by Zhenbo Li's avatar Zhenbo Li Committed by Alexandre Julliard

mshtml: Added IHTMLTable::insertRow/deleteRow methods implementation.

parent 9ee4b8b0
......@@ -622,15 +622,41 @@ static HRESULT WINAPI HTMLTable_deleteCaption(IHTMLTable *iface)
static HRESULT WINAPI HTMLTable_insertRow(IHTMLTable *iface, LONG index, IDispatch **row)
{
HTMLTable *This = impl_from_IHTMLTable(iface);
FIXME("(%p)->(%d %p)\n", This, index, row);
return E_NOTIMPL;
nsIDOMHTMLElement *nselem;
HTMLElement *elem;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%d %p)\n", This, index, row);
nsres = nsIDOMHTMLTableElement_InsertRow(This->nstable, index, &nselem);
if(NS_FAILED(nsres)) {
ERR("Insert Row at %d failed: %08x\n", index, nsres);
return E_FAIL;
}
hres = HTMLTableRow_Create(This->element.node.doc, nselem, &elem);
nsIDOMHTMLElement_Release(nselem);
if (FAILED(hres)) {
ERR("Create TableRow failed: %08x\n", hres);
return hres;
}
*row = (IDispatch *)&elem->IHTMLElement_iface;
return S_OK;
}
static HRESULT WINAPI HTMLTable_deleteRow(IHTMLTable *iface, LONG index)
{
HTMLTable *This = impl_from_IHTMLTable(iface);
FIXME("(%p)->(%d)\n", This, index);
return E_NOTIMPL;
nsresult nsres;
TRACE("(%p)->(%d)\n", This, index);
nsres = nsIDOMHTMLTableElement_DeleteRow(This->nstable, index);
if(NS_FAILED(nsres)) {
ERR("Delete Row failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLTable_get_readyState(IHTMLTable *iface, BSTR *p)
......
......@@ -5080,6 +5080,25 @@ static void _test_language_string(unsigned line, const WCHAR *lang, LCID lcid)
}
}
#define test_table_length(t,l) _test_table_length(__LINE__,t,l)
static void _test_table_length(unsigned line, IHTMLTable *table, LONG expect)
{
IHTMLElementCollection *col;
HRESULT hres;
LONG len;
hres = IHTMLTable_get_rows(table, &col);
ok_(__FILE__,line)(hres == S_OK, "get_rows failed: %08x\n", hres);
ok_(__FILE__,line)(col != NULL, "col = NULL\n");
if (hres != S_OK || col == NULL)
return;
hres = IHTMLElementCollection_get_length(col, &len);
ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
ok_(__FILE__,line)(len == expect, "Expect %d, got %d\n", expect, len);
IHTMLElementCollection_Release(col);
}
static void test_navigator(IHTMLDocument2 *doc)
{
IHTMLWindow2 *window;
......@@ -5990,6 +6009,40 @@ static void _test_table_cell_spacing(unsigned line, IHTMLTable *table, const cha
VariantClear(&v);
}
static void test_table_modify(IHTMLTable *table)
{
IDispatch *disp;
IHTMLTableRow *row;
HRESULT hres;
LONG index;
test_table_length(table, 2);
hres = IHTMLTable_insertRow(table, 0, &disp);
ok(hres == S_OK, "insertRow failed: %08x\n", hres);
ok(disp != NULL, "disp == NULL\n");
test_table_length(table, 3);
if (hres != S_OK || disp == NULL)
return;
hres = IDispatch_QueryInterface(disp, &IID_IHTMLTableRow, (void**)&row);
IDispatch_Release(disp);
ok(hres == S_OK, "QueryInterface failed: %08x\n", hres);
ok(row != NULL, "row == NULL\n");
index = 0xdeadbeef;
hres = IHTMLTableRow_get_rowIndex(row, &index);
ok(hres == S_OK, "get_rowIndex failed: %08x\n", hres);
ok(index == 0, "index = %d, expected 0\n", index);
IHTMLTableRow_Release(row);
hres = IHTMLTable_deleteRow(table, 0);
ok(hres == S_OK, "deleteRow failed: %08x\n", hres);
test_table_length(table, 2);
}
static void test_table_elem(IHTMLElement *elem)
{
IHTMLElementCollection *col;
......@@ -6152,6 +6205,8 @@ static void test_table_elem(IHTMLElement *elem)
ok(!strcmp_wa(V_BSTR(&v), "11"), "Expected 11, got %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
test_table_modify(table);
bstr = a2bstr("summary");
hres = IHTMLTable3_put_summary(table3, bstr);
ok(hres == S_OK, "put_summary = %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