From ac4117fdb5fc809aac2d23616d849563b2244bdf Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 30 Sep 2008 17:45:48 +0200 Subject: [PATCH] mshtml: Added IHTMLTable::get_rows implementation. --- dlls/mshtml/htmlelemcol.c | 25 +++++++++++++++++++++++++ dlls/mshtml/htmltable.c | 17 +++++++++++++++-- dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/nsiface.idl | 14 +++++++++++++- dlls/mshtml/tests/dom.c | 35 ++++++++++++++++++++++++++++++++++- 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c index 768dbeecbc..cf112340e9 100644 --- a/dlls/mshtml/htmlelemcol.c +++ b/dlls/mshtml/htmlelemcol.c @@ -503,6 +503,31 @@ IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument *doc, IUnkn return HTMLElementCollection_Create(unk, buf.buf, buf.len); } +IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocument *doc, IUnknown *unk, nsIDOMHTMLCollection *nscol) +{ + PRUint32 length = 0, i; + elem_vector_t buf; + + nsIDOMHTMLCollection_GetLength(nscol, &length); + + buf.len = buf.size = length; + if(buf.len) { + nsIDOMNode *nsnode; + + buf.buf = heap_alloc(buf.size*sizeof(HTMLElement*)); + + for(i=0; i(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMHTMLCollection *nscol; + nsresult nsres; + + TRACE("(%p)->(%p)\n", This, p); + + nsres = nsIDOMHTMLTableElement_GetRows(This->nstable, &nscol); + if(NS_FAILED(nsres)) { + ERR("GetRows failed: %08x\n", nsres); + return E_FAIL; + } + + *p = create_collection_from_htmlcol(This->element.node.doc, (IUnknown*)HTMLTABLE(This), nscol); + + nsIDOMHTMLCollection_Release(nscol); + return S_OK; } static HRESULT WINAPI HTMLTable_put_width(IHTMLTable *iface, VARIANT v) diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index b14ad0283c..247dfa8141 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -587,6 +587,7 @@ void set_script_mode(HTMLDocument*,SCRIPTMODE); IHTMLElementCollection *HTMLElementCollection_Create(IUnknown*,HTMLElement**,DWORD); IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL); IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*); +IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocument*,IUnknown*,nsIDOMHTMLCollection*); /* commands */ typedef struct { diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 525bfd354e..5e92dc5725 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -115,7 +115,6 @@ typedef nsISupports nsIDOMProcessingInstruction; typedef nsISupports nsIDOMEntityReference; typedef nsISupports nsIDOMHTMLFormElement; typedef nsISupports nsIDOMHTMLOptionsCollection; -typedef nsISupports nsIDOMHTMLCollection; typedef nsISupports nsIWebProgressListener; typedef nsISupports nsIDOMCSSValue; typedef nsISupports nsIPrintSession; @@ -824,6 +823,19 @@ interface nsIDOMNSHTMLElement : nsISupports nsresult ScrollIntoView(PRBool top); } +[ + object, + uuid(a6cf9083-15b3-11d2-932e-00805f8add32), + local + /* FROZEN */ +] +interface nsIDOMHTMLCollection : nsISupports +{ + nsresult GetLength(PRUint32 *aLength); + nsresult Item(PRUint32 index, nsIDOMNode **_retval); + nsresult NamedItem(const nsAString *name, nsIDOMNode **_retval); +} + [ object, uuid(a6cf9072-15b3-11d2-932e-00805f8add32), diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index b8e57da354..6e05ebbd9b 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -45,7 +45,7 @@ static const char elem_test_str[] = "" "" "" - "
" + "
" "" "" "" @@ -2243,6 +2243,30 @@ static void test_defaults(IHTMLDocument2 *doc) test_doc_title(doc, ""); } +static void test_table_elem(IHTMLElement *elem) +{ + IHTMLElementCollection *col; + IHTMLTable *table; + HRESULT hres; + + static const elem_type_t row_types[] = {ET_TR,ET_TR}; + + hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLTable, (void**)&table); + ok(hres == S_OK, "Could not get IHTMLTable iface: %08x\n", hres); + if(FAILED(hres)) + return; + + col = NULL; + hres = IHTMLTable_get_rows(table, &col); + ok(hres == S_OK, "get_rows failed: %08x\n", hres); + ok(col != NULL, "get_ros returned NULL\n"); + + test_elem_collection((IUnknown*)col, row_types, sizeof(row_types)/sizeof(*row_types)); + IHTMLElementCollection_Release(col); + + IHTMLTable_Release(table); +} + static void test_stylesheet(IDispatch *disp) { IHTMLStyleSheetRulesCollection *col = NULL; @@ -2359,6 +2383,7 @@ static void test_elems(IHTMLDocument2 *doc) static const WCHAR sW[] = {'s',0}; 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 elem_type_t all_types[] = { ET_HTML, @@ -2376,6 +2401,7 @@ static void test_elems(IHTMLDocument2 *doc) ET_TABLE, ET_TBODY, ET_TR, + ET_TR, ET_SCRIPT, ET_TEST, ET_IMG @@ -2537,6 +2563,13 @@ static void test_elems(IHTMLDocument2 *doc) IHTMLElement_Release(elem); } + elem = get_doc_elem_by_id(doc, tblW); + ok(elem != NULL, "elem == NULL\n"); + if(elem) { + test_table_elem(elem); + IHTMLElement_Release(elem); + } + hres = IHTMLDocument2_get_body(doc, &elem); ok(hres == S_OK, "get_body failed: %08x\n", hres); -- 2.32.0.93.g670b81a890