Web Inspector: searching for <u> in elements panel finds all tags containing "u"
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 18:34:11 +0000 (18:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Jan 2013 18:34:11 +0000 (18:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108176

Patch by Dmitry Zvorygin <zvorygin@chromium.org> on 2013-01-31
Reviewed by Pavel Feldman.

When searching for tag name check that tag name must either start from
search query, or must end with it.

Source/WebCore:

* 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@141436 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 02dc9da..c074b44 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-31  Dmitry Zvorygin  <zvorygin@chromium.org>
+
+        Web Inspector: searching for <u> in elements panel finds all tags containing "u"
+        https://bugs.webkit.org/show_bug.cgi?id=108176
+
+        Reviewed by Pavel Feldman.
+
+        When searching for tag name check that tag name must either start from
+        search query, or must end with it.
+
+        * inspector/elements/elements-panel-search-expected.txt:
+        * inspector/elements/elements-panel-search.html:
+
 2013-01-31  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed GTK gardening.
index ef5a3f0..1949b17 100644 (file)
@@ -15,9 +15,21 @@ F o o B a r
 Running: testStartTag
 < i n p u t   v a l u e = " I n p u t V a l " >
 
+Running: testEndTag
+< i n p u t   v a l u e = " I n p u t V a l " >
+
 Running: testPartialTag
 < i n p u t   v a l u e = " I n p u t V a l " >
 
+Running: testPartialAbsentTagStart
+Nothing found
+
+Running: testPartialAbsentTagEnd
+Nothing found
+
+Running: testFullTag
+< i n p u t   v a l u e = " I n p u t V a l " >
+
 Running: testExactAttributeName
 < i n p u t   v a l u e = " I n p u t V a l " >
 
index 8807377..1e8f795 100644 (file)
@@ -9,6 +9,12 @@ function test()
 
     function searchCallback(next, resultCount)
     {
+        if (resultCount == 0) {
+            InspectorTest.addResult("Nothing found");
+            WebInspector.domAgent.cancelSearch();
+            next();
+        }
+
         for (var i = 0; i < resultCount; ++i)
             WebInspector.domAgent.searchResult(i, searchResultCallback.bind(this, i + 1 === resultCount));
 
@@ -48,11 +54,31 @@ function test()
             WebInspector.domAgent.performSearch("<inpu" + "t", searchCallback.bind(this, next));
         },
 
+        function testEndTag(next)
+        {
+            WebInspector.domAgent.performSearch("npu" + "t>", searchCallback.bind(this, next));
+        },
+
         function testPartialTag(next)
         {
             WebInspector.domAgent.performSearch("npu" + "t", searchCallback.bind(this, next));
         },
 
+        function testPartialAbsentTagStart(next)
+        {
+            WebInspector.domAgent.performSearch("<npu" + "t", searchCallback.bind(this, next));
+        },
+
+        function testPartialAbsentTagEnd(next)
+        {
+            WebInspector.domAgent.performSearch("npu" + ">", searchCallback.bind(this, next));
+        },
+
+        function testFullTag(next)
+        {
+            WebInspector.domAgent.performSearch("<inpu" + "t>", searchCallback.bind(this, next));
+        },
+
         function testExactAttributeName(next)
         {
             WebInspector.domAgent.performSearch("valu" + "e", searchCallback.bind(this, next));
index 328a316..6b9df33 100644 (file)
@@ -1,3 +1,16 @@
+2013-01-31  Dmitry Zvorygin  <zvorygin@chromium.org>
+
+        Web Inspector: searching for <u> in elements panel finds all tags containing "u"
+        https://bugs.webkit.org/show_bug.cgi?id=108176
+
+        Reviewed by Pavel Feldman.
+
+        When searching for tag name check that tag name must either start from
+        search query, or must end with it.
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::performSearch):
+
 2013-01-30  Mark Lam  <mark.lam@apple.com>
 
         DatabaseContext needs to outlive the ScriptExecutionContext.
index 63b47d5..4859200 100644 (file)
@@ -875,7 +875,10 @@ void InspectorDOMAgent::performSearch(ErrorString*, const String& whitespaceTrim
                 break;
             }
             case Node::ELEMENT_NODE: {
-                if (node->nodeName().findIgnoringCase(tagNameQuery) != notFound) {
+                if ((!startTagFound && !endTagFound && (node->nodeName().findIgnoringCase(tagNameQuery) != notFound))
+                    || (startTagFound && endTagFound && equalIgnoringCase(node->nodeName(), tagNameQuery))
+                    || (startTagFound && !endTagFound && node->nodeName().startsWith(tagNameQuery, false))
+                    || (!startTagFound && endTagFound && node->nodeName().endsWith(tagNameQuery, false))) {
                     resultCollector.add(node);
                     break;
                 }