Title: [126749] trunk
Revision
126749
Author
[email protected]
Date
2012-08-27 04:56:37 -0700 (Mon, 27 Aug 2012)

Log Message

Web Inspector: DOM tree search issue with quotation marks
https://bugs.webkit.org/show_bug.cgi?id=95065

Reviewed by Pavel Feldman.

Source/WebCore:

Introduced the exact match mode for attributes (query enclosed in double quotes) where only entire attribute values
are matched against the search query (with the double quotes trimmed).

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

LayoutTests:

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (126748 => 126749)


--- trunk/LayoutTests/ChangeLog	2012-08-27 11:49:30 UTC (rev 126748)
+++ trunk/LayoutTests/ChangeLog	2012-08-27 11:56:37 UTC (rev 126749)
@@ -1,3 +1,13 @@
+2012-08-27  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: DOM tree search issue with quotation marks
+        https://bugs.webkit.org/show_bug.cgi?id=95065
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/elements/elements-panel-search-expected.txt:
+        * inspector/elements/elements-panel-search.html:
+
 2012-08-27  Dominic Cooney   <[email protected]>
 
         [Chromium] Unreviewed gardening.

Modified: trunk/LayoutTests/inspector/elements/elements-panel-search-expected.txt (126748 => 126749)


--- trunk/LayoutTests/inspector/elements/elements-panel-search-expected.txt	2012-08-27 11:49:30 UTC (rev 126748)
+++ trunk/LayoutTests/inspector/elements/elements-panel-search-expected.txt	2012-08-27 11:56:37 UTC (rev 126749)
@@ -24,6 +24,9 @@
 Running: testExactAttributeVal_ue
 < i n p u t   v a l u e = " I n p u t V a l " >
 
+Running: testExactAttributeVal_ueWithQuotes
+< d i v   a t t r = " f o o " > < / d i v >
+
 Running: testPartialAttributeVal_ue
 < i n p u t   v a l u e = " I n p u t V a l " >
 

Modified: trunk/LayoutTests/inspector/elements/elements-panel-search.html (126748 => 126749)


--- trunk/LayoutTests/inspector/elements/elements-panel-search.html	2012-08-27 11:49:30 UTC (rev 126748)
+++ trunk/LayoutTests/inspector/elements/elements-panel-search.html	2012-08-27 11:56:37 UTC (rev 126749)
@@ -35,7 +35,7 @@
 
         function testPlainText(next)
         {
-            WebInspector.domAgent.performSearch("Foo" + "Bar", searchCallback.bind(this, next));
+            WebInspector.domAgent.performSearch("Fo" + "o" + "Bar", searchCallback.bind(this, next));
         },
 
         function testPartialText(next)
@@ -63,6 +63,11 @@
             WebInspector.domAgent.performSearch("In" + "putVa" + "l", searchCallback.bind(this, next));
         },
 
+        function testExactAttributeVal_ueWithQuotes(next)
+        {
+            WebInspector.domAgent.performSearch("\"fo" + "o\"", searchCallback.bind(this, next));
+        },
+
         function testPartialAttributeVal_ue(next)
         {
             WebInspector.domAgent.performSearch("n" + "putVa" + "l", searchCallback.bind(this, next));
@@ -93,6 +98,7 @@
 <div attr="foo"></div>
 <div id="terminator"></div>
 <div class="divclass"><span>Found by selector</span></div>
+<span class="foo koo"></span>
 
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (126748 => 126749)


--- trunk/Source/WebCore/ChangeLog	2012-08-27 11:49:30 UTC (rev 126748)
+++ trunk/Source/WebCore/ChangeLog	2012-08-27 11:56:37 UTC (rev 126749)
@@ -1,3 +1,16 @@
+2012-08-27  Alexander Pavlov  <[email protected]>
+
+        Web Inspector: DOM tree search issue with quotation marks
+        https://bugs.webkit.org/show_bug.cgi?id=95065
+
+        Reviewed by Pavel Feldman.
+
+        Introduced the exact match mode for attributes (query enclosed in double quotes) where only entire attribute values
+        are matched against the search query (with the double quotes trimmed).
+
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::performSearch):
+
 2012-08-27  Andrey Adaikin  <[email protected]>
 
         Web Inspector: [WebGL] Implement serializing WebGL state and replaying it later

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (126748 => 126749)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-08-27 11:49:30 UTC (rev 126748)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2012-08-27 11:56:37 UTC (rev 126749)
@@ -809,12 +809,20 @@
     unsigned queryLength = whitespaceTrimmedQuery.length();
     bool startTagFound = !whitespaceTrimmedQuery.find('<');
     bool endTagFound = whitespaceTrimmedQuery.reverseFind('>') + 1 == queryLength;
+    bool startQuoteFound = !whitespaceTrimmedQuery.find('"');
+    bool endQuoteFound = whitespaceTrimmedQuery.reverseFind('"') + 1 == queryLength;
+    bool exactAttributeMatch = startQuoteFound && endQuoteFound;
 
     String tagNameQuery = whitespaceTrimmedQuery;
+    String attributeQuery = whitespaceTrimmedQuery;
     if (startTagFound)
         tagNameQuery = tagNameQuery.right(tagNameQuery.length() - 1);
     if (endTagFound)
         tagNameQuery = tagNameQuery.left(tagNameQuery.length() - 1);
+    if (startQuoteFound)
+        attributeQuery = attributeQuery.right(attributeQuery.length() - 1);
+    if (endQuoteFound)
+        attributeQuery = attributeQuery.left(attributeQuery.length() - 1);
 
     Vector<Document*> docs = documents();
     ListHashSet<Node*> resultCollector;
@@ -854,9 +862,12 @@
                         resultCollector.add(node);
                         break;
                     }
-                    if (attribute->value().find(whitespaceTrimmedQuery) != notFound) {
-                        resultCollector.add(node);
-                        break;
+                    size_t foundPosition = attribute->value().find(attributeQuery);
+                    if (foundPosition != notFound) {
+                        if (!exactAttributeMatch || (!foundPosition && attribute->value().length() == attributeQuery.length())) {
+                            resultCollector.add(node);
+                            break;
+                        }
                     }
                 }
                 break;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to