Jacek Caban : mshtml: Set image size in IHTMLImageElementFactory::create.

Alexandre Julliard julliard at winehq.org
Tue Feb 9 10:37:55 CST 2010


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb  8 21:46:45 2010 +0100

mshtml: Set image size in IHTMLImageElementFactory::create.

---

 dlls/mshtml/htmlimg.c |   37 ++++++++++++++++++++++++++++++++++---
 1 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/dlls/mshtml/htmlimg.c b/dlls/mshtml/htmlimg.c
index aad1274..296db23 100644
--- a/dlls/mshtml/htmlimg.c
+++ b/dlls/mshtml/htmlimg.c
@@ -724,12 +724,38 @@ static HRESULT WINAPI HTMLImageElementFactory_Invoke(IHTMLImageElementFactory *i
     return E_NOTIMPL;
 }
 
+static LONG var_to_size(const VARIANT *v)
+{
+    switch(V_VT(v)) {
+    case VT_EMPTY:
+        return 0;
+    case VT_I4:
+        return V_I4(v);
+    case VT_BSTR: {
+        LONG ret;
+        HRESULT hres;
+
+        hres = VarI4FromStr(V_BSTR(v), 0, 0, &ret);
+        if(FAILED(hres)) {
+            FIXME("VarI4FromStr failed: %08x\n", hres);
+            return 0;
+        }
+        return ret;
+    }
+    default:
+        FIXME("unsupported size %s\n", debugstr_variant(v));
+    }
+    return 0;
+}
+
 static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *iface,
         VARIANT width, VARIANT height, IHTMLImgElement **img_elem)
 {
     HTMLImageElementFactory *This = HTMLIMGFACTORY_THIS(iface);
+    IHTMLImgElement *img;
     HTMLElement *elem;
     nsIDOMHTMLElement *nselem;
+    LONG l;
     HRESULT hres;
 
     static const PRUnichar imgW[] = {'I','M','G',0};
@@ -754,7 +780,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
         return E_FAIL;
     }
 
-    hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)img_elem);
+    hres = IHTMLElement_QueryInterface(HTMLELEM(elem), &IID_IHTMLImgElement, (void**)&img);
     if(FAILED(hres)) {
         ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
         return hres;
@@ -762,9 +788,14 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
 
     nsIDOMHTMLElement_Release(nselem);
 
-    if(V_VT(&width) != VT_EMPTY || V_VT(&height) != VT_EMPTY)
-        FIXME("Not setting image dimensions\n");
+    l = var_to_size(&width);
+    if(l)
+        IHTMLImgElement_put_width(img, l);
+    l = var_to_size(&height);
+    if(l)
+        IHTMLImgElement_put_height(img, l);
 
+    *img_elem = img;
     return S_OK;
 }
 




More information about the wine-cvs mailing list