Jacek Caban : mshtml: Added IHTMLTableRow::get_cells implementation.

Alexandre Julliard julliard at winehq.org
Wed Oct 1 14:09:28 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep 30 17:46:02 2008 +0200

mshtml: Added IHTMLTableRow::get_cells implementation.

---

 dlls/mshtml/htmltablerow.c |   28 ++++++++++++++++++++++-
 dlls/mshtml/nsiface.idl    |   25 +++++++++++++++++++++
 dlls/mshtml/tests/dom.c    |   52 +++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 100 insertions(+), 5 deletions(-)

diff --git a/dlls/mshtml/htmltablerow.c b/dlls/mshtml/htmltablerow.c
index aaf0567..77d8221 100644
--- a/dlls/mshtml/htmltablerow.c
+++ b/dlls/mshtml/htmltablerow.c
@@ -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;
 }
diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl
index 5e92dc5..bedac82 100644
--- a/dlls/mshtml/nsiface.idl
+++ b/dlls/mshtml/nsiface.idl
@@ -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 */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 6e05ebb..199248b 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -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);
 




More information about the wine-cvs mailing list