Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: Source/WebCore/inspector/front-end/ScriptsSearchScope.js

Issue 8381041: Merge 98105 - Web Inspector: Advanced search is working very slowly and does not show searching p... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/912/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/inspector/front-end/ScriptsSearchScope.js
===================================================================
--- Source/WebCore/inspector/front-end/ScriptsSearchScope.js (revision 98335)
+++ Source/WebCore/inspector/front-end/ScriptsSearchScope.js (working copy)
@@ -34,53 +34,60 @@
{
// FIXME: Add title once it is used by search controller.
WebInspector.SearchScope.call(this)
+ this._searchId = 0;
}
WebInspector.ScriptsSearchScope.prototype = {
/**
* @param {WebInspector.SearchConfig} searchConfig
* @param {function(Object)} searchResultCallback
- * @param {function()} searchFinishedCallback
+ * @param {function(boolean)} searchFinishedCallback
*/
performSearch: function(searchConfig, searchResultCallback, searchFinishedCallback)
{
- var callbacksLeft = 0;
-
- function maybeSearchFinished()
+ this.stopSearch();
+
+ var uiSourceCodes = this._sortedUISourceCodes();
+ var uiSourceCodeIndex = 0;
+
+ function filterOutContentScripts(uiSourceCode)
{
- if (callbacksLeft === 0)
- searchFinishedCallback();
+ return !uiSourceCode.isContentScript;
}
- function searchCallbackWrapper(uiSourceCode, searchMatches)
+ // FIXME: Add setting to search in content scripts as well.
+ uiSourceCodes.filter(filterOutContentScripts);
+
+ function continueSearch()
{
- if (searchMatches.length) {
- var searchResult = new WebInspector.FileBasedSearchResultsPane.SearchResult(uiSourceCode, searchMatches);
- searchResultCallback(searchResult);
+ // FIXME: Enable support for counting matches for incremental search.
+ // FIXME: Enable support for bounding search results/matches number to keep inspector responsive.
+ if (uiSourceCodeIndex < uiSourceCodes.length) {
+ var uiSourceCode = uiSourceCodes[uiSourceCodeIndex++];
+ uiSourceCode.searchInContent(searchConfig.query, !searchConfig.ignoreCase, searchConfig.isRegex, searchCallbackWrapper.bind(this, this._searchId, uiSourceCode));
+ } else
+ searchFinishedCallback(true);
+ }
+
+ function searchCallbackWrapper(searchId, uiSourceCode, searchMatches)
+ {
+ if (searchId !== this._searchId) {
+ searchFinishedCallback(false);
+ return;
}
- --callbacksLeft;
- maybeSearchFinished();
+
+ var searchResult = new WebInspector.FileBasedSearchResultsPane.SearchResult(uiSourceCode, searchMatches);
+ searchResultCallback(searchResult);
+ continueSearch.call(this);
}
- var uiSourceCodes = this._sortedUISourceCodes();
- // FIXME: Enable support for counting matches for incremental search.
- // FIXME: Enable support for bounding search results/matches number to keep inspector responsive.
- for (var i = 0; i < uiSourceCodes.length; i++) {
- var uiSourceCode = uiSourceCodes[i];
- // FIXME: Add setting to search in content scripts as well.
- if (!uiSourceCode.isContentScript) {
- // Increase callbacksLeft first because searchInContent call could be synchronous.
- callbacksLeft++;
- // FIXME: We should not request next searchInContent unless previous one is already finished.
- uiSourceCode.searchInContent(searchConfig.query, !searchConfig.ignoreCase, searchConfig.isRegex, searchCallbackWrapper.bind(this, uiSourceCode));
- }
- }
- maybeSearchFinished();
+ continueSearch.call(this);
+ return uiSourceCodes.length;
},
stopSearch: function()
{
- // FIXME: Implement search so that it could be stopped.
+ ++this._searchId;
},
/**

Powered by Google App Engine
This is Rietveld 408576698