Jacek Caban : mshtml: Added IHTMImgElement::get_src implementation.

Alexandre Julliard julliard at winehq.org
Tue Oct 14 08:29:34 CDT 2008


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Oct 13 14:50:37 2008 -0500

mshtml: Added IHTMImgElement::get_src implementation.

---

 dlls/mshtml/htmlimg.c        |   21 +++++++++++++++++++--
 dlls/mshtml/mshtml_private.h |    2 ++
 dlls/mshtml/nsio.c           |   17 +++++++++++++++++
 dlls/mshtml/tests/dom.c      |   17 +++++++++++++++++
 4 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index 795d6f9..e5c0372 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -280,8 +280,25 @@ static HRESULT WINAPI HTMLImgElement_put_src(IHTMLImgElement *iface, BSTR v)
 static HRESULT WINAPI HTMLImgElement_get_src(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_GetSrc(This->nsimg, &src_str);
+    if(NS_FAILED(nsres)) {
+        ERR("GetSrc failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsAString_GetData(&src_str, &src);
+    hres = nsuri_to_url(src, p);
+    nsAString_Finish(&src_str);
+
+    return hres;
 }
 
 static HRESULT WINAPI HTMLImgElement_put_lowsrc(IHTMLImgElement *iface, BSTR v)
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index ebdc251..888669f 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -502,6 +502,8 @@ void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
 BOOL install_wine_gecko(BOOL);
 
+HRESULT nsuri_to_url(LPCWSTR,BSTR*);
+
 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
 
 void call_property_onchanged(ConnectionPoint*,DISPID);
diff --git a/dlls/mshtml/nsio.c b/dlls/mshtml/nsio.c
index f23254a..82f7c0d 100644
--- a/dlls/mshtml/nsio.c
+++ b/dlls/mshtml/nsio.c
@@ -67,6 +67,23 @@ typedef struct {
 
 static nsresult create_uri(nsIURI*,NSContainer*,nsIWineURI**);
 
+HRESULT nsuri_to_url(LPCWSTR nsuri, BSTR *ret)
+{
+    const WCHAR *ptr = nsuri;
+
+    static const WCHAR wine_prefixW[] = {'w','i','n','e',':'};
+
+    if(!strncmpW(nsuri, wine_prefixW, sizeof(wine_prefixW)/sizeof(WCHAR)))
+        ptr += sizeof(wine_prefixW)/sizeof(WCHAR);
+
+    *ret = SysAllocString(ptr);
+    if(!*ret)
+        return E_OUTOFMEMORY;
+
+    TRACE("%s -> %s\n", debugstr_w(nsuri), debugstr_w(*ret));
+    return S_OK;
+}
+
 static BOOL exec_shldocvw_67(HTMLDocument *doc, LPCWSTR url)
 {
     IOleCommandTarget *cmdtrg = NULL;
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index f230389..350eb24 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -1316,6 +1316,20 @@ static void _elem_get_scroll_left(unsigned line, IUnknown *unk)
     ok(l == l2, "unexpected left %ld, expected %ld\n", l2, l);
 }
 
+#define test_img_src(i,s) _test_img_src(__LINE__,i,s)
+static void _test_img_src(unsigned line, IUnknown *unk, const char *exsrc)
+{
+    IHTMLImgElement *img = _get_img_iface(line, unk);
+    BSTR src;
+    HRESULT hres;
+
+    hres = IHTMLImgElement_get_src(img, &src);
+    IHTMLImgElement_Release(img);
+    ok_(__FILE__,line) (hres == S_OK, "get_src failed: %08x\n", hres);
+    ok_(__FILE__,line) (!strcmp_wa(src, exsrc), "get_src returned %s expected %s\n", dbgstr_w(src), exsrc);
+    SysFreeString(src);
+}
+
 #define test_img_set_src(u,s) _test_img_set_src(__LINE__,u,s)
 static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
 {
@@ -1328,6 +1342,8 @@ static void _test_img_set_src(unsigned line, IUnknown *unk, const char *src)
     IHTMLImgElement_Release(img);
     SysFreeString(tmp);
     ok_(__FILE__,line) (hres == S_OK, "put_src failed: %08x\n", hres);
+
+    _test_img_src(line, unk, src);
 }
 
 #define test_img_alt(u,a) _test_img_alt(__LINE__,u,a)
@@ -3077,6 +3093,7 @@ static void test_elems(IHTMLDocument2 *doc)
 
     elem = get_elem_by_id(doc, imgidW, TRUE);
     if(elem) {
+        test_img_src((IUnknown*)elem, "");
         test_img_set_src((IUnknown*)elem, "about:blank");
         test_img_alt((IUnknown*)elem, NULL);
         test_img_set_alt((IUnknown*)elem, "alt test");




More information about the wine-cvs mailing list