The search is only performed if the field contains more than 3
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2008 03:55:53 +0000 (03:55 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Aug 2008 03:55:53 +0000 (03:55 +0000)
        letters or if Enter is pressed.

        Search is now performed through a keyup event.

        Added a WebInspector.lastQuery to remember the last query and not
        perform it again (eg. the user hits a modifier key).

        https://bugs.webkit.org/show_bug.cgi?id=18548

        Reviewed by Timothy Hatcher.

        * page/inspector/inspector.html: Removed the onsearch and incremental
        attributes
        * page/inspector/inspector.js:

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

WebCore/ChangeLog
WebCore/page/inspector/inspector.html
WebCore/page/inspector/inspector.js

index 5e4a26b..fbefe0f 100644 (file)
@@ -1,3 +1,21 @@
+2008-08-07  Anthony Ricaud  <rik24d@gmail.com>
+
+        The search is only performed if the field contains more than 3
+        letters or if Enter is pressed.
+
+        Search is now performed through a keyup event.
+
+        Added a WebInspector.lastQuery to remember the last query and not
+        perform it again (eg. the user hits a modifier key).
+
+        https://bugs.webkit.org/show_bug.cgi?id=18548
+
+        Reviewed by Timothy Hatcher.
+
+        * page/inspector/inspector.html: Removed the onsearch and incremental
+        attributes
+        * page/inspector/inspector.js:
+
 2008-08-07  Steve Falkenburg  <sfalken@apple.com>
 
         Compile derived sources through an all-in-one cpp file.
index febe73f..867bd1d 100644 (file)
@@ -73,7 +73,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 <body class="detached">
     <div id="toolbar">
         <div class="toolbar-item flexable-space"></div>
-        <div class="toolbar-item"><input id="search" type="search" results="20" incremental="incremental" onsearch="WebInspector.performSearch(this.value)"><div id="search-toolbar-label" class="toolbar-label"></div></div>
+        <div class="toolbar-item"><input id="search" type="search" results="20"><div id="search-toolbar-label" class="toolbar-label"></div></div>
     </div>
     <div id="main">
         <div id="searchResults" tabindex="0"></div>
index 7023a9b..7c33d24 100644 (file)
@@ -340,6 +340,8 @@ WebInspector.loaded = function()
     this._updateErrorAndWarningCounts();
 
     document.getElementById("search-toolbar-label").textContent = WebInspector.UIString("Search");
+    var searchField = document.getElementById("search");
+    searchField.addEventListener("keyup", this.performSearch.bind(this), false);
 
     if (platform === "mac-leopard")
         document.getElementById("toolbar").addEventListener("mousedown", this.toolbarDragStart, true);
@@ -974,13 +976,23 @@ WebInspector.addMainEventListeners = function(doc)
     doc.addEventListener("click", this.documentClick.bind(this), true);
 }
 
-WebInspector.performSearch = function(query)
+WebInspector.performSearch = function(event)
 {
+    var query = event.target.value;
+
     if (!query || !query.length) {
         this.showingSearchResults = false;
         return;
     }
 
+    var forceSearch = event.keyIdentifier === "Enter";
+    if(!forceSearch && query.length < 3)
+        return;
+
+    if (!forceSearch && this.lastQuery && this.lastQuery === query)
+        return;
+    this.lastQuery = query;
+
     var resultsContainer = document.getElementById("searchResults");
     resultsContainer.removeChildren();