Alistair Leslie-Hughes : mshtml: Implement IHTMLDocument2 get_links.

Alexandre Julliard julliard at winehq.org
Wed Nov 26 07:32:36 CST 2008


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

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Sun Nov 23 21:02:17 2008 +1100

mshtml: Implement IHTMLDocument2 get_links.

---

 dlls/mshtml/htmldoc.c   |   29 +++++++++++++++++++++++++++--
 dlls/mshtml/tests/dom.c |   29 +++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 64efea8..28f6fa8 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -402,8 +402,33 @@ static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLEleme
 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
 {
     HTMLDocument *This = HTMLDOC_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsIDOMHTMLCollection *nscoll = NULL;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(!p)
+        return E_INVALIDARG;
+
+    *p = NULL;
+
+    if(!This->nsdoc) {
+        WARN("NULL nsdoc\n");
+        return E_UNEXPECTED;
+    }
+
+    nsres = nsIDOMHTMLDocument_GetLinks(This->nsdoc, &nscoll);
+    if(NS_FAILED(nsres)) {
+        ERR("GetLinks failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    if(nscoll) {
+        *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
+        nsIDOMElement_Release(nscoll);
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index ecb2f17..d22b22c 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2801,6 +2801,17 @@ static void test_defaults(IHTMLDocument2 *doc)
         IHTMLElementCollection_Release(collection);
     }
 
+    hres = IHTMLDocument2_get_links(doc, NULL);
+    ok(hres == E_INVALIDARG, "hres %08x\n", hres);
+
+    hres = IHTMLDocument2_get_links(doc, &collection);
+    ok(hres == S_OK, "get_links failed: %08x\n", hres);
+    if(hres == S_OK)
+    {
+        test_elem_collection((IUnknown*)collection, NULL, 0);
+        IHTMLElementCollection_Release(collection);
+    }
+
     hres = IHTMLElement_QueryInterface(elem, &IID_IHTMLBodyElement, (void**)&body);
     ok(hres == S_OK, "Could not get IHTMBodyElement: %08x\n", hres);
     test_default_body(body);
@@ -3081,7 +3092,7 @@ static void test_elems(IHTMLDocument2 *doc)
     IDispatch *disp;
     long type;
     HRESULT hres;
-    IHTMLElementCollection *colimages;
+    IHTMLElementCollection *collection;
 
     static const WCHAR imgidW[] = {'i','m','g','i','d',0};
     static const WCHAR inW[] = {'i','n',0};
@@ -3130,14 +3141,24 @@ static void test_elems(IHTMLDocument2 *doc)
     test_elem_col_item(col, xW, item_types, sizeof(item_types)/sizeof(item_types[0]));
     IHTMLElementCollection_Release(col);
 
-    hres = IHTMLDocument2_get_images(doc, &colimages);
+    hres = IHTMLDocument2_get_images(doc, &collection);
     ok(hres == S_OK, "get_images failed: %08x\n", hres);
     if(hres == S_OK)
     {
         static const elem_type_t images_types[] = {ET_IMG};
-        test_elem_collection((IUnknown*)colimages, images_types, 1);
+        test_elem_collection((IUnknown*)collection, images_types, 1);
+
+        IHTMLElementCollection_Release(collection);
+    }
 
-        IHTMLElementCollection_Release(colimages);
+    hres = IHTMLDocument2_get_links(doc, &collection);
+    ok(hres == S_OK, "get_links failed: %08x\n", hres);
+    if(hres == S_OK)
+    {
+        static const elem_type_t images_types[] = {ET_A};
+        test_elem_collection((IUnknown*)collection, images_types, 1);
+
+        IHTMLElementCollection_Release(collection);
     }
 
     elem = get_doc_elem(doc);




More information about the wine-cvs mailing list