[PATCH 0/2] MR3732: mshtml: Implement querySelector(All) for document fragments
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/mshtml/htmldoc.c | 12 +++++++++++- dlls/mshtml/tests/dom.js | 27 ++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index dd8c4b24a4a..95b792388e5 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -4720,8 +4720,18 @@ static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, B TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel); nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem); + if(This->dom_document) + nsres = nsIDOMDocument_QuerySelector(This->dom_document, &nsstr, &nselem); + else { + nsIDOMDocumentFragment *frag; + nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag); + if(NS_SUCCEEDED(nsres)) { + nsres = nsIDOMDocumentFragment_QuerySelector(frag, &nsstr, &nselem); + nsIDOMDocumentFragment_Release(frag); + } + } nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) { WARN("QuerySelector failed: %08lx\n", nsres); return map_nsresult(nsres); diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index 4f2d1a5edc5..7a8e110da36 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -244,10 +244,20 @@ sync_test("query_selector", function() { + '</div>' + '<script class="class1"></script>'; - var e = document.querySelector("nomatch"); + var frag = document.createDocumentFragment() + var e = document.createElement("div"); + e.innerHTML = '<div class="class3"></div><a id="class3" class="class4"></a></div>'; + frag.appendChild(e); + var e = document.createElement("script"); + e.className = "class3"; + frag.appendChild(e); + + e = document.querySelector("nomatch"); ok(e === null, "e = " + e); e = document.body.querySelector("nomatch"); ok(e === null, "e = " + e); + e = frag.querySelector("nomatch"); + ok(e === null, "e = " + e); e = document.querySelector(".class1"); ok(e.tagName === "DIV", "e.tagName = " + e.tagName); @@ -255,11 +265,26 @@ sync_test("query_selector", function() { ok(e.tagName === "DIV", "e.tagName = " + e.tagName); ok(e.msMatchesSelector(".class1") === true, "msMatchesSelector returned " + e.msMatchesSelector(".class1")); ok(e.msMatchesSelector(".class2") === false, "msMatchesSelector returned " + e.msMatchesSelector(".class2")); + e = document.querySelector(".class3"); + ok(e === null, "e = " + e); + e = document.body.querySelector(".class3"); + ok(e === null, "e = " + e); + + e = frag.querySelector(".class3"); + ok(e.tagName === "DIV", "e.tagName = " + e.tagName); + e = frag.querySelector(".class4"); + ok(e.tagName === "A", "e.tagName = " + e.tagName); + e = frag.querySelector(".class1"); + ok(e === null, "e = " + e); + e = frag.querySelector(".class2"); + ok(e === null, "e = " + e); e = document.querySelector("a"); ok(e.tagName === "A", "e.tagName = " + e.tagName); e = document.body.querySelector("a"); ok(e.tagName === "A", "e.tagName = " + e.tagName); + e = frag.querySelector("a"); + ok(e.tagName === "A", "e.tagName = " + e.tagName); }); sync_test("compare_position", function() { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3732
From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- dlls/mshtml/htmldoc.c | 12 +++++++++++- dlls/mshtml/tests/dom.js | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index 95b792388e5..2a0c25f9132 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -4762,8 +4762,18 @@ static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel); nsAString_InitDepend(&nsstr, v); - nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list); + if(This->dom_document) + nsres = nsIDOMDocument_QuerySelectorAll(This->dom_document, &nsstr, &node_list); + else { + nsIDOMDocumentFragment *frag; + nsres = nsIDOMNode_QueryInterface(This->node.nsnode, &IID_nsIDOMDocumentFragment, (void**)&frag); + if(NS_SUCCEEDED(nsres)) { + nsres = nsIDOMDocumentFragment_QuerySelectorAll(frag, &nsstr, &node_list); + nsIDOMDocumentFragment_Release(frag); + } + } nsAString_Finish(&nsstr); + if(NS_FAILED(nsres)) { WARN("QuerySelectorAll failed: %08lx\n", nsres); return map_nsresult(nsres); diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index 7a8e110da36..0cbcb95e578 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -285,6 +285,19 @@ sync_test("query_selector", function() { ok(e.tagName === "A", "e.tagName = " + e.tagName); e = frag.querySelector("a"); ok(e.tagName === "A", "e.tagName = " + e.tagName); + + e = document.querySelectorAll(".class1"); + ok(e.length === 3, "e.length = " + e.length); + e = document.body.querySelectorAll(".class1"); + ok(e.length === 3, "e.length = " + e.length); + e = document.querySelectorAll(".class2"); + ok(e.length === 1, "e.length = " + e.length); + e = document.body.querySelectorAll(".class2"); + ok(e.length === 1, "e.length = " + e.length); + e = frag.querySelectorAll(".class3"); + ok(e.length === 2, "e.length = " + e.length); + e = frag.querySelectorAll(".class4"); + ok(e.length === 1, "e.length = " + e.length); }); sync_test("compare_position", function() { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3732
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=137022 Your paranoid android. === w1064v1507 (32 bit report) === mshtml: 09e4:dom: unhandled exception c0000005 at 75E514EB
This merge request was approved by Jacek Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3732
participants (3)
-
Gabriel Ivăncescu -
Jacek Caban (@jacek) -
Marvin