Commit f84d1f0a authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLDocument6::getElementById implementation.

parent e81e14c8
...@@ -3142,8 +3142,44 @@ static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface, ...@@ -3142,8 +3142,44 @@ static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
BSTR bstrId, IHTMLElement2 **p) BSTR bstrId, IHTMLElement2 **p)
{ {
HTMLDocument *This = impl_from_IHTMLDocument6(iface); HTMLDocument *This = impl_from_IHTMLDocument6(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p); nsIDOMElement *nselem;
return E_NOTIMPL; 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) static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
......
...@@ -9857,6 +9857,7 @@ static void test_frameset(IHTMLDocument2 *doc) ...@@ -9857,6 +9857,7 @@ static void test_frameset(IHTMLDocument2 *doc)
{ {
IHTMLWindow2 *window; IHTMLWindow2 *window;
IHTMLFramesCollection2 *frames; IHTMLFramesCollection2 *frames;
IHTMLDocument6 *doc6;
IHTMLElement *elem; IHTMLElement *elem;
HRESULT hres; HRESULT hres;
...@@ -9887,6 +9888,29 @@ static void test_frameset(IHTMLDocument2 *doc) ...@@ -9887,6 +9888,29 @@ static void test_frameset(IHTMLDocument2 *doc)
elem = get_doc_elem_by_id(doc, "nm1"); elem = get_doc_elem_by_id(doc, "nm1");
test_elem_id((IUnknown*)elem, "fr1"); 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((IUnknown*)elem);
test_framebase_name(elem, "nm1"); test_framebase_name(elem, "nm1");
test_framebase_put_name(elem, "frame name"); test_framebase_put_name(elem, "frame name");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment