Jacek Caban : mshtml: Store style filter in HTMLStyle object.

Alexandre Julliard julliard at winehq.org
Mon Feb 28 11:02:11 CST 2011


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Feb 28 13:12:50 2011 +0100

mshtml: Store style filter in HTMLStyle object.

---

 dlls/mshtml/htmlstyle.c |   28 +++++++++++++++++++++-----
 dlls/mshtml/htmlstyle.h |    1 +
 dlls/mshtml/tests/dom.c |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index dffc39e..5bd69b1 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -633,6 +633,7 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
     if(!ref) {
         if(This->nsstyle)
             nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
+        heap_free(This->filter);
         release_dispex(&This->dispex);
         heap_free(This);
     }
@@ -2547,21 +2548,36 @@ static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
 static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
 {
     HTMLStyle *This = impl_from_IHTMLStyle(iface);
+    WCHAR *new_filter = NULL;
 
-    WARN("(%p)->(%s)\n", This, debugstr_w(v));
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    if(v) {
+        new_filter = heap_strdupW(v);
+        if(!new_filter)
+            return E_OUTOFMEMORY;
+    }
 
-    /* FIXME: Handle MS-style filters */
-    return set_style_attr(This, STYLEID_FILTER, v, 0);
+    heap_free(This->filter);
+    This->filter = new_filter;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
 {
     HTMLStyle *This = impl_from_IHTMLStyle(iface);
 
-    WARN("(%p)->(%p)\n", This, p);
+    TRACE("(%p)->(%p)\n", This, p);
+
+    if(This->filter) {
+        *p = SysAllocString(This->filter);
+        if(!*p)
+            return E_OUTOFMEMORY;
+    }else {
+        *p = NULL;
+    }
 
-    /* FIXME: Handle MS-style filters */
-    return get_style_attr(This, STYLEID_FILTER, p);
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h
index 6731584..9d2be65 100644
--- a/dlls/mshtml/htmlstyle.h
+++ b/dlls/mshtml/htmlstyle.h
@@ -26,6 +26,7 @@ struct HTMLStyle {
     LONG ref;
 
     nsIDOMCSSStyleDeclaration *nsstyle;
+    WCHAR *filter;
 };
 
 /* NOTE: Make sure to keep in sync with style_tbl in htmlstyle.c */
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index af1b991..b23f63c 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -5569,6 +5569,53 @@ static void test_default_style(IHTMLStyle *style)
     }
 }
 
+#define test_style_filter(a,b) _test_style_filter(__LINE__,a,b)
+static void _test_style_filter(unsigned line, IHTMLStyle *style, const char *exval)
+{
+    BSTR str;
+    HRESULT hres;
+
+    str = (void*)0xdeadbeef;
+    hres = IHTMLStyle_get_filter(style, &str);
+    ok_(__FILE__,line)(hres == S_OK, "get_filter failed: %08x\n", hres);
+    if(exval)
+        ok_(__FILE__,line)(str && !strcmp_wa(str, exval), "filter = %s, expected %s\n", wine_dbgstr_w(str), exval);
+    else
+        ok_(__FILE__,line)(!str, "str = %s, expected NULL\n", wine_dbgstr_w(str));
+
+    SysFreeString(str);
+}
+
+#define set_style_filter(a,b) _set_style_filter(__LINE__,a,b)
+static void _set_style_filter(unsigned line, IHTMLStyle *style, const char *val)
+{
+    BSTR str = a2bstr(val);
+    HRESULT hres;
+
+    hres = IHTMLStyle_put_filter(style, str);
+    ok_(__FILE__,line)(hres == S_OK, "put_filter failed: %08x\n", hres);
+    SysFreeString(str);
+
+    _test_style_filter(line, style, val);
+}
+
+static void test_style_filters(IHTMLElement *elem)
+{
+    IHTMLStyle *style;
+    HRESULT hres;
+
+    hres = IHTMLElement_get_style(elem, &style);
+    ok(hres == S_OK, "get_style failed: %08x\n", hres);
+
+    test_style_filter(style, NULL);
+    set_style_filter(style, "alpha(opacity=50.00000)");
+    set_style_filter(style, "alpha(opacity=100)");
+    set_style_filter(style, "xxx(a,b,c) alpha(opacity=100)");
+    set_style_filter(style, NULL);
+
+    IHTMLStyle_Release(style);
+}
+
 static void test_set_csstext(IHTMLStyle *style)
 {
     VARIANT v;
@@ -6770,6 +6817,7 @@ static void test_elems2(IHTMLDocument2 *doc)
     }
 
     test_attr(div);
+    test_style_filters(div);
 
     IHTMLElement_Release(div);
 }




More information about the wine-cvs mailing list