diff --git a/dlls/mshtml/htmlbody.c b/dlls/mshtml/htmlbody.c index 6c7c48a46c1..ee23922ed4d 100644 --- a/dlls/mshtml/htmlbody.c +++ b/dlls/mshtml/htmlbody.c @@ -395,8 +395,33 @@ static HRESULT WINAPI HTMLBodyElement_get_onbeforeunload(IHTMLBodyElement *iface static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, IHTMLTxtRange **range) { HTMLBodyElement *This = HTMLBODY_THIS(iface); - FIXME("(%p)->(%p)\n", This, range); - return E_NOTIMPL; + nsIDOMRange *nsrange = NULL; + + TRACE("(%p)->(%p)\n", This, range); + + if(This->element->node->doc->nscontainer) { + nsIDOMDocument *nsdoc; + nsIDOMDocumentRange *nsdocrange; + nsresult nsres; + + nsIWebNavigation_GetDocument(This->element->node->doc->nscontainer->navigation, &nsdoc); + nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange); + nsIDOMDocument_Release(nsdoc); + + nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange); + if(NS_SUCCEEDED(nsres)) { + nsres = nsIDOMRange_SelectNodeContents(nsrange, This->element->node->nsnode); + if(NS_FAILED(nsres)) + ERR("SelectNodeContents failed: %08x\n", nsres); + }else { + ERR("CreateRange failed: %08x\n", nsres); + } + + nsIDOMDocumentRange_Release(nsdocrange); + } + + *range = HTMLTxtRange_Create(nsrange); + return S_OK; } static void HTMLBodyElement_destructor(IUnknown *iface) diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index a4c3fccfc42..85b0e30d9bc 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -685,6 +685,16 @@ interface nsIDOMRange : nsISupports nsresult Detach(); } +[ + object, + uuid(7b9badc6-c9bc-447a-8670-dbd195aed24b) + /* FROZEN */ +] +interface nsIDOMDocumentRange : nsISupports +{ + nsresult CreateRange(nsIDOMRange **_retval); +} + [ object, uuid(b2c7ed59-8634-4352-9e37-5484c8b6e4e1)