Commit 0131e047 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Store style filter in HTMLStyle object.

parent 62428749
...@@ -633,6 +633,7 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface) ...@@ -633,6 +633,7 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
if(!ref) { if(!ref) {
if(This->nsstyle) if(This->nsstyle)
nsIDOMCSSStyleDeclaration_Release(This->nsstyle); nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
heap_free(This->filter);
release_dispex(&This->dispex); release_dispex(&This->dispex);
heap_free(This); heap_free(This);
} }
...@@ -2547,21 +2548,36 @@ static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p) ...@@ -2547,21 +2548,36 @@ static HRESULT WINAPI HTMLStyle_get_clip(IHTMLStyle *iface, BSTR *p)
static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v) static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
{ {
HTMLStyle *This = impl_from_IHTMLStyle(iface); 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 */ heap_free(This->filter);
return set_style_attr(This, STYLEID_FILTER, v, 0); This->filter = new_filter;
return S_OK;
} }
static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p) static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
{ {
HTMLStyle *This = impl_from_IHTMLStyle(iface); 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 S_OK;
return get_style_attr(This, STYLEID_FILTER, p);
} }
static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName, static HRESULT WINAPI HTMLStyle_setAttribute(IHTMLStyle *iface, BSTR strAttributeName,
......
...@@ -26,6 +26,7 @@ struct HTMLStyle { ...@@ -26,6 +26,7 @@ struct HTMLStyle {
LONG ref; LONG ref;
nsIDOMCSSStyleDeclaration *nsstyle; nsIDOMCSSStyleDeclaration *nsstyle;
WCHAR *filter;
}; };
/* NOTE: Make sure to keep in sync with style_tbl in htmlstyle.c */ /* NOTE: Make sure to keep in sync with style_tbl in htmlstyle.c */
......
...@@ -5569,6 +5569,53 @@ static void test_default_style(IHTMLStyle *style) ...@@ -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) static void test_set_csstext(IHTMLStyle *style)
{ {
VARIANT v; VARIANT v;
...@@ -6770,6 +6817,7 @@ static void test_elems2(IHTMLDocument2 *doc) ...@@ -6770,6 +6817,7 @@ static void test_elems2(IHTMLDocument2 *doc)
} }
test_attr(div); test_attr(div);
test_style_filters(div);
IHTMLElement_Release(div); IHTMLElement_Release(div);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment