Commit 64b651e2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLDOMTextNode::get_length implementation.

parent c8f1e966
......@@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
struct HTMLDOMTextNode {
HTMLDOMNode node;
const IHTMLDOMTextNodeVtbl *lpIHTMLDOMTextNodeVtbl;
nsIDOMText *nstext;
};
#define HTMLTEXT(x) (&(x)->lpIHTMLDOMTextNodeVtbl)
......@@ -119,8 +121,17 @@ static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *St
static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
{
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
FIXME("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
PRUint32 length = 0;
nsresult nsres;
TRACE("(%p)->(%p)\n", This, p);
nsres = nsIDOMText_GetLength(This->nstext, &length);
if(NS_FAILED(nsres))
ERR("GetLength failed: %08x\n", nsres);
*p = length;
return S_OK;
}
static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
......@@ -170,6 +181,9 @@ static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface)
{
HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
if(This->nstext)
IHTMLDOMTextNode_Release(This->nstext);
HTMLDOMNode_destructor(&This->node);
}
......@@ -195,7 +209,8 @@ static dispex_static_data_t HTMLDOMTextNode_dispex = {
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
{
HTMLDOMTextNode *ret ;
HTMLDOMTextNode *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(*ret));
ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
......@@ -204,5 +219,9 @@ HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
init_dispex(&ret->node.dispex, (IUnknown*)HTMLTEXT(ret), &HTMLDOMTextNode_dispex);
HTMLDOMNode_Init(doc, &ret->node, nsnode);
nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMText iface: %08x\n", nsres);
return &ret->node;
}
......@@ -657,6 +657,17 @@ static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
return anchor;
}
#define get_text_iface(u) _get_text_iface(__LINE__,u)
static IHTMLDOMTextNode *_get_text_iface(unsigned line, IUnknown *unk)
{
IHTMLDOMTextNode *text;
HRESULT hres;
hres = IUnknown_QueryInterface(unk, &IID_IHTMLDOMTextNode, (void**)&text);
ok_(__FILE__,line) (hres == S_OK, "Could not get IHTMLDOMTextNode: %08x\n", hres);
return text;
}
#define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname)
{
......@@ -1738,6 +1749,19 @@ static void _test_select_get_disabled(unsigned line, IHTMLSelectElement *select,
_test_elem3_get_disabled(line, (IUnknown*)select, exb);
}
#define test_text_length(u,l) _test_text_length(__LINE__,u,l)
static void _test_text_length(unsigned line, IUnknown *unk, LONG l)
{
IHTMLDOMTextNode *text = _get_text_iface(line, unk);
LONG length;
HRESULT hres;
hres = IHTMLDOMTextNode_get_length(text, &length);
ok_(__FILE__,line)(hres == S_OK, "get_length failed: %08x\n", hres);
ok_(__FILE__,line)(length == l, "length = %d, expected %d\n", length, l);
IHTMLDOMTextNode_Release(text);
}
#define test_select_set_disabled(i,b) _test_select_set_disabled(__LINE__,i,b)
static void _test_select_set_disabled(unsigned line, IHTMLSelectElement *select, VARIANT_BOOL b)
{
......@@ -5718,6 +5742,7 @@ static void test_create_elems(IHTMLDocument2 *doc)
node = test_create_text(doc, "test");
test_ifaces((IUnknown*)node, text_iids);
test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
test_text_length((IUnknown*)node, 4);
V_VT(&var) = VT_NULL;
node2 = test_node_insertbefore((IUnknown*)body, node, &var);
......
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