Jacek Caban : mshtml: Added IHTMLTable::get_rows implementation.
Alexandre Julliard
julliard at winehq.org
Wed Oct 1 14:09:26 CDT 2008
Module: wine
Branch: master
Commit: ac4117fdb5fc809aac2d23616d849563b2244bdf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=ac4117fdb5fc809aac2d23616d849563b2244bdf
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Sep 30 17:45:48 2008 +0200
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 768dbee..cf11234 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<length; i++) {
+ nsIDOMHTMLCollection_Item(nscol, i, &nsnode);
+ buf.buf[i] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE));
+ nsIDOMNode_Release(nsnode);
+ }
+ }else {
+ buf.buf = NULL;
+ }
+
+ return HTMLElementCollection_Create(unk, buf.buf, buf.len);
+}
+
IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk,
HTMLElement **elems, DWORD len)
{
diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c
index 622f090..f43433d 100644
--- a/dlls/mshtml/htmltable.c
+++ b/dlls/mshtml/htmltable.c
@@ -274,8 +274,21 @@ static HRESULT WINAPI HTMLTable_refresh(IHTMLTable *iface)
static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollection **p)
{
HTMLTable *This = HTMLTABLE_THIS(iface);
- FIXME("(%p)->(%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 b14ad02..247dfa8 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 525bfd3..5e92dc5 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;
@@ -826,6 +825,19 @@ interface nsIDOMNSHTMLElement : nsISupports
[
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),
local
/* FROZEN */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index b8e57da..6e05ebb 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><tbody><tr></tr></tbody></table>"
+ "<table id=\"tbl\"><tbody><tr></tr><tr id=\"row2\"></tr></tbody></table>"
"<script id=\"sc\" type=\"text/javascript\"></script>"
"<test />"
"<img id=\"imgid\"/>"
@@ -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);
More information about the wine-cvs
mailing list