Web Inspector: Search box doesn't allow CSS selectors anymore
authorapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2012 12:47:57 +0000 (12:47 +0000)
committerapavlov@chromium.org <apavlov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2012 12:47:57 +0000 (12:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=86196

Reviewed by Pavel Feldman.

Source/WebCore:

Refactoring in http://trac.webkit.org/changeset/99983 inadvertently removed the selector matching during
node search in the InspectorDOMAgent. This change re-introduces the Document::querySelectorAll() evaluation
for the user query.

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::performSearch):

LayoutTests:

* inspector/elements/elements-panel-search-expected.txt:
* inspector/elements/elements-panel-search.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116755 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/inspector/elements/elements-panel-search-expected.txt
LayoutTests/inspector/elements/elements-panel-search.html
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorDOMAgent.cpp

index 30faa94..3a9b591 100644 (file)
@@ -1,3 +1,13 @@
+2012-05-11  Alexander Pavlov  <apavlov@chromium.org>
+
+        Web Inspector: Search box doesn't allow CSS selectors anymore
+        https://bugs.webkit.org/show_bug.cgi?id=86196
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/elements/elements-panel-search-expected.txt:
+        * inspector/elements/elements-panel-search.html:
+
 2012-05-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r116527.
index 4747a90..ba60edb 100644 (file)
@@ -2,6 +2,7 @@ Tests that elements panel search is returning proper results.
 
 FooBar
 
+Found by selector
 
 Running: testSetUp
 
@@ -29,3 +30,6 @@ Running: testPartialAttributeVal_ue
 Running: testXPathAttribute
 < d i v   a t t r = " f o o " > < / d i v >
 
+Running: testSelector
+< s p a n > F o u n d   b y   s e l e c t o r < / s p a n >
+
index f690639..2b7d45f 100644 (file)
@@ -71,6 +71,11 @@ function test()
         function testXPathAttribute(next)
         {
             WebInspector.domAgent.performSearch("//html" + "//@attr", searchCallback.bind(this, next));
+        },
+
+        function testSelector(next)
+        {
+            WebInspector.domAgent.performSearch("d" + "iv.divclass span", searchCallback.bind(this, next));
         }
     ]);
 
@@ -87,6 +92,7 @@ Tests that elements panel search is returning proper results.
 <input value="InputVal">
 <div attr="foo"></div>
 <div id="terminator"></div>
+<div class="divclass"><span>Found by selector</span></div>
 
 </body>
 </html>
index 9fa9620..58a4827 100644 (file)
@@ -1,3 +1,17 @@
+2012-05-11  Alexander Pavlov  <apavlov@chromium.org>
+
+        Web Inspector: Search box doesn't allow CSS selectors anymore
+        https://bugs.webkit.org/show_bug.cgi?id=86196
+
+        Reviewed by Pavel Feldman.
+
+        Refactoring in http://trac.webkit.org/changeset/99983 inadvertently removed the selector matching during
+        node search in the InspectorDOMAgent. This change re-introduces the Document::querySelectorAll() evaluation
+        for the user query.
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::performSearch):
+
 2012-05-11  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r116527.
index 8996f66..ce9b1ca 100644 (file)
@@ -884,6 +884,19 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
                 resultCollector.add(node);
             }
         }
+
+        // Selector evaluation
+        for (Vector<Document*>::iterator it = docs.begin(); it != docs.end(); ++it) {
+            Document* document = *it;
+            ExceptionCode ec = 0;
+            RefPtr<NodeList> nodeList = document->querySelectorAll(whitespaceTrimmedQuery, ec);
+            if (ec || !nodeList)
+                continue;
+
+            unsigned size = nodeList->length();
+            for (unsigned i = 0; i < size; ++i)
+                resultCollector.add(nodeList->item(i));
+        }
     }
 
     *searchId = IdentifiersFactory::createIdentifier();