mshtml: Added IHTMLStyleElement::media property implementation.

oldstable
Jacek Caban 2010-12-17 03:39:24 +01:00 committed by Alexandre Julliard
parent 96efe799c1
commit 09c63b2215
3 changed files with 103 additions and 5 deletions

View File

@ -36,6 +36,8 @@ typedef struct {
HTMLElement element;
const IHTMLStyleElementVtbl *lpIHTMLStyleElementVtbl;
nsIDOMHTMLStyleElement *nsstyle;
} HTMLStyleElement;
#define HTMLSTYLE(x) (&(x)->lpIHTMLStyleElementVtbl)
@ -180,15 +182,33 @@ static HRESULT WINAPI HTMLStyleElement_get_disabled(IHTMLStyleElement *iface, VA
static HRESULT WINAPI HTMLStyleElement_put_media(IHTMLStyleElement *iface, BSTR v)
{
HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
return E_NOTIMPL;
nsAString media_str;
nsresult nsres;
TRACE("(%p)->(%s)\n", This, debugstr_w(v));
nsAString_InitDepend(&media_str, v);
nsres = nsIDOMHTMLStyleElement_SetMedia(This->nsstyle, &media_str);
nsAString_Finish(&media_str);
if(NS_FAILED(nsres)) {
ERR("SetMedia failed: %08x\n", nsres);
return E_FAIL;
}
return S_OK;
}
static HRESULT WINAPI HTMLStyleElement_get_media(IHTMLStyleElement *iface, BSTR *p)
{
HTMLStyleElement *This = HTMLSTYLE_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsAString_Init(&nsstr, NULL);
nsres = nsIDOMHTMLStyleElement_GetMedia(This->nsstyle, &nsstr);
return return_nsstr(nsres, &nsstr, p);
}
#undef HTMLSTYLE_THIS
@ -244,6 +264,9 @@ static void HTMLStyleElement_destructor(HTMLDOMNode *iface)
{
HTMLStyleElement *This = HTMLSTYLE_NODE_THIS(iface);
if(This->nsstyle)
nsIDOMHTMLStyleElement_Release(This->nsstyle);
HTMLElement_destructor(&This->element.node);
}
@ -270,6 +293,7 @@ static dispex_static_data_t HTMLStyleElement_dispex = {
HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
HTMLStyleElement *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(*ret));
if(!ret)
@ -278,6 +302,13 @@ HRESULT HTMLStyleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem
ret->lpIHTMLStyleElementVtbl = &HTMLStyleElementVtbl;
ret->element.node.vtbl = &HTMLStyleElementImplVtbl;
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLStyleElement, (void**)&ret->nsstyle);
if(NS_FAILED(nsres)) {
ERR("Could not get nsIDOMHTMLStyleElement iface: %08x\n", nsres);
heap_free(ret);
return E_FAIL;
}
HTMLElement_Init(&ret->element, doc, nselem, &HTMLStyleElement_dispex);
*elem = &ret->element;
return S_OK;

View File

@ -1702,6 +1702,21 @@ interface nsIDOMHTMLParamElement : nsIDOMHTMLElement
nsresult SetValueType(const nsAString *aValueType);
}
[
object,
uuid(a6cf908d-15b3-11d2-932e-00805f8add32),
local
]
interface nsIDOMHTMLStyleElement : nsIDOMHTMLElement
{
nsresult GetDisabled(PRBool *aDisabled);
nsresult SetDisabled(PRBool aDisabled);
nsresult GetMedia(nsAString *aMedia);
nsresult SetMedia(const nsAString *aMedia);
nsresult GetType(nsAString *aType);
nsresult SetType(const nsAString *aType);
}
[
object,
uuid(94928ab3-8b63-11d3-989d-001083010e9b),

View File

@ -40,7 +40,7 @@ static const char range_test_str[] =
static const char range_test2_str[] =
"<html><body>abc<hr />123<br /><hr />def</body></html>";
static const char elem_test_str[] =
"<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
"<html><head><title>test</title><style id=\"styleid\">.body { margin-right: 0px; }</style>"
"<body onload=\"Testing()\">text test<!-- a comment -->"
"<a id=\"a\" href=\"http://test\" name=\"x\">link</a>"
"<input id=\"in\" class=\"testclass\" tabIndex=\"2\" title=\"test title\" />"
@ -787,6 +787,17 @@ static IHTMLObjectElement *_get_object_iface(unsigned line, IUnknown *unk)
return obj;
}
#define get_style_iface(u) _get_style_iface(__LINE__,u)
static IHTMLStyleElement *_get_style_iface(unsigned line, IUnknown *unk)
{
IHTMLStyleElement *obj;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLStyleElement, (void**)&obj);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLStyleElement: %08x\n", hres);
return obj;
}
#define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
{
@ -2435,6 +2446,40 @@ static void _test_elem_set_tabindex(unsigned line, IUnknown *unk, short index)
_test_elem_tabindex(line, unk, index);
}
#define test_style_media(s,m) _test_style_media(__LINE__,s,m)
static void _test_style_media(unsigned line, IUnknown *unk, const char *exmedia)
{
IHTMLStyleElement *style = _get_style_iface(line, unk);
BSTR media;
HRESULT hres;
hres = IHTMLStyleElement_get_media(style, &media);
ok_(__FILE__,line)(hres == S_OK, "get_media failed: %08x\n", hres);
if(exmedia)
ok_(__FILE__,line)(!strcmp_wa(media, exmedia), "media = %s, expected %s\n", wine_dbgstr_w(media), exmedia);
else
ok_(__FILE__,line)(!media, "media = %s, expected NULL\n", wine_dbgstr_w(media));
IHTMLStyleElement_Release(style);
SysFreeString(media);
}
#define test_style_put_media(s,m) _test_style_put_media(__LINE__,s,m)
static void _test_style_put_media(unsigned line, IUnknown *unk, const char *media)
{
IHTMLStyleElement *style = _get_style_iface(line, unk);
BSTR str;
HRESULT hres;
str = a2bstr(media);
hres = IHTMLStyleElement_put_media(style, str);
ok_(__FILE__,line)(hres == S_OK, "put_media failed: %08x\n", hres);
IHTMLStyleElement_Release(style);
SysFreeString(str);
_test_style_media(line, unk, media);
}
#define test_elem_filters(u) _test_elem_filters(__LINE__,u)
static void _test_elem_filters(unsigned line, IUnknown *unk)
{
@ -6279,6 +6324,13 @@ static void test_elems(IHTMLDocument2 *doc)
IHTMLElement_Release(elem);
}
elem = get_elem_by_id(doc, "styleid", TRUE);
if(elem) {
test_style_media((IUnknown*)elem, NULL);
test_style_put_media((IUnknown*)elem, "screen");
IHTMLElement_Release(elem);
}
elem = get_doc_elem_by_id(doc, "tbl");
ok(elem != NULL, "elem == NULL\n");
if(elem) {