[PATCH] Implement IHTMLImgElement get_Name

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Sun Dec 13 04:15:28 CST 2009


---
 dlls/mshtml/htmlimg.c   |   21 +++++++++++++++++++--
 dlls/mshtml/tests/dom.c |   17 ++++++++++++++++-
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index 60333c6..17756fb 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -437,8 +437,25 @@ static HRESULT WINAPI HTMLImgElement_put_name(IHTMLImgElement *iface, BSTR v)
 static HRESULT WINAPI HTMLImgElement_get_name(IHTMLImgElement *iface, BSTR *p)
 {
     HTMLImgElement *This = HTMLIMG_THIS(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    const PRUnichar *src;
+    nsAString src_str;
+    nsresult nsres;
+    HRESULT hres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsAString_Init(&src_str, NULL);
+    nsres = nsIDOMHTMLImageElement_GetName(This->nsimg, &src_str);
+    if(NS_FAILED(nsres)) {
+        ERR("GetName failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsAString_GetData(&src_str, &src);
+    hres = nsuri_to_url(src, TRUE, p);
+    nsAString_Finish(&src_str);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLImgElement_put_width(IHTMLImgElement *iface, LONG v)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index e32e2fd..083561d 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -49,7 +49,7 @@ static const char elem_test_str[] =
     "<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\"><!--\nfunction Testing() {}\n// -->\n</script>"
     "<test />"
-    "<img id=\"imgid\"/>"
+    "<img id=\"imgid\" name=\"WineImg\"/>"
     "<iframe src=\"about:blank\" id=\"ifr\"></iframe>"
     "<form id=\"frm\"></form>"
     "</body></html>";
@@ -1927,6 +1927,20 @@ static void _test_img_set_alt(unsigned line, IUnknown *unk, const char *alt)
     _test_img_alt(line, unk, alt);
 }
 
+#define test_img_name(u) _test_img_name(__LINE__,u)
+static void _test_img_name(unsigned line, IUnknown *unk)
+{
+    IHTMLImgElement *img = _get_img_iface(line, unk);
+    BSTR sName;
+    HRESULT hres;
+
+    hres = IHTMLImgElement_get_name(img, &sName);
+    ok_(__FILE__,line) (hres == S_OK, "get_Name failed: %08x\n", hres);
+    ok_(__FILE__,line) (!strcmp_wa (sName, "WineImg"), "expected 'WineImg' got '%s'\n", wine_dbgstr_w(sName));
+    SysFreeString(sName);
+}
+
+
 #define test_input_get_disabled(i,b) _test_input_get_disabled(__LINE__,i,b)
 static void _test_input_get_disabled(unsigned line, IHTMLInputElement *input, VARIANT_BOOL exb)
 {
@@ -5486,6 +5500,7 @@ static void test_elems(IHTMLDocument2 *doc)
         test_img_set_src((IUnknown*)elem, "about:blank");
         test_img_alt((IUnknown*)elem, NULL);
         test_img_set_alt((IUnknown*)elem, "alt test");
+        test_img_name((IUnknown*)elem);
         IHTMLElement_Release(elem);
     }
 
-- 
1.6.2.5


--------------040003080208070300080700--



More information about the wine-patches mailing list