From: Jacek Caban Subject: mshtml: Added IHTMLDocument2::get_activeElement implementation. Message-Id: <52FDEDDE.1000502@codeweavers.com> Date: Fri, 14 Feb 2014 11:20:14 +0100 --- dlls/mshtml/htmldoc.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index a4a0fd7..a710d8e 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -186,8 +186,35 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p) { HTMLDocument *This = impl_from_IHTMLDocument2(iface); - FIXME("(%p)->(%p)\n", This, p); - return E_NOTIMPL; + nsIDOMElement *nselem; + HTMLElement *elem; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%p)\n", This, p); + + if(!This->doc_node->nsdoc) { + *p = NULL; + return S_OK; + } + + /* + * NOTE: Gecko may return an active element even if the document is not visible. + * IE returns NULL in this case. + */ + nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem); + if(NS_FAILED(nsres)) { + ERR("GetActiveElement failed: %08x\n", nsres); + return E_FAIL; + } + + hres = get_elem(This->doc_node, nselem, &elem); + nsIDOMElement_Release(nselem); + if(FAILED(hres)) + return hres; + + *p = &elem->IHTMLElement_iface; + return S_OK; } static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)