Title: [96580] trunk/Source/WebCore
Revision
96580
Author
pfeld...@chromium.org
Date
2011-10-04 03:05:46 -0700 (Tue, 04 Oct 2011)

Log Message

Web Inspector: move abstract panel search logic into the only view that is using it.
https://bugs.webkit.org/show_bug.cgi?id=69328

Reviewed by Yury Semikhatsky.

* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.searchCanceled):
(WebInspector.Panel.prototype.performSearch):
(WebInspector.Panel.prototype.jumpToNextSearchResult):
(WebInspector.Panel.prototype.jumpToPreviousSearchResult):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype.performSearch.updateMatchesCount):
(WebInspector.ProfilesPanel.prototype.performSearch.updateMatchesCountSoon):
(WebInspector.ProfilesPanel.prototype.performSearch.finishedCallback):
(WebInspector.ProfilesPanel.prototype.performSearch.processChunk):
(WebInspector.ProfilesPanel.prototype.performSearch):
(WebInspector.ProfilesPanel.prototype.jumpToNextSearchResult):
(WebInspector.ProfilesPanel.prototype.jumpToPreviousSearchResult):
(WebInspector.ProfilesPanel.prototype._searchableViews):
(WebInspector.ProfilesPanel.prototype.searchCanceled):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (96579 => 96580)


--- trunk/Source/WebCore/ChangeLog	2011-10-04 09:51:47 UTC (rev 96579)
+++ trunk/Source/WebCore/ChangeLog	2011-10-04 10:05:46 UTC (rev 96580)
@@ -1,5 +1,28 @@
 2011-10-04  Pavel Feldman  <pfeld...@google.com>
 
+        Web Inspector: move abstract panel search logic into the only view that is using it.
+        https://bugs.webkit.org/show_bug.cgi?id=69328
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.searchCanceled):
+        (WebInspector.Panel.prototype.performSearch):
+        (WebInspector.Panel.prototype.jumpToNextSearchResult):
+        (WebInspector.Panel.prototype.jumpToPreviousSearchResult):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype.performSearch.updateMatchesCount):
+        (WebInspector.ProfilesPanel.prototype.performSearch.updateMatchesCountSoon):
+        (WebInspector.ProfilesPanel.prototype.performSearch.finishedCallback):
+        (WebInspector.ProfilesPanel.prototype.performSearch.processChunk):
+        (WebInspector.ProfilesPanel.prototype.performSearch):
+        (WebInspector.ProfilesPanel.prototype.jumpToNextSearchResult):
+        (WebInspector.ProfilesPanel.prototype.jumpToPreviousSearchResult):
+        (WebInspector.ProfilesPanel.prototype._searchableViews):
+        (WebInspector.ProfilesPanel.prototype.searchCanceled):
+
+2011-10-04  Pavel Feldman  <pfeld...@google.com>
+
         Not reviewed: fixed poor inspector merge, drive-by front-endcompilation fix.
 
         * inspector/front-end/ContentProviders.js:

Modified: trunk/Source/WebCore/inspector/front-end/Panel.js (96579 => 96580)


--- trunk/Source/WebCore/inspector/front-end/Panel.js	2011-10-04 09:51:47 UTC (rev 96579)
+++ trunk/Source/WebCore/inspector/front-end/Panel.js	2011-10-04 10:05:46 UTC (rev 96580)
@@ -108,171 +108,21 @@
 
     searchCanceled: function()
     {
-        if (this._searchResults) {
-            for (var i = 0; i < this._searchResults.length; ++i) {
-                var view = this._searchResults[i];
-                if (view.searchCanceled)
-                    view.searchCanceled();
-                delete view.currentQuery;
-            }
-        }
-
         WebInspector.searchController.updateSearchMatchesCount(0, this);
-
-        if (this._currentSearchChunkIntervalIdentifier) {
-            clearInterval(this._currentSearchChunkIntervalIdentifier);
-            delete this._currentSearchChunkIntervalIdentifier;
-        }
-
-        this._totalSearchMatches = 0;
-        this._currentSearchResultIndex = 0;
-        this._searchResults = [];
     },
 
     performSearch: function(query)
     {
         // Call searchCanceled since it will reset everything we need before doing a new search.
-        this.searchCanceled(true);
-
-        var searchableViews = this.searchableViews;
-        if (!searchableViews || !searchableViews.length)
-            return;
-
-        var parentElement = this.viewsContainerElement;
-        var visibleView = this.visibleView;
-        var sortFuction = this.searchResultsSortFunction;
-
-        var matchesCountUpdateTimeout = null;
-
-        function updateMatchesCount()
-        {
-            WebInspector.searchController.updateSearchMatchesCount(this._totalSearchMatches, this);
-            matchesCountUpdateTimeout = null;
-        }
-
-        function updateMatchesCountSoon()
-        {
-            if (matchesCountUpdateTimeout)
-                return;
-            // Update the matches count every half-second so it doesn't feel twitchy.
-            matchesCountUpdateTimeout = setTimeout(updateMatchesCount.bind(this), 500);
-        }
-
-        function finishedCallback(view, searchMatches)
-        {
-            if (!searchMatches)
-                return;
-
-            this._totalSearchMatches += searchMatches;
-            this._searchResults.push(view);
-
-            if (sortFuction)
-                this._searchResults.sort(sortFuction);
-
-            if (this.searchMatchFound)
-                this.searchMatchFound(view, searchMatches);
-
-            updateMatchesCountSoon.call(this);
-
-            if (view === visibleView)
-                view.jumpToFirstSearchResult();
-        }
-
-        var i = 0;
-        var panel = this;
-        var boundFinishedCallback = finishedCallback.bind(this);
-        var chunkIntervalIdentifier = null;
-
-        // Split up the work into chunks so we don't block the
-        // UI thread while processing.
-
-        function processChunk()
-        {
-            var view = searchableViews[i];
-
-            if (++i >= searchableViews.length) {
-                if (panel._currentSearchChunkIntervalIdentifier === chunkIntervalIdentifier)
-                    delete panel._currentSearchChunkIntervalIdentifier;
-                clearInterval(chunkIntervalIdentifier);
-            }
-
-            if (!view)
-                return;
-
-            view.currentQuery = query;
-            view.performSearch(query, boundFinishedCallback);
-        }
-
-        processChunk();
-
-        chunkIntervalIdentifier = setInterval(processChunk, 25);
-        this._currentSearchChunkIntervalIdentifier = chunkIntervalIdentifier;
+        this.searchCanceled();
     },
 
     jumpToNextSearchResult: function()
     {
-        if (!this.showView || !this._searchResults || !this._searchResults.length)
-            return;
-
-        var showFirstResult = false;
-
-        this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
-        if (this._currentSearchResultIndex === -1) {
-            this._currentSearchResultIndex = 0;
-            showFirstResult = true;
-        }
-
-        var currentView = this._searchResults[this._currentSearchResultIndex];
-
-        if (currentView.showingLastSearchResult()) {
-            if (++this._currentSearchResultIndex >= this._searchResults.length)
-                this._currentSearchResultIndex = 0;
-            currentView = this._searchResults[this._currentSearchResultIndex];
-            showFirstResult = true;
-        }
-
-        if (currentView !== this.visibleView) {
-            this.showView(currentView);
-            WebInspector.searchController.focusSearchField();
-        }
-
-        if (showFirstResult)
-            currentView.jumpToFirstSearchResult();
-        else
-            currentView.jumpToNextSearchResult();
     },
 
     jumpToPreviousSearchResult: function()
     {
-        if (!this.showView || !this._searchResults || !this._searchResults.length)
-            return;
-
-        var showLastResult = false;
-
-        this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
-        if (this._currentSearchResultIndex === -1) {
-            this._currentSearchResultIndex = 0;
-            showLastResult = true;
-        }
-
-        var currentView = this._searchResults[this._currentSearchResultIndex];
-
-        if (currentView.showingFirstSearchResult()) {
-            if (--this._currentSearchResultIndex < 0)
-                this._currentSearchResultIndex = (this._searchResults.length - 1);
-            currentView = this._searchResults[this._currentSearchResultIndex];
-            showLastResult = true;
-        }
-
-        if (currentView !== this.visibleView) {
-            this.showView(currentView);
-            WebInspector.searchController.focusSearchField();
-        }
-
-        if (showLastResult)
-            currentView.jumpToLastSearchResult();
-        else
-            currentView.jumpToPreviousSearchResult();
     },
 
     createSidebar: function(parentElement, resizerParentElement)

Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (96579 => 96580)


--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js	2011-10-04 09:51:47 UTC (rev 96579)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js	2011-10-04 10:05:46 UTC (rev 96580)
@@ -538,8 +538,153 @@
         return title;
     },
 
-    get searchableViews()
+    performSearch: function(query)
     {
+        this.searchCanceled();
+
+        var searchableViews = this._searchableViews();
+        if (!searchableViews || !searchableViews.length)
+            return;
+
+        var parentElement = this.viewsContainerElement;
+        var visibleView = this.visibleView;
+        var sortFuction = this.searchResultsSortFunction;
+
+        var matchesCountUpdateTimeout = null;
+
+        function updateMatchesCount()
+        {
+            WebInspector.searchController.updateSearchMatchesCount(this._totalSearchMatches, this);
+            matchesCountUpdateTimeout = null;
+        }
+
+        function updateMatchesCountSoon()
+        {
+            if (matchesCountUpdateTimeout)
+                return;
+            // Update the matches count every half-second so it doesn't feel twitchy.
+            matchesCountUpdateTimeout = setTimeout(updateMatchesCount.bind(this), 500);
+        }
+
+        function finishedCallback(view, searchMatches)
+        {
+            if (!searchMatches)
+                return;
+
+            this._totalSearchMatches += searchMatches;
+            this._searchResults.push(view);
+
+            if (sortFuction)
+                this._searchResults.sort(sortFuction);
+
+            if (this.searchMatchFound)
+                this.searchMatchFound(view, searchMatches);
+
+            updateMatchesCountSoon.call(this);
+
+            if (view === visibleView)
+                view.jumpToFirstSearchResult();
+        }
+
+        var i = 0;
+        var panel = this;
+        var boundFinishedCallback = finishedCallback.bind(this);
+        var chunkIntervalIdentifier = null;
+
+        // Split up the work into chunks so we don't block the
+        // UI thread while processing.
+
+        function processChunk()
+        {
+            var view = searchableViews[i];
+
+            if (++i >= searchableViews.length) {
+                if (panel._currentSearchChunkIntervalIdentifier === chunkIntervalIdentifier)
+                    delete panel._currentSearchChunkIntervalIdentifier;
+                clearInterval(chunkIntervalIdentifier);
+            }
+
+            if (!view)
+                return;
+
+            view.currentQuery = query;
+            view.performSearch(query, boundFinishedCallback);
+        }
+
+        processChunk();
+
+        chunkIntervalIdentifier = setInterval(processChunk, 25);
+        this._currentSearchChunkIntervalIdentifier = chunkIntervalIdentifier;
+    },
+
+    jumpToNextSearchResult: function()
+    {
+        if (!this.showView || !this._searchResults || !this._searchResults.length)
+            return;
+
+        var showFirstResult = false;
+
+        this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
+        if (this._currentSearchResultIndex === -1) {
+            this._currentSearchResultIndex = 0;
+            showFirstResult = true;
+        }
+
+        var currentView = this._searchResults[this._currentSearchResultIndex];
+
+        if (currentView.showingLastSearchResult()) {
+            if (++this._currentSearchResultIndex >= this._searchResults.length)
+                this._currentSearchResultIndex = 0;
+            currentView = this._searchResults[this._currentSearchResultIndex];
+            showFirstResult = true;
+        }
+
+        if (currentView !== this.visibleView) {
+            this.showView(currentView);
+            WebInspector.searchController.focusSearchField();
+        }
+
+        if (showFirstResult)
+            currentView.jumpToFirstSearchResult();
+        else
+            currentView.jumpToNextSearchResult();
+    },
+
+    jumpToPreviousSearchResult: function()
+    {
+        if (!this.showView || !this._searchResults || !this._searchResults.length)
+            return;
+
+        var showLastResult = false;
+
+        this._currentSearchResultIndex = this._searchResults.indexOf(this.visibleView);
+        if (this._currentSearchResultIndex === -1) {
+            this._currentSearchResultIndex = 0;
+            showLastResult = true;
+        }
+
+        var currentView = this._searchResults[this._currentSearchResultIndex];
+
+        if (currentView.showingFirstSearchResult()) {
+            if (--this._currentSearchResultIndex < 0)
+                this._currentSearchResultIndex = (this._searchResults.length - 1);
+            currentView = this._searchResults[this._currentSearchResultIndex];
+            showLastResult = true;
+        }
+
+        if (currentView !== this.visibleView) {
+            this.showView(currentView);
+            WebInspector.searchController.focusSearchField();
+        }
+
+        if (showLastResult)
+            currentView.jumpToLastSearchResult();
+        else
+            currentView.jumpToPreviousSearchResult();
+    },
+
+    _searchableViews: function()
+    {
         var views = [];
 
         const visibleView = this.visibleView;
@@ -563,10 +708,28 @@
         view.profile._profilesTreeElement.searchMatches = matches;
     },
 
-    searchCanceled: function(startingNewSearch)
+    searchCanceled: function()
     {
-        WebInspector.Panel.prototype.searchCanceled.call(this, startingNewSearch);
+        if (this._searchResults) {
+            for (var i = 0; i < this._searchResults.length; ++i) {
+                var view = this._searchResults[i];
+                if (view.searchCanceled)
+                    view.searchCanceled();
+                delete view.currentQuery;
+            }
+        }
 
+        WebInspector.Panel.prototype.searchCanceled.call(this);
+
+        if (this._currentSearchChunkIntervalIdentifier) {
+            clearInterval(this._currentSearchChunkIntervalIdentifier);
+            delete this._currentSearchChunkIntervalIdentifier;
+        }
+
+        this._totalSearchMatches = 0;
+        this._currentSearchResultIndex = 0;
+        this._searchResults = [];
+
         if (!this._profiles)
             return;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to