mshtml: Implement IHTMLDocument3 getElementsByTagName.

This commit is contained in:
Alistair Leslie-Hughes 2009-01-20 21:22:24 +11:00 committed by Alexandre Julliard
parent d77acecbff
commit a44ff54d81
2 changed files with 45 additions and 2 deletions

View File

@ -458,8 +458,32 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface,
IHTMLElementCollection **pelColl)
{
HTMLDocument *This = HTMLDOC3_THIS(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
return E_NOTIMPL;
nsIDOMNodeList *nslist;
nsAString id_str, ns_str;
nsresult nsres;
static const WCHAR str[] = {'*',0};
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
if(!This->nsdoc) {
WARN("NULL nsdoc\n");
return E_UNEXPECTED;
}
nsAString_Init(&id_str, v);
nsAString_Init(&ns_str, str);
nsres = nsIDOMHTMLDocument_GetElementsByTagNameNS(This->nsdoc, &ns_str, &id_str, &nslist);
nsAString_Finish(&id_str);
nsAString_Finish(&ns_str);
if(FAILED(nsres)) {
ERR("GetElementByName failed: %08x\n", nsres);
return E_FAIL;
}
*pelColl = (IHTMLElementCollection*)create_collection_from_nodelist(This, (IUnknown*)HTMLDOC3(This), nslist);
nsIDOMNodeList_Release(nslist);
return S_OK;
}
#undef HTMLDOC3_THIS

View File

@ -3418,6 +3418,8 @@ static void test_elems(IHTMLDocument2 *doc)
long type;
HRESULT hres;
IHTMLElementCollection *collection;
IHTMLDocument3 *doc3;
BSTR str;
static const WCHAR imgidW[] = {'i','m','g','i','d',0};
static const WCHAR inW[] = {'i','n',0};
@ -3804,6 +3806,23 @@ static void test_elems(IHTMLDocument2 *doc)
}
}
IDispatch_Release(disp);
hres = IHTMLDocument2_QueryInterface(doc, &IID_IHTMLDocument3, (void**)&doc3);
ok(hres == S_OK, "Could not get IHTMLDocument3 iface: %08x\n", hres);
str = a2bstr("img");
hres = IHTMLDocument3_getElementsByTagName(doc3, str, &col);
SysFreeString(str);
ok(hres == S_OK, "getElementByTag(%s) failed: %08x\n", dbgstr_w(ifrW), hres);
if(hres == S_OK)
{
static const elem_type_t img_types[] = { ET_IMG };
test_elem_collection((IUnknown*)col, img_types, sizeof(img_types)/sizeof(img_types[0]));
IHTMLElementCollection_Release(col);
}
IHTMLDocument3_Release(doc3);
}
static void test_create_elems(IHTMLDocument2 *doc)