mshtml: Added get_nodeType implementation.

This commit is contained in:
Jacek Caban 2008-04-24 18:26:18 +02:00 committed by Alexandre Julliard
parent af271b3b45
commit bb05803a2a
2 changed files with 50 additions and 2 deletions

View File

@ -104,8 +104,30 @@ static HRESULT WINAPI HTMLDOMNode_Invoke(IHTMLDOMNode *iface, DISPID dispIdMembe
static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p) static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, long *p)
{ {
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface); HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); PRUint16 type = -1;
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, p);
nsIDOMNode_GetNodeType(This->nsnode, &type);
switch(type) {
case ELEMENT_NODE:
*p = 1;
break;
case TEXT_NODE:
*p = 3;
break;
default:
/*
* FIXME:
* According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
* It needs more tests.
*/
FIXME("type %u\n", type);
*p = 0;
}
return S_OK;
} }
static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p) static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p)

View File

@ -763,6 +763,24 @@ static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
return child; return child;
} }
#define get_node_type(n) _get_node_type(__LINE__,n)
static long _get_node_type(unsigned line, IUnknown *unk)
{
IHTMLDOMNode *node;
long type = -1;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMNode, (void**)&node);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMNode: %08x\n", hres);
hres = IHTMLDOMNode_get_nodeType(node, &type);
ok(hres == S_OK, "get_nodeType failed: %08x\n", hres);
IHTMLDOMNode_Release(node);
return type;
}
static void test_elem_col_item(IHTMLElementCollection *col, LPCWSTR n, static void test_elem_col_item(IHTMLElementCollection *col, LPCWSTR n,
const elem_type_t *elem_types, long len) const elem_type_t *elem_types, long len)
{ {
@ -1406,6 +1424,7 @@ static void test_elems(IHTMLDocument2 *doc)
IHTMLElement *elem; IHTMLElement *elem;
IHTMLDOMNode *node, *node2; IHTMLDOMNode *node, *node2;
IDispatch *disp; IDispatch *disp;
long type;
HRESULT hres; HRESULT hres;
static const WCHAR xW[] = {'x',0}; static const WCHAR xW[] = {'x',0};
@ -1484,6 +1503,9 @@ static void test_elems(IHTMLDocument2 *doc)
IHTMLDOMNode_Release(node); IHTMLDOMNode_Release(node);
} }
type = get_node_type((IUnknown*)select);
ok(type == 1, "type=%ld\n", type);
IHTMLSelectElement_Release(select); IHTMLSelectElement_Release(select);
IHTMLElement_Release(elem); IHTMLElement_Release(elem);
} }
@ -1512,9 +1534,13 @@ static void test_elems(IHTMLDocument2 *doc)
if(node) { if(node) {
test_ifaces((IUnknown*)node, text_iids); test_ifaces((IUnknown*)node, text_iids);
test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode); test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode);
node2 = get_first_child((IUnknown*)node); node2 = get_first_child((IUnknown*)node);
ok(!node2, "node2 != NULL\n"); ok(!node2, "node2 != NULL\n");
type = get_node_type((IUnknown*)node);
ok(type == 3, "type=%ld\n", type);
IHTMLDOMNode_Release(node); IHTMLDOMNode_Release(node);
} }