Module: wine Branch: master Commit: 84f1b60e331cc77f94301c55c98592eddff5672c URL: https://gitlab.winehq.org/wine/wine/-/commit/84f1b60e331cc77f94301c55c98592e...
Author: Santino Mazza smazza@codeweavers.com Date: Mon Dec 19 19:54:57 2022 -0300
mshtml: Implement HTMLDocument_get_body for document fragments.
---
dlls/mshtml/htmldoc.c | 22 ++++++++++++++++------ dlls/mshtml/tests/dom.c | 4 ++-- 2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 7b71ec1c1ae..414a39ae702 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -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;
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 4e92c1c1447..dc236a27f1c 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -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);