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

Alexandre Julliard julliard at wine.codeweavers.com
Mon Aug 18 16:08:49 CDT 2014


Module: wine
Branch: master
Commit: bc582f09ff78770f212d61ff5e64e87821871819
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=bc582f09ff78770f212d61ff5e64e87821871819

Author: Zhenbo Li <litimetal at gmail.com>
Date:   Mon Aug 18 16:55:59 2014 +0800

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

---

 dlls/mshtml/htmltable.c | 34 ++++++++++++++++++++++++++----
 dlls/mshtml/tests/dom.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c
index e7991da..cfacf35 100644
--- a/dlls/mshtml/htmltable.c
+++ b/dlls/mshtml/htmltable.c
@@ -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)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index dddb28c..f235835 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -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);




More information about the wine-cvs mailing list