Module: wine Branch: master Commit: f84d1f0aac98fce5746fb550b9397fbd16fa202d URL: http://source.winehq.org/git/wine.git/?a=commit;h=f84d1f0aac98fce5746fb550b9...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Aug 24 12:29:09 2017 +0200
mshtml: Added IHTMLDocument6::getElementById implementation.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/mshtml/htmldoc.c | 40 ++++++++++++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.c | 24 ++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index a8d104e..8d48e18 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -3142,8 +3142,44 @@ static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface, BSTR bstrId, IHTMLElement2 **p) { HTMLDocument *This = impl_from_IHTMLDocument6(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p); - return E_NOTIMPL; + nsIDOMElement *nselem; + HTMLElement *elem; + nsAString nsstr; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p); + + /* + * Unlike IHTMLDocument3 implementation, this is standard compliant and does + * not search for name attributes, so we may simply let Gecko do the right thing. + */ + + if(!This->doc_node->nsdoc) { + FIXME("Not a document\n"); + return E_FAIL; + } + + nsAString_InitDepend(&nsstr, bstrId); + nsres = nsIDOMHTMLDocument_GetElementById(This->doc_node->nsdoc, &nsstr, &nselem); + nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) { + ERR("GetElementById failed: %08x\n", nsres); + return E_FAIL; + } + + if(!nselem) { + *p = NULL; + return S_OK; + } + + hres = get_elem(This->doc_node, nselem, &elem); + nsIDOMElement_Release(nselem); + if(FAILED(hres)) + return hres; + + *p = &elem->IHTMLElement2_iface; + return S_OK; }
static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface) diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index c6053a6..a3a3bfe 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -9857,6 +9857,7 @@ static void test_frameset(IHTMLDocument2 *doc) { IHTMLWindow2 *window; IHTMLFramesCollection2 *frames; + IHTMLDocument6 *doc6; IHTMLElement *elem; HRESULT hres;
@@ -9887,6 +9888,29 @@ static void test_frameset(IHTMLDocument2 *doc) elem = get_doc_elem_by_id(doc, "nm1"); test_elem_id((IUnknown*)elem, "fr1");
+ hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument6, (void**)&doc6); + if(SUCCEEDED(hres)) { + IHTMLElement2 *elem2; + BSTR str; + + str = a2bstr("nm1"); + hres = IHTMLDocument6_getElementById(doc6, str, &elem2); + ok(hres == S_OK, "getElementById failed: %08x\n", hres); + ok(!elem2, "elem = %p\n", elem2); + SysFreeString(str); + + str = a2bstr("fr1"); + hres = IHTMLDocument6_getElementById(doc6, str, &elem2); + ok(hres == S_OK, "getElementById failed: %08x\n", hres); + ok(elem2 != NULL, "elem2 is NULL\n"); + test_elem_id((IUnknown*)elem2, "fr1"); + SysFreeString(str); + + IHTMLDocument6_Release(doc6); + }else { + win_skip("IHTMLDocument6 not supported\n"); + } + test_framebase((IUnknown*)elem); test_framebase_name(elem, "nm1"); test_framebase_put_name(elem, "frame name");