Module: wine Branch: master Commit: bb983c824d1b2065bceeba219117e0861367a786 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bb983c824d1b2065bceeba2191...
Author: Alistair Leslie-Hughes leslie_alistair@hotmail.com Date: Fri Jan 16 19:59:28 2009 +1100
mshtml: Implement IHTMLDocument5 createComment.
---
dlls/mshtml/htmldoc5.c | 28 ++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 24 +++++++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmldoc5.c b/dlls/mshtml/htmldoc5.c index 34dc4e0..bd54cc4 100644 --- a/dlls/mshtml/htmldoc5.c +++ b/dlls/mshtml/htmldoc5.c @@ -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) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 777c425..e0a5f69 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -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); }