mshtml: Implement IHTMLDocument5 createComment.

This commit is contained in:
Alistair Leslie-Hughes 2009-01-16 19:59:28 +11:00 committed by Alexandre Julliard
parent be14da009a
commit bb983c824d
2 changed files with 49 additions and 3 deletions

View File

@ -124,8 +124,32 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs
IHTMLDOMNode **ppRetNode)
{
HTMLDocument *This = HTMLDOC5_THIS(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
return E_NOTIMPL;
nsIDOMComment *nscomment;
HTMLDOMNode *node;
nsAString str;
nsresult nsres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
if(!This->nsdoc) {
WARN("NULL nsdoc\n");
return E_UNEXPECTED;
}
nsAString_Init(&str, bstrdata);
nsres = nsIDOMHTMLDocument_CreateComment(This->nsdoc, &str, &nscomment);
nsAString_Finish(&str);
if(NS_FAILED(nsres)) {
ERR("CreateTextNode failed: %08x\n", nsres);
return E_FAIL;
}
node = &HTMLCommentElement_Create(This, (nsIDOMNode*)nscomment)->node;
nsIDOMElement_Release(nscomment);
*ppRetNode = HTMLDOMNODE(node);
IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
return S_OK;
}
static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)

View File

@ -3809,11 +3809,13 @@ static void test_elems(IHTMLDocument2 *doc)
static void test_create_elems(IHTMLDocument2 *doc)
{
IHTMLElement *elem, *body, *elem2;
IHTMLDOMNode *node, *node2, *node3;
IHTMLDOMNode *node, *node2, *node3, *comment;
IHTMLDocument5 *doc5;
IDispatch *disp;
VARIANT var;
long type;
HRESULT hres;
BSTR str;
static const elem_type_t types1[] = { ET_TESTG };
@ -3868,6 +3870,26 @@ static void test_create_elems(IHTMLDocument2 *doc)
test_elem_innertext(body, "insert test");
hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument5, (void**)&doc5);
if(hres == S_OK)
{
str = a2bstr("testing");
hres = IHTMLDocument5_createComment(doc5, str, &comment);
SysFreeString(str);
ok(hres == S_OK, "createComment failed: %08x\n", hres);
if(hres == S_OK)
{
type = get_node_type((IUnknown*)comment);
ok(type == 8, "type=%ld, expected 8\n", type);
test_node_get_value_str((IUnknown*)comment, "testing");
IHTMLDOMNode_Release(comment);
}
IHTMLDocument5_Release(doc5);
}
IHTMLElement_Release(body);
}