Commit a1e6835d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLElement::contains implementation.

parent d898f27a
...@@ -773,8 +773,26 @@ static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pC ...@@ -773,8 +773,26 @@ static HRESULT WINAPI HTMLElement_contains(IHTMLElement *iface, IHTMLElement *pC
VARIANT_BOOL *pfResult) VARIANT_BOOL *pfResult)
{ {
HTMLElement *This = impl_from_IHTMLElement(iface); HTMLElement *This = impl_from_IHTMLElement(iface);
FIXME("(%p)->(%p %p)\n", This, pChild, pfResult); HTMLElement *child;
return E_NOTIMPL; cpp_bool result;
nsresult nsres;
TRACE("(%p)->(%p %p)\n", This, pChild, pfResult);
child = unsafe_impl_from_IHTMLElement(pChild);
if(!child) {
ERR("not our element\n");
return E_FAIL;
}
nsres = nsIDOMNode_Contains(This->node.nsnode, child->node.nsnode, &result);
if(NS_FAILED(nsres)) {
ERR("failed\n");
return E_FAIL;
}
*pfResult = result ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
} }
static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p) static HRESULT WINAPI HTMLElement_get_sourceIndex(IHTMLElement *iface, LONG *p)
......
...@@ -2117,6 +2117,18 @@ static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer ...@@ -2117,6 +2117,18 @@ static void _test_elem_outerhtml(unsigned line, IUnknown *unk, const char *outer
SysFreeString(html); SysFreeString(html);
} }
#define test_elem_contains(a,b,c) _test_elem_contains(__LINE__,a,b,c)
static void _test_elem_contains(unsigned line, IHTMLElement *elem, IHTMLElement *elem2, VARIANT_BOOL exval)
{
VARIANT_BOOL b;
HRESULT hres;
b = 100;
hres = IHTMLElement_contains(elem, elem2, &b);
ok_(__FILE__,line)(hres == S_OK, "contains failed: %08x\n", hres);
ok_(__FILE__,line)(b == exval, "contains returned %x, expected %x\n", b, exval);
}
#define get_first_child(n) _get_first_child(__LINE__,n) #define get_first_child(n) _get_first_child(__LINE__,n)
static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk) static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
{ {
...@@ -5301,13 +5313,23 @@ static void test_elems(IHTMLDocument2 *doc) ...@@ -5301,13 +5313,23 @@ static void test_elems(IHTMLDocument2 *doc)
elem2 = test_elem_get_parent((IUnknown*)elem); elem2 = test_elem_get_parent((IUnknown*)elem);
ok(elem2 != NULL, "elem2 == NULL\n"); ok(elem2 != NULL, "elem2 == NULL\n");
test_node_name((IUnknown*)elem2, "BODY"); test_node_name((IUnknown*)elem2, "BODY");
elem3 = test_elem_get_parent((IUnknown*)elem2); elem3 = test_elem_get_parent((IUnknown*)elem2);
IHTMLElement_Release(elem2);
ok(elem3 != NULL, "elem3 == NULL\n"); ok(elem3 != NULL, "elem3 == NULL\n");
test_node_name((IUnknown*)elem3, "HTML"); test_node_name((IUnknown*)elem3, "HTML");
test_elem_contains(elem3, elem2, VARIANT_TRUE);
test_elem_contains(elem3, elem, VARIANT_TRUE);
test_elem_contains(elem2, elem, VARIANT_TRUE);
test_elem_contains(elem2, elem3, VARIANT_FALSE);
test_elem_contains(elem, elem3, VARIANT_FALSE);
test_elem_contains(elem, elem2, VARIANT_FALSE);
test_elem_contains(elem, elem, VARIANT_TRUE);
IHTMLElement_Release(elem2);
elem2 = test_elem_get_parent((IUnknown*)elem3); elem2 = test_elem_get_parent((IUnknown*)elem3);
IHTMLElement_Release(elem3);
ok(elem2 == NULL, "elem2 != NULL\n"); ok(elem2 == NULL, "elem2 != NULL\n");
IHTMLElement_Release(elem3);
test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2); test_elem_getelembytag((IUnknown*)elem, ET_OPTION, 2);
test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0); test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
......
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