Web Inspector: remove search replace from behind experiment, polish the behavior
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 13:41:07 +0000 (13:41 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 13:41:07 +0000 (13:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=91519

Reviewed by Vsevolod Vlasov.

- This change makes replace loop with no boundary, removes the loop parameter
  from jumpToNext/Previous;
- Lays out replace as a second row
- Fixes replace all with no search matches
- Splits Search and Search and Replace
- Introduces explicit Next / Previous buttons in the search mode
- Introduces editRange on the TextEditor so that it was preserving the undo stack
  (we'll need to fix editor so that it does not require it).

* English.lproj/localizedStrings.js:
* inspector/front-end/ConsolePanel.js:
(WebInspector.ConsolePanel.prototype.performSearch):
(WebInspector.ConsolePanel.prototype.jumpToNextSearchResult):
(WebInspector.ConsolePanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ElementsPanel.js:
(WebInspector.ElementsPanel.prototype.jumpToNextSearchResult):
(WebInspector.ElementsPanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ExtensionPanel.js:
(WebInspector.ExtensionPanel.prototype.performSearch):
(WebInspector.ExtensionPanel.prototype.jumpToNextSearchResult):
(WebInspector.ExtensionPanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/JavaScriptSourceFrame.js:
(WebInspector.JavaScriptSourceFrame.prototype.beforeTextChanged):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkLogView.prototype.jumpToPreviousSearchResult):
(WebInspector.NetworkLogView.prototype.jumpToNextSearchResult):
(WebInspector.NetworkPanel.prototype.jumpToPreviousSearchResult):
(WebInspector.NetworkPanel.prototype.jumpToNextSearchResult):
* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.performSearch):
(WebInspector.Panel.prototype.jumpToNextSearchResult):
(WebInspector.Panel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype.jumpToNextSearchResult):
(WebInspector.ProfilesPanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.jumpToNextSearchResult):
(WebInspector.ResourcesPanel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._editorClosed):
(WebInspector.ScriptsPanel.prototype._editorSelected):
(WebInspector.ScriptsPanel.prototype.performSearch.finishedCallback):
(WebInspector.ScriptsPanel.prototype.performSearch):
(WebInspector.ScriptsPanel.prototype.jumpToNextSearchResult):
(WebInspector.ScriptsPanel.prototype.jumpToPreviousSearchResult):
(WebInspector.ScriptsPanel.prototype.replaceSelectionWith):
(WebInspector.ScriptsPanel.prototype.replaceAllWith):
* inspector/front-end/SearchController.js:
(WebInspector.SearchController):
(WebInspector.SearchController.prototype.cancelSearch):
(WebInspector.SearchController.prototype.resetSearch):
(WebInspector.SearchController.prototype.handleShortcut):
(WebInspector.SearchController.prototype._updateSearchNavigationButtonState):
(WebInspector.SearchController.prototype._updateReplaceVisibility):
(WebInspector.SearchController.prototype._onKeyDown):
(WebInspector.SearchController.prototype._onNextButtonSearch):
(WebInspector.SearchController.prototype._onPrevButtonSearch):
(WebInspector.SearchController.prototype._performSearch):
(WebInspector.SearchController.prototype._updateReplaceDetailsVisibility):
(WebInspector.SearchController.prototype._replace):
(WebInspector.SearchController.prototype._replaceAll):
* inspector/front-end/Settings.js:
(WebInspector.ExperimentsSettings):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.beforeTextChanged):
(WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
(WebInspector.SourceFrame.prototype.performSearch):
(WebInspector.SourceFrame.prototype.replaceSearchMatchWith):
(WebInspector.SourceFrame.prototype.replaceAllWith):
(WebInspector.TextEditorDelegateForSourceFrame.prototype.beforeTextChanged):
* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor.prototype.editRange):
* inspector/front-end/inspector.css:
(.toolbar-search-replace .search-replace):
(.toolbar-search):
(.toolbar-search-replace):
(.toolbar-search-close-button):
(.toolbar-search-close-button:hover):
(.toolbar-search-close-button:active):
(.toolbar-search input[type="checkbox"]):
(.toolbar-search-replace .toolbar-replace-control):

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

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/ConsolePanel.js
Source/WebCore/inspector/front-end/ElementsPanel.js
Source/WebCore/inspector/front-end/ExtensionPanel.js
Source/WebCore/inspector/front-end/JavaScriptSourceFrame.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Panel.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/SearchController.js
Source/WebCore/inspector/front-end/Settings.js
Source/WebCore/inspector/front-end/SourceFrame.js
Source/WebCore/inspector/front-end/TextEditor.js
Source/WebCore/inspector/front-end/inspector.css

index e78f24b..b60138c 100644 (file)
@@ -1,3 +1,92 @@
+2012-07-18  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: remove search replace from behind experiment, polish the behavior
+        https://bugs.webkit.org/show_bug.cgi?id=91519
+
+        Reviewed by Vsevolod Vlasov.
+
+        - This change makes replace loop with no boundary, removes the loop parameter
+          from jumpToNext/Previous;
+        - Lays out replace as a second row
+        - Fixes replace all with no search matches
+        - Splits Search and Search and Replace
+        - Introduces explicit Next / Previous buttons in the search mode
+        - Introduces editRange on the TextEditor so that it was preserving the undo stack
+          (we'll need to fix editor so that it does not require it).
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/ConsolePanel.js:
+        (WebInspector.ConsolePanel.prototype.performSearch):
+        (WebInspector.ConsolePanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ConsolePanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ElementsPanel.js:
+        (WebInspector.ElementsPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ElementsPanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ExtensionPanel.js:
+        (WebInspector.ExtensionPanel.prototype.performSearch):
+        (WebInspector.ExtensionPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ExtensionPanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/JavaScriptSourceFrame.js:
+        (WebInspector.JavaScriptSourceFrame.prototype.beforeTextChanged):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkLogView.prototype.jumpToPreviousSearchResult):
+        (WebInspector.NetworkLogView.prototype.jumpToNextSearchResult):
+        (WebInspector.NetworkPanel.prototype.jumpToPreviousSearchResult):
+        (WebInspector.NetworkPanel.prototype.jumpToNextSearchResult):
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.performSearch):
+        (WebInspector.Panel.prototype.jumpToNextSearchResult):
+        (WebInspector.Panel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ProfilesPanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ResourcesPanel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._editorClosed):
+        (WebInspector.ScriptsPanel.prototype._editorSelected):
+        (WebInspector.ScriptsPanel.prototype.performSearch.finishedCallback):
+        (WebInspector.ScriptsPanel.prototype.performSearch):
+        (WebInspector.ScriptsPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ScriptsPanel.prototype.jumpToPreviousSearchResult):
+        (WebInspector.ScriptsPanel.prototype.replaceSelectionWith):
+        (WebInspector.ScriptsPanel.prototype.replaceAllWith):
+        * inspector/front-end/SearchController.js:
+        (WebInspector.SearchController):
+        (WebInspector.SearchController.prototype.cancelSearch):
+        (WebInspector.SearchController.prototype.resetSearch):
+        (WebInspector.SearchController.prototype.handleShortcut):
+        (WebInspector.SearchController.prototype._updateSearchNavigationButtonState):
+        (WebInspector.SearchController.prototype._updateReplaceVisibility):
+        (WebInspector.SearchController.prototype._onKeyDown):
+        (WebInspector.SearchController.prototype._onNextButtonSearch):
+        (WebInspector.SearchController.prototype._onPrevButtonSearch):
+        (WebInspector.SearchController.prototype._performSearch):
+        (WebInspector.SearchController.prototype._updateReplaceDetailsVisibility):
+        (WebInspector.SearchController.prototype._replace):
+        (WebInspector.SearchController.prototype._replaceAll):
+        * inspector/front-end/Settings.js:
+        (WebInspector.ExperimentsSettings):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.beforeTextChanged):
+        (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
+        (WebInspector.SourceFrame.prototype.performSearch):
+        (WebInspector.SourceFrame.prototype.replaceSearchMatchWith):
+        (WebInspector.SourceFrame.prototype.replaceAllWith):
+        (WebInspector.TextEditorDelegateForSourceFrame.prototype.beforeTextChanged):
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditor.prototype.editRange):
+        * inspector/front-end/inspector.css:
+        (.toolbar-search-replace .search-replace):
+        (.toolbar-search):
+        (.toolbar-search-replace):
+        (.toolbar-search-close-button):
+        (.toolbar-search-close-button:hover):
+        (.toolbar-search-close-button:active):
+        (.toolbar-search input[type="checkbox"]):
+        (.toolbar-search-replace .toolbar-replace-control):
+
 2012-07-18  YoungTaeck Song  <youngtaeck.song@samsung.com>
 
         [WK2][EFL] Divide ENABLE(WEBGL) into ENABLE(WEBGL) and USE(3D_GRAPHICS) in CMakeLists.txt
index 9edc641..a3afbfd 100644 (file)
@@ -723,4 +723,4 @@ localizedStrings["Time End"] = "Time End";
 localizedStrings["Find"] = "Find";
 localizedStrings["Replace"] = "Replace";
 localizedStrings["Replace All"] = "Replace All";
-localizedStrings["Skip"] = "Skip";
+localizedStrings["Previous"] = "Previous";
index 54ef63d..b7af2a9 100644 (file)
@@ -78,9 +78,8 @@ WebInspector.ConsolePanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         WebInspector.searchController.updateSearchMatchesCount(0, this);
         this.searchCanceled();
@@ -100,34 +99,20 @@ WebInspector.ConsolePanel.prototype = {
             this._jumpToSearchResult(0);
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this._searchResults || !this._searchResults.length)
-            return false;
-        if (!loop && this._currentSearchResultIndex + 1 >= this._searchResults.length)
-            return false;
+            return;
         this._jumpToSearchResult((this._currentSearchResultIndex + 1) % this._searchResults.length);
-        return true;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this._searchResults || !this._searchResults.length)
-            return false;
+            return;
         var index = this._currentSearchResultIndex - 1;
-        if (index === -1) {
-            if (!loop)
-                return false;
+        if (index === -1)
             index = this._searchResults.length - 1;
-        }
         this._jumpToSearchResult(index);
         return true;
     },
index 740185e..7f2f86b 100644 (file)
@@ -294,9 +294,8 @@ WebInspector.ElementsPanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         // Call searchCanceled since it will reset everything we need before doing a new search.
         this.searchCanceled();
@@ -493,41 +492,26 @@ WebInspector.ElementsPanel.prototype = {
         }
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this._searchResults)
-            return false;
+            return;
 
         this._hideSearchHighlights();
-        if (++this._currentSearchResultIndex >= this._searchResults.length) {
-            if (!loop)
-                return false;
+        if (++this._currentSearchResultIndex >= this._searchResults.length)
             this._currentSearchResultIndex = 0;
-        }
-            
+
         this._highlightCurrentSearchResult();
-        return true;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this._searchResults)
-            return false;
+            return;
 
         this._hideSearchHighlights();
-        if (--this._currentSearchResultIndex < 0) {
-            if (!loop)
-                return false;
+        if (--this._currentSearchResultIndex < 0)
             this._currentSearchResultIndex = (this._searchResults.length - 1);
-        }
 
         this._highlightCurrentSearchResult();
         return true;
index d828d33..1485b09 100644 (file)
@@ -153,34 +153,23 @@ WebInspector.ExtensionPanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PerformSearch, query);
         WebInspector.Panel.prototype.performSearch.apply(this, arguments);
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.NextSearchResult);
-        WebInspector.Panel.prototype.jumpToNextSearchResult.call(this, loop);
-        return true;
+        WebInspector.Panel.prototype.jumpToNextSearchResult.call(this);
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         WebInspector.extensionServer.notifySearchAction(this.name, WebInspector.extensionAPI.panels.SearchAction.PreviousSearchResult);
-        WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this, loop);
-        return true;
+        WebInspector.Panel.prototype.jumpToPreviousSearchResult.call(this);
     },
 
     _addStyleRule: function(selector, body)
index ade0491..54fa1a0 100644 (file)
@@ -154,9 +154,9 @@ WebInspector.JavaScriptSourceFrame.prototype = {
         this._restoreBreakpointsAfterEditing();
     },
 
-    beforeTextChanged: function(userInput)
+    beforeTextChanged: function()
     {
-        WebInspector.SourceFrame.prototype.beforeTextChanged.call(this, userInput);
+        WebInspector.SourceFrame.prototype.beforeTextChanged.call(this);
         this._removeBreakpointsBeforeEditing();
     },
 
index 0bfa3bb..732afaf 100644 (file)
@@ -1166,32 +1166,18 @@ WebInspector.NetworkLogView.prototype = {
         this._highlightNthMatchedRequest(newMatchedRequestIndex, false);
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this._matchedRequests.length)
-            return false;
-        if (!loop && this._currentMatchedRequestIndex <= 0)
-            return false;
+            return;
         this._highlightNthMatchedRequest((this._currentMatchedRequestIndex + this._matchedRequests.length - 1) % this._matchedRequests.length, true);
-        return true;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this._matchedRequests.length)
-            return false;
-        if (!loop && this._currentMatchedRequestIndex + 1 >= this._matchedRequests.length)
-            return false;
+            return;
         this._highlightNthMatchedRequest((this._currentMatchedRequestIndex + 1) % this._matchedRequests.length, true);
-        return true;
     },
 
     searchCanceled: function()
@@ -1438,20 +1424,14 @@ WebInspector.NetworkPanel.prototype = {
         this._networkLogView.performSearch(searchQuery);
     },
 
-    /**
-     * @param {boolean} loop
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
-        this._networkLogView.jumpToPreviousSearchResult(loop);
+        this._networkLogView.jumpToPreviousSearchResult();
     },
 
-    /**
-     * @param {boolean} loop
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
-        this._networkLogView.jumpToNextSearchResult(loop);
+        this._networkLogView.jumpToNextSearchResult();
     },
 
     searchCanceled: function()
index a14641c..7891a0b 100644 (file)
@@ -108,30 +108,19 @@ WebInspector.Panel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         // Call searchCanceled since it will reset everything we need before doing a new search.
         this.searchCanceled();
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean} true iff operation is successful
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
-        return false;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean} true iff operation is successful
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
-        return false;
     },
 
     /**
index 17c6e53..ce12296 100644 (file)
@@ -739,9 +739,8 @@ WebInspector.ProfilesPanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         this.searchCanceled();
 
@@ -816,14 +815,10 @@ WebInspector.ProfilesPanel.prototype = {
         this._currentSearchChunkIntervalIdentifier = chunkIntervalIdentifier;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this.showView || !this._searchResults || !this._searchResults.length)
-            return false;
+            return;
 
         var showFirstResult = false;
 
@@ -853,17 +848,12 @@ WebInspector.ProfilesPanel.prototype = {
             currentView.jumpToFirstSearchResult();
         else
             currentView.jumpToNextSearchResult();
-        return true;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this.showView || !this._searchResults || !this._searchResults.length)
-            return false;
+            return;
 
         var showLastResult = false;
 
@@ -893,7 +883,6 @@ WebInspector.ProfilesPanel.prototype = {
             currentView.jumpToLastSearchResult();
         else
             currentView.jumpToPreviousSearchResult();
-        return true;
     },
 
     _searchableViews: function()
index 71ff0a5..113b95b 100644 (file)
@@ -637,9 +637,8 @@ WebInspector.ResourcesPanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         this._resetSearchResults();
         var regex = WebInspector.SourceFrame.createSearchRegex(query);
@@ -749,32 +748,22 @@ WebInspector.ResourcesPanel.prototype = {
         this._forAllResourceTreeElements(callback);
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this.currentSearchMatches)
-            return false;
+            return;
         var currentTreeElement = this.sidebarTree.selectedTreeElement;
         var nextSearchResult = this._searchController.nextSearchResult(currentTreeElement);
         this._showSearchResult(nextSearchResult);
-        return true;
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this.currentSearchMatches)
-            return false;
+            return;
         var currentTreeElement = this.sidebarTree.selectedTreeElement;
         var previousSearchResult = this._searchController.previousSearchResult(currentTreeElement);
         this._showSearchResult(previousSearchResult);
-        return true;
     },
 
     _forAllResourceTreeElements: function(callback)
index c2d8c00..5aaaaaa 100644 (file)
@@ -573,6 +573,7 @@ WebInspector.ScriptsPanel.prototype = {
 
         // ScriptsNavigator does not need to update on EditorClosed.
         this._updateScriptViewStatusBarItems();
+        WebInspector.searchController.resetSearch();
     },
 
     _editorSelected: function(event)
@@ -581,6 +582,7 @@ WebInspector.ScriptsPanel.prototype = {
         var sourceFrame = this._showFile(uiSourceCode);
         this._navigatorController.hideNavigatorOverlay();
         sourceFrame.focus();
+        WebInspector.searchController.resetSearch();
     },
 
     _scriptSelected: function(event)
@@ -878,9 +880,8 @@ WebInspector.ScriptsPanel.prototype = {
 
     /**
      * @param {string} query
-     * @param {boolean} loop
      */
-    performSearch: function(query, loop)
+    performSearch: function(query)
     {
         WebInspector.searchController.updateSearchMatchesCount(0, this);
 
@@ -899,57 +900,46 @@ WebInspector.ScriptsPanel.prototype = {
                 return;
 
             WebInspector.searchController.updateSearchMatchesCount(searchMatches, this);
-            view.jumpToNextSearchResult(loop);
+            view.jumpToNextSearchResult();
             WebInspector.searchController.updateCurrentMatchIndex(view.currentSearchResultIndex, this);
         }
 
         this._searchView.performSearch(query, finishedCallback.bind(this));
     },
 
-    /**
-     * @param {boolean} loop
-     * @return {boolean}
-     */
-    jumpToNextSearchResult: function(loop)
+    jumpToNextSearchResult: function()
     {
         if (!this._searchView)
-            return false;
+            return;
 
         if (this._searchView !== this.visibleView) {
-            this.performSearch(this._searchQuery, loop);
-            return false;
+            this.performSearch(this._searchQuery);
+            return;
         }
 
-        if (this._searchView.showingLastSearchResult()) {
-            if (!loop)
-                return false;
+        if (this._searchView.showingLastSearchResult())
             this._searchView.jumpToFirstSearchResult();
-        else
+        else
             this._searchView.jumpToNextSearchResult();
         WebInspector.searchController.updateCurrentMatchIndex(this._searchView.currentSearchResultIndex, this);
         return true;
     },
 
-    /**
-     * @param {boolean} loop
-     */
-    jumpToPreviousSearchResult: function(loop)
+    jumpToPreviousSearchResult: function()
     {
         if (!this._searchView)
             return false;
 
         if (this._searchView !== this.visibleView) {
-            this.performSearch(this._searchQuery, loop);
+            this.performSearch(this._searchQuery);
             if (this._searchView)
                 this._searchView.jumpToLastSearchResult();
             return;
         }
 
-        if (this._searchView.showingFirstSearchResult()) {
-            if (!loop)
-                return false;
+        if (this._searchView.showingFirstSearchResult())
             this._searchView.jumpToLastSearchResult();
-        else
+        else
             this._searchView.jumpToPreviousSearchResult();
         WebInspector.searchController.updateCurrentMatchIndex(this._searchView.currentSearchResultIndex, this);
     },
@@ -968,7 +958,7 @@ WebInspector.ScriptsPanel.prototype = {
      */
     replaceSelectionWith: function(text)
     {
-        var view = /** @type {WebInspector.SourceFrame} */ this._searchView;
+        var view = /** @type {WebInspector.SourceFrame} */ this.visibleView;
         view.replaceSearchMatchWith(text);
     },
 
@@ -978,7 +968,7 @@ WebInspector.ScriptsPanel.prototype = {
      */
     replaceAllWith: function(query, text)
     {
-        var view = /** @type {WebInspector.SourceFrame} */ this._searchView;
+        var view = /** @type {WebInspector.SourceFrame} */ this.visibleView;
         view.replaceAllWith(query, text);
     },
 
index 6f4ec79..d18e280 100644 (file)
  */
 WebInspector.SearchController = function()
 {
-    this._element = document.createElement("div");
+    this._element = document.createElement("table");
     this._element.className = "toolbar-search";
+    this._element.cellSpacing = 0;
 
-    var labelElement = this._element.createChild("span");
-    labelElement.textContent = WebInspector.UIString("Find");
-
-    this._searchControlElement = this._element.createChild("div", "toolbar-search-control");
+    this._firstRowElement = this._element.createChild("tr");
+    this._secondRowElement = this._element.createChild("tr", "hidden");
 
+    // Column 1
+    this._searchControlElement = this._firstRowElement.createChild("td").createChild("span", "toolbar-search-control");
     this._searchInputElement = this._searchControlElement.createChild("input", "search-replace");
     this._searchInputElement.id = "search-input-field";
+    this._searchInputElement.placeholder = WebInspector.UIString("Find");
 
     this._matchesElement = this._searchControlElement.createChild("label", "search-results-matches");
     this._matchesElement.setAttribute("for", "search-input-field");
@@ -62,38 +64,50 @@ WebInspector.SearchController = function()
     this._searchInputElement.addEventListener("keydown", this._onKeyDown.bind(this), true);
     this._searchInputElement.addEventListener("input", this._onInput.bind(this), false);
 
-    this._replaceElement = this._element.createChild("span");
-
-    this._replaceCheckboxElement = this._replaceElement.createChild("input");
-    this._replaceCheckboxElement.type = "checkbox";
-    this._replaceCheckboxElement.id = "search-replace-trigger";
-    this._replaceCheckboxElement.tabIndex = -1;
-    this._replaceCheckboxElement.addEventListener("click", this._toggleReplaceVisibility.bind(this), false);
-
-    this._replaceLabelElement = this._replaceElement.createChild("label");
-    this._replaceLabelElement.textContent = WebInspector.UIString("Replace");
-    this._replaceLabelElement.setAttribute("for", "search-replace-trigger");
-
-    this._replaceDetailsElement = this._replaceElement.createChild("span", "hidden");
-
-    this._replaceInputElement = this._replaceDetailsElement.createChild("input", "search-replace toolbar-replace-control");
+    this._replaceInputElement = this._secondRowElement.createChild("td").createChild("input", "search-replace toolbar-replace-control");
     this._replaceInputElement.addEventListener("keydown", this._onKeyDown.bind(this), true);
+    this._replaceInputElement.placeholder = WebInspector.UIString("Replace");
+
+    // Column 2
+    this._findButtonElement = this._firstRowElement.createChild("td").createChild("button", "hidden");
+    this._findButtonElement.textContent = WebInspector.UIString("Find");
+    this._findButtonElement.tabIndex = -1;
+    this._findButtonElement.addEventListener("click", this._onNextButtonSearch.bind(this), false);
 
-    this._replaceButtonElement = this._replaceDetailsElement.createChild("button");
+    this._replaceButtonElement = this._secondRowElement.createChild("td").createChild("button");
     this._replaceButtonElement.textContent = WebInspector.UIString("Replace");
+    this._replaceButtonElement.disabled = true;
+    this._replaceButtonElement.tabIndex = -1;
     this._replaceButtonElement.addEventListener("click", this._replace.bind(this), false);
 
-    this._skipButtonElement = this._replaceDetailsElement.createChild("button");
-    this._skipButtonElement.textContent = WebInspector.UIString("Skip");
-    this._skipButtonElement.addEventListener("click", this._onNextButtonSearch.bind(this), false);
+    // Column 3
+    this._prevButtonElement = this._firstRowElement.createChild("td").createChild("button", "hidden");
+    this._prevButtonElement.textContent = WebInspector.UIString("Previous");
+    this._prevButtonElement.disabled = true;
+    this._prevButtonElement.tabIndex = -1;
+    this._prevButtonElement.addEventListener("click", this._onPrevButtonSearch.bind(this), false);
 
-    this._replaceAllButtonElement = this._replaceDetailsElement.createChild("button");
+    this._replaceAllButtonElement = this._secondRowElement.createChild("td").createChild("button");
     this._replaceAllButtonElement.textContent = WebInspector.UIString("Replace All");
     this._replaceAllButtonElement.addEventListener("click", this._replaceAll.bind(this), false);
 
-    var closeButtonElement = this._element.createChild("span", "drawer-header-close-button");
-    closeButtonElement.textContent = WebInspector.UIString("\u00D7");
-    closeButtonElement.addEventListener("click", this.cancelSearch.bind(this), false);
+    // Column 4
+    this._replaceElement = this._firstRowElement.createChild("td").createChild("span");
+
+    this._replaceCheckboxElement = this._replaceElement.createChild("input");
+    this._replaceCheckboxElement.type = "checkbox";
+    this._replaceCheckboxElement.id = "search-replace-trigger";
+    this._replaceCheckboxElement.addEventListener("click", this._updateSecondRowVisibility.bind(this), false);
+
+    this._replaceLabelElement = this._replaceElement.createChild("label");
+    this._replaceLabelElement.textContent = WebInspector.UIString("Replace");
+    this._replaceLabelElement.setAttribute("for", "search-replace-trigger");
+
+    // Column 5
+    var cancelButtonElement = this._firstRowElement.createChild("td").createChild("button");
+    cancelButtonElement.textContent = WebInspector.UIString("Cancel");
+    cancelButtonElement.tabIndex = -1;
+    cancelButtonElement.addEventListener("click", this.cancelSearch.bind(this), false);
 }
 
 WebInspector.SearchController.prototype = {
@@ -119,15 +133,20 @@ WebInspector.SearchController.prototype = {
         if (!this._searchIsVisible)
             return;
         delete this._searchIsVisible;
-        this._performSearch("", false, false, false);
         WebInspector.inspectorView.setFooterElement(null);
-        this._replaceCheckboxElement.checked = false;
-        this._toggleReplaceVisibility();
+        this.resetSearch();
+    },
+
+    resetSearch: function()
+    {
+        this._performSearch("", false, false);
+        this._updateReplaceVisibility();
+        this._matchesElement.textContent = "";
     },
 
     disableSearchUntilExplicitAction: function(event)
     {
-        this._performSearch("", false, false, false);
+        this._performSearch("", false, false);
     },
 
     /**
@@ -163,10 +182,9 @@ WebInspector.SearchController.prototype = {
                 var currentPanel = WebInspector.inspectorView.currentPanel();
 
                 if (isMac && event.metaKey && !event.ctrlKey && !event.altKey) {
-                    if (event.shiftKey) {
-                        if (currentPanel.jumpToPreviousSearchResult)
-                            currentPanel.jumpToPreviousSearchResult();
-                    } else if (currentPanel.jumpToNextSearchResult)
+                    if (event.shiftKey)
+                        currentPanel.jumpToPreviousSearchResult();
+                    else
                         currentPanel.jumpToNextSearchResult();
                     event.consume(true);
                     return true;
@@ -178,6 +196,8 @@ WebInspector.SearchController.prototype = {
 
     _updateSearchNavigationButtonState: function(enabled)
     {
+        this._replaceButtonElement.disabled = !enabled;
+        this._prevButtonElement.disabled = !enabled;
         var panel = WebInspector.inspectorView.currentPanel();
         if (enabled) {
             this._searchNavigationPrevElement.addStyleClass("enabled");
@@ -211,10 +231,13 @@ WebInspector.SearchController.prototype = {
     _updateReplaceVisibility: function()
     {
         var panel = WebInspector.inspectorView.currentPanel();
-        if (WebInspector.experimentsSettings.searchReplace.isEnabled() && panel.canSearchAndReplace())
+        if (panel && panel.canSearchAndReplace())
             this._replaceElement.removeStyleClass("hidden");
-        else
+        else {
             this._replaceElement.addStyleClass("hidden");
+            this._replaceCheckboxElement.checked = false;
+            this._updateSecondRowVisibility();
+        }
     },
 
     _onSearchFieldManualFocus: function(event)
@@ -236,7 +259,7 @@ WebInspector.SearchController.prototype = {
 
         if (isEnterKey(event)) {
             if (event.target === this._searchInputElement)
-                this._performSearch(event.target.value, true, event.shiftKey, true);
+                this._performSearch(event.target.value, true, event.shiftKey);
             else if (event.target === this._replaceInputElement)
                 this._replace();
         }
@@ -244,20 +267,22 @@ WebInspector.SearchController.prototype = {
 
     _onInput: function(event)
     {
-        this._performSearch(event.target.value, false, false, true);
+        this._performSearch(event.target.value, false, false);
     },
 
     _onNextButtonSearch: function(event)
     {
         // Simulate next search on search-navigation-button click.
-        this._performSearch(this._searchInputElement.value, true, false, true);
+        this._performSearch(this._searchInputElement.value, true, false);
         this._searchInputElement.focus();
     },
 
     _onPrevButtonSearch: function(event)
     {
+        if (!this._searchNavigationPrevElement.hasStyleClass("enabled"))
+            return;
         // Simulate previous search on search-navigation-button click.
-        this._performSearch(this._searchInputElement.value, true, true, true);
+        this._performSearch(this._searchInputElement.value, true, true);
         this._searchInputElement.focus();
     },
 
@@ -265,9 +290,8 @@ WebInspector.SearchController.prototype = {
      * @param {string} query
      * @param {boolean} forceSearch
      * @param {boolean} isBackwardSearch
-     * @param {boolean} loop
      */
-    _performSearch: function(query, forceSearch, isBackwardSearch, loop)
+    _performSearch: function(query, forceSearch, isBackwardSearch)
     {
         if (!query || !query.length) {
             delete this._currentQuery;
@@ -276,7 +300,7 @@ WebInspector.SearchController.prototype = {
                 var panel = WebInspector.panels[panelName];
                 var hadCurrentQuery = !!panel.currentQuery;
                 delete panel.currentQuery;
-                if (hadCurrentQuery && panel.searchCanceled)
+                if (hadCurrentQuery)
                     panel.searchCanceled();
             }
             this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1);
@@ -289,9 +313,9 @@ WebInspector.SearchController.prototype = {
             // search result for a good user experience.
             if (forceSearch) {
                 if (!isBackwardSearch)
-                    currentPanel.jumpToNextSearchResult(loop);
+                    currentPanel.jumpToNextSearchResult();
                 else if (isBackwardSearch)
-                    currentPanel.jumpToPreviousSearchResult(loop);
+                    currentPanel.jumpToPreviousSearchResult();
             }
             return;
         }
@@ -302,16 +326,29 @@ WebInspector.SearchController.prototype = {
         this._currentQuery = query;
 
         currentPanel.currentQuery = query;
-        currentPanel.performSearch(query, loop);
+        currentPanel.performSearch(query);
     },
 
-    _toggleReplaceVisibility: function()
+    _updateSecondRowVisibility: function()
     {
+        if (!this._searchIsVisible)
+            return;
         if (this._replaceCheckboxElement.checked) {
-            this._replaceDetailsElement.removeStyleClass("hidden");
+            this._element.addStyleClass("toolbar-search-replace");
+            this._secondRowElement.removeStyleClass("hidden");
+            this._prevButtonElement.removeStyleClass("hidden");
+            this._findButtonElement.removeStyleClass("hidden");
+            this._replaceCheckboxElement.tabIndex = -1;
             this._replaceInputElement.focus();
-        } else
-            this._replaceDetailsElement.addStyleClass("hidden");
+        } else {
+            this._element.removeStyleClass("toolbar-search-replace");
+            this._secondRowElement.addStyleClass("hidden");
+            this._prevButtonElement.addStyleClass("hidden");
+            this._findButtonElement.addStyleClass("hidden");
+            this._replaceCheckboxElement.tabIndex = 0;
+            this._searchInputElement.focus();
+        }
+        WebInspector.inspectorView.setFooterElement(this._element);
     },
 
     _replace: function()
@@ -320,13 +357,13 @@ WebInspector.SearchController.prototype = {
         currentPanel.replaceSelectionWith(this._replaceInputElement.value);
         var query = this._currentQuery;
         delete this._currentQuery;
-        this._performSearch(query, true, false, false);
+        this._performSearch(query, true, false);
     },
 
     _replaceAll: function()
     {
         var currentPanel = WebInspector.inspectorView.currentPanel();
-        currentPanel.replaceAllWith(this._currentQuery, this._replaceInputElement.value);
+        currentPanel.replaceAllWith(this._searchInputElement.value, this._replaceInputElement.value);
     }
 }
 
index ba0b266..963d1f0 100644 (file)
@@ -188,7 +188,6 @@ WebInspector.ExperimentsSettings = function()
     this.liveNativeMemoryChart = this._createExperiment("liveNativeMemoryChart", "Live native memory chart");
     this.fileSystemInspection = this._createExperiment("fileSystemInspection", "FileSystem inspection");
     this.mainThreadMonitoring = this._createExperiment("mainThreadMonitoring", "Show CPU activity in Timeline");
-    this.searchReplace = this._createExperiment("searchReplace", "Search / Replace");
 
     this._cleanUpSetting();
 }
index a8994f9..2037186 100644 (file)
@@ -270,12 +270,9 @@ WebInspector.SourceFrame.prototype = {
         this._innerSetSelectionIfNeeded();
     },
 
-    /**
-     * @param {boolean} userInput
-     */
-    beforeTextChanged: function(userInput)
+    beforeTextChanged: function()
     {
-        if (userInput)
+        if (!this._isReplacing)
             WebInspector.searchController.cancelSearch();
         this.clearMessages();
     },
@@ -355,7 +352,7 @@ WebInspector.SourceFrame.prototype = {
 
             if (shiftToIndex)
                 this._searchResults = this._searchResults.rotate(shiftToIndex);
-            
+
             callback(this, this._searchResults.length);
         }
 
@@ -431,17 +428,16 @@ WebInspector.SourceFrame.prototype = {
      */
     replaceSearchMatchWith: function(text)
     {
-        this.beforeTextChanged(false);
-
         var range = this._searchResults[this._currentSearchResultIndex];
         if (!range)
             return;
         this._textEditor.markAndRevealRange(null);
-        var newRange = this._textModel.editRange(range, text);
-        this.afterTextChanged(range, newRange);
 
-        // Collapse current match so that we don't replace things twice. 
-        this._textEditor.markAndRevealRange(newRange.collapseToEnd());
+        this._isReplacing = true;
+        var newRange = this._textEditor.editRange(range, text);
+        delete this._isReplacing;
+
+        this._textEditor.setSelection(newRange.collapseToEnd());
     },
 
     /**
@@ -450,12 +446,15 @@ WebInspector.SourceFrame.prototype = {
      */
     replaceAllWith: function(query, replacement)
     {
-        this.beforeTextChanged(false);
+        this._textEditor.markAndRevealRange(null);
+
         var text = this._textModel.text();
         var range = this._textModel.range();
         text = text.replace(WebInspector.SourceFrame.createSearchRegex(query, "g"), replacement);
-        var newRange = this._textModel.editRange(range, text);
-        this.afterTextChanged(range, newRange);
+
+        this._isReplacing = true;
+        this._textEditor.editRange(range, text);
+        delete this._isReplacing;
     },
 
     _collectRegexMatches: function(regexObject)
@@ -645,7 +644,7 @@ WebInspector.TextEditorDelegateForSourceFrame = function(sourceFrame)
 WebInspector.TextEditorDelegateForSourceFrame.prototype = {
     beforeTextChanged: function()
     {
-        this._sourceFrame.beforeTextChanged(true);
+        this._sourceFrame.beforeTextChanged();
     },
 
     afterTextChanged: function(oldRange, newRange)
index 9ca824d..fa6f4d2 100644 (file)
@@ -232,6 +232,20 @@ WebInspector.TextEditor.prototype = {
         this._updatePanelOffsets();
     },
 
+    /**
+     * @param {WebInspector.TextRange} range
+     * @param {string} text
+     * @return {WebInspector.TextRange}
+     */
+    editRange: function(range, text)
+    {
+        this._enterInternalTextChangeMode();
+        this._textModel.markUndoableState();
+        var newRange = this._textModel.editRange(range, text);
+        this._exitInternalTextChangeMode(range, newRange);
+        return newRange;
+    },
+
     _enterInternalTextChangeMode: function()
     {
         this._internalTextChangeMode = true;
index f8faae1..a9a0ec5 100644 (file)
@@ -269,14 +269,20 @@ body.detached.platform-mac-snowleopard #toolbar-dropdown {
     padding: 0 2px;
     margin: 0;
     width: 165px;
-    position: relative;
-    top: 1px;
 }
 
 .search-replace:focus {
     outline: none;
 }
 
+.toolbar-search {
+    border-spacing: 1px;
+}
+
+.toolbar-search td {
+    padding: 0 5px 0 0;
+}
+
 .toolbar-search-navigation-controls {
     position: absolute;
     top: 0;
@@ -299,11 +305,6 @@ body.detached.platform-mac-snowleopard #toolbar-dropdown {
     opacity: 1.0;
 }
 
-.toolbar-search {
-    line-height: 19px;
-    height: 22px;
-}
-
 .toolbar-search input[type="checkbox"] {
     position: relative;
     margin-top: -1px;
@@ -314,9 +315,10 @@ body.detached.platform-mac-snowleopard #toolbar-dropdown {
 .toolbar-search button {
     border: 1px solid rgb(163, 163, 163);
     border-radius: 12px;
-    margin: 0 0 0 6px;
+    margin: 0 6px;
     font-size: 11px;
     background-image: -webkit-linear-gradient(rgb(241, 241, 241), rgb(220, 220, 220));
+    width: 100%;
 }
 
 .toolbar-search button:active {
@@ -328,17 +330,16 @@ body.detached.platform-mac-snowleopard #toolbar-dropdown {
     position: relative;
     background-color: white;
     border: 1px solid rgb(163, 163, 163);
-    margin: 1px 2px 1px 5px;
     height: 20px;
     border-radius: 2px;
-    padding-right: 36px;
+    padding-top: 1px;
 }
 
 .toolbar-replace-control {
     border: 1px solid rgb(163, 163, 163);
     height: 20px;
     border-radius: 2px;
-    margin-left: 5px;
+    width: 100%;
 }
 
 .toolbar-search-navigation.enabled:active {
@@ -2866,5 +2867,4 @@ body.platform-mac #drawer-status-bar .search-status-bar-progress {
     right: 0;
     font-size: 11px;
     height: auto;
-    padding-left: 5px;
 }