Commit 9608714d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLLinkElement::disabled property implementation.

parent b75e2c4d
......@@ -17,6 +17,7 @@
*/
#include <stdarg.h>
#include <assert.h>
#define COBJMACROS
......@@ -34,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct {
HTMLElement element;
IHTMLLinkElement IHTMLLinkElement_iface;
nsIDOMHTMLLinkElement *nslink;
} HTMLLinkElement;
static inline HTMLLinkElement *impl_from_IHTMLLinkElement(IHTMLLinkElement *iface)
......@@ -214,15 +217,28 @@ static HRESULT WINAPI HTMLLinkElement_get_styleSheet(IHTMLLinkElement *iface, IH
static HRESULT WINAPI HTMLLinkElement_put_disabled(IHTMLLinkElement *iface, VARIANT_BOOL v)
{
HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
FIXME("(%p)->(%x)\n", This, v);
return E_NOTIMPL;
nsresult nsres;
TRACE("(%p)->(%x)\n", This, v);
nsres = nsIDOMHTMLLinkElement_SetDisabled(This->nslink, !!v);
return SUCCEEDED(nsres) ? S_OK : E_FAIL;
}
static HRESULT WINAPI HTMLLinkElement_get_disabled(IHTMLLinkElement *iface, VARIANT_BOOL *p)
{
HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
cpp_bool ret;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMHTMLLinkElement_GetDisabled(This->nslink, &ret);
if(NS_FAILED(nsres))
return E_FAIL;
*p = ret ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
static HRESULT WINAPI HTMLLinkElement_put_media(IHTMLLinkElement *iface, BSTR v)
......@@ -289,19 +305,28 @@ static HRESULT HTMLLinkElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
return S_OK;
}
static void HTMLLinkElement_destructor(HTMLDOMNode *iface)
static HRESULT HTMLLinkElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
{
HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
return IHTMLLinkElement_put_disabled(&This->IHTMLLinkElement_iface, v);
}
HTMLElement_destructor(&This->element.node);
static HRESULT HTMLLinkElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
{
HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
return IHTMLLinkElement_get_disabled(&This->IHTMLLinkElement_iface, p);
}
static const NodeImplVtbl HTMLLinkElementImplVtbl = {
HTMLLinkElement_QI,
HTMLLinkElement_destructor,
HTMLElement_destructor,
HTMLElement_clone,
HTMLElement_handle_event,
HTMLElement_get_attr_col
HTMLElement_get_attr_col,
NULL,
NULL,
HTMLLinkElementImpl_put_disabled,
HTMLLinkElementImpl_get_disabled,
};
static const tid_t HTMLLinkElement_iface_tids[] = {
......@@ -319,6 +344,7 @@ static dispex_static_data_t HTMLLinkElement_dispex = {
HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
{
HTMLLinkElement *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(*ret));
if(!ret)
......@@ -329,6 +355,12 @@ HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
HTMLElement_Init(&ret->element, doc, nselem, &HTMLLinkElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLLinkElement, (void**)&ret->nslink);
/* Share nslink reference with nsnode */
assert(nsres == NS_OK && (nsIDOMNode*)ret->nslink == ret->element.node.nsnode);
nsIDOMNode_Release(ret->element.node.nsnode);
*elem = &ret->element;
return S_OK;
}
......@@ -1902,6 +1902,33 @@ interface nsIDOMHTMLAnchorElement : nsIDOMHTMLElement
[
object,
uuid(59ae3529-170a-41e4-8d7a-241dca6b5760),
local
]
interface nsIDOMHTMLLinkElement : nsIDOMHTMLElement
{
nsresult GetDisabled(bool *aDisabled);
nsresult SetDisabled(bool aDisabled);
nsresult GetCharset(nsAString *aCharset);
nsresult SetCharset(const nsAString *aCharset);
nsresult GetHref(nsAString *aHref);
nsresult SetHref(const nsAString *aHref);
nsresult GetHreflang(nsAString *aHreflang);
nsresult SetHreflang(const nsAString *aHreflang);
nsresult GetMedia(nsAString *aMedia);
nsresult SetMedia(const nsAString *aMedia);
nsresult GetRel(nsAString *aRel);
nsresult SetRel(const nsAString *aRel);
nsresult GetRev(nsAString *aRev);
nsresult SetRev(const nsAString *aRev);
nsresult GetTarget(nsAString *aTarget);
nsresult SetTarget(const nsAString *aTarget);
nsresult GetType(nsAString *aType);
nsresult SetType(const nsAString *aType);
}
[
object,
uuid(ae50de74-bc26-402e-85dc-a980f506b655),
local
]
......
......@@ -64,6 +64,7 @@ static const char elem_test_str[] =
"</body></html>";
static const char elem_test2_str[] =
"<html><head><title>test</title><style>.body { margin-right: 0px; }</style>"
"<link id=\"linkid\" rel=\"stylesheet\" href=\"some.css\" type=\"text/css\"></head>"
"<body><div id=\"divid\" emptyattr=\"\" onclick=\"parseInt();\"></div></body>"
"</html>";
......@@ -866,6 +867,17 @@ static IHTMLMetaElement *_get_metaelem_iface(unsigned line, IUnknown *unk)
return ret;
}
#define get_link_iface(u) _get_link_iface(__LINE__,u)
static IHTMLLinkElement *_get_link_iface(unsigned line, IUnknown *unk)
{
IHTMLLinkElement *ret;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLLinkElement, (void**)&ret);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLLinkElement: %08x\n", hres);
return ret;
}
#define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
{
......@@ -3415,6 +3427,32 @@ static void _test_meta_httpequiv(unsigned line, IUnknown *unk, const char *exval
IHTMLMetaElement_Release(meta);
}
#define test_link_disabled(a,b) _test_link_disabled(__LINE__,a,b)
static void _test_link_disabled(unsigned line, IHTMLElement *elem, VARIANT_BOOL v)
{
IHTMLLinkElement *link = _get_link_iface(line, (IUnknown*)elem);
VARIANT_BOOL b = 10;
HRESULT hres;
hres = IHTMLLinkElement_get_disabled(link, &b);
ok_(__FILE__,line)(hres == S_OK, "get_disabled failed: %08x\n", hres);
ok_(__FILE__,line)(b == v, "disabled = %x, expected %x\n", b, v);
IHTMLLinkElement_Release(link);
}
#define link_put_disabled(a,b) _link_put_disabled(__LINE__,a,b)
static void _link_put_disabled(unsigned line, IHTMLElement *elem, VARIANT_BOOL v)
{
IHTMLLinkElement *link = _get_link_iface(line, (IUnknown*)elem);
HRESULT hres;
hres = IHTMLLinkElement_put_disabled(link, v);
ok_(__FILE__,line)(hres == S_OK, "put_disabled failed: %08x\n", hres);
IHTMLLinkElement_Release(link);
_test_link_disabled(line, elem, v);
}
#define get_elem_doc(e) _get_elem_doc(__LINE__,e)
static IHTMLDocument2 *_get_elem_doc(unsigned line, IUnknown *unk)
{
......@@ -5913,6 +5951,13 @@ static void test_elems2(IHTMLDocument2 *doc)
div = get_doc_elem_by_id(doc, "divid");
elem = get_elem_by_id(doc, "linkid", TRUE);
if(elem) {
test_link_disabled(elem, VARIANT_FALSE);
link_put_disabled(elem, VARIANT_TRUE);
IHTMLElement_Release(elem);
}
test_elem_set_innerhtml((IUnknown*)div, "<div id=\"innerid\"></div>");
elem2 = get_doc_elem_by_id(doc, "innerid");
ok(elem2 != NULL, "elem2 == NULL\n");
......
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