Jacek Caban : mshtml: Added IElementSelector:: querySelectorAll implementation.
Alexandre Julliard
julliard at winehq.org
Fri Jun 17 10:35:01 CDT 2016
Module: wine
Branch: master
Commit: 2e4fa65d0982a955fcb5b9b2a5726d9a65982990
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2e4fa65d0982a955fcb5b9b2a5726d9a65982990
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Jun 16 19:29:56 2016 +0200
mshtml: Added IElementSelector::querySelectorAll implementation.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/mshtml/htmlelem.c | 19 +++++++++++++++++--
dlls/mshtml/tests/dom.c | 26 ++++++++++++++++++++++++--
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 8aac47b..76434c8 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -4081,8 +4081,23 @@ static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BST
static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
{
HTMLElement *This = impl_from_IElementSelector(iface);
- FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
- return E_NOTIMPL;
+ nsIDOMNodeList *node_list;
+ nsAString nsstr;
+ nsresult nsres;
+
+ TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
+
+ nsAString_InitDepend(&nsstr, v);
+ nsres = nsIDOMHTMLElement_QuerySelectorAll(This->nselem, &nsstr, &node_list);
+ nsAString_Finish(&nsstr);
+ if(NS_FAILED(nsres)) {
+ ERR("QuerySelectorAll failed: %08x\n", nsres);
+ return E_FAIL;
+ }
+
+ *pel = create_child_collection(This->node.doc, node_list);
+ nsIDOMNodeList_Release(node_list);
+ return *pel ? S_OK : E_OUTOFMEMORY;
}
static const IElementSelectorVtbl ElementSelectorVtbl = {
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index 47c8827..52227d3 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -7906,10 +7906,11 @@ static void test_enum_children(IUnknown *unk, unsigned len)
IEnumVARIANT_Release(enum_var);
}
-static void test_doc_selector(IHTMLDocument2 *doc, IHTMLElement *div)
+static void test_selectors(IHTMLDocument2 *doc, IHTMLElement *div)
{
IHTMLDOMChildrenCollection *collection;
IDocumentSelector *doc_selector;
+ IElementSelector *elem_selector;
BSTR str;
HRESULT hres;
@@ -7939,6 +7940,27 @@ static void test_doc_selector(IHTMLDocument2 *doc, IHTMLElement *div)
IHTMLDOMChildrenCollection_Release(collection);
IDocumentSelector_Release(doc_selector);
+
+ hres = IHTMLElement_QueryInterface(div, &IID_IElementSelector, (void**)&elem_selector);
+ ok(hres == S_OK, "Could not get IElementSelector iface: %08x\n", hres);
+
+ collection = NULL;
+ str = a2bstr("nomatch");
+ hres = IElementSelector_querySelectorAll(elem_selector, str, &collection);
+ ok(hres == S_OK, "querySelectorAll failed: %08x\n", hres);
+ ok(collection != NULL, "collection == NULL\n");
+ test_children_collection_length(collection, 0);
+ IHTMLDOMChildrenCollection_Release(collection);
+
+ collection = NULL;
+ str = a2bstr(".cl1");
+ hres = IElementSelector_querySelectorAll(elem_selector, str, &collection);
+ ok(hres == S_OK, "querySelectorAll failed: %08x\n", hres);
+ ok(collection != NULL, "collection == NULL\n");
+ test_children_collection_length(collection, 2);
+ IHTMLDOMChildrenCollection_Release(collection);
+
+ IElementSelector_Release(elem_selector);
}
static void test_elems(IHTMLDocument2 *doc)
@@ -9005,7 +9027,7 @@ static void test_elems2(IHTMLDocument2 *doc)
IHTMLElement_Release(elem2);
}
- test_doc_selector(doc, div);
+ test_selectors(doc, div);
test_elem_set_innerhtml((IUnknown*)div, "<div id=\"elemid\">test</div>");
elem = get_elem_by_id(doc, "elemid", TRUE);
More information about the wine-cvs
mailing list