mshtml: Added IHTMLElement::get_innerText implementation.
This commit is contained in:
parent
a0ba631d86
commit
d05e328db2
|
@ -839,8 +839,10 @@ static HRESULT WINAPI HTMLElement_put_innerText(IHTMLElement *iface, BSTR v)
|
|||
static HRESULT WINAPI HTMLElement_get_innerText(IHTMLElement *iface, BSTR *p)
|
||||
{
|
||||
HTMLElement *This = HTMLELEM_THIS(iface);
|
||||
FIXME("(%p)->(%p)\n", This, p);
|
||||
return E_NOTIMPL;
|
||||
|
||||
TRACE("(%p)->(%p)\n", This, p);
|
||||
|
||||
return get_node_text(&This->node, p);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI HTMLElement_put_outerHTML(IHTMLElement *iface, BSTR v)
|
||||
|
|
|
@ -550,6 +550,7 @@ IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetLis
|
|||
|
||||
void detach_selection(HTMLDocument*);
|
||||
void detach_ranges(HTMLDocument*);
|
||||
HRESULT get_node_text(HTMLDOMNode*,BSTR*);
|
||||
|
||||
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocument*,nsIDOMNode*);
|
||||
|
||||
|
|
|
@ -1014,6 +1014,19 @@ static void _test_elem_getelembytag(unsigned line, IUnknown *unk, elem_type_t ty
|
|||
HeapFree(GetProcessHeap(), 0, types);
|
||||
}
|
||||
|
||||
#define test_elem_innertext(e,t) _test_elem_innertext(__LINE__,e,t)
|
||||
static void _test_elem_innertext(unsigned line, IHTMLElement *elem, const char *extext)
|
||||
{
|
||||
BSTR text = NULL;
|
||||
HRESULT hres;
|
||||
|
||||
hres = IHTMLElement_get_innerText(elem, &text);
|
||||
ok_(__FILE__,line) (hres == S_OK, "get_innerText failed: %08x\n", hres);
|
||||
ok_(__FILE__,line) (!strcmp_wa(text, extext), "get_innerText returned %s expected %s\n",
|
||||
dbgstr_w(text), extext);
|
||||
SysFreeString(text);
|
||||
}
|
||||
|
||||
#define get_first_child(n) _get_first_child(__LINE__,n)
|
||||
static IHTMLDOMNode *_get_first_child(unsigned line, IUnknown *unk)
|
||||
{
|
||||
|
@ -2942,6 +2955,8 @@ static void test_elems(IHTMLDocument2 *doc)
|
|||
test_elem_getelembytag((IUnknown*)elem, ET_SELECT, 0);
|
||||
test_elem_getelembytag((IUnknown*)elem, ET_HTML, 0);
|
||||
|
||||
test_elem_innertext(elem, "opt1opt2");
|
||||
|
||||
IHTMLElement_Release(elem);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ static void wstrbuf_append_node(wstrbuf_t *buf, nsIDOMNode *node)
|
|||
wstrbuf_append_nodetxt(buf, data, strlenW(data));
|
||||
nsAString_Finish(&data_str);
|
||||
|
||||
nsIDOMText_Release(nstext);
|
||||
nsIDOMText_Release(nstext);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -267,6 +267,21 @@ static void wstrbuf_append_node(wstrbuf_t *buf, nsIDOMNode *node)
|
|||
}
|
||||
}
|
||||
|
||||
static void wstrbuf_append_node_rec(wstrbuf_t *buf, nsIDOMNode *node)
|
||||
{
|
||||
nsIDOMNode *iter, *tmp;
|
||||
|
||||
wstrbuf_append_node(buf, node);
|
||||
|
||||
nsIDOMNode_GetFirstChild(node, &iter);
|
||||
while(iter) {
|
||||
wstrbuf_append_node_rec(buf, iter);
|
||||
nsIDOMNode_GetNextSibling(iter, &tmp);
|
||||
nsIDOMNode_Release(iter);
|
||||
iter = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL fill_nodestr(dompos_t *pos)
|
||||
{
|
||||
nsIDOMText *text;
|
||||
|
@ -529,6 +544,27 @@ static void range_to_string(HTMLTxtRange *This, wstrbuf_t *buf)
|
|||
}
|
||||
}
|
||||
|
||||
HRESULT get_node_text(HTMLDOMNode *node, BSTR *ret)
|
||||
{
|
||||
wstrbuf_t buf;
|
||||
HRESULT hres = S_OK;
|
||||
|
||||
wstrbuf_init(&buf);
|
||||
wstrbuf_append_node_rec(&buf, node->nsnode);
|
||||
if(buf.buf) {
|
||||
*ret = SysAllocString(buf.buf);
|
||||
if(!*ret)
|
||||
hres = E_OUTOFMEMORY;
|
||||
}else {
|
||||
*ret = NULL;
|
||||
}
|
||||
wstrbuf_finish(&buf);
|
||||
|
||||
if(SUCCEEDED(hres))
|
||||
TRACE("ret %s\n", debugstr_w(*ret));
|
||||
return hres;
|
||||
}
|
||||
|
||||
static WCHAR get_pos_char(const dompos_t *pos)
|
||||
{
|
||||
switch(pos->type) {
|
||||
|
|
Loading…
Reference in New Issue