Commit 84f1b60e authored by Santino Mazza's avatar Santino Mazza Committed by Alexandre Julliard

mshtml: Implement HTMLDocument_get_body for document fragments.

parent 071f38b1
......@@ -497,20 +497,30 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo
static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
{
HTMLDocumentNode *This = impl_from_IHTMLDocument2(iface);
nsIDOMHTMLElement *nsbody = NULL;
nsIDOMElement *nsbody = NULL;
HTMLElement *element;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
if(This->html_document) {
nsresult nsres;
nsres = nsIDOMHTMLDocument_GetBody(This->html_document, &nsbody);
nsres = nsIDOMHTMLDocument_GetBody(This->html_document, (nsIDOMHTMLElement **)&nsbody);
if(NS_FAILED(nsres)) {
TRACE("Could not get body: %08lx\n", nsres);
return E_UNEXPECTED;
}
}else {
nsAString nsnode_name;
nsIDOMDocumentFragment *frag;
nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag);
if(!NS_FAILED(nsres)) {
nsAString_InitDepend(&nsnode_name, L"BODY");
nsIDOMDocumentFragment_QuerySelector(frag, &nsnode_name, &nsbody);
nsAString_Finish(&nsnode_name);
nsIDOMDocumentFragment_Release(frag);
}
}
if(!nsbody) {
......@@ -518,8 +528,8 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
return S_OK;
}
hres = get_element((nsIDOMElement*)nsbody, &element);
nsIDOMHTMLElement_Release(nsbody);
hres = get_element(nsbody, &element);
nsIDOMElement_Release(nsbody);
if(FAILED(hres))
return hres;
......
......@@ -11081,9 +11081,9 @@ static void test_docfrag(IHTMLDocument2 *doc)
hres = IHTMLDocument2_get_body(frag, &frag_body);
ok(hres == S_OK, "get_body failed: %08lx\n", hres);
todo_wine ok(frag_body != NULL, "body == NULL\n");
ok(frag_body != NULL, "body == NULL\n");
if (frag_body) {
todo_wine ok(!iface_cmp((IUnknown *) frag_body, (IUnknown *) main_body), "frag_body == main_body\n");
ok(!iface_cmp((IUnknown *) frag_body, (IUnknown *) main_body), "frag_body == main_body\n");
IHTMLElement_Release(frag_body);
}
IHTMLElement_Release(main_body);
......
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