mshtml: Added IHTMLDocument6::getElementById implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2017-08-24 12:29:09 +02:00 committed by Alexandre Julliard
parent e81e14c894
commit f84d1f0aac
2 changed files with 62 additions and 2 deletions

View File

@ -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)

View File

@ -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");