[PATCH] Implement IHTMLDocument3 getElementsByTagName

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Jan 20 04:22:24 CST 2009


---
 dlls/mshtml/htmldoc3.c  |   28 ++++++++++++++++++++++++++--
 dlls/mshtml/tests/dom.c |   19 +++++++++++++++++++
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c
index 533dedd..bfd0d23 100644
--- a/dlls/mshtml/htmldoc3.c
+++ b/dlls/mshtml/htmldoc3.c
@@ -458,8 +458,32 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface,
                                                          IHTMLElementCollection **pelColl)
 {
     HTMLDocument *This = HTMLDOC3_THIS(iface);
-    FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
-    return E_NOTIMPL;
+    nsIDOMNodeList *nslist;
+    nsAString id_str, ns_str;
+    nsresult nsres;
+    WCHAR str[] = {'*',0};
+
+    TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
+
+    if(!This->nsdoc) {
+        WARN("NULL nsdoc\n");
+        return E_UNEXPECTED;
+    }
+
+    nsAString_Init(&id_str, v);
+    nsAString_Init(&ns_str, str);
+    nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->nsdoc, &ns_str, &id_str, &nslist);
+    nsAString_Finish(&id_str);
+    nsAString_Finish(&ns_str);
+    if(FAILED(nsres)) {
+        ERR("GetElementByName failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    *pelColl = (IHTMLElementCollection*)create_collection_from_nodelist(This, (IUnknown*)HTMLDOC3(This), nslist);
+    nsIDOMNodeList_Release(nslist);
+
+    return S_OK;
 }
 
 #undef HTMLDOC3_THIS
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index e0a5f69..88eddc5 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -3418,6 +3418,8 @@ static void test_elems(IHTMLDocument2 *doc)
     long type;
     HRESULT hres;
     IHTMLElementCollection *collection;
+    IHTMLDocument3 *doc3;
+    BSTR str;
 
     static const WCHAR imgidW[] = {'i','m','g','i','d',0};
     static const WCHAR inW[] = {'i','n',0};
@@ -3804,6 +3806,23 @@ static void test_elems(IHTMLDocument2 *doc)
         }
     }
     IDispatch_Release(disp);
+
+    hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
+    ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
+
+    str = a2bstr("img");
+    hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
+    SysFreeString(str);
+    ok(hres == S_OK, "getElementByTag(%s) failed: %08x\n", dbgstr_w(ifrW), hres);
+    if(hres == S_OK)
+    {
+        static const elem_type_t img_types[] = { ET_IMG };
+
+        test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
+        IHTMLElementCollection_Release(col);
+    }
+
+    IHTMLDocument3_Release(doc3);
 }
 
 static void test_create_elems(IHTMLDocument2 *doc)
-- 
1.5.4.3


--------------020006070902070909050501--



More information about the wine-patches mailing list