mshtml: Added IHTMLElement6::getElementsByClassName implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-07-01 11:21:27 +02:00 committed by Alexandre Julliard
parent cb1be040ea
commit 244abfcb77
3 changed files with 59 additions and 3 deletions

View File

@ -4103,8 +4103,25 @@ static HRESULT WINAPI HTMLElement6_get_nodeName(IHTMLElement6 *iface, BSTR *p)
static HRESULT WINAPI HTMLElement6_getElementsByClassName(IHTMLElement6 *iface, BSTR v, IHTMLElementCollection **pel)
{
HTMLElement *This = impl_from_IHTMLElement6(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
return E_NOTIMPL;
nsIDOMHTMLCollection *nscol = NULL;
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
if(This->nselem) {
nsAString_InitDepend(&nsstr, v);
nsres = nsIDOMHTMLElement_GetElementsByClassName(This->nselem, &nsstr, &nscol);
nsAString_Finish(&nsstr);
if(NS_FAILED(nsres)) {
ERR("GetElementsByClassName failed: %08x\n", nsres);
return E_FAIL;
}
}
*pel = create_collection_from_htmlcol(This->node.doc, nscol);
nsIDOMHTMLCollection_Release(nscol);
return S_OK;
}
static HRESULT WINAPI HTMLElement6_msMatchesSelector(IHTMLElement6 *iface, BSTR v, VARIANT_BOOL *pfMatches)

View File

@ -723,6 +723,7 @@ IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, ns
HTMLDOMNode *node;
HRESULT hres = S_OK;
if(nscol)
nsIDOMHTMLCollection_GetLength(nscol, &length);
buf.len = buf.size = length;

View File

@ -8038,6 +8038,43 @@ static void test_selectors(IHTMLDocument2 *doc, IHTMLElement *div)
IElementSelector_Release(elem_selector);
}
static void test_elemsbyclass(IHTMLElement *div)
{
IHTMLElementCollection *collection;
IHTMLElement6 *elem;
BSTR str;
HRESULT hres;
static const elem_type_t types[] = {ET_DIV, ET_FORM};
test_elem_set_innerhtml((IUnknown*)div, "<div class=\"cl1\"><form class=\"cl1\"></form></div><div class=\"cl2\"></div>");
hres = IHTMLElement_QueryInterface(div, &IID_IHTMLElement6, (void**)&elem);
ok(hres == S_OK || broken(hres == E_NOINTERFACE), "Could not get IHTMLElement6 iface: %08x\n", hres);
if(FAILED(hres)) {
win_skip("IHTMLElement6 tests skipped.\n");
return;
}
collection = NULL;
str = a2bstr("nomatch");
hres = IHTMLElement6_getElementsByClassName(elem, str, &collection);
ok(hres == S_OK, "getElementsByClassName failed: %08x\n", hres);
ok(collection != NULL, "collection == NULL\n");
test_elem_collection((IUnknown*)collection, NULL, 0);
IHTMLElementCollection_Release(collection);
collection = NULL;
str = a2bstr("cl1");
hres = IHTMLElement6_getElementsByClassName(elem, str, &collection);
ok(hres == S_OK, "getElementsByClassName failed: %08x\n", hres);
ok(collection != NULL, "collection == NULL\n");
test_elem_collection((IUnknown*)collection, types, sizeof(types)/sizeof(*types));
IHTMLElementCollection_Release(collection);
IHTMLElement6_Release(elem);
}
static void test_elems(IHTMLDocument2 *doc)
{
IHTMLElementCollection *col;
@ -9113,6 +9150,7 @@ static void test_elems2(IHTMLDocument2 *doc)
}
test_selectors(doc, div);
test_elemsbyclass(div);
test_elem_set_innerhtml((IUnknown*)div, "<div id=\"elemid\">test</div>");
elem = get_elem_by_id(doc, "elemid", TRUE);