mshtml: Added IHTMLDOMTextNode::get_length implementation.

This commit is contained in:
Jacek Caban 2009-12-10 01:09:54 +01:00 committed by Alexandre Julliard
parent c8f1e9668a
commit 64b651e262
2 changed files with 47 additions and 3 deletions

View File

@ -35,6 +35,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
struct HTMLDOMTextNode { struct HTMLDOMTextNode {
HTMLDOMNode node; HTMLDOMNode node;
const IHTMLDOMTextNodeVtbl *lpIHTMLDOMTextNodeVtbl; const IHTMLDOMTextNodeVtbl *lpIHTMLDOMTextNodeVtbl;
nsIDOMText *nstext;
}; };
#define HTMLTEXT(x) (&(x)->lpIHTMLDOMTextNodeVtbl) #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) static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
{ {
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface); HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
FIXME("(%p)->(%p)\n", This, p); PRUint32 length = 0;
return E_NOTIMPL; 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) 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); HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
if(This->nstext)
IHTMLDOMTextNode_Release(This->nstext);
HTMLDOMNode_destructor(&This->node); HTMLDOMNode_destructor(&This->node);
} }
@ -195,7 +209,8 @@ static dispex_static_data_t HTMLDOMTextNode_dispex = {
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode) HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
{ {
HTMLDOMTextNode *ret ; HTMLDOMTextNode *ret;
nsresult nsres;
ret = heap_alloc_zero(sizeof(*ret)); ret = heap_alloc_zero(sizeof(*ret));
ret->node.vtbl = &HTMLDOMTextNodeImplVtbl; 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); init_dispex(&ret->node.dispex, (IUnknown*)HTMLTEXT(ret), &HTMLDOMTextNode_dispex);
HTMLDOMNode_Init(doc, &ret->node, nsnode); 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; return &ret->node;
} }

View File

@ -657,6 +657,17 @@ static IHTMLAnchorElement *_get_anchor_iface(unsigned line, IUnknown *unk)
return anchor; 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) #define test_node_name(u,n) _test_node_name(__LINE__,u,n)
static void _test_node_name(unsigned line, IUnknown *unk, const char *exname) 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); _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) #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) 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"); node = test_create_text(doc, "test");
test_ifaces((IUnknown*)node, text_iids); test_ifaces((IUnknown*)node, text_iids);
test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]"); test_disp((IUnknown*)node, &DIID_DispHTMLDOMTextNode, "[object]");
test_text_length((IUnknown*)node, 4);
V_VT(&var) = VT_NULL; V_VT(&var) = VT_NULL;
node2 = test_node_insertbefore((IUnknown*)body, node, &var); node2 = test_node_insertbefore((IUnknown*)body, node, &var);